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

Kohei Yoshida kohei.yoshida at gmail.com
Fri May 17 12:07:04 PDT 2013


 sc/inc/clipcontext.hxx              |    7 +++++
 sc/inc/column.hxx                   |   11 +++++----
 sc/inc/document.hxx                 |    2 +
 sc/inc/table.hxx                    |   12 ++++++----
 sc/source/core/data/clipcontext.cxx |    3 ++
 sc/source/core/data/column3.cxx     |   21 +++++++++++------
 sc/source/core/data/document.cxx    |   43 ++++++++++++++++++++++++++++++------
 sc/source/core/data/table2.cxx      |   14 ++++++-----
 8 files changed, 86 insertions(+), 27 deletions(-)

New commits:
commit 7ed2000a046a5c2b8491439fe2c9ddba1a9dadb7
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri May 17 15:08:23 2013 -0400

    Same with MixDocument(). But this one has additional bottleneck...
    
    With the removal of existing cells. So, this change is not enough to
    make this operation fly.
    
    Change-Id: Ic468375f6d0c28e2cc7d5391fb0565d53ee7fb4e

diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx
index 4d9224f..599da6e 100644
--- a/sc/inc/clipcontext.hxx
+++ b/sc/inc/clipcontext.hxx
@@ -90,6 +90,13 @@ public:
     virtual ~CopyToDocContext();
 };
 
+class MixDocContext : public ClipContextBase
+{
+public:
+    MixDocContext(ScDocument& rDoc);
+    virtual ~MixDocContext();
+};
+
 }
 
 #endif
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 0e7ed53..c71ffea 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -41,6 +41,7 @@ namespace sc {
     class CopyFromClipContext;
     class CopyToClipContext;
     class CopyToDocContext;
+    class MixDocContext;
     struct ColumnBlockPosition;
 }
 
@@ -231,10 +232,12 @@ public:
     void        RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow );
 
                 //  Selection (?) of this document
-    void        MixMarked( const ScMarkData& rMark, sal_uInt16 nFunction,
-                            bool bSkipEmpty, ScColumn& rSrcCol );
-    void        MixData( SCROW nRow1, SCROW nRow2, sal_uInt16 nFunction, bool bSkipEmpty,
-                            ScColumn& rSrcCol );
+    void MixMarked(
+        sc::MixDocContext& rCxt, const ScMarkData& rMark, sal_uInt16 nFunction,
+        bool bSkipEmpty, const ScColumn& rSrcCol );
+    void MixData(
+        sc::MixDocContext& rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 nFunction, bool bSkipEmpty,
+        const ScColumn& rSrcCol );
 
     ScFormulaCell*  CreateRefCell( ScDocument* pDestDoc, const ScAddress& rDestPos,
                                     SCSIZE nIndex, sal_uInt16 nFlags ) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 5f63d85..f01e811 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1988,6 +1988,8 @@ private: // CLOOK-Impl-methods
     };
 
     bool TableExists( SCTAB nTab ) const;
+    ScTable* FetchTable( SCTAB nTab );
+    const ScTable* FetchTable( SCTAB nTab ) const;
 
     void    MergeNumberFormatter(ScDocument* pSrcDoc);
 
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 7d0836f..f04a9bb 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -53,6 +53,7 @@ namespace sc {
     class CopyFromClipContext;
     class CopyToClipContext;
     class CopyToDocContext;
+    class MixDocContext;
     struct ColumnBlockPosition;
 }
 
@@ -412,10 +413,13 @@ public:
                                 ScTable* pTransClip, sal_uInt16 nFlags, bool bAsLink );
 
                 // mark of this document
-    void        MixMarked( const ScMarkData& rMark, sal_uInt16 nFunction,
-                            bool bSkipEmpty, ScTable* pSrcTab );
-    void        MixData( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-                            sal_uInt16 nFunction, bool bSkipEmpty, ScTable* pSrcTab );
+    void MixMarked(
+        sc::MixDocContext& rCxt, const ScMarkData& rMark, sal_uInt16 nFunction,
+        bool bSkipEmpty, const ScTable* pSrcTab );
+
+    void MixData(
+        sc::MixDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
+        sal_uInt16 nFunction, bool bSkipEmpty, const ScTable* pSrcTab );
 
     void        CopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
                             SCCOL nDestCol, SCROW nDestRow, SCTAB nDestTab );
diff --git a/sc/source/core/data/clipcontext.cxx b/sc/source/core/data/clipcontext.cxx
index 8777aa3..2c7abdf 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -120,6 +120,9 @@ bool CopyToClipContext::isCloneNotes() const
 CopyToDocContext::CopyToDocContext(ScDocument& rDoc) : ClipContextBase(rDoc) {}
 CopyToDocContext::~CopyToDocContext() {}
 
