LCOV - code coverage report
Current view: top level - svx/source/sidebar - nbdtmg.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 1087 0.1 %
Date: 2014-11-03 Functions: 2 61 3.3 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10