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

Generated by: LCOV version 1.10