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