[Libreoffice-commits] core.git: Branch 'private/kohei/calc-sort-fix' - sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Mon Apr 21 12:59:25 PDT 2014


 sc/source/core/data/table3.cxx |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

New commits:
commit 04d363890d54c47a9889f7a7277c04e5b3fa52b3
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Apr 21 15:56:31 2014 -0400

    Add empty block at the top to keep row and element positions in sync.
    
    Otherwise formula cells would mis-behave during grouping.  Also, the
    range-based release() was renamed to release_range() to avoid unwanted
    function overloading due to implicit type conversion.
    
    Change-Id: I3dc1421f89926f161963eede9a2c8eb477d7e5be

diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index bc43334..dfca524 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -383,6 +383,11 @@ struct SortedColumn : boost::noncopyable
     sc::CellStoreType maCells;
     sc::CellTextAttrStoreType maCellTextAttrs;
     sc::BroadcasterStoreType maBroadcasters;
+
+    SortedColumn( size_t nTopEmptyRows ) :
+        maCells(nTopEmptyRows),
+        maCellTextAttrs(nTopEmptyRows),
+        maBroadcasters(nTopEmptyRows) {}
 };
 
 }
@@ -446,7 +451,12 @@ void ScTable::SortReorder( ScSortInfoArray* pArray, ScProgress* pProgress )
         boost::ptr_vector<SortedColumn> aSortedCols; // storage for copied cells.
         aSortedCols.reserve(nColCount);
         for (size_t i = 0; i < nColCount; ++i)
-            aSortedCols.push_back(new SortedColumn);
+        {
+            // In the sorted column container, element positions and row
+            // positions must match, else formula cells may mis-behave during
+            // grouping.
+            aSortedCols.push_back(new SortedColumn(nRow1));
+        }
 
         for (size_t i = 0; i < pRows->size(); ++i)
         {
@@ -515,24 +525,24 @@ void ScTable::SortReorder( ScSortInfoArray* pArray, ScProgress* pProgress )
             {
                 sc::CellStoreType& rDest = aCol[nThisCol].maCells;
                 sc::CellStoreType& rSrc = aSortedCols[i].maCells;
-                rSrc.transfer(0, rSrc.size()-1, rDest, nRow1);
+                rSrc.transfer(nRow1, aSortParam.nRow2, rDest, nRow1);
             }
 
             {
                 sc::CellTextAttrStoreType& rDest = aCol[nThisCol].maCellTextAttrs;
                 sc::CellTextAttrStoreType& rSrc = aSortedCols[i].maCellTextAttrs;
-                rSrc.transfer(0, rSrc.size()-1, rDest, nRow1);
+                rSrc.transfer(nRow1, aSortParam.nRow2, rDest, nRow1);
             }
 
             {
                 sc::BroadcasterStoreType& rBCDest = aCol[nThisCol].maBroadcasters;
 
                 // Release current broadcasters first, to prevent them from getting deleted.
-                rBCDest.release(nRow1, aSortParam.nRow2);
+                rBCDest.release_range(nRow1, aSortParam.nRow2);
 
                 // Transfer sorted broadcaster segment to the document.
                 sc::BroadcasterStoreType& rBCSrc = aSortedCols[i].maBroadcasters;
-                rBCSrc.transfer(0, rBCSrc.size()-1, rBCDest, nRow1);
+                rBCSrc.transfer(nRow1, aSortParam.nRow2, rBCDest, nRow1);
             }
 
             aCol[nThisCol].CellStorageModified();


More information about the Libreoffice-commits mailing list