summaryrefslogtreecommitdiff
path: root/formula
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2018-10-11 00:57:00 +0200
committerEike Rathke <erack@redhat.com>2018-10-11 11:26:37 +0200
commita6032ff5418ad66cc8fec10c636e32b124ee7864 (patch)
treef6d41d15ab98824487a3ebef5df5b6dd3389b3c5 /formula
parent79bc165b6c906aa4f9efa6f4cdebb2f8a5f405b1 (diff)
Resolves: tdf#90698 catch list (1;2) of non-references as error
Change-Id: Icc6f93bbf85df245ba332ce89791a1c8d266b1c6 Reviewed-on: https://gerrit.libreoffice.org/61639 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'formula')
-rw-r--r--formula/source/core/api/FormulaCompiler.cxx27
1 files changed, 23 insertions, 4 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index 6859e744ca15..db32c1de0ff1 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -1401,18 +1401,37 @@ void FormulaCompiler::Factor()
NextToken();
CheckSetForceArrayParameter( mpToken, 0);
eOp = Expression();
- // Do not ignore error here, regardless of bIgnoreErrors, otherwise
- // errors like =(1;) would also result in display of =(1~)
+ // Do not ignore error here, regardless of mbStopOnError, to not
+ // change the formula expression in case of an unexpected state.
if (pArr->GetCodeError() == FormulaError::NONE)
{
- pFacToken->NewOpCode( ocUnion, FormulaToken::PrivateAccess());
- PutCode( pFacToken);
+ // Left and right operands must be reference or function
+ // returning reference to form a range list.
+ const FormulaToken* p;
+ if (pc >= 2
+ && ((p = pCode[-2]) != nullptr) && isPotentialRangeType( p, true, false)
+ && ((p = pCode[-1]) != nullptr) && isPotentialRangeType( p, true, true))
+ {
+ pFacToken->NewOpCode( ocUnion, FormulaToken::PrivateAccess());
+ PutCode( pFacToken);
+ }
}
}
if (eOp != ocClose)
SetError( FormulaError::PairExpected);
else
NextToken();
+
+ /* TODO: if no conversion to ocUnion is involved this could collect
+ * such expression as a list or (matrix) vector to be passed as
+ * argument for one parameter (which in fact the ocUnion svRefList is a
+ * special case of), which would require a new StackVar type and needed
+ * to be handled by the interpreter for functions that could support it
+ * (i.e. already handle VAR_ARGS or svRefList parameters). This is also
+ * not defined by ODF.
+ * Does Excel handle =SUM((1;2))?
+ * As is, the interpreter catches extraneous uncalculated
+ * subexpressions like 1 of (1;2) as error. */
}
else
{