diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-04-07 21:29:17 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-04-07 21:30:35 -0400 |
commit | 615f6aa293a6da90da94e6e78828198ffbc0ca5e (patch) | |
tree | cfc1f9a41e837af05c400a5279d3b9436efd2752 | |
parent | 97043e70ef96d1fe8f42eb352a97149f77b73ac6 (diff) |
fdo#75741: Share the context objects to avoid poor performance.
Change-Id: I1015dbfa9e2220cd23244dae17ee8dc4828c6a67
-rw-r--r-- | sc/inc/column.hxx | 6 | ||||
-rw-r--r-- | sc/inc/table.hxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/column4.cxx | 35 | ||||
-rw-r--r-- | sc/source/core/data/document10.cxx | 10 | ||||
-rw-r--r-- | sc/source/core/data/table7.cxx | 9 |
5 files changed, 39 insertions, 27 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 42f27796c476..9318a77da137 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -372,8 +372,10 @@ public: void SetTabNo(SCTAB nNewTab); void FindRangeNamesInUse(SCROW nRow1, SCROW nRow2, std::set<sal_uInt16>& rIndexes) const; - void PreprocessRangeNameUpdate(); - void PostprocessRangeNameUpdate(); + void PreprocessRangeNameUpdate( + sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt ); + + void PostprocessRangeNameUpdate( sc::CompileFormulaContext& rCompileCxt ); const SfxPoolItem* GetAttr( SCROW nRow, sal_uInt16 nWhich ) const; const ScPatternAttr* GetPattern( SCROW nRow ) const; diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index b325c802ebec..7da817718379 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -847,8 +847,10 @@ public: void SetRangeName(ScRangeName* pNew); ScRangeName* GetRangeName() const; - void PreprocessRangeNameUpdate(); - void PostprocessRangeNameUpdate(); + void PreprocessRangeNameUpdate( + sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt ); + + void PostprocessRangeNameUpdate( sc::CompileFormulaContext& rCompileCxt ); ScConditionalFormatList* GetCondFormList(); const ScConditionalFormatList* GetCondFormList() const; diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index 7a360d09a673..c6581240b7fb 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -554,14 +554,14 @@ namespace { class PreRangeNameUpdateHandler { ScDocument* mpDoc; - boost::shared_ptr<sc::EndListeningContext> mpEndListenCxt; - boost::shared_ptr<sc::CompileFormulaContext> mpCompileFormulaCxt; + sc::EndListeningContext& mrEndListenCxt; + sc::CompileFormulaContext& mrCompileFormulaCxt; public: - PreRangeNameUpdateHandler( ScDocument* pDoc ) : + PreRangeNameUpdateHandler( ScDocument* pDoc, sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt ) : mpDoc(pDoc), - mpEndListenCxt(new sc::EndListeningContext(*pDoc)), - mpCompileFormulaCxt(new sc::CompileFormulaContext(pDoc)) {} + mrEndListenCxt(rEndListenCxt), + mrCompileFormulaCxt(rCompileCxt) {} void operator() ( sc::FormulaGroupEntry& rEntry ) { @@ -589,7 +589,7 @@ public: if (bRecompile) { // Get the formula string. - OUString aFormula = pTop->GetFormula(*mpCompileFormulaCxt); + OUString aFormula = pTop->GetFormula(mrCompileFormulaCxt); sal_Int32 n = aFormula.getLength(); if (pTop->GetMatrixFlag() != MM_NONE && n > 0) { @@ -604,13 +604,13 @@ public: for (; pp != ppEnd; ++pp) { ScFormulaCell* p = *pp; - p->EndListeningTo(*mpEndListenCxt); + p->EndListeningTo(mrEndListenCxt); mpDoc->RemoveFromFormulaTree(p); } } else { - rEntry.mpCell->EndListeningTo(*mpEndListenCxt); + rEntry.mpCell->EndListeningTo(mrEndListenCxt); mpDoc->RemoveFromFormulaTree(rEntry.mpCell); } @@ -623,12 +623,12 @@ public: class PostRangeNameUpdateHandler { ScDocument* mpDoc; - boost::shared_ptr<sc::CompileFormulaContext> mpCompileFormulaCxt; + sc::CompileFormulaContext& mrCompileFormulaCxt; public: - PostRangeNameUpdateHandler( ScDocument* pDoc ) : + PostRangeNameUpdateHandler( ScDocument* pDoc, sc::CompileFormulaContext& rCompileCxt ) : mpDoc(pDoc), - mpCompileFormulaCxt(new sc::CompileFormulaContext(pDoc)) {} + mrCompileFormulaCxt(rCompileCxt) {} void operator() ( sc::FormulaGroupEntry& rEntry ) { @@ -639,7 +639,7 @@ public: // Create a new token array from the hybrid formula string, and // set it to the group. - ScCompiler aComp(*mpCompileFormulaCxt, pTop->aPos); + ScCompiler aComp(mrCompileFormulaCxt, pTop->aPos); ScTokenArray* pNewCode = aComp.CompileString(aFormula); ScFormulaCellGroupRef xGroup = pTop->GetCellGroup(); assert(xGroup); @@ -662,7 +662,7 @@ public: OUString aFormula = pCell->GetHybridFormula(); // Create token array from formula string. - ScCompiler aComp(*mpCompileFormulaCxt, pCell->aPos); + ScCompiler aComp(mrCompileFormulaCxt, pCell->aPos); ScTokenArray* pNewCode = aComp.CompileString(aFormula); // Generate RPN tokens. @@ -677,21 +677,22 @@ public: } -void ScColumn::PreprocessRangeNameUpdate() +void ScColumn::PreprocessRangeNameUpdate( + sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt ) { // Collect all formula groups. std::vector<sc::FormulaGroupEntry> aGroups = GetFormulaGroupEntries(); - PreRangeNameUpdateHandler aFunc(pDocument); + PreRangeNameUpdateHandler aFunc(pDocument, rEndListenCxt, rCompileCxt); std::for_each(aGroups.begin(), aGroups.end(), aFunc); } -void ScColumn::PostprocessRangeNameUpdate() +void ScColumn::PostprocessRangeNameUpdate( sc::CompileFormulaContext& rCompileCxt ) { // Collect all formula groups. std::vector<sc::FormulaGroupEntry> aGroups = GetFormulaGroupEntries(); - PostRangeNameUpdateHandler aFunc(pDocument); + PostRangeNameUpdateHandler aFunc(pDocument, rCompileCxt); std::for_each(aGroups.begin(), aGroups.end(), aFunc); } diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx index 84410ab5486c..e4a2ff15b046 100644 --- a/sc/source/core/data/document10.cxx +++ b/sc/source/core/data/document10.cxx @@ -14,6 +14,8 @@ #include <table.hxx> #include <tokenarray.hxx> #include <editutil.hxx> +#include <listenercontext.hxx> +#include <tokenstringcontext.hxx> // Add totally brand-new methods to this source file. @@ -239,21 +241,25 @@ const ScCalcConfig& ScDocument::GetCalcConfig() const void ScDocument::PreprocessRangeNameUpdate() { + sc::EndListeningContext aEndListenCxt(*this); + sc::CompileFormulaContext aCompileCxt(this); + TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end(); for (; it != itEnd; ++it) { ScTable* p = *it; - p->PreprocessRangeNameUpdate(); + p->PreprocessRangeNameUpdate(aEndListenCxt, aCompileCxt); } } void ScDocument::PostprocessRangeNameUpdate() { + sc::CompileFormulaContext aCompileCxt(this); TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end(); for (; it != itEnd; ++it) { ScTable* p = *it; - p->PostprocessRangeNameUpdate(); + p->PostprocessRangeNameUpdate(aCompileCxt); } } diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx index 9406326e4699..48aa0a49ec4b 100644 --- a/sc/source/core/data/table7.cxx +++ b/sc/source/core/data/table7.cxx @@ -80,16 +80,17 @@ void ScTable::CopyCellValuesFrom( SCCOL nCol, SCROW nRow, const sc::CellValues& aCol[nCol].CopyCellValuesFrom(nRow, rSrc); } -void ScTable::PreprocessRangeNameUpdate() +void ScTable::PreprocessRangeNameUpdate( + sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt ) { for (SCCOL i = 0; i <= MAXCOL; ++i) - aCol[i].PreprocessRangeNameUpdate(); + aCol[i].PreprocessRangeNameUpdate(rEndListenCxt, rCompileCxt); } -void ScTable::PostprocessRangeNameUpdate() +void ScTable::PostprocessRangeNameUpdate( sc::CompileFormulaContext& rCompileCxt ) { for (SCCOL i = 0; i <= MAXCOL; ++i) - aCol[i].PostprocessRangeNameUpdate(); + aCol[i].PostprocessRangeNameUpdate(rCompileCxt); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |