1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_SW_INC_FMTCOL_HXX
20 #define INCLUDED_SW_INC_FMTCOL_HXX
24 #include <swtypes.hxx>
25 #include <boost/ptr_container/ptr_vector.hpp>
26 #include <rtl/ustring.hxx>
29 namespace sw
{ class DocumentStylePoolManager
; }
31 class SwFormatColl
: public SwFormat
34 SwFormatColl( SwAttrPool
& rPool
, const sal_Char
* pFormatName
,
35 const sal_uInt16
* pWhichRanges
, SwFormatColl
* pDerFrom
,
36 sal_uInt16 nFormatWhich
)
37 : SwFormat( rPool
, pFormatName
, pWhichRanges
, pDerFrom
, nFormatWhich
)
40 SwFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatName
,
41 const sal_uInt16
* pWhichRanges
, SwFormatColl
* pDerFrom
,
42 sal_uInt16 nFormatWhich
)
43 : SwFormat( rPool
, rFormatName
, pWhichRanges
, pDerFrom
, nFormatWhich
)
47 SwFormatColl(const SwFormatColl
& ) SAL_DELETED_FUNCTION
;
48 const SwFormatColl
&operator=(const SwFormatColl
&) SAL_DELETED_FUNCTION
;
51 /// Represents the style of a paragraph.
52 class SW_DLLPUBLIC SwTextFormatColl
: public SwFormatColl
55 friend class ::sw::DocumentStylePoolManager
;
57 SwTextFormatColl(const SwTextFormatColl
& rRef
) SAL_DELETED_FUNCTION
;
59 bool mbStayAssignedToListLevelOfOutlineStyle
;
63 bool mbAssignedToOutlineStyle
;
65 SwTextFormatColl
*pNextTextFormatColl
;
67 SwTextFormatColl( SwAttrPool
& rPool
, const sal_Char
* pFormatCollName
,
68 SwTextFormatColl
* pDerFrom
= 0,
69 sal_uInt16 nFormatWh
= RES_TXTFMTCOLL
)
70 : SwFormatColl(rPool
, pFormatCollName
, aTextFormatCollSetRange
, pDerFrom
, nFormatWh
)
71 , mbStayAssignedToListLevelOfOutlineStyle(false)
72 , mbAssignedToOutlineStyle(false)
74 pNextTextFormatColl
= this;
77 SwTextFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatCollName
,
78 SwTextFormatColl
* pDerFrom
= 0,
79 sal_uInt16 nFormatWh
= RES_TXTFMTCOLL
)
80 : SwFormatColl(rPool
, rFormatCollName
, aTextFormatCollSetRange
, pDerFrom
, nFormatWh
)
81 , mbStayAssignedToListLevelOfOutlineStyle(false)
82 , mbAssignedToOutlineStyle(false)
84 pNextTextFormatColl
= this;
87 /// To get UL- / LR- / FontHeight-changes.
88 virtual void Modify( const SfxPoolItem
*, const SfxPoolItem
* ) SAL_OVERRIDE
;
92 TYPEINFO_OVERRIDE(); ///< Already in base class Client.
94 inline void SetNextTextFormatColl(SwTextFormatColl
& rNext
);
95 SwTextFormatColl
& GetNextTextFormatColl() const { return *pNextTextFormatColl
; }
97 bool IsAtDocNodeSet() const;
99 void SetAttrOutlineLevel( int );
100 int GetAttrOutlineLevel() const;
102 // Return the list level of the Outline Style - the List Style for the
103 // outline numbering -
104 // to which the Paragraph Style is assigned.
105 int GetAssignedOutlineStyleLevel() const;
107 inline bool IsAssignedToListLevelOfOutlineStyle() const
109 return mbAssignedToOutlineStyle
;
112 // If a Paragraph Style is assigned to list level N of the Outline Style,
113 // then its outline level - AttrOutlineLevel - is set to N+1
114 void AssignToListLevelOfOutlineStyle(const int nAssignedListLevel
);
115 void DeleteAssignmentToListLevelOfOutlineStyle(const bool bResetOutlineLevel
118 /** Override to recognize changes on the <SwNumRuleItem> and register/unregister
119 the paragragh style at the corresponding <SwNumRule> instance. */
120 virtual bool SetFormatAttr( const SfxPoolItem
& rAttr
) SAL_OVERRIDE
;
121 virtual bool SetFormatAttr( const SfxItemSet
& rSet
) SAL_OVERRIDE
;
122 virtual bool ResetFormatAttr( sal_uInt16 nWhich1
, sal_uInt16 nWhich2
= 0 ) SAL_OVERRIDE
;
124 /// Override <ResetAllFormatAttr()> to stay assigned to list level of outline style.
125 virtual sal_uInt16
ResetAllFormatAttr() SAL_OVERRIDE
;
127 inline bool StayAssignedToListLevelOfOutlineStyle() const
129 return mbStayAssignedToListLevelOfOutlineStyle
;
132 bool AreListLevelIndentsApplicable() const;
134 void dumpAsXml(struct _xmlTextWriter
* pWriter
) const;
137 class SwGrfFormatColl
: public SwFormatColl
141 SwGrfFormatColl( SwAttrPool
& rPool
, const sal_Char
* pFormatCollName
,
142 SwGrfFormatColl
* pDerFrom
= 0 )
143 : SwFormatColl( rPool
, pFormatCollName
, aGrfFormatCollSetRange
,
144 pDerFrom
, RES_GRFFMTCOLL
)
147 SwGrfFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatCollName
,
148 SwGrfFormatColl
* pDerFrom
= 0 )
149 : SwFormatColl( rPool
, rFormatCollName
, aGrfFormatCollSetRange
,
150 pDerFrom
, RES_GRFFMTCOLL
)
154 TYPEINFO_OVERRIDE(); ///< Already in base class Client.
158 /// Conditional styles.
159 enum Master_CollConditions
161 PARA_IN_LIST
= 0x0001,
162 PARA_IN_OUTLINE
= 0x0002,
163 PARA_IN_FRAME
= 0x0004,
164 PARA_IN_TABLEHEAD
= 0x0008,
165 PARA_IN_TABLEBODY
= 0x0010,
166 PARA_IN_SECTION
= 0x0020,
167 PARA_IN_FOOTENOTE
= 0x0040,
168 PARA_IN_FOOTER
= 0x0080,
169 PARA_IN_HEADER
= 0x0100,
170 PARA_IN_ENDNOTE
= 0x0200,
172 USRFLD_EXPRESSION
= (int)0x8000
175 class SW_DLLPUBLIC SwCollCondition
: public SwClient
177 sal_uLong nCondition
;
180 sal_uLong nSubCondition
;
181 OUString
* pFieldExpression
;
185 TYPEINFO_OVERRIDE(); ///< Already in base class Client.
187 SwCollCondition( SwTextFormatColl
* pColl
, sal_uLong nMasterCond
,
188 sal_uLong nSubCond
= 0 );
189 SwCollCondition( SwTextFormatColl
* pColl
, sal_uLong nMasterCond
,
190 const OUString
& rSubExp
);
191 virtual ~SwCollCondition();
193 /// @@@ public copy ctor, but no copy assignment?
194 SwCollCondition( const SwCollCondition
& rCpy
);
196 /// @@@ public copy ctor, but no copy assignment?
197 SwCollCondition
& operator= (const SwCollCondition
&) SAL_DELETED_FUNCTION
;
200 bool operator==( const SwCollCondition
& rCmp
) const;
201 bool operator!=( const SwCollCondition
& rCmp
) const
202 { return ! (*this == rCmp
); }
204 sal_uLong
GetCondition() const { return nCondition
; }
205 sal_uLong
GetSubCondition() const { return aSubCondition
.nSubCondition
; }
206 const OUString
* GetFieldExpression() const
207 { return aSubCondition
.pFieldExpression
; }
209 void SetCondition( sal_uLong nCond
, sal_uLong nSubCond
);
210 SwTextFormatColl
* GetTextFormatColl() const { return const_cast<SwTextFormatColl
*>(static_cast<const SwTextFormatColl
*>(GetRegisteredIn())); }
211 void RegisterToFormat( SwFormat
& );
214 class SwFormatCollConditions
: public boost::ptr_vector
<SwCollCondition
> {};
216 class SW_DLLPUBLIC SwConditionTextFormatColl
: public SwTextFormatColl
219 friend class ::sw::DocumentStylePoolManager
;
221 SwFormatCollConditions aCondColls
;
223 SwConditionTextFormatColl( SwAttrPool
& rPool
, const sal_Char
* pFormatCollName
,
224 SwTextFormatColl
* pDerFrom
= 0 )
225 : SwTextFormatColl( rPool
, pFormatCollName
, pDerFrom
, RES_CONDTXTFMTCOLL
)
227 SwConditionTextFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatCollName
,
228 SwTextFormatColl
* pDerFrom
= 0 )
229 : SwTextFormatColl( rPool
, rFormatCollName
, pDerFrom
, RES_CONDTXTFMTCOLL
)
233 TYPEINFO_OVERRIDE(); ///< Already in base class Client.
235 virtual ~SwConditionTextFormatColl();
237 const SwCollCondition
* HasCondition( const SwCollCondition
& rCond
) const;
238 const SwFormatCollConditions
& GetCondColls() const { return aCondColls
; }
239 void InsertCondition( const SwCollCondition
& rCond
);
240 bool RemoveCondition( const SwCollCondition
& rCond
);
242 void SetConditions( const SwFormatCollConditions
& );
246 /// Inline implementations.
247 inline void SwTextFormatColl::SetNextTextFormatColl( SwTextFormatColl
& rNext
)
249 pNextTextFormatColl
= &rNext
;
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */