xref: /aoo42x/main/sw/source/core/inc/docfld.hxx (revision 1d2dbeb0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _DOCFLD_HXX
24 #define _DOCFLD_HXX
25 
26 #include <calc.hxx>			// fuer SwHash
27 
28 class SwTxtFld;
29 class SwIndex;
30 class SwNodeIndex;
31 class SwCntntNode;
32 class SwCntntFrm;
33 class SwSectionNode;
34 class SwSection;
35 class SwTxtTOXMark;
36 class SwTableBox;
37 class SwTxtINetFmt;
38 class SwFlyFrmFmt;
39 class SwDoc;
40 class SwNode;
41 struct SwPosition;
42 
43 // Update an den Expression Feldern
44 class _SetGetExpFld
45 {
46 	sal_uLong nNode;
47 	xub_StrLen nCntnt;
48 	union {
49 		const SwTxtFld* pTxtFld;
50 		const SwSection* pSection;
51 		const SwPosition* pPos;
52 		const SwTxtTOXMark* pTxtTOX;
53 		const SwTableBox* pTBox;
54 		const SwTxtINetFmt* pTxtINet;
55 		const SwFlyFrmFmt* pFlyFmt;
56 	} CNTNT;
57 	enum _SetGetExpFldType
58 		{
59 			TEXTFIELD, TEXTTOXMARK, SECTIONNODE, CRSRPOS, TABLEBOX,
60 			TEXTINET, FLYFRAME
61 		} eSetGetExpFldType;
62 
63 public:
64 	_SetGetExpFld( const SwNodeIndex& rNdIdx, const SwTxtFld* pFld = 0,
65 					const SwIndex* pIdx = 0 );
66 
67 	_SetGetExpFld( const SwNodeIndex& rNdIdx, const SwTxtINetFmt& rINet,
68 					const SwIndex* pIdx = 0 );
69 
70 	_SetGetExpFld( const SwSectionNode& rSectNode,
71 					const SwPosition* pPos = 0  );
72 
73 	_SetGetExpFld( const SwTableBox& rTableBox,
74 					const SwPosition* pPos = 0  );
75 
76 	_SetGetExpFld( const SwNodeIndex& rNdIdx, const SwTxtTOXMark& rTOX,
77 					const SwIndex* pIdx );
78 
79 	_SetGetExpFld( const SwPosition& rPos );
80 
81 	_SetGetExpFld( const SwFlyFrmFmt& rFlyFmt, const SwPosition* pPos = 0 );
82 
83 	sal_Bool operator==( const _SetGetExpFld& rFld ) const
84 	{	return nNode == rFld.nNode && nCntnt == rFld.nCntnt &&
85 				( !CNTNT.pTxtFld || !rFld.CNTNT.pTxtFld ||
86 					CNTNT.pTxtFld == rFld.CNTNT.pTxtFld ); }
87 	sal_Bool operator<( const _SetGetExpFld& rFld ) const;
88 
89 	const SwTxtFld* GetFld() const
90 		{ return TEXTFIELD == eSetGetExpFldType ? CNTNT.pTxtFld : 0; }
91 	const SwTxtTOXMark* GetTOX() const
92 		{ return TEXTTOXMARK == eSetGetExpFldType ? CNTNT.pTxtTOX : 0; }
93 	const SwSection* GetSection() const
94 		{ return SECTIONNODE == eSetGetExpFldType ? CNTNT.pSection : 0; }
95 	const SwTableBox* GetTableBox() const
96 		{ return TABLEBOX == eSetGetExpFldType ? CNTNT.pTBox : 0; }
97 	const SwTxtINetFmt* GetINetFmt() const
98 		{ return TEXTINET == eSetGetExpFldType ? CNTNT.pTxtINet : 0; }
99 	const SwFlyFrmFmt* GetFlyFmt() const
100 		{ return FLYFRAME == eSetGetExpFldType ? CNTNT.pFlyFmt : 0; }
101 
102 	sal_uLong GetNode() const { return nNode; }
103 	xub_StrLen GetCntnt() const { return nCntnt; }
104 	const void* GetPointer() const { return CNTNT.pTxtFld; }
105 
106 	void GetPos( SwPosition& rPos ) const;
107 	void GetPosOfContent( SwPosition& rPos ) const;
108 
109 	const SwNode* GetNodeFromCntnt() const;
110 	xub_StrLen GetCntPosFromCntnt() const;
111 
112 	void SetBodyPos( const SwCntntFrm& rFrm );
113 };
114 
115 typedef _SetGetExpFld* _SetGetExpFldPtr;
116 SV_DECL_PTRARR_SORT_DEL( _SetGetExpFlds, _SetGetExpFldPtr, 0, 10 )
117 
118 
119 // Struktur zum Speichern der Strings aus SetExp-String-Feldern
120 struct _HashStr : public SwHash
121 {
122 	String aSetStr;
123 	_HashStr( const String& rName, const String& rText, _HashStr* = 0 );
124 };
125 
126 struct SwCalcFldType : public SwHash
127 {
128 	const SwFieldType* pFldType;
129 
130 	SwCalcFldType( const String& rStr, const SwFieldType* pFldTyp )
131 		: SwHash( rStr ), pFldType( pFldTyp )
132 	{}
133 };
134 
135 // Suche nach dem String, der unter dem Namen in der HashTabelle abgelegt
136 // wurde
137 void LookString( SwHash** ppTbl, sal_uInt16 nSize, const String& rName,
138 					String& rRet, sal_uInt16* pPos = 0 );
139 
140 
141 // --------
142 
143 const int GETFLD_ALL		= 3;		// veroderte Flags !!
144 const int GETFLD_CALC		= 1;
145 const int GETFLD_EXPAND		= 2;
146 
147 class SwDocUpdtFld
148 {
149 	_SetGetExpFlds* pFldSortLst;	// akt. Field-Liste zum Calculieren
150 	SwCalcFldType*  aFldTypeTable[ TBLSZ ];
151 
152 // noch eine weitere Optimierung - wird z.Z. nicht angesprochen!
153 	long nFldUpdtPos;				// ab dieser Position mit Update starten
154 	SwCntntNode* pCNode;			// der TxtNode zur UpdatePos.
155 
156 	sal_uLong nNodes;					// sollte die NodesAnzahl unterschiedlich sein
157 	sal_uInt8 nFldLstGetMode;
158 
159 	sal_Bool bInUpdateFlds : 1;			// zur Zeit laeuft ein UpdateFlds,
160 	sal_Bool bFldsDirty : 1;			// irgendwelche Felder sind ungueltig
161 
162 	void _MakeFldList( SwDoc& pDoc, int eGetMode );
163 	void GetBodyNode( const SwTxtFld& , sal_uInt16 nFldWhich );
164 	void GetBodyNode( const SwSectionNode&);
165 public:
166 	SwDocUpdtFld();
167 	~SwDocUpdtFld();
168 
169 	const _SetGetExpFlds* GetSortLst() const { return pFldSortLst; }
170 
171     void MakeFldList( SwDoc& rDoc, int bAll, int eGetMode );
172 
173 	void InsDelFldInFldLst( sal_Bool bIns, const SwTxtFld& rFld );
174 
175 	void InsertFldType( const SwFieldType& rType );
176 	void RemoveFldType( const SwFieldType& rType );
177 
178 	sal_Bool IsInUpdateFlds() const			{ return bInUpdateFlds; }
179 	void SetInUpdateFlds( sal_Bool b ) 		{ bInUpdateFlds = b; }
180 
181 	sal_Bool IsFieldsDirty() const			{ return bFldsDirty; }
182 	void SetFieldsDirty( sal_Bool b ) 		{ bFldsDirty = b; }
183 
184 	SwHash**	GetFldTypeTable() const { return (SwHash**)aFldTypeTable; }
185 };
186 
187 
188 #endif	// _DOCFLD_HXX
189 
190