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

Generated by: LCOV version 1.10