diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-07-02 16:47:31 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-07-02 23:14:46 -0400 |
commit | 75cfc9a332b224597872960df22091ca76747058 (patch) | |
tree | 02993133144ead574e71f34d99e4a5291db1d9b6 /sc | |
parent | d61233a388284383a939e2f26a0e25b9ad243898 (diff) |
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
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/tool/formulagroup.cxx | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx index 4754bd003e0f..3dd43e308882 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; } |