Basic compiler undetected typo
[LibreOffice.git] / sw / inc / fmtcol.hxx
blob1b1bd7d2e46de5b135513691f69446064f204a67
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 "format.hxx"
24 #include "hintids.hxx"
25 #include "paratr.hxx"
26 #include <rtl/ustring.hxx>
27 #include <tools/solar.h>
29 #include <vector>
30 #include <memory>
32 class SwAttrPool;
33 namespace sw{ class DocumentStylePoolManager; }
35 class SAL_DLLPUBLIC_RTTI SwFormatColl: public SwFormat
37 protected:
38 SwFormatColl( SwAttrPool& rPool, const char* pFormatName,
39 const WhichRangesContainer& pWhichRanges, SwFormatColl* pDerFrom,
40 sal_uInt16 nFormatWhich )
41 : SwFormat( rPool, pFormatName, pWhichRanges, pDerFrom, nFormatWhich )
42 { SetAuto(false); }
44 SwFormatColl( SwAttrPool& rPool, const OUString &rFormatName,
45 const WhichRangesContainer& pWhichRanges, SwFormatColl* pDerFrom,
46 sal_uInt16 nFormatWhich )
47 : SwFormat( rPool, rFormatName, pWhichRanges, pDerFrom, nFormatWhich )
48 { SetAuto(false); }
50 private:
51 SwFormatColl(const SwFormatColl & ) = delete;
52 const SwFormatColl &operator=(const SwFormatColl &) = delete;
55 /// Represents the style of a paragraph.
56 class SW_DLLPUBLIC SwTextFormatColl
57 : public SwFormatColl
58 , public sw::FormatDropDefiner
60 friend class SwDoc;
61 friend class ::sw::DocumentStylePoolManager;
63 SwTextFormatColl(const SwTextFormatColl & rRef) = delete;
65 bool mbStayAssignedToListLevelOfOutlineStyle;
67 bool mbAssignedToOutlineStyle;
69 bool m_bInSwFntCache;
71 SwTextFormatColl *mpNextTextFormatColl;
73 SwCharFormat* mpLinkedCharFormat = nullptr;
75 protected:
76 SwTextFormatColl( SwAttrPool& rPool, const char* pFormatCollName,
77 SwTextFormatColl* pDerFrom = nullptr,
78 sal_uInt16 nFormatWh = RES_TXTFMTCOLL )
79 : SwFormatColl(rPool, pFormatCollName, aTextFormatCollSetRange, pDerFrom, nFormatWh)
80 , mbStayAssignedToListLevelOfOutlineStyle(false)
81 , mbAssignedToOutlineStyle(false)
82 , m_bInSwFntCache(false)
84 mpNextTextFormatColl = this;
87 SwTextFormatColl( SwAttrPool& rPool, const OUString &rFormatCollName,
88 SwTextFormatColl* pDerFrom,
89 sal_uInt16 nFormatWh = RES_TXTFMTCOLL )
90 : SwFormatColl(rPool, rFormatCollName, aTextFormatCollSetRange, pDerFrom, nFormatWh)
91 , mbStayAssignedToListLevelOfOutlineStyle(false)
92 , mbAssignedToOutlineStyle(false)
93 , m_bInSwFntCache(false)
95 mpNextTextFormatColl = this;
98 /// To get UL- / LR- / FontHeight-changes.
99 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
101 public:
102 virtual ~SwTextFormatColl();
103 inline void SetNextTextFormatColl(SwTextFormatColl& rNext);
104 SwTextFormatColl& GetNextTextFormatColl() const { return *mpNextTextFormatColl; }
106 void SetLinkedCharFormat(SwCharFormat& rLink);
108 const SwCharFormat* GetLinkedCharFormat() const;
110 bool IsAtDocNodeSet() const;
112 void SetAttrOutlineLevel( int );
113 int GetAttrOutlineLevel() const;
115 // Return the list level of the Outline Style - the List Style for the
116 // outline numbering -
117 // to which the Paragraph Style is assigned.
118 int GetAssignedOutlineStyleLevel() const;
120 bool IsAssignedToListLevelOfOutlineStyle() const
122 return mbAssignedToOutlineStyle;
125 // If a Paragraph Style is assigned to list level N of the Outline Style,
126 // then its outline level - AttrOutlineLevel - is set to N+1
127 void AssignToListLevelOfOutlineStyle(const int nAssignedListLevel);
128 void DeleteAssignmentToListLevelOfOutlineStyle();
130 /** Override to recognize changes on the <SwNumRuleItem> and register/unregister
131 the paragragh style at the corresponding <SwNumRule> instance. */
132 virtual bool SetFormatAttr( const SfxPoolItem& rAttr ) override;
133 virtual bool SetFormatAttr( const SfxItemSet& rSet ) override;
134 virtual bool ResetFormatAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 ) override;
136 /// Override <ResetAllFormatAttr()> to stay assigned to list level of outline style.
137 virtual sal_uInt16 ResetAllFormatAttr() override;
139 bool StayAssignedToListLevelOfOutlineStyle() const
141 return mbStayAssignedToListLevelOfOutlineStyle;
144 bool AreListLevelIndentsApplicable() const;
146 void dumpAsXml(xmlTextWriterPtr pWriter) const;
147 virtual void FormatDropNotify(const SwFormatDrop& rDrop) override
149 if(HasWriterListeners() && !IsModifyLocked())
150 CallSwClientNotify(sw::LegacyModifyHint(&rDrop, &rDrop));
152 bool IsInSwFntCache() const { return m_bInSwFntCache; };
153 void SetInSwFntCache() { m_bInSwFntCache = true; };
154 virtual void InvalidateInSwFntCache(sal_uInt16 nWhich) override
156 if(isCHRATR(nWhich))
158 m_bInSwFntCache = false;
160 else
162 switch(nWhich)
164 case RES_OBJECTDYING:
165 case RES_FMT_CHG:
166 case RES_ATTRSET_CHG:
167 m_bInSwFntCache = false;
173 class SwGrfFormatColl final : public SwFormatColl
175 friend class SwDoc;
177 SwGrfFormatColl( SwAttrPool& rPool, const char* pFormatCollName,
178 SwGrfFormatColl* pDerFrom = nullptr )
179 : SwFormatColl( rPool, pFormatCollName, aGrfFormatCollSetRange,
180 pDerFrom, RES_GRFFMTCOLL )
183 SwGrfFormatColl( SwAttrPool& rPool, const OUString &rFormatCollName,
184 SwGrfFormatColl* pDerFrom )
185 : SwFormatColl( rPool, rFormatCollName, aGrfFormatCollSetRange,
186 pDerFrom, RES_GRFFMTCOLL )
190 // FEATURE::CONDCOLL
191 /// Conditional styles.
192 enum class Master_CollCondition
194 NONE,
195 PARA_IN_LIST,
196 PARA_IN_OUTLINE,
197 PARA_IN_FRAME,
198 PARA_IN_TABLEHEAD,
199 PARA_IN_TABLEBODY,
200 PARA_IN_SECTION,
201 PARA_IN_FOOTNOTE,
202 PARA_IN_FOOTER,
203 PARA_IN_HEADER,
204 PARA_IN_ENDNOTE
207 class SW_DLLPUBLIC SwCollCondition final : public SwClient
209 Master_CollCondition m_nCondition;
210 sal_uLong m_nSubCondition;
212 public:
214 SwCollCondition( SwTextFormatColl* pColl, Master_CollCondition nMasterCond,
215 sal_uLong nSubCond );
216 virtual ~SwCollCondition() override;
218 /// @@@ public copy ctor, but no copy assignment?
219 SwCollCondition( const SwCollCondition& rCpy );
220 private:
221 /// @@@ public copy ctor, but no copy assignment?
222 SwCollCondition & operator= (const SwCollCondition &) = delete;
223 public:
225 bool operator==( const SwCollCondition& rCmp ) const;
227 Master_CollCondition GetCondition() const { return m_nCondition; }
228 sal_uLong GetSubCondition() const { return m_nSubCondition; }
230 void SetCondition( Master_CollCondition nCond, sal_uLong nSubCond );
231 SwTextFormatColl* GetTextFormatColl() const { return const_cast<SwTextFormatColl*>(static_cast<const SwTextFormatColl*>(GetRegisteredIn())); }
232 void RegisterToFormat( SwFormat& );
235 using SwFormatCollConditions = std::vector<std::unique_ptr<SwCollCondition>>;
237 class SW_DLLPUBLIC SwConditionTextFormatColl final : public SwTextFormatColl
239 friend class SwDoc;
240 friend class ::sw::DocumentStylePoolManager;
242 SwFormatCollConditions m_CondColls;
244 SwConditionTextFormatColl( SwAttrPool& rPool, const OUString &rFormatCollName,
245 SwTextFormatColl* pDerFrom )
246 : SwTextFormatColl( rPool, rFormatCollName, pDerFrom, RES_CONDTXTFMTCOLL )
249 public:
251 virtual ~SwConditionTextFormatColl() override;
253 const SwCollCondition* HasCondition( const SwCollCondition& rCond ) const;
254 const SwFormatCollConditions& GetCondColls() const { return m_CondColls; }
255 void InsertCondition( const SwCollCondition& rCond );
256 void RemoveCondition( const SwCollCondition& rCond );
258 void SetConditions( const SwFormatCollConditions& );
261 // FEATURE::CONDCOLL
262 /// Inline implementations.
263 inline void SwTextFormatColl::SetNextTextFormatColl( SwTextFormatColl& rNext )
265 mpNextTextFormatColl = &rNext;
267 #endif
269 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */