fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / editeng / numitem.hxx
blob9f88e79de0ecb5cd2c93a8b541865eb8dbdc0cc9
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 _SVX_NUMITEM_HXX
20 #define _SVX_NUMITEM_HXX
22 #include <tools/link.hxx>
23 #include <tools/string.hxx>
24 #include <svl/poolitem.hxx>
25 #include <editeng/svxenum.hxx>
26 #include <tools/gen.hxx>
27 #include <editeng/numdef.hxx>
28 #include <tools/color.hxx>
29 #include <cppuhelper/weakref.hxx>
30 #include <com/sun/star/lang/Locale.hpp>
31 #include <com/sun/star/uno/Reference.h>
32 #include <com/sun/star/style/NumberingType.hpp>
33 #include <unotools/fontcvt.hxx>
34 #include <editeng/editengdllapi.h>
36 class SvxBrushItem;
37 class Font;
38 class Graphic;
39 class SvxNodeNum;
40 namespace com{namespace sun{ namespace star{
41 namespace text{
42 class XNumberingFormatter;
44 }}}
46 // -----------------------------------------------------------------------
47 //Feature-Flags (only sal_uInt16!)
48 #define NUM_CONTINUOUS 0x0001 // consecutive numbers possible?
49 #define NUM_CHAR_TEXT_DISTANCE 0x0002 // Distance Symbol<->Text?
50 #define NUM_CHAR_STYLE 0x0004 // Character styles?
51 #define NUM_BULLET_REL_SIZE 0x0008 // relative bullet size?
52 #define NUM_BULLET_COLOR 0x0010 // Bullet color
53 #define NUM_SYMBOL_ALIGNMENT 0x0040 // alignment to be shown in the options
54 #define NUM_NO_NUMBERS 0x0080 // Numbering are not allowed
55 #define NUM_ENABLE_LINKED_BMP 0x0100 // linked bitmaps are available
56 #define NUM_ENABLE_EMBEDDED_BMP 0x0200 // embedded bitmaps are available
58 #define SVX_NO_NUM 200 // Marker for no numbering
59 #define SVX_NO_NUMLEVEL 0x20
61 #define LINK_TOKEN 0x80 //indicate linked bitmaps - for use in dialog only
62 class EDITENG_DLLPUBLIC SvxNumberType
64 static sal_Int32 nRefCount;
65 static com::sun::star::uno::Reference<com::sun::star::text::XNumberingFormatter> xFormatter;
67 sal_Int16 nNumType;
68 sal_Bool bShowSymbol; // Also show Symbol ?
70 public:
71 explicit SvxNumberType(sal_Int16 nType = com::sun::star::style::NumberingType::ARABIC);
72 SvxNumberType(const SvxNumberType& rType);
73 ~SvxNumberType();
75 String GetNumStr( sal_uLong nNo ) const;
76 String GetNumStr( sal_uLong nNo, const com::sun::star::lang::Locale& rLocale ) const;
78 void SetNumberingType(sal_Int16 nSet) {nNumType = nSet;}
79 sal_Int16 GetNumberingType() const {return nNumType;}
81 void SetShowSymbol(sal_Bool bSet) {bShowSymbol = bSet;}
82 sal_Bool IsShowSymbol()const{return bShowSymbol;}
84 sal_Bool IsTxtFmt() const
86 return com::sun::star::style::NumberingType::NUMBER_NONE != nNumType &&
87 com::sun::star::style::NumberingType::CHAR_SPECIAL != nNumType &&
88 com::sun::star::style::NumberingType::BITMAP != nNumType;
92 class EDITENG_DLLPUBLIC SvxNumberFormat : public SvxNumberType
94 public:
95 enum SvxNumPositionAndSpaceMode
97 LABEL_WIDTH_AND_POSITION,
98 LABEL_ALIGNMENT
100 enum LabelFollowedBy
102 LISTTAB,
103 SPACE,
104 NOTHING
107 private:
108 OUString sPrefix;
109 OUString sSuffix;
111 SvxAdjust eNumAdjust;
113 sal_uInt8 nInclUpperLevels; // Take over numbers from the previous level.
114 sal_uInt16 nStart; // Start of counting
116 sal_Unicode cBullet; // Symbol
117 sal_uInt16 nBulletRelSize; // percentage size of bullets
118 Color nBulletColor; // Bullet color
120 // mode indicating, if the position and spacing of the list label is
121 // determined by the former attributes (nFirstLineOffset, nAbsLSpace,
122 // nLSpace 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.
129 SvxNumPositionAndSpaceMode mePositionAndSpaceMode;
131 short nFirstLineOffset; // First line indent
132 short nAbsLSpace; // Distance Border<->Number
133 short nLSpace; // relative to the previous indentation
134 short nCharTextDistance; // Distance Number<->Text
136 // specifies what follows the list label before the text of the first line
137 // of the list item starts
138 LabelFollowedBy meLabelFollowedBy;
139 // specifies an additional list tab stop position for meLabelFollowedBy = LISTTAB
140 long mnListtabPos;
141 // specifies the first line indent
142 long mnFirstLineIndent;
143 // specifies the indent before the text, e.g. in L2R-layout the left margin
144 long mnIndentAt;
146 SvxBrushItem* pGraphicBrush;
147 sal_Int16 eVertOrient; // vertical alignment of a bitmap
149 Size aGraphicSize; // Always! in 1/100 mm
150 Font* pBulletFont; // Pointer to the bullet font
152 String sCharStyleName; // Character Style
154 DECL_STATIC_LINK( SvxNumberFormat, GraphicArrived, void * );
155 virtual void NotifyGraphicArrived();
156 public:
157 explicit SvxNumberFormat( sal_Int16 nNumberingType,
158 SvxNumPositionAndSpaceMode ePositionAndSpaceMode = LABEL_WIDTH_AND_POSITION );
159 SvxNumberFormat(const SvxNumberFormat& rFormat);
160 SvxNumberFormat( SvStream & rStream );
162 virtual ~SvxNumberFormat();
164 SvStream& Store(SvStream &rStream, FontToSubsFontConverter pConverter);
165 SvxNumberFormat* Create(SvStream& rStream );
167 SvxNumberFormat& operator=( const SvxNumberFormat& );
168 sal_Bool operator==( const SvxNumberFormat& ) const;
169 sal_Bool operator!=( const SvxNumberFormat& rFmt) const {return !(*this == rFmt);}
171 void SetNumAdjust(SvxAdjust eSet) {eNumAdjust = eSet;}
172 SvxAdjust GetNumAdjust() const {return eNumAdjust;}
173 void SetPrefix(const OUString& rSet) { sPrefix = rSet;}
174 const OUString& GetPrefix() const { return sPrefix;}
175 void SetSuffix(const OUString& rSet) { sSuffix = rSet;}
176 const OUString& GetSuffix() const { return sSuffix;}
178 void SetCharFmtName(const String& rSet){ sCharStyleName = rSet; }
179 virtual const String& GetCharFmtName()const;
181 void SetBulletFont(const Font* pFont);
182 const Font* GetBulletFont() const {return pBulletFont;}
183 void SetBulletChar(sal_Unicode cSet){cBullet = cSet;}
184 sal_Unicode GetBulletChar()const {return cBullet;}
185 void SetBulletRelSize(sal_uInt16 nSet) {nBulletRelSize = nSet;}
186 sal_uInt16 GetBulletRelSize() const { return nBulletRelSize;}
187 void SetBulletColor(Color nSet){nBulletColor = nSet;}
188 Color GetBulletColor()const {return nBulletColor;}
190 void SetIncludeUpperLevels( sal_uInt8 nSet ) { nInclUpperLevels = nSet;}
191 sal_uInt8 GetIncludeUpperLevels()const { return nInclUpperLevels;}
192 void SetStart(sal_uInt16 nSet) {nStart = nSet;}
193 sal_uInt16 GetStart() const {return nStart;}
195 virtual void SetGraphicBrush( const SvxBrushItem* pBrushItem, const Size* pSize = 0, const sal_Int16* pOrient = 0);
196 const SvxBrushItem* GetBrush() const {return pGraphicBrush;}
197 void SetGraphic( const String& rName );
198 virtual void SetVertOrient(sal_Int16 eSet);
199 virtual sal_Int16 GetVertOrient() const;
200 void SetGraphicSize(const Size& rSet) {aGraphicSize = rSet;}
201 const Size& GetGraphicSize() const {return aGraphicSize;}
203 SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const;
204 void SetPositionAndSpaceMode( SvxNumPositionAndSpaceMode ePositionAndSpaceMode );
206 void SetLSpace(short nSet) {nLSpace = nSet;}
207 short GetLSpace() const;
208 void SetAbsLSpace(short nSet) {nAbsLSpace = nSet;}
209 short GetAbsLSpace() const;
210 void SetFirstLineOffset(short nSet) { nFirstLineOffset = nSet;}
211 short GetFirstLineOffset() const;
212 void SetCharTextDistance(short nSet) { nCharTextDistance = nSet; }
213 short GetCharTextDistance() const;
215 void SetLabelFollowedBy( const LabelFollowedBy eLabelFollowedBy );
216 LabelFollowedBy GetLabelFollowedBy() const;
217 void SetListtabPos( const long nListtabPos );
218 long GetListtabPos() const;
219 void SetFirstLineIndent( const long nFirstLineIndent );
220 long GetFirstLineIndent() const;
221 void SetIndentAt( const long nIndentAt );
222 long GetIndentAt() const;
224 static Size GetGraphicSizeMM100(const Graphic* pGraphic);
225 static String CreateRomanString( sal_uLong nNo, sal_Bool bUpper );
228 enum SvxNumRuleType
230 SVX_RULETYPE_NUMBERING,
231 SVX_RULETYPE_OUTLINE_NUMBERING,
232 SVX_RULETYPE_PRESENTATION_NUMBERING,
233 SVX_RULETYPE_END
236 class EDITENG_DLLPUBLIC SvxNumRule
238 sal_uInt16 nLevelCount; // Number of supported levels
239 sal_uInt32 nFeatureFlags; // What is supported?
240 SvxNumRuleType eNumberingType; // Type of numbering
241 sal_Bool bContinuousNumbering; // sequential numbering
243 SvxNumberFormat* aFmts[SVX_MAX_NUM];
244 sal_Bool aFmtsSet[SVX_MAX_NUM]; // Flags indicating valid levels
246 static sal_Int32 nRefCount;
247 com::sun::star::lang::Locale aLocale;
248 public:
249 SvxNumRule( sal_uLong nFeatures,
250 sal_uInt16 nLevels,
251 sal_Bool bCont,
252 SvxNumRuleType eType = SVX_RULETYPE_NUMBERING,
253 SvxNumberFormat::SvxNumPositionAndSpaceMode
254 eDefaultNumberFormatPositionAndSpaceMode
255 = SvxNumberFormat::LABEL_WIDTH_AND_POSITION );
256 SvxNumRule(const SvxNumRule& rCopy);
257 SvxNumRule(SvStream &rStream);
258 virtual ~SvxNumRule();
260 int operator==( const SvxNumRule& ) const;
261 int operator!=( const SvxNumRule& rRule ) const {return !(*this == rRule);}
263 SvxNumRule& operator=( const SvxNumRule& );
265 SvStream& Store(SvStream &rStream);
266 SvxNumRule* Create(SvStream &rStream);
267 const SvxNumberFormat* Get(sal_uInt16 nLevel)const;
268 const SvxNumberFormat& GetLevel(sal_uInt16 nLevel)const;
269 void SetLevel(sal_uInt16 nLevel, const SvxNumberFormat& rFmt, sal_Bool bIsValid = sal_True);
270 void SetLevel(sal_uInt16 nLevel, const SvxNumberFormat* pFmt);
272 sal_Bool IsContinuousNumbering()const
273 {return bContinuousNumbering;}
274 void SetContinuousNumbering(sal_Bool bSet)
275 {bContinuousNumbering = bSet;}
277 sal_uInt16 GetLevelCount() const {return nLevelCount;}
278 sal_Bool IsFeatureSupported(sal_uInt32 nFeature) const
279 {return 0 != (nFeatureFlags & nFeature);}
280 sal_uInt32 GetFeatureFlags() const {return nFeatureFlags;}
281 void SetFeatureFlag( sal_uInt32 nFlag, sal_Bool bSet = sal_True ) { if(bSet) nFeatureFlags |= nFlag; else nFeatureFlags &= ~nFlag; }
283 String MakeNumString( const SvxNodeNum&, sal_Bool bInclStrings = sal_True ) const;
285 SvxNumRuleType GetNumRuleType() const { return eNumberingType; }
286 void SetNumRuleType( const SvxNumRuleType& rType ) { eNumberingType = rType; }
288 sal_Bool UnLinkGraphics();
291 class EDITENG_DLLPUBLIC SvxNumBulletItem : public SfxPoolItem
293 SvxNumRule* pNumRule;
294 public:
295 explicit SvxNumBulletItem(SvxNumRule& rRule);
296 SvxNumBulletItem(SvxNumRule& rRule, sal_uInt16 nWhich );
297 SvxNumBulletItem(const SvxNumBulletItem& rCopy);
298 virtual ~SvxNumBulletItem();
300 virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
301 virtual SfxPoolItem* Create(SvStream &rStream, sal_uInt16 nItemVersion) const;
302 sal_uInt16 GetVersion( sal_uInt16 nFileVersion ) const;
303 virtual SvStream& Store(SvStream &rStream, sal_uInt16 nItemVersion ) const;
304 virtual int operator==( const SfxPoolItem& ) const;
306 SvxNumRule* GetNumRule() const {return pNumRule;}
308 virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
309 virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
312 class SvxNodeNum
314 sal_uInt16 nLevelVal[ SVX_MAX_NUM ]; // Numbers of all levels
315 sal_uInt16 nSetValue; // predetermined number
316 sal_uInt8 nMyLevel; // Current Level
317 sal_Bool bStartNum; // Restart numbering
319 public:
320 explicit inline SvxNodeNum( sal_uInt8 nLevel = SVX_NO_NUM, sal_uInt16 nSetVal = USHRT_MAX );
321 inline SvxNodeNum& operator=( const SvxNodeNum& rCpy );
323 sal_uInt8 GetLevel() const { return nMyLevel; }
324 void SetLevel( sal_uInt8 nVal ) { nMyLevel = nVal; }
326 sal_Bool IsStart() const { return bStartNum; }
327 void SetStart( sal_Bool bFlag = sal_True ) { bStartNum = bFlag; }
329 sal_uInt16 GetSetValue() const { return nSetValue; }
330 void SetSetValue( sal_uInt16 nVal ) { nSetValue = nVal; }
332 const sal_uInt16* GetLevelVal() const { return nLevelVal; }
333 sal_uInt16* GetLevelVal() { return nLevelVal; }
336 SvxNodeNum::SvxNodeNum( sal_uInt8 nLevel, sal_uInt16 nSetVal )
337 : nSetValue( nSetVal ), nMyLevel( nLevel ), bStartNum( sal_False )
339 memset( nLevelVal, 0, sizeof( nLevelVal ) );
342 inline SvxNodeNum& SvxNodeNum::operator=( const SvxNodeNum& rCpy )
344 nSetValue = rCpy.nSetValue;
345 nMyLevel = rCpy.nMyLevel;
346 bStartNum = rCpy.bStartNum;
348 memcpy( nLevelVal, rCpy.nLevelVal, sizeof( nLevelVal ) );
349 return *this;
352 SvxNumRule* SvxConvertNumRule( const SvxNumRule* pRule, sal_uInt16 nLevel, SvxNumRuleType eType );
354 #endif
356 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */