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

New commits:
commit 91ca6a8eded939373e78ecf6091b3598936f2c08
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Fri Mar 11 21:44:21 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Mar 14 14:20:26 2022 +0100

    Related: tdf#111675 Clear global error for arguments if possible
    
    ... i.e. if the last result / current stack value is svError
    already (usually is nowadays in case of error) and error
    evaluating functions may be pending.
    
    Change-Id: I36fc0f169d36dfa7007e8bd3a5c368ed2bb3c919
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131405
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins
    (cherry picked from commit efb713febeaaf3e4b17886d405d46845d4a0e676)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131363
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index bc99592a15a8..1a0eed81302f 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -4540,6 +4540,18 @@ StackVar ScInterpreter::Interpret()
             }
             if ( nErrorFunction >= nErrorFunctionCount )
                 ++nErrorFunction;   // that's it, error => terminate
+            else if (nErrorFunctionCount && sp && GetStackType() == svError)
+            {
+                // Clear global error if we have an individual error result, so
+                // an error evaluating function can receive multiple arguments
+                // and not all evaluated arguments inheriting the error.
+                // This is important for at least IFS() and SWITCH() as long as
+                // they are classified as error evaluating functions and not
+                // implemented as short-cutting jump code paths, but also for
+                // more than one evaluated argument to AGGREGATE() or COUNT()
+                // that may ignore errors.
+                nGlobalError = FormulaError::NONE;
+            }
         }
     }
 

Reply via email to