1134 Commits
Author SHA1 Message Date
Neil Roberts d886defd9b FormulaCompiler: Use boost::intrusive_ptr::get() instead of &*
Using &* can be problematic if the pointer is null. In this case it
probably doesn’t matter, but using get() is probably easier to
understand anyway. This also paves the way for a later compiler plugin
to check for this.

Change-Id: I0ba29f530c648782d7d6af8225a2eb6d5c28b5b9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211844
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-10-07 19:15:27 +02:00
Xisco Fauli 7003eb6fc6 fix headers
Change-Id: Ia2732cc041367bc113654bc424ea6621f3961e9f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211724
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-10-05 08:52:04 +02:00
Tomaž Vajngerl a074008d58 formula: don't take the blank before an operator into the wrapper
The operand of an @ or of a union list ends where an operator further
out ends it, and the whitespace in front of that operator was still
inside it. So the blank was written inside the call parentheses, and
since a range ending in whitespace is no longer one parenthesised
group, the operand got a second pair of parentheses on top of the
ones it had - @(A1) + 1 came out as _xlfn.SINGLE((A1) )+ 1.

The wrapper now ends in front of those tokens. A blank before the #
stays with the operand, that one is the operator being rewritten.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: Ie6fe2df4e3e05b0ef845ebdb8a1aedb54b3f2a66
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/10851
Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit fd39c3a52d1cab7c0429bb98c4749bbfed088e6a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210478
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-09-15 11:16:16 +02:00
Aron Budea 16314d50bc sc: Use more is(Unary|Binary)OperatorOpCode()
Change-Id: I32805328640297cd14efe798f5f8a6cfa712090b
Signed-off-by: Aron Budea <aron.budea@collabora.com>
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/12173
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit 342fbc6b53ede419b24f69e4b4e16f980b2edb27)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210926
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-09-14 13:48:11 +02:00
Andrea Gelmini eeb4290b30 Fix typos
Change-Id: I53571976c4e045a5a09f1adc4425b41d96b0e6a4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210565
Tested-by: Julien Nabet <serval2412@yahoo.fr>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2026-09-10 21:26:38 +02:00
Noel Grandin 01df8b6ff0 map->unordered_map in lcl_fillNativeSymbols
no need to use an ordered map here, and an unordered map
is much faster.
Also avoid repeatedly indexing into the map.

Change-Id: Ia6b39800a9890ab0df3e8e73282d504e91e679ec
Signed-off-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/9633
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit 1e786f1a4b588ce289b90979231b3c5e55cab27d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210492
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-09-04 19:47:34 +02:00
Tomaž Vajngerl d9dcb8a4cc sc: take the error constants from the grammar in use
The formula writer substitutes an error constant for anything that has
no spelling in the target format, and it took that string from the
native symbol table. That table is translated, so a build in another
language wrote a translated "#REF!" into the saved formula, where only
the English spelling reads back. It now takes the string from the
table of the grammar being written, which changes nothing for the
native grammar.

