LCOV - code coverage report
Current view: top level - sw/source/core/inc - docfld.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 23 28 82.1 %
Date: 2015-06-13 12:38:46 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 <IDocumentTimerAccess.hxx>
      26             : #include <o3tl/sorted_vector.hxx>
      27             : 
      28             : class SwTextField;
      29             : class SwIndex;
      30             : class SwNodeIndex;
      31             : class SwContentFrm;
      32             : class SwSectionNode;
      33             : class SwSection;
      34             : class SwTextTOXMark;
      35             : class SwTableBox;
      36             : class SwTextINetFormat;
      37             : class SwFlyFrameFormat;
      38             : class SwDoc;
      39             : class SwNode;
      40             : struct SwPosition;
      41             : 
      42             : // Update expression fields
      43             : class _SetGetExpField
      44             : {
      45             :     sal_uLong nNode;
      46             :     sal_Int32 nContent;
      47             :     union {
      48             :         const SwTextField* pTextField;
      49             :         const SwSection* pSection;
      50             :         const SwPosition* pPos;
      51             :         const SwTextTOXMark* pTextTOX;
      52             :         const SwTableBox* pTBox;
      53             :         const SwTextINetFormat* pTextINet;
      54             :         const SwFlyFrameFormat* pFlyFormat;
      55             :     } CNTNT;
      56             :     enum _SetGetExpFieldType
      57             :         {
      58             :             TEXTFIELD, TEXTTOXMARK, SECTIONNODE, CRSRPOS, TABLEBOX,
      59             :             TEXTINET, FLYFRAME
      60             :         } eSetGetExpFieldType;
      61             : 
      62             : public:
      63             :     _SetGetExpField( const SwNodeIndex& rNdIdx, const SwTextField* pField = 0,
      64             :                     const SwIndex* pIdx = 0 );
      65             : 
      66             :     _SetGetExpField( const SwNodeIndex& rNdIdx, const SwTextINetFormat& rINet,
      67             :                     const SwIndex* pIdx = 0 );
      68             : 
      69             :     _SetGetExpField( const SwSectionNode& rSectNode,
      70             :                     const SwPosition* pPos = 0  );
      71             : 
      72             :     _SetGetExpField( const SwTableBox& rTableBox,
      73             :                     const SwPosition* pPos = 0  );
      74             : 
      75             :     _SetGetExpField( const SwNodeIndex& rNdIdx, const SwTextTOXMark& rTOX,
      76             :                     const SwIndex* pIdx );
      77             : 
      78             :     _SetGetExpField( const SwPosition& rPos );
      79             : 
      80             :     _SetGetExpField( const SwFlyFrameFormat& rFlyFormat, const SwPosition* pPos = 0 );
      81             : 
      82             :     bool operator==( const _SetGetExpField& rField ) const;
      83             :     bool operator<( const _SetGetExpField& rField ) const;
      84             : 
      85         132 :     const SwTextField* GetTextField() const
      86         132 :         { return TEXTFIELD == eSetGetExpFieldType ? CNTNT.pTextField : 0; }
      87             :     const SwTextTOXMark* GetTOX() const
      88             :         { return TEXTTOXMARK == eSetGetExpFieldType ? CNTNT.pTextTOX : 0; }
      89         272 :     const SwSection* GetSection() const
      90         272 :         { return SECTIONNODE == eSetGetExpFieldType ? CNTNT.pSection : 0; }
      91             :     const SwTableBox* GetTableBox() const
      92             :         { return TABLEBOX == eSetGetExpFieldType ? CNTNT.pTBox : 0; }
      93           0 :     const SwTextINetFormat* GetINetFormat() const
      94           0 :         { return TEXTINET == eSetGetExpFieldType ? CNTNT.pTextINet : 0; }
      95           0 :     const SwFlyFrameFormat* GetFlyFormat() const
      96           0 :         { return FLYFRAME == eSetGetExpFieldType ? CNTNT.pFlyFormat : 0; }
      97             : 
      98           4 :     sal_uLong GetNode() const { return nNode; }
      99           0 :     sal_Int32 GetContent() const { return nContent; }
     100          40 :     const void* GetPointer() const { return CNTNT.pTextField; }
     101             : 
     102             :     void GetPosOfContent( SwPosition& rPos ) const;
     103             : 
     104             :     const SwNode* GetNodeFromContent() const;
     105             :     sal_Int32 GetCntPosFromContent() const;
     106             : 
     107             :     void SetBodyPos( const SwContentFrm& rFrm );
     108             : };
     109             : 
     110         406 : class _SetGetExpFields : public o3tl::sorted_vector<_SetGetExpField*, o3tl::less_ptr_to<_SetGetExpField> >
     111             : {
     112             : public:
     113         405 :     ~_SetGetExpFields() { DeleteAndDestroyAll(); }
     114             : };
     115             : 
     116             : // struct for saving strings from the SetExp's string fields
     117         238 : struct _HashStr : public SwHash
     118             : {
     119             :     OUString aSetStr;
     120             :     _HashStr( const OUString& rName, const OUString& rText, _HashStr* = 0 );
     121             : };
     122             : 
     123         112 : struct SwCalcFieldType : public SwHash
     124             : {
     125             :     const SwFieldType* pFieldType;
     126             : 
     127          56 :     SwCalcFieldType( const OUString& rStr, const SwFieldType* pFieldTyp )
     128          56 :         : SwHash( rStr ), pFieldType( pFieldTyp )
     129          56 :     {}
     130             : };
     131             : 
     132             : // search for the string that was saved under rName in the hash table
     133             : OUString LookString( SwHash** ppTable, 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 SwDocUpdateField
     141             : {
     142             :     _SetGetExpFields* pFieldSortLst;    // current field list for calculation
     143             :     SwCalcFieldType*  aFieldTypeTable[ TBLSZ ];
     144             : 
     145             :     sal_uLong nNodes;               // if the node count is different
     146             :     sal_uInt8 nFieldLstGetMode;
     147             :     SwDoc* pDocument;
     148             : 
     149             :     bool bInUpdateFields : 1;     // currently there is an UpdateFields
     150             :     bool bFieldsDirty : 1;        // some fields are invalid
     151             : 
     152             :     void _MakeFieldList( SwDoc& pDoc, int eGetMode );
     153             :     void GetBodyNode( const SwTextField& , sal_uInt16 nFieldWhich );
     154             :     void GetBodyNode( const SwSectionNode&);
     155             : 
     156             : public:
     157             :     SwDocUpdateField(SwDoc* pDocument);
     158             :     ~SwDocUpdateField();
     159             : 
     160         972 :     const _SetGetExpFields* GetSortLst() const { return pFieldSortLst; }
     161             : 
     162             :     void MakeFieldList( SwDoc& rDoc, bool bAll, int eGetMode );
     163             : 
     164             :     void InsDelFieldInFieldLst( bool bIns, const SwTextField& rField );
     165             : 
     166             :     void InsertFieldType( const SwFieldType& rType );
     167             :     void RemoveFieldType( const SwFieldType& rType );
     168             : 
     169         492 :     bool IsInUpdateFields() const         { return bInUpdateFields; }
     170         984 :     void SetInUpdateFields( bool b )      { bInUpdateFields = b; }
     171             : 
     172       17284 :     bool IsFieldsDirty() const          { return bFieldsDirty; }
     173       13948 :     void SetFieldsDirty( bool b )
     174             :     {
     175       13948 :         bFieldsDirty = b;
     176             : 
     177       13948 :         if (b)
     178             :         {
     179        4056 :             pDocument->getIDocumentTimerAccess().StartBackgroundJobs();
     180             :         }
     181       13948 :     }
     182             : 
     183          67 :     SwHash* const * GetFieldTypeTable() const { return reinterpret_cast<SwHash* const *>(aFieldTypeTable); }
     184             : };
     185             : 
     186             : #endif
     187             : 
     188             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11