+MixDocContext::MixDocContext(ScDocument& rDoc) : ClipContextBase(rDoc) {}
+MixDocContext::~MixDocContext() {}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index a29f791..b530184 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -828,8 +828,9 @@ ScBaseCell* ScColumn::CloneCell(
 }
 
 
-void ScColumn::MixMarked( const ScMarkData& rMark, sal_uInt16 nFunction,
-                            bool bSkipEmpty, ScColumn& rSrcCol )
+void ScColumn::MixMarked(
+    sc::MixDocContext& rCxt, const ScMarkData& rMark, sal_uInt16 nFunction,
+    bool bSkipEmpty, const ScColumn& rSrcCol )
 {
     SCROW nRow1, nRow2;
 
@@ -837,7 +838,7 @@ void ScColumn::MixMarked( const ScMarkData& rMark, sal_uInt16 nFunction,
     {
         ScMarkArrayIter aIter( rMark.GetArray()+nCol );
         while (aIter.Next( nRow1, nRow2 ))
-            MixData( nRow1, nRow2, nFunction, bSkipEmpty, rSrcCol );
+            MixData(rCxt, nRow1, nRow2, nFunction, bSkipEmpty, rSrcCol);
     }
 }
 
@@ -885,9 +886,9 @@ static void lcl_AddCode( ScTokenArray& rArr, ScFormulaCell* pCell )
 }
 
 
-void ScColumn::MixData( SCROW nRow1, SCROW nRow2,
-                            sal_uInt16 nFunction, bool bSkipEmpty,
-                            ScColumn& rSrcCol )
+void ScColumn::MixData(
+    sc::MixDocContext& rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 nFunction,
+    bool bSkipEmpty, const ScColumn& rSrcCol )
 {
     SCSIZE nSrcCount = rSrcCol.maItems.size();
 
@@ -1023,12 +1024,18 @@ void ScColumn::MixData( SCROW nRow1, SCROW nRow2,
 
         if ( pNew || bDelete ) // New result?
         {
+            sc::ColumnBlockPosition* p = rCxt.getBlockPosition(nTab, nCol);
             if (pDest && !pNew) // Old cell present?
             {
                 Delete(nRow); // -> Delete
             }
             if (pNew)
-                Insert(nRow, pNew); // Insert new one
+            {
+                if (p)
+                    Insert(*p, nRow, pNew);
+                else
+                    Insert(nRow, pNew); // Insert new one
+            }
 
             Search( nRow, nIndex ); // Everything could have moved
             if (pNew)
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index cf2ae95..decaae9 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2261,6 +2261,22 @@ bool ScDocument::TableExists( SCTAB nTab ) const
     return ValidTab(nTab) && static_cast<size_t>(nTab) < maTabs.size() && maTabs[nTab];
 }
 
+ScTable* ScDocument::FetchTable( SCTAB nTab )
+{
+    if (!TableExists(nTab))
+        return NULL;
+
+    return maTabs[nTab];
+}
+
+const ScTable* ScDocument::FetchTable( SCTAB nTab ) const
+{
+    if (!TableExists(nTab))
+        return NULL;
+
+    return maTabs[nTab];
+}
+
 void ScDocument::MergeNumberFormatter(ScDocument* pSrcDoc)
 {
     SvNumberFormatter* pThisFormatter = xPoolHelper->GetFormTable();
@@ -2846,11 +2862,19 @@ void ScDocument::MixDocument( const ScRange& rRange, sal_uInt16 nFunction, bool
 {
     SCTAB nTab1 = rRange.aStart.Tab();
     SCTAB nTab2 = rRange.aEnd.Tab();
+    sc::MixDocContext aCxt(*this);
+    aCxt.setTabRange(nTab1, nTab2);
     for (SCTAB i = nTab1; i <= nTab2 && i < static_cast<SCTAB>(maTabs.size()); i++)
-        if (maTabs[i] && i < static_cast<SCTAB>(pSrcDoc->maTabs.size()) && pSrcDoc->maTabs[i])
-            maTabs[i]->MixData( rRange.aStart.Col(), rRange.aStart.Row(),
-                                rRange.aEnd.Col(), rRange.aEnd.Row(),
-                                nFunction, bSkipEmpty, pSrcDoc->maTabs[i] );
+    {
+        ScTable* pTab = FetchTable(i);
+        const ScTable* pSrcTab = pSrcDoc->FetchTable(i);
+        if (!pTab || !pSrcTab)
+            continue;
+
+        pTab->MixData(
+            aCxt, rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row(),
+            nFunction, bSkipEmpty, pSrcTab);
+    }
 }
 
 
@@ -2878,6 +2902,9 @@ void ScDocument::FillTab( const ScRange& rSrcArea, const ScMarkData& rMark,
 
         sc::CopyToDocContext aCxt(*this);
         aCxt.setTabRange(rMark.GetFirstSelected(), rMark.GetLastSelected());
+        sc::MixDocContext aMixDocCxt(*this);
+        aMixDocCxt.setTabRange(rMark.GetFirstSelected(), rMark.GetLastSelected());
+
         SCTAB nCount = static_cast<SCTAB>(maTabs.size());
         ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
         for (; itr != itrEnd && *itr < nCount; ++itr)
@@ -2893,6 +2920,8 @@ void ScDocument::FillTab( const ScRange& rSrcArea, const ScMarkData& rMark,
                     }
                     else
                         pMixDoc->AddUndoTab( i, i );
+
+                    // context used for copying content to the temporary mix document.
                     sc::CopyToDocContext aMixCxt(*pMixDoc);
                     aMixCxt.setTabRange(i, i);
                     maTabs[i]->CopyToTable(aMixCxt, nStartCol,nStartRow, nEndCol,nEndRow,
@@ -2903,7 +2932,7 @@ void ScDocument::FillTab( const ScRange& rSrcArea, const ScMarkData& rMark,
                                                  nFlags, false, maTabs[i], NULL, bAsLink );
 
                 if (bDoMix)
-                    maTabs[i]->MixData( nStartCol,nStartRow, nEndCol,nEndRow,
+                    maTabs[i]->MixData(aMixDocCxt, nStartCol,nStartRow, nEndCol,nEndRow,
                                         nFunction, bSkipEmpty, pMixDoc->maTabs[i] );
             }
 
@@ -2941,6 +2970,8 @@ void ScDocument::FillTabMarked( SCTAB nSrcTab, const ScMarkData& rMark,
 
         sc::CopyToDocContext aCxt(*this);
         aCxt.setTabRange(rMark.GetFirstSelected(), rMark.GetLastSelected());
+        sc::MixDocContext aMixDocCxt(*this);
+        aMixDocCxt.setTabRange(rMark.GetFirstSelected(), rMark.GetLastSelected());
         SCTAB nCount = static_cast<SCTAB>(maTabs.size());
         ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
         for (; itr != itrEnd && *itr < nCount; ++itr)
@@ -2968,7 +2999,7 @@ void ScDocument::FillTabMarked( SCTAB nSrcTab, const ScMarkData& rMark,
                                              nFlags, true, maTabs[i], &rMark, bAsLink );
 
                 if (bDoMix)
-                    maTabs[i]->MixMarked( rMark, nFunction, bSkipEmpty, pMixDoc->maTabs[i] );
+                    maTabs[i]->MixMarked(aMixDocCxt, rMark, nFunction, bSkipEmpty, pMixDoc->maTabs[i]);
             }
 
         SetAutoCalc( bOldAutoCalc );
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 2eca7ad..4af76be 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -831,20 +831,22 @@ void ScTable::CopyFromClip(
 }
 
 
-void ScTable::MixData( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-                            sal_uInt16 nFunction, bool bSkipEmpty, ScTable* pSrcTab )
+void ScTable::MixData(
+    sc::MixDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
+    sal_uInt16 nFunction, bool bSkipEmpty, const ScTable* pSrcTab )
 {
     for (SCCOL i=nCol1; i<=nCol2; i++)
-        aCol[i].MixData( nRow1, nRow2, nFunction, bSkipEmpty, pSrcTab->aCol[i] );
+        aCol[i].MixData(rCxt, nRow1, nRow2, nFunction, bSkipEmpty, pSrcTab->aCol[i]);
 }
 
 
 //  Markierung von diesem Dokument
-void ScTable::MixMarked( const ScMarkData& rMark, sal_uInt16 nFunction,
-                        bool bSkipEmpty, ScTable* pSrcTab )
+void ScTable::MixMarked(
+    sc::MixDocContext& rCxt, const ScMarkData& rMark, sal_uInt16 nFunction,
+    bool bSkipEmpty, const ScTable* pSrcTab )
 {
     for (SCCOL i=0; i<=MAXCOL; i++)
-        aCol[i].MixMarked( rMark, nFunction, bSkipEmpty, pSrcTab->aCol[i] );
+        aCol[i].MixMarked(rCxt, rMark, nFunction, bSkipEmpty, pSrcTab->aCol[i]);
 }
 
 


More information about the Libreoffice-commits mailing list