[Libreoffice-commits] core.git: Branch 'private/kohei/formula-opencl-work' - sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Mon Sep 9 21:25:35 PDT 2013


 sc/source/core/data/formulacell.cxx  |    6 +++---
 sc/source/core/tool/formulagroup.cxx |   11 ++++++++---
 2 files changed, 11 insertions(+), 6 deletions(-)

New commits:
commit d087e58d0787584f2829f3cf854d4d6b217e0c05
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Sep 10 00:11:13 2013 -0400

    Fix several logic errors in required array size calculation.
    
    Change-Id: Ife05e21583d14c873d38c09d78e964cdb3817d6c

diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 7e8a975..fe27177 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -3437,7 +3437,7 @@ public:
                 case svDoubleRef:
                 {
                     ScComplexRefData aRef = pToken->GetDoubleRef();
-                    ScRange aAbs = aRef.toAbs(mrCell.aPos);
+                    ScRange aAbs = aRef.toAbs(mrPos);
 
                     // Check for self reference.
                     if (aRef.Ref1.IsRowRel())
@@ -3463,12 +3463,12 @@ public:
                     size_t nCols = aAbs.aEnd.Col() - aAbs.aStart.Col() + 1;
                     std::vector<formula::VectorRefArray> aArrays;
                     aArrays.reserve(nCols);
-                    SCROW nArrayLength = nLen;
                     SCROW nRefRowSize = aAbs.aEnd.Row() - aAbs.aStart.Row() + 1;
+                    SCROW nArrayLength = nRefRowSize;
                     if (!bAbsLast)
                     {
                         // range end position is relative. Extend the array length.
-                        nArrayLength += nRefRowSize - 1;
+                        nArrayLength += nLen - 1;
                     }
 
                     // Trim trailing empty rows.
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 5dff3d9..1dbe5bd 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -204,9 +204,14 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
                         nRowEnd += i;
                     size_t nRowSize = nRowEnd - nRowStart + 1;
                     ScMatrixRef pMat(new ScMatrix(nColSize, nRowSize));
-                    if (p2->GetArrayLength() < nRowSize)
-                        // Data array is shorter than the row size of the reference. Truncate it.
-                        nRowSize = p2->GetArrayLength();
+
+                    size_t nDataRowEnd = p2->GetArrayLength() - 1;
+                    if (nRowStart > nDataRowEnd)
+                        // Referenced rows are all empty.
+                        nRowSize = 0;
+                    else if (nRowEnd > nDataRowEnd)
+                        // Data array is shorter than the row size of the reference. Truncate it to the data.
+                        nRowSize -= nRowEnd - nDataRowEnd;
 
                     for (size_t nCol = 0; nCol < nColSize; ++nCol)
                     {


More information about the Libreoffice-commits mailing list