sc/inc/document.hxx                |    4 +++-
 sc/inc/sortparam.hxx               |    3 +--
 sc/inc/table.hxx                   |   10 ++++++----
 sc/inc/undosort.hxx                |    4 ++--
 sc/source/core/data/documen3.cxx   |   14 +++++++++++++-
 sc/source/core/data/table3.cxx     |   37 ++++++++++++++++++++++++++++++-------
 sc/source/ui/docshell/dbdocfun.cxx |    2 +-
 sc/source/ui/undo/undosort.cxx     |    4 +++-
 8 files changed, 59 insertions(+), 19 deletions(-)

New commits:
commit 80b93eeac80b902fe83dd8aa4b4c375462df3d91
Author: Kohei Yoshida <kohei.yosh...@collabora.com>
Date:   Fri Jun 27 21:00:38 2014 -0400

    More tweaking...
    
    Change-Id: I9276fd92a90dc2689bd59b2ed7eef3d7267ff5b8

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 848e162..fef0683 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1676,7 +1676,9 @@ public:
     SC_DLLPUBLIC SvNumberFormatter* GetFormatTable() const;
     SC_DLLPUBLIC SvNumberFormatter* CreateFormatTable() const;
 
-    void Sort( SCTAB nTab, const ScSortParam& rSortParam, bool bKeepQuery, 
ScProgress* pProgress, sc::SortUndoParam* pUndo );
+    void Sort( SCTAB nTab, const ScSortParam& rSortParam, bool bKeepQuery, 
ScProgress* pProgress, sc::ReorderParam* pUndo );
+    void Reorder( const sc::ReorderParam& rParam, ScProgress* pProgress );
+
     SCSIZE          Query( SCTAB nTab, const ScQueryParam& rQueryParam, bool 
bKeepSub );
     SC_DLLPUBLIC bool           CreateQueryParam( SCCOL nCol1, SCROW nRow1, 
SCCOL nCol2, SCROW nRow2,
                                         SCTAB nTab, ScQueryParam& rQueryParam 
);
diff --git a/sc/inc/sortparam.hxx b/sc/inc/sortparam.hxx
index df3a449..83a1c34 100644
--- a/sc/inc/sortparam.hxx
+++ b/sc/inc/sortparam.hxx
@@ -80,11 +80,10 @@ struct SC_DLLPUBLIC ScSortParam
 
 namespace sc {
 
-struct SC_DLLPUBLIC SortUndoParam
+struct SC_DLLPUBLIC ReorderParam
 {
     ScRange maSortRange;
     std::vector<SCCOLROW> maOldIndices;
-    bool mbHasHeader;
     bool mbByRow;
     bool mbIncludePattern;
 };
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 649d8e6..9f0cff2 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -73,7 +73,7 @@ class RowHeightContext;
 class CompileFormulaContext;
 struct SetFormulaDirtyContext;
 class RefMovedHint;
-struct SortUndoParam;
+struct ReorderParam;
 
 }
 
@@ -826,7 +826,9 @@ public:
     void        ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
 
     void Sort(
-        const ScSortParam& rSortParam, bool bKeepQuery, ScProgress* pProgress, 
sc::SortUndoParam* pUndo );
+        const ScSortParam& rSortParam, bool bKeepQuery, ScProgress* pProgress, 
sc::ReorderParam* pUndo );
+    void Reorder( const sc::ReorderParam& rParam, ScProgress* pProgress );
+
     bool ValidQuery(
         SCROW nRow, const ScQueryParam& rQueryParam, ScRefCellValue* pCell = 
NULL,
         bool* pbTestEqualCondition = NULL);
@@ -1021,8 +1023,8 @@ private:
     short       Compare( ScSortInfoArray*, SCCOLROW nIndex1, SCCOLROW nIndex2) 
const;
     ScSortInfoArray* CreateSortInfoArray( SCCOLROW nInd1, SCCOLROW nInd2, bool 
bKeepQuery );
     void        QuickSort( ScSortInfoArray*, SCsCOLROW nLo, SCsCOLROW nHi);
