Line data Source code
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 _SVX_NUMITEM_HXX
20 : #define _SVX_NUMITEM_HXX
21 :
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>
35 :
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;
43 : }
44 : }}}
45 :
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
57 :
58 : #define SVX_NO_NUM 200 // Marker for no numbering
59 : #define SVX_NO_NUMLEVEL 0x20
60 :
61 : #define LINK_TOKEN 0x80 //indicate linked bitmaps - for use in dialog only
62 : class EDITENG_DLLPUBLIC SvxNumberType
63 : {
64 : static sal_Int32 nRefCount;
65 : static com::sun::star::uno::Reference<com::sun::star::text::XNumberingFormatter> xFormatter;
66 :
67 : sal_Int16 nNumType;
68 : sal_Bool bShowSymbol; // Also show Symbol ?
69 :
70 : public:
71 : explicit SvxNumberType(sal_Int16 nType = com::sun::star::style::NumberingType::ARABIC);
72 : SvxNumberType(const SvxNumberType& rType);
73 : ~SvxNumberType();
74 :
75 : String GetNumStr( sal_uLong nNo ) const;
76 : String GetNumStr( sal_uLong nNo, const com::sun::star::lang::Locale& rLocale ) const;
77 :
78 55669 : void SetNumberingType(sal_Int16 nSet) {nNumType = nSet;}
79 143458 : sal_Int16 GetNumberingType() const {return nNumType;}
80 :
81 49917 : void SetShowSymbol(sal_Bool bSet) {bShowSymbol = bSet;}
82 79219 : sal_Bool IsShowSymbol()const{return bShowSymbol;}
83 :
84 69 : sal_Bool IsTxtFmt() const
85 : {
86 : return com::sun::star::style::NumberingType::NUMBER_NONE != nNumType &&
87 : com::sun::star::style::NumberingType::CHAR_SPECIAL != nNumType &&
88 69 : com::sun::star::style::NumberingType::BITMAP != nNumType;
89 : }
90 : };
91 :
92 : class EDITENG_DLLPUBLIC SvxNumberFormat : public SvxNumberType
93 : {
94 : public:
95 : enum SvxNumPositionAndSpaceMode
96 : {
97 : LABEL_WIDTH_AND_POSITION,
98 : LABEL_ALIGNMENT
99 : };
100 : enum LabelFollowedBy
101 : {
102 : LISTTAB,
103 : SPACE,
104 : NOTHING
105 : };
106 :
107 : private:
108 : rtl::OUString sPrefix;
109 : rtl::OUString sSuffix;
110 :
111 : SvxAdjust eNumAdjust;
112 :
113 : sal_uInt8 nInclUpperLevels; // Take over numbers from the previous level.
114 : sal_uInt16 nStart; // Start of counting
115 :
116 : sal_Unicode 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 : // 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;
130 :
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
135 :
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;
145 :
146 : SvxBrushItem* pGraphicBrush;
147 : sal_Int16 eVertOrient; // vertical alignment of a bitmap
148 :
149 : Size aGraphicSize; // Always! in 1/100 mm
150 : Font* pBulletFont; // Pointer to the bullet font
151 :
152 : String sCharStyleName; // Character Style
153 :
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 :
161 : virtual ~SvxNumberFormat();
162 :
163 : SvStream& Store(SvStream &rStream, FontToSubsFontConverter pConverter);
164 :
165 : SvxNumberFormat& operator=( const SvxNumberFormat& );
166 : sal_Bool operator==( const SvxNumberFormat& ) const;
167 10548 : sal_Bool operator!=( const SvxNumberFormat& rFmt) const {return !(*this == rFmt);}
168 :
169 2629 : void SetNumAdjust(SvxAdjust eSet) {eNumAdjust = eSet;}
170 5635 : SvxAdjust GetNumAdjust() const {return eNumAdjust;}
171 811 : void SetPrefix(const rtl::OUString& rSet) { sPrefix = rSet;}
172 10135 : const rtl::OUString& GetPrefix() const { return sPrefix;}
173 3771 : void SetSuffix(const rtl::OUString& rSet) { sSuffix = rSet;}
174 10135 : const rtl::OUString& GetSuffix() const { return sSuffix;}
175 :
176 133 : void SetCharFmtName(const String& rSet){ sCharStyleName = rSet; }
177 : virtual const String& GetCharFmtName()const;
178 :
179 : void SetBulletFont(const Font* pFont);
180 488 : const Font* GetBulletFont() const {return pBulletFont;}
181 4292 : void SetBulletChar(sal_Unicode cSet){cBullet = cSet;}
182 2498 : sal_Unicode GetBulletChar()const {return cBullet;}
183 1397 : void SetBulletRelSize(sal_uInt16 nSet) {nBulletRelSize = nSet;}
184 475 : sal_uInt16 GetBulletRelSize() const { return nBulletRelSize;}
185 6455 : void SetBulletColor(Color nSet){nBulletColor = nSet;}
186 475 : Color GetBulletColor()const {return nBulletColor;}
187 :
188 4612 : void SetIncludeUpperLevels( sal_uInt8 nSet ) { nInclUpperLevels = nSet;}
189 1320 : sal_uInt8 GetIncludeUpperLevels()const { return nInclUpperLevels;}
190 5134 : void SetStart(sal_uInt16 nSet) {nStart = nSet;}
191 128 : sal_uInt16 GetStart() const {return nStart;}
192 :
193 : virtual void SetGraphicBrush( const SvxBrushItem* pBrushItem, const Size* pSize = 0, const sal_Int16* pOrient = 0);
194 20205 : const SvxBrushItem* GetBrush() const {return pGraphicBrush;}
195 : void SetGraphic( const String& rName );
196 : virtual void SetVertOrient(sal_Int16 eSet);
197 : virtual sal_Int16 GetVertOrient() const;
198 0 : void SetGraphicSize(const Size& rSet) {aGraphicSize = rSet;}
199 19405 : const Size& GetGraphicSize() const {return aGraphicSize;}
200 :
201 : SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const;
202 : void SetPositionAndSpaceMode( SvxNumPositionAndSpaceMode ePositionAndSpaceMode );
203 :
204 3689 : void SetLSpace(short nSet) {nLSpace = nSet;}
205 : short GetLSpace() const;
206 4856 : void SetAbsLSpace(short nSet) {nAbsLSpace = nSet;}
207 : short GetAbsLSpace() const;
208 3684 : void SetFirstLineOffset(short nSet) { nFirstLineOffset = nSet;}
209 : short GetFirstLineOffset() const;
210 1477 : void SetCharTextDistance(short nSet) { nCharTextDistance = nSet; }
211 : short GetCharTextDistance() const;
212 :
213 : void SetLabelFollowedBy( const LabelFollowedBy eLabelFollowedBy );
214 : LabelFollowedBy GetLabelFollowedBy() const;
215 : void SetListtabPos( const long nListtabPos );
216 : long GetListtabPos() const;
217 : void SetFirstLineIndent( const long nFirstLineIndent );
218 : long GetFirstLineIndent() const;
219 : void SetIndentAt( const long nIndentAt );
220 : long GetIndentAt() const;
221 :
222 : static Size GetGraphicSizeMM100(const Graphic* pGraphic);
223 : static String CreateRomanString( sal_uLong nNo, sal_Bool bUpper );
224 : };
225 :
226 : enum SvxNumRuleType
227 : {
228 : SVX_RULETYPE_NUMBERING,
229 : SVX_RULETYPE_OUTLINE_NUMBERING,
230 : SVX_RULETYPE_PRESENTATION_NUMBERING,
231 : SVX_RULETYPE_END
232 : };
233 :
234 : class EDITENG_DLLPUBLIC SvxNumRule
235 : {
236 : sal_uInt16 nLevelCount; // Number of supported levels
237 : sal_uInt32 nFeatureFlags; // What is supported?
238 : SvxNumRuleType eNumberingType; // Type of numbering
239 : sal_Bool bContinuousNumbering; // sequential numbering
240 :
241 : SvxNumberFormat* aFmts[SVX_MAX_NUM];
242 : sal_Bool aFmtsSet[SVX_MAX_NUM]; // Flags indicating valid levels
243 :
244 : static sal_Int32 nRefCount;
245 : com::sun::star::lang::Locale aLocale;
246 : public:
247 : SvxNumRule( sal_uLong nFeatures,
248 : sal_uInt16 nLevels,
249 : sal_Bool bCont,
250 : SvxNumRuleType eType = SVX_RULETYPE_NUMBERING,
251 : SvxNumberFormat::SvxNumPositionAndSpaceMode
252 : eDefaultNumberFormatPositionAndSpaceMode
253 : = SvxNumberFormat::LABEL_WIDTH_AND_POSITION );
254 : SvxNumRule(const SvxNumRule& rCopy);
255 : virtual ~SvxNumRule();
256 :
257 : int operator==( const SvxNumRule& ) const;
258 0 : int operator!=( const SvxNumRule& rRule ) const {return !(*this == rRule);}
259 :
260 : SvxNumRule& operator=( const SvxNumRule& );
261 :
262 : SvStream& Store(SvStream &rStream);
263 :
264 : const SvxNumberFormat* Get(sal_uInt16 nLevel)const;
265 : const SvxNumberFormat& GetLevel(sal_uInt16 nLevel)const;
266 : void SetLevel(sal_uInt16 nLevel, const SvxNumberFormat& rFmt, sal_Bool bIsValid = sal_True);
267 :
268 80 : sal_Bool IsContinuousNumbering()const
269 80 : {return bContinuousNumbering;}
270 0 : void SetContinuousNumbering(sal_Bool bSet)
271 0 : {bContinuousNumbering = bSet;}
272 :
273 30037 : sal_uInt16 GetLevelCount() const {return nLevelCount;}
274 0 : sal_Bool IsFeatureSupported(sal_uInt32 nFeature) const
275 0 : {return 0 != (nFeatureFlags & nFeature);}
276 26 : sal_uInt32 GetFeatureFlags() const {return nFeatureFlags;}
277 0 : void SetFeatureFlag( sal_uInt32 nFlag, sal_Bool bSet = sal_True ) { if(bSet) nFeatureFlags |= nFlag; else nFeatureFlags &= ~nFlag; }
278 :
279 : String MakeNumString( const SvxNodeNum&, sal_Bool bInclStrings = sal_True ) const;
280 :
281 90 : SvxNumRuleType GetNumRuleType() const { return eNumberingType; }
282 : void SetNumRuleType( const SvxNumRuleType& rType ) { eNumberingType = rType; }
283 :
284 : sal_Bool UnLinkGraphics();
285 : };
286 :
287 : class EDITENG_DLLPUBLIC SvxNumBulletItem : public SfxPoolItem
288 : {
289 : SvxNumRule* pNumRule;
290 : public:
291 : explicit SvxNumBulletItem(SvxNumRule& rRule);
292 : SvxNumBulletItem(SvxNumRule& rRule, sal_uInt16 nWhich );
293 : SvxNumBulletItem(const SvxNumBulletItem& rCopy);
294 : virtual ~SvxNumBulletItem();
295 :
296 : virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
297 : virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const;
298 : sal_uInt16 GetVersion( sal_uInt16 nFileVersion ) const;
299 : virtual SvStream& Store(SvStream &, sal_uInt16 nItemVersion ) const;
300 : virtual int operator==( const SfxPoolItem& ) const;
301 :
302 43796 : SvxNumRule* GetNumRule() const {return pNumRule;}
303 :
304 : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
305 : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
306 : };
307 :
308 : class SvxNodeNum
309 : {
310 : sal_uInt16 nLevelVal[ SVX_MAX_NUM ]; // Numbers of all levels
311 : sal_uInt16 nSetValue; // predetermined number
312 : sal_uInt8 nMyLevel; // Current Level
313 : sal_Bool bStartNum; // Restart numbering
314 :
315 : public:
316 : explicit inline SvxNodeNum( sal_uInt8 nLevel = SVX_NO_NUM, sal_uInt16 nSetVal = USHRT_MAX );
317 : inline SvxNodeNum& operator=( const SvxNodeNum& rCpy );
318 :
319 0 : sal_uInt8 GetLevel() const { return nMyLevel; }
320 0 : void SetLevel( sal_uInt8 nVal ) { nMyLevel = nVal; }
321 :
322 : sal_Bool IsStart() const { return bStartNum; }
323 : void SetStart( sal_Bool bFlag = sal_True ) { bStartNum = bFlag; }
324 :
325 : sal_uInt16 GetSetValue() const { return nSetValue; }
326 : void SetSetValue( sal_uInt16 nVal ) { nSetValue = nVal; }
327 :
328 0 : const sal_uInt16* GetLevelVal() const { return nLevelVal; }
329 0 : sal_uInt16* GetLevelVal() { return nLevelVal; }
330 : };
331 :
332 0 : SvxNodeNum::SvxNodeNum( sal_uInt8 nLevel, sal_uInt16 nSetVal )
333 0 : : nSetValue( nSetVal ), nMyLevel( nLevel ), bStartNum( sal_False )
334 : {
335 0 : memset( nLevelVal, 0, sizeof( nLevelVal ) );
336 0 : }
337 :
338 : inline SvxNodeNum& SvxNodeNum::operator=( const SvxNodeNum& rCpy )
339 : {
340 : nSetValue = rCpy.nSetValue;
341 : nMyLevel = rCpy.nMyLevel;
342 : bStartNum = rCpy.bStartNum;
343 :
344 : memcpy( nLevelVal, rCpy.nLevelVal, sizeof( nLevelVal ) );
345 : return *this;
346 : }
347 :
348 : SvxNumRule* SvxConvertNumRule( const SvxNumRule* pRule, sal_uInt16 nLevel, SvxNumRuleType eType );
349 :
350 : #endif
351 :
352 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|