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 "hintids.hxx"
26 #include <rtl/ustring.hxx>
27 #include <tools/solar.h>
33 namespace sw
{ class DocumentStylePoolManager
; }
35 class SAL_DLLPUBLIC_RTTI SwFormatColl
: public SwFormat
38 SwFormatColl( SwAttrPool
& rPool
, const char* pFormatName
,
39 const sal_uInt16
* pWhichRanges
, SwFormatColl
* pDerFrom
,
40 sal_uInt16 nFormatWhich
)
41 : SwFormat( rPool
, pFormatName
, pWhichRanges
, pDerFrom
, nFormatWhich
)
44 SwFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatName
,
45 const sal_uInt16
* pWhichRanges
, SwFormatColl
* pDerFrom
,
46 sal_uInt16 nFormatWhich
)
47 : SwFormat( rPool
, rFormatName
, pWhichRanges
, pDerFrom
, nFormatWhich
)
51 SwFormatColl(const SwFormatColl
& ) = delete;
52 const SwFormatColl
&operator=(const SwFormatColl
&) = delete;
55 /// Represents the style of a paragraph.
56 class SW_DLLPUBLIC SwTextFormatColl
58 , public sw::FormatDropDefiner
61 friend class ::sw::DocumentStylePoolManager
;
63 SwTextFormatColl(const SwTextFormatColl
& rRef
) = delete;
65 bool mbStayAssignedToListLevelOfOutlineStyle
;
67 bool mbAssignedToOutlineStyle
;
69 SwTextFormatColl
*mpNextTextFormatColl
;
72 SwTextFormatColl( SwAttrPool
& rPool
, const char* pFormatCollName
,
73 SwTextFormatColl
* pDerFrom
= nullptr,
74 sal_uInt16 nFormatWh
= RES_TXTFMTCOLL
)
75 : SwFormatColl(rPool
, pFormatCollName
, aTextFormatCollSetRange
, pDerFrom
, nFormatWh
)
76 , mbStayAssignedToListLevelOfOutlineStyle(false)
77 , mbAssignedToOutlineStyle(false)
79 mpNextTextFormatColl
= this;
82 SwTextFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatCollName
,
83 SwTextFormatColl
* pDerFrom
,
84 sal_uInt16 nFormatWh
= RES_TXTFMTCOLL
)
85 : SwFormatColl(rPool
, rFormatCollName
, aTextFormatCollSetRange
, pDerFrom
, nFormatWh
)
86 , mbStayAssignedToListLevelOfOutlineStyle(false)
87 , mbAssignedToOutlineStyle(false)
89 mpNextTextFormatColl
= this;
92 /// To get UL- / LR- / FontHeight-changes.
93 virtual void SwClientNotify(const SwModify
&, const SfxHint
&) override
;
96 inline void SetNextTextFormatColl(SwTextFormatColl
& rNext
);
97 SwTextFormatColl
& GetNextTextFormatColl() const { return *mpNextTextFormatColl
; }
99 bool IsAtDocNodeSet() const;
101 void SetAttrOutlineLevel( int );
102 int GetAttrOutlineLevel() const;
104 // Return the list level of the Outline Style - the List Style for the
105 // outline numbering -
106 // to which the Paragraph Style is assigned.
107 int GetAssignedOutlineStyleLevel() const;
109 bool IsAssignedToListLevelOfOutlineStyle() const
111 return mbAssignedToOutlineStyle
;
114 // If a Paragraph Style is assigned to list level N of the Outline Style,
115 // then its outline level - AttrOutlineLevel - is set to N+1
116 void AssignToListLevelOfOutlineStyle(const int nAssignedListLevel
);
117 void DeleteAssignmentToListLevelOfOutlineStyle();
119 /** Override to recognize changes on the <SwNumRuleItem> and register/unregister
120 the paragragh style at the corresponding <SwNumRule> instance. */
121 virtual bool SetFormatAttr( const SfxPoolItem
& rAttr
) override
;
122 virtual bool SetFormatAttr( const SfxItemSet
& rSet
) override
;
123 virtual bool ResetFormatAttr( sal_uInt16 nWhich1
, sal_uInt16 nWhich2
= 0 ) override
;
125 /// Override <ResetAllFormatAttr()> to stay assigned to list level of outline style.
126 virtual sal_uInt16
ResetAllFormatAttr() override
;
128 bool StayAssignedToListLevelOfOutlineStyle() const
130 return mbStayAssignedToListLevelOfOutlineStyle
;
133 bool AreListLevelIndentsApplicable() const;
135 void dumpAsXml(xmlTextWriterPtr pWriter
) const;
136 virtual void FormatDropNotify(const SwFormatDrop
& rDrop
) override
138 if(HasWriterListeners() && !IsModifyLocked())
139 CallSwClientNotify(sw::LegacyModifyHint(&rDrop
, &rDrop
));
143 class SwGrfFormatColl final
: public SwFormatColl
147 SwGrfFormatColl( SwAttrPool
& rPool
, const char* pFormatCollName
,
148 SwGrfFormatColl
* pDerFrom
= nullptr )
149 : SwFormatColl( rPool
, pFormatCollName
, aGrfFormatCollSetRange
,
150 pDerFrom
, RES_GRFFMTCOLL
)
153 SwGrfFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatCollName
,
154 SwGrfFormatColl
* pDerFrom
)
155 : SwFormatColl( rPool
, rFormatCollName
, aGrfFormatCollSetRange
,
156 pDerFrom
, RES_GRFFMTCOLL
)
161 /// Conditional styles.
162 enum class Master_CollCondition
177 class SW_DLLPUBLIC SwCollCondition final
: public SwClient
179 Master_CollCondition m_nCondition
;
180 sal_uLong m_nSubCondition
;
184 SwCollCondition( SwTextFormatColl
* pColl
, Master_CollCondition nMasterCond
,
185 sal_uLong nSubCond
);
186 virtual ~SwCollCondition() override
;
188 /// @@@ public copy ctor, but no copy assignment?
189 SwCollCondition( const SwCollCondition
& rCpy
);
191 /// @@@ public copy ctor, but no copy assignment?
192 SwCollCondition
& operator= (const SwCollCondition
&) = delete;
195 bool operator==( const SwCollCondition
& rCmp
) const;
197 Master_CollCondition
GetCondition() const { return m_nCondition
; }
198 sal_uLong
GetSubCondition() const { return m_nSubCondition
; }
200 void SetCondition( Master_CollCondition nCond
, sal_uLong nSubCond
);
201 SwTextFormatColl
* GetTextFormatColl() const { return const_cast<SwTextFormatColl
*>(static_cast<const SwTextFormatColl
*>(GetRegisteredIn())); }
202 void RegisterToFormat( SwFormat
& );
205 using SwFormatCollConditions
= std::vector
<std::unique_ptr
<SwCollCondition
>>;
207 class SW_DLLPUBLIC SwConditionTextFormatColl final
: public SwTextFormatColl
210 friend class ::sw::DocumentStylePoolManager
;
212 SwFormatCollConditions m_CondColls
;
214 SwConditionTextFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatCollName
,
215 SwTextFormatColl
* pDerFrom
)
216 : SwTextFormatColl( rPool
, rFormatCollName
, pDerFrom
, RES_CONDTXTFMTCOLL
)
221 virtual ~SwConditionTextFormatColl() override
;
223 const SwCollCondition
* HasCondition( const SwCollCondition
& rCond
) const;
224 const SwFormatCollConditions
& GetCondColls() const { return m_CondColls
; }
225 void InsertCondition( const SwCollCondition
& rCond
);
226 void RemoveCondition( const SwCollCondition
& rCond
);
228 void SetConditions( const SwFormatCollConditions
& );
232 /// Inline implementations.
233 inline void SwTextFormatColl::SetNextTextFormatColl( SwTextFormatColl
& rNext
)
235 mpNextTextFormatColl
= &rNext
;
239 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */