xref: /trunk/main/editeng/source/items/numitem.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_editeng.hxx"
30 
31 #include <editeng/numitem.hxx>
32 
33 #include <com/sun/star/text/HoriOrientation.hpp>
34 #include <com/sun/star/text/VertOrientation.hpp>
35 #include <com/sun/star/text/RelOrientation.hpp>
36 #include <editeng/brshitem.hxx>
37 #include <vcl/font.hxx>
38 #include <editeng/editids.hrc>
39 #include <editeng/editrids.hrc>
40 #include <editeng/numdef.hxx>
41 #include <vcl/graph.hxx>
42 #include <vcl/window.hxx>
43 #include <vcl/svapp.hxx>
44 #include <editeng/unolingu.hxx>
45 #include <com/sun/star/text/XNumberingFormatter.hpp>
46 #include <com/sun/star/text/XDefaultNumberingProvider.hpp>
47 #include <com/sun/star/style/NumberingType.hpp>
48 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
49 #include <com/sun/star/beans/PropertyValue.hpp>
50 #include <comphelper/processfactory.hxx>
51 
52 #include <editeng/unonrule.hxx>
53 
54 #define MM100_TO_TWIP(MM100)	((MM100*72L+63L)/127L)
55 
56 #define DEF_WRITER_LSPACE 	500		//Standardeinrueckung
57 #define DEF_DRAW_LSPACE 	800		//Standardeinrueckung
58 
59 #define NUMITEM_VERSION_01        0x01
60 #define NUMITEM_VERSION_02        0x02
61 #define NUMITEM_VERSION_03        0x03
62 #define NUMITEM_VERSION_04        0x04
63 
64 using namespace ::com::sun::star;
65 using namespace ::com::sun::star::lang;
66 using namespace ::com::sun::star::uno;
67 using namespace ::com::sun::star::text;
68 using namespace ::com::sun::star::beans;
69 using namespace ::com::sun::star::style;
70 
71 sal_Int32 SvxNumberType::nRefCount = 0;
72 com::sun::star::uno::Reference<com::sun::star::text::XNumberingFormatter> SvxNumberType::xFormatter = 0;
73 void lcl_getFormatter(com::sun::star::uno::Reference<com::sun::star::text::XNumberingFormatter>& _xFormatter)
74 {
75     if(!_xFormatter.is())
76    	{
77 		try
78 		{
79 			Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
80 			Reference < XInterface > xI = xMSF->createInstance(
81 				::rtl::OUString::createFromAscii( "com.sun.star.text.DefaultNumberingProvider" ) );
82 			Reference<XDefaultNumberingProvider> xRet(xI, UNO_QUERY);
83 			DBG_ASSERT(xRet.is(), "service missing: \"com.sun.star.text.DefaultNumberingProvider\"");
84 			_xFormatter = Reference<XNumberingFormatter> (xRet, UNO_QUERY);
85 		}
86 		catch(Exception& )
87 		{
88 		}
89 	}
90 }
91 /* -----------------------------22.02.01 14:24--------------------------------
92 
93  ---------------------------------------------------------------------------*/
94 SvxNumberType::SvxNumberType(sal_Int16 nType) :
95 	nNumType(nType),
96 	bShowSymbol(sal_True)
97 {
98 	nRefCount++;
99 }
100 /* -----------------------------22.02.01 14:31--------------------------------
101 
102  ---------------------------------------------------------------------------*/
103 SvxNumberType::SvxNumberType(const SvxNumberType& rType) :
104 	nNumType(rType.nNumType),
105 	bShowSymbol(rType.bShowSymbol)
106 {
107 	nRefCount++;
108 }
109 /* -----------------------------22.02.01 14:24--------------------------------
110 
111  ---------------------------------------------------------------------------*/
112 SvxNumberType::~SvxNumberType()
113 {
114 	if(!--nRefCount)
115 		xFormatter = 0;
116 }
117 /* -----------------------------22.02.01 11:09--------------------------------
118 
119  ---------------------------------------------------------------------------*/
120 String SvxNumberType::GetNumStr( sal_uLong nNo ) const
121 {
122     LanguageType eLang = Application::GetSettings().GetLanguage();
123 	Locale aLocale = SvxCreateLocale(eLang);
124 	return GetNumStr( nNo, aLocale );
125 }
126 /* -----------------28.10.98 15:56-------------------
127  *
128  * --------------------------------------------------*/
129 String 	SvxNumberType::GetNumStr( sal_uLong nNo, const Locale& rLocale ) const
130 {
131     lcl_getFormatter(xFormatter);
132 	String aTmpStr;
133 	if(!xFormatter.is())
134 		return aTmpStr;
135 
136 	if(bShowSymbol)
137 	{
138 		switch(nNumType)
139 		{
140             case NumberingType::CHAR_SPECIAL:
141             case NumberingType::BITMAP:
142 			break;
143 			default:
144 				{
145 					//#95525# '0' allowed for ARABIC numberings
146 					if(NumberingType::ARABIC == nNumType && 0 == nNo )
147 						aTmpStr = '0';
148 					else
149 					{
150 						Sequence< PropertyValue > aProperties(2);
151 						PropertyValue* pValues = aProperties.getArray();
152 						pValues[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NumberingType"));
153 						pValues[0].Value <<= nNumType;
154 						pValues[1].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value"));
155 						pValues[1].Value <<= (sal_Int32)nNo;
156 
157 						try
158 						{
159 							aTmpStr = xFormatter->makeNumberingString( aProperties, rLocale );
160 						}
161 						catch(Exception&)
162 						{
163 						}
164 					}
165 				}
166 		}
167 	}
168 	return aTmpStr;
169 }
170 /* -----------------27.10.98 10:33-------------------
171  *
172  * --------------------------------------------------*/
173 // --> OD 2008-01-09 #newlistlevelattrs#
174 SvxNumberFormat::SvxNumberFormat( sal_Int16 eType,
175                                   SvxNumPositionAndSpaceMode ePositionAndSpaceMode )
176 // <--
177     : SvxNumberType(eType),
178       eNumAdjust(SVX_ADJUST_LEFT),
179       nInclUpperLevels(0),
180       nStart(1),
181       cBullet(SVX_DEF_BULLET),
182       nBulletRelSize(100),
183       nBulletColor(COL_BLACK),
184       // --> OD 2008-01-09 #newlistlevelattrs#
185       mePositionAndSpaceMode( ePositionAndSpaceMode ),
186       // <--
187       nFirstLineOffset(0),
188       nAbsLSpace(0),
189       nLSpace(0),
190       nCharTextDistance(0),
191       // --> OD 2008-01-09 #newlistlevelattrs#
192       meLabelFollowedBy( LISTTAB ),
193       mnListtabPos( 0 ),
194       mnFirstLineIndent( 0 ),
195       mnIndentAt( 0 ),
196       // <--
197       pGraphicBrush(0),
198       eVertOrient(text::VertOrientation::NONE),
199       pBulletFont(0)
200 {
201 }
202 /* -----------------27.10.98 10:56-------------------
203  *
204  * --------------------------------------------------*/
205 SvxNumberFormat::SvxNumberFormat(const SvxNumberFormat& rFormat) :
206     SvxNumberType(rFormat),
207     // --> OD 2008-01-09 #newlistlevelattrs#
208     mePositionAndSpaceMode( rFormat.mePositionAndSpaceMode ),
209     // <--
210     pGraphicBrush(0),
211     pBulletFont(0)
212 {
213     *this = rFormat;
214 }
215 /* -----------------27.10.98 10:56-------------------
216  *
217  * --------------------------------------------------*/
218 SvxNumberFormat::~SvxNumberFormat()
219 {
220 	delete pGraphicBrush;
221 	delete pBulletFont;
222 }
223 /* -----------------08.12.98 11:14-------------------
224  *
225  * --------------------------------------------------*/
226 SvxNumberFormat::SvxNumberFormat(SvStream &rStream)
227 : mePositionAndSpaceMode( LABEL_WIDTH_AND_POSITION ),
228   meLabelFollowedBy( LISTTAB ),
229   mnListtabPos( 0 ),
230   mnFirstLineIndent( 0 ),
231   mnIndentAt( 0 )
232 {
233 
234     sal_uInt16 nVersion;
235   rStream >> nVersion;
236 
237   sal_uInt16 nUSHORT;
238   rStream >> nUSHORT;
239   SetNumberingType((sal_Int16)nUSHORT);
240   rStream >> nUSHORT;
241   eNumAdjust      = (SvxAdjust)nUSHORT;
242   rStream >> nUSHORT;
243   nInclUpperLevels = (sal_uInt8)nUSHORT;
244   rStream >> nUSHORT;
245   nStart          = nUSHORT;
246   rStream >> nUSHORT;
247   cBullet = nUSHORT;
248 
249   short nShort;
250   rStream >> nShort;
251   nFirstLineOffset        = nShort;
252   rStream >> nShort;
253   nAbsLSpace              = nShort;
254   rStream >> nShort;
255   nLSpace                 = nShort;
256 
257   rStream >> nShort;
258   nCharTextDistance       = nShort;
259   rtl_TextEncoding eEnc = gsl_getSystemTextEncoding();
260   rStream.ReadByteString(sPrefix, eEnc);
261   rStream.ReadByteString(sSuffix, eEnc);
262   rStream.ReadByteString(sCharStyleName, eEnc);
263   rStream >> nUSHORT;
264   if(nUSHORT)
265   {
266         SvxBrushItem aHelper(0);
267       pGraphicBrush = (SvxBrushItem*) aHelper.Create( rStream, BRUSH_GRAPHIC_VERSION );
268   }
269   else
270       pGraphicBrush = 0;
271 
272   rStream >> nUSHORT;
273     eVertOrient          = (sal_Int16)nUSHORT;
274 
275   rStream >> nUSHORT;
276   if(nUSHORT)
277   {
278       pBulletFont = new Font;
279       rStream >> *pBulletFont;
280         if(!pBulletFont->GetCharSet())
281             pBulletFont->SetCharSet(rStream.GetStreamCharSet());
282     }
283   else
284       pBulletFont = 0;
285   rStream >> aGraphicSize;
286 
287   rStream >> nBulletColor;
288   rStream >> nUSHORT;
289   nBulletRelSize = nUSHORT;
290   rStream >> nUSHORT;
291   SetShowSymbol((sal_Bool)nUSHORT);
292 
293   if( nVersion < NUMITEM_VERSION_03 )
294       cBullet = ByteString::ConvertToUnicode( (sal_Char)cBullet,
295                           (pBulletFont&&pBulletFont->GetCharSet()) ?  pBulletFont->GetCharSet()
296                                       : RTL_TEXTENCODING_SYMBOL );
297     if(pBulletFont)
298     {
299         sal_Bool bConvertBulletFont = rStream.GetVersion() <= SOFFICE_FILEFORMAT_50;
300         if(bConvertBulletFont)
301         {
302 
303             FontToSubsFontConverter pConverter =
304                         CreateFontToSubsFontConverter(pBulletFont->GetName(),
305                             FONTTOSUBSFONT_IMPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS);
306             if(pConverter)
307             {
308                 cBullet = ConvertFontToSubsFontChar(pConverter, cBullet);
309                 String sFontName = GetFontToSubsFontName(pConverter);
310                 pBulletFont->SetName(sFontName);
311                 DestroyFontToSubsFontConverter(pConverter);
312             }
313         }
314     }
315 
316     if( NUMITEM_VERSION_04 <= nVersion )
317     {
318         rStream >> nUSHORT;
319         mePositionAndSpaceMode = (SvxNumPositionAndSpaceMode) nUSHORT;
320         rStream >> nUSHORT;
321         meLabelFollowedBy = ( SvxNumLabelFollowedBy ) nUSHORT;
322         long nLong;
323         rStream >> nLong;
324         mnListtabPos = nLong;
325         rStream >> nLong;
326         mnFirstLineIndent = nLong;
327         rStream >> nLong;
328         mnIndentAt = nLong;
329     }
330 }
331 /* -----------------08.12.98 11:14-------------------
332  *
333  * --------------------------------------------------*/
334 SvStream&   SvxNumberFormat::Store(SvStream &rStream, FontToSubsFontConverter pConverter)
335 {
336     if(pConverter && pBulletFont)
337     {
338         cBullet = ConvertFontToSubsFontChar(pConverter, cBullet);
339         String sFontName = GetFontToSubsFontName(pConverter);
340         pBulletFont->SetName(sFontName);
341     }
342 
343     rStream << (sal_uInt16)NUMITEM_VERSION_04;
344 
345     rStream << (sal_uInt16)GetNumberingType();
346     rStream << (sal_uInt16)eNumAdjust;
347     rStream << (sal_uInt16)nInclUpperLevels;
348     rStream << nStart;
349     rStream << (sal_uInt16)cBullet;
350 
351     rStream << nFirstLineOffset;
352     rStream << nAbsLSpace;
353     rStream << nLSpace;
354 
355     rStream << nCharTextDistance;
356     rtl_TextEncoding eEnc = gsl_getSystemTextEncoding();
357     rStream.WriteByteString(sPrefix, eEnc);
358     rStream.WriteByteString(sSuffix, eEnc);
359     rStream.WriteByteString(sCharStyleName, eEnc);
360     if(pGraphicBrush)
361     {
362         rStream << (sal_uInt16)1;
363 
364         // #75113# in SD or SI force bullet itself to be stored,
365         // for that purpose throw away link when link and graphic
366         // are present, so Brush save is forced
367         if(pGraphicBrush->GetGraphicLink() && pGraphicBrush->GetGraphic())
368         {
369             String aEmpty;
370             pGraphicBrush->SetGraphicLink(aEmpty);
371         }
372 
373         pGraphicBrush->Store(rStream, BRUSH_GRAPHIC_VERSION);
374     }
375     else
376         rStream << (sal_uInt16)0;
377 
378     rStream << (sal_uInt16)eVertOrient;
379     if(pBulletFont)
380     {
381         rStream << (sal_uInt16)1;
382         rStream << *pBulletFont;
383     }
384     else
385         rStream << (sal_uInt16)0;
386     rStream << aGraphicSize;
387 
388     Color nTempColor = nBulletColor;
389     if(COL_AUTO == nBulletColor.GetColor())
390         nTempColor = COL_BLACK;
391     rStream << nTempColor;
392     rStream << nBulletRelSize;
393     rStream << (sal_uInt16)IsShowSymbol();
394 
395     rStream << ( sal_uInt16 ) mePositionAndSpaceMode;
396     rStream << ( sal_uInt16 ) meLabelFollowedBy;
397     rStream << ( long ) mnListtabPos;
398     rStream << ( long ) mnFirstLineIndent;
399     rStream << ( long ) mnIndentAt;
400 
401     return rStream;
402 }
403 
404 /* -----------------------------23.02.01 11:10--------------------------------
405 
406  ---------------------------------------------------------------------------*/
407 SvxNumberFormat& SvxNumberFormat::operator=( const SvxNumberFormat& rFormat )
408 {
409     if (& rFormat == this) { return *this; }
410 
411 	SetNumberingType(rFormat.GetNumberingType());
412 		eNumAdjust			= rFormat.eNumAdjust ;
413 		nInclUpperLevels 	= rFormat.nInclUpperLevels ;
414 		nStart				= rFormat.nStart ;
415 		cBullet				= rFormat.cBullet ;
416         // --> OD 2008-01-09 #newlistlevelattrs#
417         mePositionAndSpaceMode = rFormat.mePositionAndSpaceMode;
418         // <--
419 		nFirstLineOffset	= rFormat.nFirstLineOffset;
420 		nAbsLSpace			= rFormat.nAbsLSpace ;
421 		nLSpace             = rFormat.nLSpace ;
422 		nCharTextDistance	= rFormat.nCharTextDistance ;
423         // --> OD 2008-01-09 #newlistlevelattrs#
424         meLabelFollowedBy = rFormat.meLabelFollowedBy;
425         mnListtabPos = rFormat.mnListtabPos;
426         mnFirstLineIndent = rFormat.mnFirstLineIndent;
427         mnIndentAt = rFormat.mnIndentAt;
428         // <--
429         eVertOrient         = rFormat.eVertOrient ;
430 		sPrefix  			= rFormat.sPrefix     ;
431 		sSuffix             = rFormat.sSuffix     ;
432 		aGraphicSize		= rFormat.aGraphicSize  ;
433 		nBulletColor 		= rFormat.nBulletColor   ;
434 		nBulletRelSize      = rFormat.nBulletRelSize;
435 		SetShowSymbol(rFormat.IsShowSymbol());
436 		sCharStyleName      = rFormat.sCharStyleName;
437 	DELETEZ(pGraphicBrush);
438 	if(rFormat.pGraphicBrush)
439     {
440 		pGraphicBrush = new SvxBrushItem(*rFormat.pGraphicBrush);
441         pGraphicBrush->SetDoneLink( STATIC_LINK( this, SvxNumberFormat, GraphicArrived) );
442     }
443 	DELETEZ(pBulletFont);
444 	if(rFormat.pBulletFont)
445 			pBulletFont = new Font(*rFormat.pBulletFont);
446 	return *this;
447 }
448 /* -----------------27.10.98 10:56-------------------
449  *
450  * --------------------------------------------------*/
451 sal_Bool  SvxNumberFormat::operator==( const SvxNumberFormat& rFormat) const
452 {
453 	if( GetNumberingType()  != rFormat.GetNumberingType() ||
454 		eNumAdjust			!= rFormat.eNumAdjust ||
455 		nInclUpperLevels 	!= rFormat.nInclUpperLevels ||
456 		nStart				!= rFormat.nStart ||
457 		cBullet				!= rFormat.cBullet ||
458         // --> OD 2008-01-09 #newlistlevelattrs#
459         mePositionAndSpaceMode != rFormat.mePositionAndSpaceMode ||
460         // <--
461 		nFirstLineOffset	!= rFormat.nFirstLineOffset ||
462 		nAbsLSpace			!= rFormat.nAbsLSpace ||
463 		nLSpace             != rFormat.nLSpace ||
464 		nCharTextDistance	!= rFormat.nCharTextDistance ||
465         // --> OD 2008-01-09 #newlistlevelattrs#
466         meLabelFollowedBy != rFormat.meLabelFollowedBy ||
467         mnListtabPos != rFormat.mnListtabPos ||
468         mnFirstLineIndent != rFormat.mnFirstLineIndent ||
469         mnIndentAt != rFormat.mnIndentAt ||
470         // <--
471 		eVertOrient			!= rFormat.eVertOrient ||
472 		sPrefix  			!= rFormat.sPrefix     ||
473 		sSuffix             != rFormat.sSuffix     ||
474 		aGraphicSize		!= rFormat.aGraphicSize  ||
475 		nBulletColor 		!= rFormat.nBulletColor   ||
476 		nBulletRelSize      != rFormat.nBulletRelSize ||
477 		IsShowSymbol()		!= rFormat.IsShowSymbol() ||
478 		sCharStyleName      != rFormat.sCharStyleName
479 		)
480 		return sal_False;
481 	if (
482         (pGraphicBrush && !rFormat.pGraphicBrush) ||
483         (!pGraphicBrush && rFormat.pGraphicBrush) ||
484         (pGraphicBrush && *pGraphicBrush != *rFormat.pGraphicBrush)
485        )
486     {
487 		return sal_False;
488     }
489 	if (
490         (pBulletFont && !rFormat.pBulletFont) ||
491         (!pBulletFont && rFormat.pBulletFont) ||
492         (pBulletFont && *pBulletFont != *rFormat.pBulletFont)
493        )
494     {
495 		return sal_False;
496     }
497 	return sal_True;
498 }
499 /* -----------------28.10.98 09:53-------------------
500  *
501  * --------------------------------------------------*/
502 void SvxNumberFormat::SetGraphicBrush( const SvxBrushItem* pBrushItem,
503                     const Size* pSize, const sal_Int16* pOrient)
504 {
505 	if(!pBrushItem)
506 	{
507 		delete pGraphicBrush;
508 		pGraphicBrush = 0;
509 	}
510 	else if ( !pGraphicBrush || (pGraphicBrush && !(*pBrushItem == *pGraphicBrush)) )
511 	{
512 		delete pGraphicBrush;
513 		pGraphicBrush =  (SvxBrushItem*)pBrushItem->Clone();
514         pGraphicBrush->SetDoneLink( STATIC_LINK( this, SvxNumberFormat, GraphicArrived) );
515    }
516 
517 	if(pOrient)
518 		eVertOrient = *pOrient;
519 	else
520         eVertOrient = text::VertOrientation::NONE;
521 	if(pSize)
522 		aGraphicSize = *pSize;
523 	else
524 		aGraphicSize.Width() = aGraphicSize.Height() = 0;
525 }
526 /* -----------------28.10.98 09:59-------------------
527  *
528  * --------------------------------------------------*/
529 void SvxNumberFormat::SetGraphic( const String& rName )
530 {
531 	const String* pName;
532 	if( pGraphicBrush &&
533 			0 != (pName = pGraphicBrush->GetGraphicLink())
534 				&& *pName == rName )
535 		return ;
536 
537 	delete pGraphicBrush;
538 	String sTmp;
539     pGraphicBrush = new SvxBrushItem( rName, sTmp, GPOS_AREA, 0 );
540 	pGraphicBrush->SetDoneLink( STATIC_LINK( this, SvxNumberFormat, GraphicArrived) );
541     if( eVertOrient == text::VertOrientation::NONE )
542         eVertOrient = text::VertOrientation::TOP;
543 
544 	aGraphicSize.Width() = aGraphicSize.Height() = 0;
545 }
546 /* -----------------------------22.02.01 15:55--------------------------------
547 
548  ---------------------------------------------------------------------------*/
549 void SvxNumberFormat::SetVertOrient(sal_Int16 eSet)
550 {
551 	eVertOrient = eSet;
552 }
553 /* -----------------------------22.02.01 15:55--------------------------------
554 
555  ---------------------------------------------------------------------------*/
556 sal_Int16    SvxNumberFormat::GetVertOrient() const
557 {
558 	return eVertOrient;
559 }
560 /* -----------------28.10.98 09:59-------------------
561  *
562  * --------------------------------------------------*/
563 void SvxNumberFormat::SetBulletFont(const Font* pFont)
564 {
565 	delete pBulletFont;
566 	pBulletFont = pFont ? new Font(*pFont): 0;
567 }
568 
569 // --> OD 2008-01-09 #newlistlevelattrs#
570 SvxNumberFormat::SvxNumPositionAndSpaceMode SvxNumberFormat::GetPositionAndSpaceMode() const
571 {
572     return mePositionAndSpaceMode;
573 }
574 void SvxNumberFormat::SetPositionAndSpaceMode( SvxNumPositionAndSpaceMode ePositionAndSpaceMode )
575 {
576     mePositionAndSpaceMode = ePositionAndSpaceMode;
577 }
578 
579 short SvxNumberFormat::GetLSpace() const
580 {
581 //#if OSL_DEBUG_LEVEL > 1
582 //    DBG_ASSERT( mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION,
583 //                "<SvxNumberFormat::GetLSpace()> - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION");
584 //#endif
585     return mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION ? nLSpace : 0;
586 }
587 short SvxNumberFormat::GetAbsLSpace() const
588 {
589 //#if OSL_DEBUG_LEVEL > 1
590 //    DBG_ASSERT( mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION,
591 //                "<SvxNumberFormat::GetAbsLSpace()> - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION");
592 //#endif
593     return mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION
594            ? nAbsLSpace
595            : static_cast<short>( GetFirstLineIndent() + GetIndentAt() );
596 }
597 short SvxNumberFormat::GetFirstLineOffset() const
598 {
599 //#if OSL_DEBUG_LEVEL > 1
600 //    DBG_ASSERT( mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION,
601 //                "<SvxNumberFormat::GetFirstLineOffset()> - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION");
602 //#endif
603     return mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION
604            ? nFirstLineOffset
605            : static_cast<short>( GetFirstLineIndent() );
606 }
607 short SvxNumberFormat::GetCharTextDistance() const
608 {
609 //#if OSL_DEBUG_LEVEL > 1
610 //    DBG_ASSERT( mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION,
611 //                "<SvxNumberFormat::GetCharTextDistance()> - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION");
612 //#endif
613     return mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION ? nCharTextDistance : 0;
614 }
615 
616 void SvxNumberFormat::SetLabelFollowedBy( const SvxNumLabelFollowedBy eLabelFollowedBy )
617 {
618     meLabelFollowedBy = eLabelFollowedBy;
619 }
620 SvxNumberFormat::SvxNumLabelFollowedBy SvxNumberFormat::GetLabelFollowedBy() const
621 {
622     return meLabelFollowedBy;
623 }
624 void SvxNumberFormat::SetListtabPos( const long nListtabPos )
625 {
626     mnListtabPos = nListtabPos;
627 }
628 long SvxNumberFormat::GetListtabPos() const
629 {
630     return mnListtabPos;
631 }
632 void SvxNumberFormat::SetFirstLineIndent( const long nFirstLineIndent )
633 {
634     mnFirstLineIndent = nFirstLineIndent;
635 }
636 long SvxNumberFormat::GetFirstLineIndent() const
637 {
638     return mnFirstLineIndent;
639 }
640 void SvxNumberFormat::SetIndentAt( const long nIndentAt )
641 {
642     mnIndentAt = nIndentAt;
643 }
644 long SvxNumberFormat::GetIndentAt() const
645 {
646     return mnIndentAt;
647 }
648 // <--
649 
650 /* -----------------28.10.98 10:03-------------------
651  *
652  * --------------------------------------------------*/
653 IMPL_STATIC_LINK( SvxNumberFormat, GraphicArrived, void *, EMPTYARG )
654 {
655 	// ggfs. die GrfSize setzen:
656 	if( !pThis->aGraphicSize.Width() || !pThis->aGraphicSize.Height() )
657 	{
658 		const Graphic* pGrf = pThis->pGraphicBrush->GetGraphic();
659 		if( pGrf )
660 			pThis->aGraphicSize = SvxNumberFormat::GetGraphicSizeMM100( pGrf );
661 	}
662     pThis->NotifyGraphicArrived();
663 	return 0;
664 }
665 /* -----------------------------02.07.01 15:36--------------------------------
666 
667  ---------------------------------------------------------------------------*/
668 void SvxNumberFormat::NotifyGraphicArrived()
669 {
670 }
671 
672 /* -----------------28.10.98 10:38-------------------
673  *
674  * --------------------------------------------------*/
675 Size SvxNumberFormat::GetGraphicSizeMM100(const Graphic* pGraphic)
676 {
677 	const MapMode aMapMM100( MAP_100TH_MM );
678 	const Size& rSize = pGraphic->GetPrefSize();
679 	Size aRetSize;
680 	if ( pGraphic->GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
681 	{
682 		OutputDevice* pOutDev = Application::GetDefaultDevice();
683 		MapMode aOldMap( pOutDev->GetMapMode() );
684 		pOutDev->SetMapMode( aMapMM100 );
685 		aRetSize = pOutDev->PixelToLogic( rSize );
686 		pOutDev->SetMapMode( aOldMap );
687 	}
688 	else
689 		aRetSize = OutputDevice::LogicToLogic( rSize, pGraphic->GetPrefMapMode(), aMapMM100 );
690 	return aRetSize;
691 }
692 /* -----------------28.10.98 15:57-------------------
693  *
694  * --------------------------------------------------*/
695 String SvxNumberFormat::CreateRomanString( sal_uLong nNo, sal_Bool bUpper )
696 {
697 	nNo %= 4000;			// mehr kann nicht dargestellt werden
698 //		i, ii, iii, iv, v, vi, vii, vii, viii, ix
699 //							(Dummy),1000,500,100,50,10,5,1
700 	const char *cRomanArr = bUpper
701 						? "MDCLXVI--"	// +2 Dummy-Eintraege !!
702 						: "mdclxvi--";	// +2 Dummy-Eintraege !!
703 
704 	String sRet;
705 	sal_uInt16 nMask = 1000;
706 	while( nMask )
707 	{
708 		sal_uInt8 nZahl = sal_uInt8(nNo / nMask);
709 		sal_uInt8 nDiff = 1;
710 		nNo %= nMask;
711 
712 		if( 5 < nZahl )
713 		{
714 			if( nZahl < 9 )
715 				sRet += sal_Unicode(*(cRomanArr-1));
716 			++nDiff;
717 			nZahl -= 5;
718 		}
719 		switch( nZahl )
720 		{
721 		case 3:		{ sRet += sal_Unicode(*cRomanArr); }
722 		case 2:		{ sRet += sal_Unicode(*cRomanArr); }
723 		case 1:		{ sRet += sal_Unicode(*cRomanArr); }
724 					break;
725 
726 		case 4:		{
727 						sRet += sal_Unicode(*cRomanArr);
728 						sRet += sal_Unicode(*(cRomanArr-nDiff));
729 					}
730 					break;
731 		case 5:		{ sRet += sal_Unicode(*(cRomanArr-nDiff)); }
732 					break;
733 		}
734 
735 		nMask /= 10;			// zur naechsten Dekade
736 		cRomanArr += 2;
737 	}
738 	return sRet;
739 }
740 #ifdef OLD_NUMBER_FORMATTING
741 void SvxNumberFormat::GetCharStr( sal_uLong nNo, String& rStr ) const
742 {
743 	DBG_ASSERT( nNo, "0 ist eine ungueltige Nummer !!" );
744 
745 	const sal_uLong coDiff = 'Z' - 'A' +1;
746 	char cAdd = (SVX_NUM_CHARS_UPPER_LETTER == eNumType ? 'A' : 'a') - 1;
747 	sal_uLong nCalc;
748 
749 	do {
750 		nCalc = nNo % coDiff;
751 		if( !nCalc )
752 			nCalc = coDiff;
753 		rStr.Insert( sal_Unicode(cAdd + nCalc ), 0 );
754 		nNo -= nCalc;
755 		if( nNo )
756 			nNo /= coDiff;
757 	} while( nNo );
758 }
759 
760 void SvxNumberFormat::GetCharStrN( sal_uLong nNo, String& rStr ) const
761 {
762 	DBG_ASSERT( nNo, "0 ist eine ungueltige Nummer !!" );
763 
764 	const sal_uLong coDiff = 'Z' - 'A' +1;
765 	char cChar = (char)(--nNo % coDiff);
766 	if( SVX_NUM_CHARS_UPPER_LETTER_N == eNumType )
767 		cChar += 'A';
768 	else
769 		cChar += 'a';
770 
771 	rStr.Fill( (sal_uInt16)(nNo / coDiff) + 1, sal_Unicode(cChar) );
772 }
773 #endif //OLD_NUMBER_FORMATTING
774 /* -----------------------------22.02.01 13:31--------------------------------
775 
776  ---------------------------------------------------------------------------*/
777 const String&	SvxNumberFormat::GetCharFmtName()const
778 {
779 	return sCharStyleName;
780 }
781 /* -----------------27.10.98 10:38-------------------
782  *
783  * --------------------------------------------------*/
784 sal_Int32 SvxNumRule::nRefCount = 0;
785 static SvxNumberFormat*	pStdNumFmt = 0;
786 static SvxNumberFormat*	pStdOutlineNumFmt = 0;
787 // --> OD 2008-02-11 #newlistlevelattrs#
788 SvxNumRule::SvxNumRule( sal_uLong nFeatures,
789                         sal_uInt16 nLevels,
790                         sal_Bool bCont,
791                         SvxNumRuleType eType,
792                         SvxNumberFormat::SvxNumPositionAndSpaceMode
793                                     eDefaultNumberFormatPositionAndSpaceMode )
794     : nLevelCount(nLevels),
795       nFeatureFlags(nFeatures),
796       eNumberingType(eType),
797       bContinuousNumbering(bCont)
798 {
799 	++nRefCount;
800     LanguageType eLang = Application::GetSettings().GetLanguage();
801 	aLocale = SvxCreateLocale(eLang);
802 	for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
803 	{
804 		if(i < nLevels)
805 		{
806 			aFmts[i] = new SvxNumberFormat(SVX_NUM_CHARS_UPPER_LETTER);
807 			//daran wird zwischen writer und draw unterschieden
808 			if(nFeatures & NUM_CONTINUOUS)
809 			{
810                 // --> OD 2008-02-11 #newlistlevelattrs#
811                 if ( eDefaultNumberFormatPositionAndSpaceMode ==
812                                     SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
813                 {
814                     aFmts[i]->SetLSpace( MM100_TO_TWIP(DEF_WRITER_LSPACE) );
815                     aFmts[i]->SetAbsLSpace( MM100_TO_TWIP(DEF_WRITER_LSPACE * (i+1)) );
816                     aFmts[i]->SetFirstLineOffset(MM100_TO_TWIP(-DEF_WRITER_LSPACE));
817                 }
818                 else if ( eDefaultNumberFormatPositionAndSpaceMode ==
819                                             SvxNumberFormat::LABEL_ALIGNMENT )
820                 {
821                     // first line indent of general numbering in inch: -0,25 inch
822                     const long cFirstLineIndent = -1440/4;
823                     // indent values of general numbering in inch:
824                     //  0,5         0,75        1,0         1,25        1,5
825                     //  1,75        2,0         2,25        2,5         2,75
826                     const long cIndentAt = 1440/4;
827                     aFmts[i]->SetPositionAndSpaceMode( SvxNumberFormat::LABEL_ALIGNMENT );
828                     aFmts[i]->SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
829                     aFmts[i]->SetListtabPos( cIndentAt * (i+2) );
830                     aFmts[i]->SetFirstLineIndent( cFirstLineIndent );
831                     aFmts[i]->SetIndentAt( cIndentAt * (i+2) );
832                 }
833                 // <--
834 			}
835 			else
836 			{
837 				aFmts[i]->SetLSpace( DEF_DRAW_LSPACE );
838 				aFmts[i]->SetAbsLSpace( DEF_DRAW_LSPACE * (i) );
839 			}
840 		}
841 		else
842 			aFmts[i] = 0;
843 		aFmtsSet[i] = sal_False;
844 	}
845 }
846 /* -----------------27.10.98 10:41-------------------
847  *
848  * --------------------------------------------------*/
849 SvxNumRule::SvxNumRule(const SvxNumRule& rCopy)
850 {
851 	++nRefCount;
852 	aLocale				= rCopy.aLocale;
853 	nLevelCount          = rCopy.nLevelCount         ;
854 	nFeatureFlags        = rCopy.nFeatureFlags       ;
855 	bContinuousNumbering = rCopy.bContinuousNumbering;
856 	eNumberingType		 = rCopy.eNumberingType;
857 	memset( aFmts, 0, sizeof( aFmts ));
858 	for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
859 	{
860 		if(rCopy.aFmts[i])
861 			aFmts[i] = new SvxNumberFormat(*rCopy.aFmts[i]);
862 		else
863 			aFmts[i] = 0;
864 		aFmtsSet[i] = rCopy.aFmtsSet[i];
865 	}
866 }
867 /* -----------------08.12.98 11:07-------------------
868  *
869  * --------------------------------------------------*/
870 SvxNumRule::SvxNumRule(SvStream &rStream)
871 {
872     ++nRefCount;
873     LanguageType eLang = Application::GetSettings().GetLanguage();
874     aLocale = SvxCreateLocale(eLang);
875     sal_uInt16 nVersion;
876     sal_uInt16 nTemp;
877     rStream >> nVersion;
878     rStream >> nLevelCount;
879     rStream >> nTemp;
880     nFeatureFlags = nTemp;
881     rStream >> nTemp;
882     bContinuousNumbering = (sal_Bool)nTemp;
883     rStream >> nTemp;
884     eNumberingType       = (SvxNumRuleType)nTemp;
885     memset( aFmts, 0, sizeof( aFmts ));
886 
887     for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
888     {
889         sal_uInt16 nSet;
890         rStream >> nSet;
891         if(nSet)
892             aFmts[i] = new SvxNumberFormat(rStream);
893         else
894             aFmts[i] = 0;
895         aFmtsSet[i] = aFmts[i] ? sal_True : sal_False;
896     }
897     if(NUMITEM_VERSION_02 <= nVersion)
898     {
899         sal_uInt16 nShort;
900         rStream >> nShort;
901         nFeatureFlags = nShort;
902     }
903 }
904 
905 /* -----------------08.12.98 11:07-------------------
906  *
907  * --------------------------------------------------*/
908 SvStream&   SvxNumRule::Store(SvStream &rStream)
909 {
910     rStream<<(sal_uInt16)NUMITEM_VERSION_03;
911     rStream<<nLevelCount;
912     //first save of nFeatureFlags for old versions
913     rStream<<(sal_uInt16)nFeatureFlags;
914     rStream<<(sal_uInt16)bContinuousNumbering;
915     rStream<<(sal_uInt16)eNumberingType;
916 
917     FontToSubsFontConverter pConverter = 0;
918     sal_Bool bConvertBulletFont = rStream.GetVersion() <= SOFFICE_FILEFORMAT_50;
919     for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
920     {
921         if(aFmts[i])
922         {
923             rStream << sal_uInt16(1);
924             if(bConvertBulletFont && aFmts[i]->GetBulletFont())
925             {
926                 if(!pConverter)
927                     pConverter =
928                         CreateFontToSubsFontConverter(aFmts[i]->GetBulletFont()->GetName(),
929                                     FONTTOSUBSFONT_EXPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS);
930             }
931             aFmts[i]->Store(rStream, pConverter);
932         }
933         else
934             rStream << sal_uInt16(0);
935     }
936     //second save of nFeatureFlags for new versions
937     rStream<<(sal_uInt16)nFeatureFlags;
938     if(pConverter)
939         DestroyFontToSubsFontConverter(pConverter);
940 
941     return rStream;
942 }
943 
944 /* -----------------27.10.98 10:41-------------------
945  *
946  * --------------------------------------------------*/
947 SvxNumRule::~SvxNumRule()
948 {
949 	for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
950 		delete aFmts[i];
951 	if(!--nRefCount)
952 	{
953 		DELETEZ(pStdNumFmt);
954 		DELETEZ(pStdOutlineNumFmt);
955 	}
956 }
957 /* -----------------29.10.98 16:07-------------------
958  *
959  * --------------------------------------------------*/
960 SvxNumRule& SvxNumRule::operator=( const SvxNumRule& rCopy )
961 {
962 	nLevelCount          = rCopy.nLevelCount;
963 	nFeatureFlags        = rCopy.nFeatureFlags;
964 	bContinuousNumbering = rCopy.bContinuousNumbering;
965 	eNumberingType       = rCopy.eNumberingType;
966 	for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
967 	{
968 		delete aFmts[i];
969 		if(rCopy.aFmts[i])
970 			aFmts[i] = new SvxNumberFormat(*rCopy.aFmts[i]);
971 		else
972 			aFmts[i] = 0;
973 		aFmtsSet[i] = rCopy.aFmtsSet[i];
974 	}
975 	return *this;
976 }
977 /* -----------------27.10.98 10:41-------------------
978  *
979  * --------------------------------------------------*/
980 int   SvxNumRule::operator==( const SvxNumRule& rCopy) const
981 {
982 	if(nLevelCount != rCopy.nLevelCount ||
983 		nFeatureFlags != rCopy.nFeatureFlags ||
984 			bContinuousNumbering != rCopy.bContinuousNumbering ||
985 				eNumberingType != rCopy.eNumberingType)
986 			return sal_False;
987 	for(sal_uInt16 i = 0; i < nLevelCount; i++)
988 	{
989 		if (
990             (aFmtsSet[i] != rCopy.aFmtsSet[i]) ||
991 		    (!aFmts[i] && rCopy.aFmts[i]) ||
992 		    (aFmts[i] && !rCopy.aFmts[i]) ||
993 		    (aFmts[i] && *aFmts[i] !=  *rCopy.aFmts[i])
994            )
995         {
996 			return sal_False;
997         }
998 	}
999 	return sal_True;
1000 }
1001 /* -----------------27.10.98 10:41-------------------
1002  *
1003  * --------------------------------------------------*/
1004 const SvxNumberFormat* 	SvxNumRule::Get(sal_uInt16 nLevel)const
1005 {
1006 	DBG_ASSERT(nLevel < SVX_MAX_NUM, "falsches Level" );
1007 	if( nLevel < SVX_MAX_NUM )
1008 		return aFmtsSet[nLevel] ? aFmts[nLevel] : 0;
1009 	else
1010 		return 0;
1011 }
1012 /* -----------------02.11.98 09:10-------------------
1013  *
1014  * --------------------------------------------------*/
1015 const SvxNumberFormat& 	SvxNumRule::GetLevel(sal_uInt16 nLevel)const
1016 {
1017 	if(!pStdNumFmt)
1018 	{
1019 		pStdNumFmt = new SvxNumberFormat(SVX_NUM_ARABIC);
1020 	 	pStdOutlineNumFmt = new SvxNumberFormat(SVX_NUM_NUMBER_NONE);
1021 	}
1022 
1023 	DBG_ASSERT(nLevel < SVX_MAX_NUM, "falsches Level" );
1024 
1025 	return ( ( nLevel < SVX_MAX_NUM ) && aFmts[nLevel] ) ?
1026 			*aFmts[nLevel] :  eNumberingType == SVX_RULETYPE_NUMBERING ?
1027 														*pStdNumFmt : *pStdOutlineNumFmt;
1028 }
1029 
1030 /* -----------------29.10.98 09:08-------------------
1031  *
1032  * --------------------------------------------------*/
1033 void SvxNumRule::SetLevel( sal_uInt16 i, const SvxNumberFormat& rNumFmt, sal_Bool bIsValid )
1034 {
1035 	DBG_ASSERT(i < SVX_MAX_NUM, "falsches Level" );
1036 
1037 	if( (i < SVX_MAX_NUM) && (!aFmtsSet[i] || !(rNumFmt == *Get( i ))) )
1038 	{
1039 		delete aFmts[ i ];
1040 		aFmts[ i ] = new SvxNumberFormat( rNumFmt );
1041 		aFmtsSet[i] = bIsValid;
1042 //		bInvalidRuleFlag = sal_True;
1043 	}
1044 }
1045 /* -----------------30.10.98 12:44-------------------
1046  *
1047  * --------------------------------------------------*/
1048 void SvxNumRule::SetLevel(sal_uInt16 nLevel, const SvxNumberFormat* pFmt)
1049 {
1050 	DBG_ASSERT(nLevel < SVX_MAX_NUM, "falsches Level" );
1051 
1052 	if( nLevel < SVX_MAX_NUM )
1053 	{
1054 		aFmtsSet[nLevel] = 0 != pFmt;
1055 		if(pFmt)
1056 			SetLevel(nLevel, *pFmt);
1057 		else
1058 		{
1059 			delete aFmts[nLevel];
1060 			aFmts[nLevel] = 0;
1061 		}
1062 	}
1063 }
1064 /* -----------------28.10.98 15:38-------------------
1065  *
1066  * --------------------------------------------------*/
1067 String 	SvxNumRule::MakeNumString( const SvxNodeNum& rNum, sal_Bool bInclStrings ) const
1068 {
1069 	String aStr;
1070 	if( SVX_NO_NUM > rNum.GetLevel() && !( SVX_NO_NUMLEVEL & rNum.GetLevel() ) )
1071 	{
1072 		const SvxNumberFormat& rMyNFmt = GetLevel( rNum.GetLevel() );
1073 		if( SVX_NUM_NUMBER_NONE != rMyNFmt.GetNumberingType() )
1074 		{
1075 			sal_uInt8 i = rNum.GetLevel();
1076 
1077 			if( !IsContinuousNumbering() &&
1078 				1 < rMyNFmt.GetIncludeUpperLevels() )		// nur der eigene Level ?
1079 			{
1080 				sal_uInt8 n = rMyNFmt.GetIncludeUpperLevels();
1081 				if( 1 < n )
1082 				{
1083 					if( i+1 >= n )
1084 						i -= n - 1;
1085 					else
1086 						i = 0;
1087 				}
1088 			}
1089 
1090 			for( ; i <= rNum.GetLevel(); ++i )
1091 			{
1092 				const SvxNumberFormat& rNFmt = GetLevel( i );
1093 				if( SVX_NUM_NUMBER_NONE == rNFmt.GetNumberingType() )
1094 				{
1095 	// Soll aus 1.1.1 --> 2. NoNum --> 1..1 oder 1.1 ??
1096 	//                 if( i != rNum.nMyLevel )
1097 	//                    aStr += aDotStr;
1098 					continue;
1099 				}
1100 
1101 				sal_Bool bDot = sal_True;
1102 				if( rNum.GetLevelVal()[ i ] )
1103 				{
1104 					if(SVX_NUM_BITMAP != rNFmt.GetNumberingType())
1105 						aStr += rNFmt.GetNumStr( rNum.GetLevelVal()[ i ], aLocale );
1106 					else
1107 						bDot = sal_False;
1108 				}
1109 				else
1110 					aStr += sal_Unicode('0');		// alle 0-Level sind eine 0
1111 				if( i != rNum.GetLevel() && bDot)
1112 					aStr += sal_Unicode('.');
1113 			}
1114 		}
1115 
1116 		if( bInclStrings )
1117 		{
1118 			aStr.Insert( rMyNFmt.GetPrefix(), 0 );
1119 			aStr += rMyNFmt.GetSuffix();
1120 		}
1121 	}
1122 	return aStr;
1123 }
1124 /* -----------------18.08.99 10:18-------------------
1125 	Description: changes linked to embedded bitmaps
1126  --------------------------------------------------*/
1127 sal_Bool SvxNumRule::UnLinkGraphics()
1128 {
1129 	sal_Bool bRet = sal_False;
1130 	for(sal_uInt16 i = 0; i < GetLevelCount(); i++)
1131 	{
1132 		SvxNumberFormat aFmt(GetLevel(i));
1133 		const SvxBrushItem* pBrush = aFmt.GetBrush();
1134 		const String* pLinkStr;
1135 		const Graphic* pGraphic;
1136 		if(SVX_NUM_BITMAP == aFmt.GetNumberingType())
1137 		{
1138 			if(pBrush &&
1139 				0 != (pLinkStr = pBrush->GetGraphicLink()) &&
1140 					pLinkStr->Len() &&
1141 					0 !=(pGraphic = pBrush->GetGraphic()))
1142 			{
1143 				SvxBrushItem aTempItem(*pBrush);
1144 				aTempItem.SetGraphicLink( String());
1145 				aTempItem.SetGraphic(*pGraphic);
1146                 sal_Int16    eOrient = aFmt.GetVertOrient();
1147 				aFmt.SetGraphicBrush( &aTempItem, &aFmt.GetGraphicSize(), &eOrient );
1148 				bRet = sal_True;
1149 			}
1150 		}
1151 		else if((SVX_NUM_BITMAP|LINK_TOKEN) == aFmt.GetNumberingType())
1152 			aFmt.SetNumberingType(SVX_NUM_BITMAP);
1153 		SetLevel(i, aFmt);
1154 	}
1155 	return bRet;
1156 }
1157 
1158 /* -----------------27.10.98 10:41-------------------
1159  *
1160  * --------------------------------------------------*/
1161 SvxNumBulletItem::SvxNumBulletItem(SvxNumRule& rRule) :
1162 	SfxPoolItem(SID_ATTR_NUMBERING_RULE),
1163 	pNumRule(new SvxNumRule(rRule))
1164 {
1165 }
1166 
1167 /*-----------------23.11.98 10:36-------------------
1168  MT: Das sind ja sehr sinnige Kommentare...
1169 --------------------------------------------------*/
1170 SvxNumBulletItem::SvxNumBulletItem(SvxNumRule& rRule, sal_uInt16 _nWhich ) :
1171     SfxPoolItem(_nWhich),
1172 	pNumRule(new SvxNumRule(rRule))
1173 {
1174 }
1175 
1176 SfxPoolItem* SvxNumBulletItem::Create(SvStream &s, sal_uInt16 n) const
1177 {
1178     return SfxPoolItem::Create(s, n );
1179 }
1180 
1181 /* -----------------27.10.98 10:41-------------------
1182  *
1183  * --------------------------------------------------*/
1184 SvxNumBulletItem::SvxNumBulletItem(const SvxNumBulletItem& rCopy) :
1185 	SfxPoolItem(rCopy.Which())
1186 {
1187 	pNumRule = new SvxNumRule(*rCopy.pNumRule);
1188 }
1189 /* -----------------27.10.98 10:41-------------------
1190  *
1191  * --------------------------------------------------*/
1192 SvxNumBulletItem::~SvxNumBulletItem()
1193 {
1194 	delete pNumRule;
1195 }
1196 
1197 /* -----------------27.10.98 10:41-------------------
1198  *
1199  * --------------------------------------------------*/
1200 int  SvxNumBulletItem::operator==( const SfxPoolItem& rCopy) const
1201 {
1202 	return *pNumRule == *((SvxNumBulletItem&)rCopy).pNumRule;
1203 }
1204 /* -----------------27.10.98 10:41-------------------
1205  *
1206  * --------------------------------------------------*/
1207 SfxPoolItem*  SvxNumBulletItem::Clone( SfxItemPool * ) const
1208 {
1209 	return new SvxNumBulletItem(*this);
1210 }
1211 /* -----------------08.12.98 10:43-------------------
1212  *
1213  * --------------------------------------------------*/
1214 sal_uInt16  SvxNumBulletItem::GetVersion( sal_uInt16 /*nFileVersion*/ ) const
1215 {
1216     return NUMITEM_VERSION_03;
1217 }
1218 /* -----------------08.12.98 10:43-------------------
1219  *
1220  * --------------------------------------------------*/
1221 SvStream&   SvxNumBulletItem::Store(SvStream &rStream, sal_uInt16 /*nItemVersion*/ )const
1222 {
1223     pNumRule->Store(rStream);
1224     return rStream;
1225 }
1226 
1227 /* -----------------08.12.98 10:43-------------------
1228  *
1229  * --------------------------------------------------*/
1230 
1231 sal_Bool SvxNumBulletItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
1232 {
1233 	rVal <<= SvxCreateNumRule( pNumRule );
1234 	return sal_True;
1235 }
1236 
1237 sal_Bool SvxNumBulletItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
1238 {
1239 	uno::Reference< container::XIndexReplace > xRule;
1240 	if( rVal >>= xRule )
1241 	{
1242 		try
1243 		{
1244 			SvxNumRule* pNewRule = new SvxNumRule( SvxGetNumRule( xRule ) );
1245 			if( pNewRule->GetLevelCount() != pNumRule->GetLevelCount() ||
1246 				pNewRule->GetNumRuleType() != pNumRule->GetNumRuleType() )
1247 			{
1248 				SvxNumRule* pConverted = SvxConvertNumRule( pNewRule, pNumRule->GetLevelCount(), pNumRule->GetNumRuleType() );
1249 				delete pNewRule;
1250 				pNewRule = pConverted;
1251 			}
1252 			delete pNumRule;
1253 			pNumRule = pNewRule;
1254 			return sal_True;
1255 		}
1256 		catch(lang::IllegalArgumentException&)
1257 		{
1258 		}
1259 	}
1260 	return sal_False;
1261 }
1262 
1263 /* -----------------08.12.98 10:43-------------------
1264  *
1265  * --------------------------------------------------*/
1266 SvxNumRule* SvxConvertNumRule( const SvxNumRule* pRule, sal_uInt16 nLevels, SvxNumRuleType eType )
1267 {
1268 	const sal_uInt16 nSrcLevels = pRule->GetLevelCount();
1269 	SvxNumRule* pNewRule = new SvxNumRule( pRule->GetFeatureFlags(), nLevels, pRule->IsContinuousNumbering(), eType );
1270 
1271 	for( sal_uInt16 nLevel = 0; (nLevel < nLevels) && (nLevel < nSrcLevels); nLevel++ )
1272 		pNewRule->SetLevel( nLevel, pRule->GetLevel( nLevel ) );
1273 
1274 	return pNewRule;
1275 }
1276