xref: /AOO41X/main/sw/inc/fmtcol.hxx (revision 808c4840145b66ebc65ba9c0f5bc9b4b53af9eab)
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:
SwFmtColl(SwAttrPool & rPool,const sal_Char * pFmtName,const sal_uInt16 * pWhichRanges,SwFmtColl * pDerFrom,sal_uInt16 nFmtWhich)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 
SwFmtColl(SwAttrPool & rPool,const String & rFmtName,const sal_uInt16 * pWhichRanges,SwFmtColl * pDerFrom,sal_uInt16 nFmtWhich)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 
SwTxtFmtColl(SwAttrPool & rPool,const sal_Char * pFmtCollName,SwTxtFmtColl * pDerFrom=0,sal_uInt16 nFmtWh=RES_TXTFMTCOLL)72     SwTxtFmtColl(
73         SwAttrPool& rPool,
74         const sal_Char* pFmtCollName,
75         SwTxtFmtColl* pDerFrom = 0,
76         sal_uInt16 nFmtWh = RES_TXTFMTCOLL )
77         : SwFmtColl( rPool, pFmtCollName, aTxtFmtCollSetRange
78         , pDerFrom, nFmtWh )
79         , mbStayAssignedToListLevelOfOutlineStyle( false )
80         , mbAssignedToOutlineStyle( false )
81     {
82         pNextTxtFmtColl = this;
83     }
84 
SwTxtFmtColl(SwAttrPool & rPool,const String & rFmtCollName,SwTxtFmtColl * pDerFrom=0,sal_uInt16 nFmtWh=RES_TXTFMTCOLL)85     SwTxtFmtColl(
86         SwAttrPool& rPool,
87         const String &rFmtCollName,
88         SwTxtFmtColl* pDerFrom = 0,
89         sal_uInt16 nFmtWh = RES_TXTFMTCOLL )
90         : SwFmtColl( rPool, rFmtCollName, aTxtFmtCollSetRange
91         , pDerFrom, nFmtWh )
92         , mbStayAssignedToListLevelOfOutlineStyle( false )
93         , mbAssignedToOutlineStyle( false )
94     {
95         pNextTxtFmtColl = this;
96     }
97 
98     // zum "abfischen" von UL-/LR-/FontHeight Aenderungen
99    virtual void Modify( const SfxPoolItem*, const SfxPoolItem* );
100 
101 public:
102 
103     TYPEINFO();     //Bereits in Basisklasse Client drin.
104 
105     inline void SetNextTxtFmtColl(SwTxtFmtColl& rNext);
GetNextTxtFmtColl() const106     SwTxtFmtColl& GetNextTxtFmtColl() const { return *pNextTxtFmtColl; }
107 
108     sal_Bool IsAtDocNodeSet() const;
109 
110     void SetAttrOutlineLevel( int );
111     int GetAttrOutlineLevel() const;
112 
113     // Return the list level of the Outline Style - the List Style for the outline numbering -
114     // to which the Paragraph Style is assigned.
115     int GetAssignedOutlineStyleLevel() const;
116 
IsAssignedToListLevelOfOutlineStyle() const117     inline bool IsAssignedToListLevelOfOutlineStyle() const
118     {
119         return mbAssignedToOutlineStyle;
120     }
121 
122     // If a Paragraph Style is assigned to list level N of the Outline Style,
123     // then its outline level - AttrOutlineLevel - is set to N+1
124     void AssignToListLevelOfOutlineStyle(const int nAssignedListLevel);
125 
126     void DeleteAssignmentToListLevelOfOutlineStyle( const bool bResetOutlineLevel = true );
127 
128     // override to recognize changes on the <SwNumRuleItem> and register/unregister
129     // the paragragh style at the corresponding <SwNumRule> instance
130     virtual sal_Bool SetFmtAttr( const SfxPoolItem& rAttr );
131     virtual sal_Bool SetFmtAttr( const SfxItemSet& rSet );
132     virtual sal_Bool ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 );
133 
134     // override <ResetAllFmtAttr()> to stay assigned to list level of outline style
135     virtual sal_uInt16 ResetAllFmtAttr();
136 
StayAssignedToListLevelOfOutlineStyle() const137     inline bool StayAssignedToListLevelOfOutlineStyle() const
138     {
139         return mbStayAssignedToListLevelOfOutlineStyle;
140     }
141     // <--
142 
143     // --> OD 2008-02-13 #newlistleveattrs#
144     bool AreListLevelIndentsApplicable() const;
145     // <--
146 
147 /*----------------- JP 09.08.94 17:36 -------------------
148  wird die Funktionalitaet von Zeichenvorlagen an Absatzvorlagen
149  ueberhaupt benoetigt ??
150 
151  Wenn, ja dann muessen im TextNode und hier in der TxtCollection ein 2.
152  Attset fuer die Char-Attribute angelegt werden; damit die Vererbung
153  und der Zugriff auf die gesetzen Attribute richtig funktioniert!!
154 
155     virtual sal_Bool SetDerivedFrom( SwFmtColl* pDerFrom = 0 );
156 
157     inline SwCharFmt* GetCharFmt() const;
158     inline sal_Bool IsCharFmtSet() const;
159     void SetCharFmt(SwCharFmt *);
160     void ResetCharFmt();
161 inline sal_Bool SwTxtFmtColl::IsCharFmtSet() const
162 {
163     return aCharDepend.GetRegisteredIn() ? sal_True : sal_False;
164 }
165 inline SwCharFmt* SwTxtFmtColl::GetCharFmt() const
166 {
167     return (SwCharFmt*)aCharDepend.GetRegisteredIn();
168 }
169 --------------------------------------------------*/
170 };
171 
172 typedef SwTxtFmtColl* SwTxtFmtCollPtr;
173 SV_DECL_PTRARR(SwTxtFmtColls,SwTxtFmtCollPtr,2,4)
174 
175 
176 class SwGrfFmtColl: public SwFmtColl
177 {
178     friend class SwDoc;
179 protected:
SwGrfFmtColl(SwAttrPool & rPool,const sal_Char * pFmtCollName,SwGrfFmtColl * pDerFrom=0)180     SwGrfFmtColl( SwAttrPool& rPool, const sal_Char* pFmtCollName,
181                     SwGrfFmtColl* pDerFrom = 0 )
182         : SwFmtColl( rPool, pFmtCollName, aGrfFmtCollSetRange,
183                     pDerFrom, RES_GRFFMTCOLL )
184     {}
185 
SwGrfFmtColl(SwAttrPool & rPool,const String & rFmtCollName,SwGrfFmtColl * pDerFrom=0)186     SwGrfFmtColl( SwAttrPool& rPool, const String &rFmtCollName,
187                     SwGrfFmtColl* pDerFrom = 0 )
188         : SwFmtColl( rPool, rFmtCollName, aGrfFmtCollSetRange,
189                     pDerFrom, RES_GRFFMTCOLL )
190     {}
191 
192 public:
193     TYPEINFO();     //Bereits in Basisklasse Client drin.
194 };
195 
196 typedef SwGrfFmtColl* SwGrfFmtCollPtr;
197 SV_DECL_PTRARR(SwGrfFmtColls,SwGrfFmtCollPtr,2,4)
198 
199 
200 
201 //FEATURE::CONDCOLL
202 // --------- Bedingte Vorlagen -------------------------------
203 
204 enum Master_CollConditions
205 {
206     PARA_IN_LIST        = 0x0001,
207     PARA_IN_OUTLINE     = 0x0002,
208     PARA_IN_FRAME       = 0x0004,
209     PARA_IN_TABLEHEAD   = 0x0008,
210     PARA_IN_TABLEBODY   = 0x0010,
211     PARA_IN_SECTION     = 0x0020,
212     PARA_IN_FOOTENOTE   = 0x0040,
213     PARA_IN_FOOTER      = 0x0080,
214     PARA_IN_HEADER      = 0x0100,
215     PARA_IN_ENDNOTE     = 0x0200,
216     // ...
217     USRFLD_EXPRESSION   = (int)0x8000
218 };
219 
220 
221 class SW_DLLPUBLIC SwCollCondition : public SwClient
222 {
223     sal_uLong nCondition;
224     union
225     {
226         sal_uLong nSubCondition;
227         String* pFldExpression;
228     } aSubCondition;
229 
230 public:
231     TYPEINFO();     //Bereits in Basisklasse Client drin.
232 
233 
234     SwCollCondition( SwTxtFmtColl* pColl, sal_uLong nMasterCond,
235                     sal_uLong nSubCond = 0 );
236     SwCollCondition( SwTxtFmtColl* pColl, sal_uLong nMasterCond,
237                     const String& rSubExp );
238     virtual ~SwCollCondition();
239 
240     // @@@ public copy ctor, but no copy assignment?
241     SwCollCondition( const SwCollCondition& rCpy );
242 private:
243     // @@@ public copy ctor, but no copy assignment?
244     SwCollCondition & operator= (const SwCollCondition &);
245 public:
246 
247     int operator==( const SwCollCondition& rCmp ) const;
operator !=(const SwCollCondition & rCmp) const248     int operator!=( const SwCollCondition& rCmp ) const
249                             { return ! (*this == rCmp); }
250 
GetCondition() const251     sal_uLong GetCondition() const      { return nCondition; }
GetSubCondition() const252     sal_uLong GetSubCondition() const   { return aSubCondition.nSubCondition; }
GetFldExpression() const253     const String* GetFldExpression() const
254                                     { return aSubCondition.pFldExpression; }
255 
256     void SetCondition( sal_uLong nCond, sal_uLong nSubCond );
GetTxtFmtColl() const257     SwTxtFmtColl* GetTxtFmtColl() const     { return (SwTxtFmtColl*)GetRegisteredIn(); }
258     void RegisterToFormat( SwFmt& );
259 };
260 
261 
262 typedef SwCollCondition* SwCollConditionPtr;
263 SV_DECL_PTRARR_DEL( SwFmtCollConditions, SwCollConditionPtr, 0, 5 )
264 
265 class SW_DLLPUBLIC SwConditionTxtFmtColl : public SwTxtFmtColl
266 {
267     friend class SwDoc;
268 protected:
269     SwFmtCollConditions aCondColls;
270 
SwConditionTxtFmtColl(SwAttrPool & rPool,const sal_Char * pFmtCollName,SwTxtFmtColl * pDerFrom=0)271     SwConditionTxtFmtColl( SwAttrPool& rPool, const sal_Char* pFmtCollName,
272                             SwTxtFmtColl* pDerFrom = 0 )
273         : SwTxtFmtColl( rPool, pFmtCollName, pDerFrom, RES_CONDTXTFMTCOLL )
274     {}
SwConditionTxtFmtColl(SwAttrPool & rPool,const String & rFmtCollName,SwTxtFmtColl * pDerFrom=0)275     SwConditionTxtFmtColl( SwAttrPool& rPool, const String &rFmtCollName,
276                             SwTxtFmtColl* pDerFrom = 0 )
277         : SwTxtFmtColl( rPool, rFmtCollName, pDerFrom, RES_CONDTXTFMTCOLL )
278     {}
279 
280 public:
281     TYPEINFO();     //Bereits in Basisklasse Client drin.
282 
283     virtual ~SwConditionTxtFmtColl();
284 
285     const SwCollCondition* HasCondition( const SwCollCondition& rCond ) const;
GetCondColls() const286     const SwFmtCollConditions& GetCondColls() const     { return aCondColls; }
287     void InsertCondition( const SwCollCondition& rCond );
288     sal_Bool RemoveCondition( const SwCollCondition& rCond );
289 
290     void SetConditions( const SwFmtCollConditions& );
291 };
292 
293 //FEATURE::CONDCOLL
294 
295 // ------------- Inline Implementierungen --------------------
296 
SetNextTxtFmtColl(SwTxtFmtColl & rNext)297 inline void SwTxtFmtColl::SetNextTxtFmtColl( SwTxtFmtColl& rNext )
298 {
299     pNextTxtFmtColl = &rNext;
300 }
301 #endif
302 
303