[Libreoffice-commits] core.git: Branch 'libreoffice-6-4-3' - sc/source
Eike Rathke (via logerrit)
logerrit at kemper.freedesktop.org
Fri Apr 3 15:46:24 UTC 2020
sc/source/core/tool/interpr8.cxx | 41 +++++++++++++++++++++++++++++----------
1 file changed, 31 insertions(+), 10 deletions(-)
New commits:
commit b9728374522326364d8d579360319f7b7ebe639b
Author: Eike Rathke <erack at redhat.com>
AuthorDate: Fri Mar 27 17:54:09 2020 +0100
Commit: Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Fri Apr 3 17:45:49 2020 +0200
Resolves: tdf#131096 Handle argument error and propagate
For etsPIAdd and etsPIMult also check if the fPILevel parameter
was actually specified (explicitly or missing/omitted) and do not
pop the 3rd parameter if not. GetDoubleWithDefault() can't handle
that as apparently was erroneously assumed.
Use IllegalArgument error instead of IllegalParameter in most
cases (the parameter is fine but the argument value is not).
Actually propagate ScETSForecastCalculation::mnErrorValue if set
as PushMatrix() does not, on purpose.
Change-Id: Ia2db5b0a7a388f0f40b73c6a4f66debbedec41e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91232
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Jenkins
(cherry picked from commit 811b36e4db240be3a21a4d184b085630efcc09b7)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91185
Reviewed-by: Michael Stahl <michael.stahl at cib.de>
Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>
Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>
Tested-by: Michael Weghorn <m.weghorn at posteo.de>
diff --git a/sc/source/core/tool/interpr8.cxx b/sc/source/core/tool/interpr8.cxx
index ce4234d0853e..18a65e86f86c 100644
--- a/sc/source/core/tool/interpr8.cxx
+++ b/sc/source/core/tool/interpr8.cxx
@@ -981,6 +981,12 @@ void ScETSForecastCalculation::GetETSPredictionIntervals( const ScMatrixRef& rTM
if ( fmod( fMaxTarget, mfStepSize ) != 0.0 )
nSize++;
+ if (nSize == 0)
+ {
+ mnErrorValue = FormulaError::IllegalArgument;
+ return;
+ }
+
std::unique_ptr< double[] > xScenRange( new double[nSize]);
std::unique_ptr< double[] > xScenBase( new double[nSize]);
std::unique_ptr< double[] > xScenTrend( new double[nSize]);
@@ -1111,6 +1117,12 @@ void ScETSForecastCalculation::GetEDSPredictionIntervals( const ScMatrixRef& rTM
if ( fmod( fMaxTarget, mfStepSize ) != 0.0 )
nSize++;
+ if (nSize == 0)
+ {
+ mnErrorValue = FormulaError::IllegalArgument;
+ return;
+ }
+
double z = ScInterpreter::gaussinv( ( 1.0 + fPILevel ) / 2.0 );
double o = 1 - fPILevel;
std::vector< double > c( nSize );
@@ -1181,7 +1193,7 @@ void ScInterpreter::ScForecast_Ets( ScETSType eETSType )
nAggregation = 1;
if ( nAggregation < 1 || nAggregation > 7 )
{
- PushIllegalParameter();
+ PushIllegalArgument();
return;
}
@@ -1195,7 +1207,7 @@ void ScInterpreter::ScForecast_Ets( ScETSType eETSType )
bDataCompletion = nTemp;
else
{
- PushIllegalParameter();
+ PushIllegalArgument();
return;
}
}
@@ -1222,16 +1234,16 @@ void ScInterpreter::ScForecast_Ets( ScETSType eETSType )
double fPILevel = 0.0;
if ( nParamCount < 3 && !( nParamCount == 2 && eETSType == etsSeason ) )
{
- PushIllegalArgument();
+ PushParameterExpected();
return;
}
if ( eETSType == etsPIAdd || eETSType == etsPIMult )
{
- fPILevel = GetDoubleWithDefault( 0.95 );
+ fPILevel = (nParamCount < 4 ? 0.95 : GetDoubleWithDefault( 0.95 ));
if ( fPILevel < 0 || fPILevel > 1 )
{
- PushIllegalParameter();
+ PushIllegalArgument();
return;
}
}
@@ -1249,7 +1261,7 @@ void ScInterpreter::ScForecast_Ets( ScETSType eETSType )
if ( static_cast< int >( pTypeMat->GetDouble( j, i ) ) < 1 ||
static_cast< int >( pTypeMat->GetDouble( j, i ) ) > 9 )
{
- PushIllegalParameter();
+ PushIllegalArgument();
return;
}
}
@@ -1304,7 +1316,10 @@ void ScInterpreter::ScForecast_Ets( ScETSType eETSType )
pTMat->GetDimensions( nC, nR );
ScMatrixRef pFcMat = GetNewMat( nC, nR );
aETSCalc.GetForecastRange( pTMat, pFcMat );
- PushMatrix( pFcMat );
+ if (aETSCalc.GetError() != FormulaError::NONE)
+ PushError( aETSCalc.GetError()); // explicitly push error, PushMatrix() does not
+ else
+ PushMatrix( pFcMat );
}
break;
case etsPIAdd :
@@ -1316,13 +1331,15 @@ void ScInterpreter::ScForecast_Ets( ScETSType eETSType )
if ( nSmplInPrd == 0 )
{
aETSCalc.GetEDSPredictionIntervals( pTMat, pPIMat, fPILevel );
- PushMatrix( pPIMat );
}
else
{
aETSCalc.GetETSPredictionIntervals( pTMat, pPIMat, fPILevel );
- PushMatrix( pPIMat );
}
+ if (aETSCalc.GetError() != FormulaError::NONE)
+ PushError( aETSCalc.GetError()); // explicitly push error, PushMatrix() does not
+ else
+ PushMatrix( pPIMat );
}
break;
case etsStatAdd :
@@ -1332,13 +1349,17 @@ void ScInterpreter::ScForecast_Ets( ScETSType eETSType )
pTypeMat->GetDimensions( nC, nR );
ScMatrixRef pStatMat = GetNewMat( nC, nR );
aETSCalc.GetStatisticValue( pTypeMat, pStatMat );
- PushMatrix( pStatMat );
+ if (aETSCalc.GetError() != FormulaError::NONE)
+ PushError( aETSCalc.GetError()); // explicitly push error, PushMatrix() does not
+ else
+ PushMatrix( pStatMat );
}
break;
case etsSeason :
{
double rVal;
aETSCalc.GetSamplesInPeriod( rVal );
+ SetError( aETSCalc.GetError() );
PushDouble( rVal );
}
break;
More information about the Libreoffice-commits
mailing list