diff options
author | Eike Rathke <erack@redhat.com> | 2018-03-06 18:41:56 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2018-03-28 23:53:16 +0200 |
commit | 3f0705b5037fefec43fcf234127b3d1fd84f846f (patch) | |
tree | c517b681723b8d2240b55403b617620d4cb21666 | |
parent | 5116f74a2fdf8f444cf60f88db042f4b87c25748 (diff) |
Resolves: tdf#116100 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.
(cherry picked from commit cfc6cf5177f8df23af35c4509c0276a19de56cce)
Change-Id: I72328a690760637f6d31fadba447641c64711a67
Reviewed-on: https://gerrit.libreoffice.org/51380
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r-- | formula/source/core/api/FormulaCompiler.cxx | 6 | ||||
-rw-r--r-- | formula/source/ui/dlg/formula.cxx | 1 | ||||
-rw-r--r-- | include/formula/paramclass.hxx | 11 | ||||
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 9 |
4 files changed, 23 insertions, 4 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index 0ee613dcd8f0..715a2608c7ea 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -2606,9 +2606,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; } @@ -2622,6 +2624,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 1a7505ac06f8..c98167ea54bc 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 125efec1b397..49c7d009f05a 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -802,12 +802,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); |