diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index da1769d13b17..f243aab357f7 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -2746,6 +2746,13 @@ void FormulaCompiler::ForceArrayOperator( FormulaTokenRef const & rCurr ) else rCurr->SetInForceArray( formula::ParamClass::SuppressedReferenceOrForceArray); } + + // Propagate a ForceArrayReturn to caller if the called function + // returns one and the caller so far does not have a stronger array + // mode set. + if (pCurrentFactorToken->GetInForceArray() == ParamClass::Unknown + && GetForceArrayParameter( rCurr.get(), SAL_MAX_UINT16) == ParamClass::ForceArrayReturn) + pCurrentFactorToken->SetInForceArray( ParamClass::ForceArrayReturn); } } diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index aa3dbec8c8ef..a80897c280fb 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -151,7 +151,7 @@ bool FormulaToken::IsInForceArray() const { ParamClass eParam = GetInForceArray(); return eParam == ParamClass::ForceArray || eParam == ParamClass::ReferenceOrForceArray - || eParam == ParamClass::ReferenceOrRefArray; + || eParam == ParamClass::ReferenceOrRefArray || eParam == ParamClass::ForceArrayReturn; } bool FormulaToken::operator==( const FormulaToken& rToken ) const diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx index adfe4e210f2d..d1052c3a4142 100644 --- a/formula/source/ui/dlg/formula.cxx +++ b/formula/source/ui/dlg/formula.cxx @@ -757,6 +757,7 @@ void FormulaDlg_Impl::MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, co case ParamClass::ForceArray: case ParamClass::ReferenceOrForceArray: case ParamClass::SuppressedReferenceOrForceArray: + case ParamClass::ForceArrayReturn: ; // nothing, only as array/matrix // no default to get compiler warning } diff --git a/include/formula/paramclass.hxx b/include/formula/paramclass.hxx index a1e564819457..30773c35e016 100644 --- a/include/formula/paramclass.hxx +++ b/include/formula/paramclass.hxx @@ -67,7 +67,12 @@ namespace formula Reference in JumpMatrix context should use the result matrix instead of the array of references. Never used as initial parameter classification. */ - SuppressedReferenceOrForceArray + SuppressedReferenceOrForceArray, + + /** A function return forces the caller into array mode for this one + call, making it behave like it had ForceArray but not propagated to + any further operators in the same parameter. */ + ForceArrayReturn }; } diff --git a/sc/source/core/tool/parclass.cxx b/sc/source/core/tool/parclass.cxx index 4d1672bbd079..ce6c9094cc71 100644 --- a/sc/source/core/tool/parclass.cxx +++ b/sc/source/core/tool/parclass.cxx @@ -146,7 +146,7 @@ const ScParameterClassification::RawData ScParameterClassification::pRawData[] = { ocForecast_ETS_STA, {{ ForceArray, ForceArray, ForceArray, Value, Value, Value }, 0, Value }}, { ocForecast_ETS_STM, {{ ForceArray, ForceArray, ForceArray, Value, Value, Value }, 0, Value }}, { ocFormula, {{ Reference }, 0, Value }}, - { ocFrequency, {{ ReferenceOrForceArray, ReferenceOrForceArray }, 0, Value }}, + { ocFrequency, {{ ReferenceOrForceArray, ReferenceOrForceArray }, 0, ForceArrayReturn }}, { ocGCD, {{ Reference }, 1, Value }}, { ocGeoMean, {{ Reference }, 1, Value }}, { ocGreater, {{ Array, Array }, 0, Value }},