LibreOffice Module sc (master) 1
recursionhelper.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include "formularesult.hxx"
23
24#include <list>
25#include <vector>
26#include <stack>
28
29class ScFormulaCell;
30
32{
37 ScFormulaCell* p, bool bR, const ScFormulaResult & rRes ) :
39 {
40 }
41};
42
43typedef ::std::list< ScFormulaRecursionEntry > ScFormulaRecursionList;
44
46{
47 typedef ::std::stack< ScFormulaCell* > ScRecursionInIterationStack;
49 ScFormulaRecursionList::iterator aInsertPos;
50 ScFormulaRecursionList::iterator aLastIterationStart;
52 std::vector< ScFormulaCell* > aFGList;
53 // Flag list corresponding to aFGList to indicate whether each formula-group
54 // is in a dependency evaluation mode or not.
55 std::vector< bool > aInDependencyEvalMode;
56 sal_uInt16 nRecursionCount;
57 sal_uInt16 nIteration;
58 // Count of ScFormulaCell::CheckComputeDependencies in current call-stack.
66 std::vector< ScFormulaCell* > aTemporaryGroupCells;
68
69 void Init();
70 void ResetIteration();
71
72public:
73
75 sal_uInt16 GetRecursionCount() const { return nRecursionCount; }
78 sal_uInt16 GetDepComputeLevel() const { return nDependencyComputationLevel; }
79 void IncDepComputeLevel();
80 void DecDepComputeLevel();
82 bool IsInRecursionReturn() const { return bInRecursionReturn &&
84 void SetInRecursionReturn( bool b );
85 bool IsDoingRecursion() const { return bDoingRecursion; }
86 void SetDoingRecursion( bool b ) { bDoingRecursion = b; }
87
88 void Insert( ScFormulaCell* p, bool bOldRunning, const ScFormulaResult & rRes );
89
90 bool IsInIterationReturn() const { return bInIterationReturn; }
91 void SetInIterationReturn( bool b );
92 bool IsDoingIteration() const { return nIteration > 0; }
93 sal_uInt16 GetIteration() const { return nIteration; }
95 void StartIteration();
96 void ResumeIteration();
97 void IncIteration();
98 void EndIteration();
99
100 const ScFormulaRecursionList::iterator& GetLastIterationStart() const { return aLastIterationStart; }
101 ScFormulaRecursionList::iterator GetIterationStart();
102 ScFormulaRecursionList::iterator GetIterationEnd();
105 bool IsInReturn() const { return bInRecursionReturn; }
109
110 void Clear();
111
113 bool PushFormulaGroup(ScFormulaCell* pCell);
114 void PopFormulaGroup();
116 bool AnyParentFGInCycle();
117 void SetFormulaGroupDepEvalMode(bool bSet);
118 // When dependency computation detects a cycle, it may not compute proper cell values.
119 // This sets a flag that ScFormulaCell will use to avoid setting those new values
120 // and resetting the dirty flag, until the dependency computation bails out.
123
126
128 bool HasFormulaGroupSet() const { return pFGSet != nullptr; }
130 void SetGroupsIndependent(bool bSet) { bGroupsIndependent = bSet; }
132};
133
138{
141public:
145
146};
147
149{
151public:
155};
156
158{
161public:
166
168};
169
170/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScRecursionHelper & mrRecHelper
A class to wrap ScRecursionHelper::PushFormulaGroup(), ScRecursionHelper::PopFormulaGroup() and make ...
Store a variable formula cell result, balancing between runtime performance and memory consumption.
bool PushFormulaGroup(ScFormulaCell *pCell)
Detects a simple cycle involving formula-groups and singleton formula-cells.
bool IsInRecursionReturn() const
A pure recursion return, no iteration.
o3tl::sorted_vector< ScFormulaCellGroup * > * pFGSet
void SetGroupsIndependent(bool bSet)
void SetDoingRecursion(bool b)
sal_uInt16 nDependencyComputationLevel
void SetInRecursionReturn(bool b)
const ScFormulaRecursionList::iterator & GetLastIterationStart() const
sal_uInt16 GetIteration() const
sal_uInt16 GetDepComputeLevel() const
::std::stack< ScFormulaCell * > ScRecursionInIterationStack
bool IsInIterationReturn() const
ScRecursionInIterationStack & GetRecursionInIterationStack()
const ScFormulaRecursionList & GetList() const
ScRecursionInIterationStack aRecursionInIterationStack
bool CheckFGIndependence(ScFormulaCellGroup *pFG)
void SetFormulaGroupDepEvalMode(bool bSet)
void AddTemporaryGroupCell(ScFormulaCell *cell)
std::vector< ScFormulaCell * > aFGList
void SetInIterationReturn(bool b)
ScFormulaRecursionList::iterator aInsertPos
bool & GetConvergingReference()
ScFormulaRecursionList::iterator GetIterationStart()
bool IsDoingRecursion() const
void Insert(ScFormulaCell *p, bool bOldRunning, const ScFormulaResult &rRes)
bool IsDoingIteration() const
bool HasFormulaGroupSet() const
ScFormulaRecursionList aRecursionFormulas
void SetFormulaGroupSet(o3tl::sorted_vector< ScFormulaCellGroup * > *pSet)
bool IsAbortingDependencyComputation() const
ScFormulaRecursionList & GetList()
ScFormulaRecursionList::iterator aLastIterationStart
bool AnyCycleMemberInDependencyEvalMode(const ScFormulaCell *pCell)
std::vector< bool > aInDependencyEvalMode
std::vector< ScFormulaCell * > aTemporaryGroupCells
bool IsInReturn() const
Any return, recursion or iteration, iteration is always coupled with recursion.
sal_uInt16 GetRecursionCount() const
ScFormulaRecursionList::iterator GetIterationEnd()
sal_uInt16 nRecursionCount
void * p
::std::list< ScFormulaRecursionEntry > ScFormulaRecursionList
ScFormulaRecursionEntry(ScFormulaCell *p, bool bR, const ScFormulaResult &rRes)
ScFormulaResult aPreviousResult