LCOV - code coverage report
Current view: top level - sw/inc - cellfml.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 7 22 31.8 %
Date: 2015-06-13 12:38:46 Functions: 3 13 23.1 %
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 SwTableFormulaUpdate;
      32             : class SwDoc;
      33             : 
      34             : class SwTableCalcPara
      35             : {
      36             :     const SwTableBox* pLastTableBox;
      37             :     sal_uInt16 nStackCnt, nMaxSize;
      38             : 
      39             : public:
      40             :     SwTableSortBoxes *pBoxStk;  ///< stack for recognizing recursion
      41             :     SwCalc& rCalc;              ///< current Calculator
      42             :     const SwTable* pTable;        ///< current table
      43             : 
      44             :     SwTableCalcPara( SwCalc& rCalculator, const SwTable& rTable );
      45             :     ~SwTableCalcPara();
      46             : 
      47             :     bool CalcWithStackOverflow();
      48           0 :     bool IsStackOverflow() const        { return nMaxSize == nStackCnt; }
      49           0 :     bool IncStackCnt()                  { return nMaxSize == ++nStackCnt; }
      50           0 :     void DecStackCnt()                  { if( nStackCnt ) --nStackCnt; }
      51           0 :     void SetLastTableBox( const SwTableBox* pBox )    { pLastTableBox = 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 _GetFormulaBoxes( 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             :     static void GetBoxes( const SwTableBox& rStt, const SwTableBox& rEnd,
      79             :                     SwSelBoxes& rBoxes );
      80             :     OUString ScanString( FnScanFormula fnFormula, const SwTable& rTable,
      81             :                         void* = 0 ) const;
      82             : 
      83             :     static const SwTable* FindTable( SwDoc& rDoc, const OUString& rNm );
      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             :     // !!! every derived class must override this !!!
      96             :     virtual const SwNode* GetNodeOfFormula() const = 0;
      97             : 
      98             :     SwTableFormula( const OUString& rFormula );
      99             : 
     100           0 :     OUString MakeFormula( SwTableCalcPara& rCalcPara ) const
     101             :     {
     102             :         return ScanString( &SwTableFormula::_MakeFormula,
     103           0 :                             *rCalcPara.pTable, &rCalcPara );
     104             :     }
     105             : 
     106             :     static sal_uInt16 GetLnPosInTable( const SwTable& rTable, const SwTableBox* pBox );
     107             : 
     108             : public:
     109             : 
     110         168 :     SwTableFormula( const SwTableFormula& rCpy )    { *this = rCpy; }
     111             :     virtual ~SwTableFormula();
     112         168 :     SwTableFormula& operator=( const SwTableFormula& rCpy )
     113             :     {
     114         168 :         m_sFormula = rCpy.m_sFormula;
     115         168 :         m_eNmType = rCpy.m_eNmType;
     116         168 :         m_bValidValue = rCpy.m_bValidValue;
     117         168 :         return *this;
     118             :     }
     119             : 
     120             :     /// create from the internal formula (for CORE) the external formula (for UI)
     121             :     void PtrToBoxNm( const SwTable* pTable );
     122             :     /// create from the external formula the internal
     123             :     void BoxNmToPtr( const SwTable* pTable );
     124             :     /// create from the external/internal formula the relative formula
     125             :     void ToRelBoxNm( const SwTable* pTable );
     126             :     /// gets called before/after merging/splitting of tables
     127             :     void ToSplitMergeBoxNm( SwTableFormulaUpdate& rTableUpd );
     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         169 :     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& rTable, 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.11