[Libreoffice-commits] core.git: sc/source

Jochen Nitschke j.nitschke+logerrit at ok.de
Wed Mar 16 06:55:08 UTC 2016


 sc/source/core/tool/interpr4.cxx |   70 ++++++++++++++++++---------------------
 1 file changed, 34 insertions(+), 36 deletions(-)

New commits:
commit f53fc22f04ccd799035acbec718c42176a4554c9
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Tue Mar 15 09:25:14 2016 +0100

    sc: replace define with helper
    
    Change-Id: I79915d5449e64c9eb46ff91ce3279ce27af12fec
    Reviewed-on: https://gerrit.libreoffice.org/23257
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 2869133..027a253 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -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 :
-
-        switch ( eOp )
-        {
-            CASE_OCERRFUNC
-                 ++ nErrorFunction;
-            default:
-                ;   // nothing
-        }
+        if( IsErrFunc(eOp) )
+            ++nErrorFunction;
+
         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 )


More information about the Libreoffice-commits mailing list