LibreOffice Module sw (master)  1
fmtcol.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #ifndef INCLUDED_SW_INC_FMTCOL_HXX
20 #define INCLUDED_SW_INC_FMTCOL_HXX
21 
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>
28 
29 #include <vector>
30 #include <memory>
31 
32 class SwAttrPool;
33 namespace sw{ class DocumentStylePoolManager; }
34 
35 class SAL_DLLPUBLIC_RTTI SwFormatColl: public SwFormat
36 {
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); }
43 
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); }
49 
50 private:
51  SwFormatColl(const SwFormatColl & ) = delete;
52  const SwFormatColl &operator=(const SwFormatColl &) = delete;
53 };
54 
57  : public SwFormatColl
58  , public sw::FormatDropDefiner
59 {
60  friend class SwDoc;
61  friend class ::sw::DocumentStylePoolManager;
62 
63  SwTextFormatColl(const SwTextFormatColl & rRef) = delete;
64 
66 
68 
70 
72 
73 protected:
74  SwTextFormatColl( SwAttrPool& rPool, const char* pFormatCollName,
75  SwTextFormatColl* pDerFrom = nullptr,
76  sal_uInt16 nFormatWh = RES_TXTFMTCOLL )
77  : SwFormatColl(rPool, pFormatCollName, aTextFormatCollSetRange, pDerFrom, nFormatWh)
78  , mbStayAssignedToListLevelOfOutlineStyle(false)
79  , mbAssignedToOutlineStyle(false)
80  , m_bInSwFntCache(false)
81  {
82  mpNextTextFormatColl = this;
83  }
84 
85  SwTextFormatColl( SwAttrPool& rPool, const OUString &rFormatCollName,
86  SwTextFormatColl* pDerFrom,
87  sal_uInt16 nFormatWh = RES_TXTFMTCOLL )
88  : SwFormatColl(rPool, rFormatCollName, aTextFormatCollSetRange, pDerFrom, nFormatWh)
89  , mbStayAssignedToListLevelOfOutlineStyle(false)
90  , mbAssignedToOutlineStyle(false)
91  , m_bInSwFntCache(false)
92  {
93  mpNextTextFormatColl = this;
94  }
95 
97  virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
98 
99 public:
100  virtual ~SwTextFormatColl();
101  inline void SetNextTextFormatColl(SwTextFormatColl& rNext);
102  SwTextFormatColl& GetNextTextFormatColl() const { return *mpNextTextFormatColl; }
103 
104  bool IsAtDocNodeSet() const;
105 
106  void SetAttrOutlineLevel( int );
107  int GetAttrOutlineLevel() const;
108 
109  // Return the list level of the Outline Style - the List Style for the
110  // outline numbering -
111  // to which the Paragraph Style is assigned.
112  int GetAssignedOutlineStyleLevel() const;
113 
115  {
116  return mbAssignedToOutlineStyle;
117  }
118 
119  // If a Paragraph Style is assigned to list level N of the Outline Style,
120  // then its outline level - AttrOutlineLevel - is set to N+1
121  void AssignToListLevelOfOutlineStyle(const int nAssignedListLevel);
122  void DeleteAssignmentToListLevelOfOutlineStyle();
123 
126  virtual bool SetFormatAttr( const SfxPoolItem& rAttr ) override;
127  virtual bool SetFormatAttr( const SfxItemSet& rSet ) override;
128  virtual bool ResetFormatAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 ) override;
129 
131  virtual sal_uInt16 ResetAllFormatAttr() override;
132 
134  {
135  return mbStayAssignedToListLevelOfOutlineStyle;
136  }
137 
138  bool AreListLevelIndentsApplicable() const;
139 
140  void dumpAsXml(xmlTextWriterPtr pWriter) const;
141  virtual void FormatDropNotify(const SwFormatDrop& rDrop) override
142  {
144  CallSwClientNotify(sw::LegacyModifyHint(&rDrop, &rDrop));
145  };
146  bool IsInSwFntCache() const { return m_bInSwFntCache; };
147  void SetInSwFntCache() { m_bInSwFntCache = true; };
148  virtual void InvalidateInSwFntCache(sal_uInt16 nWhich) override
149  {
150  if(isCHRATR(nWhich))
151  {
152  m_bInSwFntCache = false;
153  }
154  else
155  {
156  switch(nWhich)
157  {
158  case RES_OBJECTDYING:
159  case RES_FMT_CHG:
160  case RES_ATTRSET_CHG:
161  m_bInSwFntCache = false;
162  }
163  }
164  };
165 };
166 
167 class SwGrfFormatColl final : public SwFormatColl
168 {
169  friend class SwDoc;
170 
171  SwGrfFormatColl( SwAttrPool& rPool, const char* pFormatCollName,
172  SwGrfFormatColl* pDerFrom = nullptr )
173  : SwFormatColl( rPool, pFormatCollName, aGrfFormatCollSetRange,
174  pDerFrom, RES_GRFFMTCOLL )
175  {}
176 
177  SwGrfFormatColl( SwAttrPool& rPool, const OUString &rFormatCollName,
178  SwGrfFormatColl* pDerFrom )
179  : SwFormatColl( rPool, rFormatCollName, aGrfFormatCollSetRange,
180  pDerFrom, RES_GRFFMTCOLL )
181  {}
182 };
183 
184 // FEATURE::CONDCOLL
187 {
188  NONE,
189  PARA_IN_LIST,
199 };
200 
202 {
205 
206 public:
207 
209  sal_uLong nSubCond );
210  virtual ~SwCollCondition() override;
211 
213  SwCollCondition( const SwCollCondition& rCpy );
214 private:
216  SwCollCondition & operator= (const SwCollCondition &) = delete;
217 public:
218 
219  bool operator==( const SwCollCondition& rCmp ) const;
220 
221  Master_CollCondition GetCondition() const { return m_nCondition; }
222  sal_uLong GetSubCondition() const { return m_nSubCondition; }
223 
224  void SetCondition( Master_CollCondition nCond, sal_uLong nSubCond );
225  SwTextFormatColl* GetTextFormatColl() const { return const_cast<SwTextFormatColl*>(static_cast<const SwTextFormatColl*>(GetRegisteredIn())); }
226  void RegisterToFormat( SwFormat& );
227 };
228 
229 using SwFormatCollConditions = std::vector<std::unique_ptr<SwCollCondition>>;
230 
232 {
233  friend class SwDoc;
234  friend class ::sw::DocumentStylePoolManager;
235 
237 
238  SwConditionTextFormatColl( SwAttrPool& rPool, const OUString &rFormatCollName,
239  SwTextFormatColl* pDerFrom )
240  : SwTextFormatColl( rPool, rFormatCollName, pDerFrom, RES_CONDTXTFMTCOLL )
241  {}
242 
243 public:
244 
245  virtual ~SwConditionTextFormatColl() override;
246 
247  const SwCollCondition* HasCondition( const SwCollCondition& rCond ) const;
248  const SwFormatCollConditions& GetCondColls() const { return m_CondColls; }
249  void InsertCondition( const SwCollCondition& rCond );
250  void RemoveCondition( const SwCollCondition& rCond );
251 
252  void SetConditions( const SwFormatCollConditions& );
253 };
254 
255 // FEATURE::CONDCOLL
258 {
259  mpNextTextFormatColl = &rNext;
260 }
261 #endif
262 
263 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void FormatDropNotify(const SwFormatDrop &rDrop) override
Definition: fmtcol.hxx:141
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
bool isCHRATR(const sal_uInt16 nWhich)
Definition: hintids.hxx:472
bool m_bInSwFntCache
Definition: fmtcol.hxx:69
constexpr TypedWhichId< SwFormatChg > RES_FMT_CHG(162)
sal_uLong GetSubCondition() const
Definition: fmtcol.hxx:222
sal_uIntPtr sal_uLong
SwFormatCollConditions m_CondColls
Definition: fmtcol.hxx:236
Definition: doc.hxx:188
Master_CollCondition GetCondition() const
Definition: fmtcol.hxx:221
Master_CollCondition
Conditional styles.
Definition: fmtcol.hxx:186
bool mbStayAssignedToListLevelOfOutlineStyle
Definition: fmtcol.hxx:65
constexpr TypedWhichId< SwConditionTextFormatColl > RES_CONDTXTFMTCOLL(160)
Dialog to specify the properties of date form field.
bool HasWriterListeners() const
Definition: calbck.hxx:197
SwTextFormatColl * GetTextFormatColl() const
Definition: fmtcol.hxx:225
SwFormatColl(SwAttrPool &rPool, const OUString &rFormatName, const WhichRangesContainer &pWhichRanges, SwFormatColl *pDerFrom, sal_uInt16 nFormatWhich)
Definition: fmtcol.hxx:44
SwGrfFormatColl(SwAttrPool &rPool, const OUString &rFormatCollName, SwGrfFormatColl *pDerFrom)
Definition: fmtcol.hxx:177
bool IsAssignedToListLevelOfOutlineStyle() const
Definition: fmtcol.hxx:114
bool IsInSwFntCache() const
Definition: fmtcol.hxx:146
bool mbAssignedToOutlineStyle
Definition: fmtcol.hxx:67
WhichRangesContainer const aGrfFormatCollSetRange(svl::Items< RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_GRFATR_BEGIN, RES_GRFATR_END-1, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1 >)
void SetNextTextFormatColl(SwTextFormatColl &rNext)
Inline implementations.
Definition: fmtcol.hxx:257
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: format.cxx:227
SwFormat & operator=(const SwFormat &)
Definition: format.cxx:105
SwTextFormatColl * mpNextTextFormatColl
Definition: fmtcol.hxx:71
virtual sal_uInt16 ResetAllFormatAttr()
Takes all hints from Delta-Array,.
Definition: format.cxx:652
Base class for various Writer styles.
Definition: format.hxx:46
SwGrfFormatColl(SwAttrPool &rPool, const char *pFormatCollName, SwGrfFormatColl *pDerFrom=nullptr)
Definition: fmtcol.hxx:171
struct _xmlTextWriter * xmlTextWriterPtr
SwFormatColl(SwAttrPool &rPool, const char *pFormatName, const WhichRangesContainer &pWhichRanges, SwFormatColl *pDerFrom, sal_uInt16 nFormatWhich)
Definition: fmtcol.hxx:38
WhichRangesContainer const aTextFormatCollSetRange(svl::Items< RES_CHRATR_BEGIN, RES_CHRATR_END-1, RES_PARATR_BEGIN, RES_PARATR_END-1, RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, XATTR_FILL_FIRST, XATTR_FILL_LAST >)
void dumpAsXml(xmlTextWriterPtr=nullptr) const
Dumps the entire nodes structure to the given destination (file nodes.xml in the current directory by...
Definition: docfmt.cxx:1937
void SetAuto(bool bNew)
Definition: format.hxx:163
constexpr TypedWhichId< SwGrfFormatColl > RES_GRFFMTCOLL(158)
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(163)
sal_uLong m_nSubCondition
Definition: fmtcol.hxx:204
SwConditionTextFormatColl(SwAttrPool &rPool, const OUString &rFormatCollName, SwTextFormatColl *pDerFrom)
Definition: fmtcol.hxx:238
constexpr TypedWhichId< SwTextFormatColl > RES_TXTFMTCOLL(157)
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
std::vector< std::unique_ptr< SwCollCondition >> SwFormatCollConditions
Definition: fmtcol.hxx:229
Master_CollCondition m_nCondition
Definition: fmtcol.hxx:203
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:450
bool IsModifyLocked() const
Definition: calbck.hxx:205
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: format.cxx:624
void SetInSwFntCache()
Definition: fmtcol.hxx:147
virtual void InvalidateInSwFntCache(sal_uInt16 nWhich) override
Definition: fmtcol.hxx:148
bool StayAssignedToListLevelOfOutlineStyle() const
Definition: fmtcol.hxx:133
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:159
WriterListener & operator=(WriterListener const &)=delete
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:326
SwTextFormatColl(SwAttrPool &rPool, const OUString &rFormatCollName, SwTextFormatColl *pDerFrom, sal_uInt16 nFormatWh=RES_TXTFMTCOLL)
Definition: fmtcol.hxx:85
If SwFormatDrop is a Client, it is the CharFormat that describes the font for the DropCaps...
Definition: paratr.hxx:62
const SwFormatCollConditions & GetCondColls() const
Definition: fmtcol.hxx:248
bool operator==(const ScCsvLayoutData &rData1, const ScCsvLayoutData &rData2)
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_OBJECTDYING(RES_MSG_BEGIN)
SwTextFormatColl & GetNextTextFormatColl() const
Definition: fmtcol.hxx:102
SwTextFormatColl(SwAttrPool &rPool, const char *pFormatCollName, SwTextFormatColl *pDerFrom=nullptr, sal_uInt16 nFormatWh=RES_TXTFMTCOLL)
Definition: fmtcol.hxx:74