1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _DOCFLD_HXX 28 #define _DOCFLD_HXX 29 30 #include <calc.hxx> // fuer SwHash 31 32 class SwTxtFld; 33 class SwIndex; 34 class SwNodeIndex; 35 class SwCntntNode; 36 class SwCntntFrm; 37 class SwSectionNode; 38 class SwSection; 39 class SwTxtTOXMark; 40 class SwTableBox; 41 class SwTxtINetFmt; 42 class SwFlyFrmFmt; 43 class SwDoc; 44 class SwNode; 45 struct SwPosition; 46 47 // Update an den Expression Feldern 48 class _SetGetExpFld 49 { 50 sal_uLong nNode; 51 xub_StrLen nCntnt; 52 union { 53 const SwTxtFld* pTxtFld; 54 const SwSection* pSection; 55 const SwPosition* pPos; 56 const SwTxtTOXMark* pTxtTOX; 57 const SwTableBox* pTBox; 58 const SwTxtINetFmt* pTxtINet; 59 const SwFlyFrmFmt* pFlyFmt; 60 } CNTNT; 61 enum _SetGetExpFldType 62 { 63 TEXTFIELD, TEXTTOXMARK, SECTIONNODE, CRSRPOS, TABLEBOX, 64 TEXTINET, FLYFRAME 65 } eSetGetExpFldType; 66 67 public: 68 _SetGetExpFld( const SwNodeIndex& rNdIdx, const SwTxtFld* pFld = 0, 69 const SwIndex* pIdx = 0 ); 70 71 _SetGetExpFld( const SwNodeIndex& rNdIdx, const SwTxtINetFmt& rINet, 72 const SwIndex* pIdx = 0 ); 73 74 _SetGetExpFld( const SwSectionNode& rSectNode, 75 const SwPosition* pPos = 0 ); 76 77 _SetGetExpFld( const SwTableBox& rTableBox, 78 const SwPosition* pPos = 0 ); 79 80 _SetGetExpFld( const SwNodeIndex& rNdIdx, const SwTxtTOXMark& rTOX, 81 const SwIndex* pIdx ); 82 83 _SetGetExpFld( const SwPosition& rPos ); 84 85 _SetGetExpFld( const SwFlyFrmFmt& rFlyFmt, const SwPosition* pPos = 0 ); 86 87 sal_Bool operator==( const _SetGetExpFld& rFld ) const 88 { return nNode == rFld.nNode && nCntnt == rFld.nCntnt && 89 ( !CNTNT.pTxtFld || !rFld.CNTNT.pTxtFld || 90 CNTNT.pTxtFld == rFld.CNTNT.pTxtFld ); } 91 sal_Bool operator<( const _SetGetExpFld& rFld ) const; 92 93 const SwTxtFld* GetFld() const 94 { return TEXTFIELD == eSetGetExpFldType ? CNTNT.pTxtFld : 0; } 95 const SwTxtTOXMark* GetTOX() const 96 { return TEXTTOXMARK == eSetGetExpFldType ? CNTNT.pTxtTOX : 0; } 97 const SwSection* GetSection() const 98 { return SECTIONNODE == eSetGetExpFldType ? CNTNT.pSection : 0; } 99 const SwTableBox* GetTableBox() const 100 { return TABLEBOX == eSetGetExpFldType ? CNTNT.pTBox : 0; } 101 const SwTxtINetFmt* GetINetFmt() const 102 { return TEXTINET == eSetGetExpFldType ? CNTNT.pTxtINet : 0; } 103 const SwFlyFrmFmt* GetFlyFmt() const 104 { return FLYFRAME == eSetGetExpFldType ? CNTNT.pFlyFmt : 0; } 105 106 sal_uLong GetNode() const { return nNode; } 107 xub_StrLen GetCntnt() const { return nCntnt; } 108 const void* GetPointer() const { return CNTNT.pTxtFld; } 109 110 void GetPos( SwPosition& rPos ) const; 111 void GetPosOfContent( SwPosition& rPos ) const; 112 113 const SwNode* GetNodeFromCntnt() const; 114 xub_StrLen GetCntPosFromCntnt() const; 115 116 void SetBodyPos( const SwCntntFrm& rFrm ); 117 }; 118 119 typedef _SetGetExpFld* _SetGetExpFldPtr; 120 SV_DECL_PTRARR_SORT_DEL( _SetGetExpFlds, _SetGetExpFldPtr, 0, 10 ) 121 122 123 // Struktur zum Speichern der Strings aus SetExp-String-Feldern 124 struct _HashStr : public SwHash 125 { 126 String aSetStr; 127 _HashStr( const String& rName, const String& rText, _HashStr* = 0 ); 128 }; 129 130 struct SwCalcFldType : public SwHash 131 { 132 const SwFieldType* pFldType; 133 134 SwCalcFldType( const String& rStr, const SwFieldType* pFldTyp ) 135 : SwHash( rStr ), pFldType( pFldTyp ) 136 {} 137 }; 138 139 // Suche nach dem String, der unter dem Namen in der HashTabelle abgelegt 140 // wurde 141 void LookString( SwHash** ppTbl, sal_uInt16 nSize, const String& rName, 142 String& rRet, sal_uInt16* pPos = 0 ); 143 144 145 // -------- 146 147 const int GETFLD_ALL = 3; // veroderte Flags !! 148 const int GETFLD_CALC = 1; 149 const int GETFLD_EXPAND = 2; 150 151 class SwDocUpdtFld 152 { 153 _SetGetExpFlds* pFldSortLst; // akt. Field-Liste zum Calculieren 154 SwCalcFldType* aFldTypeTable[ TBLSZ ]; 155 156 // noch eine weitere Optimierung - wird z.Z. nicht angesprochen! 157 long nFldUpdtPos; // ab dieser Position mit Update starten 158 SwCntntNode* pCNode; // der TxtNode zur UpdatePos. 159 160 sal_uLong nNodes; // sollte die NodesAnzahl unterschiedlich sein 161 sal_uInt8 nFldLstGetMode; 162 163 sal_Bool bInUpdateFlds : 1; // zur Zeit laeuft ein UpdateFlds, 164 sal_Bool bFldsDirty : 1; // irgendwelche Felder sind ungueltig 165 166 void _MakeFldList( SwDoc& pDoc, int eGetMode ); 167 void GetBodyNode( const SwTxtFld& , sal_uInt16 nFldWhich ); 168 void GetBodyNode( const SwSectionNode&); 169 public: 170 SwDocUpdtFld(); 171 ~SwDocUpdtFld(); 172 173 const _SetGetExpFlds* GetSortLst() const { return pFldSortLst; } 174 175 void MakeFldList( SwDoc& rDoc, int bAll, int eGetMode ); 176 177 void InsDelFldInFldLst( sal_Bool bIns, const SwTxtFld& rFld ); 178 179 void InsertFldType( const SwFieldType& rType ); 180 void RemoveFldType( const SwFieldType& rType ); 181 182 sal_Bool IsInUpdateFlds() const { return bInUpdateFlds; } 183 void SetInUpdateFlds( sal_Bool b ) { bInUpdateFlds = b; } 184 185 sal_Bool IsFieldsDirty() const { return bFldsDirty; } 186 void SetFieldsDirty( sal_Bool b ) { bFldsDirty = b; } 187 188 SwHash** GetFldTypeTable() const { return (SwHash**)aFldTypeTable; } 189 }; 190 191 192 #endif // _DOCFLD_HXX 193 194