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

Eike Rathke erack at redhat.com
Tue Mar 6 17:59:33 UTC 2018


 formula/source/core/api/FormulaCompiler.cxx |    6 +++++-
 formula/source/ui/dlg/formula.cxx           |    1 +
 include/formula/paramclass.hxx              |   11 +++++++++--
 sc/source/core/tool/interpr1.cxx            |    9 ++++++++-
 4 files changed, 23 insertions(+), 4 deletions(-)

New commits:
commit cfc6cf5177f8df23af35c4509c0276a19de56cce
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Mar 6 18:41:56 2018 +0100

    Resolves: tdf#116215 fewer array of references cases, tdf#58874 related
    
    In particular if in any ForceArray context use the matrix result
    instead of the array of references list.
    
    Change-Id: I72328a690760637f6d31fadba447641c64711a67

diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index a83cc129a93c..537f8f74f074 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -2579,9 +2579,11 @@ void FormulaCompiler::ForceArrayOperator( FormulaTokenRef const & rCurr )
     else if (eType == formula::ParamClass::ReferenceOrForceArray)
     {
         // Inherit further only if the return class of the nested function is
-        // not Reference.
+        // not Reference. Else flag as suppressed.
         if (GetForceArrayParameter( rCurr.get(), SAL_MAX_UINT16) != ParamClass::Reference)
             rCurr->SetInForceArray( eType);
+        else
+            rCurr->SetInForceArray( formula::ParamClass::SuppressedReferenceOrForceArray);
         return;
     }
 
@@ -2595,6 +2597,8 @@ void FormulaCompiler::ForceArrayOperator( FormulaTokenRef const & rCurr )
         {
             if (GetForceArrayParameter( rCurr.get(), SAL_MAX_UINT16) != ParamClass::Reference)
                 rCurr->SetInForceArray( eType);
+            else
+                rCurr->SetInForceArray( formula::ParamClass::SuppressedReferenceOrForceArray);
         }
     }
 }
diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx
index 745554c5493e..2e5d3569b68d 100644
--- a/formula/source/ui/dlg/formula.cxx
+++ b/formula/source/ui/dlg/formula.cxx
@@ -762,6 +762,7 @@ void FormulaDlg_Impl::MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, co
                             case ParamClass::Array:
                             case ParamClass::ForceArray:
                             case ParamClass::ReferenceOrForceArray:
+                            case ParamClass::SuppressedReferenceOrForceArray:
                                 ;   // nothing, only as array/matrix
                             // no default to get compiler warning
                         }
diff --git a/include/formula/paramclass.hxx b/include/formula/paramclass.hxx
index e8d411088061..a22854fc890c 100644
--- a/include/formula/paramclass.hxx
+++ b/include/formula/paramclass.hxx
@@ -51,8 +51,15 @@ namespace formula
             propagated to subsequent operators and functions being part of a
             parameter of this function. Used with functions that treat
             references separately from arrays, but need the forced array
-            calculation of parameters that are not references.*/
-        ReferenceOrForceArray
+            calculation of parameters that are not references. */
+        ReferenceOrForceArray,
+
+        /** Same as ReferenceOrForceArray but suppressed / not inherited in the
+            compiler's ForceArray context to indicate that a result of
+            Reference in JumpMatrix context should use the result matrix
+            instead of the array of references. Never used as initial parameter
+            classification. */
+        SuppressedReferenceOrForceArray
     };
 }
 
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 546f72a15332..3123ba8fd54f 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -800,12 +800,19 @@ bool ScInterpreter::JumpMatrix( short nStackLevel )
     }
     if ( !bCont )
     {   // We're done with it, throw away jump matrix, keep result.
-        // For an intermediate result of Reference use the array of references,
+        // For an intermediate result of Reference use the array of references
+        // if there are more than one reference and the current ForceArray
+        // context is not ForceArray or related, suppressed, ...,
         // else (also for a final result of Reference) use the matrix.
         // Treat the result of a jump command as final and use the matrix (see
         // tdf#115493 for why).
+        ParamClass eParamClass;
         if (!FormulaCompiler::IsOpCodeJumpCommand( pJumpMatrix->GetOpCode()) &&
+                pJumpMatrix->GetRefList().size() > 1 &&
                 ScParameterClassification::GetParameterType( pCur, SAL_MAX_UINT16) == ParamClass::Reference &&
+                (eParamClass = pCur->GetInForceArray()) != ParamClass::ForceArray &&
+                eParamClass != ParamClass::ReferenceOrForceArray &&
+                eParamClass != ParamClass::SuppressedReferenceOrForceArray &&
                 aCode.PeekNextOperator())
         {
             FormulaTokenRef xRef = new ScRefListToken(true);


More information about the Libreoffice-commits mailing list