LCOV - code coverage report
Current view: top level - sc/inc - recursionhelper.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 7 20 35.0 %
Date: 2015-06-13 12:38:46 Functions: 7 18 38.9 %
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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_SC_INC_RECURSIONHELPER_HXX
      21             : #define INCLUDED_SC_INC_RECURSIONHELPER_HXX
      22             : 
      23             : #include "formularesult.hxx"
      24             : 
      25             : #include <list>
      26             : #include <stack>
      27             : 
      28             : class ScFormulaCell;
      29             : 
      30           0 : struct ScFormulaRecursionEntry
      31             : {
      32             :     ScFormulaCell*  pCell;
      33             :     bool            bOldRunning;
      34             :     ScFormulaResult aPreviousResult;
      35           0 :     ScFormulaRecursionEntry(
      36             :         ScFormulaCell* p, bool bR, const ScFormulaResult & rRes ) :
      37           0 :         pCell(p), bOldRunning(bR), aPreviousResult( rRes)
      38             :     {
      39           0 :     }
      40             : };
      41             : 
      42             : typedef ::std::list< ScFormulaRecursionEntry > ScFormulaRecursionList;
      43             : 
      44         219 : class ScRecursionHelper
      45             : {
      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;
      54             :     bool                                bDoingRecursion;
      55             :     bool                                bInIterationReturn;
      56             :     bool                                bConverging;
      57             : 
      58             :     void Init();
      59             :     void ResetIteration();
      60             : 
      61             : public:
      62             : 
      63             :     ScRecursionHelper();
      64       11831 :     sal_uInt16  GetRecursionCount() const       { return nRecursionCount; }
      65       11831 :     void    IncRecursionCount()             { ++nRecursionCount; }
      66       11831 :     void    DecRecursionCount()             { --nRecursionCount; }
      67             :     /// A pure recursion return, no iteration.
      68           0 :     bool    IsInRecursionReturn() const     { return bInRecursionReturn &&
      69           0 :         !bInIterationReturn; }
      70             :     void SetInRecursionReturn( bool b );
      71           0 :     bool    IsDoingRecursion() const        { return bDoingRecursion; }
      72           0 :     void    SetDoingRecursion( bool b )     { bDoingRecursion = b; }
      73             : 
      74             :     void Insert( ScFormulaCell* p, bool bOldRunning, const ScFormulaResult & rRes );
      75             : 
      76           0 :     bool    IsInIterationReturn() const     { return bInIterationReturn; }
      77             :     void SetInIterationReturn( bool b );
      78       11831 :     bool    IsDoingIteration() const        { return nIteration > 0; }
      79       23662 :     sal_uInt16  GetIteration() const            { return nIteration; }
      80           0 :     bool &  GetConvergingReference()        { return bConverging; }
      81             :     void StartIteration();
      82             :     void ResumeIteration();
      83             :     void IncIteration();
      84             :     void EndIteration();
      85             : 
      86           0 :     ScFormulaRecursionList::iterator GetLastIterationStart() { return aLastIterationStart; }
      87             :     ScFormulaRecursionList::iterator GetIterationStart();
      88             :     ScFormulaRecursionList::iterator GetIterationEnd();
      89             :     /** Any return, recursion or iteration, iteration is always coupled with
      90             :         recursion. */
      91       35467 :     bool    IsInReturn() const              { return bInRecursionReturn; }
      92             :     const ScFormulaRecursionList&   GetList() const { return aRecursionFormulas; }
      93           0 :     ScFormulaRecursionList&         GetList()       { return aRecursionFormulas; }
      94           0 :     ScRecursionInIterationStack&    GetRecursionInIterationStack()  { return aRecursionInIterationStack; }
      95             : 
      96             :     void Clear();
      97             : };
      98             : 
      99             : #endif // INCLUDED_SC_INC_RECURSIONHELPER_HXX
     100             : 
     101             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11