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

Kohei Yoshida kohei.yoshida at gmail.com
Fri May 17 10:28:39 PDT 2013


 sc/inc/column.hxx                |    2 +-
 sc/inc/table.hxx                 |    6 +++---
 sc/source/core/data/column.cxx   |   12 +++++-------
 sc/source/core/data/document.cxx |    8 ++++++--
 sc/source/core/data/table2.cxx   |   13 +++++--------
 5 files changed, 20 insertions(+), 21 deletions(-)

New commits:
commit 823516dfb1e910c5789fb162aeb67d7b40ab457c
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri May 17 13:29:04 2013 -0400

    Reuse CopyToDocContext for UndoTo*.
    
    UndoToDocument and its nested methods are tightly coupled with the CopyTo
    counterparts, and they both are used in the same undo / redo code....
    
    Perhaps we can clean this up to reduce redundancy in the future.
    
    Change-Id: Id3aec60914ac3a87acbb53f889896a5850047c59

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 1165ee3..0e7ed53 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -257,7 +257,7 @@ public:
         ScColumn& rColumn, const ScMarkData* pMarkData = NULL, bool bAsLink = false) const;
 
     void UndoToColumn(
-        SCROW nRow1, SCROW nRow2, sal_uInt16 nFlags, bool bMarked,
+        sc::CopyToDocContext& rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 nFlags, bool bMarked,
         ScColumn& rColumn, const ScMarkData* pMarkData = NULL) const;
 
     void        CopyScenarioFrom( const ScColumn& rSrcCol );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index c40e5ec..7d0836f 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -402,9 +402,9 @@ public:
         sal_uInt16 nFlags, bool bMarked, ScTable* pDestTab,
         const ScMarkData* pMarkData = NULL, bool bAsLink = false, bool bColRowFlags = true );
 
-    void        UndoToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-                            sal_uInt16 nFlags, bool bMarked, ScTable* pDestTab,
-                            const ScMarkData* pMarkData = NULL);
+    void UndoToTable(
+        sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
+        sal_uInt16 nFlags, bool bMarked, ScTable* pDestTab, const ScMarkData* pMarkData = NULL );
 
     void        CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                             SCsCOL nDx, SCsROW nDy, ScTable* pTable);
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index d196223..94cd257 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1475,18 +1475,16 @@ void ScColumn::CopyToColumn(
 
 
 void ScColumn::UndoToColumn(
-    SCROW nRow1, SCROW nRow2, sal_uInt16 nFlags, bool bMarked, ScColumn& rColumn,
-    const ScMarkData* pMarkData) const
+    sc::CopyToDocContext& rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 nFlags, bool bMarked,
+    ScColumn& rColumn, const ScMarkData* pMarkData ) const
 {
-    sc::CopyToDocContext aCxt(*rColumn.pDocument);
-    aCxt.setTabRange(rColumn.nTab, rColumn.nTab);
     if (nRow1 > 0)
-        CopyToColumn(aCxt, 0, nRow1-1, IDF_FORMULA, false, rColumn);
+        CopyToColumn(rCxt, 0, nRow1-1, IDF_FORMULA, false, rColumn);
 
-    CopyToColumn(aCxt, nRow1, nRow2, nFlags, bMarked, rColumn, pMarkData);      //! bMarked ????
+    CopyToColumn(rCxt, nRow1, nRow2, nFlags, bMarked, rColumn, pMarkData);      //! bMarked ????
 
     if (nRow2 < MAXROW)
-        CopyToColumn(aCxt, nRow2+1, MAXROW, IDF_FORMULA, false, rColumn);
+        CopyToColumn(rCxt, nRow2+1, MAXROW, IDF_FORMULA, false, rColumn);
 }
 
 
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 44668ac..4e54630 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1872,11 +1872,13 @@ void ScDocument::UndoToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
         if (nTab1 > 0)
             CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTab1-1, IDF_FORMULA, false, pDestDoc, pMarks );
 
+        sc::CopyToDocContext aCxt(*pDestDoc);
+        aCxt.setTabRange(nTab1, nTab2);
         OSL_ASSERT( nTab2 < static_cast<SCTAB>(maTabs.size()) && nTab2 < static_cast<SCTAB>(pDestDoc->maTabs.size()));
         for (SCTAB i = nTab1; i <= nTab2; i++)
         {
             if (maTabs[i] && pDestDoc->maTabs[i])
-                maTabs[i]->UndoToTable(nCol1, nRow1, nCol2, nRow2, nFlags,
+                maTabs[i]->UndoToTable(aCxt, nCol1, nRow1, nCol2, nRow2, nFlags,
                                     bOnlyMarked, pDestDoc->maTabs[i], pMarks);
         }
 
@@ -1926,13 +1928,15 @@ void ScDocument::UndoToDocument(const ScRange& rRange,
 
     bool bOldAutoCalc = pDestDoc->GetAutoCalc();
     pDestDoc->SetAutoCalc( false );     // avoid multiple calculations
+    sc::CopyToDocContext aCxt(*pDestDoc);
+    aCxt.setTabRange(nTab1, nTab2);
     if (nTab1 > 0)
         CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTab1-1, IDF_FORMULA, false, pDestDoc, pMarks );
 
     for (SCTAB i = nTab1; i <= nTab2 && i < static_cast<SCTAB>(maTabs.size()); i++)
     {
         if (maTabs[i] && i < static_cast<SCTAB>(pDestDoc->maTabs.size()) && pDestDoc->maTabs[i])
-            maTabs[i]->UndoToTable(aNewRange.aStart.Col(), aNewRange.aStart.Row(),
+            maTabs[i]->UndoToTable(aCxt, aNewRange.aStart.Col(), aNewRange.aStart.Row(),
                                     aNewRange.aEnd.Col(), aNewRange.aEnd.Row(),
                                     nFlags, bOnlyMarked, pDestDoc->maTabs[i], pMarks);
     }
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 1a59fca..2eca7ad 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1151,24 +1151,21 @@ void ScTable::CopyToTable(
 }
 
 
-void ScTable::UndoToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-                            sal_uInt16 nFlags, bool bMarked, ScTable* pDestTab,
-                            const ScMarkData* pMarkData)
+void ScTable::UndoToTable(
+    sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
+    sal_uInt16 nFlags, bool bMarked, ScTable* pDestTab, const ScMarkData* pMarkData )
 {
     if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2))
     {
         bool bWidth  = (nRow1==0 && nRow2==MAXROW && pColWidth && pDestTab->pColWidth);
         bool bHeight = (nCol1==0 && nCol2==MAXCOL && mpRowHeights && pDestTab->mpRowHeights);
 
-        sc::CopyToDocContext aCopyCxt(*pDestTab->pDocument);
-        aCopyCxt.setTabRange(pDestTab->nTab, pDestTab->nTab);
         for ( SCCOL i = 0; i <= MAXCOL; i++)
         {
             if ( i >= nCol1 && i <= nCol2 )
-                aCol[i].UndoToColumn(nRow1, nRow2, nFlags, bMarked, pDestTab->aCol[i],
-                                        pMarkData);
+                aCol[i].UndoToColumn(rCxt, nRow1, nRow2, nFlags, bMarked, pDestTab->aCol[i], pMarkData);
             else
-                aCol[i].CopyToColumn(aCopyCxt, 0, MAXROW, IDF_FORMULA, false, pDestTab->aCol[i]);
+                aCol[i].CopyToColumn(rCxt, 0, MAXROW, IDF_FORMULA, false, pDestTab->aCol[i]);
         }
 
         //remove old notes


More information about the Libreoffice-commits mailing list