1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: numitem.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SVX_NUMITEM_HXX
31 #define _SVX_NUMITEM_HXX
33 // include ---------------------------------------------------------------
35 #ifndef _LINK_HXX //autogen
36 #include <tools/link.hxx>
38 #ifndef _STRING_HXX //autogen
39 #include <tools/string.hxx>
41 #ifndef _SFXPOOLITEM_HXX //autogen
42 #include <bf_svtools/poolitem.hxx>
44 #ifndef _SVX_SVXENUM_HXX //autogen
45 #include <bf_svx/svxenum.hxx>
47 #ifndef _SV_GEN_HXX //autogen
48 #include <tools/gen.hxx>
50 #ifndef _SVX_NUMDEF_HXX //autogen
51 #include <bf_svx/numdef.hxx>
53 #ifndef _COLOR_HXX //autogen
54 #include <tools/color.hxx>
56 #ifndef _CPPUHELPER_WEAKREF_HXX_
57 #include <cppuhelper/weakref.hxx>
59 #ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
60 #include <com/sun/star/lang/Locale.hpp>
62 #ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
63 #include <com/sun/star/uno/Reference.h>
65 #ifndef _COM_SUN_STAR_STYLE_NUMBERINGTYPE_HPP_
66 #include <com/sun/star/style/NumberingType.hpp>
68 #ifndef _SV_FONTCVT_HXX
69 #include <vcl/fontcvt.hxx>
71 namespace com
{namespace sun
{ namespace star
{
73 class XNumberingFormatter
;
85 // -----------------------------------------------------------------------
86 //Feature-Flags (only USHORT!)
87 #define NUM_CONTINUOUS 0x0001 // fortlaufende Numerierung moeglich?
88 #define NUM_CHAR_TEXT_DISTANCE 0x0002 // Abstand Symbol<->Text?
89 #define NUM_CHAR_STYLE 0x0004 // Zeichenvorlagen?
90 #define NUM_BULLET_REL_SIZE 0x0008 // rel. Bulletgroesse?
91 #define NUM_BULLET_COLOR 0x0010 // Bullet color
92 #define NUM_HIDDEN_SYMBOLS 0x0020 // hidden symbols
93 #define NUM_SYMBOL_ALIGNMENT 0x0040 // alignment soll unter den Optionen angezeigt werden
94 #define NUM_NO_NUMBERS 0x0080 // Numberierungen sind nicht erlaubt
95 #define NUM_ENABLE_LINKED_BMP 0x0100 // linked bitmaps are available
96 #define NUM_ENABLE_EMBEDDED_BMP 0x0200 // embedded bitmaps are available
98 #define SVX_NO_NUM 200 // Markierung fuer keine Numerierung
99 #define SVX_NO_NUMLEVEL 0x20
101 #define NUMITEM_VERSION_01 0x01
102 #define NUMITEM_VERSION_02 0x02
103 #define NUMITEM_VERSION_03 0x03
105 #define LINK_TOKEN 0x80 //indicate linked bitmaps - for use in dialog only
106 using namespace ::com::sun::star::style
;
110 static sal_Int32 nRefCount
;
111 static ::com::sun::star::uno::Reference
< ::com::sun::star::text::XNumberingFormatter
> xFormatter
;
114 sal_Bool bShowSymbol
; // Symbol auch anzeigen?
117 SvxNumberType(sal_Int16 nType
= (sal_Int16
) NumberingType::ARABIC
);
118 SvxNumberType(const SvxNumberType
& rType
);
121 String
GetNumStr( ULONG nNo
) const;
122 String
GetNumStr( ULONG nNo
, const ::com::sun::star::lang::Locale
& rLocale
) const;
124 void SetNumberingType(sal_Int16 nSet
) {nNumType
= nSet
;}
125 sal_Int16
GetNumberingType() const {return nNumType
;}
127 void SetShowSymbol(sal_Bool bSet
) {bShowSymbol
= bSet
;}
128 sal_Bool
IsShowSymbol()const{return bShowSymbol
;}
130 sal_Bool
IsTxtFmt() const
132 return ::com::sun::star::style::NumberingType::NUMBER_NONE
!= nNumType
&&
133 ::com::sun::star::style::NumberingType::CHAR_SPECIAL
!= nNumType
&&
134 ::com::sun::star::style::NumberingType::BITMAP
!= nNumType
;
138 class SvxNumberFormat
: public SvxNumberType
143 SvxAdjust eNumAdjust
;
145 BYTE nInclUpperLevels
; //Nummern aus der vorigen Ebenen uebernehmen
146 USHORT nStart
; //Start der Zaehlung
148 sal_Unicode cBullet
; //Symbol
149 USHORT nBulletRelSize
; //proz. Groesse des Bullets
150 Color nBulletColor
; //Bullet color
152 short nFirstLineOffset
; //Erstzeileneinzug
153 short nAbsLSpace
; //Abstand Rand<->Nummer
154 short nLSpace
; //relative Einrueckung zum Vorgaenger
155 short nCharTextDistance
; //Abstand Nummer<->Text
157 SvxBrushItem
* pGraphicBrush
; //
158 SvxFrameVertOrient eVertOrient
; // vert. Ausrichtung einer Bitmap
160 Size aGraphicSize
; // immer! in 1/100 mm
161 Font
* pBulletFont
; // Pointer auf den BulletFont
163 String sCharStyleName
; // Zeichenvorlage
165 BitmapEx
* pScaledImageCache
; // Image scaled to aGraphicSize, only cached for WINDOW/VDEV
167 // void GetCharStr( ULONG nNo, String& rStr ) const;
168 // void GetCharStrN( ULONG nNo, String& rStr ) const;
170 SvxNumberFormat(sal_Int16 nNumberingType
);
171 SvxNumberFormat(const SvxNumberFormat
& rFormat
);
172 SvxNumberFormat(SvStream
&rStream
);
175 SvStream
& Store(SvStream
&rStream
, FontToSubsFontConverter pConverter
);
177 SvxNumberFormat
& operator=( const SvxNumberFormat
& );
178 BOOL
operator==( const SvxNumberFormat
& ) const;
179 BOOL
operator!=( const SvxNumberFormat
& rFmt
) const {return !(*this == rFmt
);}
181 void SetNumAdjust(SvxAdjust eSet
) {eNumAdjust
= eSet
;}
182 SvxAdjust
GetNumAdjust() const {return eNumAdjust
;}
183 void SetPrefix(const String
& rSet
) { sPrefix
= rSet
;}
184 const String
& GetPrefix() const { return sPrefix
;}
185 void SetSuffix(const String
& rSet
) { sSuffix
= rSet
;}
186 const String
& GetSuffix() const { return sSuffix
;}
188 void SetCharFmtName(const String
& rSet
){ sCharStyleName
= rSet
; }
189 virtual const String
& GetCharFmtName()const;
191 void SetBulletFont(const Font
* pFont
);
192 const Font
* GetBulletFont() const {return pBulletFont
;}
193 void SetBulletChar(sal_Unicode cSet
){cBullet
= cSet
;}
194 sal_Unicode
GetBulletChar()const {return cBullet
;}
195 void SetBulletRelSize(USHORT nSet
) {nBulletRelSize
= nSet
;}
196 USHORT
GetBulletRelSize() const { return nBulletRelSize
;}
197 void SetBulletColor(Color nSet
){nBulletColor
= nSet
;}
198 Color
GetBulletColor()const {return nBulletColor
;}
200 void SetIncludeUpperLevels( BYTE nSet
) { nInclUpperLevels
= nSet
;}
201 BYTE
GetIncludeUpperLevels()const { return nInclUpperLevels
;}
202 void SetStart(USHORT nSet
) {nStart
= nSet
;}
203 USHORT
GetStart() const {return nStart
;}
205 virtual void SetGraphicBrush( const SvxBrushItem
* pBrushItem
, const Size
* pSize
= 0, const SvxFrameVertOrient
* pOrient
= 0);
206 const SvxBrushItem
* GetBrush() const {return pGraphicBrush
;}
207 virtual SvxFrameVertOrient
GetVertOrient() const;
208 void SetGraphicSize(const Size
& rSet
) {aGraphicSize
= rSet
;}
209 const Size
& GetGraphicSize() const {return aGraphicSize
;}
211 void SetLSpace(short nSet
) {nLSpace
= nSet
;}
212 short GetLSpace() const {return nLSpace
;}
213 void SetAbsLSpace(short nSet
) {nAbsLSpace
= nSet
;}
214 short GetAbsLSpace() const {return nAbsLSpace
;}
215 void SetFirstLineOffset(short nSet
) { nFirstLineOffset
= nSet
;}
216 short GetFirstLineOffset() const {return nFirstLineOffset
; }
217 void SetCharTextDistance(short nSet
) { nCharTextDistance
= nSet
; }
218 short GetCharTextDistance() const {return nCharTextDistance
;}
220 static String
CreateRomanString( ULONG nNo
, BOOL bUpper
);
225 SVX_RULETYPE_NUMBERING
,
226 SVX_RULETYPE_OUTLINE_NUMBERING
,
227 SVX_RULETYPE_PRESENTATION_NUMBERING
,
233 USHORT nLevelCount
; // Anzahl der unterstuetzten Levels
234 ULONG nFeatureFlags
; // was wird unterstuetzt?
235 SvxNumRuleType eNumberingType
; // was fuer eine Numerierung
236 BOOL bContinuousNumbering
; // fortlaufende Numerierung
238 SvxNumberFormat
* aFmts
[SVX_MAX_NUM
];
239 BOOL aFmtsSet
[SVX_MAX_NUM
]; //Flags ueber Gueltigkeit der Ebenen
241 static sal_Int32 nRefCount
;
242 ::com::sun::star::lang::Locale aLocale
;
244 SvxNumRule(ULONG nFeatures
, USHORT nLevels
, BOOL bCont
, SvxNumRuleType eType
= SVX_RULETYPE_NUMBERING
);
245 SvxNumRule(const SvxNumRule
& rCopy
);
246 SvxNumRule(SvStream
&rStream
);
247 virtual ~SvxNumRule();
249 int operator==( const SvxNumRule
& ) const;
250 int operator!=( const SvxNumRule
& rRule
) const {return !(*this == rRule
);}
253 SvStream
& Store(SvStream
&rStream
);
255 const SvxNumberFormat
* Get(USHORT nLevel
)const;
256 const SvxNumberFormat
& GetLevel(USHORT nLevel
)const;
257 void SetLevel(USHORT nLevel
, const SvxNumberFormat
& rFmt
, BOOL bIsValid
= TRUE
);
259 BOOL
IsContinuousNumbering()const
260 {return bContinuousNumbering
;}
261 void SetContinuousNumbering(BOOL bSet
)
262 {bContinuousNumbering
= bSet
;}
264 USHORT
GetLevelCount() const {return nLevelCount
;}
265 BOOL
IsFeatureSupported(ULONG nFeature
) const
266 {return 0 != (nFeatureFlags
& nFeature
);}
267 ULONG
GetFeatureFlags() const {return nFeatureFlags
;}
268 void SetFeatureFlag( ULONG nFlag
, BOOL bSet
= TRUE
) { if(bSet
) nFeatureFlags
|= nFlag
; else nFeatureFlags
&= ~nFlag
; }
271 SvxNumRuleType
GetNumRuleType() const { return eNumberingType
; }
272 void SetNumRuleType( const SvxNumRuleType
& rType
) { eNumberingType
= rType
; }
274 BOOL
UnLinkGraphics();
276 /* -----------------27.10.98 13:04-------------------
278 * --------------------------------------------------*/
279 class SvxNumBulletItem
: public SfxPoolItem
281 SvxNumRule
* pNumRule
;
283 SvxNumBulletItem(SvxNumRule
& rRule
);
284 SvxNumBulletItem(SvxNumRule
& rRule
, USHORT nWhich
);
285 SvxNumBulletItem(const SvxNumBulletItem
& rCopy
);
286 virtual ~SvxNumBulletItem();
288 virtual SfxPoolItem
* Clone( SfxItemPool
*pPool
= 0 ) const;
289 virtual SfxPoolItem
* Create(SvStream
&, USHORT
) const;
290 virtual SvStream
& Store(SvStream
&, USHORT nItemVersion
) const;
291 virtual USHORT
GetVersion( USHORT nFileVersion
) const;
292 virtual int operator==( const SfxPoolItem
& ) const;
294 SvxNumRule
* GetNumRule() const {return pNumRule
;}
296 virtual sal_Bool
PutValue( const ::com::sun::star::uno::Any
& rVal
, BYTE nMemberId
= 0 );
298 /* -----------------28.10.98 15:21-------------------
300 * --------------------------------------------------*/
303 USHORT nLevelVal
[ SVX_MAX_NUM
]; // Nummern aller Levels
304 USHORT nSetValue
; // vorgegebene Nummer
305 BYTE nMyLevel
; // akt. Level
306 BOOL bStartNum
; // Numerierung neu starten
309 inline SvxNodeNum( BYTE nLevel
= SVX_NO_NUM
, USHORT nSetVal
= USHRT_MAX
);
310 inline SvxNodeNum
& operator=( const SvxNodeNum
& rCpy
);
312 // BOOL operator==( const SwNodeNum& ) const;
314 BYTE
GetLevel() const { return nMyLevel
; }
315 void SetLevel( BYTE nVal
) { nMyLevel
= nVal
; }
317 BOOL
IsStart() const { return bStartNum
; }
318 void SetStart( BOOL bFlag
= TRUE
) { bStartNum
= bFlag
; }
320 USHORT
GetSetValue() const { return nSetValue
; }
321 void SetSetValue( USHORT nVal
) { nSetValue
= nVal
; }
323 const USHORT
* GetLevelVal() const { return nLevelVal
; }
324 USHORT
* GetLevelVal() { return nLevelVal
; }
327 SvxNodeNum::SvxNodeNum( BYTE nLevel
, USHORT nSetVal
)
328 : nSetValue( nSetVal
), nMyLevel( nLevel
), bStartNum( FALSE
)
330 memset( nLevelVal
, 0, sizeof( nLevelVal
) );
333 inline SvxNodeNum
& SvxNodeNum::operator=( const SvxNodeNum
& rCpy
)
335 nSetValue
= rCpy
.nSetValue
;
336 nMyLevel
= rCpy
.nMyLevel
;
337 bStartNum
= rCpy
.bStartNum
;
339 memcpy( nLevelVal
, rCpy
.nLevelVal
, sizeof( nLevelVal
) );
343 /* --------------------------------------------------
345 * --------------------------------------------------*/
346 SvxNumRule
* SvxConvertNumRule( const SvxNumRule
* pRule
, USHORT nLevel
, SvxNumRuleType eType
);
348 }//end of namespace binfilter