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