bump product version to 4.1.6.2
[LibreOffice.git] / sw / inc / fmtcol.hxx
blob3ff4e2e8a8d1e511e4e392818513d3c5ccabf57d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _FMTCOL_HXX
20 #define _FMTCOL_HXX
22 #include "swdllapi.h"
23 #include <format.hxx>
24 #include <swtypes.hxx> // For MAXLEVEL.
25 #include <boost/ptr_container/ptr_vector.hpp>
27 class SwDoc; // For friend.
29 class SwFmtColl : public SwFmt
31 protected:
32 SwFmtColl( SwAttrPool& rPool, const sal_Char* pFmtName,
33 const sal_uInt16* pWhichRanges, SwFmtColl* pDerFrom,
34 sal_uInt16 nFmtWhich )
35 : SwFmt( rPool, pFmtName, pWhichRanges, pDerFrom, nFmtWhich )
36 { SetAuto( sal_False ); }
38 SwFmtColl( SwAttrPool& rPool, const String &rFmtName,
39 const sal_uInt16* pWhichRanges, SwFmtColl* pDerFrom,
40 sal_uInt16 nFmtWhich )
41 : SwFmt( rPool, rFmtName, pWhichRanges, pDerFrom, nFmtWhich )
42 { SetAuto( sal_False ); }
44 private:
46 /// For now don't copy and don't assign.
47 SwFmtColl(const SwFmtColl & );
48 const SwFmtColl &operator=(const SwFmtColl &);
51 /// Represents the style of a paragraph.
52 class SW_DLLPUBLIC SwTxtFmtColl: public SwFmtColl
54 friend class SwDoc;
56 SwTxtFmtColl(const SwTxtFmtColl & rRef);
58 bool mbStayAssignedToListLevelOfOutlineStyle;
60 protected:
62 bool mbAssignedToOutlineStyle;
64 SwTxtFmtColl *pNextTxtFmtColl;
66 SwTxtFmtColl( SwAttrPool& rPool, const sal_Char* pFmtCollName,
67 SwTxtFmtColl* pDerFrom = 0,
68 sal_uInt16 nFmtWh = RES_TXTFMTCOLL )
69 : SwFmtColl( rPool, pFmtCollName, aTxtFmtCollSetRange,
70 pDerFrom, nFmtWh ),
71 mbStayAssignedToListLevelOfOutlineStyle( false ),
73 mbAssignedToOutlineStyle(false)
74 { pNextTxtFmtColl = this; }
76 SwTxtFmtColl( SwAttrPool& rPool, const String &rFmtCollName,
77 SwTxtFmtColl* pDerFrom = 0,
78 sal_uInt16 nFmtWh = RES_TXTFMTCOLL )
79 : SwFmtColl( rPool, rFmtCollName, aTxtFmtCollSetRange,
80 pDerFrom, nFmtWh ),
82 mbStayAssignedToListLevelOfOutlineStyle( false ),
84 mbAssignedToOutlineStyle(false)
85 { pNextTxtFmtColl = this; }
87 /// To get UL- / LR- / FontHeight-changes.
88 virtual void Modify( const SfxPoolItem*, const SfxPoolItem* );
90 public:
92 TYPEINFO(); ///< Already in base class Client.
94 inline void SetNextTxtFmtColl(SwTxtFmtColl& rNext);
95 SwTxtFmtColl& GetNextTxtFmtColl() const { return *pNextTxtFmtColl; }
97 bool IsAtDocNodeSet() const;
99 void SetAttrOutlineLevel( int );
100 int GetAttrOutlineLevel() const;
101 int GetAssignedOutlineStyleLevel() const;
102 inline bool IsAssignedToListLevelOfOutlineStyle() const
104 return mbAssignedToOutlineStyle;
106 void AssignToListLevelOfOutlineStyle(const int nAssignedListLevel);
107 void DeleteAssignmentToListLevelOfOutlineStyle();
109 /** Override to recognize changes on the <SwNumRuleItem> and register/unregister
110 the paragragh style at the corresponding <SwNumRule> instance. */
111 virtual bool SetFmtAttr( const SfxPoolItem& rAttr );
112 virtual bool SetFmtAttr( const SfxItemSet& rSet );
113 virtual bool ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 );
115 /// Override <ResetAllFmtAttr()> to stay assigned to list level of outline style.
116 virtual sal_uInt16 ResetAllFmtAttr();
118 inline bool StayAssignedToListLevelOfOutlineStyle() const
120 return mbStayAssignedToListLevelOfOutlineStyle;
123 bool AreListLevelIndentsApplicable() const;
126 Is the functionality of character styles at paragraph styles needed?
127 If so, a second Attset for char-attributes has to be created
128 in TextNode and here in TxtCollection in order to make both
129 the inheritance of and the access to set attributes function correctly!
131 virtual sal_Bool SetDerivedFrom( SwFmtColl* pDerFrom = 0 );
133 inline SwCharFmt* GetCharFmt() const;
134 inline sal_Bool IsCharFmtSet() const;
135 void SetCharFmt(SwCharFmt *);
136 void ResetCharFmt();
137 inline sal_Bool SwTxtFmtColl::IsCharFmtSet() const
139 return aCharDepend.GetRegisteredIn() ? sal_True : sal_False;
141 inline SwCharFmt* SwTxtFmtColl::GetCharFmt() const
143 return (SwCharFmt*)aCharDepend.GetRegisteredIn();
148 class SwGrfFmtColl: public SwFmtColl
150 friend class SwDoc;
151 protected:
152 SwGrfFmtColl( SwAttrPool& rPool, const sal_Char* pFmtCollName,
153 SwGrfFmtColl* pDerFrom = 0 )
154 : SwFmtColl( rPool, pFmtCollName, aGrfFmtCollSetRange,
155 pDerFrom, RES_GRFFMTCOLL )
158 SwGrfFmtColl( SwAttrPool& rPool, const String &rFmtCollName,
159 SwGrfFmtColl* pDerFrom = 0 )
160 : SwFmtColl( rPool, rFmtCollName, aGrfFmtCollSetRange,
161 pDerFrom, RES_GRFFMTCOLL )
164 public:
165 TYPEINFO(); ///< Already in base class Client.
168 // FEATURE::CONDCOLL
169 /// Conditional styles.
170 enum Master_CollConditions
172 PARA_IN_LIST = 0x0001,
173 PARA_IN_OUTLINE = 0x0002,
174 PARA_IN_FRAME = 0x0004,
175 PARA_IN_TABLEHEAD = 0x0008,
176 PARA_IN_TABLEBODY = 0x0010,
177 PARA_IN_SECTION = 0x0020,
178 PARA_IN_FOOTENOTE = 0x0040,
179 PARA_IN_FOOTER = 0x0080,
180 PARA_IN_HEADER = 0x0100,
181 PARA_IN_ENDNOTE = 0x0200,
182 // ...
183 USRFLD_EXPRESSION = (int)0x8000
186 class SW_DLLPUBLIC SwCollCondition : public SwClient
188 sal_uLong nCondition;
189 union
191 sal_uLong nSubCondition;
192 String* pFldExpression;
193 } aSubCondition;
195 public:
196 TYPEINFO(); ///< Already in base class Client.
198 SwCollCondition( SwTxtFmtColl* pColl, sal_uLong nMasterCond,
199 sal_uLong nSubCond = 0 );
200 SwCollCondition( SwTxtFmtColl* pColl, sal_uLong nMasterCond,
201 const String& rSubExp );
202 virtual ~SwCollCondition();
204 /// @@@ public copy ctor, but no copy assignment?
205 SwCollCondition( const SwCollCondition& rCpy );
206 private:
207 /// @@@ public copy ctor, but no copy assignment?
208 SwCollCondition & operator= (const SwCollCondition &);
209 public:
211 int operator==( const SwCollCondition& rCmp ) const;
212 int operator!=( const SwCollCondition& rCmp ) const
213 { return ! (*this == rCmp); }
215 sal_uLong GetCondition() const { return nCondition; }
216 sal_uLong GetSubCondition() const { return aSubCondition.nSubCondition; }
217 const String* GetFldExpression() const
218 { return aSubCondition.pFldExpression; }
220 void SetCondition( sal_uLong nCond, sal_uLong nSubCond );
221 SwTxtFmtColl* GetTxtFmtColl() const { return (SwTxtFmtColl*)GetRegisteredIn(); }
222 void RegisterToFormat( SwFmt& );
225 class SwFmtCollConditions : public boost::ptr_vector<SwCollCondition> {};
227 class SW_DLLPUBLIC SwConditionTxtFmtColl : public SwTxtFmtColl
229 friend class SwDoc;
230 protected:
231 SwFmtCollConditions aCondColls;
233 SwConditionTxtFmtColl( SwAttrPool& rPool, const sal_Char* pFmtCollName,
234 SwTxtFmtColl* pDerFrom = 0 )
235 : SwTxtFmtColl( rPool, pFmtCollName, pDerFrom, RES_CONDTXTFMTCOLL )
237 SwConditionTxtFmtColl( SwAttrPool& rPool, const String &rFmtCollName,
238 SwTxtFmtColl* pDerFrom = 0 )
239 : SwTxtFmtColl( rPool, rFmtCollName, pDerFrom, RES_CONDTXTFMTCOLL )
242 public:
243 TYPEINFO(); ///< Already in base class Client.
245 virtual ~SwConditionTxtFmtColl();
247 const SwCollCondition* HasCondition( const SwCollCondition& rCond ) const;
248 const SwFmtCollConditions& GetCondColls() const { return aCondColls; }
249 void InsertCondition( const SwCollCondition& rCond );
250 bool RemoveCondition( const SwCollCondition& rCond );
252 void SetConditions( const SwFmtCollConditions& );
255 // FEATURE::CONDCOLL
256 /// Inline implementations.
257 inline void SwTxtFmtColl::SetNextTxtFmtColl( SwTxtFmtColl& rNext )
259 pNextTxtFmtColl = &rNext;
261 #endif
263 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */