summaryrefslogtreecommitdiff
path: root/sc/inc
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.co.uk>2018-05-15 16:44:15 +0530
committerJulien Nabet <serval2412@yahoo.fr>2018-05-24 07:27:02 +0200
commit25cc0ab3b5d154fffbef27fad4adcf90f36ae92e (patch)
treedbd95afe17861b71872d5c81bb08cdb5bc8bc0f6 /sc/inc
parent1d16a2562577acdaa3624ab02216bef02863619a (diff)
Calc threading : Check for "self" references...
...on indirect dependencies too. Here a self reference to any formula-group means if there are any references in a formula (of the formula-group itself or any of its dependencies) that points to any element inside the formula-group. If there are any self-references, then that formula-group can't be computed in parallel. For example, with this patch we can detect the following case:- Suppose the formula-group that we want to check is: "=(F2+G2-10)*10.0" spanning A2:A100. Let the formula-group starting at F2 be "=A1*0.1-10". The indirect dependency formula-group starting at F2, references back the elements of our original formula-group at A2. This makes the F.G at A2 unsafe for parallel computation. Concretly, this patch fixes a recalc crash on tdf#63638/1 Change-Id: I7b999a34571b191d2f70da6a3831f78b24a6b0a7 Reviewed-on: https://gerrit.libreoffice.org/54433 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sc/inc')
-rw-r--r--sc/inc/formulacell.hxx1
-rw-r--r--sc/inc/recursionhelper.hxx8
2 files changed, 9 insertions, 0 deletions
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 7656e7a3efec..cee9fec13fc2 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -66,6 +66,7 @@ public:
SvNumFormatType mnFormatType;
bool mbInvariant:1;
bool mbSubTotal:1;
+ bool mbSeenInPath:1; // For detecting cycle of formula groups
sal_uInt8 meCalcState;
diff --git a/sc/inc/recursionhelper.hxx b/sc/inc/recursionhelper.hxx
index 560b66ab357e..b8ca1d087509 100644
--- a/sc/inc/recursionhelper.hxx
+++ b/sc/inc/recursionhelper.hxx
@@ -23,9 +23,11 @@
#include "formularesult.hxx"
#include <list>
+#include <vector>
#include <stack>
class ScFormulaCell;
+struct ScFormulaCellGroup;
struct ScFormulaRecursionEntry
{
@@ -44,10 +46,12 @@ typedef ::std::list< ScFormulaRecursionEntry > ScFormulaRecursionList;
class ScRecursionHelper
{
typedef ::std::stack< ScFormulaCell* > ScRecursionInIterationStack;
+ typedef ::std::vector< ScFormulaCellGroup* > ScFGList;
ScFormulaRecursionList aRecursionFormulas;
ScFormulaRecursionList::iterator aInsertPos;
ScFormulaRecursionList::iterator aLastIterationStart;
ScRecursionInIterationStack aRecursionInIterationStack;
+ ScFGList aFGList;
sal_uInt16 nRecursionCount;
sal_uInt16 nIteration;
bool bInRecursionReturn;
@@ -94,6 +98,10 @@ public:
ScRecursionInIterationStack& GetRecursionInIterationStack() { return aRecursionInIterationStack; }
void Clear();
+
+ /** Detects whether the formula-group is part of a simple cycle of formula-groups. */
+ bool PushFormulaGroup(ScFormulaCellGroup* pGrp);
+ void PopFormulaGroup();
};
#endif // INCLUDED_SC_INC_RECURSIONHELPER_HXX