fdo#75741: Share the context objects to avoid poor performance.
Change-Id: I1015dbfa9e2220cd23244dae17ee8dc4828c6a67
This commit is contained in:
@@ -372,8 +372,10 @@ public:
|
|||||||
void SetTabNo(SCTAB nNewTab);
|
void SetTabNo(SCTAB nNewTab);
|
||||||
void FindRangeNamesInUse(SCROW nRow1, SCROW nRow2, std::set<sal_uInt16>& rIndexes) const;
|
void FindRangeNamesInUse(SCROW nRow1, SCROW nRow2, std::set<sal_uInt16>& rIndexes) const;
|
||||||
|
|
||||||
void PreprocessRangeNameUpdate();
|
void PreprocessRangeNameUpdate(
|
||||||
void PostprocessRangeNameUpdate();
|
sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
|
||||||
|
|
||||||
|
void PostprocessRangeNameUpdate( sc::CompileFormulaContext& rCompileCxt );
|
||||||
|
|
||||||
const SfxPoolItem* GetAttr( SCROW nRow, sal_uInt16 nWhich ) const;
|
const SfxPoolItem* GetAttr( SCROW nRow, sal_uInt16 nWhich ) const;
|
||||||
const ScPatternAttr* GetPattern( SCROW nRow ) const;
|
const ScPatternAttr* GetPattern( SCROW nRow ) const;
|
||||||
|
@@ -847,8 +847,10 @@ public:
|
|||||||
void SetRangeName(ScRangeName* pNew);
|
void SetRangeName(ScRangeName* pNew);
|
||||||
ScRangeName* GetRangeName() const;
|
ScRangeName* GetRangeName() const;
|
||||||
|
|
||||||
void PreprocessRangeNameUpdate();
|
void PreprocessRangeNameUpdate(
|
||||||
void PostprocessRangeNameUpdate();
|
sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
|
||||||
|
|
||||||
|
void PostprocessRangeNameUpdate( sc::CompileFormulaContext& rCompileCxt );
|
||||||
|
|
||||||
ScConditionalFormatList* GetCondFormList();
|
ScConditionalFormatList* GetCondFormList();
|
||||||
const ScConditionalFormatList* GetCondFormList() const;
|
const ScConditionalFormatList* GetCondFormList() const;
|
||||||
|
@@ -554,14 +554,14 @@ namespace {
|
|||||||
class PreRangeNameUpdateHandler
|
class PreRangeNameUpdateHandler
|
||||||
{
|
{
|
||||||
ScDocument* mpDoc;
|
ScDocument* mpDoc;
|
||||||
boost::shared_ptr<sc::EndListeningContext> mpEndListenCxt;
|
sc::EndListeningContext& mrEndListenCxt;
|
||||||
boost::shared_ptr<sc::CompileFormulaContext> mpCompileFormulaCxt;
|
sc::CompileFormulaContext& mrCompileFormulaCxt;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PreRangeNameUpdateHandler( ScDocument* pDoc ) :
|
PreRangeNameUpdateHandler( ScDocument* pDoc, sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt ) :
|
||||||
mpDoc(pDoc),
|
mpDoc(pDoc),
|
||||||
mpEndListenCxt(new sc::EndListeningContext(*pDoc)),
|
mrEndListenCxt(rEndListenCxt),
|
||||||
mpCompileFormulaCxt(new sc::CompileFormulaContext(pDoc)) {}
|
mrCompileFormulaCxt(rCompileCxt) {}
|
||||||
|
|
||||||
void operator() ( sc::FormulaGroupEntry& rEntry )
|
void operator() ( sc::FormulaGroupEntry& rEntry )
|
||||||
{
|
{
|
||||||
@@ -589,7 +589,7 @@ public:
|
|||||||
if (bRecompile)
|
if (bRecompile)
|
||||||
{
|
{
|
||||||
// Get the formula string.
|
// Get the formula string.
|
||||||
OUString aFormula = pTop->GetFormula(*mpCompileFormulaCxt);
|
OUString aFormula = pTop->GetFormula(mrCompileFormulaCxt);
|
||||||
sal_Int32 n = aFormula.getLength();
|
sal_Int32 n = aFormula.getLength();
|
||||||
if (pTop->GetMatrixFlag() != MM_NONE && n > 0)
|
if (pTop->GetMatrixFlag() != MM_NONE && n > 0)
|
||||||
{
|
{
|
||||||
@@ -604,13 +604,13 @@ public:
|
|||||||
for (; pp != ppEnd; ++pp)
|
for (; pp != ppEnd; ++pp)
|
||||||
{
|
{
|
||||||
ScFormulaCell* p = *pp;
|
ScFormulaCell* p = *pp;
|
||||||
p->EndListeningTo(*mpEndListenCxt);
|
p->EndListeningTo(mrEndListenCxt);
|
||||||
mpDoc->RemoveFromFormulaTree(p);
|
mpDoc->RemoveFromFormulaTree(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rEntry.mpCell->EndListeningTo(*mpEndListenCxt);
|
rEntry.mpCell->EndListeningTo(mrEndListenCxt);
|
||||||
mpDoc->RemoveFromFormulaTree(rEntry.mpCell);
|
mpDoc->RemoveFromFormulaTree(rEntry.mpCell);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -623,12 +623,12 @@ public:
|
|||||||
class PostRangeNameUpdateHandler
|
class PostRangeNameUpdateHandler
|
||||||
{
|
{
|
||||||
ScDocument* mpDoc;
|
ScDocument* mpDoc;
|
||||||
boost::shared_ptr<sc::CompileFormulaContext> mpCompileFormulaCxt;
|
sc::CompileFormulaContext& mrCompileFormulaCxt;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PostRangeNameUpdateHandler( ScDocument* pDoc ) :
|
PostRangeNameUpdateHandler( ScDocument* pDoc, sc::CompileFormulaContext& rCompileCxt ) :
|
||||||
mpDoc(pDoc),
|
mpDoc(pDoc),
|
||||||
mpCompileFormulaCxt(new sc::CompileFormulaContext(pDoc)) {}
|
mrCompileFormulaCxt(rCompileCxt) {}
|
||||||
|
|
||||||
void operator() ( sc::FormulaGroupEntry& rEntry )
|
void operator() ( sc::FormulaGroupEntry& rEntry )
|
||||||
{
|
{
|
||||||
@@ -639,7 +639,7 @@ public:
|
|||||||
|
|
||||||
// Create a new token array from the hybrid formula string, and
|
// Create a new token array from the hybrid formula string, and
|
||||||
// set it to the group.
|
// set it to the group.
|
||||||
ScCompiler aComp(*mpCompileFormulaCxt, pTop->aPos);
|
ScCompiler aComp(mrCompileFormulaCxt, pTop->aPos);
|
||||||
ScTokenArray* pNewCode = aComp.CompileString(aFormula);
|
ScTokenArray* pNewCode = aComp.CompileString(aFormula);
|
||||||
ScFormulaCellGroupRef xGroup = pTop->GetCellGroup();
|
ScFormulaCellGroupRef xGroup = pTop->GetCellGroup();
|
||||||
assert(xGroup);
|
assert(xGroup);
|
||||||
@@ -662,7 +662,7 @@ public:
|
|||||||
OUString aFormula = pCell->GetHybridFormula();
|
OUString aFormula = pCell->GetHybridFormula();
|
||||||
|
|
||||||
// Create token array from formula string.
|
// Create token array from formula string.
|
||||||
ScCompiler aComp(*mpCompileFormulaCxt, pCell->aPos);
|
ScCompiler aComp(mrCompileFormulaCxt, pCell->aPos);
|
||||||
ScTokenArray* pNewCode = aComp.CompileString(aFormula);
|
ScTokenArray* pNewCode = aComp.CompileString(aFormula);
|
||||||
|
|
||||||
// Generate RPN tokens.
|
// Generate RPN tokens.
|
||||||
@@ -677,21 +677,22 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScColumn::PreprocessRangeNameUpdate()
|
void ScColumn::PreprocessRangeNameUpdate(
|
||||||
|
sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt )
|
||||||
{
|
{
|
||||||
// Collect all formula groups.
|
// Collect all formula groups.
|
||||||
std::vector<sc::FormulaGroupEntry> aGroups = GetFormulaGroupEntries();
|
std::vector<sc::FormulaGroupEntry> aGroups = GetFormulaGroupEntries();
|
||||||
|
|
||||||
PreRangeNameUpdateHandler aFunc(pDocument);
|
PreRangeNameUpdateHandler aFunc(pDocument, rEndListenCxt, rCompileCxt);
|
||||||
std::for_each(aGroups.begin(), aGroups.end(), aFunc);
|
std::for_each(aGroups.begin(), aGroups.end(), aFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScColumn::PostprocessRangeNameUpdate()
|
void ScColumn::PostprocessRangeNameUpdate( sc::CompileFormulaContext& rCompileCxt )
|
||||||
{
|
{
|
||||||
// Collect all formula groups.
|
// Collect all formula groups.
|
||||||
std::vector<sc::FormulaGroupEntry> aGroups = GetFormulaGroupEntries();
|
std::vector<sc::FormulaGroupEntry> aGroups = GetFormulaGroupEntries();
|
||||||
|
|
||||||
PostRangeNameUpdateHandler aFunc(pDocument);
|
PostRangeNameUpdateHandler aFunc(pDocument, rCompileCxt);
|
||||||
std::for_each(aGroups.begin(), aGroups.end(), aFunc);
|
std::for_each(aGroups.begin(), aGroups.end(), aFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
#include <table.hxx>
|
#include <table.hxx>
|
||||||
#include <tokenarray.hxx>
|
#include <tokenarray.hxx>
|
||||||
#include <editutil.hxx>
|
#include <editutil.hxx>
|
||||||
|
#include <listenercontext.hxx>
|
||||||
|
#include <tokenstringcontext.hxx>
|
||||||
|
|
||||||
// Add totally brand-new methods to this source file.
|
// Add totally brand-new methods to this source file.
|
||||||
|
|
||||||
@@ -239,21 +241,25 @@ const ScCalcConfig& ScDocument::GetCalcConfig() const
|
|||||||
|
|
||||||
void ScDocument::PreprocessRangeNameUpdate()
|
void ScDocument::PreprocessRangeNameUpdate()
|
||||||
{
|
{
|
||||||
|
sc::EndListeningContext aEndListenCxt(*this);
|
||||||
|
sc::CompileFormulaContext aCompileCxt(this);
|
||||||
|
|
||||||
TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end();
|
TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end();
|
||||||
for (; it != itEnd; ++it)
|
for (; it != itEnd; ++it)
|
||||||
{
|
{
|
||||||
ScTable* p = *it;
|
ScTable* p = *it;
|
||||||
p->PreprocessRangeNameUpdate();
|
p->PreprocessRangeNameUpdate(aEndListenCxt, aCompileCxt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScDocument::PostprocessRangeNameUpdate()
|
void ScDocument::PostprocessRangeNameUpdate()
|
||||||
{
|
{
|
||||||
|
sc::CompileFormulaContext aCompileCxt(this);
|
||||||
TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end();
|
TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end();
|
||||||
for (; it != itEnd; ++it)
|
for (; it != itEnd; ++it)
|
||||||
{
|
{
|
||||||
ScTable* p = *it;
|
ScTable* p = *it;
|
||||||
p->PostprocessRangeNameUpdate();
|
p->PostprocessRangeNameUpdate(aCompileCxt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -80,16 +80,17 @@ void ScTable::CopyCellValuesFrom( SCCOL nCol, SCROW nRow, const sc::CellValues&
|
|||||||
aCol[nCol].CopyCellValuesFrom(nRow, rSrc);
|
aCol[nCol].CopyCellValuesFrom(nRow, rSrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScTable::PreprocessRangeNameUpdate()
|
void ScTable::PreprocessRangeNameUpdate(
|
||||||
|
sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt )
|
||||||
{
|
{
|
||||||
for (SCCOL i = 0; i <= MAXCOL; ++i)
|
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)
|
for (SCCOL i = 0; i <= MAXCOL; ++i)
|
||||||
aCol[i].PostprocessRangeNameUpdate();
|
aCol[i].PostprocessRangeNameUpdate(rCompileCxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
Reference in New Issue
Block a user