diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-04-29 17:51:41 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-04-30 13:10:43 -0400 |
commit | f07601a255eaad729fdb2fffc36336a4cd364501 (patch) | |
tree | 712f7e50f745bf377ac4666d874807a7da9461b8 /sc/source | |
parent | dfc3f290b5934326a8e042eb81c1b2c81ee0a1ec (diff) |
Handle range reference as well for group calculation. Not tested yet.
Change-Id: I3bf58a20f0b8c017862ae23202e4b2272f7c952c
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index ba039b6e7422..598725350e7b 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -3023,8 +3023,32 @@ bool ScFormulaCell::InterpretFormulaGroup() aRef.CalcAbsIfRel(aPos); if (aRef.Ref1.IsRowRel() || aRef.Ref2.IsRowRel()) { - // TODO: Implement this. - return false; + // Row reference is relative. + bool bAbsFirst = !aRef.Ref1.IsRowRel(); + bool bAbsLast = !aRef.Ref2.IsRowRel(); + ScAddress aRefPos(aRef.Ref1.nCol, aRef.Ref1.nRow, aRef.Ref1.nTab); + size_t nCols = aRef.Ref2.nCol - aRef.Ref1.nCol + 1; + std::vector<const double*> aArrays; + aArrays.reserve(nCols); + SCROW nLength = xGroup->mnLength; + if (!bAbsLast) + { + // range end position is relative. Extend it. + nLength += aRef.Ref2.nRow - aRef.Ref1.nRow; + } + + for (SCCOL i = aRef.Ref1.nCol; i <= aRef.Ref2.nCol; ++i) + { + aRefPos.SetCol(i); + const double* pArray = pDocument->FetchDoubleArray(aCxt, aRefPos, nLength); + if (!pArray) + return false; + + aArrays.push_back(pArray); + } + + formula::DoubleVectorRefToken aTok(aArrays, nLength, bAbsFirst, bAbsLast); + aCode.AddToken(aTok); } else { |