LCOV - code coverage report
Current view: top level - svx/source/sidebar - nbdtmg.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 1108 0.0 %
Date: 2014-04-14 Functions: 0 61 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10