Reading had a gap of its own. The OOXML table had a second "#REF!" row
for the stop opcode, and the symbol map keeps the first spelling it
finds in opcode order, so that row shadowed the error constant and a
bare #REF! read from a file gave #NAME?. Nothing needs a spelling for
the stop opcode, so the row is gone.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: Idbe8ce87d6ad6346106622379ff59908a36eb7f7
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/10163
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
(cherry picked from commit 75160522f6a9de4999b824725326475ba8d713f1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210313
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-09-01 09:08:38 +02:00
Tomaž Vajngerl 62eced2131 sc: allow parentheses on both sides of the intersection blank
The compiler decides whether a blank is the intersection operator by
looking at the tokens on either side. Both parenthesis tokens have the
separator type, which those checks read as "not a reference", so
=SUM((A1:B1,A2:B2) A1:A2) didn't parse even though it should intersect
the list with the range. The parentheses are now accepted by their
opcode, and so is a reference list built from a converted separator on
either side.

The blank also keeps the parenthesis after it a group. An operand
followed by a parenthesis normally opens an argument list for a
callable, but with the intersection blank in between there is no call,
so ocCall is not injected. A name in front still calls either way.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I8e4b5fb7136419b4e937c8abb521711a8d418af8
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/10162
Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit b12a7af0e1aab942aa5014b799a96271d03c472f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210305
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-08-31 23:49:41 +02:00
Tomaž Vajngerl c56ee53c8a sc: join list parts that start with a reference
A reference list is built from the separator between two parts of a
parenthesised expression, and which parts join was decided from the
opcodes at the top of their compiled code. That was wrong both ways:
INDEX returns a reference but wasn't counted, so (INDEX(A1:A3,1),B1)
fell apart, while (F25, F26%) didn't parse at all even though it
should give #VALUE!.

The left part now has to end in a reference or an opcode that returns
one, INDEX among them. The right part joins if it starts with one, or
with a nested list, IF, CHOOSE, a lookup, the @ operator or an error
constant. What it then makes of that reference is the calculation's
business.

A part starting with anything else leaves the separator a separator
and the formula doesn't parse, which is what the producing
application refuses at its formula bar too.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: If65d2f0f9cc599729564cfc5369c0479b07c93e8
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/10160
Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 50ddf65b640a9cb88aea56be4367a3e44152c230)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210303
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-08-31 20:27:22 +02:00
Tomaž Vajngerl 1ff770e5bf sc: bind the # operator to the reference it follows
The # postfix operator was parsed at the same level as the percent
sign, which is looser than the prefix operators. Because of this
=@A1# compiled to the spill range of an implicit intersection and
=-A1# to the spill range of a negated value. Neither of those means
anything, and OOXML writes the # around the reference alone in both
cases.

The # is now parsed right after the factor it follows, tighter than any
operator that can come before it. A whole range reference goes inside,
because the lexer reads A1:A3 as a single reference. The percent sign
stays above the reference operators, so =A1%# leaves the # with nothing
to bind to and doesn't parse, and the export drops such a # (OOXML has
no spelling for it either).

A blank between two operands is only the intersection operator if both
sides yield a reference. The # does, so the checks that keep the blank
alive and that keep the operator once the operands are known had to be
told about it.

The interpreter passes the spill range on as a matrix that carries the
range it was read from. The intersection, range and union operators
only took references and refused that, so PopReferenceOperand now
hands them the carried range as a double reference.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I1a587bf291ff639b326a366b8efc332106eb5fd3
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/10156
Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit c589c34aaec00d60fc47f1933762b105f9d22de3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210293
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-08-31 17:35:25 +02:00
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
Andrea Gelmini 2bf4cc6345 Fix typos
Change-Id: Ib3a314597d03db4b8b04bb82f48af62cdc78df6a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210160
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2026-08-29 16:23:01 +02:00
Tomaž Vajngerl 27fdb4291e sc: keep the @ and # wrapper starts right as the text moves
The _xlfn.SINGLE and _xlfn.ANCHORARRAY wrappers go into the formula
text once the operand they enclose stands in the buffer, and each
splice moves the text behind it along. Several of the recorded
starts did not move with it, so =SUM( @A1#) saved as
SUM(__xlfn.SINGLE(xlfn.ANCHORARRAY( A1))), and A1~-B2# and @-A1%#
came out wrong in the same way.

Whitespace ahead of a scope or of an expression is no longer part of
it, so the starts the wrappers and the union list use begin behind
the blank.

The spilled-range splice pulls an @ that begins inside its wrapper
back to the wrapper's own start, so the @ takes the whole wrapper as
its operand.

The union list's parenthesis and the @ splice both move the start of
the expression they go in front of, so a postfix operator behind
them still finds where its operand begins.

A scope's parentheses count as taken when a wrapper begins ahead of
the scope's text, as they already did when one begins exactly at it.

The writer of the pending @ wrappers asserts that they stand in the
order their operands begin. That order is what keeps the starts
still waiting correct, and each of these bugs broke it.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I87ca7c67be9d2f11ca34661a79401a2fa1c60bbe
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/9638
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit 3d52e137f229d87bc5633dc7966bace3044f1c3a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209504
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-08-23 13:32:49 +02:00
Xisco Fauli 0c91381485 loplugin:unusedmethods
Change-Id: I17586b49f970be17c5f6d2823d4a973521b2ed62
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209407
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-08-21 09:31:35 +02:00
Tomaž Vajngerl 6be9e4a7bc sc: anchor the spilled-range wrapper on the whole expression
XLSX writes the # operator as _xlfn.ANCHORARRAY around its operand.
The walk spliced that wrapper at the start of the last factor, but the
grammar puts the # above the range, intersection and union operators,
so all of those belong inside the operand. A1~B2# came out as
(A1,_xlfn.ANCHORARRAY(B2)) and A1:INDEX(B1:B10;5)# as
A1:_xlfn.ANCHORARRAY(INDEX(B1:B10,5)).

Each parenthesis scope already records where its union-level
expression begins, which is in front of every operator the # binds
looser than. The wrapper splices there instead, and an open union list
takes its own parentheses first.

Nothing reads the separate stack of factor starts now. Its depth
matched the scope stack's, so that stack carries it and the vector is
gone.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I6fd212a0e97ee40ce04c27a758f78669d3fce5f8
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/9309
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit 82f4f2386f5d752a890de306fb89c314c4d87a1f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209412
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-08-21 00:02:32 +02:00
Tomaž Vajngerl cccd6f9f1a sc: parenthesize a reference union on OOXML save
OOXML writes the union operator as the same comma that separates
function arguments, so a union with no parentheses of its own fell
apart on save: SUM(A1~B2) became SUM(A1,B2), which reads as two
arguments, and INDEX(A1:B3~D1:E3;1;1;2) changed its meaning even on
Calc's own reload. A union already inside a parenthesised group was
safe, since the group's tokens are kept.

The walk now records where the union-level expression of each
parenthesis scope starts. The first union operator opens a list
there, and the list takes one pair of parentheses when the
expression ends: at a looser operator, an argument separator, the
parenthesis that closes the scope, or the end of the formula.

A list that fills a grouping parenthesis exactly keeps that pair, so
a formula holds its shape over repeated round trips. Two kinds of
parenthesis cannot be reused that way: the one behind AND, OR or the
call operator, which opens an argument list rather than a group, and
one that an @ wrapper beginning at the same place has already taken.

The group check behind the @ wrapper refuses a group with a comma
directly inside it, passing over the commas an inline matrix or a
bracketed reference carries. Text that no parse could read takes no
parentheses at all, so a list reaching such text drops its pair.

Unit tests pin the written string for each union shape, and the
positions the inserted parenthesis shifts. A round-trip test checks
the saved XML and the reloaded formulas and values.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I970f3b4ecea680f6e70d146a2f1608c4adff9c1f
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/9308
Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit dd8104342d7147f07006bebb1dbeec60b48250f6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209411
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-08-21 00:02:28 +02:00
Michael Weghorn b9ecf11693 formula: Switch ParaWin::m_pMyParent to reference
Switch the member (and corresponding ctor param) from pointer
to reference and rename accordingly.

Change-Id: I48a419282684628482b24b097e3e385ea81e383f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209398
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2026-08-20 22:30:18 +02:00
Michael Weghorn b429497ea6 formula: Pass IFormulaDlg_Impl's ControlReferenceHandler param by ref
Change-Id: I27a02c6857d5fbe17d0c57ce094992b54c7ade4d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209397
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2026-08-20 22:30:13 +02:00
Michael Weghorn 651bd99452 formula: Pass FormulaDlg's IControlReferenceHandler param by ref
... instead of by pointer.
Do the same for FormulaModalDialog.

Change-Id: I4698574b04a32daaa0c1c7c38d5b3ce3b9007f0d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209396
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2026-08-20 22:30:07 +02:00
Michael Weghorn 926f4d8e5d formula: Prefix ArgInput members with "m_"
Add the usual "m_" naming prefix for ArgInput class members
to distinguish them from local variables.

Change-Id: If4b4fc8e269b87a2af4b2e34ff744c0237241ff1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209395
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2026-08-20 22:30:00 +02:00
Michael Weghorn 658e625392 formula: Prefix ParaWin members with "m_"
Add the usual "m_" naming prefix for ParaWin class members
that don't have it yet, to distinguish them from local variables.

Change-Id: Ife371a2cbd9af95b3d3219ce2f7bfbfbffdf73c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209390
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2026-08-20 22:29:54 +02:00
Michael Weghorn f198072e38 formula: clang-format parawin.hxx
This in particular gets rid of an extra indentation level.

Change-Id: Ie7b1b80be12e70266081fa2da284a4bae2b25a08
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209389
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2026-08-20 22:29:49 +02:00
Michael Weghorn 38ad74fe13 formula: Pass ArgInput::InitArgInput params by ref
This makes clear they're always non-null and also
allows dropping some null checks.

Change-Id: Ie2e828fdf223ed69bc570f58225d1b0de4aa0f27
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209388
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2026-08-20 22:29:43 +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
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
Aron Budea f806ff98be cool#16026 XLSX: Use "#REF!" for invalid user-defined functions (again)
Otherwise a formula like "_xludf.(SUM(A1:A2))",
ie. user-defined without a name can be exported to XLSX,
which is invalid.

Adapt fix in 06c4bf867de38be2e65e1813ed1a1f05b0b49b4a
after 996ee806764dd7cc0a24b1b218b3cf4cefd50db1.

Affected eg. forum-mso-de-49320.xls

Change-Id: I6d02d6e5b82ca851ca9569d324c4e4c60f3da919
Signed-off-by: Aron Budea <aron.budea@collabora.com>
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/7402
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit a5ee7ceb3da75e0ae2aa739d612a0d0fc6eaf218)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208732
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-07-28 14:37:06 +02:00
Michael Weghorn a881b303b3 tdf#130857 formula: Only use selection indices if selection exists
The bool return value of weld::TextWidget::get_selection_bounds
indicates whether a text selection actually exists.

