From f6703ce85f9399b94958601ed6623865b205c5fb Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Fri, 19 May 2017 22:48:24 +0200 Subject: Change IterateParameters to push token instead of returning double, tdf#58874 Change-Id: Ib256d99126116379b27fc246dedf0fac2efb8c02 --- sc/source/core/inc/interpre.hxx | 2 +- sc/source/core/tool/interpr6.cxx | 31 +++++++++++++++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index 902fde9e1376..9ddf9e2c1900 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -568,7 +568,7 @@ void ScUnicode(); void ScUnichar(); void ScMin( bool bTextAsZero = false ); void ScMax( bool bTextAsZero = false ); -double IterateParameters( ScIterFunc, bool bTextAsZero = false ); +void IterateParameters( ScIterFunc, bool bTextAsZero = false ); void ScSumSQ(); void ScSum(); void ScProduct(); diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx index 31448ee48f6e..72c82e9474a7 100644 --- a/sc/source/core/tool/interpr6.cxx +++ b/sc/source/core/tool/interpr6.cxx @@ -459,7 +459,7 @@ void IterateMatrix( } } -double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) +void ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) { short nParamCount = GetByte(); double fRes = ( eFunc == ifPRODUCT ) ? 1.0 : 0.0; @@ -614,7 +614,10 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) { PopSingleRef( aAdr ); if (nGlobalError == FormulaError::NoRef) - return 0.0; + { + PushError( FormulaError::NoRef); + return; + } if ( nGlobalError != FormulaError::NONE && ( eFunc == ifCOUNT2 || eFunc == ifCOUNT || ( mnSubTotalFlags & SubtotalFlags::IgnoreErrVal ) ) ) @@ -680,7 +683,10 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) { PopDoubleRef( aRange, nParamCount, nRefInList); if (nGlobalError == FormulaError::NoRef) - return 0.0; + { + PushError( FormulaError::NoRef); + return; + } if ( nGlobalError != FormulaError::NONE && ( eFunc == ifCOUNT2 || eFunc == ifCOUNT || ( mnSubTotalFlags & SubtotalFlags::IgnoreErrVal ) ) ) @@ -717,8 +723,8 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) FormulaError nErr = aAction.getError(); if ( nErr != FormulaError::NONE ) { - SetError( nErr ); - return fRes; + PushError( nErr ); + return; } fRes += aAction.getSum(); @@ -881,37 +887,38 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) // Counts are always numbers. if( nFuncFmtType == css::util::NumberFormat::LOGICAL || eFunc == ifCOUNT || eFunc == ifCOUNT2 ) nFuncFmtType = css::util::NumberFormat::NUMBER; - return fRes; + + PushDouble( fRes); } void ScInterpreter::ScSumSQ() { - PushDouble( IterateParameters( ifSUMSQ ) ); + IterateParameters( ifSUMSQ ); } void ScInterpreter::ScSum() { - PushDouble( IterateParameters( ifSUM ) ); + IterateParameters( ifSUM ); } void ScInterpreter::ScProduct() { - PushDouble( IterateParameters( ifPRODUCT ) ); + IterateParameters( ifPRODUCT ); } void ScInterpreter::ScAverage( bool bTextAsZero ) { - PushDouble( IterateParameters( ifAVERAGE, bTextAsZero ) ); + IterateParameters( ifAVERAGE, bTextAsZero ); } void ScInterpreter::ScCount() { - PushDouble( IterateParameters( ifCOUNT ) ); + IterateParameters( ifCOUNT ); } void ScInterpreter::ScCount2() { - PushDouble( IterateParameters( ifCOUNT2 ) ); + IterateParameters( ifCOUNT2 ); } void ScInterpreter::ScRawSubtract() -- cgit v1.2.3