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"
25 #include <rtl/ustring.hxx>
26 #include <tools/solar.h>
32 namespace sw
{ class DocumentStylePoolManager
; }
34 class SAL_DLLPUBLIC_RTTI SwFormatColl
: public SwFormat
37 SwFormatColl( SwAttrPool
& rPool
, const char* pFormatName
,
38 const sal_uInt16
* pWhichRanges
, SwFormatColl
* pDerFrom
,
39 sal_uInt16 nFormatWhich
)
40 : SwFormat( rPool
, pFormatName
, pWhichRanges
, pDerFrom
, nFormatWhich
)
43 SwFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatName
,
44 const sal_uInt16
* pWhichRanges
, SwFormatColl
* pDerFrom
,
45 sal_uInt16 nFormatWhich
)
46 : SwFormat( rPool
, rFormatName
, pWhichRanges
, pDerFrom
, nFormatWhich
)
50 SwFormatColl(const SwFormatColl
& ) = delete;
51 const SwFormatColl
&operator=(const SwFormatColl
&) = delete;
54 /// Represents the style of a paragraph.
55 class SW_DLLPUBLIC SwTextFormatColl
: public SwFormatColl
58 friend class ::sw::DocumentStylePoolManager
;
60 SwTextFormatColl(const SwTextFormatColl
& rRef
) = delete;
62 bool mbStayAssignedToListLevelOfOutlineStyle
;
64 bool mbAssignedToOutlineStyle
;
66 SwTextFormatColl
*mpNextTextFormatColl
;
70 SwTextFormatColl( SwAttrPool
& rPool
, const char* pFormatCollName
,
71 SwTextFormatColl
* pDerFrom
= nullptr,
72 sal_uInt16 nFormatWh
= RES_TXTFMTCOLL
)
73 : SwFormatColl(rPool
, pFormatCollName
, aTextFormatCollSetRange
, pDerFrom
, nFormatWh
)
74 , mbStayAssignedToListLevelOfOutlineStyle(false)
75 , mbAssignedToOutlineStyle(false)
77 mpNextTextFormatColl
= this;
80 SwTextFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatCollName
,
81 SwTextFormatColl
* pDerFrom
,
82 sal_uInt16 nFormatWh
= RES_TXTFMTCOLL
)
83 : SwFormatColl(rPool
, rFormatCollName
, aTextFormatCollSetRange
, pDerFrom
, nFormatWh
)
84 , mbStayAssignedToListLevelOfOutlineStyle(false)
85 , mbAssignedToOutlineStyle(false)
87 mpNextTextFormatColl
= this;
90 /// To get UL- / LR- / FontHeight-changes.
91 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;
138 class SwGrfFormatColl final
: public SwFormatColl
142 SwGrfFormatColl( SwAttrPool
& rPool
, const char* pFormatCollName
,
143 SwGrfFormatColl
* pDerFrom
= nullptr )
144 : SwFormatColl( rPool
, pFormatCollName
, aGrfFormatCollSetRange
,
145 pDerFrom
, RES_GRFFMTCOLL
)
148 SwGrfFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatCollName
,
149 SwGrfFormatColl
* pDerFrom
)
150 : SwFormatColl( rPool
, rFormatCollName
, aGrfFormatCollSetRange
,
151 pDerFrom
, RES_GRFFMTCOLL
)
156 /// Conditional styles.
157 enum class Master_CollCondition
172 class SW_DLLPUBLIC SwCollCondition final
: public SwClient
174 Master_CollCondition m_nCondition
;
175 sal_uLong m_nSubCondition
;
179 SwCollCondition( SwTextFormatColl
* pColl
, Master_CollCondition nMasterCond
,
180 sal_uLong nSubCond
);
181 virtual ~SwCollCondition() override
;
183 /// @@@ public copy ctor, but no copy assignment?
184 SwCollCondition( const SwCollCondition
& rCpy
);
186 /// @@@ public copy ctor, but no copy assignment?
187 SwCollCondition
& operator= (const SwCollCondition
&) = delete;
190 bool operator==( const SwCollCondition
& rCmp
) const;
192 Master_CollCondition
GetCondition() const { return m_nCondition
; }
193 sal_uLong
GetSubCondition() const { return m_nSubCondition
; }
195 void SetCondition( Master_CollCondition nCond
, sal_uLong nSubCond
);
196 SwTextFormatColl
* GetTextFormatColl() const { return const_cast<SwTextFormatColl
*>(static_cast<const SwTextFormatColl
*>(GetRegisteredIn())); }
197 void RegisterToFormat( SwFormat
& );
200 using SwFormatCollConditions
= std::vector
<std::unique_ptr
<SwCollCondition
>>;
202 class SW_DLLPUBLIC SwConditionTextFormatColl final
: public SwTextFormatColl
205 friend class ::sw::DocumentStylePoolManager
;
207 SwFormatCollConditions m_CondColls
;
209 SwConditionTextFormatColl( SwAttrPool
& rPool
, const OUString
&rFormatCollName
,
210 SwTextFormatColl
* pDerFrom
)
211 : SwTextFormatColl( rPool
, rFormatCollName
, pDerFrom
, RES_CONDTXTFMTCOLL
)
216 virtual ~SwConditionTextFormatColl() override
;
218 const SwCollCondition
* HasCondition( const SwCollCondition
& rCond
) const;
219 const SwFormatCollConditions
& GetCondColls() const { return m_CondColls
; }
220 void InsertCondition( const SwCollCondition
& rCond
);
221 void RemoveCondition( const SwCollCondition
& rCond
);
223 void SetConditions( const SwFormatCollConditions
& );
227 /// Inline implementations.
228 inline void SwTextFormatColl::SetNextTextFormatColl( SwTextFormatColl
& rNext
)
230 mpNextTextFormatColl
= &rNext
;
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */