[Libreoffice-commits] .: Branch 'feature/gsoc-calc-perf2' - sc/inc sc/source

Daniel Bankston dbank at kemper.freedesktop.org
Thu Jul 12 22:31:01 PDT 2012


 sc/inc/cell.hxx                   |    2 +-
 sc/inc/document.hxx               |    3 ++-
 sc/source/core/data/cell.cxx      |    7 +++++--
 sc/source/core/data/documen4.cxx  |    5 +++--
 sc/source/filter/xml/xmlsubti.cxx |    2 +-
 5 files changed, 12 insertions(+), 7 deletions(-)

New commits:
commit cb14c160489254298eb03f7406107e06395943d1
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date:   Fri Jul 13 00:27:36 2012 -0500

    Fix for ods matrix import performance
    
    Our latest changes that recalculate volatile formulas at the end of import
    resulted in several seconds performance loss on a large matrix test file
    with complex formulas.
    
    When the matrix cells are put in the document, ScFormulaCell::SetDirty()
    gets called.  Although the cells are set clean during import after this,
    SetDirty() also uses ScDocument::TrackFormulas() which puts the cells in
    the formula tree.  So when we call ScDocument::DoRecalc() at the end of
    import, the interpreter goes through all matrix cells because they are
    in the formula tree.
    
    This commit prevent that from happening, which gives us back our performance.
    
    Change-Id: Icdf436065e4a238aa0bf910badfd58757087803a

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index f609a46..820ef7b 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -472,7 +472,7 @@ public:
     virtual void    Notify( SvtBroadcaster& rBC, const SfxHint& rHint);
     void            SetCompile( bool bVal ) { bCompile = bVal; }
     ScDocument*     GetDocument() const     { return pDocument; }
-    void            SetMatColsRows( SCCOL nCols, SCROW nRows );
+    void            SetMatColsRows( SCCOL nCols, SCROW nRows, bool bSetDirty=true );
     void            GetMatColsRows( SCCOL& nCols, SCROW& nRows ) const;
 
                     // cell belongs to ChangeTrack and not to the real document
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 6d4a02e..6849c53 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -770,7 +770,8 @@ public:
                                         const ScMarkData& rMark,
                                         const rtl::OUString& rFormula,
                                         const ScTokenArray* p = NULL,
-                                        const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT );
+                                        const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT,
+                                        bool bSetDirty=true );
     SC_DLLPUBLIC void           InsertTableOp(const ScTabOpParam& rParam,   // multi-operation
                                   SCCOL nCol1, SCROW nRow1,
                                   SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark);
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 82b31f3..ae9c844 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -1726,7 +1726,7 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
 }
 
 
-void ScFormulaCell::SetMatColsRows( SCCOL nCols, SCROW nRows )
+void ScFormulaCell::SetMatColsRows( SCCOL nCols, SCROW nRows, bool bSetDirty )
 {
     ScMatrixFormulaCellToken* pMat = aResult.GetMatrixFormulaCellTokenNonConst();
     if (pMat)
@@ -1736,7 +1736,10 @@ void ScFormulaCell::SetMatColsRows( SCCOL nCols, SCROW nRows )
         aResult.SetToken( new ScMatrixFormulaCellToken( nCols, nRows));
         // Setting the new token actually forces an empty result at this top
         // left cell, so have that recalculated.
-        SetDirty();
+        //but during ODS import, we don't won't matrix cells to be dirty
+        //or added to the formula tree so we check bSetDirty.
+        if(bSetDirty)
+            SetDirty();
     }
 }
 
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 8eca485..7411ffa 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -123,7 +123,8 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
                                      const ScMarkData& rMark,
                                      const rtl::OUString& rFormula,
                                      const ScTokenArray* pArr,
-                                     const formula::FormulaGrammar::Grammar eGram )
+                                     const formula::FormulaGrammar::Grammar eGram,
+                                     bool bSetDirty )
 {
     PutInOrder(nCol1, nCol2);
     PutInOrder(nRow1, nRow2);
@@ -157,7 +158,7 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
         pCell = new ScFormulaCell( this, aPos, pArr, eGram, MM_FORMULA );
     else
         pCell = new ScFormulaCell( this, aPos, rFormula, eGram, MM_FORMULA );
-    pCell->SetMatColsRows( nCol2 - nCol1 + 1, nRow2 - nRow1 + 1 );
+    pCell->SetMatColsRows( nCol2 - nCol1 + 1, nRow2 - nRow1 + 1, bSetDirty );
     itr = rMark.begin();
     for (; itr != itrEnd && *itr < nMax; ++itr)
     {
diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx
index 87cd34e..b1eeb9d 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -297,7 +297,7 @@ void ScMyTables::AddMatrixRange(
     pDoc->InsertMatrixFormula(
         aScRange.aStart.Col(), aScRange.aStart.Row(),
         aScRange.aEnd.Col(), aScRange.aEnd.Row(),
-        aMark, EMPTY_STRING, pCode, eGrammar );
+        aMark, EMPTY_STRING, pCode, eGrammar, false );
     delete pCode;
     pDoc->IncXMLImportedFormulaCount( rFormula.getLength() );
 }


More information about the Libreoffice-commits mailing list