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

Generated by: LCOV version 1.10