summaryrefslogtreecommitdiff
path: root/sc/inc/document.hxx
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-06-04 18:39:54 +0200
committerLuboš Luňák <l.lunak@collabora.com>2020-06-09 09:49:19 +0200
commita97539174fd7f76713291dd4e8138adb1f776c91 (patch)
tree77c60c0297f42b8ce25c8be50a7094eb5db56ca2 /sc/inc/document.hxx
parent49df367a5da14b31729e2f4f5dd6bf4e249df8d3 (diff)
delay and batch calls to StartListeningFormulaCells() (tdf#133302)
In the testcase ScColumn::StartListeningUnshared() gets called repeatedly with almost the same cells range (just extending), so this gets quadratic. Delaying and doing it once on the whole range at the end avoids this. Change-Id: I3e92817d434cf7e4be0ea658f9adc0a24ceda260 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95531 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc/inc/document.hxx')
-rw-r--r--sc/inc/document.hxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 03ea2b9d4336..0f7415ac846f 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -49,6 +49,7 @@
#include <memory>
#include <map>
#include <set>
+#include <unordered_map>
#include <vector>
#include "markdata.hxx"
@@ -129,6 +130,7 @@ class ScBroadcastAreaSlotMachine;
class ScChangeViewSettings;
class ScChartListenerCollection;
class ScClipOptions;
+class ScColumn;
class ScConditionalFormat;
class ScConditionalFormatList;
class ScDBCollection;
@@ -519,6 +521,10 @@ private:
// 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;
+ // If non-empty, ScColumn::StartListeningFormulaCells() calls may be delayed using this,
+ // avoiding repeated calling for the same cells in the given range. The function will be called once
+ // later for all the cells in the range.
+ std::unordered_map< ScColumn*, std::pair<SCROW, SCROW>> pDelayedStartListeningFormulaCells;
bool bLinkFormulaNeedingCheck; // valid only after loading, for ocDde and ocWebservice
@@ -1360,6 +1366,14 @@ public:
bool IsDelayedFormulaGrouping() const { return bool(pDelayedFormulaGrouping); }
/// To be used only by SharedFormulaUtil::joinFormulaCells().
void AddDelayedFormulaGroupingCell( const ScFormulaCell* cell );
+ /// If set, ScColumn::StartListeningFormulaCells() calls may be delayed using
+ /// CanDelayStartListeningFormulaCells() until reset again, at which point the function will
+ /// be called as necessary.
+ void EnableDelayStartListeningFormulaCells( ScColumn* column, bool delay );
+ bool IsEnabledDelayStartListeningFormulaCells( ScColumn* column ) const;
+ /// If true is returned, ScColumn::StartListeningFormulaCells() for the given cells will be performed
+ /// later. If false is returned, it needs to be done explicitly.
+ bool CanDelayStartListeningFormulaCells( ScColumn* column, SCROW row1, SCROW row2 );
FormulaError GetErrCode( const ScAddress& ) const;