diff options
author | Eike Rathke <erack@redhat.com> | 2024-05-31 17:34:35 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2024-06-03 13:24:12 +0200 |
commit | 5af051e9e6b0f86fe471c4f040506ee9fdb91e92 (patch) | |
tree | 10d583167a1ffd555f89f06ff6ee7cc41e47554b /sc | |
parent | c8d067868792e6de49bde70507bd30261d3fbd3d (diff) |
Resolves: tdf#158789 operate on query array if no extra array or range given
Also push error and bail out early if there was an error, or more
important pResultMatrix is nullptr.
Change-Id: I1094ed9d14795ea1bc3f4ff61d687cc28d0b94fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168300
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
(cherry picked from commit a523e9bf2d54fc84583c9da05af592297b055e40)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168315
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index e372228721e3..c5113ba204aa 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -5575,7 +5575,8 @@ void ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) ScMatrixRef pResultMatrix = QueryMat( pQueryMatrix, aOptions); if (nGlobalError != FormulaError::NONE || !pResultMatrix) { - SetError( FormulaError::IllegalParameter); + PushIllegalParameter(); + return; } if (pSumExtraMatrix) @@ -5599,6 +5600,25 @@ void ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) } } } + else if (!bSumExtraRange) + { + for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol) + { + for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow) + { + if (pResultMatrix->IsValue( nCol, nRow) && + pResultMatrix->GetDouble( nCol, nRow)) + { + if (pQueryMatrix->IsValue( nCol, nRow)) + { + fVal = pQueryMatrix->GetDouble( nCol, nRow); + ++fCount; + fSum += fVal; + } + } + } + } + } else { for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol) |