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