[Libreoffice-commits] .: sc/inc sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Aug 24 08:55:48 PDT 2012
sc/inc/cell.hxx | 4 ++--
sc/inc/document.hxx | 6 ++++--
sc/source/core/data/cell.cxx | 11 ++++++-----
sc/source/core/data/documen4.cxx | 5 +++--
sc/source/core/data/documen7.cxx | 5 +++--
sc/source/filter/xml/xmlsubti.cxx | 2 +-
sc/source/ui/docshell/docsh.cxx | 2 +-
7 files changed, 20 insertions(+), 15 deletions(-)
New commits:
commit deaac6fffa883d5604a35eb0706c7526b87398cc
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Sat Jul 28 03:24:57 2012 -0500
Improve 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: I961f69b0117d4261f8afefb6d94173105f0925b2
diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index f609a46..79e99db 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -376,7 +376,7 @@ public:
void GetFormula( rtl::OUStringBuffer& rBuffer,
const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT ) const;
- void SetDirty();
+ void SetDirty( bool bDirtyFlag=true );
void SetDirtyVar();
// If setting entire document dirty after load, no broadcasts but still append to FormulaTree.
void SetDirtyAfterLoad();
@@ -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 bDirtyFlag=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 ba23156..a2db35f 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 bDirtyFlag=true );
SC_DLLPUBLIC void InsertTableOp(const ScTabOpParam& rParam, // multi-operation
SCCOL nCol1, SCROW nRow1,
SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark);
@@ -1657,7 +1658,8 @@ public:
void PutInFormulaTree( ScFormulaCell* pCell );
void RemoveFromFormulaTree( ScFormulaCell* pCell );
void CalcFormulaTree( bool bOnlyForced = false,
- bool bNoProgressBar = false );
+ bool bNoProgressBar = false,
+ bool bDirtyFlag=true );
void ClearFormulaTree();
void AppendToFormulaTrack( ScFormulaCell* pCell );
void RemoveFromFormulaTrack( ScFormulaCell* pCell );
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 4676cc8..8f3a0a4 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -1726,17 +1726,17 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
}
-void ScFormulaCell::SetMatColsRows( SCCOL nCols, SCROW nRows )
+void ScFormulaCell::SetMatColsRows( SCCOL nCols, SCROW nRows, bool bDirtyFlag )
{
ScMatrixFormulaCellToken* pMat = aResult.GetMatrixFormulaCellTokenNonConst();
if (pMat)
- pMat->SetMatColsRows( nCols, nRows);
+ pMat->SetMatColsRows( nCols, nRows );
else if (nCols || 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();
+ SetDirty( bDirtyFlag );
}
}
@@ -1805,7 +1805,7 @@ void ScFormulaCell::Notify( SvtBroadcaster&, const SfxHint& rHint)
}
}
-void ScFormulaCell::SetDirty()
+void ScFormulaCell::SetDirty( bool bDirtyFlag )
{
if ( !IsInChangeTrack() )
{
@@ -1819,7 +1819,8 @@ void ScFormulaCell::SetDirty()
// setzen, z.B. in CompileTokenArray
if ( !bDirty || !pDocument->IsInFormulaTree( this ) )
{
- SetDirtyVar();
+ if( bDirtyFlag )
+ SetDirtyVar();
pDocument->AppendToFormulaTrack( this );
pDocument->TrackFormulas();
}
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 7d993e9..52fe982 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -122,7 +122,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 bDirtyFlag )
{
PutInOrder(nCol1, nCol2);
PutInOrder(nRow1, nRow2);
@@ -155,7 +156,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, bDirtyFlag );
itr = rMark.begin();
for (; itr != itrEnd && *itr < nMax; ++itr)
{
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx
index 71bf25b..e9af746 100644
--- a/sc/source/core/data/documen7.cxx
+++ b/sc/source/core/data/documen7.cxx
@@ -280,7 +280,7 @@ bool ScDocument::IsInFormulaTree( ScFormulaCell* pCell ) const
}
-void ScDocument::CalcFormulaTree( bool bOnlyForced, bool bNoProgress )
+void ScDocument::CalcFormulaTree( bool bOnlyForced, bool bNoProgress, bool bDirtyFlag )
{
OSL_ENSURE( !IsCalculatingFormulaTree(), "CalcFormulaTree recursion" );
// never ever recurse into this, might end up lost in infinity
@@ -317,7 +317,8 @@ void ScDocument::CalcFormulaTree( bool bOnlyForced, bool bNoProgress )
}
else
{ // andere simpel berechnen
- pCell->SetDirtyVar();
+ if( bDirtyFlag )
+ pCell->SetDirtyVar();
pCell = pCell->GetNext();
}
}
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() );
}
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index d59206a..2d06f82 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -441,7 +441,7 @@ sal_Bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::un
if(sGenerator.indexOf(SC_LIBO_PROD_NAME) == -1)
DoHardRecalc(false);
else //still need to recalc volatile formula cells
- DoRecalc(false);
+ aDocument.CalcFormulaTree(false, false, false);
aDocument.EnableAdjustHeight(false);
More information about the Libreoffice-commits
mailing list