131 Commits
Author SHA1 Message Date
Tomaž Vajngerl 1ac50fddc7 sc: rewrite the token array into the OOXML shape
OOXML writes @ and # as calls and a reference union as a parenthesised
list, so for each of them we need to know how far the sub-expression
under it reaches. CreateStringFromTokenArray worked that out from the
text it had already written. The problem with this is that every pair
it spliced in shifted all the offsets that were still waiting behind
it, so it kept breaking.

Instead of patching the text, OOXMLRewriter builds a second
token array in the shape OOXML spells out and the writer walks that as
it stands. The call names and the parentheses are ordinary tokens, so
there is nothing to splice and no offsets to keep track of. It is the
same trick RewriteMissing already plays a few lines further up, and it
means the input and the output can be looked at side by side.

The # changes place, from behind its operand to a call in front of it,
so it gets an opcode of its own. _xlfn.ANCHORARRAY spells ocAnchorArray
now, and ocSpill keeps the native postfix spelling with no OOXML one at
all, so the postfix form cannot end up in a file by accident. The
import already rewrote the call back into the postfix operator and now
recognises it by opcode instead of by position. The @ stays
ocSingleValue, it is already in front of its operand so only the
parentheses are new.

The OFFSET() literal argument is swapped for the reference error in
the same pass, instead of the writing loop jumping over tokens.

A unit test drives the rewrite on its own: token array in, token array
out, one case per shape. The shapes that end up with nothing to wrap
are in there too - a lone @, one with a missing argument, and text that
never parsed - since those are the ones where dropping a token is the
only change.

Also drop the dead "@" and "#" rows from the OOXML symbol table, the
rows above them already have _xlfn.SINGLE and _xlfn.ANCHORARRAY.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I63944fb85b5c4388f304f7d94afd0b4f347d7782
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/10155
Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 4feac84950f5b524d99e277481de50f7b45a8d2f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210292
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-08-31 15:56:50 +02:00
Tomaž Vajngerl 44c66f0b84 sc: wrap the whole @ operand in _xlfn.SINGLE, or none of it
The @ operand walk on OOXML save took the token behind the @ as the
whole operand, so any operand longer than one token was cut apart by
the wrapper: a leading sign, a structured table reference, a range
built with the range operator, and a nested @ or # inside an
argument list all left parts of themselves outside.

The @ now writes no text of its own. The main token loop notes where
the wrapper has to go and which parenthesis scope the operand lives
in, and splices _xlfn.SINGLE(...) in once the operand ends. The #
splice already worked that way, so there is one walk with one set of
special cases and no recursion.

Prefix signs and whitespace go inside the wrapper with the operand,
and a sign moves the factor start past itself, so a # wraps the
reference it follows and leaves the sign outside. Table reference
brackets scope like parentheses, which keeps a multi-item reference
whole. AND and OR are written as a name with an argument list, so
such a name does not end the operand either and the whole call stays
inside.

An operand that writes no text leaves the wrapper out. One that is
exactly one parenthesised group lends its parentheses to the
wrapper, so a saved formula keeps its shape over round trips. Text
that never parsed takes no wrapper and drops a # behind it, the way
an ODF save leaves the @ out.

The error strings for tokens the writer cannot spell out sit in
AppendTokenOrError, which tests the cheap conditions first. The
whitespace opcode test moved to opcode.hxx as isWhitespaceOpCode,
replacing the private copies, and the operator range tests join it
there as isUnaryOperatorOpCode and isBinaryOperatorOpCode. Unit
tests pin the saved output for each operand shape.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I9b6c12bbc8d0ddb9efa043a2364d13c4699e7bd5
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/9290
Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit 2b8d9c58e8f7b5f138d44f41d756421c3f7932cd)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209393
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-08-20 18:32:18 +02:00
Tomaž Vajngerl 21b9909afa sc: add the ARRAYTOTEXT function
ARRAYTOTEXT returns a cell range or array as one text string,
taking the range and an optional format number.

Format 0 (or omitted) joins the values in row order with ", ".
Format 1 gives an array constant: braces around the array, ","
between columns, ";" between rows, and text quoted with any
inner double quote doubled. Any other format returns #VALUE!.

A number keeps its input-line text, a boolean reads TRUE or
FALSE in the current locale, an empty cell adds nothing, and an
error in a range lists as its error text while a reference to a
single error cell returns that error.

The function is wired up with its name tables, wizard entry,
parameter classification, and OOXML and binary filter mappings.

A self-checking OOXML workbook is verified after import and
after an XLSX and an ODS round trip, each with a recalc, and the
exported files are checked for the ARRAYTOTEXT formula. A ucalc
test covers the locale-dependent boolean text for a value and
a range.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I0cdd9737a51f402e39cf9a1346f4c5326680fe8f
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/7219
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit f66673d65ee307f17512a4239dd4b52ac189ac20)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208395
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-07-22 08:05:35 +02:00
Tomaž Vajngerl 6612d4f785 sc: add the # postfix operator for spilled-range references
A1# is the postfix counterpart of the @ prefix. When A1 is
the origin of a dynamic-array formula spilled into A1:A4, A1#
refers to the whole spill range, so SUM(A1#) totals the four
values and ROWS(A1#) returns 4.

The new opcode ocSpill sits in the unary-operator range. The
tokenizer produces it from a bare # after a reference or
value. Otherwise # stays the start of a #REF! or #NAME!
token. The compiler routes it through PostOpLine so it
follows its operand in the RPN.

ScSpilledRange pushes the spill range as an ScMatrixRangeToken
so aggregating functions see the whole range, and ISREF
reports it as a reference. A master yields its matrix. A
plain number, string, or non-master matrix slot yields the
the cell value.

A freshly typed =A1# counts as an array result, so it
promotes to a dynamic-array master and spills again. A cell
that does not promote collapses the range by implicit
intersection to the row-aligned value, or #VALUE! outside the
range, keeping that cell's number format.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: Idf2752af3f7575f6bc95b940344aa365415e4a2f
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/5785
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
(cherry picked from commit 9b97b0fc91bce4b8726ea210347e8ea84270e148)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207904
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-07-10 01:08:46 +02:00
Ben Urban 76c9c81b02 Implemented functions which rely on callables
Add BYCOL(tdf#164508), BYROW(tdf#164509), MAKEARRAY(tdf#164511),
MAP(tdf#164512), REDUCE(tdf#164513), SCAN(tdf#161428) formula
functions, which are usually used together with LAMBDA and are
important for interoperability with other Office suites.

Change-Id: I7eb5a992a113638fdadf0cf61592c082094fb44f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205979
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-07-09 08:44:48 +02:00
Ben Urban 331e346fb1 Implemented LAMBDA and ISOMITTED for Calc
Added LAMBDA (tdf#138749) function
Added ISOMITTED (tdf#164510) function
Rewrote LET to work with the new LAMBDA

Change-Id: I45dbf18c43e56c788848f60cd8380dd8d7c476b5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206265
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-07-09 08:43:28 +02:00
Ben Urban 3bdd856e9f Implemented callables as first-class objects in Calc formulas
Three types of callables are available:

* Built-in functions (tdf#164507)

* External functions

* Macro functions

Change-Id: I6311c9412db650cfeb1100497e4ccdc39662c350
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206264
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-07-09 08:42:21 +02:00
Ben Urban 58c2fbaea0 Fixed some typos in comments and metadata for LET
Removed LET from sc/README.md's list of functions supporting
wildcards and regular expressions, since it doesn't interact
with either.

Changed LET's return type from ForceArrayReturn to Value, since
it usually doesn't return an array.

Change-Id: I99168d274483ddea5ba338d4e019cf433fe88c45
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205977
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-06-29 14:45:57 +02:00
Tomaž Vajngerl 6f1fb25a94 sc: add @ prefix operator for opting out of array spill
The @ operator collapses an array operand to its upper-left value.
It is the implicit-intersection prefix used to opt a formula out
of the dynamic-array spill behaviour. =@SEQUENCE(4) returns 1
instead of the four-row spill.

The new ocSingleValue opcode joins the unary-operator range so the
existing compile and interpret machinery treats it like any other
unary prefix. The @ character stops being part of name syntax in
the OOXML grammar, so sheet names that contain @ have to be quoted
from now on.

In-session only for now. The operator is parsed and interpreted
but not yet serialised into XLSX or ODS.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I18cf56e34f933ebb7f6e43c157618c9fe28dbe0f
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/4172
Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit fbd04d7c394ad7445a667bf63820f88551b176e1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206673
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-06-16 09:14:42 +02:00
Noel Grandin 716be93f00 drop the SC_OPCODE constants
now that we have moved the code to use the OpCode oc* constants

Change-Id: I00b0fe8f490803fc9a74f3c7a87d13da4b34ce58
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/1819
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit fc05fda4b467ce7932a6341c8e98469964abdac6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206193
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-06-08 10:09:40 +02:00
Noel Grandin 114bc67a2d Convert from using SC_OPCODE_ constants to use oc* constants
so that we can standardise on a single enum

Change-Id: I2c9347a5ee59c8b8f0bb199b22ea51ca94ecf8c3
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/1795
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit 5b4826b51eee143a564dfa94ed50ab89cc36216b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206192
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-06-08 10:09:29 +02:00
Noel Grandin 0c55b6e0b3 rearrange OpCode order to match SC_OPCODE order
as a prelude to removing the SC_OPCODE constants and
just using a single enum for this stuff.

we need the order to match because when we switch
to using OpCode only, several parts of code check
for ranges of enum values.

Change-Id: I83cdca016b5fe9ab2486385593ab233eff393538
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/1767
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Noel Grandin <noel.grandin@collabora.com>
(cherry picked from commit 4009c9873f1c32f23b43fd51bd15dc159bae5b98)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206191
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-06-08 10:09:19 +02:00
Tomaž Vajngerl bcbd784ca8 sc: Add #SPILL! error if a Calc array formula spills (is blocked)
If there is content in the way where an array formula would write
it's result, don't just overwrite the content, but produce a spill
error instead (#SPILL!) in the first cell of the array.

Change-Id: Ic2c31d638e2d4e51078a466e7f7b6f04ca6de417
Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/1727
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit a564bb54cb40af3ccf1c8e6c9ba4c56ae8b56da4)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204872
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-05-06 20:45:04 +02:00
Karthik Godha 1f5c17cc84 sc: Add new ocUDExternal token for user-defined functions
Excel uses "_xludf." prefix for formulas containing unkown external
functions. A new token ocUDExternal is created to handle unknown
external functions

bug-document: forum-mso-en4-352508.xls
Change-Id: If08469e496ff76bb8b912211bd82c67363711d74
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199631
Reviewed-by: Balazs Varga <balazs.varga@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204130
Tested-by: Jenkins
2026-04-23 12:44:43 +02:00
Balazs Varga 6a69c9e2ac tdf#78486 sc: add pivot table calculated field support (core + OOXML)
Introduce calculated field infrastructure across the pivot table stack:
cache (ScDPCache::CalculatedField), filtered cache, data sources
(ScSheetDPData, ScDatabaseDPData, ScDPGroupTableData), result
calculation (ScDPTabRes), dimension supplier (ScDPSource), and
save/restore (ScDPDimCalcSaveData). Add new ocDPFieldName opcode
and formula compiler support for pivot field references.
Handle OOXML import/export of pivot calculated fields.

Change-Id: I42d094122d547b8ee9a2b63f809bdb13127f8f01
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197913
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga@collabora.com>
2026-03-13 08:05:40 +01:00
Noel Grandin a465133a02 Revert "replace SC_OPCODE* with oc* constants (1)"
This reverts commit 23ef4be9b8.

Revert for this now, I messed up some of the search and replace and renamed things I did not intend to touch,

Change-Id: Ibf862fc3559f41bf200ec2ca50a5369bb356b4f8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201564
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-03-12 20:58:59 +01:00
Noel Grandin 23ef4be9b8 replace SC_OPCODE* with oc* constants (1)
I note in moving comments around to preserve them that ocXor
is in the wrong place, but it has always been that way, so I will
leave it alone.

Change-Id: Ia5fd59e96c478fe5f30788554cc260059a1c46e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201510
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-03-12 09:06:58 +01:00
Noel Grandin 9cf8591e35 ocCall is dead
since
  commit 2c8fe2e737
  Author: Noel Grandin <noel@peralex.com>
  Date:   Mon May 16 10:11:04 2016 +0200
  update unusedmethods plugin to deal with constructors

Change-Id: I1730eafc44516bfcf4095d08c93616ec16fa58f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201492
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-03-12 06:43:36 +01:00
Daniel Lee 63b5081fd8 tdf#143148: Use pragma once instead of include guards
Replace include guards with pragma once in include/formula

Change-Id: I54346cb2f400cf3da9dadbe2eb73cdb25991229c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193011
Tested-by: Jenkins
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
2025-10-31 11:24:22 +01:00
Xisco Fauli fd0cc5b2d3 tdf#150865: Add support for TEXTAFTER function
Change-Id: Iedd79b069c145de4c3b70d50552df8bf7da66a1e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185218
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2025-05-12 16:13:32 +02:00
Xisco Fauli 09a285319b tdf#150864: Add support for TEXTBEFORE function
Change-Id: I57a19add67b4ffff12fa8af575d997bcda378a4e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185206
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2025-05-12 15:48:22 +02:00
Xisco Fauli 4c2596a4b5 tdf#150866: Add support for TEXTSPLIT function
Change-Id: I918b46c29791f865e841eb967b2799f7986538bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185027
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
2025-05-09 08:09:54 +02:00
Xisco Fauli 9c35a5990c tdf#150867: Add support for VSTACK function
Change-Id: I76e3267f45a0d035f6a79af934b9ce2c606b4b89
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181120
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2025-02-04 17:26:01 +01:00
Xisco Fauli 094e26cd98 tdf#150868: Add support for HSTACK function
Change-Id: I105ffabc8dd1fa58bf3acec4a81c3217061d3a26
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181100
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2025-02-04 17:16:15 +01:00
Xisco Fauli d595e1aa41 tdf#151000: Add support for CHOOSECOLS function
Change-Id: Id183f79a148080adebe652f63e29716910c638b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180992
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2025-02-01 09:06:05 +01:00
Xisco Fauli e1d250ff2e tdf#150999: Add support for CHOOSEROWS function
Change-Id: If7de1b243a6040424a5712ba28017176b7e36101
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180955
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2025-01-30 21:39:02 +01:00
Xisco Fauli 5506dd8bcf tdf#151001: Add support for EXPAND function
Change-Id: I4eabd526d656c13da7792d3c195f036ce78bd0d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180706
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2025-01-24 16:57:21 +01:00
Xisco Fauli 9bf96332b5 tdf#150998: Add support for DROP function
Change-Id: Id84cbf25e655410c3fac655cd88f1d74dc98defd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180673
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2025-01-24 10:08:51 +01:00
Xisco Fauli e820e7a33b tdf#150997: Add support for TAKE function
Change-Id: I2e7d223707941d31db0330282f783e845497130b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180622
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2025-01-23 19:57:59 +01:00
Xisco Fauli 5f8a153826 tdf#150880: Add support for WRAPROWS function
Change-Id: I44341835403c068a61cfb79185aeabe6daf32f70
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180598
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2025-01-22 18:37:03 +01:00
Xisco Fauli 99e09f215d tdf#150881: Add support for WRAPCOLS function
Change-Id: Ie152a83dcb7bf16f7a92ab55fd801270658a2e9e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180365
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2025-01-22 12:23:40 +01:00
Xisco Fauli 6b620171f6 tdf#150878: Add support for TOROW function
Change-Id: Ic1acb5c2fd08ecab7c3ee059888cf44aa45ee287
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180308
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2025-01-16 14:13:20 +01:00
Xisco Fauli ee05b94e71 tdf#150879: Add support for TOCOL function
Change-Id: I0c8bfdd8f9b806a1260cceace1ced4be2b046abb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180245
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2025-01-15 15:20:12 +01:00
Balazs Varga 521a56d8d1 tdf#137543 - Add new LET function to Calc
Add new LET function to Calc which assigns names to calculation results.

TODO: oasis proposal

Change-Id: Ia0d56a30751a44a72e364a28b64fd8f617e997dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168349
Tested-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
2024-06-06 09:09:47 +02:00
Balazs Varga c1565b8b94 tdf#126573 Add Excel2021 array function UNIQUE to Calc
Add new function called UNIQUE to the function list.

(TODO: dynamic array in separate patch, oasis proposal)

Change-Id: Ie138aee545995d4af1e66be5a4cf4e99e6e2f581
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167484
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
2024-05-15 18:10:54 +02:00
Balazs Varga d68f2394af tdf#126573 Add Excel2021 array function RANDARRAY to Calc
Add new function called RANDARRAY to the function list.

(TODO: dynamic array in separate patch, oasis proposal)

Change-Id: I34bad3b7e8d631d649a0350d7c1170b26161331d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167003
Tested-by: Jenkins
Tested-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
2024-05-08 17:45:36 +02:00
Balazs Varga 35772a003b tdf#126573 Add Excel2021 array function SEQUENCE to Calc
Add new function called SEQUENCE to the function list.

(TODO: dynamic array in separate patch, oasis proposal)

Change-Id: I9fa6f2c83536536987542cc00a9eec5c196ada8d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166245
Tested-by: Jenkins
Tested-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
2024-04-26 09:33:23 +02:00
Balazs Varga bfb4c58ae7 tdf#126573 Add Excel2021 array function SORTBY to Calc
TODO/WIP: oasis proposal
More information about how this new function works:
https://support.microsoft.com/en-au/office/sortby-function-cd2d7a62-1b93-435c-b561-d6a35134f28f
https://exceljet.net/functions/sortby-function

Change-Id: I4538a32f7f75056d3055369fc5f4483d24fd1089
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165069
Tested-by: Jenkins
Tested-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
2024-03-26 10:20:38 +01:00
Balazs Varga 45435a680b tdf#126573 Add Excel2021 array function SORT to Calc
TODO/WIP: oasis proposal
More information about how this new function works:
https://support.microsoft.com/en-au/office/sort-function-22f63bd0-ccc8-492f-953d-c20e8e44b86c
https://exceljet.net/functions/sort-function

Note: Move ScSortInfoArray class to sortparam.hxx, which is a more
logical place.

Change-Id: I70e720e93ba0414d54cb3437de0bfa066508fe30
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164778
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
2024-03-25 15:54:01 +01:00
Balazs Varga b0791dd921 tdf#126573 Add Excel2021 array function FILTER to Calc
https://issues.oasis-open.org/browse/OFFICE-4156

TODO: add dynamic arrays would be useful: Older array formulas,
known as legacy array formulas, always return a fixed-size result
- they always spill into the same number of cells. The spilling behavior
described in this topic does not apply to legacy array formulas.

More info about it:
https://support.microsoft.com/en-gb/office/dynamic-array-formulas-and-spilled-array-behavior-205c6b06-03ba-4151-89a1-87a7eb36e531

Related Bug: https://bugs.documentfoundation.org/show_bug.cgi?id=127808

Change-Id: I1c3769ef33fa0207f55e1c96083717c2d90402e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163955
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
2024-03-01 18:31:35 +01:00
Balazs Varga b36ecef07a tdf#128425 Add Excel2021 function XMATCH to Calc
https://issues.oasis-open.org/browse/OFFICE-4155

Change-Id: I7791ab873cf62ce882feba75dc0d722bc5990f9a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163260
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
2024-02-18 23:13:01 +01:00
Winfried DonkersandBalazs Varga f7039822c7 tdf#127293 Add Excel2021 function XLOOKUP to Calc
https://issues.oasis-open.org/browse/OFFICE-4154

What is working already: xlookup with normal forward,
backward search in columns/rows. Binary search in rows with
real binary search algorithm, in columns only works with linear search yet.
Linear forward backward wildcard/regex search in columns/rows.
Looking for the first smaller or greater value with linear and binary search
ALso all the combination of all these options. Except XLOOKUP
not supperted wildcard/regex search with binary search.

TODO in next patches:
- add the binary search option for searching in columns.
- Evaluate Formula calculation not working in general.

Co-authored-by: Balazs Varga <balazs.varga.extern@allotropia.de>

Change-Id: I15fd4479b63ec13b093d269760d1bbb5957553e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131905
Tested-by: Jenkins
Tested-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
2024-01-31 09:14:19 +01:00
Eike Rathke 516318113f Resolves: tdf#76310 Preserve whitespace TAB, CR, LF in formula expressions
Allowed whitespace in ODFF and OOXML are
U+0020 SPACE
U+0009 CHARACTER TABULATION
U+000A LINE FEED
U+000D CARRIAGE RETURN

Line feed and carriage return look a bit funny in the Function Wizard if
part of a function's argument but work. Once a formula is edited, CR are
converted to LF though, probably already in EditEngine, didn't
investigate.

Change-Id: I6278f6be48872e0710a3d74212db391dda249ed2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119635
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
2021-07-28 18:56:29 +02:00
Eike Rathke 716655820d Resolves: tdf#127831 implement RAND.NV() and RANDBETWEEN.NV() non-volatile
Same as RAND() and RANDBETWEEN() but not recalculating on every
change, just the normal expression recalculation.

Change-Id: I8ba7099125e487a78bd3d91db8b666c2f36b22fd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92994
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
2020-04-28 11:26:38 +02:00
Dennis Francis 32d9f7a632 tdf#74664 : Adds FOURIER() formula
FOURIER(Array, GroupedByColumns, Inverse, Polar)
is a matrix formula that computes discrete Fourier transform[DFT]
of input array(first argument) via a radix-2, decimation-in-time
fast Fourier transform algorithm.

Unit test for this is coming up in a new commit.

The data in input array(first argument) can be :-

1) grouped by columns (needs to be indicated by flag GroupedByColumns = TRUE)
   In this case the array can contain 1 or 2 columns, where the first column
   contains the real part of input series and second column if present contains
   the imaginary part of the input series. If there is only 1 column, the input
   series is treated as purely real. If the number of rows is not a power of 2,
   zeroes are appended to the input series internally to make the series length
   equal to the next nearest power of 2.

2) grouped by rows (needs to be indicated by flag GroupedByColumns = FALSE)
   In this case the array can contain 1 or 2 rows, where the first row
   contains the real part of input series and second row if present contains
   the imaginary part of the input series. If there is only 1 row, the input
   series is treated as purely real. If the number of columns is not a power of 2,
   zeroes are appended to the input series internally to make the series length
   equal to the next nearest power of 2.

The third argument "Inverse" is a boolean flag to indicate whether an inverse
DFT needs to be computed. This argument is optional and the default value is
FALSE.

The fourth argument Polar is a boolean flag to indicate whether the final output
needs to be in polar coordinates. This argument is optional and the default value
is FALSE.

The result of DFT consists of two columns - first column contains the real parts (or
the magnitudes if Polar=TRUE) and second column contains the imaginary parts (or
the phases if Polar=TRUE).

Implementation:

A fairly straighforward non-recursive implementation of radix-2 FFT algorithm is
written from scratch.

Reference:

Heckbert, P., 1995. Fourier transforms and the fast Fourier transform (FFT) algorithm.
Computer Graphics, 2, pp.15-463.

The normalization factor used in DFT / and inverse DFT in this implementation matches that
of fft() and ifft() functions of Matlab/Octave. It also matches the one used in Wikipedia
article on DFT: https://en.wikipedia.org/wiki/Discrete_Fourier_transform.

Change-Id: If4a40a6ef62bce1f03c589ae5357b2049f66fe64
Reviewed-on: https://gerrit.libreoffice.org/67938
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
2019-02-19 12:35:25 +01:00
Eike Rathke 8dec85a3b3 Resolves: tdf#113977 implement REGEX() spreadsheet function
REGEX( Text ; Expression [ ; Replacement ] )

Using ICU regular expressions
http://userguide.icu-project.org/strings/regexp

Change-Id: I4cb9b8ba77cfb5b8faab93037aa0d947609383d7
Reviewed-on: https://gerrit.libreoffice.org/62332
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
2018-10-25 12:13:58 +02:00
Eike Rathke 14729a8aad Remove unused ocIndirectXL and ocAddressXL
Separated implementation is gone since long.

Change-Id: I78279f631c9205202af92ad8e248f9a1226b7a19
Reviewed-on: https://gerrit.libreoffice.org/61075
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
2018-09-28 15:20:34 +02:00
Eike Rathke a8d4d4b9ed Resolves: tdf#115879 treat NOT as the 1-parameter function that it is
... instead of a low precedence unary operator with an odd
behaviour. This wasn't documented nor specified but maybe needed
for old(est) binary file format compatibility. Generate an error
for anything else than a context of a function with one argument.

There might be some corner cases of documents where some old usage
leads to error now, of which some may have worked by accident, but
some not as intended.

Related, the internal not exposed (but available) NEG was classified
similar as a unary operator but corectly handled as function at all
places. Classified as an ordinary 1-parameter function as well.

Change-Id: I3d84a6382243c8d64313e37346f81c857e71be95
Reviewed-on: https://gerrit.libreoffice.org/50055
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
2018-02-20 23:24:17 +01:00
Eike Rathke f6c2fd1ce5 Remove unused ocExternalRef
Change-Id: Ie32411637f2f2dbedfc8e4272e952ecc1d72ac49
2017-12-20 22:05:34 +01:00
Tor Lillqvist bfa72a6a2a Add a debugging output OpCodeEnumToString() function
Change-Id: I5382107dc556df822292e72af48d23e04a3408a2
Reviewed-on: https://gerrit.libreoffice.org/45261
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2017-11-25 06:51:30 +01:00