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

Eike Rathke erack at redhat.com
Tue May 3 17:16:31 UTC 2016


 sc/source/core/tool/interpr4.cxx |    2 ++
 sc/source/core/tool/interpr8.cxx |   12 ++++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

New commits:
commit a2aea8bac55cef23297573733ba28f563f5aa791
Author: Eike Rathke <erack at redhat.com>
Date:   Tue May 3 19:12:17 2016 +0200

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

diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 3cc7c9e..684913b 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3601,6 +3601,8 @@ bool IsErrFunc(OpCode oc)
         case ocIfError :
         case ocIfNA :
         case ocErrorType_ODF :
+        case ocIfs_MS:
+        case ocSwitch_MS:
             return true;
         default:
             return false;
diff --git a/sc/source/core/tool/interpr8.cxx b/sc/source/core/tool/interpr8.cxx
index 771210e..58e94cf 100644
--- a/sc/source/core/tool/interpr8.cxx
+++ b/sc/source/core/tool/interpr8.cxx
@@ -1872,6 +1872,7 @@ void ScInterpreter::ScIfs_MS()
 
     ReverseStack( nParamCount );
 
+    nGlobalError = 0;   // propagate only for condition or active result path
     bool bFinished = false;
     while ( nParamCount > 0 && !bFinished && !nGlobalError )
     {
@@ -1930,6 +1931,7 @@ void ScInterpreter::ScSwitch_MS()
 
     ReverseStack( nParamCount );
 
+    nGlobalError = 0;   // propagate only for match or active result path
     bool isValue = false;
     double fRefVal = 0;
     svl::SharedString aRefStr;
@@ -1968,6 +1970,7 @@ void ScInterpreter::ScSwitch_MS()
             return;
     }
     nParamCount--;
+    sal_uInt16 nFirstMatchError = 0;
     bool bFinished = false;
     while ( nParamCount > 1 && !bFinished && !nGlobalError )
     {
@@ -1977,14 +1980,17 @@ void ScInterpreter::ScSwitch_MS()
             fVal = GetDouble();
         else
             aStr = GetString();
+        if (!nFirstMatchError)
+            nFirstMatchError = nGlobalError;
         nParamCount--;
-        if ( ( isValue && rtl::math::approxEqual( fRefVal, fVal ) ) ||
-             ( !isValue && aRefStr.getDataIgnoreCase() == aStr.getDataIgnoreCase() ) )
+        if ( !nGlobalError && (( isValue && rtl::math::approxEqual( fRefVal, fVal ) ) ||
+             ( !isValue && aRefStr.getDataIgnoreCase() == aStr.getDataIgnoreCase() )) )
         {
             // TRUE
             if ( nParamCount < 1 )
             {
                 // no parameter given for THEN
+                nGlobalError = nFirstMatchError;
                 PushParameterExpected();
                 return;
             }
@@ -2007,11 +2013,13 @@ void ScInterpreter::ScSwitch_MS()
                 PushNA();
                 return;
             }
+            nGlobalError = 0;
         }
     }
 
     if ( nGlobalError || !bFinished  )
     {
+        nGlobalError = nFirstMatchError;
         if ( !bFinished )
             PushNA(); // no true expression found
         if ( nGlobalError )


More information about the Libreoffice-commits mailing list