sc/source/core/data/formulacell.cxx |   28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

New commits:
commit 2ea9b75327755aca7d5ee66ab25b371e57f8f5ee
Author: Kohei Yoshida <kohei.yosh...@gmail.com>
Date:   Mon Apr 29 17:51:41 2013 -0400

    Handle range reference as well for group calculation. Not tested yet.
    
    Change-Id: I3bf58a20f0b8c017862ae23202e4b2272f7c952c

diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index ba039b6..5987253 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
                 {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to