xref: /aoo42x/main/sw/source/core/inc/docfld.hxx (revision 69a74367)
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 	sal_Bool operator<( const _SetGetExpFld& rFld ) const;
85 
GetTxtFld() const86 	const SwTxtFld* GetTxtFld() const
87 		{ return TEXTFIELD == eSetGetExpFldType ? CNTNT.pTxtFld : 0; }
GetTOX() const88 	const SwTxtTOXMark* GetTOX() const
89 		{ return TEXTTOXMARK == eSetGetExpFldType ? CNTNT.pTxtTOX : 0; }
GetSection() const90 	const SwSection* GetSection() const
91 		{ return SECTIONNODE == eSetGetExpFldType ? CNTNT.pSection : 0; }
GetTableBox() const92 	const SwTableBox* GetTableBox() const
93 		{ return TABLEBOX == eSetGetExpFldType ? CNTNT.pTBox : 0; }
GetINetFmt() const94 	const SwTxtINetFmt* GetINetFmt() const
95 		{ return TEXTINET == eSetGetExpFldType ? CNTNT.pTxtINet : 0; }
GetFlyFmt() const96 	const SwFlyFrmFmt* GetFlyFmt() const
97 		{ return FLYFRAME == eSetGetExpFldType ? CNTNT.pFlyFmt : 0; }
98 
GetNode() const99 	sal_uLong GetNode() const { return nNode; }
GetCntnt() const100 	xub_StrLen GetCntnt() const { return nCntnt; }
GetPointer() const101 	const void* GetPointer() const { return CNTNT.pTxtFld; }
102 
103 	void GetPos( SwPosition& rPos ) const;
104 	void GetPosOfContent( SwPosition& rPos ) const;
105 
106 	const SwNode* GetNodeFromCntnt() const;
107 	xub_StrLen GetCntPosFromCntnt() const;
108 
109 	void SetBodyPos( const SwCntntFrm& rFrm );
110 };
111 
112 typedef _SetGetExpFld* _SetGetExpFldPtr;
113 SV_DECL_PTRARR_SORT_DEL( _SetGetExpFlds, _SetGetExpFldPtr, 0, 10 )
114 
115 
116 // Struktur zum Speichern der Strings aus SetExp-String-Feldern
117 struct _HashStr : public SwHash
118 {
119 	String aSetStr;
120 	_HashStr( const String& rName, const String& rText, _HashStr* = 0 );
121 };
122 
123 struct SwCalcFldType : public SwHash
124 {
125 	const SwFieldType* pFldType;
126 
SwCalcFldTypeSwCalcFldType127 	SwCalcFldType( const String& rStr, const SwFieldType* pFldTyp )
128 		: SwHash( rStr ), pFldType( pFldTyp )
129 	{}
130 };
131 
132 // Suche nach dem String, der unter dem Namen in der HashTabelle abgelegt
133 // wurde
134 void LookString( SwHash** ppTbl, sal_uInt16 nSize, const String& rName,
135 					String& rRet, sal_uInt16* pPos = 0 );
136 
137 
138 // --------
139 
140 const int GETFLD_ALL		= 3;		// veroderte Flags !!
141 const int GETFLD_CALC		= 1;
142 const int GETFLD_EXPAND		= 2;
143 
144 class SwDocUpdtFld
145 {
146 	_SetGetExpFlds* pFldSortLst;	// akt. Field-Liste zum Calculieren
147 	SwCalcFldType*  aFldTypeTable[ TBLSZ ];
148 
149 // noch eine weitere Optimierung - wird z.Z. nicht angesprochen!
150 	long nFldUpdtPos;				// ab dieser Position mit Update starten
151 	SwCntntNode* pCNode;			// der TxtNode zur UpdatePos.
152 
153 	sal_uLong nNodes;					// sollte die NodesAnzahl unterschiedlich sein
154 	sal_uInt8 nFldLstGetMode;
155 
156 	sal_Bool bInUpdateFlds : 1;			// zur Zeit laeuft ein UpdateFlds,
157 	sal_Bool bFldsDirty : 1;			// irgendwelche Felder sind ungueltig
158 
159 	void _MakeFldList( SwDoc& pDoc, int eGetMode );
160 	void GetBodyNode( const SwTxtFld& , sal_uInt16 nFldWhich );
161 	void GetBodyNode( const SwSectionNode&);
162 public:
163 	SwDocUpdtFld();
164 	~SwDocUpdtFld();
165 
GetSortLst() const166 	const _SetGetExpFlds* GetSortLst() const { return pFldSortLst; }
167 
168     void MakeFldList( SwDoc& rDoc, int bAll, int eGetMode );
169 
170 	void InsDelFldInFldLst( sal_Bool bIns, const SwTxtFld& rFld );
171 
172 	void InsertFldType( const SwFieldType& rType );
173 	void RemoveFldType( const SwFieldType& rType );
174 
IsInUpdateFlds() const175 	sal_Bool IsInUpdateFlds() const			{ return bInUpdateFlds; }
SetInUpdateFlds(sal_Bool b)176 	void SetInUpdateFlds( sal_Bool b ) 		{ bInUpdateFlds = b; }
177 
IsFieldsDirty() const178 	sal_Bool IsFieldsDirty() const			{ return bFldsDirty; }
SetFieldsDirty(sal_Bool b)179 	void SetFieldsDirty( sal_Bool b ) 		{ bFldsDirty = b; }
180 
GetFldTypeTable() const181 	SwHash**	GetFldTypeTable() const { return (SwHash**)aFldTypeTable; }
182 };
183 
184 
185 #endif	// _DOCFLD_HXX
186 
187