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

Generated by: LCOV version 1.11