xref: /trunk/main/editeng/inc/editeng/numitem.hxx (revision 4c5491ea)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SVX_NUMITEM_HXX
24 #define _SVX_NUMITEM_HXX
25 
26 // include ---------------------------------------------------------------
27 
28 #include <tools/link.hxx>
29 #include <tools/string.hxx>
30 #include <svl/poolitem.hxx>
31 #include <editeng/svxenum.hxx>
32 #include <tools/gen.hxx>
33 #include <editeng/numdef.hxx>
34 #include <tools/color.hxx>
35 #include <cppuhelper/weakref.hxx>
36 #include <com/sun/star/lang/Locale.hpp>
37 #include <com/sun/star/uno/Reference.h>
38 #include <com/sun/star/style/NumberingType.hpp>
39 #include <unotools/fontcvt.hxx>
40 #include <editeng/editengdllapi.h>
41 
42 class SvxBrushItem;
43 class Font;
44 class Graphic;
45 class SvxNodeNum;
46 class BitmapEx;
47 namespace com{namespace sun{ namespace star{
48 	namespace text{
49 		class XNumberingFormatter;
50 	}
51 }}}
52 
53 // -----------------------------------------------------------------------
54 //Feature-Flags (only sal_uInt16!)
55 #define NUM_CONTINUOUS 			0x0001 // fortlaufende Numerierung moeglich?
56 #define NUM_CHAR_TEXT_DISTANCE 	0x0002 // Abstand Symbol<->Text?
57 #define NUM_CHAR_STYLE			0x0004 // Zeichenvorlagen?
58 #define NUM_BULLET_REL_SIZE		0x0008 // rel. Bulletgroesse?
59 #define NUM_BULLET_COLOR		0x0010 // Bullet color
60 #define NUM_SYMBOL_ALIGNMENT	0x0040 // alignment soll unter den Optionen angezeigt werden
61 #define NUM_NO_NUMBERS			0x0080 // Numberierungen sind nicht erlaubt
62 #define NUM_ENABLE_LINKED_BMP	0x0100 // linked bitmaps are available
63 #define NUM_ENABLE_EMBEDDED_BMP	0x0200 // embedded bitmaps are available
64 
65 #define SVX_NO_NUM				200 // Markierung fuer keine Numerierung
66 #define SVX_NO_NUMLEVEL         0x20
67 
68 #define LINK_TOKEN 	0x80 //indicate linked bitmaps - for use in dialog only
69 class EDITENG_DLLPUBLIC SvxNumberType
70 {
71 	static sal_Int32 nRefCount;
72 	static com::sun::star::uno::Reference<com::sun::star::text::XNumberingFormatter> xFormatter;
73 
74 	sal_Int16		nNumType;
75 	sal_Bool		bShowSymbol;		// Symbol auch anzeigen?
76 
77 public:
78 	SvxNumberType(sal_Int16 nType = com::sun::star::style::NumberingType::ARABIC);
79 	SvxNumberType(const SvxNumberType& rType);
80 	~SvxNumberType();
81 
82 	String 			GetNumStr( sal_uLong nNo ) const;
83 	String 			GetNumStr( sal_uLong nNo, const com::sun::star::lang::Locale& rLocale ) const;
84 
SetNumberingType(sal_Int16 nSet)85 	void			SetNumberingType(sal_Int16 nSet) {nNumType = nSet;}
GetNumberingType() const86 	sal_Int16		GetNumberingType() const {return nNumType;}
87 
SetShowSymbol(sal_Bool bSet)88 	void 			SetShowSymbol(sal_Bool bSet) {bShowSymbol = bSet;}
IsShowSymbol() const89 	sal_Bool		IsShowSymbol()const{return bShowSymbol;}
90 
IsTxtFmt() const91 	sal_Bool		IsTxtFmt() const
92 					{
93 						return com::sun::star::style::NumberingType::NUMBER_NONE != nNumType &&
94 		   					com::sun::star::style::NumberingType::CHAR_SPECIAL != nNumType &&
95 		   					com::sun::star::style::NumberingType::BITMAP != nNumType;
96 					}
97 };
98 
99 class EDITENG_DLLPUBLIC SvxNumberFormat : public SvxNumberType
100 {
101 public:
102     // --> OD 2008-01-08 #newlistlevelattrs#
103     enum SvxNumPositionAndSpaceMode
104     {
105         LABEL_WIDTH_AND_POSITION,
106         LABEL_ALIGNMENT
107     };
108     enum SvxNumLabelFollowedBy
109     {
110         LISTTAB,
111         SPACE,
112         NOTHING
113     };
114     // <--
115 
116 private:
117 	String 				sPrefix;
118 	String 				sSuffix;
119 
120 	SvxAdjust			eNumAdjust;
121 
122 	sal_uInt8				nInclUpperLevels;	//Nummern aus der vorigen Ebenen uebernehmen
123 	sal_uInt16 				nStart;				//Start der Zaehlung
124 
125 	sal_Unicode 		cBullet;			//Symbol
126 	sal_uInt16				nBulletRelSize;		//proz. Groesse des Bullets
127 	Color				nBulletColor;		//Bullet color
128 
129     // --> OD 2008-01-08 #newlistlevelattrs#
130     // mode indicating, if the position and spacing of the list label is
131     // determined by the former attributes (nFirstLineOffset, nAbsLSpace,
132     // nLSpace and nCharTextDistance) called position and spacing via label
133     // width and position (LABEL_WIDTH_AND_POSITION) or by the new attributes
134     // (meLabelFollowedBy, mnListtabPos, mnFirstLineIndent and mnIndentAt)
135     // called position and spacing via label alignment.
136     // Note 1: Attribute <eNumAdjust> is relevant for both modes.
137     // Note 2: The values of the former attributes are treated as 0, if mode
138     //         LABEL_ALIGNMENT is active.
139     SvxNumPositionAndSpaceMode mePositionAndSpaceMode;
140     // <--
141 
142 	short 				nFirstLineOffset;   //Erstzeileneinzug
143 	short 				nAbsLSpace;			//Abstand Rand<->Nummer
144 	short 				nLSpace;			//relative Einrueckung zum Vorgaenger
145 	short				nCharTextDistance;	//Abstand Nummer<->Text
146 
147     // --> OD 2008-01-08 #newlistlevelattrs#
148     // specifies what follows the list label before the text of the first line
149     // of the list item starts
150     SvxNumLabelFollowedBy       meLabelFollowedBy;
151     // specifies an additional list tab stop position for meLabelFollowedBy = LISTTAB
152     long                        mnListtabPos;
153     // specifies the first line indent
154     long                        mnFirstLineIndent;
155     // specifies the indent before the text, e.g. in L2R-layout the left margin
156     long                        mnIndentAt;
157     // <--
158 
159 	SvxBrushItem* 	 	pGraphicBrush; 			//
160     sal_Int16           eVertOrient;        // vert. Ausrichtung einer Bitmap
161 
162 	Size 				aGraphicSize;		// immer! in 1/100 mm
163 	Font* 				pBulletFont;		// Pointer auf den BulletFont
164 
165 	String				sCharStyleName;		// Zeichenvorlage
166 
167 	BitmapEx*			pScaledImageCache;	// Image scaled to aGraphicSize, only cached for WINDOW/VDEV
168 
169 	DECL_STATIC_LINK( SvxNumberFormat, GraphicArrived, void * );
170     virtual void NotifyGraphicArrived();
171 public:
172     // --> OD 2008-01-09 #newlistlevelattrs#
173     SvxNumberFormat( sal_Int16 nNumberingType,
174                      SvxNumPositionAndSpaceMode ePositionAndSpaceMode = LABEL_WIDTH_AND_POSITION );
175     // <--
176 	SvxNumberFormat(const SvxNumberFormat& rFormat);
177     SvxNumberFormat(SvStream &rStream);
178 
179 	virtual ~SvxNumberFormat();
180 
181     SvStream&       Store(SvStream &rStream, FontToSubsFontConverter pConverter);
182 
183 	SvxNumberFormat& operator=( const SvxNumberFormat&  );
184 	sal_Bool 			operator==( const SvxNumberFormat&  ) const;
operator !=(const SvxNumberFormat & rFmt) const185 	sal_Bool            operator!=( const SvxNumberFormat& rFmt) const {return !(*this == rFmt);}
186 
SetNumAdjust(SvxAdjust eSet)187 	void			SetNumAdjust(SvxAdjust eSet) {eNumAdjust = eSet;}
GetNumAdjust() const188 	SvxAdjust		GetNumAdjust() const {return eNumAdjust;}
SetPrefix(const String & rSet)189 	void 			SetPrefix(const String& rSet) { sPrefix = rSet;}
GetPrefix() const190 	const String&	GetPrefix() const { return sPrefix;}
SetSuffix(const String & rSet)191 	void            SetSuffix(const String& rSet) { sSuffix = rSet;}
GetSuffix() const192 	const String&	GetSuffix() const { return sSuffix;}
193 
SetCharFmtName(const String & rSet)194 	void					SetCharFmtName(const String& rSet){ sCharStyleName = rSet; }
195 	virtual const String&	GetCharFmtName()const;
196 
197 	void			SetBulletFont(const Font* pFont);
GetBulletFont() const198 	const Font* 	GetBulletFont() const {return pBulletFont;}
SetBulletChar(sal_Unicode cSet)199 	void			SetBulletChar(sal_Unicode cSet){cBullet = cSet;}
GetBulletChar() const200 	sal_Unicode 	GetBulletChar()const {return cBullet;}
SetBulletRelSize(sal_uInt16 nSet)201 	void			SetBulletRelSize(sal_uInt16 nSet) {nBulletRelSize = nSet;}
GetBulletRelSize() const202 	sal_uInt16			GetBulletRelSize() const { return nBulletRelSize;}
SetBulletColor(Color nSet)203 	void			SetBulletColor(Color nSet){nBulletColor = nSet;}
GetBulletColor() const204 	Color			GetBulletColor()const {return nBulletColor;}
205 
SetIncludeUpperLevels(sal_uInt8 nSet)206 	void			SetIncludeUpperLevels( sal_uInt8 nSet ) { nInclUpperLevels = nSet;}
GetIncludeUpperLevels() const207 	sal_uInt8 			GetIncludeUpperLevels()const  { return nInclUpperLevels;}
SetStart(sal_uInt16 nSet)208 	void 			SetStart(sal_uInt16 nSet) {nStart = nSet;}
GetStart() const209 	sal_uInt16			GetStart() const {return nStart;}
210 
211     virtual void    SetGraphicBrush( const SvxBrushItem* pBrushItem, const Size* pSize = 0, const sal_Int16* pOrient = 0);
GetBrush() const212 	const SvxBrushItem* 		GetBrush() const {return pGraphicBrush;}
213 	void 			SetGraphic( const String& rName );
214     virtual void        SetVertOrient(sal_Int16 eSet);
215     virtual sal_Int16   GetVertOrient() const;
SetGraphicSize(const Size & rSet)216 	void			SetGraphicSize(const Size& rSet) {aGraphicSize = rSet;}
GetGraphicSize() const217 	const Size&		GetGraphicSize() const {return aGraphicSize;}
218 
219     // --> OD 2008-01-09 #newlistlevelattrs#
220     SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const;
221     void SetPositionAndSpaceMode( SvxNumPositionAndSpaceMode ePositionAndSpaceMode );
222     // <--
223 
SetLSpace(short nSet)224 	void			SetLSpace(short nSet) {nLSpace = nSet;}
225     // --> OD 2008-01-09 #newlistlevelattrs#
226     short           GetLSpace() const;
227     // <--
SetAbsLSpace(short nSet)228 	void			SetAbsLSpace(short nSet) {nAbsLSpace = nSet;}
229     // --> OD 2008-01-09 #newlistlevelattrs#
230     short           GetAbsLSpace() const;
231     // <--
SetFirstLineOffset(short nSet)232 	void 			SetFirstLineOffset(short nSet) { nFirstLineOffset = nSet;}
233     // --> OD 2008-01-09 #newlistlevelattrs#
234     short           GetFirstLineOffset() const;
235     // <--
SetCharTextDistance(short nSet)236 	void			SetCharTextDistance(short nSet) { nCharTextDistance = nSet; }
237     // --> OD 2008-01-09 #newlistlevelattrs#
238     short           GetCharTextDistance() const;
239     // <--
240 
241     // --> OD 2008-01-09 #newlistlevelattrs#
242     void SetLabelFollowedBy( const SvxNumLabelFollowedBy eLabelFollowedBy );
243     SvxNumLabelFollowedBy GetLabelFollowedBy() const;
244     void SetListtabPos( const long nListtabPos );
245     long GetListtabPos() const;
246     void SetFirstLineIndent( const long nFirstLineIndent );
247     long GetFirstLineIndent() const;
248     void SetIndentAt( const long nIndentAt );
249     long GetIndentAt() const;
250     // <--
251 
252 	static Size		GetGraphicSizeMM100(const Graphic* pGraphic);
253 	static String 	CreateRomanString( sal_uLong nNo, sal_Bool bUpper );
254 };
255 
256 enum SvxNumRuleType
257 {
258 	SVX_RULETYPE_NUMBERING,
259 	SVX_RULETYPE_OUTLINE_NUMBERING,
260 	SVX_RULETYPE_PRESENTATION_NUMBERING,
261 	SVX_RULETYPE_END
262 };
263 
264 class EDITENG_DLLPUBLIC SvxNumRule
265 {
266 	sal_uInt16 				nLevelCount;            // Anzahl der unterstuetzten Levels
267 	sal_uInt32 				nFeatureFlags;          // was wird unterstuetzt?
268 	SvxNumRuleType		eNumberingType;         // was fuer eine Numerierung
269 	sal_Bool 				bContinuousNumbering;	// fortlaufende Numerierung
270 
271 	SvxNumberFormat* 	aFmts[SVX_MAX_NUM];
272 	sal_Bool			 	aFmtsSet[SVX_MAX_NUM]; //Flags ueber Gueltigkeit der Ebenen
273 
274 	static sal_Int32	nRefCount;
275 	com::sun::star::lang::Locale aLocale;
276 public:
277     // --> OD 2008-02-11 #newlistlevelattrs#
278     SvxNumRule( sal_uLong nFeatures,
279                 sal_uInt16 nLevels,
280                 sal_Bool bCont,
281                 SvxNumRuleType eType = SVX_RULETYPE_NUMBERING,
282                 SvxNumberFormat::SvxNumPositionAndSpaceMode
283                         eDefaultNumberFormatPositionAndSpaceMode
284                                 = SvxNumberFormat::LABEL_WIDTH_AND_POSITION );
285     // <--
286 	SvxNumRule(const SvxNumRule& rCopy);
287 	SvxNumRule(SvStream &rStream);
288 	virtual ~SvxNumRule();
289 
290 	int              		operator==( const SvxNumRule& ) const;
operator !=(const SvxNumRule & rRule) const291 	int              		operator!=( const SvxNumRule& rRule ) const {return !(*this == rRule);}
292 
293 	SvxNumRule& 			operator=( const SvxNumRule&  );
294 
295 	SvStream&               Store(SvStream &rStream);
296 
297 	const SvxNumberFormat* 	Get(sal_uInt16 nLevel)const;
298 	const SvxNumberFormat& 	GetLevel(sal_uInt16 nLevel)const;
299 	void					SetLevel(sal_uInt16 nLevel, const SvxNumberFormat& rFmt, sal_Bool bIsValid = sal_True);
300 	void					SetLevel(sal_uInt16 nLevel, const SvxNumberFormat* pFmt);
301 
IsContinuousNumbering() const302 	sal_Bool					IsContinuousNumbering()const
303 											{return bContinuousNumbering;}
SetContinuousNumbering(sal_Bool bSet)304 	void					SetContinuousNumbering(sal_Bool bSet)
305 											{bContinuousNumbering = bSet;}
306 
GetLevelCount() const307 	sal_uInt16 					GetLevelCount() const {return nLevelCount;}
IsFeatureSupported(sal_uInt32 nFeature) const308 	sal_Bool					IsFeatureSupported(sal_uInt32 nFeature) const
309 											{return 0 != (nFeatureFlags & nFeature);}
GetFeatureFlags() const310 	sal_uInt32 					GetFeatureFlags() const {return nFeatureFlags;}
SetFeatureFlag(sal_uInt32 nFlag,sal_Bool bSet=sal_True)311 	void					SetFeatureFlag( sal_uInt32 nFlag, sal_Bool bSet = sal_True ) { if(bSet) nFeatureFlags |= nFlag; else nFeatureFlags &= ~nFlag; }
312 
313 	String 					MakeNumString( const SvxNodeNum&, sal_Bool bInclStrings = sal_True ) const;
314 
GetNumRuleType() const315 	SvxNumRuleType			GetNumRuleType() const { return eNumberingType; }
SetNumRuleType(const SvxNumRuleType & rType)316 	void                    SetNumRuleType( const SvxNumRuleType& rType ) { eNumberingType = rType; }
317 
318 	sal_Bool					UnLinkGraphics();
319 };
320 /* -----------------27.10.98 13:04-------------------
321  *
322  * --------------------------------------------------*/
323 class EDITENG_DLLPUBLIC SvxNumBulletItem : public SfxPoolItem
324 {
325 	SvxNumRule* 			pNumRule;
326 public:
327 	SvxNumBulletItem(SvxNumRule& rRule);
328 	SvxNumBulletItem(SvxNumRule& rRule, sal_uInt16 nWhich );
329 	SvxNumBulletItem(const SvxNumBulletItem& rCopy);
330 	virtual ~SvxNumBulletItem();
331 
332 	virtual SfxPoolItem*     Clone( SfxItemPool *pPool = 0 ) const;
333     virtual SfxPoolItem*     Create(SvStream &, sal_uInt16) const;
334 	sal_uInt16  GetVersion( sal_uInt16 nFileVersion ) const;
335     virtual SvStream&        Store(SvStream &, sal_uInt16 nItemVersion ) const;
336 	virtual int              operator==( const SfxPoolItem& ) const;
337 
GetNumRule() const338 	SvxNumRule* 			GetNumRule() const {return pNumRule;}
339 
340 	virtual	sal_Bool		QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
341 	virtual	sal_Bool		PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
342 };
343 /* -----------------28.10.98 15:21-------------------
344  *
345  * --------------------------------------------------*/
346 class SvxNodeNum
347 {
348 	sal_uInt16 nLevelVal[ SVX_MAX_NUM ];	// Nummern aller Levels
349 	sal_uInt16 nSetValue;					// vorgegebene Nummer
350 	sal_uInt8 nMyLevel;						// akt. Level
351 	sal_Bool bStartNum;						// Numerierung neu starten
352 
353 public:
354 	inline SvxNodeNum( sal_uInt8 nLevel = SVX_NO_NUM, sal_uInt16 nSetVal = USHRT_MAX );
355 	inline SvxNodeNum& operator=( const SvxNodeNum& rCpy );
356 
GetLevel() const357 	sal_uInt8 GetLevel() const 					{ return nMyLevel; }
SetLevel(sal_uInt8 nVal)358 	void SetLevel( sal_uInt8 nVal )  			{ nMyLevel = nVal; }
359 
IsStart() const360 	sal_Bool IsStart() const					{ return bStartNum; }
SetStart(sal_Bool bFlag=sal_True)361 	void SetStart( sal_Bool bFlag = sal_True ) 		{ bStartNum = bFlag; }
362 
GetSetValue() const363 	sal_uInt16 GetSetValue() const 				{ return nSetValue; }
SetSetValue(sal_uInt16 nVal)364 	void SetSetValue( sal_uInt16 nVal )  		{ nSetValue = nVal; }
365 
GetLevelVal() const366 	const sal_uInt16* GetLevelVal() const 		{ return nLevelVal; }
GetLevelVal()367 		  sal_uInt16* GetLevelVal() 	 		{ return nLevelVal; }
368 };
369 
SvxNodeNum(sal_uInt8 nLevel,sal_uInt16 nSetVal)370 SvxNodeNum::SvxNodeNum( sal_uInt8 nLevel, sal_uInt16 nSetVal )
371 	: nSetValue( nSetVal ), nMyLevel( nLevel ), bStartNum( sal_False )
372 {
373 	memset( nLevelVal, 0, sizeof( nLevelVal ) );
374 }
375 
operator =(const SvxNodeNum & rCpy)376 inline SvxNodeNum& SvxNodeNum::operator=( const SvxNodeNum& rCpy )
377 {
378 	nSetValue = rCpy.nSetValue;
379 	nMyLevel = rCpy.nMyLevel;
380 	bStartNum = rCpy.bStartNum;
381 
382 	memcpy( nLevelVal, rCpy.nLevelVal, sizeof( nLevelVal ) );
383 	return *this;
384 }
385 
386 /* --------------------------------------------------
387  *
388  * --------------------------------------------------*/
389 SvxNumRule* SvxConvertNumRule( const SvxNumRule* pRule, sal_uInt16 nLevel, SvxNumRuleType eType );
390 
391 #endif
392 
393