xref: /trunk/main/sw/inc/fmtcol.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 _FMTCOL_HXX
24 #define _FMTCOL_HXX
25 
26 #include <svl/svarray.hxx>
27 #include "swdllapi.h"
28 #include <format.hxx>
29 #include <swtypes.hxx>		// fuer MAXLEVEL
30 
31 class SwDoc;		// fuer friend
32 
33 class SwFmtColl : public SwFmt
34 {
35 protected:
36 	SwFmtColl( SwAttrPool& rPool, const sal_Char* pFmtName,
37 				const sal_uInt16* pWhichRanges, SwFmtColl* pDerFrom,
38 				sal_uInt16 nFmtWhich )
39 	  	: SwFmt( rPool, pFmtName, pWhichRanges, pDerFrom, nFmtWhich )
40 	{ SetAuto( sal_False ); }
41 
42 	SwFmtColl( SwAttrPool& rPool, const String &rFmtName,
43 				const sal_uInt16* pWhichRanges, SwFmtColl* pDerFrom,
44 				sal_uInt16 nFmtWhich )
45 	  	: SwFmt( rPool, rFmtName, pWhichRanges, pDerFrom, nFmtWhich )
46 	{ SetAuto( sal_False ); }
47 
48 
49 private:
50 	// erstmal wird nicht kopiert und nicht zugewiesen
51 	SwFmtColl(const SwFmtColl & );
52 	const SwFmtColl &operator=(const SwFmtColl &);
53 };
54 
55 
56 class SW_DLLPUBLIC SwTxtFmtColl: public SwFmtColl
57 {
58 	friend class SwDoc;
59 
60     SwTxtFmtColl(const SwTxtFmtColl & rRef);
61 
62     // --> OD 2007-01-24 #i73790#
63     bool mbStayAssignedToListLevelOfOutlineStyle;
64     // <--
65 
66 protected:
67 	//sal_uInt8 nOutlineLevel;		 //<-#outline level, removed by zhaojianwei
68 	bool mbAssignedToOutlineStyle;//<-#outline level added by zhaojianwei
69 
70 	SwTxtFmtColl *pNextTxtFmtColl;
71 
72 	SwTxtFmtColl( SwAttrPool& rPool, const sal_Char* pFmtCollName,
73 					SwTxtFmtColl* pDerFrom = 0,
74 					sal_uInt16 nFmtWh = RES_TXTFMTCOLL )
75 		: SwFmtColl( rPool, pFmtCollName, aTxtFmtCollSetRange,
76 						pDerFrom, nFmtWh ),
77           // --> OD 2007-01-24 #i73790#
78           mbStayAssignedToListLevelOfOutlineStyle( false ),
79           // <--
80           //nOutlineLevel( NO_NUMBERING )	//<-#outline level,removed by zhaojianwei
81 		  mbAssignedToOutlineStyle(false)	//<-#outline level,added by zhaojianwei
82     { pNextTxtFmtColl = this; }
83 
84 	SwTxtFmtColl( SwAttrPool& rPool, const String &rFmtCollName,
85 					SwTxtFmtColl* pDerFrom = 0,
86 					sal_uInt16 nFmtWh = RES_TXTFMTCOLL )
87 		: SwFmtColl( rPool, rFmtCollName, aTxtFmtCollSetRange,
88 						pDerFrom, nFmtWh ),
89           // --> OD 2007-01-24 #i73790#
90           mbStayAssignedToListLevelOfOutlineStyle( false ),
91           // <--
92           //nOutlineLevel( NO_NUMBERING )	//<-#outline level,removed by zhaojianwei
93 		  mbAssignedToOutlineStyle(false)	//<-#outline level,added by zhaojianwei
94     { pNextTxtFmtColl = this; }
95 
96 	// zum "abfischen" von UL-/LR-/FontHeight Aenderungen
97    virtual void Modify( const SfxPoolItem*, const SfxPoolItem* );
98 
99 public:
100 
101 	TYPEINFO();		//Bereits in Basisklasse Client drin.
102 
103 	inline void SetNextTxtFmtColl(SwTxtFmtColl& rNext);
104 	SwTxtFmtColl& GetNextTxtFmtColl() const { return *pNextTxtFmtColl; }
105 
106 	sal_Bool IsAtDocNodeSet() const;
107 
108     // --> OD 2006-11-22 #i71574#
109    //<-#outline level,zhaojianwei
110 	void SetAttrOutlineLevel( int );
111 	int  GetAttrOutlineLevel() const;
112 	int  GetAssignedOutlineStyleLevel() const;
113     inline bool IsAssignedToListLevelOfOutlineStyle() const
114     {
115         return mbAssignedToOutlineStyle;
116     }
117 	void AssignToListLevelOfOutlineStyle(const int nAssignedListLevel);
118     void DeleteAssignmentToListLevelOfOutlineStyle();
119 	//<-end
120     // <--
121 
122     // --> OD 2008-03-04 #refactorlists#
123     // override to recognize changes on the <SwNumRuleItem> and register/unregister
124     // the paragragh style at the corresponding <SwNumRule> instance
125     virtual sal_Bool SetFmtAttr( const SfxPoolItem& rAttr );
126     virtual sal_Bool SetFmtAttr( const SfxItemSet& rSet );
127     virtual sal_Bool ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 );
128     // <--
129 
130     // --> OD 2007-01-24 #i73790#
131     // override <ResetAllFmtAttr()> to stay assigned to list level of outline style
132     virtual sal_uInt16 ResetAllFmtAttr();
133 
134     inline bool StayAssignedToListLevelOfOutlineStyle() const
135     {
136         return mbStayAssignedToListLevelOfOutlineStyle;
137     }
138     // <--
139 
140     // --> OD 2008-02-13 #newlistleveattrs#
141     bool AreListLevelIndentsApplicable() const;
142     // <--
143 
144 /*----------------- JP 09.08.94 17:36 -------------------
145  wird die Funktionalitaet von Zeichenvorlagen an Absatzvorlagen
146  ueberhaupt benoetigt ??
147 
148  Wenn, ja dann muessen im TextNode und hier in der TxtCollection ein 2.
149  Attset fuer die Char-Attribute angelegt werden; damit die Vererbung
150  und der Zugriff auf die gesetzen Attribute richtig funktioniert!!
151 
152 	virtual sal_Bool SetDerivedFrom( SwFmtColl* pDerFrom = 0 );
153 
154 	inline SwCharFmt* GetCharFmt() const;
155 	inline sal_Bool IsCharFmtSet() const;
156 	void SetCharFmt(SwCharFmt *);
157 	void ResetCharFmt();
158 inline sal_Bool SwTxtFmtColl::IsCharFmtSet() const
159 {
160 	return aCharDepend.GetRegisteredIn() ? sal_True : sal_False;
161 }
162 inline SwCharFmt* SwTxtFmtColl::GetCharFmt() const
163 {
164 	return (SwCharFmt*)aCharDepend.GetRegisteredIn();
165 }
166 --------------------------------------------------*/
167 };
168 
169 typedef SwTxtFmtColl* SwTxtFmtCollPtr;
170 SV_DECL_PTRARR(SwTxtFmtColls,SwTxtFmtCollPtr,2,4)
171 
172 
173 class SwGrfFmtColl: public SwFmtColl
174 {
175 	friend class SwDoc;
176 protected:
177 	SwGrfFmtColl( SwAttrPool& rPool, const sal_Char* pFmtCollName,
178 					SwGrfFmtColl* pDerFrom = 0 )
179 		: SwFmtColl( rPool, pFmtCollName, aGrfFmtCollSetRange,
180 					pDerFrom, RES_GRFFMTCOLL )
181 	{}
182 
183 	SwGrfFmtColl( SwAttrPool& rPool, const String &rFmtCollName,
184 					SwGrfFmtColl* pDerFrom = 0 )
185 		: SwFmtColl( rPool, rFmtCollName, aGrfFmtCollSetRange,
186 					pDerFrom, RES_GRFFMTCOLL )
187 	{}
188 
189 public:
190 	TYPEINFO();		//Bereits in Basisklasse Client drin.
191 };
192 
193 typedef SwGrfFmtColl* SwGrfFmtCollPtr;
194 SV_DECL_PTRARR(SwGrfFmtColls,SwGrfFmtCollPtr,2,4)
195 
196 
197 
198 //FEATURE::CONDCOLL
199 // --------- Bedingte Vorlagen -------------------------------
200 
201 enum Master_CollConditions
202 {
203 	PARA_IN_LIST		= 0x0001,
204 	PARA_IN_OUTLINE		= 0x0002,
205 	PARA_IN_FRAME		= 0x0004,
206 	PARA_IN_TABLEHEAD	= 0x0008,
207 	PARA_IN_TABLEBODY	= 0x0010,
208 	PARA_IN_SECTION		= 0x0020,
209 	PARA_IN_FOOTENOTE 	= 0x0040,
210 	PARA_IN_FOOTER 		= 0x0080,
211 	PARA_IN_HEADER 		= 0x0100,
212 	PARA_IN_ENDNOTE 	= 0x0200,
213 	// ...
214 	USRFLD_EXPRESSION	= (int)0x8000
215 };
216 
217 
218 class SW_DLLPUBLIC SwCollCondition : public SwClient
219 {
220 	sal_uLong nCondition;
221 	union
222 	{
223 		sal_uLong nSubCondition;
224 		String* pFldExpression;
225 	} aSubCondition;
226 
227 public:
228 	TYPEINFO();		//Bereits in Basisklasse Client drin.
229 
230 
231 	SwCollCondition( SwTxtFmtColl* pColl, sal_uLong nMasterCond,
232 					sal_uLong nSubCond = 0 );
233 	SwCollCondition( SwTxtFmtColl* pColl, sal_uLong nMasterCond,
234 					const String& rSubExp );
235 	virtual ~SwCollCondition();
236 
237 	// @@@ public copy ctor, but no copy assignment?
238 	SwCollCondition( const SwCollCondition& rCpy );
239 private:
240 	// @@@ public copy ctor, but no copy assignment?
241 	SwCollCondition & operator= (const SwCollCondition &);
242 public:
243 
244 	int operator==( const SwCollCondition& rCmp ) const;
245 	int operator!=( const SwCollCondition& rCmp ) const
246 							{ return ! (*this == rCmp); }
247 
248 	sal_uLong GetCondition() const 		{ return nCondition; }
249 	sal_uLong GetSubCondition() const	{ return aSubCondition.nSubCondition; }
250 	const String* GetFldExpression() const
251 									{ return aSubCondition.pFldExpression; }
252 
253 	void SetCondition( sal_uLong nCond, sal_uLong nSubCond );
254 	SwTxtFmtColl* GetTxtFmtColl() const 	{ return (SwTxtFmtColl*)GetRegisteredIn(); }
255     void RegisterToFormat( SwFmt& );
256 };
257 
258 
259 typedef SwCollCondition* SwCollConditionPtr;
260 SV_DECL_PTRARR_DEL( SwFmtCollConditions, SwCollConditionPtr, 0, 5 )
261 
262 class SW_DLLPUBLIC SwConditionTxtFmtColl : public SwTxtFmtColl
263 {
264 	friend class SwDoc;
265 protected:
266 	SwFmtCollConditions aCondColls;
267 
268 	SwConditionTxtFmtColl( SwAttrPool& rPool, const sal_Char* pFmtCollName,
269 							SwTxtFmtColl* pDerFrom = 0 )
270 		: SwTxtFmtColl( rPool, pFmtCollName, pDerFrom, RES_CONDTXTFMTCOLL )
271 	{}
272 	SwConditionTxtFmtColl( SwAttrPool& rPool, const String &rFmtCollName,
273 							SwTxtFmtColl* pDerFrom = 0 )
274 		: SwTxtFmtColl( rPool, rFmtCollName, pDerFrom, RES_CONDTXTFMTCOLL )
275 	{}
276 
277 public:
278 	TYPEINFO();		//Bereits in Basisklasse Client drin.
279 
280 	virtual ~SwConditionTxtFmtColl();
281 
282 	const SwCollCondition* HasCondition( const SwCollCondition& rCond ) const;
283 	const SwFmtCollConditions& GetCondColls() const		{ return aCondColls; }
284 	void InsertCondition( const SwCollCondition& rCond );
285 	sal_Bool RemoveCondition( const SwCollCondition& rCond );
286 
287 	void SetConditions( const SwFmtCollConditions& );
288 };
289 
290 //FEATURE::CONDCOLL
291 
292 // ------------- Inline Implementierungen --------------------
293 
294 inline void SwTxtFmtColl::SetNextTxtFmtColl( SwTxtFmtColl& rNext )
295 {
296 	pNextTxtFmtColl = &rNext;
297 }
298 #endif
299 
300