[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Tue Jul 2 13:48:21 PDT 2013


 sc/source/core/tool/formulagroup.cxx |   21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

New commits:
commit 64fdd070cbafb16ad38fb48bbf47175d18333e90
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jul 2 16:47:31 2013 -0400

    Be aware that the top row may not always be the top of the group.
    
    Adjust the length and the starting row position for accordingly.
    
    Change-Id: I2f9c5a515887b98334bad51c5409461d5dd1505d

diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 4754bd0..3dd43e3 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -18,6 +18,8 @@
 
 #include "formula/vectortoken.hxx"
 
+#include <vector>
+
 namespace sc {
 
 ScMatrixRef FormulaGroupInterpreterSoftware::inverseMatrix(const ScMatrix& /*rMat*/)
@@ -29,12 +31,16 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
                                                 const ScFormulaCellGroupRef& xGroup,
                                                 ScTokenArray& rCode)
 {
-    // Until we implement group calculation for real, decompose the group into
-    // individual formula token arrays for individual calculation.
+    // Decompose the group into individual cells and calculate them individually.
+
     ScAddress aTmpPos = rTopPos;
-    for (sal_Int32 i = 0; i < xGroup->mnLength; ++i)
+    SCROW nOffset = rTopPos.Row() - xGroup->mnStart;
+    SCROW nLength = xGroup->mnLength - nOffset;
+    std::vector<double> aResults;
+    aResults.reserve(nLength);
+    for (SCROW i = 0; i < nLength; ++i)
     {
-        aTmpPos.SetRow(xGroup->mnStart + i);
+        aTmpPos.SetRow(rTopPos.Row() + i);
         ScTokenArray aCode2;
         for (const formula::FormulaToken* p = rCode.First(); p; p = rCode.Next())
         {
@@ -89,11 +95,12 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
         aComp.CompileTokenArray(); // Create RPN token array.
         ScInterpreter aInterpreter(pDest, &rDoc, aTmpPos, aCode2);
         aInterpreter.Interpret();
-        pDest->SetResultToken(aInterpreter.GetResultToken().get());
-        pDest->ResetDirty();
-        pDest->SetChanged(true);
+        aResults.push_back(aInterpreter.GetResultToken()->GetDouble());
     } // for loop end (xGroup->mnLength)
 
+    if (!aResults.empty())
+        rDoc.SetFormulaResults(rTopPos, &aResults[0], aResults.size());
+
     return true;
 }
 


More information about the Libreoffice-commits mailing list