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