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/.
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"
30 struct ScFormulaRecursionEntry
34 ScFormulaResult aPreviousResult
;
35 ScFormulaRecursionEntry(
36 ScFormulaCell
* p
, bool bR
, const ScFormulaResult
& rRes
) :
37 pCell(p
), bOldRunning(bR
), aPreviousResult( rRes
)
42 typedef ::std::list
< ScFormulaRecursionEntry
> ScFormulaRecursionList
;
44 class ScRecursionHelper
46 typedef ::std::stack
< ScFormulaCell
* > ScRecursionInIterationStack
;
47 ScFormulaRecursionList aRecursionFormulas
;
48 ScFormulaRecursionList::iterator aInsertPos
;
49 ScFormulaRecursionList::iterator aLastIterationStart
;
50 ScRecursionInIterationStack aRecursionInIterationStack
;
51 sal_uInt16 nRecursionCount
;
52 sal_uInt16 nIteration
;
53 bool bInRecursionReturn
;
55 bool bInIterationReturn
;
59 void ResetIteration();
64 sal_uInt16
GetRecursionCount() const { return nRecursionCount
; }
65 void IncRecursionCount() { ++nRecursionCount
; }
66 void DecRecursionCount() { --nRecursionCount
; }
67 /// A pure recursion return, no iteration.
68 bool IsInRecursionReturn() const { return bInRecursionReturn
&&
69 !bInIterationReturn
; }
70 void SetInRecursionReturn( bool b
);
71 bool IsDoingRecursion() const { return bDoingRecursion
; }
72 void SetDoingRecursion( bool b
) { bDoingRecursion
= b
; }
74 void Insert( ScFormulaCell
* p
, bool bOldRunning
, const ScFormulaResult
& rRes
);
76 bool IsInIterationReturn() const { return bInIterationReturn
; }
77 void SetInIterationReturn( bool b
);
78 bool IsDoingIteration() const { return nIteration
> 0; }
79 sal_uInt16
GetIteration() const { return nIteration
; }
80 bool & GetConvergingReference() { return bConverging
; }
81 void StartIteration();
82 void ResumeIteration();
86 ScFormulaRecursionList::iterator
GetLastIterationStart() { return aLastIterationStart
; }
87 ScFormulaRecursionList::iterator
GetIterationStart();
88 ScFormulaRecursionList::iterator
GetIterationEnd();
89 /** Any return, recursion or iteration, iteration is always coupled with
91 bool IsInReturn() const { return bInRecursionReturn
; }
92 const ScFormulaRecursionList
& GetList() const { return aRecursionFormulas
; }
93 ScFormulaRecursionList
& GetList() { return aRecursionFormulas
; }
94 ScRecursionInIterationStack
& GetRecursionInIterationStack() { return aRecursionInIterationStack
; }
99 #endif // INCLUDED_SC_INC_RECURSIONHELPER_HXX
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */