sc/source/core/tool/interpr6.cxx |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

New commits:
commit dad860ac671dd629401ecdf62b804e6e42b176ec
Author:     Eike Rathke <[email protected]>
AuthorDate: Fri May 6 23:49:13 2022 +0200
Commit:     Caolán McNamara <[email protected]>
CommitDate: Sat May 7 21:04:23 2022 +0200

    Resolves: tdf#148843 Handle single reference error values correctly
    
    ... if errors are to be ignored through AGGREGATE(). Affected were
    AVERAGE, SUM, SUMSQ and PRODUCT. An error encountered in this
    constellation lead to the next argument being ignored as well.
    
    Change-Id: Ief28d79b4c230b1a2b6f8f0a865fbf8f51854c4c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133964
    Reviewed-by: Eike Rathke <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit 4ea44fdb19e568093ab1e0549c3ffa33296a486b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133868
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 9dd442624884..0d80a8842566 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -637,8 +637,14 @@ void ScInterpreter::IterateParameters( ScIterFunc eFunc, 
bool bTextAsZero )
                     }
                     else if (aCell.hasNumeric())
                     {
-                        nCount++;
                         fVal = GetCellValue(aAdr, aCell);
+                        if (nGlobalError != FormulaError::NONE)
+                        {
+                            if (eFunc == ifCOUNT || (mnSubTotalFlags & 
SubtotalFlags::IgnoreErrVal))
+                                nGlobalError = FormulaError::NONE;
+                            break;
+                        }
+                        nCount++;
                         CurFmtToFuncFmt();
                         switch( eFunc )
                         {
@@ -646,13 +652,6 @@ void ScInterpreter::IterateParameters( ScIterFunc eFunc, 
bool bTextAsZero )
                             case ifSUM:     fRes += fVal; break;
                             case ifSUMSQ:   fRes += fVal * fVal; break;
                             case ifPRODUCT: fRes *= fVal; break;
-                            case ifCOUNT:
-                                if ( nGlobalError != FormulaError::NONE )
-                                {
-                                    nGlobalError = FormulaError::NONE;
-                                    nCount--;
-                                }
-                                break;
                             default: ; // nothing
                         }
                     }

Reply via email to