LibreOffice Module sw (master)  1
numrule.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_NUMRULE_HXX
20 #define INCLUDED_SW_INC_NUMRULE_HXX
21 
22 #include <sal/types.h>
23 #include <rtl/ustring.hxx>
24 #include <editeng/numitem.hxx>
25 #include <i18nlangtag/lang.h>
26 #include "swdllapi.h"
27 #include "swtypes.hxx"
28 #include "calbck.hxx"
29 #include "SwNumberTreeTypes.hxx"
30 #include "ndarr.hxx"
31 #include <unordered_map>
32 #include <memory>
33 #include <vector>
34 #include "charfmt.hxx"
35 
36 class SwTextFormatColl;
38 class SwNodeNum;
39 namespace vcl { class Font; }
40 class SvxBrushItem;
41 class SfxGrabBagItem;
42 class SwDoc;
43 class SwFormatVertOrient;
44 class SwTextNode;
45 class Size;
46 
47 const sal_Unicode cBulletChar = 0x2022;
48 
49 class SW_DLLPUBLIC SwNumFormat final : public SvxNumberFormat, public SwClient
50 {
51  std::unique_ptr<SwFormatVertOrient> m_pVertOrient;
52  //For i120928,record the cp info of graphic within bullet
54  SAL_DLLPRIVATE void UpdateNumNodes( SwDoc* pDoc );
55 
56  using SvxNumberFormat::operator ==;
57  using SvxNumberFormat::operator !=;
58 
59  virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) override;
60 
61 public:
62  SwNumFormat();
63  SwNumFormat( const SwNumFormat& );
64  SwNumFormat( const SvxNumberFormat&, SwDoc* pDoc);
65 
66  virtual ~SwNumFormat() override;
67 
69 
70  bool operator==( const SwNumFormat& ) const;
71  bool operator!=( const SwNumFormat& r ) const { return !(*this == r); }
72 
73  SwCharFormat* GetCharFormat() const { return const_cast<SwCharFormat*>(static_cast<const SwCharFormat*>(GetRegisteredIn())); }
74  void SetCharFormat( SwCharFormat* );
75 
77  virtual OUString GetCharFormatName() const override;
78 
79  //For i120928,access the cp info of graphic within bullet
80  void SetGrfBulletCP(sal_Unicode cP){m_cGrfBulletCP = cP;}
81  sal_Unicode GetGrfBulletCP() const {return m_cGrfBulletCP;}
82 
83  virtual void SetGraphicBrush( const SvxBrushItem* pBrushItem, const Size* pSize = nullptr, const sal_Int16* pOrient = nullptr) override;
84 
85  const SwFormatVertOrient* GetGraphicOrientation() const;
86 
87  bool IsEnumeration() const; // #i22362#
88  bool IsItemize() const; // #i29560#
89 };
90 
93 {
94 
95 public:
96  typedef std::vector< SwTextNode* > tTextNodeList;
97  typedef std::vector< SwTextFormatColl* > tParagraphStyleList;
98 
99  struct Extremities
100  {
101  sal_uInt16 nPrefixChars;
102  sal_uInt16 nSuffixChars;
103  };
104 
105 private:
106  friend void FinitCore();
107 
108  static SwNumFormat* maBaseFormats [ RULE_END ][ MAXLEVEL ];
109  static const sal_uInt16 maDefNumIndents[ MAXLEVEL ];
111  static SwNumFormat* maLabelAlignmentBaseFormats [ RULE_END ][ MAXLEVEL ];
112  static sal_uInt16 mnRefCount;
113 
114  std::unique_ptr<SwNumFormat> maFormats[ MAXLEVEL ];
115 
117  tTextNodeList maTextNodeList;
118 
120  tParagraphStyleList maParagraphStyleList;
121 
123  std::unordered_map<OUString, SwNumRule *> * mpNumRuleMap;
124 
125  OUString msName;
127  sal_uInt16 mnPoolFormatId;
128  sal_uInt16 mnPoolHelpId;
130  bool mbAutoRuleFlag : 1;
131  bool mbInvalidRuleFlag : 1;
132  bool mbContinusNum : 1;
133  bool mbAbsSpaces : 1;
134  bool mbHidden : 1;
137 
139  OUString msDefaultListId;
140  std::shared_ptr<SfxGrabBagItem> mpGrabBagItem;
141 
142 public:
144  SwNumRule( const OUString& rNm,
145  const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode,
147 
148  SwNumRule( const SwNumRule& );
149  ~SwNumRule();
150 
151  SwNumRule& operator=( const SwNumRule& );
152  bool operator==( const SwNumRule& ) const;
153  bool operator!=( const SwNumRule& r ) const { return !(*this == r); }
154 
155  const SwNumFormat* GetNumFormat( sal_uInt16 i ) const;
156  const SwNumFormat& Get( sal_uInt16 i ) const;
157 
158  bool IsHidden( ) const { return mbHidden; }
159  void SetHidden( bool bValue ) { mbHidden = bValue; }
160 
161  void Set( sal_uInt16 i, const SwNumFormat* );
162  void Set( sal_uInt16 i, const SwNumFormat& );
163  OUString MakeNumString( const SwNodeNum&, bool bInclStrings = true ) const;
166  OUString MakeNumString( const SwNumberTree::tNumberVector & rNumVector,
167  const bool bInclStrings = true,
168  const bool bOnlyArabic = false,
169  const unsigned int _nRestrictToThisLevel = MAXLEVEL,
170  Extremities* pExtremities = nullptr,
171  LanguageType nLang = LANGUAGE_SYSTEM) const;
172  OUString MakeRefNumString( const SwNodeNum& rNodeNum,
173  const bool bInclSuperiorNumLabels,
174  const int nRestrictInclToThisLevel ) const;
175 
177  void GetTextNodeList( SwNumRule::tTextNodeList& rTextNodeList ) const;
178  SwNumRule::tTextNodeList::size_type GetTextNodeListSize() const;
179 
180  void AddTextNode( SwTextNode& rTextNode );
181  void RemoveTextNode( SwTextNode& rTextNode );
182 
183  SwNumRule::tParagraphStyleList::size_type GetParagraphStyleListSize() const;
184  void AddParagraphStyle( SwTextFormatColl& rTextFormatColl );
185  void RemoveParagraphStyle( SwTextFormatColl& rTextFormatColl );
186 
187  void SetDefaultListId( const OUString& sDefaultListId )
188  {
189  msDefaultListId = sDefaultListId;
190  }
191  const OUString& GetDefaultListId() const
192  {
193  return msDefaultListId;
194  }
200  void SetNumRuleMap(
201  std::unordered_map<OUString, SwNumRule *>* pNumRuleMap );
202 
203  static OUString GetOutlineRuleName();
204 
205  static sal_uInt16 GetNumIndent( sal_uInt8 nLvl );
206  static sal_uInt16 GetBullIndent( sal_uInt8 nLvl );
207 
208  SwNumRuleType GetRuleType() const { return meRuleType; }
209  void SetRuleType( SwNumRuleType eNew ) { meRuleType = eNew;
210  mbInvalidRuleFlag = true; }
211 
215  SwNumRule& CopyNumRule( SwDoc*, const SwNumRule& );
216 
219  void CheckCharFormats( SwDoc* pDoc );
220 
221  const OUString& GetName() const { return msName; }
222 
223  void SetName( const OUString& rNm,
224  IDocumentListsAccess& rDocListAccess );
225 
226  bool IsAutoRule() const { return mbAutoRuleFlag; }
227  void SetAutoRule( bool bFlag ) { mbAutoRuleFlag = bFlag; }
228 
229  bool IsInvalidRule() const { return mbInvalidRuleFlag; }
230  void SetInvalidRule( bool bFlag );
231 
232  bool IsContinusNum() const { return mbContinusNum; }
233  void SetContinusNum( bool bFlag ) { mbContinusNum = bFlag; }
234 
235  bool IsAbsSpaces() const { return mbAbsSpaces; }
236  void SetAbsSpaces( bool bFlag ) { mbAbsSpaces = bFlag; }
237 
238  bool IsOutlineRule() const { return meRuleType == OUTLINE_RULE; }
239 
240  bool IsCountPhantoms() const { return mbCountPhantoms; }
241  void SetCountPhantoms(bool bCountPhantoms);
242 
243  bool IsUsedByRedline() const { return mbUsedByRedline; }
244  void SetUsedByRedline(bool bUsed ) { mbUsedByRedline = bUsed; }
245 
247  sal_uInt16 GetPoolFormatId() const { return mnPoolFormatId; }
248  void SetPoolFormatId( sal_uInt16 nId ) { mnPoolFormatId = nId; }
249 
251  sal_uInt16 GetPoolHelpId() const { return mnPoolHelpId; }
252  void SetPoolHelpId( sal_uInt16 nId ) { mnPoolHelpId = nId; }
253  sal_uInt8 GetPoolHlpFileId() const { return mnPoolHlpFileId; }
254  void SetPoolHlpFileId( sal_uInt8 nId ) { mnPoolHlpFileId = nId; }
255 
256  void SetSvxRule(const SvxNumRule&, SwDoc* pDoc);
257  SvxNumRule MakeSvxNumRule() const;
258 
260  void ChangeIndent( const sal_Int32 nDiff );
262  void SetIndent( const short nNewIndent,
263  const sal_uInt16 nListLevel );
266  void SetIndentOfFirstListLevelAndChangeOthers( const short nNewIndent );
267 
268  void Validate();
269  void dumpAsXml(xmlTextWriterPtr w) const;
270  void GetGrabBagItem(css::uno::Any& rVal) const;
271  void SetGrabBagItem(const css::uno::Any& rVal);
272 };
273 
275 namespace numfunc
276 {
278  OUString const & GetDefBulletFontname();
279 
285 
288 
291 
298 
300 }
301 
302 #endif // INCLUDED_SW_INC_NUMRULE_HXX
303 
304 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvxNumberFormat & operator=(const SvxNumberFormat &)
sal_uInt16 mnPoolHelpId
HelpId for this Pool-style.
Definition: numrule.hxx:128
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
void SetAutoRule(bool bFlag)
Definition: numrule.hxx:227
bool IsHidden() const
Definition: numrule.hxx:158
void SetPoolHlpFileId(sal_uInt8 nId)
Definition: numrule.hxx:254
void SetGrfBulletCP(sal_Unicode cP)
Definition: numrule.hxx:80
sal_uInt16 GetPoolFormatId() const
Query and set PoolFormat IDs.
Definition: numrule.hxx:247
const OUString & GetDefaultListId() const
Definition: numrule.hxx:191
bool IsAutoRule() const
Definition: numrule.hxx:226
Definition: doc.hxx:185
const sal_Unicode cBulletChar
Character for lists.
Definition: numrule.hxx:47
void SetContinusNum(bool bFlag)
Definition: numrule.hxx:233
sal_uInt8 mnPoolHlpFileId
FilePos at Doc on style helps.
Definition: numrule.hxx:129
SwNumRuleType
Definition: numrule.hxx:91
const OUString & GetName() const
Definition: numrule.hxx:221
sal_uInt16 GetPoolHelpId() const
Query and set Help-IDs for document styles.
Definition: numrule.hxx:251
void SetHidden(bool bValue)
Definition: numrule.hxx:159
void SetAbsSpaces(bool bFlag)
Definition: numrule.hxx:236
static LanguageType nLang
Definition: srtdlg.cxx:60
sal_uInt16 sal_Unicode
bool mbUsedByRedline
Definition: numrule.hxx:136
OUString msDefaultListId
Definition: numrule.hxx:139
bool operator==(const SvxNumberFormat &) const
sal_Unicode GetBulletChar(sal_uInt8 nLevel)
retrieve unicode of character used for the default bullet list for the given list level ...
Definition: number.cxx:1262
void SetCharFormatName(const OUString &rSet)
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
void SetPoolFormatId(sal_uInt16 nId)
Definition: numrule.hxx:248
bool IsContinusNum() const
Definition: numrule.hxx:232
SwCharFormat * GetCharFormat() const
Definition: numrule.hxx:73
struct _xmlTextWriter * xmlTextWriterPtr
std::unique_ptr< SwFormatVertOrient > m_pVertOrient
Definition: numrule.hxx:51
bool IsCountPhantoms() const
Definition: numrule.hxx:240
bool IsInvalidRule() const
Definition: numrule.hxx:229
SwNumRuleType GetRuleType() const
Definition: numrule.hxx:208
bool operator!=(const SwNumRule &r) const
Definition: numrule.hxx:153
const vcl::Font & GetDefBulletFont()
retrieve font used for the default bullet list characters
Definition: number.cxx:1257
void FinitCore()
Definition: init.cxx:672
SwNumRuleType meRuleType
Definition: numrule.hxx:126
void SetRuleType(SwNumRuleType eNew)
Definition: numrule.hxx:209
sal_Unicode m_cGrfBulletCP
Definition: numrule.hxx:53
void SetPoolHelpId(sal_uInt16 nId)
Definition: numrule.hxx:252
sal_uInt8 GetPoolHlpFileId() const
Definition: numrule.hxx:253
std::unordered_map< OUString, SwNumRule * > * mpNumRuleMap
unordered_map containing "name->rule" relation
Definition: numrule.hxx:123
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
Provides access to the lists of a document.
std::vector< tSwNumTreeNumber > tNumberVector
const SvxNumberFormat::SvxNumPositionAndSpaceMode meDefaultNumberFormatPositionAndSpaceMode
it needs to export as part of tracked numbering change
Definition: numrule.hxx:138
sal_uInt16 nPrefixChars
Definition: numrule.hxx:101
bool operator!=(const SwNumFormat &r) const
Definition: numrule.hxx:71
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
SvxNumberFormat::SvxNumPositionAndSpaceMode GetDefaultPositionAndSpaceMode()
Definition: number.cxx:1379
bool IsDefBulletFontUserDefined()
determine if default bullet font is user defined
Definition: number.cxx:1252
void SetDefaultListId(const OUString &sDefaultListId)
Definition: numrule.hxx:187
unsigned char sal_uInt8
OUString const & GetDefBulletFontname()
retrieve font family name used for the default bullet list characters
Definition: number.cxx:1247
sal_uInt16 nSuffixChars
Definition: numrule.hxx:102
tTextNodeList maTextNodeList
container for associated text nodes
Definition: numrule.hxx:117
static sal_uInt16 mnRefCount
Definition: numrule.hxx:112
virtual OUString GetCharFormatName() const
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:157
bool IsUsedByRedline() const
Definition: numrule.hxx:243
std::vector< SwTextNode * > tTextNodeList
Definition: numrule.hxx:96
virtual void SetGraphicBrush(const SvxBrushItem *pBrushItem, const Size *pSize=nullptr, const sal_Int16 *pOrient=nullptr)
std::shared_ptr< SfxGrabBagItem > mpGrabBagItem
Style InteropGrabBag.
Definition: numrule.hxx:140
tParagraphStyleList maParagraphStyleList
container for associated paragraph styles
Definition: numrule.hxx:120
bool IsAbsSpaces() const
Definition: numrule.hxx:235
SVX_DLLPUBLIC MSO_SPT Get(const OUString &)
sal_Unicode GetGrfBulletCP() const
Definition: numrule.hxx:81
void SetUsedByRedline(bool bUsed)
Definition: numrule.hxx:244
bool operator==(const ScCsvLayoutData &rData1, const ScCsvLayoutData &rData2)
sal_uInt16 mnPoolFormatId
Id-for NumRules created "automatically".
Definition: numrule.hxx:127
std::vector< SwTextFormatColl * > tParagraphStyleList
Definition: numrule.hxx:97
bool IsOutlineRule() const
Definition: numrule.hxx:238
virtual void Modify(const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue)
Definition: calbck.cxx:130
bool ChangeIndentOnTabAtFirstPosOfFirstListItem()
configuration, if at first position of the first list item the -key increased the indent of the ...
Definition: number.cxx:1374
OUString msName
Definition: numrule.hxx:125
bool mbCountPhantoms
Definition: numrule.hxx:135
namespace for static functions and methods for numbering and bullets
Definition: number.cxx:1039