tdf#125181 maxY is 50000 in prstGeom for star24 and star32
[LibreOffice.git] / sc / inc / recursionhelper.hxx
blobd91ee0cfbe582dcba3d9f573ec68cd6a50e82615
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_INC_RECURSIONHELPER_HXX
21 #define INCLUDED_SC_INC_RECURSIONHELPER_HXX
23 #include "formularesult.hxx"
25 #include <list>
26 #include <vector>
27 #include <stack>
29 class ScFormulaCell;
31 struct ScFormulaRecursionEntry
33 ScFormulaCell* const pCell;
34 bool const bOldRunning;
35 ScFormulaResult aPreviousResult;
36 ScFormulaRecursionEntry(
37 ScFormulaCell* p, bool bR, const ScFormulaResult & rRes ) :
38 pCell(p), bOldRunning(bR), aPreviousResult( rRes)
43 typedef ::std::list< ScFormulaRecursionEntry > ScFormulaRecursionList;
45 class ScRecursionHelper
47 typedef ::std::stack< ScFormulaCell* > ScRecursionInIterationStack;
48 typedef ::std::vector< ScFormulaCell* > ScFGList;
49 ScFormulaRecursionList aRecursionFormulas;
50 ScFormulaRecursionList::iterator aInsertPos;
51 ScFormulaRecursionList::iterator aLastIterationStart;
52 ScRecursionInIterationStack aRecursionInIterationStack;
53 ScFGList aFGList;
54 sal_uInt16 nRecursionCount;
55 sal_uInt16 nIteration;
56 // Count of ScFormulaCell::CheckComputeDependencies in current call-stack.
57 sal_uInt16 nDependencyComputationLevel;
58 bool bInRecursionReturn;
59 bool bDoingRecursion;
60 bool bInIterationReturn;
61 bool bConverging;
62 std::vector< ScFormulaCell* > aTemporaryGroupCells;
64 void Init();
65 void ResetIteration();
67 public:
69 ScRecursionHelper();
70 sal_uInt16 GetRecursionCount() const { return nRecursionCount; }
71 void IncRecursionCount() { ++nRecursionCount; }
72 void DecRecursionCount() { --nRecursionCount; }
73 sal_uInt16 GetDepComputeLevel() { return nDependencyComputationLevel; }
74 void IncDepComputeLevel() { ++nDependencyComputationLevel; }
75 void DecDepComputeLevel() { --nDependencyComputationLevel; }
76 /// A pure recursion return, no iteration.
77 bool IsInRecursionReturn() const { return bInRecursionReturn &&
78 !bInIterationReturn; }
79 void SetInRecursionReturn( bool b );
80 bool IsDoingRecursion() const { return bDoingRecursion; }
81 void SetDoingRecursion( bool b ) { bDoingRecursion = b; }
83 void Insert( ScFormulaCell* p, bool bOldRunning, const ScFormulaResult & rRes );
85 bool IsInIterationReturn() const { return bInIterationReturn; }
86 void SetInIterationReturn( bool b );
87 bool IsDoingIteration() const { return nIteration > 0; }
88 sal_uInt16 GetIteration() const { return nIteration; }
89 bool & GetConvergingReference() { return bConverging; }
90 void StartIteration();
91 void ResumeIteration();
92 void IncIteration();
93 void EndIteration();
95 const ScFormulaRecursionList::iterator& GetLastIterationStart() { return aLastIterationStart; }
96 ScFormulaRecursionList::iterator GetIterationStart();
97 ScFormulaRecursionList::iterator GetIterationEnd();
98 /** Any return, recursion or iteration, iteration is always coupled with
99 recursion. */
100 bool IsInReturn() const { return bInRecursionReturn; }
101 const ScFormulaRecursionList& GetList() const { return aRecursionFormulas; }
102 ScFormulaRecursionList& GetList() { return aRecursionFormulas; }
103 ScRecursionInIterationStack& GetRecursionInIterationStack() { return aRecursionInIterationStack; }
105 void Clear();
107 /** Detects a simple cycle involving formula-groups and singleton formula-cells. */
108 bool PushFormulaGroup(ScFormulaCell* pCell);
109 void PopFormulaGroup();
110 bool AnyParentFGInCycle();
112 void AddTemporaryGroupCell(ScFormulaCell* cell);
113 void CleanTemporaryGroupCells();
116 /** A class to wrap ScRecursionHelper::PushFormulaGroup(),
117 ScRecursionHelper::PopFormulaGroup() and make these calls
118 exception safe. */
119 class ScFormulaGroupCycleCheckGuard
121 ScRecursionHelper& mrRecHelper;
122 bool mbShouldPop;
123 public:
124 ScFormulaGroupCycleCheckGuard() = delete;
125 ScFormulaGroupCycleCheckGuard(ScRecursionHelper& rRecursionHelper, ScFormulaCell* pCell);
126 ~ScFormulaGroupCycleCheckGuard();
130 class ScFormulaGroupDependencyComputeGuard
132 ScRecursionHelper& mrRecHelper;
133 public:
134 ScFormulaGroupDependencyComputeGuard() = delete;
135 ScFormulaGroupDependencyComputeGuard(ScRecursionHelper& rRecursionHelper);
136 ~ScFormulaGroupDependencyComputeGuard();
139 #endif // INCLUDED_SC_INC_RECURSIONHELPER_HXX
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */