LCOV - code coverage report
Current view: top level - sw/inc - cellfml.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 22 0.0 %
Date: 2014-04-14 Functions: 0 13 0.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             :  * 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_SW_INC_CELLFML_HXX
      21             : #define INCLUDED_SW_INC_CELLFML_HXX
      22             : 
      23             : #include <rtl/ustring.hxx>
      24             : 
      25             : class SwTable;
      26             : class SwNode;
      27             : class SwTableSortBoxes;
      28             : class SwSelBoxes;
      29             : class SwCalc;
      30             : class SwTableBox;
      31             : class SwTableFmlUpdate;
      32             : class SwDoc;
      33             : 
      34             : class SwTblCalcPara
      35             : {
      36             :     const SwTableBox* pLastTblBox;
      37             :     sal_uInt16 nStackCnt, nMaxSize;
      38             : 
      39             : public:
      40             :     SwTableSortBoxes *pBoxStk;  ///< stack for recognizing recursion
      41             :     SwCalc& rCalc;              ///< current Calculator
      42             :     const SwTable* pTbl;        ///< current table
      43             : 
      44             :     SwTblCalcPara( SwCalc& rCalculator, const SwTable& rTable );
      45             :     ~SwTblCalcPara();
      46             : 
      47             :     sal_Bool CalcWithStackOverflow();
      48           0 :     sal_Bool IsStackOverflow() const        { return nMaxSize == nStackCnt; }
      49           0 :     sal_Bool IncStackCnt()                  { return nMaxSize == ++nStackCnt; }
      50           0 :     void DecStackCnt()                  { if( nStackCnt ) --nStackCnt; }
      51           0 :     void SetLastTblBox( const SwTableBox* pBox )    { pLastTblBox = pBox; }
      52             : };
      53             : 
      54             : class SwTableFormula
      55             : {
      56             : typedef void (SwTableFormula:: *FnScanFormula)( const SwTable&, OUString&,
      57             :                                                 OUString&, OUString*, void* ) const;
      58             : 
      59             :     void BoxNmsToPtr( const SwTable&, OUString&, OUString&, OUString* = 0,
      60             :                         void* pPara = 0 ) const;
      61             :     void PtrToBoxNms( const SwTable&, OUString&, OUString&, OUString* = 0,
      62             :                         void* pPara = 0 ) const;
      63             :     void RelNmsToBoxNms( const SwTable&, OUString&, OUString&, OUString* = 0,
      64             :                         void* pPara = 0 ) const;
      65             :     void RelBoxNmsToPtr( const SwTable&, OUString&, OUString&, OUString* = 0,
      66             :                         void* pPara = 0 ) const;
      67             :     void BoxNmsToRelNm( const SwTable&, OUString&, OUString&, OUString* = 0,
      68             :                         void* pPara = 0 ) const;
      69             :     void _MakeFormula( const SwTable&, OUString&, OUString&, OUString* = 0,
      70             :                         void* pPara = 0 ) const;
      71             :     void _GetFmlBoxes( const SwTable&, OUString&, OUString&, OUString* = 0,
      72             :                         void* pPara = 0 ) const;
      73             :     void _HasValidBoxes( const SwTable&, OUString&, OUString&, OUString* = 0,
      74             :                         void* pPara = 0 ) const;
      75             :     void _SplitMergeBoxNm( const SwTable&, OUString&, OUString&, OUString* = 0,
      76             :                         void* pPara = 0 ) const;
      77             : 
      78             :     void GetBoxes( const SwTableBox& rStt, const SwTableBox& rEnd,
      79             :                     SwSelBoxes& rBoxes ) const;
      80             :     OUString ScanString( FnScanFormula fnFormula, const SwTable& rTbl,
      81             :                         void* = 0 ) const;
      82             : 
      83             :     const SwTable* FindTable( SwDoc& rDoc, const OUString& rNm ) const;
      84             : 
      85             : protected:
      86             :     enum NameType { EXTRNL_NAME, INTRNL_NAME, REL_NAME };
      87             : 
      88             :     OUString    m_sFormula;         ///< current formula
      89             :     NameType    m_eNmType;          ///< current display method
      90             :     bool        m_bValidValue;      ///< true: recalculate formula
      91             : 
      92             :     // find the node in which the formula is located
      93             :     //  TextFeld    -> TextNode,
      94             :     //  BoxAttribut -> BoxStartNode
      95             :     // !!! has to be overloaded by every derivation !!!
      96             :     virtual const SwNode* GetNodeOfFormula() const = 0;
      97             : 
      98             :     SwTableFormula( const OUString& rFormula );
      99             : 
     100           0 :     OUString MakeFormula( SwTblCalcPara& rCalcPara ) const
     101             :     {
     102             :         return ScanString( &SwTableFormula::_MakeFormula,
     103           0 :                             *rCalcPara.pTbl, &rCalcPara );
     104             :     }
     105             : 
     106             :     static sal_uInt16 GetLnPosInTbl( const SwTable& rTbl, const SwTableBox* pBox );
     107             : 
     108             : public:
     109             : 
     110           0 :     SwTableFormula( const SwTableFormula& rCpy )    { *this = rCpy; }
     111             :     virtual ~SwTableFormula();
     112           0 :     SwTableFormula& operator=( const SwTableFormula& rCpy )
     113             :     {
     114           0 :         m_sFormula = rCpy.m_sFormula;
     115           0 :         m_eNmType = rCpy.m_eNmType;
     116           0 :         m_bValidValue = rCpy.m_bValidValue;
     117           0 :         return *this;
     118             :     }
     119             : 
     120             :     /// create from the internal formula (for CORE) the external formula (for UI)
     121             :     void PtrToBoxNm( const SwTable* pTbl );
     122             :     /// create from the external formula the internal
     123             :     void BoxNmToPtr( const SwTable* pTbl );
     124             :     /// create from the external/internal formula the relative formula
     125             :     void ToRelBoxNm( const SwTable* pTbl );
     126             :     /// gets called before/after merging/splitting of tables
     127             :     void ToSplitMergeBoxNm( SwTableFmlUpdate& rTblUpd );
     128             : 
     129           0 :     bool IsIntrnlName() const               { return m_eNmType == INTRNL_NAME; }
     130           0 :     NameType GetNameType() const            { return m_eNmType; }
     131             : 
     132           0 :     bool IsValid() const                    { return m_bValidValue; }
     133           0 :     void ChgValid( bool bNew )              { m_bValidValue = bNew; }
     134             : 
     135           0 :     OUString GetFormula() const             { return m_sFormula; }
     136           0 :     void SetFormula( const OUString& rNew )
     137             :     {
     138           0 :         m_sFormula = rNew;
     139           0 :         m_eNmType = EXTRNL_NAME;
     140           0 :         m_bValidValue = false;
     141           0 :     }
     142             : 
     143             :     void GetBoxesOfFormula(const SwTable& rTbl, SwSelBoxes& rBoxes);
     144             :     // are all boxes valid which this formula relies on?
     145             :     bool HasValidBoxes() const;
     146             : };
     147             : 
     148             : #endif
     149             : 
     150             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10