xref: /trunk/main/svx/source/sidebar/nbdtmg.cxx (revision 8c84d0613eeaa348d10c2591df582960e5d98cfe)
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 #include "precompiled_svx.hxx"
22 #ifndef _NBDTMG_HXX
23 #include <svx/nbdtmg.hxx>
24 #endif
25 #ifndef _SVX_SVXIDS_HRC
26 #include <svx/svxids.hrc>
27 #endif
28 #ifndef _SV_SVAPP_HXX
29 #include <vcl/svapp.hxx>
30 #endif
31 #ifndef _SFXITEMSET_HXX
32 #include <svl/itemset.hxx>
33 #endif
34 #ifndef _SFXREQUEST_HXX
35 #include <sfx2/request.hxx>
36 #endif
37 #ifndef _SFXSTRITEM_HXX
38 #include <svl/stritem.hxx>
39 #endif
40 #ifndef _UNO_LINGU_HXX
41 #include <editeng/unolingu.hxx>
42 #endif
43 #ifndef _CTRLTOOL_HXX
44 #include <svtools/ctrltool.hxx>
45 #endif
46 #ifndef _SFX_OBJSH_HXX
47 #include <sfx2/objsh.hxx>
48 #endif
49 #ifndef _SVX_FLSTITEM_HXX
50 #include <editeng/flstitem.hxx>
51 #endif
52 #ifndef _SFXITEMPOOL_HXX
53 #include <svl/itempool.hxx>
54 #endif
55 #ifndef _SV_OUTDEV_HXX
56 #include <vcl/outdev.hxx>
57 #endif
58 #ifndef _GALLERY_HXX_
59 #include <svx/gallery.hxx>
60 #endif
61 #ifndef _SVX_BRSHITEM_HXX
62 #include <editeng/brshitem.hxx>
63 #endif
64 #include <svx/dialmgr.hxx>
65 #ifndef _SVX_DIALOGS_HRC
66 #include <svx/dialogs.hrc>
67 #endif
68 #ifndef _SV_GRAPH_HXX
69 #include <vcl/graph.hxx>
70 #endif
71 
72 #include <unotools/streamwrap.hxx>
73 #include <unotools/ucbstreamhelper.hxx>
74 #include <unotools/pathoptions.hxx>
75 #include <editeng/eeitem.hxx>
76 
77 #include <com/sun/star/text/HoriOrientation.hpp>
78 #include <com/sun/star/text/VertOrientation.hpp>
79 #include <com/sun/star/text/RelOrientation.hpp>
80 #include <com/sun/star/style/NumberingType.hpp>
81 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
82 #include <com/sun/star/container/XIndexAccess.hpp>
83 #include <com/sun/star/text/XDefaultNumberingProvider.hpp>
84 #include <com/sun/star/text/XNumberingFormatter.hpp>
85 #include <com/sun/star/beans/PropertyValue.hpp>
86 #include <comphelper/processfactory.hxx>
87 #include <com/sun/star/text/XNumberingTypeInfo.hpp>
88 
89 using namespace com::sun::star;
90 using namespace com::sun::star::uno;
91 using namespace com::sun::star::beans;
92 using namespace com::sun::star::lang;
93 using namespace com::sun::star::text;
94 using namespace com::sun::star::container;
95 using namespace com::sun::star::style;
96 using rtl::OUString;
97 
98 namespace svx { namespace sidebar {
99 #define NUM_TYPE_MEMBER 4
100 #define NUM_VALUSET_COUNT       16
101 #define MAX_VALUESET_GRAPHIC    30
102 
103 typedef NumSettings_Impl* NumSettings_ImplPtr;
104 SV_DECL_PTRARR_DEL(NumSettingsArr_Impl,NumSettings_ImplPtr,8,4)
105 SV_IMPL_PTRARR( NumSettingsArr_Impl, NumSettings_ImplPtr )
106 
107 typedef NumberSettings_Impl* NumberSettings_ImplPtr;
108 SV_DECL_PTRARR_DEL(NumberSettingsArr_Impl,NumberSettings_ImplPtr,8,4)
109 SV_IMPL_PTRARR( NumberSettingsArr_Impl, NumberSettings_ImplPtr )
110 
111 Font& lcl_GetDefaultBulletFont()
112 {
113     static sal_Bool bInit = 0;
114     static Font aDefBulletFont( UniString::CreateFromAscii(
115                                 RTL_CONSTASCII_STRINGPARAM( "StarSymbol" ) ),
116                                 String(), Size( 0, 14 ) );
117     if(!bInit)
118     {
119         aDefBulletFont.SetCharSet( RTL_TEXTENCODING_SYMBOL );
120         aDefBulletFont.SetFamily( FAMILY_DONTKNOW );
121         aDefBulletFont.SetPitch( PITCH_DONTKNOW );
122         aDefBulletFont.SetWeight( WEIGHT_DONTKNOW );
123         aDefBulletFont.SetTransparent( sal_True );
124         bInit = sal_True;
125     }
126     return aDefBulletFont;
127 }
128 
129 static const sal_Unicode aDefaultBulletTypes[] =
130 {
131     0x2022,
132     0x25cf,
133     0xe00c,
134     0xe00a,
135     0x2794,
136     0x27a2,
137     0x2717,
138     0x2714
139 };
140 
141 static const sal_Unicode aDefaultRTLBulletTypes[] =
142 {
143     0x2022,
144     0x25cf,
145     0xe00c,
146     0xe00a,
147     0x25c4,
148     0x272b,
149     0x2717,
150     0x2714
151 };
152 
153 static const sal_Char sNumberingType[] = "NumberingType";
154 static const sal_Char sValue[] = "Value";
155 static const sal_Char sParentNumbering[] = "ParentNumbering";
156 static const sal_Char sPrefix[] = "Prefix";
157 static const sal_Char sSuffix[] = "Suffix";
158 static const sal_Char sBulletChar[] = "BulletChar";
159 static const sal_Char sBulletFontName[] = "BulletFontName";
160 
161 NumSettings_ImplPtr lcl_CreateNumberingSettingsPtr(const Sequence<PropertyValue>& rLevelProps)
162 {
163     const PropertyValue* pValues = rLevelProps.getConstArray();
164     NumSettings_ImplPtr pNew = new NumSettings_Impl;
165     for(sal_Int32 j = 0; j < rLevelProps.getLength(); j++)
166     {
167         if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sNumberingType)))
168             pValues[j].Value >>= pNew->nNumberType;
169         else if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sPrefix)))
170             pValues[j].Value >>= pNew->sPrefix;
171         else if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sSuffix)))
172             pValues[j].Value >>= pNew->sSuffix;
173         else if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sParentNumbering)))
174             pValues[j].Value >>= pNew->nParentNumbering;
175         else if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sBulletChar)))
176             pValues[j].Value >>= pNew->sBulletChar;
177         else if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sBulletFontName)))
178             pValues[j].Value >>= pNew->sBulletFont;
179     }
180     const sal_Unicode cLocalPrefix = pNew->sPrefix.getLength() ? pNew->sPrefix.getStr()[0] : 0;
181     const sal_Unicode cLocalSuffix = pNew->sSuffix.getLength() ? pNew->sSuffix.getStr()[0] : 0;
182     String aEmptyStr;
183     if( cLocalPrefix == ' ') pNew->sPrefix=aEmptyStr;
184     if( cLocalSuffix == ' ') pNew->sSuffix=aEmptyStr;
185     return pNew;
186 }
187 
188 sal_uInt16 NBOTypeMgrBase:: IsSingleLevel(sal_uInt16 nCurLevel)
189 {
190     sal_uInt16 nLv = (sal_uInt16)0xFFFF;
191     sal_uInt16 nCount = 0;
192     sal_uInt16 nMask = 1;
193     for( sal_uInt16 i = 0; i < SVX_MAX_NUM; i++ )
194     {
195         if(nCurLevel & nMask)
196         {
197             nCount++;
198             nLv=i;
199         }
200         nMask <<= 1 ;
201     }
202 
203     if ( nCount == 1)
204         return nLv;
205     else
206         return (sal_uInt16)0xFFFF;
207 }
208 
209 void NBOTypeMgrBase::StoreBulCharFmtName_impl() {
210         if ( pSet )
211         {
212             SfxAllItemSet aSet(*pSet);
213             SFX_ITEMSET_ARG(&aSet,pBulletCharFmt,SfxStringItem,SID_BULLET_CHAR_FMT,sal_False);
214 
215             if ( pBulletCharFmt )
216             {
217                 aNumCharFmtName =  String(pBulletCharFmt->GetValue());
218             }
219         }
220 }
221 String NBOTypeMgrBase::GetBulCharFmtName()
222 {
223     return aNumCharFmtName;
224 }
225 void NBOTypeMgrBase::ImplLoad(String filename)
226 {
227     bIsLoading = true;
228     SfxMapUnit      eOldCoreUnit=eCoreUnit;
229     eCoreUnit = SFX_MAPUNIT_100TH_MM;
230     INetURLObject aFile( SvtPathOptions().GetPalettePath() );
231     aFile.Append( filename);
232     SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aFile.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
233     if( pIStm ) {
234         sal_uInt32                      nVersion;
235         sal_Int32                   nNumIndex;
236         *pIStm >> nVersion;
237         if (nVersion==DEFAULT_NUMBERING_CACHE_FORMAT_VERSION) //first version
238         {
239             *pIStm >> nNumIndex;
240             sal_uInt16 mLevel = 0x1;
241             while (nNumIndex>=0 && nNumIndex<DEFAULT_NUM_VALUSET_COUNT) {
242                 SvxNumRule aNum(*pIStm);
243                 //bullet color in font properties is not stored correctly. Need set tranparency bits manually
244                 for(sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
245                 {
246                     SvxNumberFormat aFmt(aNum.GetLevel(i));
247                     if (aFmt.GetBulletFont()) {
248                         Font aFont(*aFmt.GetBulletFont());
249                         Color c=aFont.GetColor();
250                         c.SetTransparency(0xFF);
251                         aFont.SetColor(c);
252                         aFmt.SetBulletFont(&aFont);
253                         aNum.SetLevel(i, aFmt);
254                     }
255                 }
256                 RelplaceNumRule(aNum,nNumIndex,mLevel);
257                 *pIStm >> nNumIndex;
258             }
259             delete pIStm;
260         }
261     }
262     eCoreUnit = eOldCoreUnit;
263     bIsLoading = false;
264 }
265 void NBOTypeMgrBase::ImplStore(String filename)
266 {
267     if (bIsLoading) return;
268     SfxMapUnit      eOldCoreUnit=eCoreUnit;
269     eCoreUnit = SFX_MAPUNIT_100TH_MM;
270     INetURLObject aFile( SvtPathOptions().GetPalettePath() );
271     aFile.Append( filename);
272     SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aFile.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE );
273     if( pOStm ) {
274         sal_uInt32                      nVersion;
275         sal_Int32                       nNumIndex;
276         nVersion = DEFAULT_NUMBERING_CACHE_FORMAT_VERSION;
277         *pOStm << nVersion;
278         for(sal_Int32 nItem = 0; nItem < DEFAULT_NUM_VALUSET_COUNT; nItem++ ) {
279             if (IsCustomized(nItem)) {
280                 SvxNumRule aDefNumRule( NUM_BULLET_REL_SIZE|NUM_CONTINUOUS|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE|NUM_SYMBOL_ALIGNMENT,10, sal_False ,
281                     SVX_RULETYPE_NUMBERING,SvxNumberFormat::LABEL_ALIGNMENT);
282                 sal_uInt16 mLevel = 0x1;
283                 *pOStm << nItem;
284                 ApplyNumRule(aDefNumRule,nItem,mLevel,false,true);
285                 aDefNumRule.Store(*pOStm);
286             }
287         }
288         nNumIndex = -1;
289         *pOStm << nNumIndex;  //write end flag
290         delete pOStm;
291     }
292     eCoreUnit = eOldCoreUnit;
293 }
294 
295 void NBOTypeMgrBase::StoreMapUnit_impl() {
296     if ( pSet )
297     {
298         const SfxPoolItem* pItem;
299         SfxItemState eState = pSet->GetItemState(SID_ATTR_NUMBERING_RULE, sal_False, &pItem);
300         if(eState == SFX_ITEM_SET)
301         {
302             eCoreUnit = pSet->GetPool()->GetMetric(pSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
303         } else {
304             //sd use different sid for numbering rule
305             eState = pSet->GetItemState(EE_PARA_NUMBULLET, sal_False, &pItem);
306             if(eState == SFX_ITEM_SET)
307             {
308                 eCoreUnit = pSet->GetPool()->GetMetric(pSet->GetPool()->GetWhich(EE_PARA_NUMBULLET));
309             }
310         }
311     }
312 }
313 SfxMapUnit NBOTypeMgrBase::GetMapUnit()
314 {
315     return eCoreUnit;
316 }
317 /***************************************************************************************************
318 **********************Character Bullet Type lib**********************************************************
319 ****************************************************************************************************/
320 BulletsTypeMgr* BulletsTypeMgr::_instance = 0;
321 BulletsSettings_Impl* BulletsTypeMgr::pActualBullets[] ={0,0,0,0,0,0,0,0};
322 sal_Unicode BulletsTypeMgr::aDynamicBulletTypes[]={' ',' ',' ',' ',' ',' ',' ',' '};
323 sal_Unicode BulletsTypeMgr::aDynamicRTLBulletTypes[]={' ',' ',' ',' ',' ',' ',' ',' '};
324 
325 BulletsTypeMgr::BulletsTypeMgr(const NBOType aType):
326     NBOTypeMgrBase(aType)
327 {
328     Init();
329 }
330 
331 BulletsTypeMgr::BulletsTypeMgr(const NBOType aType,const SfxItemSet* pArg):
332     NBOTypeMgrBase(aType,pArg)
333 {
334     Init();
335 }
336 
337 BulletsTypeMgr::BulletsTypeMgr(const BulletsTypeMgr& aTypeMgr):
338     NBOTypeMgrBase(aTypeMgr)
339 {
340     for (sal_uInt16 i=0;i<DEFAULT_BULLET_TYPES;i++)
341     {
342         pActualBullets[i]->bIsCustomized = aTypeMgr.pActualBullets[i]->bIsCustomized;
343         pActualBullets[i]->cBulletChar = aTypeMgr.pActualBullets[i]->cBulletChar;
344         pActualBullets[i]->aFont = aTypeMgr.pActualBullets[i]->aFont;
345         pActualBullets[i]->sDescription = aTypeMgr. pActualBullets[i]->sDescription;
346         pActualBullets[i]->eType = aTypeMgr. pActualBullets[i]->eType;
347     }
348 }
349 void BulletsTypeMgr::Init()
350 {
351     Font& rActBulletFont = lcl_GetDefaultBulletFont();
352     String sName = rActBulletFont.GetName();
353     if( Application::GetSettings().GetLayoutRTL() )
354     {
355         for (sal_uInt16 i=0;i<DEFAULT_BULLET_TYPES;i++)
356         {
357             pActualBullets[i] = new BulletsSettings_Impl(eNBType::BULLETS);
358             pActualBullets[i]->cBulletChar = aDefaultRTLBulletTypes[i];
359             pActualBullets[i]->aFont = rActBulletFont;
360             if (i==4 || i==5)
361                 pActualBullets[i]->sDescription = SVX_RESSTR( RID_SVXSTR_BULLET_RTL_DESCRIPTION_4 - 4 + i );
362             else
363                 pActualBullets[i]->sDescription = SVX_RESSTR( RID_SVXSTR_BULLET_DESCRIPTION_0 + i );
364         }
365     }else
366     {
367         for (sal_uInt16 i=0;i<DEFAULT_BULLET_TYPES;i++)
368         {
369             pActualBullets[i] = new BulletsSettings_Impl(eNBType::BULLETS);
370             pActualBullets[i]->cBulletChar = aDefaultBulletTypes[i];
371             pActualBullets[i]->aFont =rActBulletFont;
372             pActualBullets[i]->sDescription = SVX_RESSTR( RID_SVXSTR_BULLET_DESCRIPTION_0 + i );
373         }
374     }
375 }
376 sal_uInt16 BulletsTypeMgr::GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex)
377 {
378     if ( mLevel == (sal_uInt16)0xFFFF || mLevel == 0)
379         return (sal_uInt16)0xFFFF;
380     //if ( !lcl_IsNumFmtSet(pNR, mLevel) ) return (sal_uInt16)0xFFFF;
381 
382     sal_uInt16 nActLv = IsSingleLevel(mLevel);
383 
384     if ( nActLv == (sal_uInt16)0xFFFF )
385         return (sal_uInt16)0xFFFF;
386 
387     SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
388     sal_Unicode cChar = aFmt.GetBulletChar();
389     //sal_uInt16 nLength = 0;
390     /*if( Application::GetSettings().GetLayoutRTL() )
391     {
392         nLength = sizeof(aDynamicRTLBulletTypes)/sizeof(sal_Unicode);
393         for(sal_uInt16 i = 0; i < nLength; i++)
394         {
395             if ( cChar == aDynamicRTLBulletTypes[i] ||
396                 (cChar == 9830 && 57356 == aDynamicRTLBulletTypes[i]) ||
397                 (cChar == 9632 && 57354 == aDynamicRTLBulletTypes[i]) )
398             {
399                 return i+1;
400             }
401         }
402     } else
403     {
404         nLength = sizeof(aDynamicBulletTypes)/sizeof(sal_Unicode);
405         for(sal_uInt16 i = 0; i < nLength; i++)
406         {
407             if ( cChar == aDynamicBulletTypes[i] ||
408                 (cChar == 9830 && 57356 == aDynamicBulletTypes[i]) ||
409                 (cChar == 9632 && 57354 == aDynamicBulletTypes[i]) )
410             {
411                 return i+1;
412             }
413         }
414     }*/
415     //nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
416     for(sal_uInt16 i = nFromIndex; i < DEFAULT_BULLET_TYPES; i++)
417     {
418         if ( (cChar == pActualBullets[i]->cBulletChar||
419             (cChar == 9830 && 57356 == pActualBullets[i]->cBulletChar) ||
420             (cChar == 9632 && 57354 == pActualBullets[i]->cBulletChar)))// && pFont && (pFont->GetName().CompareTo(pActualBullets[i]->aFont.GetName())==COMPARE_EQUAL))
421         {
422             return i+1;
423         }
424     }
425 
426     return (sal_uInt16)0xFFFF;
427 }
428 
429 sal_Bool BulletsTypeMgr::RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel)
430 {
431     if ( mLevel == (sal_uInt16)0xFFFF || mLevel == 0)
432         return sal_False;
433 
434     if ( GetNBOIndexForNumRule(aNum,mLevel) != (sal_uInt16)0xFFFF )
435         return sal_False;
436 
437     sal_uInt16 nActLv = IsSingleLevel(mLevel);
438 
439     if ( nActLv == (sal_uInt16)0xFFFF )
440         return sal_False;
441 
442     SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
443     sal_Unicode cChar = aFmt.GetBulletChar();
444     const Font* pFont = aFmt.GetBulletFont();
445     //sal_uInt16 nLength = 0;
446     /*if( Application::GetSettings().GetLayoutRTL() )
447     {
448         nLength = sizeof(aDynamicRTLBulletTypes)/sizeof(sal_Unicode);
449 
450         if ( nIndex >= nLength )
451             return sal_False;
452 
453         aDynamicRTLBulletTypes[nIndex] = cChar;
454     } else
455     {
456         nLength = sizeof(aDynamicBulletTypes)/sizeof(sal_Unicode);
457 
458         if ( nIndex >= nLength )
459             return sal_False;
460 
461         aDynamicBulletTypes[nIndex] = cChar;
462     }*/
463     //nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
464     if ( nIndex >= DEFAULT_BULLET_TYPES )
465         return sal_False;
466 
467     pActualBullets[nIndex]->cBulletChar = cChar;
468     if ( pFont )
469         pActualBullets[nIndex]->aFont = *pFont;
470     pActualBullets[nIndex]->bIsCustomized = sal_True;
471 
472     String aStrFromRES = String(SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION));
473     String aReplace = String::CreateFromAscii("%LIST_NUM");
474     String sNUM = String::CreateFromInt32( nIndex + 1 );
475     aStrFromRES.SearchAndReplace(aReplace,sNUM);
476     pActualBullets[nIndex]->sDescription = aStrFromRES;
477 
478     return sal_True;
479 }
480 
481 sal_Bool BulletsTypeMgr::ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel,sal_Bool /* isDefault */,sal_Bool isResetSize)
482 {
483     //if ( mLevel == (sal_uInt16)0xFFFF )
484     //  return sal_False;
485 
486     sal_Unicode cChar;
487     //sal_uInt16 nLength = 0;
488     /*if( Application::GetSettings().GetLayoutRTL() )
489     {
490         nLength = sizeof(aDynamicRTLBulletTypes)/sizeof(sal_Unicode);
491 
492         if ( nIndex >= nLength )
493             return sal_False;
494 
495         cChar = aDynamicRTLBulletTypes[nIndex];
496     }else
497     {
498         nLength = sizeof(aDynamicBulletTypes)/sizeof(sal_Unicode);
499 
500         if ( nIndex >= nLength )
501             return sal_False;
502 
503         cChar = aDynamicBulletTypes[nIndex];
504     }*/
505     //nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
506     if ( nIndex >= DEFAULT_BULLET_TYPES )
507         return sal_False;
508     cChar = pActualBullets[nIndex]->cBulletChar;
509     //Font& rActBulletFont = lcl_GetDefaultBulletFont();
510     Font rActBulletFont = pActualBullets[nIndex]->aFont;
511 
512     sal_uInt16 nMask = 1;
513     String sBulletCharFmtName = GetBulCharFmtName();
514     for(sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
515     {
516         if(mLevel & nMask)
517         {
518             SvxNumberFormat aFmt(aNum.GetLevel(i));
519             aFmt.SetNumberingType( SVX_NUM_CHAR_SPECIAL );
520             aFmt.SetBulletFont(&rActBulletFont);
521             aFmt.SetBulletChar(cChar );
522             aFmt.SetCharFmtName(sBulletCharFmtName);
523             if (isResetSize) aFmt.SetBulletRelSize(45);
524             aNum.SetLevel(i, aFmt);
525         }
526         nMask <<= 1;
527     }
528 
529     return sal_True;
530 }
531 
532 String BulletsTypeMgr::GetDescription(sal_uInt16 nIndex,sal_Bool /* isDefault */)
533 {
534     String sRet;
535     //sal_uInt16 nLength = 0;
536     //nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
537 
538     if ( nIndex >= DEFAULT_BULLET_TYPES )
539         return sRet;
540     else
541         sRet = pActualBullets[nIndex]->sDescription;
542 
543     return sRet;
544 }
545 sal_Bool BulletsTypeMgr::IsCustomized(sal_uInt16 nIndex)
546 {
547     sal_Bool bRet = sal_False;
548     //sal_uInt16 nLength = 0;
549     //nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
550 
551     if ( nIndex >= DEFAULT_BULLET_TYPES )
552         bRet = sal_False;
553     else
554         bRet = pActualBullets[nIndex]->bIsCustomized;
555 
556     return bRet;
557 }
558 
559 sal_Unicode BulletsTypeMgr::GetBulChar(sal_uInt16 nIndex)
560 {
561     sal_Unicode cChar;
562     //sal_uInt16 nLength = 0;
563     //nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
564 
565     if ( nIndex >= DEFAULT_BULLET_TYPES )
566         cChar = ' ';
567     else
568         cChar = pActualBullets[nIndex]->cBulletChar;
569 
570     /*if( Application::GetSettings().GetLayoutRTL() )
571     {
572         nLength = sizeof(aDynamicRTLBulletTypes)/sizeof(sal_Unicode);
573 
574         if ( nIndex >= nLength )
575             cChar = ' ';
576         else
577             cChar = aDynamicRTLBulletTypes[nIndex];
578     }else
579     {
580         nLength = sizeof(aDynamicBulletTypes)/sizeof(sal_Unicode);
581 
582         if ( nIndex >= nLength )
583             cChar = ' ';
584         else
585             cChar = aDynamicBulletTypes[nIndex];
586     }*/
587 
588     return cChar;
589 }
590 Font BulletsTypeMgr::GetBulCharFont(sal_uInt16 nIndex)
591 {
592     Font aRet;
593     if ( nIndex >= DEFAULT_BULLET_TYPES )
594         aRet = lcl_GetDefaultBulletFont();
595     else
596         aRet = pActualBullets[nIndex]->aFont;
597 
598     return aRet;
599 }
600 /***************************************************************************************************
601 **********************Graphic Bullet Type lib***********************************************************
602 ****************************************************************************************************/
603 GraphyicBulletsTypeMgr* GraphyicBulletsTypeMgr::_instance = 0;
604 GraphyicBulletsTypeMgr::GraphyicBulletsTypeMgr(const NBOType aType):
605     NBOTypeMgrBase(aType)
606 {
607     Init();
608 }
609 
610 GraphyicBulletsTypeMgr::GraphyicBulletsTypeMgr(const NBOType aType,const SfxItemSet* pArg):
611     NBOTypeMgrBase(aType,pArg)
612 {
613     Init();
614 }
615 GraphyicBulletsTypeMgr::GraphyicBulletsTypeMgr(const GraphyicBulletsTypeMgr& aTypeMgr):
616     NBOTypeMgrBase(aTypeMgr)
617 {
618     for (sal_uInt16 i=0;i< aTypeMgr.aGrfDataLst.Count();i++)
619     {
620         GrfBulDataRelation* pEntry = new GrfBulDataRelation(eNBType::GRAPHICBULLETS);
621         GrfBulDataRelation* pSrcEntry = (GrfBulDataRelation*)(aTypeMgr.aGrfDataLst.GetObject(i));
622         if ( pEntry && pSrcEntry)
623         {
624             pEntry->bIsCustomized = pSrcEntry->bIsCustomized;
625             pEntry->nTabIndex = pSrcEntry->nTabIndex;
626             pEntry->nGallaryIndex = pSrcEntry->nGallaryIndex;
627             pEntry->sGrfName = pSrcEntry->sGrfName;
628             pEntry->sDescription = pSrcEntry->sDescription;
629             aGrfDataLst.Insert( pEntry, LIST_APPEND );
630         }
631         else
632             delete pEntry;
633     }
634 }
635 void GraphyicBulletsTypeMgr::Init()
636 {
637     List aGrfNames;
638     GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames);
639     for(sal_uInt16 i = 0; i < aGrfNames.Count(); i++)
640     {
641         String* pGrfNm = (String*) aGrfNames.GetObject(i);
642             INetURLObject aObj(*pGrfNm);
643             if(aObj.GetProtocol() == INET_PROT_FILE)
644                     *pGrfNm = aObj.PathToFileName();
645 
646         GrfBulDataRelation* pEntry = new GrfBulDataRelation(eNBType::GRAPHICBULLETS);
647         pEntry->nTabIndex = i+1;
648         pEntry->nGallaryIndex = i;
649         pEntry->sGrfName = *pGrfNm;
650 
651         if( i < MAX_VALUESET_GRAPHIC )
652         {
653             pEntry->sDescription = SVX_RESSTR( RID_SVXSTR_GRAPHICS_DESCRIPTIONS + i );
654         }else
655         {
656             pEntry->sDescription = *pGrfNm;
657         }
658 
659         aGrfDataLst.Insert( pEntry, LIST_APPEND );
660     }
661 }
662 sal_uInt16 GraphyicBulletsTypeMgr::GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 /* nFromIndex */)
663 {
664     if ( mLevel == (sal_uInt16)0xFFFF || mLevel == 0)
665         return (sal_uInt16)0xFFFF;
666 
667     sal_uInt16 nActLv = IsSingleLevel(mLevel);
668 
669     if ( nActLv == (sal_uInt16)0xFFFF )
670         return (sal_uInt16)0xFFFF;
671 
672     SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
673     const SvxBrushItem* pBrsh = aFmt.GetBrush();
674     const Graphic* pGrf = 0;
675     if ( pBrsh )
676         pGrf = pBrsh->GetGraphic();
677 
678     if ( pGrf )
679     {
680         Graphic aGraphic;
681         for(sal_uInt16 i=0;i<aGrfDataLst.Count();i++)
682         {
683             GrfBulDataRelation* pEntry = (GrfBulDataRelation*) aGrfDataLst.GetObject(i);
684             sal_Bool bExist = sal_False;
685             if ( pEntry) // && pEntry->sGrfName.CompareTo(*pGrfName)==COMPARE_EQUAL )
686                 bExist = GalleryExplorer::GetGraphicObj(GALLERY_THEME_BULLETS, pEntry->nGallaryIndex,&aGraphic);
687             if (bExist) {
688                 Bitmap aSum=pGrf->GetBitmap();
689                 Bitmap aSum1=aGraphic.GetBitmap();
690                 if (aSum.IsEqual(aSum1))
691                 return pEntry->nTabIndex;
692             }
693         }
694     }
695 
696     return (sal_uInt16)0xFFFF;
697 }
698 
699 sal_Bool GraphyicBulletsTypeMgr::RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel)
700 {
701     if ( mLevel == (sal_uInt16)0xFFFF || mLevel > aNum.GetLevelCount() || mLevel == 0)
702         return sal_False;
703 
704     if ( GetNBOIndexForNumRule(aNum,mLevel) != (sal_uInt16)0xFFFF )
705         return sal_False;
706 
707     if ( nIndex >= aGrfDataLst.Count() )
708         return sal_False;
709 
710     sal_uInt16 nActLv = IsSingleLevel(mLevel);
711     if ( nActLv == (sal_uInt16)0xFFFF )
712         return sal_False;
713 
714     SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
715     const SvxBrushItem* pBrsh = aFmt.GetBrush();
716     const Graphic* pGrf = 0;
717     if ( pBrsh )
718         pGrf = pBrsh->GetGraphic();
719     else
720         return sal_False;
721 
722     String sEmpty;
723     if ( pGrf )
724     {
725         const String* pGrfName = pBrsh->GetGraphicLink();
726         //String* pGrfName = (String*)(pBrsh->GetGraphicLink());
727         GrfBulDataRelation* pEntry = (GrfBulDataRelation*) aGrfDataLst.GetObject(nIndex);
728         if ( pGrfName )
729             pEntry->sGrfName = *pGrfName;
730         //pEntry->sDescription = sEmpty;
731         pEntry->nGallaryIndex = (sal_uInt16)0xFFFF;
732         pEntry->bIsCustomized = sal_True;
733         String aStrFromRES = String(SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION));
734         String aReplace = String::CreateFromAscii("%LIST_NUM");
735         String sNUM = String::CreateFromInt32( nIndex + 1 );
736         aStrFromRES.SearchAndReplace(aReplace,sNUM);
737         pEntry->sDescription = aStrFromRES;
738     }else
739     {
740         return sal_False;
741     }
742 
743     return sal_True;
744 }
745 
746 sal_Bool GraphyicBulletsTypeMgr::ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel,sal_Bool /* isDefault */,sal_Bool /* isResetSize */)
747 {
748     //if ( mLevel == (sal_uInt16)0xFFFF )
749     //  return sal_False;
750 
751     if ( nIndex >= aGrfDataLst.Count() )
752         return sal_False;
753 
754     String sGrfName;
755     GrfBulDataRelation* pEntry = (GrfBulDataRelation*) aGrfDataLst.GetObject(nIndex);
756     sGrfName= pEntry->sGrfName;
757 
758     sal_uInt16 nMask = 1;
759     String aEmptyStr;
760     sal_uInt16 nSetNumberingType = SVX_NUM_BITMAP;
761     String sNumCharFmtName = GetBulCharFmtName();
762     for(sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
763     {
764         if(mLevel & nMask)
765         {
766             SvxNumberFormat aFmt(aNum.GetLevel(i));
767             aFmt.SetNumberingType(nSetNumberingType);
768             aFmt.SetPrefix( aEmptyStr );
769             aFmt.SetSuffix( aEmptyStr );
770             aFmt.SetCharFmtName( sNumCharFmtName );
771 
772                     Graphic aGraphic;
773                     if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, pEntry->nGallaryIndex, &aGraphic))
774             {
775                         Size aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
776                         sal_Int16 eOrient = text::VertOrientation::LINE_CENTER;
777                 aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)GetMapUnit());
778                         SvxBrushItem aBrush(aGraphic, GPOS_AREA, SID_ATTR_BRUSH );
779                         aFmt.SetGraphicBrush( &aBrush, &aSize, &eOrient );
780             }
781             else// if(pGrfName)
782                 aFmt.SetGraphic( sGrfName );
783 
784             aNum.SetLevel(i, aFmt);
785         }
786         nMask <<= 1 ;
787     }
788 
789     return sal_True;
790 }
791 String GraphyicBulletsTypeMgr::GetDescription(sal_uInt16 nIndex,sal_Bool /* isDefault */)
792 {
793     String sRet;
794     sal_uInt16 nLength = 0;
795     nLength = aGrfDataLst.Count() ;
796 
797     if ( nIndex >= nLength )
798         return sRet;
799     else
800     {
801         GrfBulDataRelation* pEntry  = (GrfBulDataRelation*) aGrfDataLst.GetObject(nIndex);
802         if ( pEntry )
803         {
804             sRet = pEntry->sDescription;
805         };
806     }
807     return sRet;
808 }
809 sal_Bool GraphyicBulletsTypeMgr::IsCustomized(sal_uInt16 nIndex)
810 {
811     sal_Bool bRet = sal_False;
812 
813     sal_uInt16 nLength = 0;
814     nLength = aGrfDataLst.Count() ;
815 
816     if ( nIndex >= nLength )
817         return bRet;
818     else
819     {
820         GrfBulDataRelation* pEntry  = (GrfBulDataRelation*) aGrfDataLst.GetObject(nIndex);
821         if ( pEntry )
822         {
823             bRet = pEntry->bIsCustomized;
824         };
825     }
826 
827     return bRet;
828 }
829 String GraphyicBulletsTypeMgr::GetGrfName(sal_uInt16 nIndex)
830 {
831     String sRet;
832     if ( nIndex < aGrfDataLst.Count() )
833     {
834         GrfBulDataRelation* pEntry = (GrfBulDataRelation*) aGrfDataLst.GetObject(nIndex);
835         if ( pEntry )
836         {
837             sRet = pEntry->sGrfName;
838         }
839     }
840 
841     return sRet;
842 }
843 /***************************************************************************************************
844 **********************Mix Bullets Type lib**************************************************************
845 ****************************************************************************************************/
846 MixBulletsTypeMgr* MixBulletsTypeMgr::_instance = 0;
847 MixBulletsSettings_Impl* MixBulletsTypeMgr::pActualBullets[] ={0,0,0,0,0,0,0,0};
848 MixBulletsSettings_Impl* MixBulletsTypeMgr::pDefaultActualBullets[] ={0,0,0,0,0,0,0,0};
849 
850 MixBulletsTypeMgr::MixBulletsTypeMgr(const NBOType aType):
851     NBOTypeMgrBase(aType)
852 {
853     Init();
854     for(sal_Int32 nItem = 0; nItem < DEFAULT_BULLET_TYPES; nItem++ )
855     {
856         pDefaultActualBullets[nItem] = pActualBullets[nItem];
857     }
858     //Initial the first time to store the default value. Then do it again for customized value
859     Init();
860     ImplLoad(String::CreateFromAscii("standard.sya"));
861 }
862 
863 MixBulletsTypeMgr::MixBulletsTypeMgr(const NBOType aType,const SfxItemSet* pArg):
864     NBOTypeMgrBase(aType,pArg)
865 {
866     Init();
867     for(sal_Int32 nItem = 0; nItem < DEFAULT_BULLET_TYPES; nItem++ )
868     {
869         pDefaultActualBullets[nItem] = pActualBullets[nItem];
870     }
871     //Initial the first time to store the default value. Then do it again for customized value
872     Init();
873     ImplLoad(String::CreateFromAscii("standard.sya"));
874 }
875 
876 MixBulletsTypeMgr::MixBulletsTypeMgr(const MixBulletsTypeMgr& aTypeMgr):
877     NBOTypeMgrBase(aTypeMgr)
878 {
879     for (sal_uInt16 i=0;i<DEFAULT_BULLET_TYPES;i++)
880     {
881         if ( aTypeMgr.pActualBullets[i]->eType == eNBType::BULLETS )
882         {
883             pActualBullets[i]->eType = aTypeMgr.pActualBullets[i]->eType;
884             pActualBullets[i]->nIndex = aTypeMgr.pActualBullets[i]->nIndex; //index in the tab page display
885             pActualBullets[i]->nIndexDefault = aTypeMgr.pActualBullets[i]->nIndexDefault;
886             pActualBullets[i]->pBullets = new BulletsSettings_Impl(eNBType::BULLETS) ;
887             ((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->cBulletChar = ((BulletsSettings_Impl*)(aTypeMgr.pActualBullets[i]->pBullets))->cBulletChar;
888             ((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->aFont = ((BulletsSettings_Impl*)(aTypeMgr.pActualBullets[i]->pBullets))->aFont;
889             ((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->sDescription = ((BulletsSettings_Impl*)(aTypeMgr.pActualBullets[i]->pBullets))->sDescription;
890             ((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->bIsCustomized = ((BulletsSettings_Impl*)(aTypeMgr.pActualBullets[i]->pBullets))->bIsCustomized;
891             ((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->eType = ((BulletsSettings_Impl*)(aTypeMgr.pActualBullets[i]->pBullets))->eType;
892         }else if ( aTypeMgr.pActualBullets[i]->eType == eNBType::GRAPHICBULLETS )
893         {
894             pActualBullets[i]->eType = aTypeMgr.pActualBullets[i]->eType;
895             pActualBullets[i]->nIndex = aTypeMgr.pActualBullets[i]->nIndex; //index in the tab page display
896             pActualBullets[i]->nIndexDefault = aTypeMgr.pActualBullets[i]->nIndexDefault;
897             pActualBullets[i]->pBullets = new GrfBulDataRelation(eNBType::GRAPHICBULLETS) ;
898             ((GrfBulDataRelation*)(pActualBullets[i]->pBullets))->sGrfName = ((GrfBulDataRelation*)(aTypeMgr.pActualBullets[i]->pBullets))->sGrfName;
899             ((GrfBulDataRelation*)(pActualBullets[i]->pBullets))->sDescription = ((GrfBulDataRelation*)(aTypeMgr.pActualBullets[i]->pBullets))->sDescription;
900             ((GrfBulDataRelation*)(pActualBullets[i]->pBullets))->bIsCustomized = ((GrfBulDataRelation*)(aTypeMgr.pActualBullets[i]->pBullets))->bIsCustomized;
901             ((GrfBulDataRelation*)(pActualBullets[i]->pBullets))->eType = ((GrfBulDataRelation*)(aTypeMgr.pActualBullets[i]->pBullets))->eType;
902             if ( ((GrfBulDataRelation*)(aTypeMgr.pActualBullets[i]->pBullets))->bIsCustomized && ((GrfBulDataRelation*)(aTypeMgr.pActualBullets[i]->pBullets))->pGrfObj != NULL)
903             {
904                 ((GrfBulDataRelation*)(pActualBullets[i]->pBullets))->pGrfObj = ((GrfBulDataRelation*)(aTypeMgr.pActualBullets[i]->pBullets))->pGrfObj;
905             }
906         }
907     }
908     ImplLoad(String::CreateFromAscii("standard.sya"));
909 }
910 void MixBulletsTypeMgr::Init()
911 {
912     BulletsTypeMgr* pBTMgr = BulletsTypeMgr::GetInstance();
913     if ( pBTMgr )
914     {
915         //Index 1
916         pActualBullets[0] = new MixBulletsSettings_Impl(eNBType::BULLETS);
917         pActualBullets[0]->eType = eNBType::BULLETS;
918         pActualBullets[0]->nIndex = 0+1; //index in the tab page display,decrease 1 to the index within arr
919         pActualBullets[0]->nIndexDefault = 2;    //index in the tab page display,decrease 1 to the index within arr
920         pActualBullets[0]->pBullets = new BulletsSettings_Impl(eNBType::BULLETS) ;
921         ((BulletsSettings_Impl*)(pActualBullets[0]->pBullets))->cBulletChar = pBTMgr->GetBulChar(pActualBullets[0]->nIndexDefault-1);
922         ((BulletsSettings_Impl*)(pActualBullets[0]->pBullets))->aFont = pBTMgr->GetBulCharFont(pActualBullets[0]->nIndexDefault-1);
923         ((BulletsSettings_Impl*)(pActualBullets[0]->pBullets))->sDescription = pBTMgr->GetDescription(pActualBullets[0]->nIndexDefault-1);
924         ((BulletsSettings_Impl*)(pActualBullets[0]->pBullets))->bIsCustomized = pBTMgr->IsCustomized(pActualBullets[0]->nIndexDefault-1);
925         ((BulletsSettings_Impl*)(pActualBullets[0]->pBullets))->eType = eNBType::BULLETS;
926 
927         //Index 2
928         pActualBullets[1] = new MixBulletsSettings_Impl(eNBType::BULLETS);
929         pActualBullets[1]->eType = eNBType::BULLETS;
930         pActualBullets[1]->nIndex = 1+1; //index in the tab page display,decrease 1 to the index within arr
931         pActualBullets[1]->nIndexDefault = 3;    //index in the tab page display,decrease 1 to the index within arr
932         pActualBullets[1]->pBullets = new BulletsSettings_Impl(eNBType::BULLETS) ;
933         ((BulletsSettings_Impl*)(pActualBullets[1]->pBullets))->cBulletChar = pBTMgr->GetBulChar(pActualBullets[1]->nIndexDefault-1);
934         ((BulletsSettings_Impl*)(pActualBullets[1]->pBullets))->aFont = pBTMgr->GetBulCharFont(pActualBullets[1]->nIndexDefault-1);
935         ((BulletsSettings_Impl*)(pActualBullets[1]->pBullets))->sDescription = pBTMgr->GetDescription(pActualBullets[1]->nIndexDefault-1);
936         ((BulletsSettings_Impl*)(pActualBullets[1]->pBullets))->bIsCustomized = pBTMgr->IsCustomized(pActualBullets[1]->nIndexDefault-1);
937         ((BulletsSettings_Impl*)(pActualBullets[1]->pBullets))->eType = eNBType::BULLETS;
938 
939         //Index 3
940         pActualBullets[2] = new MixBulletsSettings_Impl(eNBType::BULLETS);
941         pActualBullets[2]->eType = eNBType::BULLETS;
942         pActualBullets[2]->nIndex = 2+1; //index in the tab page display,decrease 1 to the index within arr
943         pActualBullets[2]->nIndexDefault = 4;    //index in the tab page display,decrease 1 to the index within arr
944         pActualBullets[2]->pBullets = new BulletsSettings_Impl(eNBType::BULLETS) ;
945         ((BulletsSettings_Impl*)(pActualBullets[2]->pBullets))->cBulletChar = pBTMgr->GetBulChar(pActualBullets[2]->nIndexDefault-1);
946         ((BulletsSettings_Impl*)(pActualBullets[2]->pBullets))->aFont = pBTMgr->GetBulCharFont(pActualBullets[2]->nIndexDefault-1);
947         ((BulletsSettings_Impl*)(pActualBullets[2]->pBullets))->sDescription = pBTMgr->GetDescription(pActualBullets[2]->nIndexDefault-1);
948         ((BulletsSettings_Impl*)(pActualBullets[2]->pBullets))->bIsCustomized = pBTMgr->IsCustomized(pActualBullets[2]->nIndexDefault-1);
949         ((BulletsSettings_Impl*)(pActualBullets[2]->pBullets))->eType = eNBType::BULLETS;
950 
951         //Index 4
952         pActualBullets[3] = new MixBulletsSettings_Impl(eNBType::BULLETS);
953         pActualBullets[3]->eType = eNBType::BULLETS;
954         pActualBullets[3]->nIndex = 3+1; //index in the tab page display,decrease 1 to the index within arr
955         pActualBullets[3]->nIndexDefault = 5;    //index in the tab page display,decrease 1 to the index within arr
956         pActualBullets[3]->pBullets = new BulletsSettings_Impl(eNBType::BULLETS) ;
957         ((BulletsSettings_Impl*)(pActualBullets[3]->pBullets))->cBulletChar = pBTMgr->GetBulChar(pActualBullets[3]->nIndexDefault-1);
958         ((BulletsSettings_Impl*)(pActualBullets[3]->pBullets))->aFont = pBTMgr->GetBulCharFont(pActualBullets[3]->nIndexDefault-1);
959         ((BulletsSettings_Impl*)(pActualBullets[3]->pBullets))->sDescription = pBTMgr->GetDescription(pActualBullets[3]->nIndexDefault-1);
960         ((BulletsSettings_Impl*)(pActualBullets[3]->pBullets))->bIsCustomized = pBTMgr->IsCustomized(pActualBullets[3]->nIndexDefault-1);
961         ((BulletsSettings_Impl*)(pActualBullets[3]->pBullets))->eType = eNBType::BULLETS;
962 
963         //Index 5
964         pActualBullets[4] = new MixBulletsSettings_Impl(eNBType::BULLETS);
965         pActualBullets[4]->eType = eNBType::BULLETS;
966         pActualBullets[4]->nIndex = 4+1; //index in the tab page display,decrease 1 to the index within arr
967         pActualBullets[4]->nIndexDefault = 6;    //index in the tab page display,decrease 1 to the index within arr
968         pActualBullets[4]->pBullets = new BulletsSettings_Impl(eNBType::BULLETS) ;
969         ((BulletsSettings_Impl*)(pActualBullets[4]->pBullets))->cBulletChar = pBTMgr->GetBulChar(pActualBullets[4]->nIndexDefault-1);
970         ((BulletsSettings_Impl*)(pActualBullets[4]->pBullets))->aFont = pBTMgr->GetBulCharFont(pActualBullets[4]->nIndexDefault-1);
971         ((BulletsSettings_Impl*)(pActualBullets[4]->pBullets))->sDescription = pBTMgr->GetDescription(pActualBullets[4]->nIndexDefault-1);
972         ((BulletsSettings_Impl*)(pActualBullets[4]->pBullets))->bIsCustomized = pBTMgr->IsCustomized(pActualBullets[4]->nIndexDefault-1);
973         ((BulletsSettings_Impl*)(pActualBullets[4]->pBullets))->eType = eNBType::BULLETS;
974 
975         //Index 6
976         pActualBullets[5] = new MixBulletsSettings_Impl(eNBType::BULLETS);
977         pActualBullets[5]->eType = eNBType::BULLETS;
978         pActualBullets[5]->nIndex = 5+1; //index in the tab page display,decrease 1 to the index within arr
979         pActualBullets[5]->nIndexDefault = 8;    //index in the tab page display,decrease 1 to the index within arr
980         pActualBullets[5]->pBullets = new BulletsSettings_Impl(eNBType::BULLETS) ;
981         ((BulletsSettings_Impl*)(pActualBullets[5]->pBullets))->cBulletChar = pBTMgr->GetBulChar(pActualBullets[5]->nIndexDefault-1);
982         ((BulletsSettings_Impl*)(pActualBullets[5]->pBullets))->aFont = pBTMgr->GetBulCharFont(pActualBullets[5]->nIndexDefault-1);
983         ((BulletsSettings_Impl*)(pActualBullets[5]->pBullets))->sDescription = pBTMgr->GetDescription(pActualBullets[5]->nIndexDefault-1);
984         ((BulletsSettings_Impl*)(pActualBullets[5]->pBullets))->bIsCustomized = pBTMgr->IsCustomized(pActualBullets[5]->nIndexDefault-1);
985         ((BulletsSettings_Impl*)(pActualBullets[5]->pBullets))->eType = eNBType::BULLETS;
986     }
987 
988     GraphyicBulletsTypeMgr* mGrfTMgr = GraphyicBulletsTypeMgr::GetInstance();
989     if ( mGrfTMgr )
990     {
991         //Index 7
992         pActualBullets[6] = new MixBulletsSettings_Impl(eNBType::GRAPHICBULLETS);
993         pActualBullets[6]->eType = eNBType::GRAPHICBULLETS;
994         pActualBullets[6]->nIndex = 6+1; //index in the tab page display,decrease 1 to the index within arr
995         pActualBullets[6]->nIndexDefault = 9;    //index in the tab page display,decrease 1 to the index within arr
996         pActualBullets[6]->pBullets = new GrfBulDataRelation(eNBType::GRAPHICBULLETS) ;
997         ((GrfBulDataRelation*)(pActualBullets[6]->pBullets))->sGrfName = mGrfTMgr->GetGrfName(pActualBullets[6]->nIndexDefault);
998         ((GrfBulDataRelation*)(pActualBullets[6]->pBullets))->sDescription = mGrfTMgr->GetDescription(pActualBullets[6]->nIndexDefault);
999         ((GrfBulDataRelation*)(pActualBullets[6]->pBullets))->bIsCustomized = mGrfTMgr->IsCustomized(pActualBullets[6]->nIndexDefault);
1000         ((GrfBulDataRelation*)(pActualBullets[6]->pBullets))->eType = eNBType::GRAPHICBULLETS;
1001 
1002         //Index 8
1003         pActualBullets[7] = new MixBulletsSettings_Impl(eNBType::GRAPHICBULLETS);
1004         pActualBullets[7]->eType = eNBType::GRAPHICBULLETS;
1005         pActualBullets[7]->nIndex = 7+1; //index in the tab page display,decrease 1 to the index within arr
1006         pActualBullets[7]->nIndexDefault = 23;   //index in the tab page display,decrease 1 to the index within arr
1007         pActualBullets[7]->pBullets = new GrfBulDataRelation(eNBType::GRAPHICBULLETS) ;
1008         ((GrfBulDataRelation*)(pActualBullets[7]->pBullets))->sGrfName = mGrfTMgr->GetGrfName(pActualBullets[7]->nIndexDefault);
1009         ((GrfBulDataRelation*)(pActualBullets[7]->pBullets))->sDescription = mGrfTMgr->GetDescription(pActualBullets[7]->nIndexDefault);
1010         ((GrfBulDataRelation*)(pActualBullets[7]->pBullets))->bIsCustomized = mGrfTMgr->IsCustomized(pActualBullets[7]->nIndexDefault);
1011         ((GrfBulDataRelation*)(pActualBullets[7]->pBullets))->eType = eNBType::GRAPHICBULLETS;
1012     }
1013 
1014 }
1015 sal_uInt16 MixBulletsTypeMgr::GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex)
1016 {
1017     if ( mLevel == (sal_uInt16)0xFFFF || mLevel == 0)
1018         return (sal_uInt16)0xFFFF;
1019     //if ( !lcl_IsNumFmtSet(pNR, mLevel) ) return (sal_uInt16)0xFFFF;
1020 
1021     sal_uInt16 nActLv = IsSingleLevel(mLevel);
1022 
1023     if ( nActLv == (sal_uInt16)0xFFFF )
1024         return (sal_uInt16)0xFFFF;
1025 
1026     SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
1027     sal_Int16 eNumType = aFmt.GetNumberingType();
1028     if( eNumType == SVX_NUM_CHAR_SPECIAL)
1029     {
1030         sal_Unicode cChar = aFmt.GetBulletChar();
1031         const Font* pFont = aFmt.GetBulletFont();
1032         String sName = pFont?pFont->GetName():String();
1033 
1034         for(sal_uInt16 i = nFromIndex; i < DEFAULT_BULLET_TYPES; i++)
1035         {
1036             if ( pActualBullets[i]->eType == eNBType::BULLETS )
1037             {
1038                 String ssName = ((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->aFont.GetName();
1039                 if ( (cChar == ((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->cBulletChar||
1040                     (cChar == 9830 && 57356 == ((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->cBulletChar) ||
1041                     (cChar == 9632 && 57354 == ((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->cBulletChar)))//&&
1042                     //(pFont && pFont->GetName().CompareTo(((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->aFont.GetName())==COMPARE_EQUAL) )
1043                 {
1044                     return pActualBullets[i]->nIndex;
1045                 }
1046             }
1047         }
1048     }else if ( (eNumType&(~LINK_TOKEN)) == SVX_NUM_BITMAP )
1049     {
1050         const SvxBrushItem* pBrsh = aFmt.GetBrush();
1051         const Graphic* pGrf = 0;
1052         if ( pBrsh )
1053             pGrf = pBrsh->GetGraphic();
1054 
1055         if ( pGrf )
1056         {
1057             for(sal_uInt16 i = nFromIndex; i < DEFAULT_BULLET_TYPES; i++)
1058             {
1059                 if ( pActualBullets[i]->eType == eNBType::GRAPHICBULLETS )
1060                 {
1061                     GrfBulDataRelation* pEntry = (GrfBulDataRelation*) (pActualBullets[i]->pBullets);
1062                     //sal_Bool bExist = sal_False;
1063                     if ( pEntry && pActualBullets[i]->nIndexDefault == (sal_uInt16)0xFFFF  && pEntry->pGrfObj)
1064                     {
1065                         if ( pEntry->pGrfObj->GetBitmap().IsEqual(pGrf->GetBitmap()))
1066                         {
1067                             return pActualBullets[i]->nIndex;
1068                         }
1069                     }else { //if ( pEntry && pGrfName && pEntry->sGrfName.CompareTo(*pGrfName)==COMPARE_EQUAL )
1070                         //bExist = GalleryExplorer::GetGraphicObj(GALLERY_THEME_BULLETS, pActualBullets[i]->nIndexDefault-1,pSrGrf);
1071                         Graphic aSrGrf;
1072                         if (pEntry)
1073                             GalleryExplorer::GetGraphicObj(GALLERY_THEME_BULLETS, pActualBullets[i]->nIndexDefault,&aSrGrf);
1074                         Bitmap aSum=pGrf->GetBitmap();
1075                         Bitmap aSum1=aSrGrf.GetBitmap();
1076                         if (aSum.IsEqual(aSum1))
1077                             return pActualBullets[i]->nIndex;
1078                     }
1079                 }
1080             }
1081         }
1082     }
1083 
1084     return (sal_uInt16)0xFFFF;
1085 }
1086 
1087 sal_Bool MixBulletsTypeMgr::RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel)
1088 {
1089     if ( mLevel == (sal_uInt16)0xFFFF || mLevel == 0 || nIndex>=DEFAULT_BULLET_TYPES)
1090         return sal_False;
1091 
1092     //if ( GetNBOIndexForNumRule(aNum,mLevel) != (sal_uInt16)0xFFFF )
1093     //  return sal_False;
1094 
1095     sal_uInt16 nActLv = IsSingleLevel(mLevel);
1096 
1097     if ( nActLv == (sal_uInt16)0xFFFF )
1098         return sal_False;
1099 
1100     SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
1101     sal_Int16 eNumType = aFmt.GetNumberingType();
1102     if( eNumType == SVX_NUM_CHAR_SPECIAL && pActualBullets[nIndex]->eType == eNBType::BULLETS )
1103     {
1104         sal_Unicode cChar = aFmt.GetBulletChar();
1105         const Font* pFont = aFmt.GetBulletFont();
1106         BulletsSettings_Impl* pEntry = (BulletsSettings_Impl*) (pActualBullets[nIndex]->pBullets);
1107         pEntry->cBulletChar = cChar;
1108         pEntry->aFont = pFont?*pFont:lcl_GetDefaultBulletFont();
1109         pEntry->bIsCustomized = sal_True;
1110         String aStrFromRES = String(SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION));
1111         String aReplace = String::CreateFromAscii("%LIST_NUM");
1112         String sNUM = String::CreateFromInt32( nIndex + 1 );
1113         aStrFromRES.SearchAndReplace(aReplace,sNUM);
1114         pEntry->sDescription = aStrFromRES;
1115 
1116     }else if ( (eNumType&(~LINK_TOKEN)) == SVX_NUM_BITMAP && pActualBullets[nIndex]->eType == eNBType::GRAPHICBULLETS )
1117     {
1118         const SvxBrushItem* pBrsh = aFmt.GetBrush();
1119         const Graphic* pGrf = 0;
1120         if ( pBrsh )
1121             pGrf = pBrsh->GetGraphic();
1122         else
1123             return sal_False;
1124 
1125         String sEmpty;
1126         if ( pGrf )
1127         {
1128             const String* pGrfName = pBrsh->GetGraphicLink();
1129             //String* pGrfName = (String*)(pBrsh->GetGraphicLink());
1130             GrfBulDataRelation* pEntry = (GrfBulDataRelation*) (pActualBullets[nIndex]->pBullets);
1131             if ( pGrfName )
1132                 pEntry->sGrfName = *pGrfName;
1133             GraphyicBulletsTypeMgr* mGrfTMgr = GraphyicBulletsTypeMgr::GetInstance();
1134             if ( mGrfTMgr )
1135             {
1136                 //sal_uInt16 nDIndex = mGrfTMgr->GetNBOIndexForNumRule(aNum,mLevel);
1137                 //if ( nDIndex != (sal_uInt16)0xFFFF)
1138                 //{
1139                 //  pActualBullets[nIndex]->nIndexDefault = nDIndex -1;
1140                 //  sEmpty = mGrfTMgr->GetDescription( nDIndex -1);
1141                 //}else
1142                 {
1143                     pActualBullets[nIndex]->nIndexDefault  = (sal_uInt16)0xFFFF;
1144                     sEmpty = String(SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION));
1145                     String aReplace = String::CreateFromAscii("%LIST_NUM");
1146                     String sNUM = String::CreateFromInt32( nIndex + 1 );
1147                     sEmpty.SearchAndReplace(aReplace,sNUM);
1148                     //pEntry->pGrfObj = pGrf;
1149                     pEntry->pGrfObj = new Graphic(*pGrf);
1150                     pEntry->aSize = aFmt.GetGraphicSize();
1151                     pEntry->aSize = OutputDevice::LogicToLogic(pEntry->aSize,(MapUnit)GetMapUnit(),MAP_100TH_MM);
1152                     sal_uInt16 nDIndex = mGrfTMgr->GetNBOIndexForNumRule(aNum,mLevel);
1153                     if (nDIndex!=(sal_uInt16)0xFFFF) pEntry->aSize=Size(0,0);
1154                 }
1155             }
1156             pEntry->sDescription = sEmpty;
1157             pEntry->bIsCustomized = sal_True;
1158         }else
1159         {
1160             return sal_False;
1161         }
1162     }else
1163     {
1164         delete pActualBullets[nIndex]->pBullets;
1165         pActualBullets[nIndex]->pBullets = 0;
1166         if ( eNumType == SVX_NUM_CHAR_SPECIAL )
1167         {
1168             sal_Unicode cChar = aFmt.GetBulletChar();
1169             const Font* pFont = aFmt.GetBulletFont();
1170             pActualBullets[nIndex]->eType = eNBType::BULLETS;
1171             pActualBullets[nIndex]->nIndex = nIndex+1; //index in the tab page display,decrease 1 to the index within arr
1172             pActualBullets[nIndex]->pBullets = new BulletsSettings_Impl(eNBType::BULLETS) ;
1173             ((BulletsSettings_Impl*)(pActualBullets[nIndex]->pBullets))->cBulletChar = cChar;
1174             ((BulletsSettings_Impl*)(pActualBullets[nIndex]->pBullets))->aFont = pFont?*pFont:lcl_GetDefaultBulletFont();
1175             ((BulletsSettings_Impl*)(pActualBullets[nIndex]->pBullets))->bIsCustomized = sal_True;
1176             ((BulletsSettings_Impl*)(pActualBullets[nIndex]->pBullets))->eType = eNBType::BULLETS;
1177             BulletsTypeMgr* pBTMgr = BulletsTypeMgr::GetInstance();
1178             if ( pBTMgr )
1179             {
1180                 //sal_uInt16 nDIndex = pBTMgr->GetNBOIndexForNumRule(aNum,mLevel);
1181                 //if ( nDIndex != (sal_uInt16)0xFFFF)
1182                 //{
1183                 //  pActualBullets[nIndex]->nIndexDefault = nDIndex -1;
1184                 //  ((BulletsSettings_Impl*)(pActualBullets[nIndex]->pBullets))->sDescription = pBTMgr->GetDescription(nDIndex - 1);
1185                 //}else
1186                 {
1187                     pActualBullets[nIndex]->nIndexDefault  = (sal_uInt16)0xFFFF;
1188                     String aStrFromRES = String(SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION));
1189                     String aReplace = String::CreateFromAscii("%LIST_NUM");
1190                     String sNUM = String::CreateFromInt32( nIndex + 1 );
1191                     aStrFromRES.SearchAndReplace(aReplace,sNUM);
1192                     ((BulletsSettings_Impl*)(pActualBullets[nIndex]->pBullets))->sDescription = aStrFromRES;
1193                 }
1194             }
1195         }else if ( (eNumType&(~LINK_TOKEN)) == SVX_NUM_BITMAP )
1196         {
1197             const SvxBrushItem* pBrsh = aFmt.GetBrush();
1198             const Graphic* pGrf = 0;
1199             if ( pBrsh )
1200                 pGrf = pBrsh->GetGraphic();
1201             else
1202                 return sal_False;
1203 
1204             String sEmpty;
1205             const String* pGrfName = 0;
1206             if ( pGrf )
1207             {
1208                 pGrfName = pBrsh->GetGraphicLink();
1209 
1210                 pActualBullets[nIndex]->eType = eNBType::GRAPHICBULLETS;
1211                 pActualBullets[nIndex]->nIndex = nIndex+1; //index in the tab page display,decrease 1 to the index within arr
1212                 pActualBullets[nIndex]->pBullets = new GrfBulDataRelation(eNBType::GRAPHICBULLETS) ;
1213                 if (pGrfName)
1214                     ((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->sGrfName = *pGrfName;
1215                 ((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->bIsCustomized = sal_True;
1216                 ((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->eType = eNBType::GRAPHICBULLETS;
1217                 GraphyicBulletsTypeMgr* mGrfTMgr = GraphyicBulletsTypeMgr::GetInstance();
1218                 if ( mGrfTMgr )
1219                 {
1220                     //sal_uInt16 nDIndex = mGrfTMgr->GetNBOIndexForNumRule(aNum,mLevel);
1221                     //if ( nDIndex != (sal_uInt16)0xFFFF)
1222                     //{
1223                     //  pActualBullets[nIndex]->nIndexDefault = nDIndex - 1;
1224                     //  ((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->sDescription = mGrfTMgr->GetDescription(nDIndex - 1);
1225                     //}else
1226                     {
1227                         pActualBullets[nIndex]->nIndexDefault  = (sal_uInt16)0xFFFF;
1228                         String aStrFromRES = String(SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION));
1229                         String aReplace = String::CreateFromAscii("%LIST_NUM");
1230                         String sNUM = String::CreateFromInt32( nIndex + 1 );
1231                         aStrFromRES.SearchAndReplace(aReplace,sNUM);
1232                         ((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->sDescription = aStrFromRES;
1233                         //((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->pGrfObj = pGrf;
1234                         ((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->pGrfObj = new Graphic(*pGrf);
1235                         ((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->pGrfObj = new Graphic(*pGrf);
1236                         Size aTmpSize = aFmt.GetGraphicSize();
1237                         aTmpSize = OutputDevice::LogicToLogic(aTmpSize,(MapUnit)GetMapUnit(),MAP_100TH_MM);
1238                         sal_uInt16 nDIndex = mGrfTMgr->GetNBOIndexForNumRule(aNum,mLevel);
1239                         if (nDIndex!=(sal_uInt16)0xFFFF) aTmpSize=Size(0,0);
1240                         ((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->aSize = aTmpSize;
1241 
1242                 }
1243                 }
1244             }
1245         }
1246     }
1247     SvxNumRule aTmpRule1(aNum);
1248     ApplyNumRule(aTmpRule1,nIndex,mLevel,true);
1249     if (GetNBOIndexForNumRule(aTmpRule1,mLevel,nIndex)==nIndex+1) {
1250         if (pActualBullets[nIndex]->eType == eNBType::BULLETS) {
1251             BulletsSettings_Impl* pEntry = (BulletsSettings_Impl*) (pActualBullets[nIndex]->pBullets);
1252             pEntry->bIsCustomized = false;
1253             pEntry->sDescription = GetDescription(nIndex,true);
1254         }
1255         if (pActualBullets[nIndex]->eType == eNBType::GRAPHICBULLETS) {
1256             GrfBulDataRelation* pEntry = (GrfBulDataRelation*) (pActualBullets[nIndex]->pBullets);
1257             pEntry->bIsCustomized = false;
1258             pEntry->sDescription = GetDescription(nIndex,true);
1259         }
1260     }
1261     ImplStore(String::CreateFromAscii("standard.sya"));
1262     return sal_True;
1263 }
1264 
1265 sal_Bool MixBulletsTypeMgr::ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel,sal_Bool isDefault,sal_Bool isResetSize)
1266 {
1267     //if ( mLevel == (sal_uInt16)0xFFFF || nIndex>=DEFAULT_BULLET_TYPES )
1268     if ( nIndex>=DEFAULT_BULLET_TYPES )
1269         return sal_False;
1270     MixBulletsSettings_Impl* pCurrentBullets = pActualBullets[nIndex];
1271     if (isDefault) pCurrentBullets=pDefaultActualBullets[nIndex];
1272 
1273     if ( pCurrentBullets->eType == eNBType::BULLETS )
1274     {
1275         sal_Unicode cChar;
1276         cChar = ((BulletsSettings_Impl*)(pCurrentBullets->pBullets))->cBulletChar;
1277 
1278         //Font& rActBulletFont = lcl_GetDefaultBulletFont();
1279         Font rActBulletFont = ((BulletsSettings_Impl*)(pCurrentBullets->pBullets))->aFont;
1280         sal_uInt16 nMask = 1;
1281         String sBulletCharFmtName = GetBulCharFmtName();
1282         for(sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
1283         {
1284             if(mLevel & nMask)
1285             {
1286                 SvxNumberFormat aFmt(aNum.GetLevel(i));
1287                 if (SVX_NUM_CHAR_SPECIAL !=aFmt.GetNumberingType()) isResetSize=true;
1288                 aFmt.SetNumberingType( SVX_NUM_CHAR_SPECIAL );
1289                 aFmt.SetBulletFont(&rActBulletFont);
1290                 aFmt.SetBulletChar(cChar );
1291                 aFmt.SetCharFmtName(sBulletCharFmtName);
1292                 String aEmptyStr;
1293                 aFmt.SetPrefix( aEmptyStr );
1294                 aFmt.SetSuffix( aEmptyStr );
1295                 if (isResetSize) aFmt.SetBulletRelSize(45);
1296                 aNum.SetLevel(i, aFmt);
1297             }
1298             nMask <<= 1;
1299         }
1300     }else if (  pCurrentBullets->eType == eNBType::GRAPHICBULLETS )
1301     {
1302         String sGrfName;
1303         GrfBulDataRelation* pEntry = (GrfBulDataRelation*) (pCurrentBullets->pBullets);
1304         sGrfName= pEntry->sGrfName;
1305 
1306         sal_uInt16 nMask = 1;
1307         String aEmptyStr;
1308         sal_uInt16 nSetNumberingType = SVX_NUM_BITMAP;
1309         String sNumCharFmtName = GetBulCharFmtName();
1310         for(sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
1311         {
1312             if(mLevel & nMask)
1313             {
1314                 SvxNumberFormat aFmt(aNum.GetLevel(i));
1315                 if (SVX_NUM_BITMAP !=aFmt.GetNumberingType()) isResetSize=true;
1316                 aFmt.SetNumberingType(nSetNumberingType);
1317                 aFmt.SetPrefix( aEmptyStr );
1318                 aFmt.SetSuffix( aEmptyStr );
1319                 aFmt.SetCharFmtName( sNumCharFmtName );
1320                 if ( pCurrentBullets->nIndexDefault == (sal_uInt16)0xFFFF && pEntry->pGrfObj )
1321                 {
1322                     Size aSize = pEntry->aSize;
1323                     sal_Int16 eOrient = text::VertOrientation::LINE_CENTER;
1324                     if (!isResetSize && aFmt.GetGraphicSize()!=Size(0,0)) aSize=aFmt.GetGraphicSize();
1325                     else {
1326                         if (aSize.Width()==0 && aSize.Height()==0) {
1327                             aSize = SvxNumberFormat::GetGraphicSizeMM100( pEntry->pGrfObj );
1328                         }
1329                         aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)GetMapUnit());
1330                     }
1331                     SvxBrushItem aBrush(*(pEntry->pGrfObj), GPOS_AREA, SID_ATTR_BRUSH );
1332                     aFmt.SetGraphicBrush( &aBrush, &aSize, &eOrient );
1333                 }else
1334                 {
1335                             Graphic aGraphic;
1336                             if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, pCurrentBullets->nIndexDefault, &aGraphic))
1337                     {
1338                                 Size aSize = pEntry->aSize;
1339                                 sal_Int16 eOrient = text::VertOrientation::LINE_CENTER;
1340                                 if (!isResetSize  && aFmt.GetGraphicSize()!=Size(0,0)) aSize=aFmt.GetGraphicSize();
1341                                 else {
1342                                     if (aSize.Width()==0 && aSize.Height()==0) {
1343                                         aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
1344                                     }
1345                                     aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)GetMapUnit());
1346                                 }
1347                                 SvxBrushItem aBrush(aGraphic, GPOS_AREA, SID_ATTR_BRUSH );
1348                                 aFmt.SetGraphicBrush( &aBrush, &aSize, &eOrient );
1349                     }else
1350                         aFmt.SetGraphic( sGrfName );
1351                 }
1352 
1353                 aNum.SetLevel(i, aFmt);
1354             }
1355             nMask <<= 1 ;
1356         }
1357     }
1358 
1359     return sal_True;
1360 }
1361 
1362 String MixBulletsTypeMgr::GetDescription(sal_uInt16 nIndex,sal_Bool isDefault)
1363 {
1364     String sRet;
1365     //sal_uInt16 nLength = 0;
1366     //nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
1367 
1368     if ( nIndex >= DEFAULT_BULLET_TYPES )
1369         return sRet;
1370     else
1371         sRet = pActualBullets[nIndex]->pBullets->sDescription;
1372     if (isDefault) sRet = pDefaultActualBullets[nIndex]->pBullets->sDescription;
1373     return sRet;
1374 }
1375 sal_Bool MixBulletsTypeMgr::IsCustomized(sal_uInt16 nIndex)
1376 {
1377     sal_Bool bRet = sal_False;
1378     //sal_uInt16 nLength = 0;
1379     //nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
1380 
1381     if ( nIndex >= DEFAULT_BULLET_TYPES )
1382         bRet = sal_False;
1383     else
1384         bRet = pActualBullets[nIndex]->pBullets->bIsCustomized;
1385 
1386     return bRet;
1387 }
1388 /***************************************************************************************************
1389 **********************Numbering Type lib**************************************************************
1390 ****************************************************************************************************/
1391 NumberingTypeMgr* NumberingTypeMgr::_instance = 0;
1392 
1393 NumberingTypeMgr::NumberingTypeMgr(const NBOType aType):
1394     NBOTypeMgrBase(aType),
1395     //pNumSettingsArr( new NumSettingsArr_Impl ),
1396     pNumberSettingsArr (new NumberSettingsArr_Impl)
1397 {
1398     Init();
1399     pDefaultNumberSettingsArr = pNumberSettingsArr;
1400     pNumberSettingsArr = new NumberSettingsArr_Impl;
1401     //Initial the first time to store the default value. Then do it again for customized value
1402     Init();
1403     ImplLoad(String::CreateFromAscii("standard.syb"));
1404 }
1405 
1406 NumberingTypeMgr::NumberingTypeMgr(const NBOType aType,const SfxItemSet* pArg):
1407     NBOTypeMgrBase(aType,pArg),
1408     //pNumSettingsArr( new NumSettingsArr_Impl ),
1409     pNumberSettingsArr (new NumberSettingsArr_Impl)
1410 {
1411     Init();
1412     pDefaultNumberSettingsArr = pNumberSettingsArr;
1413     pNumberSettingsArr = new NumberSettingsArr_Impl;
1414     //Initial the first time to store the default value. Then do it again for customized value
1415     Init();
1416     ImplLoad(String::CreateFromAscii("standard.syb"));
1417 }
1418 
1419 NumberingTypeMgr::NumberingTypeMgr(const NumberingTypeMgr& aTypeMgr):
1420     NBOTypeMgrBase(aTypeMgr),
1421     //pNumSettingsArr( new NumSettingsArr_Impl ),
1422     pNumberSettingsArr (new NumberSettingsArr_Impl)
1423 {
1424     /*
1425     for(sal_uInt16 i=0;i<aTypeMgr.GetNumCount();i++)
1426     {
1427         NumberSettings_Impl* _pSet = aTypeMgr.GetNumSettingByIndex(i);
1428         if ( _pSet )
1429         {
1430             pNumberSettingsArr->GetObject(i)->nIndex = _pSet->nIndex;
1431             pNumberSettingsArr->GetObject(i)->nIndexDefault = _pSet->nIndexDefault;
1432             pNumberSettingsArr->GetObject(i)->sDescription = _pSet->sDescription;
1433             pNumberSettingsArr->GetObject(i)->bIsCustomized = _pSet->bIsCustomized;
1434             if ( _pSet->pNumSetting )
1435             {
1436                 pNumberSettingsArr->GetObject(i)->pNumSetting->nNumberType = _pSet->pNumSetting->nNumberType;
1437                 pNumberSettingsArr->GetObject(i)->pNumSetting->nParentNumbering = _pSet->pNumSetting->nParentNumbering;
1438                 pNumberSettingsArr->GetObject(i)->pNumSetting->sPrefix = _pSet->pNumSetting->sPrefix;
1439                 pNumberSettingsArr->GetObject(i)->pNumSetting->sSuffix = _pSet->pNumSetting->sSuffix;
1440                 pNumberSettingsArr->GetObject(i)->pNumSetting->sBulletChar = _pSet->pNumSetting->sBulletChar;
1441                 pNumberSettingsArr->GetObject(i)->pNumSetting->sBulletFont = _pSet->pNumSetting->sBulletFont;
1442 
1443                 pNumberSettingsArr->GetObject(i)->pNumSetting->eLabelFollowedBy = _pSet->pNumSetting->eLabelFollowedBy;
1444                 pNumberSettingsArr->GetObject(i)->pNumSetting->nTabValue = _pSet->pNumSetting->nTabValue;
1445                 pNumberSettingsArr->GetObject(i)->pNumSetting->eNumAlign = _pSet->pNumSetting->eNumAlign;
1446                 pNumberSettingsArr->GetObject(i)->pNumSetting->nNumAlignAt = _pSet->pNumSetting->nNumAlignAt;
1447                 pNumberSettingsArr->GetObject(i)->pNumSetting->nNumIndentAt = _pSet->pNumSetting->nNumIndentAt;
1448             }
1449         }
1450     }
1451     */
1452     ImplLoad(String::CreateFromAscii("standard.syb"));
1453 }
1454 
1455 void NumberingTypeMgr::Init()
1456 {
1457     Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
1458     Reference < XInterface > xI = xMSF->createInstance(
1459         ::rtl::OUString::createFromAscii( "com.sun.star.text.DefaultNumberingProvider" ) );
1460     Reference<XDefaultNumberingProvider> xDefNum(xI, UNO_QUERY);
1461 
1462     if(xDefNum.is())
1463     {
1464         Sequence< Sequence< PropertyValue > > aNumberings;
1465             LanguageType eLang = Application::GetSettings().GetLanguage();
1466         Locale aLocale = SvxCreateLocale(eLang);
1467         try
1468         {
1469             aNumberings = xDefNum->getDefaultContinuousNumberingLevels( aLocale );
1470 
1471                     sal_Int32 nLength = aNumberings.getLength() > DEFAULT_NUM_VALUSET_COUNT ? DEFAULT_NUM_VALUSET_COUNT :aNumberings.getLength();
1472 
1473             const Sequence<PropertyValue>* pValuesArr = aNumberings.getConstArray();
1474             for(sal_Int32 i = 0; i < nLength; i++)
1475             {
1476                 NumSettings_ImplPtr pNew = lcl_CreateNumberingSettingsPtr(pValuesArr[i]);
1477                 NumberSettings_Impl* pNumEntry = new NumberSettings_Impl;
1478                 pNumEntry->nIndex = i + 1;
1479                 pNumEntry->nIndexDefault = i;
1480                 pNumEntry->pNumSetting = pNew;
1481                 //SetItemText( i + 1, SVX_RESSTR( RID_SVXSTR_SINGLENUM_DESCRIPTIONS + i ));
1482                 {
1483                     String sText;
1484                     //const OUString sValue(C2U("Value"));
1485                     Reference<XNumberingFormatter> xFormatter(xDefNum, UNO_QUERY);
1486                     if(xFormatter.is() && aNumberings.getLength() > i)
1487                     {
1488 
1489                         for (sal_uInt16 j=0;j<3;j++)
1490                         {
1491                             Sequence<PropertyValue> aLevel = aNumberings.getConstArray()[i];
1492                             try
1493                             {
1494                                 aLevel.realloc(aLevel.getLength() + 1);
1495                                 PropertyValue& rValue = aLevel.getArray()[aLevel.getLength() - 1];
1496                                 rValue.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value"));
1497                                 rValue.Value <<= (sal_Int32)(j + 1);
1498 
1499                                 if (j!=0)
1500                                     sText += String::CreateFromAscii(" ");
1501 
1502                                 sText+=String(xFormatter->makeNumberingString( aLevel, aLocale ));
1503                             }
1504                             catch(Exception&)
1505                             {
1506                                 DBG_ERROR("Exception in DefaultNumberingProvider::makeNumberingString");
1507                             }
1508                         }
1509                     }
1510                     String aStrFromRES(SVX_RESSTR( RID_SVXSTR_SINGLENUM_DESCRIPTIONS));
1511                     String aReplace = String::CreateFromAscii("%NUMBERINGSAMPLE");
1512                     aStrFromRES.SearchAndReplace(aReplace,sText);
1513                     pNumEntry->sDescription = aStrFromRES;
1514                 }
1515         //End modification
1516 
1517                 //pNumEntry->sDescription = SVX_RESSTR( RID_SVXSTR_SINGLENUM_DESCRIPTION_0 + i );
1518                 pNumberSettingsArr->Insert(pNumEntry, pNumberSettingsArr->Count());
1519             }
1520         }
1521         catch(Exception&)
1522         {
1523         }
1524     }
1525 }
1526 
1527 sal_uInt16 NumberingTypeMgr::GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex)
1528 {
1529     if ( mLevel == (sal_uInt16)0xFFFF || mLevel > aNum.GetLevelCount() || mLevel == 0)
1530         return (sal_uInt16)0xFFFF;
1531 
1532     sal_uInt16 nActLv = IsSingleLevel(mLevel);
1533 
1534     if ( nActLv == (sal_uInt16)0xFFFF )
1535         return (sal_uInt16)0xFFFF;
1536 
1537     SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
1538     String sPreFix = aFmt.GetPrefix();
1539     String sSuffix = aFmt.GetSuffix();
1540     String sEmpty;
1541         sal_Int16 eNumType = aFmt.GetNumberingType();
1542 
1543     sal_uInt16 nCount = pNumberSettingsArr->Count();
1544     for(sal_uInt16 i = nFromIndex; i < nCount; i++)
1545     {
1546         NumberSettings_ImplPtr _pSet = pNumberSettingsArr->GetObject(i);
1547         sal_Int16 eNType = _pSet->pNumSetting->nNumberType;
1548         String sLocalPreFix = _pSet->pNumSetting->sPrefix.getStr();
1549         String sLocalSuffix = _pSet->pNumSetting->sSuffix.getStr();
1550         if (sPreFix.CompareTo(sLocalPreFix)==COMPARE_EQUAL &&
1551             sSuffix.CompareTo(sLocalSuffix)==COMPARE_EQUAL &&
1552             eNumType == eNType )
1553         {
1554             return i+1;
1555         }
1556     }
1557 
1558 
1559     return (sal_uInt16)0xFFFF;
1560 }
1561 
1562 sal_Bool NumberingTypeMgr::RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel)
1563 {
1564     //if ( mLevel == (sal_uInt16)0xFFFF || mLevel == 0)
1565     //  return sal_False;
1566 
1567     //if ( GetNBOIndexForNumRule(aNum,mLevel) != (sal_uInt16)0xFFFF )
1568     //  return sal_False;
1569 
1570     sal_uInt16 nActLv = IsSingleLevel(mLevel);
1571 
1572     if ( nActLv == (sal_uInt16)0xFFFF )
1573         return sal_False;
1574 
1575     SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
1576     //sal_Unicode cPrefix = rtl::OUString(aFmt.GetPrefix()).getStr()[0];
1577     //sal_Unicode cSuffix = rtl::OUString(aFmt.GetSuffix()).getStr()[0];
1578     sal_Int16 eNumType = aFmt.GetNumberingType();
1579 
1580     sal_uInt16 nCount = pNumberSettingsArr->Count();
1581     if ( nIndex >= nCount )
1582         return sal_False;
1583 
1584     NumberSettings_ImplPtr _pSet = pNumberSettingsArr->GetObject(nIndex);
1585 
1586     _pSet->pNumSetting->sPrefix = aFmt.GetPrefix();
1587     _pSet->pNumSetting->sSuffix = aFmt.GetSuffix();
1588      _pSet->pNumSetting->nNumberType = eNumType;
1589     _pSet->bIsCustomized = sal_True;
1590 
1591     SvxNumRule aTmpRule1(aNum);
1592     SvxNumRule aTmpRule2(aNum);
1593     ApplyNumRule(aTmpRule1,nIndex,mLevel,true);
1594     ApplyNumRule(aTmpRule2,nIndex,mLevel,false);
1595     if (aTmpRule1==aTmpRule2) _pSet->bIsCustomized=false;
1596     if (_pSet->bIsCustomized) {
1597         String aStrFromRES = String(SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_NUMBERING_DESCRIPTION));
1598         String aReplace = String::CreateFromAscii("%LIST_NUM");
1599         String sNUM = String::CreateFromInt32( nIndex + 1 );
1600         aStrFromRES.SearchAndReplace(aReplace,sNUM);
1601         _pSet->sDescription = aStrFromRES;
1602     } else {
1603         _pSet->sDescription = GetDescription(nIndex,true);
1604     }
1605     ImplStore(String::CreateFromAscii("standard.syb"));
1606     return sal_True;
1607 }
1608 
1609 sal_Bool NumberingTypeMgr::ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel,sal_Bool isDefault,sal_Bool isResetSize)
1610 {
1611     //if ( mLevel == (sal_uInt16)0xFFFF )
1612     //  return sal_False;
1613 
1614     //DBG_ASSERT(pNumSettingsArr->Count() > nIndex, "wrong index");
1615     if(pNumberSettingsArr->Count() <= nIndex)
1616         return sal_False;
1617     NumberSettingsArr_Impl*     pCurrentNumberSettingsArr=pNumberSettingsArr;
1618     if (isDefault) pCurrentNumberSettingsArr=pDefaultNumberSettingsArr;
1619     NumberSettings_ImplPtr _pSet = pCurrentNumberSettingsArr->GetObject(nIndex);
1620     sal_Int16 eNewType = _pSet->pNumSetting->nNumberType;
1621 
1622     sal_uInt16 nMask = 1;
1623     String sNumCharFmtName = GetBulCharFmtName();
1624     for(sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
1625     {
1626         if(mLevel & nMask)
1627         {
1628             SvxNumberFormat aFmt(aNum.GetLevel(i));
1629             if (eNewType!=aFmt.GetNumberingType()) isResetSize=true;
1630             aFmt.SetNumberingType(eNewType);
1631             aFmt.SetPrefix(_pSet->pNumSetting->sPrefix);
1632             aFmt.SetSuffix(_pSet->pNumSetting->sSuffix);
1633 
1634             aFmt.SetCharFmtName(sNumCharFmtName);
1635             if (isResetSize) aFmt.SetBulletRelSize(100);
1636             aNum.SetLevel(i, aFmt);
1637         }
1638         nMask <<= 1 ;
1639     }
1640 
1641     return sal_True;
1642 }
1643 String NumberingTypeMgr::GetDescription(sal_uInt16 nIndex,sal_Bool isDefault)
1644 {
1645     String sRet;
1646     sal_uInt16 nLength = 0;
1647     nLength = pNumberSettingsArr->Count();
1648 
1649     if ( nIndex >= nLength )
1650         return sRet;
1651     else
1652         sRet = pNumberSettingsArr->GetObject(nIndex)->sDescription;
1653     if (isDefault) sRet = pDefaultNumberSettingsArr->GetObject(nIndex)->sDescription;
1654 
1655     return sRet;
1656 }
1657 sal_Bool NumberingTypeMgr::IsCustomized(sal_uInt16 nIndex)
1658 {
1659     sal_Bool bRet = sal_False;
1660     sal_uInt16 nLength = 0;
1661     nLength = pNumberSettingsArr->Count();
1662 
1663     if ( nIndex >= nLength )
1664         bRet = sal_False;
1665     else
1666         bRet = pNumberSettingsArr->GetObject(nIndex)->bIsCustomized;
1667 
1668     return bRet;
1669 }
1670 sal_uInt16 NumberingTypeMgr::GetNumCount() const
1671 {
1672     sal_uInt16 nRet = 0;
1673     if ( pNumberSettingsArr )
1674         nRet = pNumberSettingsArr->Count();
1675 
1676     return nRet;
1677 }
1678 NumberSettings_Impl* NumberingTypeMgr::GetNumSettingByIndex(sal_uInt16 nIndex) const
1679 {
1680     NumberSettings_Impl* pRet = 0;
1681     if ( pNumberSettingsArr && nIndex< pNumberSettingsArr->Count() )
1682     {
1683         pRet = pNumberSettingsArr->GetObject(nIndex);
1684     }
1685 
1686     return pRet;
1687 }
1688 /***************************************************************************************************
1689 **********************Multi-level /Outline Type lib*******************************************************
1690 ****************************************************************************************************/
1691 OutlineTypeMgr* OutlineTypeMgr::_instance = 0;
1692 
1693 OutlineTypeMgr::OutlineTypeMgr(const NBOType aType):
1694     NBOTypeMgrBase(aType)//,
1695     //pNumSettingsArrs( new NumSettingsArr_Impl[DEFAULT_NUM_VALUSET_COUNT] )
1696 {
1697     Init();
1698     for(sal_Int32 nItem = 0; nItem < DEFAULT_NUM_VALUSET_COUNT; nItem++ )
1699     {
1700         pDefaultOutlineSettingsArrs[nItem] = pOutlineSettingsArrs[nItem];
1701     }
1702     //Initial the first time to store the default value. Then do it again for customized value
1703     Init();
1704     ImplLoad(String::CreateFromAscii("standard.syc"));
1705 }
1706 
1707 OutlineTypeMgr::OutlineTypeMgr(const NBOType aType,const SfxItemSet* pArg):
1708     NBOTypeMgrBase(aType,pArg)//,
1709     //pNumSettingsArrs( new NumSettingsArr_Impl[DEFAULT_NUM_VALUSET_COUNT])
1710 {
1711     Init();
1712     for(sal_Int32 nItem = 0; nItem < DEFAULT_NUM_VALUSET_COUNT; nItem++ )
1713     {
1714         pDefaultOutlineSettingsArrs[nItem] = pOutlineSettingsArrs[nItem];
1715     }
1716     //Initial the first time to store the default value. Then do it again for customized value
1717     Init();
1718     ImplLoad(String::CreateFromAscii("standard.syc"));
1719 }
1720 
1721 OutlineTypeMgr::OutlineTypeMgr(const OutlineTypeMgr& aTypeMgr):
1722     NBOTypeMgrBase(aTypeMgr)//,
1723     //pNumSettingsArrs( new NumSettingsArr_Impl[DEFAULT_NUM_VALUSET_COUNT])
1724 {
1725     Init();
1726     for(sal_Int32 nItem = 0; nItem < DEFAULT_NUM_VALUSET_COUNT; nItem++ )
1727     {
1728         pDefaultOutlineSettingsArrs[nItem] = pOutlineSettingsArrs[nItem];
1729     }
1730     //Initial the first time to store the default value. Then do it again for customized value
1731     Init();
1732     ImplLoad(String::CreateFromAscii("standard.syc"));
1733 }
1734 
1735 void OutlineTypeMgr::Init()
1736 {
1737     Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
1738     Reference < XInterface > xI = xMSF->createInstance(
1739         ::rtl::OUString::createFromAscii( "com.sun.star.text.DefaultNumberingProvider" ) );
1740     Reference<XDefaultNumberingProvider> xDefNum(xI, UNO_QUERY);
1741 
1742     if(xDefNum.is())
1743     {
1744         Sequence<Reference<XIndexAccess> > aOutlineAccess;
1745             LanguageType eLang = Application::GetSettings().GetLanguage();
1746         Locale aLocale = SvxCreateLocale(eLang);
1747         try
1748         {
1749             aOutlineAccess = xDefNum->getDefaultOutlineNumberings( aLocale );
1750 
1751             SvxNumRule aDefNumRule( NUM_BULLET_REL_SIZE|NUM_CONTINUOUS|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE|NUM_SYMBOL_ALIGNMENT,10, sal_False ,
1752                 SVX_RULETYPE_NUMBERING,SvxNumberFormat::LABEL_ALIGNMENT);
1753 
1754             for(sal_Int32 nItem = 0;
1755                 nItem < aOutlineAccess.getLength() && nItem < DEFAULT_NUM_VALUSET_COUNT;
1756                 nItem++ )
1757             {
1758                 pOutlineSettingsArrs[ nItem ] = new OutlineSettings_Impl;
1759                 OutlineSettings_Impl* pItemArr = pOutlineSettingsArrs[ nItem ];
1760                 pItemArr->sDescription = SVX_RESSTR( RID_SVXSTR_OUTLINENUM_DESCRIPTION_0 + nItem );
1761                 pItemArr->pNumSettingsArr = new NumSettingsArr_Impl;
1762                 Reference<XIndexAccess> xLevel = aOutlineAccess.getConstArray()[nItem];
1763                 for(sal_Int32 nLevel = 0; nLevel < xLevel->getCount() && nLevel < 5; nLevel++)
1764                 {
1765                     Any aValueAny = xLevel->getByIndex(nLevel);
1766                     Sequence<PropertyValue> aLevelProps;
1767                     aValueAny >>= aLevelProps;
1768                     NumSettings_ImplPtr pNew = lcl_CreateNumberingSettingsPtr(aLevelProps);
1769                     SvxNumberFormat aNumFmt( aDefNumRule.GetLevel( nLevel) );
1770                     pNew->eLabelFollowedBy = aNumFmt.GetLabelFollowedBy();
1771                     pNew->nTabValue = aNumFmt.GetListtabPos();
1772                     pNew->eNumAlign = aNumFmt.GetNumAdjust();
1773                     pNew->nNumAlignAt = aNumFmt.GetFirstLineIndent();
1774                     pNew->nNumIndentAt = aNumFmt.GetIndentAt();
1775                     pItemArr->pNumSettingsArr->Insert( pNew, pItemArr->pNumSettingsArr->Count() );
1776                 }
1777             }
1778         }
1779         catch(Exception&)
1780         {
1781         }
1782     }
1783 }
1784 
1785 sal_uInt16 OutlineTypeMgr::GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 /* mLevel */,sal_uInt16 nFromIndex)
1786 {
1787     sal_uInt16 nLength = sizeof(pOutlineSettingsArrs)/sizeof(OutlineSettings_Impl*);
1788     for(sal_uInt16 iDex = nFromIndex; iDex < nLength; iDex++)
1789     {
1790         sal_Bool bNotMatch = sal_False;
1791         OutlineSettings_Impl* pItemArr = pOutlineSettingsArrs[iDex];
1792         sal_uInt16 nCount = pItemArr->pNumSettingsArr->Count();
1793         for (sal_uInt16 iLevel=0;iLevel < nCount;iLevel++)
1794         {
1795             NumSettings_ImplPtr _pSet = pItemArr->pNumSettingsArr->GetObject(iLevel);
1796             sal_Int16 eNType = _pSet->nNumberType;
1797 
1798                 SvxNumberFormat aFmt(aNum.GetLevel(iLevel));
1799             String sPreFix = aFmt.GetPrefix();
1800             String sSuffix = aFmt.GetSuffix();
1801             String sEmpty;
1802                 sal_Int16 eNumType = aFmt.GetNumberingType();
1803                 if( eNumType == SVX_NUM_CHAR_SPECIAL)
1804             {
1805                 sal_Unicode cChar = aFmt.GetBulletChar();
1806                 sal_Unicode ccChar = _pSet->sBulletChar.getStr()[0];
1807                 rtl::OUString sFont = _pSet->sBulletFont;
1808                 if ( !((cChar == ccChar) && //pFont && sFont.compareTo(pFont->GetName()) &&
1809                     _pSet->eLabelFollowedBy == aFmt.GetLabelFollowedBy() &&
1810                     _pSet->nTabValue == aFmt.GetListtabPos() &&
1811                     _pSet->eNumAlign == aFmt.GetNumAdjust() &&
1812                     _pSet->nNumAlignAt == aFmt.GetFirstLineIndent() &&
1813                     _pSet->nNumIndentAt == aFmt.GetIndentAt()))
1814                 {
1815                     bNotMatch = sal_True;
1816                     break;
1817                 }
1818                 }else if ((eNumType&(~LINK_TOKEN)) == SVX_NUM_BITMAP ) {
1819                         const SvxBrushItem* pBrsh1 = aFmt.GetBrush();
1820                         const SvxBrushItem* pBrsh2 = _pSet->pBrushItem;
1821                         sal_Bool bIsMatch = false;
1822                         if (pBrsh1==pBrsh2) bIsMatch = true;
1823                         if (pBrsh1 && pBrsh2) {
1824                             const Graphic* pGrf1 = pBrsh1->GetGraphic();;
1825                             const Graphic* pGrf2 = pBrsh2->GetGraphic();;
1826                             if (pGrf1==pGrf2) bIsMatch = true;
1827                             if (pGrf1 && pGrf2) {
1828                                 if ( pGrf1->GetBitmap().IsEqual(pGrf2->GetBitmap()) &&
1829                                      _pSet->aSize==aFmt.GetGraphicSize())
1830                                     bIsMatch = true;
1831                             }
1832                         }
1833                         if (!bIsMatch) {
1834                             bNotMatch = sal_True;
1835                             break;
1836                         }
1837                 } else
1838                 {
1839                 if (!((sPreFix.CompareTo(_pSet->sPrefix.getStr())==COMPARE_EQUAL) &&
1840                     ( sSuffix.CompareTo(_pSet->sSuffix.getStr())==COMPARE_EQUAL ) &&
1841                     eNumType == eNType &&
1842                     _pSet->eLabelFollowedBy == aFmt.GetLabelFollowedBy() &&
1843                     _pSet->nTabValue == aFmt.GetListtabPos() &&
1844                     _pSet->eNumAlign == aFmt.GetNumAdjust() &&
1845                     _pSet->nNumAlignAt == aFmt.GetFirstLineIndent() &&
1846                     _pSet->nNumIndentAt == aFmt.GetIndentAt()))
1847                 {
1848                     bNotMatch = sal_True;
1849                     break;
1850                 }
1851                 }
1852         }
1853         if ( !bNotMatch )
1854             return iDex+1;
1855     }
1856 
1857 
1858     return (sal_uInt16)0xFFFF;
1859 }
1860 
1861 sal_Bool OutlineTypeMgr::RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel)
1862 {
1863     //if ( mLevel == 0 || mLevel == (sal_uInt16)0xFFFF )
1864     //  return sal_False;
1865 
1866     sal_uInt16 nLength = sizeof(pOutlineSettingsArrs)/sizeof(OutlineSettings_Impl*);
1867     if ( nIndex >= nLength )
1868         return sal_False;
1869 
1870     OutlineSettings_Impl* pItemArr = pOutlineSettingsArrs[nIndex];
1871     sal_uInt16 nCount = pItemArr->pNumSettingsArr->Count();
1872     for (sal_uInt16 iLevel=0;iLevel < nCount;iLevel++)
1873     {
1874         SvxNumberFormat aFmt(aNum.GetLevel(iLevel));
1875         sal_Int16 eNumType = aFmt.GetNumberingType();
1876 
1877         NumSettings_ImplPtr _pSet = pItemArr->pNumSettingsArr->GetObject(iLevel);
1878 
1879         _pSet->eLabelFollowedBy = aFmt.GetLabelFollowedBy();
1880         _pSet->nTabValue = aFmt.GetListtabPos();
1881         _pSet->eNumAlign = aFmt.GetNumAdjust();
1882         _pSet->nNumAlignAt = aFmt.GetFirstLineIndent();
1883         _pSet->nNumIndentAt = aFmt.GetIndentAt();
1884 
1885         if( eNumType == SVX_NUM_CHAR_SPECIAL)
1886         {
1887             sal_Unicode cChar = aFmt.GetBulletChar();
1888             OUString sChar(cChar);
1889             _pSet->sBulletChar = sChar;//OUString(cChar);
1890             if ( aFmt.GetBulletFont() )
1891                 _pSet->sBulletFont = rtl::OUString(aFmt.GetBulletFont()->GetName());
1892             _pSet->nNumberType = eNumType;
1893             pItemArr->bIsCustomized = sal_True;
1894         }else if ((eNumType&(~LINK_TOKEN)) == SVX_NUM_BITMAP ) {
1895             if (_pSet->pBrushItem) {
1896                 delete (_pSet->pBrushItem);
1897                 _pSet->pBrushItem=NULL;
1898             }
1899             if (aFmt.GetBrush())
1900                 _pSet->pBrushItem = new SvxBrushItem(*aFmt.GetBrush());
1901             _pSet->aSize = aFmt.GetGraphicSize();
1902             _pSet->nNumberType = eNumType;
1903         } else
1904         {
1905             _pSet->sPrefix = aFmt.GetPrefix();
1906             _pSet->sSuffix = aFmt.GetSuffix();
1907             _pSet->nNumberType = eNumType;
1908             if ( aFmt.GetBulletFont() )
1909                 _pSet->sBulletFont = rtl::OUString(aFmt.GetBulletFont()->GetName());
1910             pItemArr->bIsCustomized = sal_True;
1911          }
1912     }
1913     SvxNumRule aTmpRule1(aNum);
1914     SvxNumRule aTmpRule2(aNum);
1915     ApplyNumRule(aTmpRule1,nIndex,mLevel,true);
1916     ApplyNumRule(aTmpRule2,nIndex,mLevel,false);
1917     if (aTmpRule1==aTmpRule2) pItemArr->bIsCustomized=false;
1918     if (pItemArr->bIsCustomized) {
1919         String aStrFromRES = String(SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_MULTILEVEL_DESCRIPTION));
1920         String aReplace = String::CreateFromAscii("%LIST_NUM");
1921         String sNUM = String::CreateFromInt32( nIndex + 1 );
1922         aStrFromRES.SearchAndReplace(aReplace,sNUM);
1923         pItemArr->sDescription = aStrFromRES;
1924     } else {
1925         pItemArr->sDescription = GetDescription(nIndex,true);
1926     }
1927     ImplStore(String::CreateFromAscii("standard.syc"));
1928     return sal_True;
1929 }
1930 
1931 sal_Bool OutlineTypeMgr::ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 /* mLevel */,sal_Bool isDefault,sal_Bool isResetSize)
1932 {
1933     //if ( mLevel == (sal_uInt16)0xFFFF )
1934     //  return sal_False;
1935 
1936     DBG_ASSERT(DEFAULT_NUM_VALUSET_COUNT > nIndex, "wrong index");
1937     if(DEFAULT_NUM_VALUSET_COUNT <= nIndex)
1938         return sal_False;
1939 
1940     const FontList* pList = 0;
1941 
1942     OutlineSettings_Impl* pItemArr = pOutlineSettingsArrs[nIndex];
1943     if (isDefault) pItemArr=pDefaultOutlineSettingsArrs[nIndex];
1944 
1945     //Font& rActBulletFont = lcl_GetDefaultBulletFont();
1946     NumSettingsArr_Impl *pNumSettingsArr=pItemArr->pNumSettingsArr;
1947 
1948     NumSettings_ImplPtr pLevelSettings = 0;
1949     String sBulletCharFmtName = GetBulCharFmtName();
1950     for(sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
1951     {
1952         if(pNumSettingsArr->Count() > i)
1953             pLevelSettings = pNumSettingsArr->GetObject(i);
1954 
1955         if(!pLevelSettings)
1956             break;
1957 
1958         SvxNumberFormat aFmt(aNum.GetLevel(i));
1959         //aFmt.SetBulletFont(&pLevelSettings->aFont);
1960         Font& rActBulletFont = lcl_GetDefaultBulletFont();
1961         if (pLevelSettings->nNumberType !=aFmt.GetNumberingType()) isResetSize=true;
1962         aFmt.SetNumberingType( pLevelSettings->nNumberType );
1963         sal_uInt16 nUpperLevelOrChar = (sal_uInt16)pLevelSettings->nParentNumbering;
1964         if(aFmt.GetNumberingType() == SVX_NUM_CHAR_SPECIAL)
1965         {
1966             if( pLevelSettings->sBulletFont.getLength() &&
1967                 pLevelSettings->sBulletFont.compareTo(rActBulletFont.GetName()))
1968             {
1969                         //search for the font
1970                         if(!pList)
1971                         {
1972                                 SfxObjectShell* pCurDocShell = SfxObjectShell::Current();
1973                                 const SvxFontListItem* pFontListItem = (const SvxFontListItem* )pCurDocShell->GetItem( SID_ATTR_CHAR_FONTLIST );
1974                                 pList = pFontListItem ? pFontListItem->GetFontList() : 0;
1975                         }
1976                         if(pList && pList->IsAvailable( pLevelSettings->sBulletFont ) )
1977                         {
1978                     FontInfo aInfo = pList->Get(pLevelSettings->sBulletFont,WEIGHT_NORMAL, ITALIC_NONE);
1979                     Font aFont(aInfo);
1980                     aFmt.SetBulletFont(&aFont);
1981                         }
1982                         else
1983                         {
1984                          //if it cannot be found then create a new one
1985                          Font aCreateFont( pLevelSettings->sBulletFont,String(), Size( 0, 14 ) );
1986                          aCreateFont.SetCharSet( RTL_TEXTENCODING_DONTKNOW );
1987                          aCreateFont.SetFamily( FAMILY_DONTKNOW );
1988                          aCreateFont.SetPitch( PITCH_DONTKNOW );
1989                          aCreateFont.SetWeight( WEIGHT_DONTKNOW );
1990                          aCreateFont.SetTransparent( sal_True );
1991                          aFmt.SetBulletFont( &aCreateFont );
1992                         }
1993             }else
1994             aFmt.SetBulletFont( &rActBulletFont );
1995 
1996             sal_Unicode cChar = 0;
1997             if( pLevelSettings->sBulletChar.getLength() )
1998                 cChar = pLevelSettings->sBulletChar.getStr()[0];
1999             if( Application::GetSettings().GetLayoutRTL() )
2000             {
2001                             if( 0 == i && cChar == BulletsTypeMgr::aDynamicBulletTypes[5] )
2002                     cChar = BulletsTypeMgr::aDynamicRTLBulletTypes[5];
2003                 else if( 1 == i )
2004                 {
2005                     const SvxNumberFormat& numberFmt = aNum.GetLevel(0);
2006                     if( numberFmt.GetBulletChar() == BulletsTypeMgr::aDynamicRTLBulletTypes[5] )
2007                         cChar = BulletsTypeMgr::aDynamicRTLBulletTypes[4];
2008                 }
2009             }
2010 
2011             aFmt.SetBulletChar(cChar);
2012             aFmt.SetCharFmtName( sBulletCharFmtName );
2013             if (isResetSize) aFmt.SetBulletRelSize(45);
2014         }else if ((aFmt.GetNumberingType()&(~LINK_TOKEN)) == SVX_NUM_BITMAP ) {
2015             if (pLevelSettings->pBrushItem) {
2016                     const Graphic* pGrf = pLevelSettings->pBrushItem->GetGraphic();;
2017                     Size aSize = pLevelSettings->aSize;
2018                     sal_Int16 eOrient = text::VertOrientation::LINE_CENTER;
2019                     if (!isResetSize  && aFmt.GetGraphicSize()!=Size(0,0)) aSize=aFmt.GetGraphicSize();
2020                     else {
2021                         if (aSize.Width()==0 && aSize.Height()==0 && pGrf) {
2022                             aSize = SvxNumberFormat::GetGraphicSizeMM100( pGrf );
2023                         }
2024                     }
2025                     aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)GetMapUnit());
2026                     aFmt.SetGraphicBrush( pLevelSettings->pBrushItem, &aSize, &eOrient );
2027             }
2028         } else
2029         {
2030             aFmt.SetIncludeUpperLevels(sal::static_int_cast< sal_uInt8 >(0 != nUpperLevelOrChar ? aNum.GetLevelCount() : 0));
2031             aFmt.SetCharFmtName(sBulletCharFmtName);
2032                 if (isResetSize) aFmt.SetBulletRelSize(100);
2033         }
2034         if(pNumSettingsArr->Count() > i) {
2035             aFmt.SetLabelFollowedBy(pLevelSettings->eLabelFollowedBy);
2036             aFmt.SetListtabPos(pLevelSettings->nTabValue);
2037             aFmt.SetNumAdjust(pLevelSettings->eNumAlign);
2038             aFmt.SetFirstLineIndent(pLevelSettings->nNumAlignAt);
2039             aFmt.SetIndentAt(pLevelSettings->nNumIndentAt);
2040         }
2041         aFmt.SetPrefix(pLevelSettings->sPrefix);
2042         aFmt.SetSuffix(pLevelSettings->sSuffix);
2043         aNum.SetLevel(i, aFmt);
2044     }
2045 
2046     return sal_True;
2047 }
2048 String OutlineTypeMgr::GetDescription(sal_uInt16 nIndex,sal_Bool isDefault)
2049 {
2050     String sRet;
2051     sal_uInt16 nLength = 0;
2052     nLength = sizeof(pOutlineSettingsArrs)/sizeof(OutlineSettings_Impl*);
2053 
2054     if ( nIndex >= nLength )
2055         return sRet;
2056     else
2057     {
2058         OutlineSettings_Impl* pItemArr = pOutlineSettingsArrs[nIndex];
2059         if (isDefault) pItemArr = pDefaultOutlineSettingsArrs[nIndex];
2060         if ( pItemArr )
2061         {
2062             sRet = pItemArr->sDescription;
2063         };
2064     }
2065     return sRet;
2066 }
2067 sal_Bool OutlineTypeMgr::IsCustomized(sal_uInt16 nIndex)
2068 {
2069     sal_Bool bRet = sal_False;
2070 
2071     sal_uInt16 nLength = 0;
2072     nLength = sizeof(pOutlineSettingsArrs)/sizeof(OutlineSettings_Impl*);
2073 
2074     if ( nIndex >= nLength )
2075         return bRet;
2076     else
2077     {
2078         OutlineSettings_Impl* pItemArr = pOutlineSettingsArrs[nIndex];
2079         if ( pItemArr )
2080         {
2081             bRet = pItemArr->bIsCustomized;
2082         };
2083     }
2084 
2085     return bRet;
2086 }
2087 
2088 
2089 }}
2090