summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorDaniel Bankston <daniel.e.bankston@gmail.com>2012-07-28 03:24:57 -0500
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-08-24 11:55:44 -0400
commitdeaac6fffa883d5604a35eb0706c7526b87398cc (patch)
treea7a5d089c2c9d00449ddcc9ea2e3df6920df5e59 /sc
parent1b40fbe41459a2231870af94a06263d89af554a6 (diff)
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
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/cell.hxx4
-rw-r--r--sc/inc/document.hxx6
-rw-r--r--sc/source/core/data/cell.cxx11
-rw-r--r--sc/source/core/data/documen4.cxx5
-rw-r--r--sc/source/core/data/documen7.cxx5
-rw-r--r--sc/source/filter/xml/xmlsubti.cxx2
-rw-r--r--sc/source/ui/docshell/docsh.cxx2
7 files changed, 20 insertions, 15 deletions
diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index f609a4642109..79e99dba8527 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 ba23156effac..a2db35f8388c 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 4676cc8a0e17..8f3a0a458728 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 7d993e94faa8..52fe982bcbf7 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 71bf25bf6b7d..e9af74683976 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 87cd34e26e54..b1eeb9d3ef76 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 d59206a43e2f..2d06f8213a10 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);