sc: replace define with helper

Change-Id: I79915d5449e64c9eb46ff91ce3279ce27af12fec
Reviewed-on: https://gerrit.libreoffice.org/23257
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
Jochen Nitschke 2016-03-15 09:25:14 +01:00 committed by Noel Grandin
parent 53f645a9c9
commit f53fc22f04

View File

@ -3565,8 +3565,37 @@ double applyImplicitIntersection(const sc::RangeMatrix& rMat, const ScAddress& r
return fVal;
}
// Test for Functions that evaluate an error code and directly set nGlobalError to 0
bool IsErrFunc(OpCode oc)
{
switch (oc)
{
case ocCount :
case ocCount2 :
case ocErrorType :
case ocIsEmpty :
case ocIsErr :
case ocIsError :
case ocIsFormula :
case ocIsLogical :
case ocIsNA :
case ocIsNonString :
case ocIsRef :
case ocIsString :
case ocIsValue :
case ocN :
case ocType :
case ocIfError :
case ocIfNA :
case ocErrorType_ODF :
return true;
default:
return false;
}
}
} //namespace
StackVar ScInterpreter::Interpret()
{
short nRetTypeExpr = css::util::NumberFormat::UNDEFINED;
@ -4132,48 +4161,17 @@ StackVar ScInterpreter::Interpret()
pJumpMatrix = nullptr;
} while ( bGotResult );
// Functions that evaluate an error code and directly set nGlobalError to 0,
// usage: switch( OpCode ) { CASE_OCERRFUNC statements; }
#define CASE_OCERRFUNC \
case ocCount : \
case ocCount2 : \
case ocErrorType : \
case ocIsEmpty : \
case ocIsErr : \
case ocIsError : \
case ocIsFormula : \
case ocIsLogical : \
case ocIsNA : \
case ocIsNonString : \
case ocIsRef : \
case ocIsString : \
case ocIsValue : \
case ocN : \
case ocType : \
case ocIfError : \
case ocIfNA : \
case ocErrorType_ODF :
if( IsErrFunc(eOp) )
++nErrorFunction;
switch ( eOp )
{
CASE_OCERRFUNC
++ nErrorFunction;
default:
; // nothing
}
if ( nGlobalError )
{
if ( !nErrorFunctionCount )
{ // count of errorcode functions in formula
for ( FormulaToken* t = rArr.FirstRPN(); t; t = rArr.NextRPN() )
{
switch ( t->GetOpCode() )
{
CASE_OCERRFUNC
++nErrorFunctionCount;
default:
; // nothing
}
if ( IsErrFunc(t->GetOpCode()) )
++nErrorFunctionCount;
}
}
if ( nErrorFunction >= nErrorFunctionCount )