Kaydet (Commit) a2aea8ba authored tarafından Eike Rathke's avatar Eike Rathke

IFS/SWITCH propagate error only for active paths, tdf#97831 follow-up

Change-Id: Ief07f0d582e2f283a3ede88a7d202e8cff0e14bf
üst bc4d4654
...@@ -3601,6 +3601,8 @@ bool IsErrFunc(OpCode oc) ...@@ -3601,6 +3601,8 @@ bool IsErrFunc(OpCode oc)
case ocIfError : case ocIfError :
case ocIfNA : case ocIfNA :
case ocErrorType_ODF : case ocErrorType_ODF :
case ocIfs_MS:
case ocSwitch_MS:
return true; return true;
default: default:
return false; return false;
......
...@@ -1872,6 +1872,7 @@ void ScInterpreter::ScIfs_MS() ...@@ -1872,6 +1872,7 @@ void ScInterpreter::ScIfs_MS()
ReverseStack( nParamCount ); ReverseStack( nParamCount );
nGlobalError = 0; // propagate only for condition or active result path
bool bFinished = false; bool bFinished = false;
while ( nParamCount > 0 && !bFinished && !nGlobalError ) while ( nParamCount > 0 && !bFinished && !nGlobalError )
{ {
...@@ -1930,6 +1931,7 @@ void ScInterpreter::ScSwitch_MS() ...@@ -1930,6 +1931,7 @@ void ScInterpreter::ScSwitch_MS()
ReverseStack( nParamCount ); ReverseStack( nParamCount );
nGlobalError = 0; // propagate only for match or active result path
bool isValue = false; bool isValue = false;
double fRefVal = 0; double fRefVal = 0;
svl::SharedString aRefStr; svl::SharedString aRefStr;
...@@ -1968,6 +1970,7 @@ void ScInterpreter::ScSwitch_MS() ...@@ -1968,6 +1970,7 @@ void ScInterpreter::ScSwitch_MS()
return; return;
} }
nParamCount--; nParamCount--;
sal_uInt16 nFirstMatchError = 0;
bool bFinished = false; bool bFinished = false;
while ( nParamCount > 1 && !bFinished && !nGlobalError ) while ( nParamCount > 1 && !bFinished && !nGlobalError )
{ {
...@@ -1977,14 +1980,17 @@ void ScInterpreter::ScSwitch_MS() ...@@ -1977,14 +1980,17 @@ void ScInterpreter::ScSwitch_MS()
fVal = GetDouble(); fVal = GetDouble();
else else
aStr = GetString(); aStr = GetString();
if (!nFirstMatchError)
nFirstMatchError = nGlobalError;
nParamCount--; nParamCount--;
if ( ( isValue && rtl::math::approxEqual( fRefVal, fVal ) ) || if ( !nGlobalError && (( isValue && rtl::math::approxEqual( fRefVal, fVal ) ) ||
( !isValue && aRefStr.getDataIgnoreCase() == aStr.getDataIgnoreCase() ) ) ( !isValue && aRefStr.getDataIgnoreCase() == aStr.getDataIgnoreCase() )) )
{ {
// TRUE // TRUE
if ( nParamCount < 1 ) if ( nParamCount < 1 )
{ {
// no parameter given for THEN // no parameter given for THEN
nGlobalError = nFirstMatchError;
PushParameterExpected(); PushParameterExpected();
return; return;
} }
...@@ -2007,11 +2013,13 @@ void ScInterpreter::ScSwitch_MS() ...@@ -2007,11 +2013,13 @@ void ScInterpreter::ScSwitch_MS()
PushNA(); PushNA();
return; return;
} }
nGlobalError = 0;
} }
} }
if ( nGlobalError || !bFinished ) if ( nGlobalError || !bFinished )
{ {
nGlobalError = nFirstMatchError;
if ( !bFinished ) if ( !bFinished )
PushNA(); // no true expression found PushNA(); // no true expression found
if ( nGlobalError ) if ( nGlobalError )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment