[Libreoffice-commits] core.git: formula/source sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Oct 11 09:27:01 UTC 2018


 formula/source/core/api/FormulaCompiler.cxx |   27 +++++++++++++++++++++++----
 sc/source/core/tool/interpr4.cxx            |    4 +++-
 2 files changed, 26 insertions(+), 5 deletions(-)

New commits:
commit a6032ff5418ad66cc8fec10c636e32b124ee7864
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Thu Oct 11 00:57:00 2018 +0200
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Thu Oct 11 11:26:37 2018 +0200

    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 at redhat.com>
    Tested-by: Jenkins

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
     {
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 4b5ff2281bfa..c47b33f8488c 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -4507,7 +4507,7 @@ StackVar ScInterpreter::Interpret()
             bForcedResultType = false;
     }
 
-    if( sp )
+    if (sp == 1)
     {
         pCur = pStack[ sp-1 ];
         if( pCur->GetOpCode() == ocPush )
@@ -4634,6 +4634,8 @@ StackVar ScInterpreter::Interpret()
         else
             SetError( FormulaError::UnknownStackVariable);
     }
+    else if (sp > 1)
+        SetError( FormulaError::OperatorExpected);
     else
         SetError( FormulaError::NoCode);
 


More information about the Libreoffice-commits mailing list