LibreOffice Module editeng (master) 1
numitem.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_EDITENG_NUMITEM_HXX
20#define INCLUDED_EDITENG_NUMITEM_HXX
21
22#include <rtl/ustring.hxx>
23#include <svl/poolitem.hxx>
24#include <editeng/svxenum.hxx>
25#include <tools/gen.hxx>
26#include <editeng/numdef.hxx>
27#include <tools/color.hxx>
28#include <com/sun/star/style/NumberingType.hpp>
29#include <unotools/fontcvt.hxx>
32#include <vcl/vclenum.hxx>
33#include <vcl/font.hxx>
34#include <memory>
35#include <optional>
36#include <algorithm>
37
38class SvxBrushItem;
39class Graphic;
40class SvxNodeNum;
41namespace com::sun::star::text { class XNumberingFormatter; }
42
43namespace com::sun::star::lang { struct Locale; }
44
45
46#define SVX_NO_NUM 200 // Marker for no numbering
47#define SVX_NO_NUMLEVEL 0x20
48#define SVX_NUM_REL_SIZE_MIN 25 // Lower limit for numbering relative size
49
50
51#define LINK_TOKEN 0x80 //indicate linked bitmaps - for use in dialog only
52
53typedef struct _xmlTextWriter* xmlTextWriterPtr;
54
56{
57 static sal_Int32 nRefCount;
58 static css::uno::Reference<css::text::XNumberingFormatter> xFormatter;
59
61 bool bShowSymbol; // Also show Symbol ?
62
63public:
64 explicit SvxNumberType(SvxNumType nType = SVX_NUM_ARABIC);
65 SvxNumberType(const SvxNumberType& rType);
67 SvxNumberType & operator =(SvxNumberType const &) = default;
68
69 OUString GetNumStr( sal_Int32 nNo ) const;
70 OUString GetNumStr( sal_Int32 nNo, const css::lang::Locale& rLocale, bool bIsLegal = false ) const;
71
74
75 void SetShowSymbol(bool bSet) {bShowSymbol = bSet;}
76 bool IsShowSymbol()const{return bShowSymbol;}
77
78 bool IsTextFormat() const
79 {
80 return css::style::NumberingType::NUMBER_NONE != nNumType &&
81 css::style::NumberingType::CHAR_SPECIAL != nNumType &&
82 css::style::NumberingType::BITMAP != nNumType;
83 }
84
85 void dumpAsXml(xmlTextWriterPtr w) const;
86};
87
89{
90public:
92 {
94 LABEL_ALIGNMENT
95 };
97 {
101 NEWLINE
102 };
103
104private:
105 OUString sPrefix;
106 OUString sSuffix;
107 std::optional<OUString> sListFormat; // Format string ">%1.%2<" can be used instead of prefix/suffix
108 // Right now it is optional value to distinguish empty list format
109 // and not set list format when we need to fallback to prefix/suffix.
110
112
113 sal_uInt8 nInclUpperLevels; // Take over numbers from the previous level.
114 sal_uInt16 nStart; // Start of counting
115
116 sal_UCS4 cBullet; // Symbol
117 sal_uInt16 nBulletRelSize; // percentage size of bullets
118 Color nBulletColor; // Bullet color
119
120 // mode indicating, if the position and spacing of the list label is
121 // determined by the former attributes (nFirstLineOffset, nAbsLSpace
122 // and nCharTextDistance) called position and spacing via label
123 // width and position (LABEL_WIDTH_AND_POSITION) or by the new attributes
124 // (meLabelFollowedBy, mnListtabPos, mnFirstLineIndent and mnIndentAt)
125 // called position and spacing via label alignment.
126 // Note 1: Attribute <eNumAdjust> is relevant for both modes.
127 // Note 2: The values of the former attributes are treated as 0, if mode
128 // LABEL_ALIGNMENT is active.
130
131 sal_Int32 nFirstLineOffset; // First line indent
132 sal_Int32 nAbsLSpace; // Distance Border<->Number
133 short nCharTextDistance; // Distance Number<->Text
134
135 // specifies what follows the list label before the text of the first line
136 // of the list item starts
138 // specifies an additional list tab stop position for meLabelFollowedBy = LISTTAB
140 // specifies the first line indent
142 // specifies the indent before the text, e.g. in L2R-layout the left margin
144
145 std::unique_ptr<SvxBrushItem>
147 sal_Int16 eVertOrient; // vertical alignment of a bitmap
148
149 Size aGraphicSize; // Always! in 1/100 mm
150 std::optional<vcl::Font>
151 pBulletFont; // Pointer to the bullet font
152
153 OUString sCharStyleName; // Character Style
154
155 bool mbIsLegal = false; // "Legal" level numbering = all levels use arabic numbering
156
157public:
158 explicit SvxNumberFormat( SvxNumType nNumberingType );
159 SvxNumberFormat(const SvxNumberFormat& rFormat);
160 SvxNumberFormat( SvStream & rStream );
161
162 virtual ~SvxNumberFormat();
163
164 void Store(SvStream &rStream, FontToSubsFontConverter pConverter);
165
166 SvxNumberFormat& operator=( const SvxNumberFormat& );
167 bool operator==( const SvxNumberFormat& ) const;
168 bool operator!=( const SvxNumberFormat& rFmt) const {return !(*this == rFmt);}
169
170 void SetNumAdjust(SvxAdjust eSet) {eNumAdjust = eSet;}
171 SvxAdjust GetNumAdjust() const {return eNumAdjust;}
172 void SetPrefix(const OUString& rSet);
173 const OUString& GetPrefix() const { return sPrefix;}
174 void SetSuffix(const OUString& rSet);
175 const OUString& GetSuffix() const { return sSuffix;}
176 // Based on prefix and suffix initialize them (for backward compatibility) and generate listformat string
177 void SetListFormat(const OUString& rPrefix, const OUString& rSuffix, int nLevel);
178 void SetListFormat(std::optional<OUString> oSet = std::nullopt);
179 bool HasListFormat() const { return sListFormat.has_value(); }
180 OUString GetListFormat(bool bIncludePrefixSuffix = true) const;
181
182 void SetCharFormatName(const OUString& rSet){ sCharStyleName = rSet; }
183 virtual OUString GetCharFormatName()const;
184
185 void SetBulletFont(const vcl::Font* pFont);
186 const std::optional<vcl::Font>& GetBulletFont() const { return pBulletFont; }
187 void SetBulletChar(sal_UCS4 cSet){cBullet = cSet;}
188 sal_UCS4 GetBulletChar()const {return cBullet;}
189 void SetBulletRelSize(sal_uInt16 nSet) {nBulletRelSize = std::max(nSet,sal_uInt16(SVX_NUM_REL_SIZE_MIN));}
190 sal_uInt16 GetBulletRelSize() const { return nBulletRelSize;}
191 void SetBulletColor(Color nSet){nBulletColor = nSet;}
192 const Color& GetBulletColor()const {return nBulletColor;}
193
194 void SetIncludeUpperLevels( sal_uInt8 nSet ) { nInclUpperLevels = nSet;}
195 sal_uInt8 GetIncludeUpperLevels()const { return nInclUpperLevels;}
196 void SetStart(sal_uInt16 nSet) {nStart = nSet;}
197 sal_uInt16 GetStart() const {return nStart;}
198
199 virtual void SetGraphicBrush( const SvxBrushItem* pBrushItem, const Size* pSize = nullptr, const sal_Int16* pOrient = nullptr);
200 const SvxBrushItem* GetBrush() const {return pGraphicBrush.get();}
201 void SetGraphic( const OUString& rName );
202 sal_Int16 GetVertOrient() const;
203 void SetGraphicSize(const Size& rSet) {aGraphicSize = rSet;}
204 const Size& GetGraphicSize() const {return aGraphicSize;}
205
206 SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const { return mePositionAndSpaceMode;}
207 void SetPositionAndSpaceMode( SvxNumPositionAndSpaceMode ePositionAndSpaceMode );
208
209 void SetAbsLSpace(sal_Int32 nSet) {nAbsLSpace = nSet;}
210 sal_Int32 GetAbsLSpace() const;
211 void SetFirstLineOffset(sal_Int32 nSet) { nFirstLineOffset = nSet;}
212 sal_Int32 GetFirstLineOffset() const;
213 void SetCharTextDistance(short nSet) { nCharTextDistance = nSet; }
214 short GetCharTextDistance() const;
215
216 void SetLabelFollowedBy( const LabelFollowedBy eLabelFollowedBy );
217 LabelFollowedBy GetLabelFollowedBy() const { return meLabelFollowedBy;}
218 OUString GetLabelFollowedByAsString() const;
219 void SetListtabPos( const tools::Long nListtabPos );
220 tools::Long GetListtabPos() const { return mnListtabPos;}
221 void SetFirstLineIndent( const tools::Long nFirstLineIndent );
222 tools::Long GetFirstLineIndent() const { return mnFirstLineIndent;}
223 void SetIndentAt( const tools::Long nIndentAt );
224 tools::Long GetIndentAt() const { return mnIndentAt;}
225
226 static Size GetGraphicSizeMM100(const Graphic* pGraphic);
227 static OUString CreateRomanString( sal_Int32 nNo, bool bUpper );
228
229 bool GetIsLegal() const { return mbIsLegal; }
230 void SetIsLegal(bool val) { mbIsLegal = val; }
231};
232
233//Feature-Flags (only sal_uInt16!)
234enum class SvxNumRuleFlags : sal_uInt16
235{
236 NONE = 0x0000,
237 CONTINUOUS = 0x0001, // consecutive numbers possible?
238 CHAR_STYLE = 0x0004, // Character styles?
239 BULLET_REL_SIZE = 0x0008, // relative bullet size?
240 BULLET_COLOR = 0x0010, // Bullet color
241 NO_NUMBERS = 0x0080, // Numbering are not allowed
242 ENABLE_LINKED_BMP = 0x0100, // linked bitmaps are available
243 ENABLE_EMBEDDED_BMP = 0x0200 // embedded bitmaps are available
244};
245namespace o3tl
246{
247 template<> struct typed_flags<SvxNumRuleFlags> : is_typed_flags<SvxNumRuleFlags, 0x039d> {};
248}
249
251{
252 NUMBERING,
255};
256
258{
259 std::unique_ptr<SvxNumberFormat> aFmts[SVX_MAX_NUM];
260 sal_uInt16 nLevelCount; // Number of supported levels
261 SvxNumRuleFlags nFeatureFlags; // What is supported?
262 SvxNumRuleType eNumberingType; // Type of numbering
263 bool bContinuousNumbering; // sequential numbering
264 bool aFmtsSet[SVX_MAX_NUM]; // Flags indicating valid levels
265
266 static sal_Int32 nRefCount;
267public:
268 SvxNumRule( SvxNumRuleFlags nFeatures,
269 sal_uInt16 nLevels,
270 bool bCont,
273 eDefaultNumberFormatPositionAndSpaceMode
275 SvxNumRule(const SvxNumRule& rCopy);
276 SvxNumRule(SvxNumRule&&) noexcept;
277 SvxNumRule(SvStream &rStream);
278 ~SvxNumRule();
279
280 bool operator==( const SvxNumRule& ) const;
281 bool operator!=( const SvxNumRule& rRule ) const {return !(*this == rRule);}
282
283 SvxNumRule& operator=( const SvxNumRule& );
284 SvxNumRule& operator=( SvxNumRule&& ) noexcept;
285
286 void Store(SvStream &rStream);
287 void dumpAsXml(xmlTextWriterPtr pWriter) const;
288 const SvxNumberFormat* Get(sal_uInt16 nLevel)const;
289 const SvxNumberFormat& GetLevel(sal_uInt16 nLevel)const;
290 void SetLevel(sal_uInt16 nLevel, const SvxNumberFormat& rFmt, bool bIsValid = true);
291 void SetLevel(sal_uInt16 nLevel, const SvxNumberFormat* pFmt);
292
293 bool IsContinuousNumbering()const
294 {return bContinuousNumbering;}
296 {bContinuousNumbering = bSet;}
297
298 sal_uInt16 GetLevelCount() const {return nLevelCount;}
300 { return bool(nFeatureFlags & nFeature); }
301 SvxNumRuleFlags GetFeatureFlags() const {return nFeatureFlags;}
302 void SetFeatureFlag( SvxNumRuleFlags nFlag, bool bSet = true ) { if(bSet) nFeatureFlags |= nFlag; else nFeatureFlags &= ~nFlag; }
303
304 OUString MakeNumString( const SvxNodeNum& ) const;
305
306 SvxNumRuleType GetNumRuleType() const { return eNumberingType; }
307
308 void UnLinkGraphics();
309};
310
312{
314public:
315 explicit SvxNumBulletItem(SvxNumRule const & rRule);
316 explicit SvxNumBulletItem(SvxNumRule && rRule);
317 SvxNumBulletItem(SvxNumRule const & rRule, sal_uInt16 nWhich );
318 SvxNumBulletItem(SvxNumRule && rRule, sal_uInt16 nWhich );
320 virtual ~SvxNumBulletItem() override;
321
322 virtual SvxNumBulletItem* Clone( SfxItemPool *pPool = nullptr ) const override;
323 virtual bool operator==( const SfxPoolItem& ) const override;
324
325 const SvxNumRule& GetNumRule() const { return maNumRule; }
326 SvxNumRule& GetNumRule() { return maNumRule; }
327
328 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
329 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
330 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
331};
332
334{
335 sal_uInt16 nLevelVal[ SVX_MAX_NUM ] = {}; // Numbers of all levels
336 sal_uInt8 nMyLevel = 0; // Current Level
337
338public:
339 explicit inline SvxNodeNum() = default;
340 inline SvxNodeNum& operator=( const SvxNodeNum& rCpy );
341
342 sal_uInt8 GetLevel() const { return nMyLevel; }
343 void SetLevel( sal_uInt8 nVal ) { nMyLevel = nVal; }
344
345 const sal_uInt16* GetLevelVal() const { return nLevelVal; }
346 sal_uInt16* GetLevelVal() { return nLevelVal; }
347};
348
350{
351 if ( &rCpy != this)
352 {
353 nMyLevel = rCpy.nMyLevel;
354
355 memcpy( nLevelVal, rCpy.nLevelVal, sizeof( nLevelVal ) );
356 }
357 return *this;
358}
359
360SvxNumRule SvxConvertNumRule( const SvxNumRule& rRule, sal_uInt16 nLevel, SvxNumRuleType eType );
361
362#endif
363
364/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString sCharStyleName
sal_uInt8 GetLevel() const
Definition: numitem.hxx:342
sal_uInt16 nLevelVal[SVX_MAX_NUM]
Definition: numitem.hxx:335
SvxNodeNum & operator=(const SvxNodeNum &rCpy)
Definition: numitem.hxx:349
SvxNodeNum()=default
void SetLevel(sal_uInt8 nVal)
Definition: numitem.hxx:343
const sal_uInt16 * GetLevelVal() const
Definition: numitem.hxx:345
sal_uInt16 * GetLevelVal()
Definition: numitem.hxx:346
sal_uInt8 nMyLevel
Definition: numitem.hxx:336
SvxNumRule & GetNumRule()
Definition: numitem.hxx:326
SvxNumRule maNumRule
Definition: numitem.hxx:313
const SvxNumRule & GetNumRule() const
Definition: numitem.hxx:325
sal_uInt16 GetLevelCount() const
Definition: numitem.hxx:298
SvxNumRuleFlags GetFeatureFlags() const
Definition: numitem.hxx:301
void SetContinuousNumbering(bool bSet)
Definition: numitem.hxx:295
static sal_Int32 nRefCount
Definition: numitem.hxx:266
SvxNumRuleType GetNumRuleType() const
Definition: numitem.hxx:306
SvxNumRuleType eNumberingType
Definition: numitem.hxx:262
bool bContinuousNumbering
Definition: numitem.hxx:263
SvxNumRuleFlags nFeatureFlags
Definition: numitem.hxx:261
bool IsFeatureSupported(SvxNumRuleFlags nFeature) const
Definition: numitem.hxx:299
sal_uInt16 nLevelCount
Definition: numitem.hxx:260
void SetFeatureFlag(SvxNumRuleFlags nFlag, bool bSet=true)
Definition: numitem.hxx:302
std::optional< OUString > sListFormat
Definition: numitem.hxx:107
void SetStart(sal_uInt16 nSet)
Definition: numitem.hxx:196
tools::Long GetIndentAt() const
Definition: numitem.hxx:224
void SetAbsLSpace(sal_Int32 nSet)
Definition: numitem.hxx:209
OUString sSuffix
Definition: numitem.hxx:106
sal_uInt8 GetIncludeUpperLevels() const
Definition: numitem.hxx:195
const SvxBrushItem * GetBrush() const
Definition: numitem.hxx:200
sal_uInt16 nStart
Definition: numitem.hxx:114
const Color & GetBulletColor() const
Definition: numitem.hxx:192
sal_uInt16 GetBulletRelSize() const
Definition: numitem.hxx:190
sal_uInt16 nBulletRelSize
Definition: numitem.hxx:117
sal_Int32 nAbsLSpace
Definition: numitem.hxx:132
void SetGraphicSize(const Size &rSet)
Definition: numitem.hxx:203
tools::Long mnListtabPos
Definition: numitem.hxx:139
tools::Long GetFirstLineIndent() const
Definition: numitem.hxx:222
const std::optional< vcl::Font > & GetBulletFont() const
Definition: numitem.hxx:186
sal_UCS4 GetBulletChar() const
Definition: numitem.hxx:188
void SetCharTextDistance(short nSet)
Definition: numitem.hxx:213
SvxAdjust eNumAdjust
Definition: numitem.hxx:111
const Size & GetGraphicSize() const
Definition: numitem.hxx:204
sal_uInt16 GetStart() const
Definition: numitem.hxx:197
LabelFollowedBy GetLabelFollowedBy() const
Definition: numitem.hxx:217
bool operator!=(const SvxNumberFormat &rFmt) const
Definition: numitem.hxx:168
bool GetIsLegal() const
Definition: numitem.hxx:229
sal_UCS4 cBullet
Definition: numitem.hxx:116
tools::Long mnFirstLineIndent
Definition: numitem.hxx:141
short nCharTextDistance
Definition: numitem.hxx:133
std::unique_ptr< SvxBrushItem > pGraphicBrush
Definition: numitem.hxx:146
void SetBulletColor(Color nSet)
Definition: numitem.hxx:191
tools::Long GetListtabPos() const
Definition: numitem.hxx:220
void SetNumAdjust(SvxAdjust eSet)
Definition: numitem.hxx:170
SvxNumPositionAndSpaceMode
Definition: numitem.hxx:92
@ LABEL_WIDTH_AND_POSITION
Definition: numitem.hxx:93
void SetIsLegal(bool val)
Definition: numitem.hxx:230
void SetBulletRelSize(sal_uInt16 nSet)
Definition: numitem.hxx:189
SvxAdjust GetNumAdjust() const
Definition: numitem.hxx:171
void SetIncludeUpperLevels(sal_uInt8 nSet)
Definition: numitem.hxx:194
Color nBulletColor
Definition: numitem.hxx:118
bool HasListFormat() const
Definition: numitem.hxx:179
sal_Int16 eVertOrient
Definition: numitem.hxx:147
OUString sCharStyleName
Definition: numitem.hxx:153
void SetFirstLineOffset(sal_Int32 nSet)
Definition: numitem.hxx:211
SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const
Definition: numitem.hxx:206
OUString sPrefix
Definition: numitem.hxx:105
sal_Int32 nFirstLineOffset
Definition: numitem.hxx:131
void SetCharFormatName(const OUString &rSet)
Definition: numitem.hxx:182
sal_uInt8 nInclUpperLevels
Definition: numitem.hxx:113
tools::Long mnIndentAt
Definition: numitem.hxx:143
LabelFollowedBy meLabelFollowedBy
Definition: numitem.hxx:137
SvxNumPositionAndSpaceMode mePositionAndSpaceMode
Definition: numitem.hxx:129
void SetBulletChar(sal_UCS4 cSet)
Definition: numitem.hxx:187
const OUString & GetPrefix() const
Definition: numitem.hxx:173
std::optional< vcl::Font > pBulletFont
Definition: numitem.hxx:151
const OUString & GetSuffix() const
Definition: numitem.hxx:175
bool IsTextFormat() const
Definition: numitem.hxx:78
static css::uno::Reference< css::text::XNumberingFormatter > xFormatter
Definition: numitem.hxx:58
bool bShowSymbol
Definition: numitem.hxx:61
bool IsShowSymbol() const
Definition: numitem.hxx:76
SvxNumType nNumType
Definition: numitem.hxx:60
void SetNumberingType(SvxNumType nSet)
Definition: numitem.hxx:72
SvxNumType GetNumberingType() const
Definition: numitem.hxx:73
void SetShowSymbol(bool bSet)
Definition: numitem.hxx:75
static sal_Int32 nRefCount
Definition: numitem.hxx:57
bool operator==(const EditLine &r1, const EditLine &r2)
Definition: editdoc.cxx:978
#define EDITENG_DLLPUBLIC
Definition: editengdllapi.h:28
struct _xmlTextWriter * xmlTextWriterPtr
void * FontToSubsFontConverter
NEWLINE
OUString sPrefix
OUString sSuffix
sal_Int16 nNumType
sal_Int32 nFirstLineOffset
NONE
SvStream & Store(const SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16)
css::uno::Reference< css::animations::XAnimationNode > Clone(const css::uno::Reference< css::animations::XAnimationNode > &xSourceNode, const SdPage *pSource=nullptr, const SdPage *pTarget=nullptr)
long Long
#define SVX_MAX_NUM
Definition: numdef.hxx:23
SvxNumRuleType
Definition: numitem.hxx:251
#define SVX_NUM_REL_SIZE_MIN
Definition: numitem.hxx:48
SvxNumRuleFlags
Definition: numitem.hxx:235
struct _xmlTextWriter * xmlTextWriterPtr
Definition: numitem.hxx:53
SvxNumRule SvxConvertNumRule(const SvxNumRule &rRule, sal_uInt16 nLevel, SvxNumRuleType eType)
Definition: numitem.cxx:1145
static SfxItemSet & rSet
SvxNumType
these must match the values in css::style::NumberingType
Definition: svxenum.hxx:144
@ SVX_NUM_ARABIC
Definition: svxenum.hxx:149
SvxAdjust
Definition: svxenum.hxx:77
unsigned char sal_uInt8
sal_uInt32 sal_UCS4