-    void SortReorderByColumn( ScSortInfoArray* pArray, ScProgress* pProgress, 
sc::SortUndoParam* pUndo );
-    void SortReorderByRow( ScSortInfoArray* pArray, ScProgress* pProgress, 
sc::SortUndoParam* pUndo );
+    void SortReorderByColumn( ScSortInfoArray* pArray, ScProgress* pProgress );
+    void SortReorderByRow( ScSortInfoArray* pArray, ScProgress* pProgress );
 
     bool        CreateExcelQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW 
nRow2, ScQueryParam& rQueryParam);
     bool        CreateStarQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW 
nRow2, ScQueryParam& rQueryParam);
diff --git a/sc/inc/undosort.hxx b/sc/inc/undosort.hxx
index d7a4512..fb8fbeb 100644
--- a/sc/inc/undosort.hxx
+++ b/sc/inc/undosort.hxx
@@ -17,10 +17,10 @@ namespace sc {
 
 class UndoSort : public ScSimpleUndo
 {
-    SortUndoParam maParam;
+    ReorderParam maParam;
 
 public:
-    UndoSort( ScDocShell* pDocSh, const SortUndoParam& rParam );
+    UndoSort( ScDocShell* pDocSh, const ReorderParam& rParam );
 
     virtual OUString GetComment() const;
     virtual void Undo();
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 38162ce..1486092 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -1336,7 +1336,7 @@ bool ScDocument::UpdateOutlineRow( SCROW nStartRow, SCROW 
nEndRow, SCTAB nTab, b
 }
 
 void ScDocument::Sort(
-    SCTAB nTab, const ScSortParam& rSortParam, bool bKeepQuery, ScProgress* 
pProgress, sc::SortUndoParam* pUndo )
+    SCTAB nTab, const ScSortParam& rSortParam, bool bKeepQuery, ScProgress* 
pProgress, sc::ReorderParam* pUndo )
 {
     if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && 
maTabs[nTab] )
     {
@@ -1347,6 +1347,18 @@ void ScDocument::Sort(
     }
 }
 
+void ScDocument::Reorder( const sc::ReorderParam& rParam, ScProgress* 
pProgress )
+{
+    ScTable* pTab = FetchTable(rParam.maSortRange.aStart.Tab());
+    if (!pTab)
+        return;
+
+    bool bOldEnableIdle = IsIdleEnabled();
+    EnableIdle(false);
+    pTab->Reorder(rParam, pProgress);
+    EnableIdle(bOldEnableIdle);
+}
+
 SCSIZE ScDocument::Query(SCTAB nTab, const ScQueryParam& rQueryParam, bool 
bKeepSub)
 {
     if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && 
maTabs[nTab] )
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 1283ee1..e83f86f 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -560,8 +560,7 @@ public:
 
 }
 
-void ScTable::SortReorderByColumn(
-    ScSortInfoArray* pArray, ScProgress* pProgress, sc::SortUndoParam* pUndo )
+void ScTable::SortReorderByColumn( ScSortInfoArray* pArray, ScProgress* 
pProgress )
 {
     size_t nCount = pArray->GetCount();
     SCCOLROW nStart = pArray->GetStart();
@@ -638,8 +637,7 @@ void ScTable::SortReorderByColumn(
     }
 }
 
