Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / sw / inc / fmtcol.hxx
blob1efc50c130ae939b6484bfa44840c51480cf6b49
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
22 #include "swdllapi.h"
23 #include <frmatr.hxx>
24 #include <swtypes.hxx>
25 #include <rtl/ustring.hxx>
27 #include <vector>
28 #include <memory>
30 class SwDoc;
31 namespace sw{ class DocumentStylePoolManager; }
33 class SwFormatColl : public SwFormat
35 protected:
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 )
40 { SetAuto(false); }
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 )
46 { SetAuto(false); }
48 private:
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
56 friend class SwDoc;
57 friend class ::sw::DocumentStylePoolManager;
59 SwTextFormatColl(const SwTextFormatColl & rRef) = delete;
61 bool mbStayAssignedToListLevelOfOutlineStyle;
63 protected:
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;
92 public:
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
139 friend class SwDoc;
140 protected:
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 )
153 public:
156 // FEATURE::CONDCOLL
157 /// Conditional styles.
158 enum class Master_CollCondition
160 NONE,
161 PARA_IN_LIST,
162 PARA_IN_OUTLINE,
163 PARA_IN_FRAME,
164 PARA_IN_TABLEHEAD,
165 PARA_IN_TABLEBODY,
166 PARA_IN_SECTION,
167 PARA_IN_FOOTNOTE,
168 PARA_IN_FOOTER,
169 PARA_IN_HEADER,
170 PARA_IN_ENDNOTE
173 class SW_DLLPUBLIC SwCollCondition : public SwClient
175 Master_CollCondition m_nCondition;
176 sal_uLong m_nSubCondition;
178 public:
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 );
186 private:
187 /// @@@ public copy ctor, but no copy assignment?
188 SwCollCondition & operator= (const SwCollCondition &) = delete;
189 public:
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
205 friend class SwDoc;
206 friend class ::sw::DocumentStylePoolManager;
207 protected:
208 SwFormatCollConditions m_CondColls;
210 SwConditionTextFormatColl( SwAttrPool& rPool, const OUString &rFormatCollName,
211 SwTextFormatColl* pDerFrom )
212 : SwTextFormatColl( rPool, rFormatCollName, pDerFrom, RES_CONDTXTFMTCOLL )
215 public:
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& );
227 // FEATURE::CONDCOLL
228 /// Inline implementations.
229 inline void SwTextFormatColl::SetNextTextFormatColl( SwTextFormatColl& rNext )
231 mpNextTextFormatColl = &rNext;
233 #endif
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */