Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _SVX_NUMITEM_HXX
29 : : #define _SVX_NUMITEM_HXX
30 : :
31 : : #include <tools/link.hxx>
32 : : #include <tools/string.hxx>
33 : : #include <svl/poolitem.hxx>
34 : : #include <editeng/svxenum.hxx>
35 : : #include <tools/gen.hxx>
36 : : #include <editeng/numdef.hxx>
37 : : #include <tools/color.hxx>
38 : : #include <cppuhelper/weakref.hxx>
39 : : #include <com/sun/star/lang/Locale.hpp>
40 : : #include <com/sun/star/uno/Reference.h>
41 : : #include <com/sun/star/style/NumberingType.hpp>
42 : : #include <unotools/fontcvt.hxx>
43 : : #include <editeng/editengdllapi.h>
44 : :
45 : : class SvxBrushItem;
46 : : class Font;
47 : : class Graphic;
48 : : class SvxNodeNum;
49 : : namespace com{namespace sun{ namespace star{
50 : : namespace text{
51 : : class XNumberingFormatter;
52 : : }
53 : : }}}
54 : :
55 : : // -----------------------------------------------------------------------
56 : : //Feature-Flags (only sal_uInt16!)
57 : : #define NUM_CONTINUOUS 0x0001 // consecutive numbers possible?
58 : : #define NUM_CHAR_TEXT_DISTANCE 0x0002 // Distance Symbol<->Text?
59 : : #define NUM_CHAR_STYLE 0x0004 // Character styles?
60 : : #define NUM_BULLET_REL_SIZE 0x0008 // relative bullet size?
61 : : #define NUM_BULLET_COLOR 0x0010 // Bullet color
62 : : #define NUM_SYMBOL_ALIGNMENT 0x0040 // alignment to be shown in the options
63 : : #define NUM_NO_NUMBERS 0x0080 // Numbering are not allowed
64 : : #define NUM_ENABLE_LINKED_BMP 0x0100 // linked bitmaps are available
65 : : #define NUM_ENABLE_EMBEDDED_BMP 0x0200 // embedded bitmaps are available
66 : :
67 : : #define SVX_NO_NUM 200 // Marker for no numbering
68 : : #define SVX_NO_NUMLEVEL 0x20
69 : :
70 : : #define LINK_TOKEN 0x80 //indicate linked bitmaps - for use in dialog only
71 : : class EDITENG_DLLPUBLIC SvxNumberType
72 : : {
73 : : static sal_Int32 nRefCount;
74 : : static com::sun::star::uno::Reference<com::sun::star::text::XNumberingFormatter> xFormatter;
75 : :
76 : : sal_Int16 nNumType;
77 : : sal_Bool bShowSymbol; // Also show Symbol ?
78 : :
79 : : public:
80 : : SvxNumberType(sal_Int16 nType = com::sun::star::style::NumberingType::ARABIC);
81 : : SvxNumberType(const SvxNumberType& rType);
82 : : ~SvxNumberType();
83 : :
84 : : String GetNumStr( sal_uLong nNo ) const;
85 : : String GetNumStr( sal_uLong nNo, const com::sun::star::lang::Locale& rLocale ) const;
86 : :
87 : 161164 : void SetNumberingType(sal_Int16 nSet) {nNumType = nSet;}
88 : 263587 : sal_Int16 GetNumberingType() const {return nNumType;}
89 : :
90 : 121842 : void SetShowSymbol(sal_Bool bSet) {bShowSymbol = bSet;}
91 : 197364 : sal_Bool IsShowSymbol()const{return bShowSymbol;}
92 : :
93 : 246 : sal_Bool IsTxtFmt() const
94 : : {
95 : : return com::sun::star::style::NumberingType::NUMBER_NONE != nNumType &&
96 : : com::sun::star::style::NumberingType::CHAR_SPECIAL != nNumType &&
97 [ + + ][ + + ]: 246 : com::sun::star::style::NumberingType::BITMAP != nNumType;
[ + - ]
98 : : }
99 : : };
100 : :
101 : : class EDITENG_DLLPUBLIC SvxNumberFormat : public SvxNumberType
102 : : {
103 : : public:
104 : : enum SvxNumPositionAndSpaceMode
105 : : {
106 : : LABEL_WIDTH_AND_POSITION,
107 : : LABEL_ALIGNMENT
108 : : };
109 : : enum LabelFollowedBy
110 : : {
111 : : LISTTAB,
112 : : SPACE,
113 : : NOTHING
114 : : };
115 : :
116 : : private:
117 : : rtl::OUString sPrefix;
118 : : rtl::OUString sSuffix;
119 : :
120 : : SvxAdjust eNumAdjust;
121 : :
122 : : sal_uInt8 nInclUpperLevels; // Take over numbers from the previous level.
123 : : sal_uInt16 nStart; // Start of counting
124 : :
125 : : sal_Unicode cBullet; // Symbol
126 : : sal_uInt16 nBulletRelSize; // percentage size of bullets
127 : : Color nBulletColor; // Bullet color
128 : :
129 : : // mode indicating, if the position and spacing of the list label is
130 : : // determined by the former attributes (nFirstLineOffset, nAbsLSpace,
131 : : // nLSpace and nCharTextDistance) called position and spacing via label
132 : : // width and position (LABEL_WIDTH_AND_POSITION) or by the new attributes
133 : : // (meLabelFollowedBy, mnListtabPos, mnFirstLineIndent and mnIndentAt)
134 : : // called position and spacing via label alignment.
135 : : // Note 1: Attribute <eNumAdjust> is relevant for both modes.
136 : : // Note 2: The values of the former attributes are treated as 0, if mode
137 : : // LABEL_ALIGNMENT is active.
138 : : SvxNumPositionAndSpaceMode mePositionAndSpaceMode;
139 : :
140 : : short nFirstLineOffset; // First line indent
141 : : short nAbsLSpace; // Distance Border<->Number
142 : : short nLSpace; // relative to the previous indentation
143 : : short nCharTextDistance; // Distance Number<->Text
144 : :
145 : : // specifies what follows the list label before the text of the first line
146 : : // of the list item starts
147 : : LabelFollowedBy meLabelFollowedBy;
148 : : // specifies an additional list tab stop position for meLabelFollowedBy = LISTTAB
149 : : long mnListtabPos;
150 : : // specifies the first line indent
151 : : long mnFirstLineIndent;
152 : : // specifies the indent before the text, e.g. in L2R-layout the left margin
153 : : long mnIndentAt;
154 : :
155 : : SvxBrushItem* pGraphicBrush;
156 : : sal_Int16 eVertOrient; // vertical alignment of a bitmap
157 : :
158 : : Size aGraphicSize; // Always! in 1/100 mm
159 : : Font* pBulletFont; // Pointer to the bullet font
160 : :
161 : : String sCharStyleName; // Character Style
162 : :
163 : : DECL_STATIC_LINK( SvxNumberFormat, GraphicArrived, void * );
164 : : virtual void NotifyGraphicArrived();
165 : : public:
166 : : SvxNumberFormat( sal_Int16 nNumberingType,
167 : : SvxNumPositionAndSpaceMode ePositionAndSpaceMode = LABEL_WIDTH_AND_POSITION );
168 : : SvxNumberFormat(const SvxNumberFormat& rFormat);
169 : :
170 : : virtual ~SvxNumberFormat();
171 : :
172 : : SvStream& Store(SvStream &rStream, FontToSubsFontConverter pConverter);
173 : :
174 : : SvxNumberFormat& operator=( const SvxNumberFormat& );
175 : : sal_Bool operator==( const SvxNumberFormat& ) const;
176 : 16205 : sal_Bool operator!=( const SvxNumberFormat& rFmt) const {return !(*this == rFmt);}
177 : :
178 : 8377 : void SetNumAdjust(SvxAdjust eSet) {eNumAdjust = eSet;}
179 : 6461 : SvxAdjust GetNumAdjust() const {return eNumAdjust;}
180 : 5347 : void SetPrefix(const rtl::OUString& rSet) { sPrefix = rSet;}
181 : 8936 : const rtl::OUString& GetPrefix() const { return sPrefix;}
182 : 32111 : void SetSuffix(const rtl::OUString& rSet) { sSuffix = rSet;}
183 : 8936 : const rtl::OUString& GetSuffix() const { return sSuffix;}
184 : :
185 : 191 : void SetCharFmtName(const String& rSet){ sCharStyleName = rSet; }
186 : : virtual const String& GetCharFmtName()const;
187 : :
188 : : void SetBulletFont(const Font* pFont);
189 : 3354 : const Font* GetBulletFont() const {return pBulletFont;}
190 : 50894 : void SetBulletChar(sal_Unicode cSet){cBullet = cSet;}
191 : 7244 : sal_Unicode GetBulletChar()const {return cBullet;}
192 : 6870 : void SetBulletRelSize(sal_uInt16 nSet) {nBulletRelSize = nSet;}
193 : 2977 : sal_uInt16 GetBulletRelSize() const { return nBulletRelSize;}
194 : 2876 : void SetBulletColor(Color nSet){nBulletColor = nSet;}
195 : 2977 : Color GetBulletColor()const {return nBulletColor;}
196 : :
197 : 49708 : void SetIncludeUpperLevels( sal_uInt8 nSet ) { nInclUpperLevels = nSet;}
198 : 3528 : sal_uInt8 GetIncludeUpperLevels()const { return nInclUpperLevels;}
199 : 54204 : void SetStart(sal_uInt16 nSet) {nStart = nSet;}
200 : 889 : sal_uInt16 GetStart() const {return nStart;}
201 : :
202 : : virtual void SetGraphicBrush( const SvxBrushItem* pBrushItem, const Size* pSize = 0, const sal_Int16* pOrient = 0);
203 : 61960 : const SvxBrushItem* GetBrush() const {return pGraphicBrush;}
204 : : void SetGraphic( const String& rName );
205 : : virtual void SetVertOrient(sal_Int16 eSet);
206 : : virtual sal_Int16 GetVertOrient() const;
207 : 4 : void SetGraphicSize(const Size& rSet) {aGraphicSize = rSet;}
208 : 60800 : const Size& GetGraphicSize() const {return aGraphicSize;}
209 : :
210 : : SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const;
211 : : void SetPositionAndSpaceMode( SvxNumPositionAndSpaceMode ePositionAndSpaceMode );
212 : :
213 : 26688 : void SetLSpace(short nSet) {nLSpace = nSet;}
214 : : short GetLSpace() const;
215 : 28632 : void SetAbsLSpace(short nSet) {nAbsLSpace = nSet;}
216 : : short GetAbsLSpace() const;
217 : 19138 : void SetFirstLineOffset(short nSet) { nFirstLineOffset = nSet;}
218 : : short GetFirstLineOffset() const;
219 : 12168 : void SetCharTextDistance(short nSet) { nCharTextDistance = nSet; }
220 : : short GetCharTextDistance() const;
221 : :
222 : : void SetLabelFollowedBy( const LabelFollowedBy eLabelFollowedBy );
223 : : LabelFollowedBy GetLabelFollowedBy() const;
224 : : void SetListtabPos( const long nListtabPos );
225 : : long GetListtabPos() const;
226 : : void SetFirstLineIndent( const long nFirstLineIndent );
227 : : long GetFirstLineIndent() const;
228 : : void SetIndentAt( const long nIndentAt );
229 : : long GetIndentAt() const;
230 : :
231 : : static Size GetGraphicSizeMM100(const Graphic* pGraphic);
232 : : static String CreateRomanString( sal_uLong nNo, sal_Bool bUpper );
233 : : };
234 : :
235 : : enum SvxNumRuleType
236 : : {
237 : : SVX_RULETYPE_NUMBERING,
238 : : SVX_RULETYPE_OUTLINE_NUMBERING,
239 : : SVX_RULETYPE_PRESENTATION_NUMBERING,
240 : : SVX_RULETYPE_END
241 : : };
242 : :
243 : : class EDITENG_DLLPUBLIC SvxNumRule
244 : : {
245 : : sal_uInt16 nLevelCount; // Number of supported levels
246 : : sal_uInt32 nFeatureFlags; // What is supported?
247 : : SvxNumRuleType eNumberingType; // Type of numbering
248 : : sal_Bool bContinuousNumbering; // sequential numbering
249 : :
250 : : SvxNumberFormat* aFmts[SVX_MAX_NUM];
251 : : sal_Bool aFmtsSet[SVX_MAX_NUM]; // Flags indicating valid levels
252 : :
253 : : static sal_Int32 nRefCount;
254 : : com::sun::star::lang::Locale aLocale;
255 : : public:
256 : : SvxNumRule( sal_uLong nFeatures,
257 : : sal_uInt16 nLevels,
258 : : sal_Bool bCont,
259 : : SvxNumRuleType eType = SVX_RULETYPE_NUMBERING,
260 : : SvxNumberFormat::SvxNumPositionAndSpaceMode
261 : : eDefaultNumberFormatPositionAndSpaceMode
262 : : = SvxNumberFormat::LABEL_WIDTH_AND_POSITION );
263 : : SvxNumRule(const SvxNumRule& rCopy);
264 : : virtual ~SvxNumRule();
265 : :
266 : : int operator==( const SvxNumRule& ) const;
267 : 0 : int operator!=( const SvxNumRule& rRule ) const {return !(*this == rRule);}
268 : :
269 : : SvxNumRule& operator=( const SvxNumRule& );
270 : :
271 : : SvStream& Store(SvStream &rStream);
272 : :
273 : : const SvxNumberFormat* Get(sal_uInt16 nLevel)const;
274 : : const SvxNumberFormat& GetLevel(sal_uInt16 nLevel)const;
275 : : void SetLevel(sal_uInt16 nLevel, const SvxNumberFormat& rFmt, sal_Bool bIsValid = sal_True);
276 : :
277 : 116 : sal_Bool IsContinuousNumbering()const
278 : 116 : {return bContinuousNumbering;}
279 : 0 : void SetContinuousNumbering(sal_Bool bSet)
280 : 0 : {bContinuousNumbering = bSet;}
281 : :
282 : 34884 : sal_uInt16 GetLevelCount() const {return nLevelCount;}
283 : 0 : sal_Bool IsFeatureSupported(sal_uInt32 nFeature) const
284 : 0 : {return 0 != (nFeatureFlags & nFeature);}
285 : 344 : sal_uInt32 GetFeatureFlags() const {return nFeatureFlags;}
286 [ # # ]: 0 : void SetFeatureFlag( sal_uInt32 nFlag, sal_Bool bSet = sal_True ) { if(bSet) nFeatureFlags |= nFlag; else nFeatureFlags &= ~nFlag; }
287 : :
288 : : String MakeNumString( const SvxNodeNum&, sal_Bool bInclStrings = sal_True ) const;
289 : :
290 : 232 : SvxNumRuleType GetNumRuleType() const { return eNumberingType; }
291 : : void SetNumRuleType( const SvxNumRuleType& rType ) { eNumberingType = rType; }
292 : :
293 : : sal_Bool UnLinkGraphics();
294 : : };
295 : :
296 : : class EDITENG_DLLPUBLIC SvxNumBulletItem : public SfxPoolItem
297 : : {
298 : : SvxNumRule* pNumRule;
299 : : public:
300 : : SvxNumBulletItem(SvxNumRule& rRule);
301 : : SvxNumBulletItem(SvxNumRule& rRule, sal_uInt16 nWhich );
302 : : SvxNumBulletItem(const SvxNumBulletItem& rCopy);
303 : : virtual ~SvxNumBulletItem();
304 : :
305 : : virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
306 : : virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const;
307 : : sal_uInt16 GetVersion( sal_uInt16 nFileVersion ) const;
308 : : virtual SvStream& Store(SvStream &, sal_uInt16 nItemVersion ) const;
309 : : virtual int operator==( const SfxPoolItem& ) const;
310 : :
311 : 44172 : SvxNumRule* GetNumRule() const {return pNumRule;}
312 : :
313 : : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
314 : : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
315 : : };
316 : :
317 : : class SvxNodeNum
318 : : {
319 : : sal_uInt16 nLevelVal[ SVX_MAX_NUM ]; // Numbers of all levels
320 : : sal_uInt16 nSetValue; // predetermined number
321 : : sal_uInt8 nMyLevel; // Current Level
322 : : sal_Bool bStartNum; // Restart numbering
323 : :
324 : : public:
325 : : inline SvxNodeNum( sal_uInt8 nLevel = SVX_NO_NUM, sal_uInt16 nSetVal = USHRT_MAX );
326 : : inline SvxNodeNum& operator=( const SvxNodeNum& rCpy );
327 : :
328 : 0 : sal_uInt8 GetLevel() const { return nMyLevel; }
329 : 0 : void SetLevel( sal_uInt8 nVal ) { nMyLevel = nVal; }
330 : :
331 : : sal_Bool IsStart() const { return bStartNum; }
332 : : void SetStart( sal_Bool bFlag = sal_True ) { bStartNum = bFlag; }
333 : :
334 : : sal_uInt16 GetSetValue() const { return nSetValue; }
335 : : void SetSetValue( sal_uInt16 nVal ) { nSetValue = nVal; }
336 : :
337 : 0 : const sal_uInt16* GetLevelVal() const { return nLevelVal; }
338 : 0 : sal_uInt16* GetLevelVal() { return nLevelVal; }
339 : : };
340 : :
341 : 0 : SvxNodeNum::SvxNodeNum( sal_uInt8 nLevel, sal_uInt16 nSetVal )
342 : 0 : : nSetValue( nSetVal ), nMyLevel( nLevel ), bStartNum( sal_False )
343 : : {
344 : 0 : memset( nLevelVal, 0, sizeof( nLevelVal ) );
345 : 0 : }
346 : :
347 : : inline SvxNodeNum& SvxNodeNum::operator=( const SvxNodeNum& rCpy )
348 : : {
349 : : nSetValue = rCpy.nSetValue;
350 : : nMyLevel = rCpy.nMyLevel;
351 : : bStartNum = rCpy.bStartNum;
352 : :
353 : : memcpy( nLevelVal, rCpy.nLevelVal, sizeof( nLevelVal ) );
354 : : return *this;
355 : : }
356 : :
357 : : SvxNumRule* SvxConvertNumRule( const SvxNumRule* pRule, sal_uInt16 nLevel, SvxNumRuleType eType );
358 : :
359 : : #endif
360 : :
361 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|