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 <erack@redhat.com>
Tested-by: Jenkins
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 9dd4426..0d80a88 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
                        }
                    }