[Libreoffice-commits] core.git: sc/source

Eike Rathke erack at redhat.com
Tue Jun 13 11:37:44 UTC 2017


 sc/source/core/tool/interpr5.cxx |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

New commits:
commit 8f187d38b18f65ed70a225f63869147605fda704
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Jun 13 13:30:57 2017 +0200

    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

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();


More information about the Libreoffice-commits mailing list