LCOV - code coverage report
Current view: top level - sc/source/core/tool - recursionhelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 16 53 30.2 %
Date: 2012-08-25 Functions: 4 13 30.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 14 21.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4                 :            :  *
       5                 :            :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :            :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :            :  * the License or as specified alternatively below. You may obtain a copy of
       8                 :            :  * the License at http://www.mozilla.org/MPL/
       9                 :            :  *
      10                 :            :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :            :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :            :  * for the specific language governing rights and limitations under the
      13                 :            :  * License.
      14                 :            :  *
      15                 :            :  * Major Contributor(s):
      16                 :            :  *   Copyright (C) 2012 Kohei Yoshida <kohei.yoshida@suse.com>
      17                 :            :  *
      18                 :            :  * All Rights Reserved.
      19                 :            :  *
      20                 :            :  * For minor contributions see the git repository.
      21                 :            :  *
      22                 :            :  * Alternatively, the contents of this file may be used under the terms of
      23                 :            :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      24                 :            :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      25                 :            :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      26                 :            :  * instead of those above.
      27                 :            :  */
      28                 :            : 
      29                 :            : #include "recursionhelper.hxx"
      30                 :            : 
      31                 :        142 : void ScRecursionHelper::Init()
      32                 :            : {
      33                 :        142 :     nRecursionCount    = 0;
      34                 :        142 :     bInRecursionReturn = bDoingRecursion = bInIterationReturn = false;
      35                 :        142 :     aInsertPos = GetIterationEnd();
      36                 :        142 :     ResetIteration();
      37                 :        142 : }
      38                 :            : 
      39                 :        142 : void ScRecursionHelper::ResetIteration()
      40                 :            : {
      41                 :        142 :     aLastIterationStart = GetIterationEnd();
      42                 :        142 :     nIteration = 0;
      43                 :        142 :     bConverging = false;
      44                 :        142 : }
      45                 :            : 
      46 [ +  - ][ +  - ]:        142 : ScRecursionHelper::ScRecursionHelper()
      47                 :            : {
      48         [ +  - ]:        142 :     Init();
      49                 :        142 : }
      50                 :            : 
      51                 :          0 : void ScRecursionHelper::SetInRecursionReturn( bool b )
      52                 :            : {
      53                 :            :     // Do not use IsInRecursionReturn() here, it decouples iteration.
      54 [ #  # ][ #  # ]:          0 :     if (b && !bInRecursionReturn)
      55                 :          0 :         aInsertPos = aRecursionFormulas.begin();
      56                 :          0 :     bInRecursionReturn = b;
      57                 :          0 : }
      58                 :            : 
      59                 :          0 : void ScRecursionHelper::Insert(
      60                 :            :     ScFormulaCell* p, bool bOldRunning, const ScFormulaResult & rRes )
      61                 :            : {
      62                 :            :     aRecursionFormulas.insert( aInsertPos, ScFormulaRecursionEntry( p,
      63         [ #  # ]:          0 :                 bOldRunning, rRes));
      64                 :          0 : }
      65                 :            : 
      66                 :          0 : void ScRecursionHelper::SetInIterationReturn( bool b )
      67                 :            : {
      68                 :            :     // An iteration return is always coupled to a recursion return.
      69                 :          0 :     SetInRecursionReturn( b);
      70                 :          0 :     bInIterationReturn = b;
      71                 :          0 : }
      72                 :            : 
      73                 :          0 : void ScRecursionHelper::StartIteration()
      74                 :            : {
      75                 :          0 :     SetInIterationReturn( false);
      76                 :          0 :     nIteration = 1;
      77                 :          0 :     bConverging = false;
      78                 :          0 :     aLastIterationStart = GetIterationStart();
      79                 :          0 : }
      80                 :            : 
      81                 :          0 : void ScRecursionHelper::ResumeIteration()
      82                 :            : {
      83                 :          0 :     SetInIterationReturn( false);
      84                 :          0 :     aLastIterationStart = GetIterationStart();
      85                 :          0 : }
      86                 :            : 
      87                 :          0 : void ScRecursionHelper::IncIteration()
      88                 :            : {
      89                 :          0 :     ++nIteration;
      90                 :          0 : }
      91                 :            : 
      92                 :          0 : void ScRecursionHelper::EndIteration()
      93                 :            : {
      94                 :          0 :     aRecursionFormulas.erase( GetIterationStart(), GetIterationEnd());
      95                 :          0 :     ResetIteration();
      96                 :          0 : }
      97                 :            : 
      98                 :          0 : ScFormulaRecursionList::iterator ScRecursionHelper::GetIterationStart()
      99                 :            : {
     100                 :          0 :     return aRecursionFormulas.begin();
     101                 :            : }
     102                 :            : 
     103                 :        284 : ScFormulaRecursionList::iterator ScRecursionHelper::GetIterationEnd()
     104                 :            : {
     105                 :        284 :     return aRecursionFormulas.end();
     106                 :            : }
     107                 :            : 
     108                 :          0 : void ScRecursionHelper::Clear()
     109                 :            : {
     110                 :          0 :     aRecursionFormulas.clear();
     111         [ #  # ]:          0 :     while (!aRecursionInIterationStack.empty())
     112                 :          0 :         aRecursionInIterationStack.pop();
     113                 :          0 :     Init();
     114                 :          0 : }
     115                 :            : 
     116                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
     117                 :            : 
     118                 :            : 
     119                 :            : 
     120                 :            : 
     121                 :            : 

Generated by: LCOV version 1.10