13 Commits
Author SHA1 Message Date
Ben Urban e1d69c4592 tdf#127808, tdf#173380: sc: Fix dynamic arrays for LAMBDA and LET
* Recognize LAMBDA during dynamic array analysis; LAMBDA
never produces an array, but it can be part of a formula
that generates one.

* Fix handling of LET; subexpressions before the last should
not affect the result, unless we are willing to to a more
thorough analysis.

* Update test to check for the new behavior.

* Account for svExternalDoubleRef.

Change-Id: Ia9a4761079de986906ac70252066d8d9b4655f59
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210461
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-09-03 19:42:45 +02:00
Ben Urban 11ad7d61b4 sc: Implement lambda and related fuctions as FunctionsTest
Like the other functions in Calc

Based on https://gerrit.libreoffice.org/c/core/+/208073

Change-Id: I0e74bff3e29328007345841ffefd6fb18965e5ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209144
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-08-19 11:40:23 +02:00
Ben Urban 5776da7d06 tdf#138749: Enabled constructing a LAMBDA with no parameters
The sequence for LAMBDA in the RPN code is now:
[0] ocLambda, svJump
[1] ocPush, svStringName (parameter name)
[2] ocSep, svSep
(Repeat [1] and [2] for each parameter)
[3] (body code)
[4] ocClose, svSep
[5] (code after LAMBDA expression)

Jumps in the ocLambda point to [0], each [2], and [4], which means
there are two more jumps than parameters.

For example:
=LAMBDA(x;y;x+y)(3;4)
generates the following RPN code:
index opcode  type (data)
 [0] ocLambda svJump ({4,0,2,4,8})
 [1] ocPush   svStringName ("x")
 [2] ocSep    svSep
 [3] ocPush   svStringName ("y")
 [4] ocSep    svSep
 [5] ocPush   svStringName ("x")
 [6] ocPush   svStringName ("y")
 [7] ocAdd    svByte
 [8] ocClose  svSep
 [9] ocPush   svDouble (3.0)
[10] ocPush   svDouble (4.0)
[11] ocCall   svByte (3)
The first parameter is in [1], the second is in [3], the body is
in [5]-[7], and [9] is where the code resumes after the LAMBDA.

Change-Id: I4dc871893f47ebbd4dad9cc02ac3efe0ca6ca883
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207973
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-08-18 18:08:25 +02:00
Ben Urban 46efe4ffad Fixed typo
Change-Id: I6855830b438af532638fe1f68941f139af2b7863
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208713
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-07-28 10:13:54 +02:00
Ben Urban 86615b08bf tdf#164513: Added UI strings for REDUCE()
Change-Id: Ib589d4f8d63523d9830e37c0ef9d5e6dd1978092
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208351
Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
Tested-by: Jenkins
2026-07-23 14:50:03 +02:00
Ben Urban 2d4a1434e4 tdf#172815: Change MAP() function UI wording
Change-Id: I3ebd0f063da6c53f916145c1d231638cda0501ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208349
Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
Tested-by: Jenkins
2026-07-23 14:37:13 +02:00
Ben Urban e5386e95c8 tdf#172823: Add UI strings for SCAN function to Calc
Change-Id: I67681892e25bfe5470c61e3ee1e008d58819629a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208350
Tested-by: Jenkins
Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
2026-07-22 15:43:20 +02:00
Ben Urban c3e8217a65 tdf#138749: Updated tooltip for LAMBDA
Change-Id: I75c9acd197cd03512346f63b76bd72007f1cd6cd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207986
Tested-by: Jenkins
Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
2026-07-21 22:27:02 +02:00
Ben Urban 97b180f071 tdf#138749: Implemented support for optional parameters for LAMBDA
LAMBDA now supports optional parameters with the [name] syntax; all
such parameters must appear after all required parameters in the
parameter list.

Optional parameters use svMissing, for compatibility with ISOMITTED.

Change-Id: Ice026eeb6937dadd3b1ffd8c07e0d3ce88de9afc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207392
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-07-12 14:23:51 +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