sc/source/core/tool/interpr4.cxx |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

New commits:
commit 62b40429946c0e5021912072dc79a60fc11fce06
Author: Eike Rathke <er...@redhat.com>
Date:   Wed Mar 9 16:18:55 2016 +0100

    Resolves: tdf#95226 second case, stack error count in JumpMatrix context
    
    For the early bail out on errors to work correctly and not prematurely
    end calculations the current error function needs to be stacked in
    JumpMatrix context, otherwise we may end up with
    ((nErrorFunction=74)>=(nErrorFunctionCount=2)) or some such..
    
    Change-Id: I3559e15180694961585db92f6aa98a46430ae372

diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 107158e..2869133 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -74,6 +74,7 @@
 #include <basic/basmgr.hxx>
 #include <vbahelper/vbaaccesshelper.hxx>
 #include <memory>
+#include <stack>
 
 using namespace com::sun::star;
 using namespace formula;
@@ -3572,6 +3573,7 @@ StackVar ScInterpreter::Interpret()
     sal_uLong nRetIndexExpr = 0;
     sal_uInt16 nErrorFunction = 0;
     sal_uInt16 nErrorFunctionCount = 0;
+    std::stack<sal_uInt16> aErrorFunctionStack;
     sal_uInt16 nStackBase;
 
     nGlobalError = 0;
@@ -4113,7 +4115,19 @@ StackVar ScInterpreter::Interpret()
             else
                 nLevel = 0;
             if ( nLevel == 1 || (nLevel == 2 && aCode.IsEndOfPath()) )
+            {
+                if (nLevel == 1)
+                    aErrorFunctionStack.push( nErrorFunction);
                 bGotResult = JumpMatrix( nLevel );
+                if (aErrorFunctionStack.empty())
+                    assert(!"ScInterpreter::Interpret - aErrorFunctionStack 
empty in JumpMatrix context");
+                else
+                {
+                    nErrorFunction = aErrorFunctionStack.top();
+                    if (bGotResult)
+                        aErrorFunctionStack.pop();
+                }
+            }
             else
                 pJumpMatrix = nullptr;
         } while ( bGotResult );
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to