[Libreoffice-commits] core.git: Branch 'private/kohei/sort-ref-update' - 2 commits - sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Sun Jul 13 11:51:04 PDT 2014


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

New commits:
commit 4e2c12fd7c8b74351a29047ce68f5dfa7f29228e
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Sun Jul 13 14:51:56 2014 -0400

    Reorder columns without using ScSortInfo array.
    
    Change-Id: Iee17dc79db1336fdd7921e7ac7e1ee3da066f1de

diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 218c4df..008e883 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -658,40 +658,38 @@ public:
 void ScTable::SortReorderByColumn(
     ScSortInfoArray* pArray, SCROW nRow1, SCROW nRow2, bool bPattern, ScProgress* pProgress )
 {
-    size_t nCount = pArray->GetCount();
     SCCOLROW nStart = pArray->GetStart();
     SCCOLROW nLast = pArray->GetLast();
-    ScSortInfo** ppInfo = pArray->GetFirstArray();
 
-    std::vector<ScSortInfo*> aTable(nCount);
-
-    SCSIZE nPos;
-    for ( nPos = 0; nPos < nCount; nPos++ )
-        aTable[ppInfo[nPos]->nOrg - nStart] = ppInfo[nPos];
+    std::vector<SCCOLROW> aIndices = pArray->GetOldIndices();
+    size_t nCount = aIndices.size();
 
     // Cut formula grouping at row and reference boundaries before the reordering.
     ScRange aSortRange(nStart, nRow1, nTab, nLast, nRow2, nTab);
     for (SCCOL nCol = nStart; nCol <= nLast; ++nCol)
         aCol[nCol].SplitFormulaGroupByRelativeRef(aSortRange);
 
+    // table to keep track of column index to position in the index table.
+    std::vector<SCCOLROW> aPosTable(nCount);
+    for (size_t i = 0; i < nCount; ++i)
+        aPosTable[aIndices[i]-nStart] = i;
+
     SCCOLROW nDest = nStart;
-    for ( nPos = 0; nPos < nCount; nPos++, nDest++ )
+    for (size_t i = 0; i < nCount; ++i, ++nDest)
     {
-        SCCOLROW nOrg = ppInfo[nPos]->nOrg;
-        if ( nDest != nOrg )
+        SCCOLROW nSrc = aIndices[i];
+        if (nDest != nSrc)
         {
-            aCol[nDest].Swap(aCol[nOrg], nRow1, nRow2, bPattern);
+            aCol[nDest].Swap(aCol[nSrc], nRow1, nRow2, bPattern);
 
-            // neue Position des weggeswapten eintragen
-            ScSortInfo* p = ppInfo[nPos];
-            p->nOrg = nDest;
-            ::std::swap(p, aTable[nDest-nStart]);
-            p->nOrg = nOrg;
-            ::std::swap(p, aTable[nOrg-nStart]);
-            OSL_ENSURE( p == ppInfo[nPos], "SortReorder: nOrg MisMatch" );
+            // Update the position of the index that was originally equal to nDest.
+            size_t nPos = aPosTable[nDest-nStart];
+            aIndices[nPos] = nSrc;
+            aPosTable[nSrc-nStart] = nPos;
         }
-        if(pProgress)
-            pProgress->SetStateOnPercent( nPos );
+
+        if (pProgress)
+            pProgress->SetStateOnPercent(i);
     }
 
     // Reset formula cell positions which became out-of-sync after column reordering.
commit 62cc06d6ba54789050c6da32449af291c87c4646
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Sun Jul 13 10:39:17 2014 -0400

    Don't forget to pass this flag.
    
    Change-Id: Ibc95b67266eb6a96cebdd026ac51a419e978f197

diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 061dd56..218c4df 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -463,6 +463,7 @@ ScSortInfoArray* ScTable::CreateSortInfoArray( const sc::ReorderParam& rParam )
         SCCOL nCol2 = rParam.maSortRange.aEnd.Col();
 
         pArray = new ScSortInfoArray(0, nRow1, nRow2);
+        pArray->SetKeepQuery(rParam.mbHiddenFiltered);
 
         initDataRows(
             *pArray, *this, aCol, nCol1, nRow1, nCol2, nRow2,


More information about the Libreoffice-commits mailing list