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

Generated by: LCOV version 1.10