LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/inc - docfld.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 14 27 51.9 %
Date: 2012-12-17 Functions: 12 21 57.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 _DOCFLD_HXX
      21             : #define _DOCFLD_HXX
      22             : 
      23             : #include <calc.hxx>
      24             : #include <o3tl/sorted_vector.hxx>
      25             : 
      26             : class SwTxtFld;
      27             : class SwIndex;
      28             : class SwNodeIndex;
      29             : class SwCntntFrm;
      30             : class SwSectionNode;
      31             : class SwSection;
      32             : class SwTxtTOXMark;
      33             : class SwTableBox;
      34             : class SwTxtINetFmt;
      35             : class SwFlyFrmFmt;
      36             : class SwDoc;
      37             : class SwNode;
      38             : struct SwPosition;
      39             : 
      40             : // Update expression fields
      41             : class _SetGetExpFld
      42             : {
      43             :     sal_uLong nNode;
      44             :     xub_StrLen nCntnt;
      45             :     union {
      46             :         const SwTxtFld* pTxtFld;
      47             :         const SwSection* pSection;
      48             :         const SwPosition* pPos;
      49             :         const SwTxtTOXMark* pTxtTOX;
      50             :         const SwTableBox* pTBox;
      51             :         const SwTxtINetFmt* pTxtINet;
      52             :         const SwFlyFrmFmt* pFlyFmt;
      53             :     } CNTNT;
      54             :     enum _SetGetExpFldType
      55             :         {
      56             :             TEXTFIELD, TEXTTOXMARK, SECTIONNODE, CRSRPOS, TABLEBOX,
      57             :             TEXTINET, FLYFRAME
      58             :         } eSetGetExpFldType;
      59             : 
      60             : public:
      61             :     _SetGetExpFld( const SwNodeIndex& rNdIdx, const SwTxtFld* pFld = 0,
      62             :                     const SwIndex* pIdx = 0 );
      63             : 
      64             :     _SetGetExpFld( const SwNodeIndex& rNdIdx, const SwTxtINetFmt& rINet,
      65             :                     const SwIndex* pIdx = 0 );
      66             : 
      67             :     _SetGetExpFld( const SwSectionNode& rSectNode,
      68             :                     const SwPosition* pPos = 0  );
      69             : 
      70             :     _SetGetExpFld( const SwTableBox& rTableBox,
      71             :                     const SwPosition* pPos = 0  );
      72             : 
      73             :     _SetGetExpFld( const SwNodeIndex& rNdIdx, const SwTxtTOXMark& rTOX,
      74             :                     const SwIndex* pIdx );
      75             : 
      76             :     _SetGetExpFld( const SwPosition& rPos );
      77             : 
      78             :     _SetGetExpFld( const SwFlyFrmFmt& rFlyFmt, const SwPosition* pPos = 0 );
      79             : 
      80           0 :     bool operator==( const _SetGetExpFld& rFld ) const
      81             :         {   return nNode == rFld.nNode && nCntnt == rFld.nCntnt &&
      82           0 :                 ( !CNTNT.pTxtFld || !rFld.CNTNT.pTxtFld ||
      83           0 :                     CNTNT.pTxtFld == rFld.CNTNT.pTxtFld ); }
      84             :     bool operator<( const _SetGetExpFld& rFld ) const;
      85             : 
      86           0 :     const SwTxtFld* GetFld() const
      87           0 :         { return TEXTFIELD == eSetGetExpFldType ? CNTNT.pTxtFld : 0; }
      88             :     const SwTxtTOXMark* GetTOX() const
      89             :         { return TEXTTOXMARK == eSetGetExpFldType ? CNTNT.pTxtTOX : 0; }
      90           4 :     const SwSection* GetSection() const
      91           4 :         { return SECTIONNODE == eSetGetExpFldType ? CNTNT.pSection : 0; }
      92             :     const SwTableBox* GetTableBox() const
      93             :         { return TABLEBOX == eSetGetExpFldType ? CNTNT.pTBox : 0; }
      94           0 :     const SwTxtINetFmt* GetINetFmt() const
      95           0 :         { return TEXTINET == eSetGetExpFldType ? CNTNT.pTxtINet : 0; }
      96           0 :     const SwFlyFrmFmt* GetFlyFmt() const
      97           0 :         { return FLYFRAME == eSetGetExpFldType ? CNTNT.pFlyFmt : 0; }
      98             : 
      99           0 :     sal_uLong GetNode() const { return nNode; }
     100           0 :     xub_StrLen GetCntnt() const { return nCntnt; }
     101           0 :     const void* GetPointer() const { return CNTNT.pTxtFld; }
     102             : 
     103             :     void GetPos( SwPosition& rPos ) const;
     104             :     void GetPosOfContent( SwPosition& rPos ) const;
     105             : 
     106             :     const SwNode* GetNodeFromCntnt() const;
     107             :     xub_StrLen GetCntPosFromCntnt() const;
     108             : 
     109             :     void SetBodyPos( const SwCntntFrm& rFrm );
     110             : };
     111             : 
     112          30 : class _SetGetExpFlds : public o3tl::sorted_vector<_SetGetExpFld*, o3tl::less_ptr_to<_SetGetExpFld> >
     113             : {
     114             : public:
     115          20 :     ~_SetGetExpFlds() { DeleteAndDestroyAll(); }
     116             : };
     117             : 
     118             : // struct for saving strings from the SetExp's string fields
     119           4 : struct _HashStr : public SwHash
     120             : {
     121             :     String aSetStr;
     122             :     _HashStr( const String& rName, const String& rText, _HashStr* = 0 );
     123             : };
     124             : 
     125           0 : struct SwCalcFldType : public SwHash
     126             : {
     127             :     const SwFieldType* pFldType;
     128             : 
     129          18 :     SwCalcFldType( const String& rStr, const SwFieldType* pFldTyp )
     130          18 :         : SwHash( rStr ), pFldType( pFldTyp )
     131          18 :     {}
     132             : };
     133             : 
     134             : // search for the string that was saved under rName in the hash table
     135             : void LookString( SwHash** ppTbl, sal_uInt16 nSize, const String& rName,
     136             :                     String& rRet, sal_uInt16* pPos = 0 );
     137             : 
     138             : const int GETFLD_ALL        = 3;        // combine flags via OR
     139             : const int GETFLD_CALC       = 1;
     140             : const int GETFLD_EXPAND     = 2;
     141             : 
     142             : class SwDocUpdtFld
     143             : {
     144             :     _SetGetExpFlds* pFldSortLst;    // current field list for calculation
     145             :     SwCalcFldType*  aFldTypeTable[ TBLSZ ];
     146             : 
     147             :     sal_uLong nNodes;               // if the node count is different
     148             :     sal_uInt8 nFldLstGetMode;
     149             : 
     150             :     bool bInUpdateFlds : 1;     // currently there is an UpdateFlds
     151             :     bool bFldsDirty : 1;        // some fields are invalid
     152             : 
     153             :     void _MakeFldList( SwDoc& pDoc, int eGetMode );
     154             :     void GetBodyNode( const SwTxtFld& , sal_uInt16 nFldWhich );
     155             :     void GetBodyNode( const SwSectionNode&);
     156             : 
     157             : public:
     158             :     SwDocUpdtFld();
     159             :     ~SwDocUpdtFld();
     160             : 
     161          42 :     const _SetGetExpFlds* GetSortLst() const { return pFldSortLst; }
     162             : 
     163             :     void MakeFldList( SwDoc& rDoc, int bAll, int eGetMode );
     164             : 
     165             :     void InsDelFldInFldLst( bool bIns, const SwTxtFld& rFld );
     166             : 
     167             :     void InsertFldType( const SwFieldType& rType );
     168             :     void RemoveFldType( const SwFieldType& rType );
     169             : 
     170          38 :     bool IsInUpdateFlds() const         { return bInUpdateFlds; }
     171          76 :     void SetInUpdateFlds( bool b )      { bInUpdateFlds = b; }
     172             : 
     173        7561 :     bool IsFieldsDirty() const          { return bFldsDirty; }
     174         287 :     void SetFieldsDirty( bool b )       { bFldsDirty = b; }
     175             : 
     176          22 :     SwHash** GetFldTypeTable() const { return (SwHash**)aFldTypeTable; }
     177             : };
     178             : 
     179             : #endif
     180             : 
     181             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10