Teach symstore more duplicated DLLs
[LibreOffice.git] / sw / inc / numrule.hxx
blob6152e6bee99faa443a110ad52260dfb49769c99f
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_NUMRULE_HXX
20 #define INCLUDED_SW_INC_NUMRULE_HXX
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"
36 class SwTextFormatColl;
37 class IDocumentListsAccess;
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;
47 const sal_Unicode cBulletChar = 0x2022; ///< Character for lists.
49 class SW_DLLPUBLIC SwNumFormat final : public SvxNumberFormat, public SwClient
51 std::unique_ptr<SwFormatVertOrient> m_pVertOrient;
52 //For i120928,record the cp info of graphic within bullet
53 sal_Unicode m_cGrfBulletCP;
54 SAL_DLLPRIVATE void UpdateNumNodes( SwDoc* pDoc );
56 using SvxNumberFormat::operator ==;
57 using SvxNumberFormat::operator !=;
59 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) override;
61 public:
62 SwNumFormat();
63 SwNumFormat( const SwNumFormat& );
64 SwNumFormat( const SvxNumberFormat&, SwDoc* pDoc);
66 virtual ~SwNumFormat() override;
68 SwNumFormat& operator=( const SwNumFormat& );
70 bool operator==( const SwNumFormat& ) const;
71 bool operator!=( const SwNumFormat& r ) const { return !(*this == r); }
73 SwCharFormat* GetCharFormat() const { return const_cast<SwCharFormat*>(static_cast<const SwCharFormat*>(GetRegisteredIn())); }
74 void SetCharFormat( SwCharFormat* );
76 using SvxNumberFormat::SetCharFormatName;
77 virtual OUString GetCharFormatName() const override;
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;}
83 virtual void SetGraphicBrush( const SvxBrushItem* pBrushItem, const Size* pSize = nullptr, const sal_Int16* pOrient = nullptr) override;
85 const SwFormatVertOrient* GetGraphicOrientation() const;
87 bool IsEnumeration() const; // #i22362#
88 bool IsItemize() const; // #i29560#
91 enum SwNumRuleType { OUTLINE_RULE = 0, NUM_RULE = 1, RULE_END = 2 };
92 class SW_DLLPUBLIC SwNumRule
95 public:
96 typedef std::vector< SwTextNode* > tTextNodeList;
97 typedef std::vector< SwTextFormatColl* > tParagraphStyleList;
99 struct Extremities
101 sal_uInt16 nPrefixChars;
102 sal_uInt16 nSuffixChars;
105 private:
106 friend void FinitCore();
108 static SwNumFormat* maBaseFormats [ RULE_END ][ MAXLEVEL ];
109 static const sal_uInt16 maDefNumIndents[ MAXLEVEL ];
110 /// default list level properties for position-and-space mode LABEL_ALIGNMENT
111 static SwNumFormat* maLabelAlignmentBaseFormats [ RULE_END ][ MAXLEVEL ];
112 static sal_uInt16 mnRefCount;
114 std::unique_ptr<SwNumFormat> maFormats[ MAXLEVEL ];
116 /** container for associated text nodes */
117 tTextNodeList maTextNodeList;
119 /** container for associated paragraph styles */
120 tParagraphStyleList maParagraphStyleList;
122 /** unordered_map containing "name->rule" relation */
123 std::unordered_map<OUString, SwNumRule *> * mpNumRuleMap;
125 OUString msName;
126 SwNumRuleType meRuleType;
127 sal_uInt16 mnPoolFormatId; ///< Id-for NumRules created "automatically"
128 sal_uInt16 mnPoolHelpId; ///< HelpId for this Pool-style.
129 sal_uInt8 mnPoolHlpFileId; ///< FilePos at Doc on style helps.
130 bool mbAutoRuleFlag : 1;
131 bool mbInvalidRuleFlag : 1;
132 bool mbContinusNum : 1; ///< Continuous numbering without levels.
133 bool mbAbsSpaces : 1; ///< Levels represent absolute indents.
134 bool mbHidden : 1; ///< Is the numbering rule to be hidden in the UI?
135 bool mbCountPhantoms;
136 bool mbUsedByRedline; /// it needs to export as part of tracked numbering change
138 const SvxNumberFormat::SvxNumPositionAndSpaceMode meDefaultNumberFormatPositionAndSpaceMode;
139 OUString msDefaultListId;
140 std::shared_ptr<SfxGrabBagItem> mpGrabBagItem; ///< Style InteropGrabBag.
142 public:
143 /// add parameter <eDefaultNumberFormatPositionAndSpaceMode>
144 SwNumRule( const OUString& rNm,
145 const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode,
146 SwNumRuleType = NUM_RULE );
148 SwNumRule( const SwNumRule& );
149 ~SwNumRule();
151 SwNumRule& operator=( const SwNumRule& );
152 bool operator==( const SwNumRule& ) const;
153 bool operator!=( const SwNumRule& r ) const { return !(*this == r); }
155 const SwNumFormat* GetNumFormat( sal_uInt16 i ) const;
156 const SwNumFormat& Get( sal_uInt16 i ) const;
158 bool IsHidden( ) const { return mbHidden; }
159 void SetHidden( bool bValue ) { mbHidden = bValue; }
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;
164 /** - add optional parameter <_nRestrictToThisLevel> in order to
165 restrict returned string to this level. */
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 OUString MakeParagraphStyleListString() const;
177 /** @return list of associated text nodes */
178 void GetTextNodeList( SwNumRule::tTextNodeList& rTextNodeList ) const;
179 SwNumRule::tTextNodeList::size_type GetTextNodeListSize() const;
181 void AddTextNode( SwTextNode& rTextNode );
182 void RemoveTextNode( SwTextNode& rTextNode );
184 SwNumRule::tParagraphStyleList::size_type GetParagraphStyleListSize() const;
185 void AddParagraphStyle( SwTextFormatColl& rTextFormatColl );
186 void RemoveParagraphStyle( SwTextFormatColl& rTextFormatColl );
188 void SetDefaultListId( const OUString& sDefaultListId )
190 msDefaultListId = sDefaultListId;
192 const OUString& GetDefaultListId() const
194 return msDefaultListId;
197 Register this rule in a "name->numrule" map.
199 @param pNumRuleMap map to register in
201 void SetNumRuleMap(
202 std::unordered_map<OUString, SwNumRule *>* pNumRuleMap );
204 static OUString GetOutlineRuleName();
206 static sal_uInt16 GetNumIndent( sal_uInt8 nLvl );
207 static sal_uInt16 GetBullIndent( sal_uInt8 nLvl );
209 SwNumRuleType GetRuleType() const { return meRuleType; }
210 void SetRuleType( SwNumRuleType eNew ) { meRuleType = eNew;
211 mbInvalidRuleFlag = true; }
213 /** A kind of copy-constructor to make sure the num formats are
214 attached to the correctCharFormats of a document!!
215 (Copies the NumFormats and returns itself). */
216 SwNumRule& CopyNumRule( SwDoc*, const SwNumRule& );
218 /** Tests whether the CharFormats are from the given doc
219 and copies them if appropriate. */
220 void CheckCharFormats( SwDoc* pDoc );
222 const OUString& GetName() const { return msName; }
224 void SetName( const OUString& rNm,
225 IDocumentListsAccess& rDocListAccess );
227 bool IsAutoRule() const { return mbAutoRuleFlag; }
228 void SetAutoRule( bool bFlag ) { mbAutoRuleFlag = bFlag; }
230 bool IsInvalidRule() const { return mbInvalidRuleFlag; }
231 void SetInvalidRule( bool bFlag );
233 bool IsContinusNum() const { return mbContinusNum; }
234 void SetContinusNum( bool bFlag ) { mbContinusNum = bFlag; }
236 bool IsAbsSpaces() const { return mbAbsSpaces; }
237 void SetAbsSpaces( bool bFlag ) { mbAbsSpaces = bFlag; }
239 bool IsOutlineRule() const { return meRuleType == OUTLINE_RULE; }
241 bool IsCountPhantoms() const { return mbCountPhantoms; }
242 void SetCountPhantoms(bool bCountPhantoms);
244 bool IsUsedByRedline() const { return mbUsedByRedline; }
245 void SetUsedByRedline(bool bUsed ) { mbUsedByRedline = bUsed; }
247 /// Query and set PoolFormat IDs.
248 sal_uInt16 GetPoolFormatId() const { return mnPoolFormatId; }
249 void SetPoolFormatId( sal_uInt16 nId ) { mnPoolFormatId = nId; }
251 /// Query and set Help-IDs for document styles.
252 sal_uInt16 GetPoolHelpId() const { return mnPoolHelpId; }
253 void SetPoolHelpId( sal_uInt16 nId ) { mnPoolHelpId = nId; }
254 sal_uInt8 GetPoolHlpFileId() const { return mnPoolHlpFileId; }
255 void SetPoolHlpFileId( sal_uInt8 nId ) { mnPoolHlpFileId = nId; }
257 void SetSvxRule(const SvxNumRule&, SwDoc* pDoc);
258 SvxNumRule MakeSvxNumRule() const;
260 /// change indent of all list levels by given difference
261 void ChangeIndent( const sal_Int32 nDiff );
262 /// set indent of certain list level to given value
263 void SetIndent( const short nNewIndent,
264 const sal_uInt16 nListLevel );
265 /** set indent of first list level to given value and change other list level's
266 indents accordingly */
267 void SetIndentOfFirstListLevelAndChangeOthers( const short nNewIndent );
269 void Validate();
270 void dumpAsXml(xmlTextWriterPtr w) const;
271 void GetGrabBagItem(css::uno::Any& rVal) const;
272 void SetGrabBagItem(const css::uno::Any& rVal);
275 /// namespace for static functions and methods for numbering and bullets
276 namespace numfunc
278 /** retrieve font family name used for the default bullet list characters */
279 OUString const & GetDefBulletFontname();
281 /** determine if default bullet font is user defined
283 The default bullet font is user defined, if it is given in the user configuration
285 bool IsDefBulletFontUserDefined();
287 /** retrieve font used for the default bullet list characters */
288 SW_DLLPUBLIC const vcl::Font& GetDefBulletFont();
290 /** retrieve unicode of character used for the default bullet list for the given list level */
291 sal_Unicode GetBulletChar( sal_uInt8 nLevel );
293 /** configuration, if at first position of the first list item the <TAB>-key
294 increased the indent of the complete list or only demotes this list item.
295 The same for <SHIFT-TAB>-key at the same position for decreasing the
296 indent of the complete list or only promotes this list item.
298 bool ChangeIndentOnTabAtFirstPosOfFirstListItem();
300 SvxNumberFormat::SvxNumPositionAndSpaceMode GetDefaultPositionAndSpaceMode();
303 #endif // INCLUDED_SW_INC_NUMRULE_HXX
305 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */