summaryrefslogtreecommitdiff
path: root/sc/inc/document.hxx
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2018-12-07 17:42:07 +0100
committerEike Rathke <erack@redhat.com>2018-12-14 16:25:25 +0100
commit169a1b542165f3444791fd6e672d56d3fe48bd66 (patch)
tree1b1614e38aa962c9798d655769defea0832f5804 /sc/inc/document.hxx
parenta3fb726f4972c5a869e778353c8c1c19f149c5ea (diff)
avoid possible expensive repetitive formula group changes (tdf#102364)
The testcase from tdf#102364 is actually a rather pathological case, the document having a full 1M cells column with the same formula, and doing undo in this case essentially pastes the column over itself (I think a column is first deleted, which moves this column, and then ScUndoInsertCells will trigger ScMoveUndo::UndoRef(), which will paste the column in that place again. And since this is done cell by cell, removing old cell first splits the large formula group and then adding a new cell with the same formula rejoins the formula group, and setting these formula group changes for all the cells over and over actually takes a long time. Avoid that by delaying the formula grouping operation and do it just once at the end. I'm not sure if this is that good way of handling this, given the testcase is very specific, but I can imagine something similar happening in other possible cases (manual copy&paste of a large column over itself or moving it slightly up or down). Change-Id: Ie4241197103a039c232150333250f78175b1c2c7 Reviewed-on: https://gerrit.libreoffice.org/64782 Tested-by: Jenkins Reviewed-by: Kohei Yoshida <libreoffice@kohei.us> Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/inc/document.hxx')
-rw-r--r--sc/inc/document.hxx10
1 files changed, 10 insertions, 0 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index f5f8fdbd594d..bb7a4f01fa2b 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -502,6 +502,9 @@ private:
bool bExpandRefs;
// for detective update, is set for each change of a formula
bool bDetectiveDirty;
+ // If the pointer is set, formula cells will not be automatically grouped into shared formula groups,
+ // instead the range will be extended to contain all such cells.
+ std::unique_ptr< ScRange > pDelayedFormulaGrouping;
bool bLinkFormulaNeedingCheck; // valid only after loading, for ocDde and ocWebservice
@@ -1317,6 +1320,12 @@ public:
bool IsForcedFormulaPending() const { return bForcedFormulaPending; }
// if CalcFormulaTree() is currently running
bool IsCalculatingFormulaTree() { return bCalculatingFormulaTree; }
+ /// If set, joining cells into shared formula groups will be delayed until reset again
+ /// (RegroupFormulaCells() will be called as needed).
+ void DelayFormulaGrouping( bool delay );
+ bool IsDelayedFormulaGrouping() const { return pDelayedFormulaGrouping.get() != nullptr; }
+ /// To be used only by SharedFormulaUtil::joinFormulaCells().
+ void AddDelayedFormulaGroupingCell( ScFormulaCell* cell );
FormulaError GetErrCode( const ScAddress& ) const;
@@ -2399,6 +2408,7 @@ public:
*/
void UnshareFormulaCells( SCTAB nTab, SCCOL nCol, std::vector<SCROW>& rRows );
void RegroupFormulaCells( SCTAB nTab, SCCOL nCol );
+ void RegroupFormulaCells( const ScRange& range );
ScFormulaVectorState GetFormulaVectorState( const ScAddress& rPos ) const;