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 /// SwFormatColl is just an SwFormat subclass that defaults to m_bAutoFormat=false, expressing that
36 /// this set of formatting is a style, not direct formatting.
37 class SAL_DLLPUBLIC_RTTI SwFormatColl
: public SwFormat
40 SwFormatColl( SwAttrPool
& rPool
, const char* pFormatName
,
41 const WhichRangesContainer
& pWhichRanges
, SwFormatColl
* pDerFrom
,
42 sal_uInt16 nFormatWhich
)
43 : SwFormat( rPool
, pFormatName
, pWhichRanges
, pDerFrom
, nFormatWhich
)
46 SwFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatName
,
47 const WhichRangesContainer
& pWhichRanges
, SwFormatColl
* pDerFrom
,
48 sal_uInt16 nFormatWhich
)
49 : SwFormat( rPool
, rFormatName
, pWhichRanges
, pDerFrom
, nFormatWhich
)
53 SwFormatColl(const SwFormatColl
& ) = delete;
54 const SwFormatColl
&operator=(const SwFormatColl
&) = delete;
57 /// Represents the style of a paragraph.
58 class SW_DLLPUBLIC SwTextFormatColl
60 , public sw::FormatDropDefiner
63 friend class ::sw::DocumentStylePoolManager
;
65 SwTextFormatColl(const SwTextFormatColl
& rRef
) = delete;
67 bool mbStayAssignedToListLevelOfOutlineStyle
;
69 bool mbAssignedToOutlineStyle
;
73 SwTextFormatColl
*mpNextTextFormatColl
;
75 SwCharFormat
* mpLinkedCharFormat
= nullptr;
78 SwTextFormatColl( SwAttrPool
& rPool
, const char* pFormatCollName
,
79 SwTextFormatColl
* pDerFrom
= nullptr,
80 sal_uInt16 nFormatWh
= RES_TXTFMTCOLL
)
81 : SwFormatColl(rPool
, pFormatCollName
, aTextFormatCollSetRange
, pDerFrom
, nFormatWh
)
82 , mbStayAssignedToListLevelOfOutlineStyle(false)
83 , mbAssignedToOutlineStyle(false)
84 , m_bInSwFntCache(false)
86 mpNextTextFormatColl
= this;
89 SwTextFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatCollName
,
90 SwTextFormatColl
* pDerFrom
,
91 sal_uInt16 nFormatWh
= RES_TXTFMTCOLL
)
92 : SwFormatColl(rPool
, rFormatCollName
, aTextFormatCollSetRange
, pDerFrom
, nFormatWh
)
93 , mbStayAssignedToListLevelOfOutlineStyle(false)
94 , mbAssignedToOutlineStyle(false)
95 , m_bInSwFntCache(false)
97 mpNextTextFormatColl
= this;
100 /// To get UL- / LR- / FontHeight-changes.
101 virtual void SwClientNotify(const SwModify
&, const SfxHint
&) override
;
104 virtual ~SwTextFormatColl();
105 inline void SetNextTextFormatColl(SwTextFormatColl
& rNext
);
106 SwTextFormatColl
& GetNextTextFormatColl() const { return *mpNextTextFormatColl
; }
108 void SetLinkedCharFormat(SwCharFormat
* pLink
);
110 const SwCharFormat
* GetLinkedCharFormat() const;
112 bool IsAtDocNodeSet() const;
114 void SetAttrOutlineLevel( int );
115 int GetAttrOutlineLevel() const;
117 // Return the list level of the Outline Style - the List Style for the
118 // outline numbering -
119 // to which the Paragraph Style is assigned.
120 int GetAssignedOutlineStyleLevel() const;
122 bool IsAssignedToListLevelOfOutlineStyle() const
124 return mbAssignedToOutlineStyle
;
127 // If a Paragraph Style is assigned to list level N of the Outline Style,
128 // then its outline level - AttrOutlineLevel - is set to N+1
129 void AssignToListLevelOfOutlineStyle(const int nAssignedListLevel
);
130 void DeleteAssignmentToListLevelOfOutlineStyle();
132 /** Override to recognize changes on the <SwNumRuleItem> and register/unregister
133 the paragragh style at the corresponding <SwNumRule> instance. */
134 virtual bool SetFormatAttr( const SfxPoolItem
& rAttr
) override
;
135 virtual bool SetFormatAttr( const SfxItemSet
& rSet
) override
;
136 virtual bool ResetFormatAttr( sal_uInt16 nWhich1
, sal_uInt16 nWhich2
= 0 ) override
;
138 /// Override <ResetAllFormatAttr()> to stay assigned to list level of outline style.
139 virtual sal_uInt16
ResetAllFormatAttr() override
;
141 bool StayAssignedToListLevelOfOutlineStyle() const
143 return mbStayAssignedToListLevelOfOutlineStyle
;
146 ::sw::ListLevelIndents
AreListLevelIndentsApplicable() const;
147 bool AreListLevelIndentsApplicableImpl(sal_uInt16 nWhich
) const;
149 void dumpAsXml(xmlTextWriterPtr pWriter
) const;
150 virtual void FormatDropNotify(const SwFormatDrop
& rDrop
) override
152 if(HasWriterListeners() && !IsModifyLocked())
153 CallSwClientNotify(sw::LegacyModifyHint(&rDrop
, &rDrop
));
155 bool IsInSwFntCache() const { return m_bInSwFntCache
; };
156 void SetInSwFntCache() { m_bInSwFntCache
= true; };
157 virtual void InvalidateInSwFntCache(sal_uInt16 nWhich
) override
161 m_bInSwFntCache
= false;
167 case RES_OBJECTDYING
:
169 case RES_ATTRSET_CHG
:
170 m_bInSwFntCache
= false;
176 class SwGrfFormatColl final
: public SwFormatColl
180 SwGrfFormatColl( SwAttrPool
& rPool
, const char* pFormatCollName
,
181 SwGrfFormatColl
* pDerFrom
= nullptr )
182 : SwFormatColl( rPool
, pFormatCollName
, aGrfFormatCollSetRange
,
183 pDerFrom
, RES_GRFFMTCOLL
)
186 SwGrfFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatCollName
,
187 SwGrfFormatColl
* pDerFrom
)
188 : SwFormatColl( rPool
, rFormatCollName
, aGrfFormatCollSetRange
,
189 pDerFrom
, RES_GRFFMTCOLL
)
194 /// Conditional styles.
195 enum class Master_CollCondition
210 class SW_DLLPUBLIC SwCollCondition final
: public SwClient
212 Master_CollCondition m_nCondition
;
213 sal_uInt32 m_nSubCondition
;
217 SwCollCondition( SwTextFormatColl
* pColl
, Master_CollCondition nMasterCond
,
218 sal_uInt32 nSubCond
);
219 virtual ~SwCollCondition() override
;
221 /// @@@ public copy ctor, but no copy assignment?
222 SwCollCondition( const SwCollCondition
& rCpy
);
224 /// @@@ public copy ctor, but no copy assignment?
225 SwCollCondition
& operator= (const SwCollCondition
&) = delete;
228 bool operator==( const SwCollCondition
& rCmp
) const;
230 Master_CollCondition
GetCondition() const { return m_nCondition
; }
231 sal_uInt32
GetSubCondition() const { return m_nSubCondition
; }
233 void SetCondition( Master_CollCondition nCond
, sal_uInt32 nSubCond
);
234 SwTextFormatColl
* GetTextFormatColl() const { return const_cast<SwTextFormatColl
*>(static_cast<const SwTextFormatColl
*>(GetRegisteredIn())); }
235 void RegisterToFormat( SwFormat
& );
238 using SwFormatCollConditions
= std::vector
<std::unique_ptr
<SwCollCondition
>>;
240 class SW_DLLPUBLIC SwConditionTextFormatColl final
: public SwTextFormatColl
243 friend class ::sw::DocumentStylePoolManager
;
245 SwFormatCollConditions m_CondColls
;
247 SwConditionTextFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatCollName
,
248 SwTextFormatColl
* pDerFrom
)
249 : SwTextFormatColl( rPool
, rFormatCollName
, pDerFrom
, RES_CONDTXTFMTCOLL
)
254 virtual ~SwConditionTextFormatColl() override
;
256 const SwCollCondition
* HasCondition( const SwCollCondition
& rCond
) const;
257 const SwFormatCollConditions
& GetCondColls() const { return m_CondColls
; }
258 void InsertCondition( const SwCollCondition
& rCond
);
259 void RemoveCondition( const SwCollCondition
& rCond
);
261 void SetConditions( const SwFormatCollConditions
& );
265 /// Inline implementations.
266 inline void SwTextFormatColl::SetNextTextFormatColl( SwTextFormatColl
& rNext
)
268 mpNextTextFormatColl
= &rNext
;
272 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */