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

Kohei Yoshida kohei.yoshida at collabora.com
Mon Sep 9 22:23:37 PDT 2013


Rebased ref, commits from common ancestor:
commit b44aca7cfc0c7b73f6213ee3f5d4c5f3b2fc8e95
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..91e91dc 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,16 @@ 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;
+                        SCROW nLastRefRowOffset = aAbs.aEnd.Row() - mrPos.Row();
+                        SCROW nLastRefRow = mrPos.Row() + nLen - 1 + nLastRefRowOffset;
+                        SCROW nNewLength = nLastRefRow - aAbs.aStart.Row() + 1;
+                        if (nNewLength > nArrayLength)
+                            nArrayLength = nNewLength;
                     }
 
                     // 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