-void ScTable::SortReorderByRow(
-    ScSortInfoArray* pArray, ScProgress* pProgress, sc::SortUndoParam* pUndo )
+void ScTable::SortReorderByRow( ScSortInfoArray* pArray, ScProgress* pProgress 
)
 {
     SCROW nRow1 = pArray->GetStart();
     SCROW nRow2 = pArray->GetLast();
@@ -1093,11 +1091,19 @@ void ScTable::DecoladeRow( ScSortInfoArray* pArray, 
SCROW nRow1, SCROW nRow2 )
 }
 
 void ScTable::Sort(
-    const ScSortParam& rSortParam, bool bKeepQuery, ScProgress* pProgress, 
sc::SortUndoParam* pUndo )
+    const ScSortParam& rSortParam, bool bKeepQuery, ScProgress* pProgress, 
sc::ReorderParam* pUndo )
 {
     aSortParam = rSortParam;
     InitSortCollator( rSortParam );
     bGlobalKeepQuery = bKeepQuery;
+
+    if (pUndo)
+    {
+        // Copy over the basic sort parameters.
+        pUndo->mbByRow = rSortParam.bByRow;
+        pUndo->mbIncludePattern = rSortParam.bIncludePattern;
+    }
+
     if (rSortParam.bByRow)
     {
         SCROW nLastRow = 0;
@@ -1117,7 +1123,13 @@ void ScTable::Sort(
                 DecoladeRow(pArray.get(), nRow1, nLastRow);
 
             QuickSort(pArray.get(), nRow1, nLastRow);
-            SortReorderByRow(pArray.get(), pProgress, pUndo);
+            SortReorderByRow(pArray.get(), pProgress);
+
+            if (pUndo)
+            {
+                pUndo->maSortRange = ScRange(rSortParam.nCol1, nRow1, nTab, 
rSortParam.nCol2, nLastRow, nTab);
+                pUndo->maOldIndices = pArray->GetOldIndices();
+            }
 
             // #i59745# update position of caption objects of cell notes --> 
reported at (SortReorder) ScColumn::SwapCellNotes level
         }
@@ -1139,7 +1151,13 @@ void ScTable::Sort(
             boost::scoped_ptr<ScSortInfoArray> 
pArray(CreateSortInfoArray(nCol1, nLastCol, bKeepQuery));
 
             QuickSort(pArray.get(), nCol1, nLastCol);
-            SortReorderByColumn(pArray.get(), pProgress, pUndo);
+            SortReorderByColumn(pArray.get(), pProgress);
+
+            if (pUndo)
+            {
+                pUndo->maSortRange = ScRange(nCol1, aSortParam.nRow1, nTab, 
nLastCol, aSortParam.nRow2, nTab);
+                pUndo->maOldIndices = pArray->GetOldIndices();
+            }
 
             // #i59745# update position of caption objects of cell notes --> 
reported at (SortReorder) ScColumn::SwapCellNotes level
         }
@@ -1147,6 +1165,11 @@ void ScTable::Sort(
     DestroySortCollator();
 }
 
+void ScTable::Reorder( const sc::ReorderParam& rParam, ScProgress* pProgress )
+{
+
+}
+
 namespace {
 
 class SubTotalRowFinder
diff --git a/sc/source/ui/docshell/dbdocfun.cxx 
b/sc/source/ui/docshell/dbdocfun.cxx
index a57809b..9d7f316 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -592,7 +592,7 @@ bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& 
rSortParam,
     }
 #endif
 
-    sc::SortUndoParam aUndoParam;
+    sc::ReorderParam aUndoParam;
 
     // don't call ScDocument::Sort with an empty SortParam (may be empty here 
if bCopy is set)
     if (aLocalParam.GetSortKeyCount() && aLocalParam.maKeyState[0].bDoSort)
diff --git a/sc/source/ui/undo/undosort.cxx b/sc/source/ui/undo/undosort.cxx
index 09671bc..1258882 100644
--- a/sc/source/ui/undo/undosort.cxx
+++ b/sc/source/ui/undo/undosort.cxx
@@ -13,7 +13,7 @@
 
 namespace sc {
 
-UndoSort::UndoSort( ScDocShell* pDocSh, const SortUndoParam& rParam ) :
+UndoSort::UndoSort( ScDocShell* pDocSh, const ReorderParam& rParam ) :
     ScSimpleUndo(pDocSh), maParam(rParam) {}
 
 OUString UndoSort::GetComment() const
@@ -23,6 +23,8 @@ OUString UndoSort::GetComment() const
 
 void UndoSort::Undo()
 {
+    ScDocument& rDoc = pDocShell->GetDocument();
+    rDoc.Reorder(maParam, NULL);
 }
 
 void UndoSort::Redo()
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to