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#include "fmtornt.hxx"
36
39class SwNodeNum;
40namespace vcl { class Font; }
41class SvxBrushItem;
42class SfxGrabBagItem;
43class SwDoc;
44class SwTextNode;
45class Size;
46class SwWrtShell;
47
48const sal_Unicode cBulletChar = 0x2022;
49
51{
53 //For i120928,record the cp info of graphic within bullet
55 SAL_DLLPRIVATE void UpdateNumNodes(SwDoc& rDoc);
56
57 using SvxNumberFormat::operator ==;
58 using SvxNumberFormat::operator !=;
59
60 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
61
62public:
64 SwNumFormat( const SwNumFormat& );
65 SwNumFormat( const SvxNumberFormat&, SwDoc* pDoc);
66
67 virtual ~SwNumFormat() override;
68
70
71 bool operator==( const SwNumFormat& ) const;
72 bool operator!=( const SwNumFormat& r ) const { return !(*this == r); }
73
74 SwCharFormat* GetCharFormat() const { return const_cast<SwCharFormat*>(static_cast<const SwCharFormat*>(GetRegisteredIn())); }
75 void SetCharFormat( SwCharFormat* );
76
78 virtual OUString GetCharFormatName() const override;
79
80 //For i120928,access the cp info of graphic within bullet
81 void SetGrfBulletCP(sal_Unicode cP){m_cGrfBulletCP = cP;}
82 sal_Unicode GetGrfBulletCP() const {return m_cGrfBulletCP;}
83
84 virtual void SetGraphicBrush( const SvxBrushItem* pBrushItem, const Size* pSize = nullptr, const sal_Int16* pOrient = nullptr) override;
85
86 const SwFormatVertOrient* GetGraphicOrientation() const;
87
88 bool IsEnumeration() const; // #i22362#
89 bool IsItemize() const; // #i29560#
90};
91
94{
95
96public:
97 typedef std::vector< SwTextNode* > tTextNodeList;
98 typedef std::vector< SwTextFormatColl* > tParagraphStyleList;
99
101 {
102 sal_uInt16 nPrefixChars;
103 sal_uInt16 nSuffixChars;
104 };
105
106private:
107 friend void FinitCore();
108
109 static SwNumFormat* saBaseFormats [ RULE_END ][ MAXLEVEL ];
110 static const sal_uInt16 saDefNumIndents[ MAXLEVEL ];
112 static SwNumFormat* saLabelAlignmentBaseFormats [ RULE_END ][ MAXLEVEL ];
113 static sal_uInt16 snRefCount;
114
115 std::unique_ptr<SwNumFormat> maFormats[ MAXLEVEL ];
116
119
122
124 std::unordered_map<OUString, SwNumRule *> * mpNumRuleMap;
125
126 OUString msName;
128 sal_uInt16 mnPoolFormatId;
129 sal_uInt16 mnPoolHelpId;
133 bool mbContinusNum : 1;
134 bool mbAbsSpaces : 1;
135 bool mbHidden : 1;
138
141 std::shared_ptr<SfxGrabBagItem> mpGrabBagItem;
142
143public:
145 SwNumRule( OUString aNm,
146 const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode,
148
149 SwNumRule( const SwNumRule& );
150 ~SwNumRule();
151
152 SwNumRule& operator=( const SwNumRule& );
153 bool operator==( const SwNumRule& ) const;
154 bool operator!=( const SwNumRule& r ) const { return !(*this == r); }
155
156 void Reset( const OUString& rName );
157
158 const SwNumFormat* GetNumFormat( sal_uInt16 i ) const;
159 const SwNumFormat& Get( sal_uInt16 i ) const;
160
161 bool IsHidden( ) const { return mbHidden; }
162 void SetHidden( bool bValue ) { mbHidden = bValue; }
163
164 void Set( sal_uInt16 i, const SwNumFormat* );
165 void Set( sal_uInt16 i, const SwNumFormat& );
166 OUString MakeNumString( const SwNodeNum&, bool bInclStrings = true ) const;
169 OUString MakeNumString( const SwNumberTree::tNumberVector & rNumVector,
170 const bool bInclStrings = true,
171 const unsigned int _nRestrictToThisLevel = MAXLEVEL,
172 Extremities* pExtremities = nullptr,
173 LanguageType nLang = LANGUAGE_SYSTEM) const;
174 OUString MakeRefNumString( const SwNodeNum& rNodeNum,
175 const bool bInclSuperiorNumLabels,
176 const int nRestrictInclToThisLevel ) const;
177 OUString MakeParagraphStyleListString() const;
178
180 void GetTextNodeList( SwNumRule::tTextNodeList& rTextNodeList ) const;
181 SwNumRule::tTextNodeList::size_type GetTextNodeListSize() const;
182
183 void AddTextNode( SwTextNode& rTextNode );
184 void RemoveTextNode( SwTextNode& rTextNode );
185
186 SwNumRule::tParagraphStyleList::size_type GetParagraphStyleListSize() const;
187 void AddParagraphStyle( SwTextFormatColl& rTextFormatColl );
188 void RemoveParagraphStyle( SwTextFormatColl& rTextFormatColl );
189
190 void SetDefaultListId( const OUString& sDefaultListId )
191 {
192 msDefaultListId = sDefaultListId;
193 }
194 const OUString& GetDefaultListId() const
195 {
196 return msDefaultListId;
197 }
203 void SetNumRuleMap(
204 std::unordered_map<OUString, SwNumRule *>* pNumRuleMap );
205
206 static OUString GetOutlineRuleName();
207
208 static sal_uInt16 GetNumIndent( sal_uInt8 nLvl );
209 static sal_uInt16 GetBullIndent( sal_uInt8 nLvl );
210
211 SwNumRuleType GetRuleType() const { return meRuleType; }
212 void SetRuleType( SwNumRuleType eNew ) { meRuleType = eNew;
213 mbInvalidRuleFlag = true; }
214
218 SwNumRule& CopyNumRule( SwDoc&, const SwNumRule& );
219
222 void CheckCharFormats( SwDoc& rDoc );
223
224 const OUString& GetName() const { return msName; }
225
226 void SetName( const OUString& rNm,
227 IDocumentListsAccess& rDocListAccess );
228
229 bool IsAutoRule() const { return mbAutoRuleFlag; }
230 void SetAutoRule( bool bFlag ) { mbAutoRuleFlag = bFlag; }
231
232 bool IsInvalidRule() const { return mbInvalidRuleFlag; }
233 void SetInvalidRule( bool bFlag );
234
235 bool IsContinusNum() const { return mbContinusNum; }
236 void SetContinusNum( bool bFlag ) { mbContinusNum = bFlag; }
237
238 bool IsAbsSpaces() const { return mbAbsSpaces; }
239 void SetAbsSpaces( bool bFlag ) { mbAbsSpaces = bFlag; }
240
241 bool IsOutlineRule() const { return meRuleType == OUTLINE_RULE; }
242
243 bool IsCountPhantoms() const { return mbCountPhantoms; }
244 void SetCountPhantoms(bool bCountPhantoms);
245
246 bool IsUsedByRedline() const { return mbUsedByRedline; }
247 void SetUsedByRedline(bool bUsed ) { mbUsedByRedline = bUsed; }
248
250 sal_uInt16 GetPoolFormatId() const { return mnPoolFormatId; }
251 void SetPoolFormatId( sal_uInt16 nId ) { mnPoolFormatId = nId; }
252
254 sal_uInt16 GetPoolHelpId() const { return mnPoolHelpId; }
255 void SetPoolHelpId( sal_uInt16 nId ) { mnPoolHelpId = nId; }
256 sal_uInt8 GetPoolHlpFileId() const { return mnPoolHlpFileId; }
257 void SetPoolHlpFileId( sal_uInt8 nId ) { mnPoolHlpFileId = nId; }
258
259 void SetSvxRule(const SvxNumRule&, SwDoc* pDoc);
260 SvxNumRule MakeSvxNumRule() const;
261
263 void ChangeIndent( const sal_Int32 nDiff );
265 void SetIndent( const short nNewIndent,
266 const sal_uInt16 nListLevel );
269 void SetIndentOfFirstListLevelAndChangeOthers( const short nNewIndent );
270
271 void Validate(const SwDoc& rDoc);
272 void dumpAsXml(xmlTextWriterPtr w) const;
273 void GetGrabBagItem(css::uno::Any& rVal) const;
274 void SetGrabBagItem(const css::uno::Any& rVal);
275};
276
278namespace numfunc
279{
281 OUString const & GetDefBulletFontname();
282
288
291
294
301
307 bool NumDownChangesIndent(const SwWrtShell& rShell);
308
310}
311
312#endif // INCLUDED_SW_INC_NUMRULE_HXX
313
314/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides access to the lists of a document.
virtual void SetGraphicBrush(const SvxBrushItem *pBrushItem, const Size *pSize=nullptr, const sal_Int16 *pOrient=nullptr)
bool operator==(const SvxNumberFormat &) const
virtual OUString GetCharFormatName() const
void SetCharFormatName(const OUString &rSet)
SvxNumberFormat & operator=(const SvxNumberFormat &)
void dumpAsXml(xmlTextWriterPtr w) const
Represents the style of a text portion.
Definition: charfmt.hxx:27
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:166
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: calbck.cxx:120
Definition: doc.hxx:197
Defines the vertical position of a fly frame.
Definition: fmtornt.hxx:37
SwCharFormat * GetCharFormat() const
Definition: numrule.hxx:74
sal_Unicode m_cGrfBulletCP
Definition: numrule.hxx:54
void SetGrfBulletCP(sal_Unicode cP)
Definition: numrule.hxx:81
sal_Unicode GetGrfBulletCP() const
Definition: numrule.hxx:82
bool operator!=(const SwNumFormat &r) const
Definition: numrule.hxx:72
SwFormatVertOrient m_aVertOrient
Definition: numrule.hxx:52
sal_uInt16 mnPoolFormatId
Id-for NumRules created "automatically".
Definition: numrule.hxx:128
void SetUsedByRedline(bool bUsed)
Definition: numrule.hxx:247
void SetAutoRule(bool bFlag)
Definition: numrule.hxx:230
bool IsAutoRule() const
Definition: numrule.hxx:229
void SetRuleType(SwNumRuleType eNew)
Definition: numrule.hxx:212
sal_uInt16 mnPoolHelpId
HelpId for this Pool-style.
Definition: numrule.hxx:129
SvxNumberFormat::SvxNumPositionAndSpaceMode meDefaultNumberFormatPositionAndSpaceMode
it needs to export as part of tracked numbering change
Definition: numrule.hxx:139
sal_uInt8 GetPoolHlpFileId() const
Definition: numrule.hxx:256
void SetAbsSpaces(bool bFlag)
Definition: numrule.hxx:239
std::vector< SwTextFormatColl * > tParagraphStyleList
Definition: numrule.hxx:98
bool IsCountPhantoms() const
Definition: numrule.hxx:243
bool IsUsedByRedline() const
Definition: numrule.hxx:246
bool IsOutlineRule() const
Definition: numrule.hxx:241
bool mbAutoRuleFlag
Definition: numrule.hxx:131
void SetHidden(bool bValue)
Definition: numrule.hxx:162
void SetPoolHelpId(sal_uInt16 nId)
Definition: numrule.hxx:255
bool IsContinusNum() const
Definition: numrule.hxx:235
bool operator!=(const SwNumRule &r) const
Definition: numrule.hxx:154
bool mbContinusNum
Continuous numbering without levels.
Definition: numrule.hxx:133
const OUString & GetDefaultListId() const
Definition: numrule.hxx:194
bool IsInvalidRule() const
Definition: numrule.hxx:232
void SetDefaultListId(const OUString &sDefaultListId)
Definition: numrule.hxx:190
const OUString & GetName() const
Definition: numrule.hxx:224
bool IsHidden() const
Definition: numrule.hxx:161
sal_uInt16 GetPoolFormatId() const
Query and set PoolFormat IDs.
Definition: numrule.hxx:250
void SetPoolHlpFileId(sal_uInt8 nId)
Definition: numrule.hxx:257
static sal_uInt16 snRefCount
Definition: numrule.hxx:113
std::unordered_map< OUString, SwNumRule * > * mpNumRuleMap
unordered_map containing "name->rule" relation
Definition: numrule.hxx:124
std::vector< SwTextNode * > tTextNodeList
Definition: numrule.hxx:97
void SetPoolFormatId(sal_uInt16 nId)
Definition: numrule.hxx:251
void SetContinusNum(bool bFlag)
Definition: numrule.hxx:236
sal_uInt8 mnPoolHlpFileId
FilePos at Doc on style helps.
Definition: numrule.hxx:130
bool IsAbsSpaces() const
Definition: numrule.hxx:238
OUString msName
Definition: numrule.hxx:126
SwNumRuleType GetRuleType() const
Definition: numrule.hxx:211
OUString msDefaultListId
Definition: numrule.hxx:140
tParagraphStyleList maParagraphStyleList
container for associated paragraph styles
Definition: numrule.hxx:121
bool mbHidden
Is the numbering rule to be hidden in the UI?
Definition: numrule.hxx:135
bool mbCountPhantoms
Definition: numrule.hxx:136
sal_uInt16 GetPoolHelpId() const
Query and set Help-IDs for document styles.
Definition: numrule.hxx:254
SwNumRuleType meRuleType
Definition: numrule.hxx:127
bool mbAbsSpaces
Levels represent absolute indents.
Definition: numrule.hxx:134
tTextNodeList maTextNodeList
container for associated text nodes
Definition: numrule.hxx:118
bool mbInvalidRuleFlag
Definition: numrule.hxx:132
bool mbUsedByRedline
Definition: numrule.hxx:137
std::shared_ptr< SfxGrabBagItem > mpGrabBagItem
Style InteropGrabBag.
Definition: numrule.hxx:141
Represents the style of a paragraph.
Definition: fmtcol.hxx:61
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
struct _xmlTextWriter * xmlTextWriterPtr
void FinitCore()
Definition: init.cxx:684
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
std::vector< tSwNumTreeNumber > tNumberVector
namespace for static functions and methods for numbering and bullets
Definition: number.cxx:1157
bool IsDefBulletFontUserDefined()
determine if default bullet font is user defined
Definition: number.cxx:1367
SvxNumberFormat::SvxNumPositionAndSpaceMode GetDefaultPositionAndSpaceMode()
Definition: number.cxx:1538
bool ChangeIndentOnTabAtFirstPosOfFirstListItem()
configuration, if at first position of the first list item the <TAB>-key increased the indent of the ...
Definition: number.cxx:1489
sal_Unicode GetBulletChar(sal_uInt8 nLevel)
retrieve unicode of character used for the default bullet list for the given list level
Definition: number.cxx:1377
bool NumDownChangesIndent(const SwWrtShell &rShell)
Decides if increasing ("downing") the numbering level will change the amount of indentation or not.
Definition: number.cxx:1494
OUString const & GetDefBulletFontname()
retrieve font family name used for the default bullet list characters
Definition: number.cxx:1362
const vcl::Font & GetDefBulletFont()
retrieve font used for the default bullet list characters
Definition: number.cxx:1372
const sal_Unicode cBulletChar
Character for lists.
Definition: numrule.hxx:48
SwNumRuleType
Definition: numrule.hxx:92
@ OUTLINE_RULE
Definition: numrule.hxx:92
@ NUM_RULE
Definition: numrule.hxx:92
@ RULE_END
Definition: numrule.hxx:92
sal_Int16 nId
static LanguageType nLang
Definition: srtdlg.cxx:51
sal_uInt16 nSuffixChars
Definition: numrule.hxx:103
sal_uInt16 nPrefixChars
Definition: numrule.hxx:102
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:92
OUString msName
unsigned char sal_uInt8
sal_uInt16 sal_Unicode