Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _DOCFLD_HXX
30 : : #define _DOCFLD_HXX
31 : :
32 : : #include <calc.hxx>
33 : : #include <o3tl/sorted_vector.hxx>
34 : :
35 : : class SwTxtFld;
36 : : class SwIndex;
37 : : class SwNodeIndex;
38 : : class SwCntntNode;
39 : : class SwCntntFrm;
40 : : class SwSectionNode;
41 : : class SwSection;
42 : : class SwTxtTOXMark;
43 : : class SwTableBox;
44 : : class SwTxtINetFmt;
45 : : class SwFlyFrmFmt;
46 : : class SwDoc;
47 : : class SwNode;
48 : : struct SwPosition;
49 : :
50 : : // Update expression fields
51 : : class _SetGetExpFld
52 : : {
53 : : sal_uLong nNode;
54 : : xub_StrLen nCntnt;
55 : : union {
56 : : const SwTxtFld* pTxtFld;
57 : : const SwSection* pSection;
58 : : const SwPosition* pPos;
59 : : const SwTxtTOXMark* pTxtTOX;
60 : : const SwTableBox* pTBox;
61 : : const SwTxtINetFmt* pTxtINet;
62 : : const SwFlyFrmFmt* pFlyFmt;
63 : : } CNTNT;
64 : : enum _SetGetExpFldType
65 : : {
66 : : TEXTFIELD, TEXTTOXMARK, SECTIONNODE, CRSRPOS, TABLEBOX,
67 : : TEXTINET, FLYFRAME
68 : : } eSetGetExpFldType;
69 : :
70 : : public:
71 : : _SetGetExpFld( const SwNodeIndex& rNdIdx, const SwTxtFld* pFld = 0,
72 : : const SwIndex* pIdx = 0 );
73 : :
74 : : _SetGetExpFld( const SwNodeIndex& rNdIdx, const SwTxtINetFmt& rINet,
75 : : const SwIndex* pIdx = 0 );
76 : :
77 : : _SetGetExpFld( const SwSectionNode& rSectNode,
78 : : const SwPosition* pPos = 0 );
79 : :
80 : : _SetGetExpFld( const SwTableBox& rTableBox,
81 : : const SwPosition* pPos = 0 );
82 : :
83 : : _SetGetExpFld( const SwNodeIndex& rNdIdx, const SwTxtTOXMark& rTOX,
84 : : const SwIndex* pIdx );
85 : :
86 : : _SetGetExpFld( const SwPosition& rPos );
87 : :
88 : : _SetGetExpFld( const SwFlyFrmFmt& rFlyFmt, const SwPosition* pPos = 0 );
89 : :
90 : 0 : bool operator==( const _SetGetExpFld& rFld ) const
91 : : { return nNode == rFld.nNode && nCntnt == rFld.nCntnt &&
92 : 0 : ( !CNTNT.pTxtFld || !rFld.CNTNT.pTxtFld ||
93 [ # # ][ # # ]: 0 : CNTNT.pTxtFld == rFld.CNTNT.pTxtFld ); }
[ # # ][ # # ]
[ # # ]
94 : : bool operator<( const _SetGetExpFld& rFld ) const;
95 : :
96 : 8 : const SwTxtFld* GetFld() const
97 [ - + ]: 8 : { return TEXTFIELD == eSetGetExpFldType ? CNTNT.pTxtFld : 0; }
98 : : const SwTxtTOXMark* GetTOX() const
99 : : { return TEXTTOXMARK == eSetGetExpFldType ? CNTNT.pTxtTOX : 0; }
100 : 18 : const SwSection* GetSection() const
101 [ + - ]: 18 : { return SECTIONNODE == eSetGetExpFldType ? CNTNT.pSection : 0; }
102 : : const SwTableBox* GetTableBox() const
103 : : { return TABLEBOX == eSetGetExpFldType ? CNTNT.pTBox : 0; }
104 : 0 : const SwTxtINetFmt* GetINetFmt() const
105 [ # # ]: 0 : { return TEXTINET == eSetGetExpFldType ? CNTNT.pTxtINet : 0; }
106 : 0 : const SwFlyFrmFmt* GetFlyFmt() const
107 [ # # ]: 0 : { return FLYFRAME == eSetGetExpFldType ? CNTNT.pFlyFmt : 0; }
108 : :
109 : 16 : sal_uLong GetNode() const { return nNode; }
110 : 8 : xub_StrLen GetCntnt() const { return nCntnt; }
111 : 0 : const void* GetPointer() const { return CNTNT.pTxtFld; }
112 : :
113 : : void GetPos( SwPosition& rPos ) const;
114 : : void GetPosOfContent( SwPosition& rPos ) const;
115 : :
116 : : const SwNode* GetNodeFromCntnt() const;
117 : : xub_StrLen GetCntPosFromCntnt() const;
118 : :
119 : : void SetBodyPos( const SwCntntFrm& rFrm );
120 : : };
121 : :
122 : 93 : class _SetGetExpFlds : public o3tl::sorted_vector<_SetGetExpFld*, o3tl::less_ptr_to<_SetGetExpFld> >
123 : : {
124 : : public:
125 [ + - ]: 91 : ~_SetGetExpFlds() { DeleteAndDestroyAll(); }
126 : : };
127 : :
128 : : // struct for saving strings from the SetExp's string fields
129 [ + - ][ - + ]: 6 : struct _HashStr : public SwHash
130 : : {
131 : : String aSetStr;
132 : : _HashStr( const String& rName, const String& rText, _HashStr* = 0 );
133 : : };
134 : :
135 [ - + ]: 72 : struct SwCalcFldType : public SwHash
136 : : {
137 : : const SwFieldType* pFldType;
138 : :
139 : 57 : SwCalcFldType( const String& rStr, const SwFieldType* pFldTyp )
140 : 57 : : SwHash( rStr ), pFldType( pFldTyp )
141 : 57 : {}
142 : : };
143 : :
144 : : // search for the string that was saved under rName in the hash table
145 : : void LookString( SwHash** ppTbl, sal_uInt16 nSize, const String& rName,
146 : : String& rRet, sal_uInt16* pPos = 0 );
147 : :
148 : : const int GETFLD_ALL = 3; // combine flags via OR
149 : : const int GETFLD_CALC = 1;
150 : : const int GETFLD_EXPAND = 2;
151 : :
152 : : class SwDocUpdtFld
153 : : {
154 : : _SetGetExpFlds* pFldSortLst; // current field list for calculation
155 : : SwCalcFldType* aFldTypeTable[ TBLSZ ];
156 : :
157 : : // another optimization - currently not used!
158 : : long nFldUpdtPos; // start update from this position
159 : : SwCntntNode* pCNode; // TxtNode at update position
160 : :
161 : : sal_uLong nNodes; // if the node count is different
162 : : sal_uInt8 nFldLstGetMode;
163 : :
164 : : sal_Bool bInUpdateFlds : 1; // currently there is an UpdateFlds
165 : : sal_Bool bFldsDirty : 1; // some fields are invalid
166 : :
167 : : void _MakeFldList( SwDoc& pDoc, int eGetMode );
168 : : void GetBodyNode( const SwTxtFld& , sal_uInt16 nFldWhich );
169 : : void GetBodyNode( const SwSectionNode&);
170 : :
171 : : public:
172 : : SwDocUpdtFld();
173 : : ~SwDocUpdtFld();
174 : :
175 : 179 : const _SetGetExpFlds* GetSortLst() const { return pFldSortLst; }
176 : :
177 : : void MakeFldList( SwDoc& rDoc, int bAll, int eGetMode );
178 : :
179 : : void InsDelFldInFldLst( sal_Bool bIns, const SwTxtFld& rFld );
180 : :
181 : : void InsertFldType( const SwFieldType& rType );
182 : : void RemoveFldType( const SwFieldType& rType );
183 : :
184 : 97 : sal_Bool IsInUpdateFlds() const { return bInUpdateFlds; }
185 : 194 : void SetInUpdateFlds( sal_Bool b ) { bInUpdateFlds = b; }
186 : :
187 : 15758 : sal_Bool IsFieldsDirty() const { return bFldsDirty; }
188 : 12297 : void SetFieldsDirty( sal_Bool b ) { bFldsDirty = b; }
189 : :
190 : 81 : SwHash** GetFldTypeTable() const { return (SwHash**)aFldTypeTable; }
191 : : };
192 : :
193 : : #endif
194 : :
195 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|