Only use the start and end indices from the out params
if that is the case and otherwise return a default-constructed
Selection object (i.e. one using start and end indices of 0).

Otherwise, this would result in an assertion due to the use of
invalid string indices as seen with the qt6 vcl plugin and native
widgets enabled (SAL_VCL_QT_USE_WELDED_WIDGETS=1) for the following
scenario with upcoming commit

    Change-Id: I10fcd9c326a047cf4abd34369f02be1847d77ae1
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Wed Jul 22 14:20:53 2026 +0200

        tdf#130857 qt weld: Support Calc "Edit Print Ranges" dialog

in place:

* start Calc
* "Format" -> "Print Ranges" -> "Edit..."
* click on the "Shrink" button in the "Print Range" section
* click anywhere in the sheet

Assertion:

    soffice.bin: /home/michi/development/git/libreoffice/sal/rtl/strtmpl.hxx:1059: void rtl::str::newReplaceStrAt(rtl_tString **, rtl_tString *, sal_Int32, sal_Int32, rtl_tString *) [rtl_tString = _rtl_uString]: Assertion `nIndex >= 0 && nIndex <= pStr->length' failed.

This is because QtInstanceEntry::get_selection_bounds
sets the indices to -1 if no selection exists.

Change-Id: Ifc8fd6f6a6d676fe26364da9077cb10acb439a5a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208474
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2026-07-25 10:34:14 +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
Noel Grandin 49044478b3 use more unique_ptr in FormulaTokenArray
Change-Id: Ife00f7e119e4870a3584ae7d766d9debd6220217
Reviewed-on: https://gerrit.collaboraoffice.com/c/core/+/632
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
(cherry picked from commit b80addae75093d947065f0e41e1a1aebd2c89a03)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208282
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-07-21 09:02:36 +02:00
Tomaž Vajngerl d9241ddd7a Import optional LAMBDA parameters written with the _xlop. prefix
The OOXML format marks an optional LAMBDA parameter with the _xlop.
prefix in the parameter list, while the body refers to the same
parameter through the _xlpm. prefix. Calc recognised only _xlpm., so an
optional parameter kept its prefix, did not match the bare name used in
the body, and lost the mark that made it optional. It failed to bind,
and a call that left it out reported an error.

Recognise _xlop. as a parameter marker and strip it to the bare name, so
the declaration and the body references match. Carry the optional mark
onto the parameter token so the compiled code treats it the same way as
the native square-bracket form.

Write an optional parameter back with the marker the grammar uses: the
_xlop. prefix in OOXML and square brackets in the native grammars.

Add a test that imports an optional parameter in the OOXML form and
checks that ISOMITTED sees it as omitted and that concatenating it
yields the other operand.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: Ia1df0fa6ca498f4c607507b3a865b3b367e5c11a
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/5782
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
(cherry picked from commit f198d7a984654aabd5e988d3c327da5552bc68e0)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207891
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-07-12 14:24:34 +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
Michael Weghorn f1f6a505a0 weld: Pass weld::TextWidget& in text change callback/handler
Switch the weld::Entry and weld::TextView handlers
that are called when the text changes due to user
interaction to pass a weld::TextWidget& param
instead of a weld::Entry& and weld::TextView&
one respectively.
Adjust related methods across the code base accordingly.

This unifies the behavior for both of these
weld::TextWidget subclasses and prepares for
deduplicating the logic and moving it to the
common base class in an upcoming commit.

That will also ensure they stay in sync.
(Change also motivated by the fact that their behavior was
differing before

    Change-Id: I03d2a13cd84d53d806eb9e363f49c4b6be28d938
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Thu Jul 9 13:08:58 2026 +0200

        tdf#130857 weld: Don't signal about programmatic TextView text change
.)

Change-Id: I5572fc88caf577fae9a23a39f1ec4f2179935a99
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207936
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2026-07-10 18:17:27 +02:00
Tomaž Vajngerl e703f728ff sc: wrap the # operator in _xlfn.ANCHORARRAY on XLSX export
XLSX stores the # spilled-range operator as the prefix call
_xlfn.ANCHORARRAY(<ref>). The exporter emitted the bare #
glyph, which older readers reject.

The operand is already in the buffer when the parse walk
reaches ocSpill, so CreateStringFromTokenArray keeps a
per-parenthesis-depth stack of where the current factor
began. ocSpill splices _xlfn.ANCHORARRAY( at that position
and closes at the buffer's end.

For =@A1# the # binds tighter than @, giving the nested form
_xlfn.SINGLE(_xlfn.ANCHORARRAY(A1)). EmitSingleValueOperandOOXML
splices ANCHORARRAY around the operand and consumes the
trailing ocSpill, so the main loop does not wrap it again in
the wrong order.

Tests check the ANCHORARRAY form in the saved XML and
round-trip an imported spill formula through save and reload.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I9e92350d2574adeebf44fae903ee32dd63654d7c
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/5789
Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit 89715a92489305230b52f2874d768dc117a71eee)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207907
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-07-10 01:09:50 +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
Tomaž Vajngerl 14d723ea36 sc: let @ collapse arrays from range arithmetic, not just functions
The @ operator collapses an array operand to its upper-left
value. A function operand like SEQUENCE pushes a matrix and @
collapses it. A range arithmetic operand like (B2:B3+0) does
implicit intersection first and hands @ a scalar, so @ has
nothing to collapse.

Mark @'s operand as ForceArray in the parameter classifier and
wrap UnaryLine in a CurrentFactor scope so the classification
reaches the nested operators. Range arithmetic inside @ then
materialises as a matrix and reaches @ for the upper-left pick.

testSingleValueOperator covers @ on a range expression and a
chained @ binary.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I7f59bfa1efbceeceb9a3d7f71a0243e9a521b24a
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/5517
Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit 4148cbecbdaa3164c53d3869252a3ca714ba5726)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207868
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-07-09 17:08:49 +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
Tomaž Vajngerl 0522c17c22 sc: round-trip the @ operator through XLSX as _xlfn.SINGLE
The OOXML spec writes =@(expr) as =_xlfn.SINGLE(expr). Calc
emitted the bare @ glyph on save and dropped the wrapper on
load, so =@(F3:F5+0) fell back to a non-array context after a
round trip and lost the authored value.

Map "_xlfn.SINGLE" to ocSingleValue in the OOXML symbol
table. The regular exporter walk now spells ocSingleValue as
"_xlfn.SINGLE" and the import compiler recognises the
wrapper, so a parenthesised operand round-trips with no
further work. A small exporter branch wraps bare and
function-call operands in the wrapper's own parentheses.

OOXML files in the wild put the @ operand inside a redundant
parenthesis pair, _xlfn.SINGLE((expr)). A post-compile pass
on import drops the inner pair so the cell reads back as
=@(expr). The helper takes a trigger-opcode list for reuse.

testSingleOperatorXlsxRoundTrip covers the export path,
testIntersectionOperatorXlsxRoundTrip covers the import strip
from a fixture file.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I2648da125945295fd8548842aba9c82978d96aa9
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/5573
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
(cherry picked from commit 5ac9db1f563bbde01f9e24fc9bbb8c3599eb0c06)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207789
Tested-by: Jenkins
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-07-08 23:47:16 +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 5286d91e80 sc: round-trip dynamic-array masters and @ through ODF
Import classifies each formula cell:
- Plain non-array, no coext:spill: the import-time walk over
  the freshly compiled RPN decides if the formula intends an
  array. If yes, prepend @ at the front of the parse and at
  the back of the RPN.
- Plain non-array + coext:spill="true": a master saved while in
  spill state. Comes back at 1x1 with the dynamic flag, the
  position marked spilled. The next interpret re-checks the
  blockers.
- Array formula (matrix dims): static array master by default.
  coext:spill="true" promotes it to a dynamic-array master.
  Legacy Ctrl+Shift+Enter (CSE) arrays without the marker keep
  their static iteration-and-pad behaviour.

Export reverses:
- ODF always strips @ on save. The @ is an in-memory marker
  only. OOXML and the UI grammar keep it.
- Dynamic master: coext:spill="true" in extended ODF, matrix
  dims as before. In spill state, write as plain non-array with
  coext:spill="true".
- Static array master: matrix dims, no coext:spill.

GetFormula skips the {} wrapping for dynamic-array masters so
they read back as plain formulas. Static array masters keep {}.

XML_SPILL is added to the xmloff token machinery and the ODF
extension schema (OpenDocument-v1.4+libreoffice-schema.rng)
gains coext:spill on table-cell.

Tests cover each import shape, the FODS export of regular and
spilled masters, the @ insertion on CompileXML, and the @
stripping at the formula-compiler level. ArrayFormulasStatic.ods
is a legacy fixture whose B1 = AND(C4:C52) summarises 49 per-row
value checks. The test runs the grid on import and after an ODS
round trip and confirms plain bare-range cells gain @ while the
five matrix masters stay static, keep their {} wrapping, and
get no coext:spill in the saved XML.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: Ib8ae345528185c824415ec5d039b6d5cf0d7eac8
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/4663
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
(cherry picked from commit a21f6a3a0eae72fef90576d249d96dc00beeb2c5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207171
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-06-24 00:04:16 +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
Michael Weghorn f26084217a weld: Move weld::Button to own header/Rename weld.hxx
In the past, weld.hxx used to contain the class
definitions for weld::Widget and all subclasses.

By now, weld::Widget and almost all subclasses have
been moved to separate headers, to make it easier
to keep the overview and to avoid having to
recompile ~all UI code when one class changes.

By now, only weld::Button is left in weld.hxx.
Rename the header to Button.hxx.
Drop weld.hxx includes and instead add Button.hxx
includes (or weld::Button forward declarations) where
weld::Button is used.
(Don't simply replace all weld.hxx includes with
Button.hxx ones, since many of them were for the
use of other widgets that have since been moved
to their own headers.)

Add further includes where needed now that the
(direct or transitive) includes of weld.hxx were removed.

Change-Id: I8ea6201446a418d5e38b46337059dcd517ee29d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205937
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2026-06-05 07:58:07 +02:00
Michael Weghorn 8b5a46a0e0 weld: Move weld::toId and weld::fromId to weldutils.hxx
In the past, weld.hxx used to contain the class
definitions for weld::Widget and all subclasses,
as well as a few helpers.

By now, weld::Widget and almost all subclasses have
been moved to separate headers, to make it easier
to keep the overview and to avoid having to
recompile ~all UI code when anything in weld.hxx
changes.

Move the weld::toId and weld::fromId helpers from
weld.hxx to weldutils.hxx, in preparation of getting
rid of weld.hxx altogether in an upcomcing commit.

Change-Id: I408fe20a74ff104cbfe07bde3105317a1922ff61
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205936
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2026-06-04 14:37:13 +02:00
Xisco Fauli 6f81bce807 loplugin:unusedmethods
Change-Id: I57a535f72e639a9b708c5c7dc1790e354d2d477e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205943
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-06-04 10:00:29 +02:00
Michael Weghorn 8f7cf9c32c weld: Move weld::CheckButton to own header
Move the class out of weld.hxx into its own header, in
order to make it easier to keep an overview and to avoid
having to recompile ~all UI code when the class is
modified.

Add missing includes/forward declarations in places
previously depending on transitive includes that
are now dropped.

Change-Id: I3215b358e0fa45ffce08756218c386e1a4d7ebc6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205928
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2026-06-04 08:39:19 +02:00
Michael Weghorn 243bb112ec weld: Move weld::Container to own header
Move the class out of weld.hxx into its own header, in
order to make it easier to keep an overview and to avoid
having to recompile ~all UI code when the class is
modified.

Adjust includes in files that were implicitly depending
on transitive includes that are no longer present because
the more specific include/weld/Container.hxx is included
further down now instead of include/weld/weld.hxx.

Change-Id: I04e6bb72ce446b746dfdf88b45c7df9d0ccda473
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205899
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2026-06-03 23:19:22 +02:00
Caolán McNamara 9bdfe90546 crashtesting: fix FormulaCompiler::Factor crashes
crash on loading bugtrackers/xls/ooo25114-1.xls (etc)

 #0  0x00007f118813ea61 in rtl::OUString::equalsAsciiL (this=<optimized out>,
     asciiStr=0x7f118814e760 "com.sun.star.sheet.addin.Analysis.getRandbetween",
     asciiStrLength=48) at engine/include/rtl/ustring.hxx:1255
 #1  0x00007f118813ff1a in rtl::operator==<char const [49]> (rString=<optimized out>,
     literal=...) at engine/include/rtl/ustring.hxx:2130
 #2  0x00007f118813c2a8 in formula::FormulaCompiler::Factor (this=0x7f11697fbe10)
     at engine/formula/source/core/api/FormulaCompiler.cxx:1743
 #3  0x00007f118813d274 in formula::FormulaCompiler::CompileTokenArray (this=0x7f11697fbe10)
     at engine/formula/source/core/api/FormulaCompiler.cxx:2429
 #4  0x00007f450a8dfe4a in ScFormulaCell::ScFormulaCell (this=0x7f4504e5a260, ...)
     at engine/sc/source/core/data/formulacell.cxx:701
 #5  0x00007f451675c6fe in ImportExcel::Formula (this=0x7f4504444ef0, ...)
     at engine/sc/source/filter/excel/excform.cxx:150

since:

commit f59c512a885ae4264ba9f7b8fe4d7b9574a2a0dc
Date:   Mon Apr 13 15:36:11 2026 +0200

    reduce FormulaExternalToken virtual calls

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I1d578b329d120fb55f3ad47ea5d1acdfed6a5cdc
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/2010
(cherry picked from commit 796aee17c6a78ac725eaa35270add93335412559)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205959
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-06-03 20:33:00 +02:00
Noel Grandin 62f1a275e1 ofz#516502581 Heap-buffer-overflow
regression from
  commit 726a1ff3abce3a4eff5dd115182b15eccb653568
  reduce FormulaByteToken virtual calls

Change-Id: Ica3e5a6c32f03cfdb215eb3ab78d74284e951094
Signed-off-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/3497
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit 15d5ebba4151353127ddcb41aa2824dbe283788f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205883
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-06-01 20:50:20 +02:00