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 <rtl/ustring.hxx>
31 namespace sw
{ class DocumentStylePoolManager
; }
33 class SwFormatColl
: public SwFormat
36 SwFormatColl( SwAttrPool
& rPool
, const sal_Char
* pFormatName
,
37 const sal_uInt16
* pWhichRanges
, SwFormatColl
* pDerFrom
,
38 sal_uInt16 nFormatWhich
)
39 : SwFormat( rPool
, pFormatName
, pWhichRanges
, pDerFrom
, nFormatWhich
)
42 SwFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatName
,
43 const sal_uInt16
* pWhichRanges
, SwFormatColl
* pDerFrom
,
44 sal_uInt16 nFormatWhich
)
45 : SwFormat( rPool
, rFormatName
, pWhichRanges
, pDerFrom
, nFormatWhich
)
49 SwFormatColl(const SwFormatColl
& ) = delete;
50 const SwFormatColl
&operator=(const SwFormatColl
&) = delete;
53 /// Represents the style of a paragraph.
54 class SW_DLLPUBLIC SwTextFormatColl
: public SwFormatColl
57 friend class ::sw::DocumentStylePoolManager
;
59 SwTextFormatColl(const SwTextFormatColl
& rRef
) = delete;
61 bool mbStayAssignedToListLevelOfOutlineStyle
;
65 bool mbAssignedToOutlineStyle
;
67 SwTextFormatColl
*mpNextTextFormatColl
;
69 SwTextFormatColl( SwAttrPool
& rPool
, const sal_Char
* pFormatCollName
,
70 SwTextFormatColl
* pDerFrom
= nullptr,
71 sal_uInt16 nFormatWh
= RES_TXTFMTCOLL
)
72 : SwFormatColl(rPool
, pFormatCollName
, aTextFormatCollSetRange
, pDerFrom
, nFormatWh
)
73 , mbStayAssignedToListLevelOfOutlineStyle(false)
74 , mbAssignedToOutlineStyle(false)
76 mpNextTextFormatColl
= this;
79 SwTextFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatCollName
,
80 SwTextFormatColl
* pDerFrom
,
81 sal_uInt16 nFormatWh
= RES_TXTFMTCOLL
)
82 : SwFormatColl(rPool
, rFormatCollName
, aTextFormatCollSetRange
, pDerFrom
, nFormatWh
)
83 , mbStayAssignedToListLevelOfOutlineStyle(false)
84 , mbAssignedToOutlineStyle(false)
86 mpNextTextFormatColl
= this;
89 /// To get UL- / LR- / FontHeight-changes.
90 virtual void Modify( const SfxPoolItem
*, const SfxPoolItem
* ) override
;
95 inline void SetNextTextFormatColl(SwTextFormatColl
& rNext
);
96 SwTextFormatColl
& GetNextTextFormatColl() const { return *mpNextTextFormatColl
; }
98 bool IsAtDocNodeSet() const;
100 void SetAttrOutlineLevel( int );
101 int GetAttrOutlineLevel() const;
103 // Return the list level of the Outline Style - the List Style for the
104 // outline numbering -
105 // to which the Paragraph Style is assigned.
106 int GetAssignedOutlineStyleLevel() const;
108 bool IsAssignedToListLevelOfOutlineStyle() const
110 return mbAssignedToOutlineStyle
;
113 // If a Paragraph Style is assigned to list level N of the Outline Style,
114 // then its outline level - AttrOutlineLevel - is set to N+1
115 void AssignToListLevelOfOutlineStyle(const int nAssignedListLevel
);
116 void DeleteAssignmentToListLevelOfOutlineStyle();
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
) override
;
121 virtual bool SetFormatAttr( const SfxItemSet
& rSet
) override
;
122 virtual bool ResetFormatAttr( sal_uInt16 nWhich1
, sal_uInt16 nWhich2
= 0 ) override
;
124 /// Override <ResetAllFormatAttr()> to stay assigned to list level of outline style.
125 virtual sal_uInt16
ResetAllFormatAttr() override
;
127 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
= nullptr )
143 : SwFormatColl( rPool
, pFormatCollName
, aGrfFormatCollSetRange
,
144 pDerFrom
, RES_GRFFMTCOLL
)
147 SwGrfFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatCollName
,
148 SwGrfFormatColl
* pDerFrom
)
149 : SwFormatColl( rPool
, rFormatCollName
, aGrfFormatCollSetRange
,
150 pDerFrom
, RES_GRFFMTCOLL
)
157 /// Conditional styles.
158 enum class Master_CollCondition
173 class SW_DLLPUBLIC SwCollCondition
: public SwClient
175 Master_CollCondition m_nCondition
;
176 sal_uLong m_nSubCondition
;
180 SwCollCondition( SwTextFormatColl
* pColl
, Master_CollCondition nMasterCond
,
181 sal_uLong nSubCond
);
182 virtual ~SwCollCondition() override
;
184 /// @@@ public copy ctor, but no copy assignment?
185 SwCollCondition( const SwCollCondition
& rCpy
);
187 /// @@@ public copy ctor, but no copy assignment?
188 SwCollCondition
& operator= (const SwCollCondition
&) = delete;
191 bool operator==( const SwCollCondition
& rCmp
) const;
193 Master_CollCondition
GetCondition() const { return m_nCondition
; }
194 sal_uLong
GetSubCondition() const { return m_nSubCondition
; }
196 void SetCondition( Master_CollCondition nCond
, sal_uLong nSubCond
);
197 SwTextFormatColl
* GetTextFormatColl() const { return const_cast<SwTextFormatColl
*>(static_cast<const SwTextFormatColl
*>(GetRegisteredIn())); }
198 void RegisterToFormat( SwFormat
& );
201 using SwFormatCollConditions
= std::vector
<std::unique_ptr
<SwCollCondition
>>;
203 class SW_DLLPUBLIC SwConditionTextFormatColl
: public SwTextFormatColl
206 friend class ::sw::DocumentStylePoolManager
;
208 SwFormatCollConditions m_CondColls
;
210 SwConditionTextFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatCollName
,
211 SwTextFormatColl
* pDerFrom
)
212 : SwTextFormatColl( rPool
, rFormatCollName
, pDerFrom
, RES_CONDTXTFMTCOLL
)
217 virtual ~SwConditionTextFormatColl() override
;
219 const SwCollCondition
* HasCondition( const SwCollCondition
& rCond
) const;
220 const SwFormatCollConditions
& GetCondColls() const { return m_CondColls
; }
221 void InsertCondition( const SwCollCondition
& rCond
);
222 bool RemoveCondition( const SwCollCondition
& rCond
);
224 void SetConditions( const SwFormatCollConditions
& );
228 /// Inline implementations.
229 inline void SwTextFormatColl::SetNextTextFormatColl( SwTextFormatColl
& rNext
)
231 mpNextTextFormatColl
= &rNext
;
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */