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

Kohei Yoshida kohei.yoshida at gmail.com
Mon Aug 12 13:42:07 PDT 2013


 sc/source/core/tool/sharedformula.cxx |   36 ++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

New commits:
commit 478868c419491dd5ad0921fe8b4e7f71d946dd10
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Aug 12 16:42:53 2013 -0400

    Ungroup a cell when the group length becomes 1.
    
    Change-Id: Ic656d4837ab1fc5feb4b19765ae427371dfdfe10

diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx
index 07d9029..6583ac9 100644
--- a/sc/source/core/tool/sharedformula.cxx
+++ b/sc/source/core/tool/sharedformula.cxx
@@ -38,13 +38,25 @@ void SharedFormulaUtil::splitFormulaCellGroup(const CellStoreType::position_type
 
     ScFormulaCellGroupRef xGroup = rTop.GetCellGroup();
 
-    ScFormulaCellGroupRef xGroup2(new ScFormulaCellGroup);
-    xGroup2->mbInvariant = xGroup->mbInvariant;
-    xGroup2->mnStart = nRow;
-    xGroup2->mnLength = xGroup->mnStart + xGroup->mnLength - nRow;
-    xGroup2->mpCode = xGroup->mpCode->Clone();
+    SCROW nLength2 = xGroup->mnStart + xGroup->mnLength - nRow;
+    ScFormulaCellGroupRef xGroup2;
+    if (nLength2 > 1)
+    {
+        xGroup2.reset(new ScFormulaCellGroup);
+        xGroup2->mbInvariant = xGroup->mbInvariant;
+        xGroup2->mnStart = nRow;
+        xGroup2->mnLength = nLength2;
+        xGroup2->mpCode = xGroup->mpCode->Clone();
+    }
 
     xGroup->mnLength = nRow - xGroup->mnStart;
+    if (xGroup->mnLength == 1)
+    {
+        // The top group consists of only one cell. Ungroup this.
+        ScFormulaCellGroupRef xNone;
+        ScFormulaCell& rPrev = *sc::formula_block::at(*aPos.first->data, aPos.second-1);
+        rPrev.SetCellGroup(xNone);
+    }
 
     // Apply the lower group object to the lower cells.
 #if DEBUG_COLUMN_STORAGE
@@ -56,7 +68,7 @@ void SharedFormulaUtil::splitFormulaCellGroup(const CellStoreType::position_type
     }
 #endif
     sc::formula_block::iterator itEnd = it;
-    std::advance(itEnd, xGroup2->mnLength);
+    std::advance(itEnd, nLength2);
     for (; it != itEnd; ++it)
     {
         ScFormulaCell& rCell = **it;
commit 8da8c604a3715c9f1b1cd4e720649db52d6816c5
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Aug 12 16:28:29 2013 -0400

    Fix indentation.
    
    Change-Id: I2caebb42d92bf81e3ba8809a47f833a9379e769d

diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx
index 9299e33..07d9029 100644
--- a/sc/source/core/tool/sharedformula.cxx
+++ b/sc/source/core/tool/sharedformula.cxx
@@ -48,12 +48,12 @@ void SharedFormulaUtil::splitFormulaCellGroup(const CellStoreType::position_type
 
     // Apply the lower group object to the lower cells.
 #if DEBUG_COLUMN_STORAGE
-        if (xGroup2->mnStart + xGroup2->mnLength > aPos.first->position + aPos.first->size)
-        {
-            cerr << "ScColumn::SplitFormulaCellGroup: Shared formula region goes beyond the formula block. Not good." << endl;
-            cerr.flush();
-            abort();
-        }
+    if (xGroup2->mnStart + xGroup2->mnLength > aPos.first->position + aPos.first->size)
+    {
+        cerr << "ScColumn::SplitFormulaCellGroup: Shared formula region goes beyond the formula block. Not good." << endl;
+        cerr.flush();
+        abort();
+    }
 #endif
     sc::formula_block::iterator itEnd = it;
     std::advance(itEnd, xGroup2->mnLength);


More information about the Libreoffice-commits mailing list