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 : : #ifndef _FMTCOL_HXX
29 : : #define _FMTCOL_HXX
30 : :
31 : : #include "swdllapi.h"
32 : : #include <format.hxx>
33 : : #include <swtypes.hxx> // For MAXLEVEL.
34 : : #include <boost/ptr_container/ptr_vector.hpp>
35 : :
36 : : class SwDoc; // For friend.
37 : :
38 [ - + ]: 12895 : class SwFmtColl : public SwFmt
39 : : {
40 : : protected:
41 : 3098 : SwFmtColl( SwAttrPool& rPool, const sal_Char* pFmtName,
42 : : const sal_uInt16* pWhichRanges, SwFmtColl* pDerFrom,
43 : : sal_uInt16 nFmtWhich )
44 : 3098 : : SwFmt( rPool, pFmtName, pWhichRanges, pDerFrom, nFmtWhich )
45 : 3098 : { SetAuto( sal_False ); }
46 : :
47 : 10600 : SwFmtColl( SwAttrPool& rPool, const String &rFmtName,
48 : : const sal_uInt16* pWhichRanges, SwFmtColl* pDerFrom,
49 : : sal_uInt16 nFmtWhich )
50 : 10600 : : SwFmt( rPool, rFmtName, pWhichRanges, pDerFrom, nFmtWhich )
51 : 10600 : { SetAuto( sal_False ); }
52 : :
53 : : private:
54 : :
55 : : // For now don't copy and don't assign.
56 : : SwFmtColl(const SwFmtColl & );
57 : : const SwFmtColl &operator=(const SwFmtColl &);
58 : : };
59 : :
60 : : /// Represents the style of a paragraph.
61 [ - + ]: 21412 : class SW_DLLPUBLIC SwTxtFmtColl: public SwFmtColl
62 : : {
63 : : friend class SwDoc;
64 : :
65 : : SwTxtFmtColl(const SwTxtFmtColl & rRef);
66 : :
67 : : bool mbStayAssignedToListLevelOfOutlineStyle;
68 : :
69 : : protected:
70 : :
71 : : bool mbAssignedToOutlineStyle;
72 : :
73 : : SwTxtFmtColl *pNextTxtFmtColl;
74 : :
75 : 1549 : SwTxtFmtColl( SwAttrPool& rPool, const sal_Char* pFmtCollName,
76 : : SwTxtFmtColl* pDerFrom = 0,
77 : : sal_uInt16 nFmtWh = RES_TXTFMTCOLL )
78 : : : SwFmtColl( rPool, pFmtCollName, aTxtFmtCollSetRange,
79 : : pDerFrom, nFmtWh ),
80 : : mbStayAssignedToListLevelOfOutlineStyle( false ),
81 : :
82 : 1549 : mbAssignedToOutlineStyle(false)
83 : 1549 : { pNextTxtFmtColl = this; }
84 : :
85 : 10600 : SwTxtFmtColl( SwAttrPool& rPool, const String &rFmtCollName,
86 : : SwTxtFmtColl* pDerFrom = 0,
87 : : sal_uInt16 nFmtWh = RES_TXTFMTCOLL )
88 : : : SwFmtColl( rPool, rFmtCollName, aTxtFmtCollSetRange,
89 : : pDerFrom, nFmtWh ),
90 : :
91 : : mbStayAssignedToListLevelOfOutlineStyle( false ),
92 : :
93 : 10600 : mbAssignedToOutlineStyle(false)
94 : 10600 : { pNextTxtFmtColl = this; }
95 : :
96 : : // To get UL- / LR- / FontHeight-changes.
97 : : virtual void Modify( const SfxPoolItem*, const SfxPoolItem* );
98 : :
99 : : public:
100 : :
101 : : TYPEINFO(); // Already in base class Client.
102 : :
103 : : inline void SetNextTxtFmtColl(SwTxtFmtColl& rNext);
104 : 55232 : SwTxtFmtColl& GetNextTxtFmtColl() const { return *pNextTxtFmtColl; }
105 : :
106 : : sal_Bool IsAtDocNodeSet() const;
107 : :
108 : : void SetAttrOutlineLevel( int );
109 : : int GetAttrOutlineLevel() const;
110 : : int GetAssignedOutlineStyleLevel() const;
111 : 315107 : inline bool IsAssignedToListLevelOfOutlineStyle() const
112 : : {
113 : 315107 : return mbAssignedToOutlineStyle;
114 : : }
115 : : void AssignToListLevelOfOutlineStyle(const int nAssignedListLevel);
116 : : void DeleteAssignmentToListLevelOfOutlineStyle();
117 : :
118 : : // Override to recognize changes on the <SwNumRuleItem> and register/unregister
119 : : // the paragragh style at the corresponding <SwNumRule> instance.
120 : : virtual sal_Bool SetFmtAttr( const SfxPoolItem& rAttr );
121 : : virtual sal_Bool SetFmtAttr( const SfxItemSet& rSet );
122 : : virtual sal_Bool ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 );
123 : :
124 : : // Override <ResetAllFmtAttr()> to stay assigned to list level of outline style.
125 : : virtual sal_uInt16 ResetAllFmtAttr();
126 : :
127 : 8584 : inline bool StayAssignedToListLevelOfOutlineStyle() const
128 : : {
129 : 8584 : return mbStayAssignedToListLevelOfOutlineStyle;
130 : : }
131 : :
132 : : bool AreListLevelIndentsApplicable() const;
133 : :
134 : : /*
135 : : Is the functionality of character styles at paragraph styles needed?
136 : : If so, a second Attset for char-attributes has to be created
137 : : in TextNode and here in TxtCollection in order to make both
138 : : the inheritance of and the access to set attributes function correctly!
139 : :
140 : : virtual sal_Bool SetDerivedFrom( SwFmtColl* pDerFrom = 0 );
141 : :
142 : : inline SwCharFmt* GetCharFmt() const;
143 : : inline sal_Bool IsCharFmtSet() const;
144 : : void SetCharFmt(SwCharFmt *);
145 : : void ResetCharFmt();
146 : : inline sal_Bool SwTxtFmtColl::IsCharFmtSet() const
147 : : {
148 : : return aCharDepend.GetRegisteredIn() ? sal_True : sal_False;
149 : : }
150 : : inline SwCharFmt* SwTxtFmtColl::GetCharFmt() const
151 : : {
152 : : return (SwCharFmt*)aCharDepend.GetRegisteredIn();
153 : : }
154 : : */
155 : : };
156 : :
157 [ - + ]: 2916 : class SwGrfFmtColl: public SwFmtColl
158 : : {
159 : : friend class SwDoc;
160 : : protected:
161 : 1549 : SwGrfFmtColl( SwAttrPool& rPool, const sal_Char* pFmtCollName,
162 : : SwGrfFmtColl* pDerFrom = 0 )
163 : : : SwFmtColl( rPool, pFmtCollName, aGrfFmtCollSetRange,
164 : 1549 : pDerFrom, RES_GRFFMTCOLL )
165 : 1549 : {}
166 : :
167 : 0 : SwGrfFmtColl( SwAttrPool& rPool, const String &rFmtCollName,
168 : : SwGrfFmtColl* pDerFrom = 0 )
169 : : : SwFmtColl( rPool, rFmtCollName, aGrfFmtCollSetRange,
170 : 0 : pDerFrom, RES_GRFFMTCOLL )
171 : 0 : {}
172 : :
173 : : public:
174 : : TYPEINFO(); // Already in base class Client.
175 : : };
176 : :
177 : : // FEATURE::CONDCOLL
178 : : // Conditional styles.
179 : : enum Master_CollConditions
180 : : {
181 : : PARA_IN_LIST = 0x0001,
182 : : PARA_IN_OUTLINE = 0x0002,
183 : : PARA_IN_FRAME = 0x0004,
184 : : PARA_IN_TABLEHEAD = 0x0008,
185 : : PARA_IN_TABLEBODY = 0x0010,
186 : : PARA_IN_SECTION = 0x0020,
187 : : PARA_IN_FOOTENOTE = 0x0040,
188 : : PARA_IN_FOOTER = 0x0080,
189 : : PARA_IN_HEADER = 0x0100,
190 : : PARA_IN_ENDNOTE = 0x0200,
191 : : // ...
192 : : USRFLD_EXPRESSION = (int)0x8000
193 : : };
194 : :
195 : : class SW_DLLPUBLIC SwCollCondition : public SwClient
196 : : {
197 : : sal_uLong nCondition;
198 : : union
199 : : {
200 : : sal_uLong nSubCondition;
201 : : String* pFldExpression;
202 : : } aSubCondition;
203 : :
204 : : public:
205 : : TYPEINFO(); // Already in base class Client.
206 : :
207 : : SwCollCondition( SwTxtFmtColl* pColl, sal_uLong nMasterCond,
208 : : sal_uLong nSubCond = 0 );
209 : : SwCollCondition( SwTxtFmtColl* pColl, sal_uLong nMasterCond,
210 : : const String& rSubExp );
211 : : virtual ~SwCollCondition();
212 : :
213 : : // @@@ public copy ctor, but no copy assignment?
214 : : SwCollCondition( const SwCollCondition& rCpy );
215 : : private:
216 : : // @@@ public copy ctor, but no copy assignment?
217 : : SwCollCondition & operator= (const SwCollCondition &);
218 : : public:
219 : :
220 : : int operator==( const SwCollCondition& rCmp ) const;
221 : : int operator!=( const SwCollCondition& rCmp ) const
222 : : { return ! (*this == rCmp); }
223 : :
224 : 0 : sal_uLong GetCondition() const { return nCondition; }
225 : 0 : sal_uLong GetSubCondition() const { return aSubCondition.nSubCondition; }
226 : 0 : const String* GetFldExpression() const
227 : 0 : { return aSubCondition.pFldExpression; }
228 : :
229 : : void SetCondition( sal_uLong nCond, sal_uLong nSubCond );
230 : 0 : SwTxtFmtColl* GetTxtFmtColl() const { return (SwTxtFmtColl*)GetRegisteredIn(); }
231 : : void RegisterToFormat( SwFmt& );
232 : : };
233 : :
234 : 3015 : class SwFmtCollConditions : public boost::ptr_vector<SwCollCondition> {};
235 : :
236 : : class SW_DLLPUBLIC SwConditionTxtFmtColl : public SwTxtFmtColl
237 : : {
238 : : friend class SwDoc;
239 : : protected:
240 : : SwFmtCollConditions aCondColls;
241 : :
242 : : SwConditionTxtFmtColl( SwAttrPool& rPool, const sal_Char* pFmtCollName,
243 : : SwTxtFmtColl* pDerFrom = 0 )
244 : : : SwTxtFmtColl( rPool, pFmtCollName, pDerFrom, RES_CONDTXTFMTCOLL )
245 : : {}
246 : 1553 : SwConditionTxtFmtColl( SwAttrPool& rPool, const String &rFmtCollName,
247 : : SwTxtFmtColl* pDerFrom = 0 )
248 [ + - ]: 1553 : : SwTxtFmtColl( rPool, rFmtCollName, pDerFrom, RES_CONDTXTFMTCOLL )
249 : 1553 : {}
250 : :
251 : : public:
252 : : TYPEINFO(); // Already in base class Client.
253 : :
254 : : virtual ~SwConditionTxtFmtColl();
255 : :
256 : : const SwCollCondition* HasCondition( const SwCollCondition& rCond ) const;
257 : 84 : const SwFmtCollConditions& GetCondColls() const { return aCondColls; }
258 : : void InsertCondition( const SwCollCondition& rCond );
259 : : sal_Bool RemoveCondition( const SwCollCondition& rCond );
260 : :
261 : : void SetConditions( const SwFmtCollConditions& );
262 : : };
263 : :
264 : : // FEATURE::CONDCOLL
265 : : // Inline implementations.
266 : 2080 : inline void SwTxtFmtColl::SetNextTxtFmtColl( SwTxtFmtColl& rNext )
267 : : {
268 : 2080 : pNextTxtFmtColl = &rNext;
269 : 2080 : }
270 : : #endif
271 : :
272 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|