LCOV - code coverage report
Current view: top level - sc/source/core/tool - recursionhelper.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 17 53 32.1 %
Date: 2015-06-13 12:38:46 Functions: 6 15 40.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      10             : #include "recursionhelper.hxx"
      11             : 
      12         220 : void ScRecursionHelper::Init()
      13             : {
      14         220 :     nRecursionCount    = 0;
      15         220 :     bInRecursionReturn = bDoingRecursion = bInIterationReturn = false;
      16         220 :     aInsertPos = GetIterationEnd();
      17         220 :     ResetIteration();
      18         220 : }
      19             : 
      20         220 : void ScRecursionHelper::ResetIteration()
      21             : {
      22         220 :     aLastIterationStart = GetIterationEnd();
      23         220 :     nIteration = 0;
      24         220 :     bConverging = false;
      25         220 : }
      26             : 
      27         220 : ScRecursionHelper::ScRecursionHelper()
      28             : {
      29         220 :     Init();
      30         220 : }
      31             : 
      32           0 : void ScRecursionHelper::SetInRecursionReturn( bool b )
      33             : {
      34             :     // Do not use IsInRecursionReturn() here, it decouples iteration.
      35           0 :     if (b && !bInRecursionReturn)
      36           0 :         aInsertPos = aRecursionFormulas.begin();
      37           0 :     bInRecursionReturn = b;
      38           0 : }
      39             : 
      40           0 : void ScRecursionHelper::Insert(
      41             :     ScFormulaCell* p, bool bOldRunning, const ScFormulaResult & rRes )
      42             : {
      43             :     aRecursionFormulas.insert( aInsertPos, ScFormulaRecursionEntry( p,
      44           0 :                 bOldRunning, rRes));
      45           0 : }
      46             : 
      47           0 : void ScRecursionHelper::SetInIterationReturn( bool b )
      48             : {
      49             :     // An iteration return is always coupled to a recursion return.
      50           0 :     SetInRecursionReturn( b);
      51           0 :     bInIterationReturn = b;
      52           0 : }
      53             : 
      54           0 : void ScRecursionHelper::StartIteration()
      55             : {
      56           0 :     SetInIterationReturn( false);
      57           0 :     nIteration = 1;
      58           0 :     bConverging = false;
      59           0 :     aLastIterationStart = GetIterationStart();
      60           0 : }
      61             : 
      62           0 : void ScRecursionHelper::ResumeIteration()
      63             : {
      64           0 :     SetInIterationReturn( false);
      65           0 :     aLastIterationStart = GetIterationStart();
      66           0 : }
      67             : 
      68           0 : void ScRecursionHelper::IncIteration()
      69             : {
      70           0 :     ++nIteration;
      71           0 : }
      72             : 
      73           0 : void ScRecursionHelper::EndIteration()
      74             : {
      75           0 :     aRecursionFormulas.erase( GetIterationStart(), GetIterationEnd());
      76           0 :     ResetIteration();
      77           0 : }
      78             : 
      79           0 : ScFormulaRecursionList::iterator ScRecursionHelper::GetIterationStart()
      80             : {
      81           0 :     return aRecursionFormulas.begin();
      82             : }
      83             : 
      84         440 : ScFormulaRecursionList::iterator ScRecursionHelper::GetIterationEnd()
      85             : {
      86         440 :     return aRecursionFormulas.end();
      87             : }
      88             : 
      89           0 : void ScRecursionHelper::Clear()
      90             : {
      91           0 :     aRecursionFormulas.clear();
      92           0 :     while (!aRecursionInIterationStack.empty())
      93           0 :         aRecursionInIterationStack.pop();
      94           0 :     Init();
      95         156 : }
      96             : 
      97             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11