diff options
author | Eike Rathke <erack@redhat.com> | 2017-06-13 13:30:57 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-06-13 13:37:19 +0200 |
commit | 8f187d38b18f65ed70a225f63869147605fda704 (patch) | |
tree | 84e4d5980db40b94f1c137f72a0a5bd28c928ca9 /sc/source | |
parent | cea458998745f0084271b41d90c92ad27ad071eb (diff) |
Handle SUMPRODUCT with reference list and array of references, tdf#58874
Note that Excel does not handle this the same, strangely it returns 0 for array
of references, not even an error, as if all products involved a 0 somewhere.
For reference list (union operator) it returns #VALUE!
Change-Id: I4540a4f221518c8991c7fa3cf3f1f08f28a49038
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/tool/interpr5.cxx | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx index 4e0ee214897c..90c447e59eb8 100644 --- a/sc/source/core/tool/interpr5.cxx +++ b/sc/source/core/tool/interpr5.cxx @@ -1690,14 +1690,19 @@ public: void ScInterpreter::ScSumProduct() { - sal_uInt8 nParamCount = GetByte(); + short nParamCount = GetByte(); if ( !MustHaveParamCount( nParamCount, 1, 30 ) ) return; + // XXX NOTE: Excel returns #VALUE! for reference list and 0 (why?) for + // array of references. We calculate the proper individual arrays if sizes + // match. + + size_t nInRefList = 0; ScMatrixRef pMatLast; ScMatrixRef pMat; - pMatLast = GetMatrix(); + pMatLast = GetMatrix( --nParamCount, nInRefList); if (!pMatLast) { PushIllegalParameter(); @@ -1709,9 +1714,9 @@ void ScInterpreter::ScSumProduct() std::vector<double> aResArray; pMatLast->GetDoubleArray(aResArray); - for (sal_uInt16 i = 1; i < nParamCount; ++i) + while (nParamCount--) { - pMat = GetMatrix(); + pMat = GetMatrix( nParamCount, nInRefList); if (!pMat) { PushIllegalParameter(); |