1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include "recursionhelper.hxx"
12 void ScRecursionHelper::Init()
15 bInRecursionReturn
= bDoingRecursion
= bInIterationReturn
= false;
16 aInsertPos
= GetIterationEnd();
20 void ScRecursionHelper::ResetIteration()
22 aLastIterationStart
= GetIterationEnd();
27 ScRecursionHelper::ScRecursionHelper()
32 void ScRecursionHelper::SetInRecursionReturn( bool b
)
34 // Do not use IsInRecursionReturn() here, it decouples iteration.
35 if (b
&& !bInRecursionReturn
)
36 aInsertPos
= aRecursionFormulas
.begin();
37 bInRecursionReturn
= b
;
40 void ScRecursionHelper::Insert(
41 ScFormulaCell
* p
, bool bOldRunning
, const ScFormulaResult
& rRes
)
43 aRecursionFormulas
.insert( aInsertPos
, ScFormulaRecursionEntry( p
,
47 void ScRecursionHelper::SetInIterationReturn( bool b
)
49 // An iteration return is always coupled to a recursion return.
50 SetInRecursionReturn( b
);
51 bInIterationReturn
= b
;
54 void ScRecursionHelper::StartIteration()
56 SetInIterationReturn( false);
59 aLastIterationStart
= GetIterationStart();
62 void ScRecursionHelper::ResumeIteration()
64 SetInIterationReturn( false);
65 aLastIterationStart
= GetIterationStart();
68 void ScRecursionHelper::IncIteration()
73 void ScRecursionHelper::EndIteration()
75 aRecursionFormulas
.erase( GetIterationStart(), GetIterationEnd());
79 ScFormulaRecursionList::iterator
ScRecursionHelper::GetIterationStart()
81 return aRecursionFormulas
.begin();
84 ScFormulaRecursionList::iterator
ScRecursionHelper::GetIterationEnd()
86 return aRecursionFormulas
.end();
89 void ScRecursionHelper::Clear()
91 aRecursionFormulas
.clear();
92 while (!aRecursionInIterationStack
.empty())
93 aRecursionInIterationStack
.pop();
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */