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 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sw.hxx" 26 27 #define _SVSTDARR_USHORTS 28 29 #include <svl/smplhint.hxx> 30 #include <hintids.hxx> 31 #include <svl/itemiter.hxx> 32 #include <svl/eitem.hxx> 33 #include <unotools/syslocale.hxx> 34 #include <editeng/boxitem.hxx> 35 #include <editeng/numitem.hxx> 36 // --> OD 2008-02-13 #newlistlevelattrs# 37 #include <editeng/lrspitem.hxx> 38 // <-- 39 #include <fmtcol.hxx> 40 #include <uitool.hxx> 41 #include <swmodule.hxx> 42 #include <wrtsh.hxx> 43 #include <docsh.hxx> 44 #include <errhdl.hxx> 45 #include <frmfmt.hxx> 46 #include <charfmt.hxx> 47 #include <poolfmt.hxx> 48 #include <pagedesc.hxx> 49 #include <docstyle.hxx> 50 #include <docary.hxx> 51 #include <ccoll.hxx> 52 #include <doc.hxx> 53 #include <IDocumentUndoRedo.hxx> 54 #include <cmdid.h> 55 #include <swstyle.h> 56 #include <app.hrc> 57 #include <paratr.hxx> 58 #include <SwStyleNameMapper.hxx> 59 #include <svl/cjkoptions.hxx> 60 #include <comphelper/processfactory.hxx> 61 #include <unotools/localedatawrapper.hxx> 62 #include <unotools/intlwrapper.hxx> 63 #include <numrule.hxx> 64 #include <fmthdft.hxx> 65 #include <svx/svxids.hrc> 66 // --> OD 2008-02-12 #newlistlevelattrs# 67 #include <SwRewriter.hxx> 68 // <-- 69 70 // MD 06.02.95: Die Formatnamen in der Liste aller Namen haben als 71 // erstes Zeichen die Familie: 72 73 #define cCHAR (sal_Unicode)'c' 74 #define cPARA (sal_Unicode)'p' 75 #define cFRAME (sal_Unicode)'f' 76 #define cPAGE (sal_Unicode)'g' 77 #define cNUMRULE (sal_Unicode)'n' 78 79 // Dieses Zeichen wird bei der Herausgabe der Namen wieder entfernt und 80 // die Familie wird neu generiert. 81 82 // Ausserdem gibt es jetzt zusaetzlich das Bit bPhysical. Ist dieses Bit 83 // sal_True, werden die Pool-Formatnamen NICHT mit eingetragen. 84 85 class SwImplShellAction 86 { 87 SwWrtShell* pSh; 88 CurrShell* pCurrSh; 89 public: 90 SwImplShellAction( SwDoc& rDoc ); 91 ~SwImplShellAction(); 92 93 SwWrtShell* GetSh() { return pSh; } 94 }; 95 96 SwImplShellAction::SwImplShellAction( SwDoc& rDoc ) 97 : pCurrSh( 0 ) 98 { 99 if( rDoc.GetDocShell() ) 100 pSh = rDoc.GetDocShell()->GetWrtShell(); 101 else 102 pSh = 0; 103 104 if( pSh ) 105 { 106 pCurrSh = new CurrShell( pSh ); 107 pSh->StartAllAction(); 108 } 109 } 110 111 SwImplShellAction::~SwImplShellAction() 112 { 113 if( pCurrSh ) 114 { 115 pSh->EndAllAction(); 116 delete pCurrSh; 117 } 118 } 119 120 /*-------------------------------------------------------------------- 121 Beschreibung: SwCharFormate finden/anlegen 122 evtl. Style fuellen 123 --------------------------------------------------------------------*/ 124 125 SwCharFmt* lcl_FindCharFmt( SwDoc& rDoc, 126 const String& rName, 127 SwDocStyleSheet* pStyle = 0, 128 sal_Bool bCreate = sal_True ) 129 { 130 SwCharFmt* pFmt = 0; 131 if( rName.Len() ) 132 { 133 pFmt = rDoc.FindCharFmtByName( rName ); 134 if( !pFmt && rName == *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD - 135 RES_POOLCOLL_TEXT_BEGIN ] ) 136 { 137 // Standard-Zeichenvorlage 138 pFmt = (SwCharFmt*)rDoc.GetDfltCharFmt(); 139 } 140 141 if( !pFmt && bCreate ) 142 { // Pool abklappern 143 const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT); 144 if(nId != USHRT_MAX) 145 pFmt = rDoc.GetCharFmtFromPool(nId); 146 } 147 } 148 if(pStyle) 149 { 150 if(pFmt) 151 { 152 pStyle->SetPhysical(sal_True); 153 SwFmt* p = pFmt->DerivedFrom(); 154 if( p && !p->IsDefault() ) 155 pStyle->PresetParent( p->GetName() ); 156 else 157 pStyle->PresetParent( aEmptyStr ); 158 } 159 else 160 pStyle->SetPhysical(sal_False); 161 } 162 return pFmt; 163 } 164 165 166 /*-------------------------------------------------------------------- 167 Beschreibung: ParaFormate finden/erzeugen 168 Style fuellen 169 --------------------------------------------------------------------*/ 170 171 SwTxtFmtColl* lcl_FindParaFmt( SwDoc& rDoc, 172 const String& rName, 173 SwDocStyleSheet* pStyle = 0, 174 sal_Bool bCreate = sal_True ) 175 { 176 SwTxtFmtColl* pColl = 0; 177 178 if( rName.Len() ) 179 { 180 pColl = rDoc.FindTxtFmtCollByName( rName ); 181 if( !pColl && bCreate ) 182 { // Pool abklappern 183 const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL); 184 if(nId != USHRT_MAX) 185 pColl = rDoc.GetTxtCollFromPool(nId); 186 } 187 } 188 189 if(pStyle) 190 { 191 if(pColl) 192 { 193 pStyle->SetPhysical(sal_True); 194 if( pColl->DerivedFrom() && !pColl->DerivedFrom()->IsDefault() ) 195 pStyle->PresetParent( pColl->DerivedFrom()->GetName() ); 196 else 197 pStyle->PresetParent( aEmptyStr ); 198 199 SwTxtFmtColl& rNext = pColl->GetNextTxtFmtColl(); 200 pStyle->PresetFollow(rNext.GetName()); 201 } 202 else 203 pStyle->SetPhysical(sal_False); 204 } 205 return pColl; 206 } 207 208 209 /*-------------------------------------------------------------------- 210 Beschreibung: Rahmenformate 211 --------------------------------------------------------------------*/ 212 213 214 SwFrmFmt* lcl_FindFrmFmt( SwDoc& rDoc, 215 const String& rName, 216 SwDocStyleSheet* pStyle = 0, 217 sal_Bool bCreate = sal_True ) 218 { 219 SwFrmFmt* pFmt = 0; 220 if( rName.Len() ) 221 { 222 pFmt = rDoc.FindFrmFmtByName( rName ); 223 if( !pFmt && bCreate ) 224 { // Pool abklappern 225 const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT); 226 if(nId != USHRT_MAX) 227 pFmt = rDoc.GetFrmFmtFromPool(nId); 228 } 229 } 230 231 if(pStyle) 232 { 233 if(pFmt) 234 { 235 pStyle->SetPhysical(sal_True); 236 if( pFmt->DerivedFrom() && !pFmt->DerivedFrom()->IsDefault() ) 237 pStyle->PresetParent( pFmt->DerivedFrom()->GetName() ); 238 else 239 pStyle->PresetParent( aEmptyStr ); 240 } 241 else 242 pStyle->SetPhysical(sal_False); 243 } 244 return pFmt; 245 } 246 247 /*-------------------------------------------------------------------- 248 Beschreibung: Seitendescriptoren 249 --------------------------------------------------------------------*/ 250 251 252 const SwPageDesc* lcl_FindPageDesc( SwDoc& rDoc, 253 const String& rName, 254 SwDocStyleSheet* pStyle = 0, 255 sal_Bool bCreate = sal_True ) 256 { 257 const SwPageDesc* pDesc = 0; 258 259 if( rName.Len() ) 260 { 261 pDesc = rDoc.FindPageDescByName( rName ); 262 if( !pDesc && bCreate ) 263 { 264 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC); 265 if(nId != USHRT_MAX) 266 pDesc = rDoc.GetPageDescFromPool(nId); 267 } 268 } 269 270 if(pStyle) 271 { 272 if(pDesc) 273 { 274 pStyle->SetPhysical(sal_True); 275 if(pDesc->GetFollow()) 276 pStyle->PresetFollow(pDesc->GetFollow()->GetName()); 277 else 278 pStyle->PresetParent( aEmptyStr ); 279 } 280 else 281 pStyle->SetPhysical(sal_False); 282 } 283 return pDesc; 284 } 285 286 const SwNumRule* lcl_FindNumRule( SwDoc& rDoc, 287 const String& rName, 288 SwDocStyleSheet* pStyle = 0, 289 sal_Bool bCreate = sal_True ) 290 { 291 const SwNumRule* pRule = 0; 292 293 if( rName.Len() ) 294 { 295 pRule = rDoc.FindNumRulePtr( rName ); 296 if( !pRule && bCreate ) 297 { 298 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE); 299 if(nId != USHRT_MAX) 300 pRule = rDoc.GetNumRuleFromPool(nId); 301 } 302 } 303 304 if(pStyle) 305 { 306 if(pRule) 307 { 308 pStyle->SetPhysical(sal_True); 309 pStyle->PresetParent( aEmptyStr ); 310 } 311 else 312 pStyle->SetPhysical(sal_False); 313 } 314 return pRule; 315 } 316 317 318 sal_uInt16 lcl_FindName( const SwPoolFmtList& rLst, SfxStyleFamily eFam, 319 const String& rName ) 320 { 321 if( rLst.Count() ) 322 { 323 // suchen 324 String sSrch( ' ' ); 325 switch( eFam ) 326 { 327 case SFX_STYLE_FAMILY_CHAR: sSrch = cCHAR; break; 328 case SFX_STYLE_FAMILY_PARA: sSrch = cPARA; break; 329 case SFX_STYLE_FAMILY_FRAME: sSrch = cFRAME; break; 330 case SFX_STYLE_FAMILY_PAGE: sSrch = cPAGE; break; 331 case SFX_STYLE_FAMILY_PSEUDO: sSrch = cNUMRULE; break; 332 default:; //prevent warning 333 } 334 sSrch += rName; 335 for( sal_uInt16 i=0; i < rLst.Count(); ++i ) 336 if( *rLst[i] == sSrch ) 337 return i; 338 } 339 return USHRT_MAX; 340 } 341 342 sal_Bool FindPhyStyle( SwDoc& rDoc, const String& rName, SfxStyleFamily eFam ) 343 { 344 switch( eFam ) 345 { 346 case SFX_STYLE_FAMILY_CHAR : 347 return 0 != lcl_FindCharFmt( rDoc, rName, 0, sal_False ); 348 case SFX_STYLE_FAMILY_PARA : 349 return 0 != lcl_FindParaFmt( rDoc, rName, 0, sal_False ); 350 case SFX_STYLE_FAMILY_FRAME: 351 return 0 != lcl_FindFrmFmt( rDoc, rName, 0, sal_False ); 352 case SFX_STYLE_FAMILY_PAGE : 353 return 0 != lcl_FindPageDesc( rDoc, rName, 0, sal_False ); 354 case SFX_STYLE_FAMILY_PSEUDO: 355 return 0 != lcl_FindNumRule( rDoc, rName, 0, sal_False ); 356 default:; //prevent warning 357 } 358 return sal_False; 359 } 360 361 362 /*-------------------------------------------------------------------- 363 Beschreibung: Einfuegen von Strings in die Liste der Vorlagen 364 --------------------------------------------------------------------*/ 365 366 367 void SwPoolFmtList::Append( char cChar, const String& rStr ) 368 { 369 String* pStr = new String( cChar ); 370 *pStr += rStr; 371 for ( sal_uInt16 i=0; i < Count(); ++i ) 372 { 373 if( *operator[](i) == *pStr ) 374 { 375 delete pStr; 376 return; 377 } 378 } 379 Insert( pStr, Count() ); 380 } 381 382 /*-------------------------------------------------------------------- 383 Beschreibung: Liste kompletti loeschen 384 --------------------------------------------------------------------*/ 385 386 387 void SwPoolFmtList::Erase() 388 { 389 DeleteAndDestroy( 0, Count() ); 390 } 391 392 /* */ 393 394 /*-------------------------------------------------------------------- 395 Beschreibung: UI-seitige implementierung von StyleSheets 396 greift auf die Core-Engine zu 397 --------------------------------------------------------------------*/ 398 399 SwDocStyleSheet::SwDocStyleSheet( SwDoc& rDocument, 400 const String& rName, 401 SwDocStyleSheetPool& _rPool, 402 SfxStyleFamily eFam, 403 sal_uInt16 _nMask) : 404 405 SfxStyleSheetBase( rName, _rPool, eFam, _nMask ), 406 pCharFmt(0), 407 pColl(0), 408 pFrmFmt(0), 409 pDesc(0), 410 pNumRule(0), 411 412 rDoc(rDocument), 413 aCoreSet(GetPool().GetPool(), 414 RES_CHRATR_BEGIN, RES_CHRATR_END - 1, 415 RES_PARATR_BEGIN, RES_PARATR_END - 1, 416 // --> OD 2008-02-25 #refactorlists# 417 RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1, 418 // <-- 419 RES_FRMATR_BEGIN, RES_FRMATR_END - 1, 420 RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, 421 SID_ATTR_PAGE, SID_ATTR_PAGE_EXT1, 422 SID_ATTR_PAGE_HEADERSET,SID_ATTR_PAGE_FOOTERSET, 423 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 424 FN_PARAM_FTN_INFO, FN_PARAM_FTN_INFO, 425 SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL, 426 SID_ATTR_PARA_PAGENUM, SID_ATTR_PARA_PAGENUM, 427 SID_SWREGISTER_MODE, SID_SWREGISTER_MODE, 428 SID_SWREGISTER_COLLECTION, SID_SWREGISTER_COLLECTION, 429 FN_COND_COLL, FN_COND_COLL, 430 SID_ATTR_AUTO_STYLE_UPDATE, SID_ATTR_AUTO_STYLE_UPDATE, 431 SID_ATTR_NUMBERING_RULE, SID_ATTR_NUMBERING_RULE, 432 SID_PARA_BACKGRND_DESTINATION, SID_ATTR_BRUSH_CHAR, 433 SID_ATTR_NUMBERING_RULE, SID_ATTR_NUMBERING_RULE, 434 0), 435 bPhysical(sal_False) 436 { 437 nHelpId = UCHAR_MAX; 438 } 439 440 441 SwDocStyleSheet::SwDocStyleSheet( const SwDocStyleSheet& rOrg) : 442 SfxStyleSheetBase(rOrg), 443 pCharFmt(rOrg.pCharFmt), 444 pColl(rOrg.pColl), 445 pFrmFmt(rOrg.pFrmFmt), 446 pDesc(rOrg.pDesc), 447 pNumRule(rOrg.pNumRule), 448 rDoc(rOrg.rDoc), 449 aCoreSet(rOrg.aCoreSet), 450 bPhysical(rOrg.bPhysical) 451 { 452 } 453 454 455 SwDocStyleSheet::~SwDocStyleSheet() 456 { 457 } 458 459 /*-------------------------------------------------------------------- 460 Beschreibung: Zuruecksetzen 461 --------------------------------------------------------------------*/ 462 463 464 void SwDocStyleSheet::Reset() 465 { 466 aName.Erase(); 467 aFollow.Erase(); 468 aParent.Erase(); 469 SetPhysical(sal_False); 470 } 471 472 /*-------------------------------------------------------------------- 473 Beschreibung: virtuelle Methoden 474 --------------------------------------------------------------------*/ 475 476 477 const String& SwDocStyleSheet::GetParent() const 478 { 479 if( !bPhysical ) 480 { 481 // dann pruefe, ob schon im Doc vorhanden 482 SwFmt* pFmt = 0; 483 SwGetPoolIdFromName eGetType; 484 switch(nFamily) 485 { 486 case SFX_STYLE_FAMILY_CHAR: 487 pFmt = rDoc.FindCharFmtByName( aName ); 488 eGetType = nsSwGetPoolIdFromName::GET_POOLID_CHRFMT; 489 break; 490 491 case SFX_STYLE_FAMILY_PARA: 492 pFmt = rDoc.FindTxtFmtCollByName( aName ); 493 eGetType = nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL; 494 break; 495 496 case SFX_STYLE_FAMILY_FRAME: 497 pFmt = rDoc.FindFrmFmtByName( aName ); 498 eGetType = nsSwGetPoolIdFromName::GET_POOLID_FRMFMT; 499 break; 500 501 case SFX_STYLE_FAMILY_PAGE: 502 case SFX_STYLE_FAMILY_PSEUDO: 503 default: 504 return aEmptyStr; // es gibt keinen Parent 505 } 506 507 String sTmp; 508 if( !pFmt ) // noch nicht vorhanden, also dflt. Parent 509 { 510 sal_uInt16 i = SwStyleNameMapper::GetPoolIdFromUIName( aName, eGetType ); 511 i = ::GetPoolParent( i ); 512 if( i && USHRT_MAX != i ) 513 SwStyleNameMapper::FillUIName( i, sTmp ); 514 } 515 else 516 { 517 SwFmt* p = pFmt->DerivedFrom(); 518 if( p && !p->IsDefault() ) 519 sTmp = p->GetName(); 520 } 521 SwDocStyleSheet* pThis = (SwDocStyleSheet*)this; 522 pThis->aParent = sTmp; 523 } 524 return aParent; 525 } 526 527 /*-------------------------------------------------------------------- 528 Beschreibung: Nachfolger 529 --------------------------------------------------------------------*/ 530 531 532 const String& SwDocStyleSheet::GetFollow() const 533 { 534 if( !bPhysical ) 535 { 536 SwDocStyleSheet* pThis = (SwDocStyleSheet*)this; 537 pThis->FillStyleSheet( FillAllInfo ); 538 } 539 return aFollow; 540 } 541 542 /*-------------------------------------------------------------------- 543 Beschreibung: Welche Verkettung ist moeglich 544 --------------------------------------------------------------------*/ 545 546 547 sal_Bool SwDocStyleSheet::HasFollowSupport() const 548 { 549 switch(nFamily) 550 { 551 case SFX_STYLE_FAMILY_PARA : 552 case SFX_STYLE_FAMILY_PAGE : return sal_True; 553 case SFX_STYLE_FAMILY_FRAME: 554 case SFX_STYLE_FAMILY_CHAR : 555 case SFX_STYLE_FAMILY_PSEUDO: return sal_False; 556 default: 557 ASSERT(!this, "unbekannte Style-Familie"); 558 } 559 return sal_False; 560 } 561 562 /*-------------------------------------------------------------------- 563 Beschreibung: Parent ? 564 --------------------------------------------------------------------*/ 565 566 567 sal_Bool SwDocStyleSheet::HasParentSupport() const 568 { 569 sal_Bool bRet = sal_False; 570 switch(nFamily) 571 { 572 case SFX_STYLE_FAMILY_CHAR : 573 case SFX_STYLE_FAMILY_PARA : 574 case SFX_STYLE_FAMILY_FRAME: bRet = sal_True; 575 default:; //prevent warning 576 } 577 return bRet; 578 } 579 580 581 sal_Bool SwDocStyleSheet::HasClearParentSupport() const 582 { 583 sal_Bool bRet = sal_False; 584 switch(nFamily) 585 { 586 case SFX_STYLE_FAMILY_PARA : 587 case SFX_STYLE_FAMILY_CHAR : 588 case SFX_STYLE_FAMILY_FRAME: bRet = sal_True; 589 default:; //prevent warning 590 } 591 return bRet; 592 } 593 594 /*-------------------------------------------------------------------- 595 Beschreibung: textuelle Beschreibung ermitteln 596 --------------------------------------------------------------------*/ 597 String SwDocStyleSheet::GetDescription(SfxMapUnit eUnit) 598 { 599 IntlWrapper aIntlWrapper( 600 ::comphelper::getProcessServiceFactory(), 601 SvtSysLocale().GetLocaleData().getLocale()); 602 603 String sPlus(String::CreateFromAscii(" + ")); 604 if ( SFX_STYLE_FAMILY_PAGE == nFamily ) 605 { 606 if( !pSet ) 607 GetItemSet(); 608 609 SfxItemIter aIter( *pSet ); 610 String aDesc; 611 const SfxPoolItem* pItem = aIter.FirstItem(); 612 613 while ( pItem ) 614 { 615 if(!IsInvalidItem(pItem)) 616 switch ( pItem->Which() ) 617 { 618 case RES_LR_SPACE: 619 case SID_ATTR_PAGE_SIZE: 620 case SID_ATTR_PAGE_MAXSIZE: 621 case SID_ATTR_PAGE_PAPERBIN: 622 case SID_ATTR_PAGE_APP: 623 case SID_ATTR_BORDER_INNER: 624 break; 625 default: 626 { 627 String aItemPresentation; 628 if ( !IsInvalidItem( pItem ) && 629 rPool.GetPool().GetPresentation( 630 *pItem, SFX_ITEM_PRESENTATION_COMPLETE, 631 eUnit, aItemPresentation, &aIntlWrapper ) ) 632 { 633 if ( aDesc.Len() && aItemPresentation.Len() ) 634 aDesc += sPlus; 635 aDesc += aItemPresentation; 636 } 637 } 638 } 639 pItem = aIter.NextItem(); 640 } 641 return aDesc; 642 } 643 else if ( SFX_STYLE_FAMILY_FRAME == nFamily || 644 SFX_STYLE_FAMILY_PARA == nFamily) 645 { 646 if( !pSet ) 647 GetItemSet(); 648 649 SfxItemIter aIter( *pSet ); 650 String aDesc; 651 const SfxPoolItem* pItem = aIter.FirstItem(); 652 653 String sPageNum, sModel, sBreak; 654 sal_Bool bHasWesternFontPrefix = sal_False; 655 sal_Bool bHasCJKFontPrefix = sal_False; 656 SvtCJKOptions aCJKOptions; 657 658 while ( pItem ) 659 { 660 if(!IsInvalidItem(pItem)) 661 switch ( pItem->Which() ) 662 { 663 case SID_ATTR_AUTO_STYLE_UPDATE: 664 case SID_PARA_BACKGRND_DESTINATION: 665 case RES_PAGEDESC: 666 //CTL no yet supported 667 case RES_CHRATR_CTL_FONT: 668 case RES_CHRATR_CTL_FONTSIZE: 669 case RES_CHRATR_CTL_LANGUAGE: 670 case RES_CHRATR_CTL_POSTURE: 671 case RES_CHRATR_CTL_WEIGHT: 672 break; 673 default: 674 { 675 String aItemPresentation; 676 if ( !IsInvalidItem( pItem ) && 677 rPool.GetPool().GetPresentation( 678 *pItem, SFX_ITEM_PRESENTATION_COMPLETE, 679 eUnit, aItemPresentation, &aIntlWrapper ) ) 680 { 681 sal_Bool bIsDefault = sal_False; 682 switch ( pItem->Which() ) 683 { 684 case SID_ATTR_PARA_PAGENUM: 685 sPageNum = aItemPresentation; 686 break; 687 case SID_ATTR_PARA_MODEL: 688 sModel = aItemPresentation; 689 break; 690 case RES_BREAK: 691 sBreak = aItemPresentation; 692 break; 693 case RES_CHRATR_CJK_FONT: 694 case RES_CHRATR_CJK_FONTSIZE: 695 case RES_CHRATR_CJK_LANGUAGE: 696 case RES_CHRATR_CJK_POSTURE: 697 case RES_CHRATR_CJK_WEIGHT: 698 if(aCJKOptions.IsCJKFontEnabled()) 699 bIsDefault = sal_True; 700 if(!bHasCJKFontPrefix) 701 { 702 aItemPresentation.Insert(SW_RESSTR(STR_CJK_FONT), 0); 703 bHasCJKFontPrefix = sal_True; 704 } 705 break; 706 case RES_CHRATR_FONT: 707 case RES_CHRATR_FONTSIZE: 708 case RES_CHRATR_LANGUAGE: 709 case RES_CHRATR_POSTURE: 710 case RES_CHRATR_WEIGHT: 711 if(!bHasWesternFontPrefix) 712 { 713 aItemPresentation.Insert(SW_RESSTR(STR_WESTERN_FONT), 0); 714 bHasWesternFontPrefix = sal_True; 715 bIsDefault = sal_True; 716 } 717 // no break; 718 default: 719 bIsDefault = sal_True; 720 } 721 if(bIsDefault) 722 { 723 if ( aDesc.Len() && aItemPresentation.Len() ) 724 aDesc += sPlus; 725 aDesc += aItemPresentation; 726 } 727 } 728 } 729 } 730 pItem = aIter.NextItem(); 731 } 732 //Sonderbehandlung fuer Umburch, Seitenvorlage und Seitenoffset 733 if(sBreak.Len() && !sModel.Len()) // wemm Model. dann ist Break ungueltig 734 { 735 if(aDesc.Len()) 736 aDesc += sPlus; 737 aDesc += sBreak; 738 } 739 if(sModel.Len()) 740 { 741 if(aDesc.Len()) 742 aDesc += sPlus; 743 aDesc += SW_RESSTR(STR_PAGEBREAK); 744 aDesc += sPlus; 745 aDesc += sModel; 746 if(sPageNum != String(UniString::CreateFromInt32(0))) 747 { 748 aDesc += sPlus; 749 aDesc += SW_RESSTR(STR_PAGEOFFSET); 750 aDesc += sPageNum; 751 } 752 } 753 return aDesc; 754 } 755 else if( SFX_STYLE_FAMILY_PSEUDO == nFamily ) 756 { 757 // if( pNumRule ) 758 // return pNumRule->GetName(); 759 //os: was sollte man bei Numerierungen schon anzeigen? 760 return aEmptyStr; 761 } 762 763 return SfxStyleSheetBase::GetDescription(eUnit); 764 } 765 766 767 String SwDocStyleSheet::GetDescription() 768 { 769 return GetDescription(SFX_MAPUNIT_CM); 770 } 771 772 /*-------------------------------------------------------------------- 773 Beschreibung: Namen setzen 774 --------------------------------------------------------------------*/ 775 776 777 sal_Bool SwDocStyleSheet::SetName( const String& rStr) 778 { 779 if( !rStr.Len() ) 780 return sal_False; 781 782 if( aName != rStr ) 783 { 784 if( !SfxStyleSheetBase::SetName( rStr )) 785 return sal_False; 786 } 787 else if(!bPhysical) 788 FillStyleSheet( FillPhysical ); 789 790 int bChg = sal_False; 791 switch(nFamily) 792 { 793 case SFX_STYLE_FAMILY_CHAR : 794 { 795 ASSERT(pCharFmt, "SwCharFormat fehlt!"); 796 if( pCharFmt && pCharFmt->GetName() != rStr ) 797 { 798 pCharFmt->SetName( rStr ); 799 bChg = sal_True; 800 } 801 break; 802 } 803 case SFX_STYLE_FAMILY_PARA : 804 { 805 ASSERT(pColl, "Collektion fehlt!"); 806 if( pColl && pColl->GetName() != rStr ) 807 { 808 if (pColl->GetName().Len() > 0) 809 rDoc.RenameFmt(*pColl, rStr); 810 else 811 pColl->SetName(rStr); 812 813 bChg = sal_True; 814 } 815 break; 816 } 817 case SFX_STYLE_FAMILY_FRAME: 818 { 819 ASSERT(pFrmFmt, "FrmFmt fehlt!"); 820 if( pFrmFmt && pFrmFmt->GetName() != rStr ) 821 { 822 if (pFrmFmt->GetName().Len() > 0) 823 rDoc.RenameFmt(*pFrmFmt, rStr); 824 else 825 pFrmFmt->SetName( rStr ); 826 827 bChg = sal_True; 828 } 829 break; 830 } 831 case SFX_STYLE_FAMILY_PAGE : 832 ASSERT(pDesc, "PageDesc fehlt!"); 833 if( pDesc && pDesc->GetName() != rStr ) 834 { 835 //PageDesc setzen - mit vorherigem kopieren - ist fuer das 836 //setzen des Namens wohl nicht notwendig. Deshalb erlauben 837 //wir hier mal einen cast. 838 // -> #116530# 839 SwPageDesc aPageDesc(*((SwPageDesc*)pDesc)); 840 String aOldName(aPageDesc.GetName()); 841 842 aPageDesc.SetName( rStr ); 843 bool const bDoesUndo = rDoc.GetIDocumentUndoRedo().DoesUndo(); 844 845 rDoc.GetIDocumentUndoRedo().DoUndo(aOldName.Len() > 0); 846 rDoc.ChgPageDesc(aOldName, aPageDesc); 847 rDoc.GetIDocumentUndoRedo().DoUndo(bDoesUndo); 848 // <- #116530# 849 850 rDoc.SetModified(); 851 bChg = sal_True; 852 } 853 break; 854 case SFX_STYLE_FAMILY_PSEUDO: 855 ASSERT(pNumRule, "NumRule fehlt!"); 856 857 // -> #106897# 858 if (pNumRule) 859 { 860 String aOldName = pNumRule->GetName(); 861 862 if (aOldName.Len() > 0) 863 { 864 if ( aOldName != rStr && 865 rDoc.RenameNumRule(aOldName, rStr)) 866 { 867 pNumRule = rDoc.FindNumRulePtr(rStr); 868 rDoc.SetModified(); 869 870 bChg = sal_True; 871 } 872 } 873 else 874 { 875 // --> OD 2008-07-08 #i91400# 876 ((SwNumRule*)pNumRule)->SetName( rStr, rDoc ); 877 // <-- 878 rDoc.SetModified(); 879 880 bChg = sal_True; 881 } 882 } 883 // <- #106897# 884 885 break; 886 887 default: 888 ASSERT(!this, "unbekannte Style-Familie"); 889 } 890 891 if( bChg ) 892 { 893 rPool.First(); // interne Liste muss geupdatet werden 894 rPool.Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, *this ) ); 895 SwEditShell* pSh = rDoc.GetEditShell(); 896 if( pSh ) 897 pSh->CallChgLnk(); 898 } 899 return sal_True; 900 } 901 902 /*-------------------------------------------------------------------- 903 Beschreibung: Ableitungshirachie 904 --------------------------------------------------------------------*/ 905 906 907 sal_Bool SwDocStyleSheet::SetParent( const String& rStr) 908 { 909 SwFmt* pFmt = 0, *pParent = 0; 910 switch(nFamily) 911 { 912 case SFX_STYLE_FAMILY_CHAR : 913 ASSERT( pCharFmt, "SwCharFormat fehlt!" ) 914 if( 0 != ( pFmt = pCharFmt ) && rStr.Len() ) 915 pParent = lcl_FindCharFmt(rDoc, rStr); 916 break; 917 918 case SFX_STYLE_FAMILY_PARA : 919 ASSERT( pColl, "Collektion fehlt!") 920 if( 0 != ( pFmt = pColl ) && rStr.Len() ) 921 pParent = lcl_FindParaFmt( rDoc, rStr ); 922 break; 923 924 case SFX_STYLE_FAMILY_FRAME: 925 ASSERT(pFrmFmt, "FrameFormat fehlt!"); 926 if( 0 != ( pFmt = pFrmFmt ) && rStr.Len() ) 927 pParent = lcl_FindFrmFmt( rDoc, rStr ); 928 break; 929 930 case SFX_STYLE_FAMILY_PAGE: 931 case SFX_STYLE_FAMILY_PSEUDO: 932 break; 933 default: 934 ASSERT(!this, "unbekannte Style-Familie"); 935 } 936 937 sal_Bool bRet = sal_False; 938 if( pFmt && pFmt->DerivedFrom() && 939 pFmt->DerivedFrom()->GetName() != rStr ) 940 { 941 { 942 SwImplShellAction aTmp( rDoc ); 943 bRet = pFmt->SetDerivedFrom( pParent ); 944 } 945 946 if( bRet ) 947 { 948 aParent = rStr; 949 rPool.Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, 950 *this ) ); 951 } 952 } 953 954 return bRet; 955 } 956 957 /*-------------------------------------------------------------------- 958 Beschreibung: Nachfolger detzen 959 --------------------------------------------------------------------*/ 960 961 962 sal_Bool SwDocStyleSheet::SetFollow( const String& rStr) 963 { 964 if( rStr.Len() && !SfxStyleSheetBase::SetFollow( rStr )) 965 return sal_False; 966 967 SwImplShellAction aTmpSh( rDoc ); 968 switch(nFamily) 969 { 970 case SFX_STYLE_FAMILY_PARA : 971 { 972 ASSERT(pColl, "Collection fehlt!"); 973 if( pColl ) 974 { 975 SwTxtFmtColl* pFollow = pColl; 976 if( rStr.Len() && 0 == (pFollow = lcl_FindParaFmt(rDoc, rStr) )) 977 pFollow = pColl; 978 979 pColl->SetNextTxtFmtColl(*pFollow); 980 } 981 break; 982 } 983 case SFX_STYLE_FAMILY_PAGE : 984 { 985 ASSERT(pDesc, "PageDesc fehlt!"); 986 if( pDesc ) 987 { 988 const SwPageDesc* pFollowDesc = rStr.Len() 989 ? lcl_FindPageDesc(rDoc, rStr) 990 : 0; 991 sal_uInt16 nId; 992 if( pFollowDesc != pDesc->GetFollow() && 993 rDoc.FindPageDescByName( pDesc->GetName(), &nId ) ) 994 { 995 SwPageDesc aDesc( *pDesc ); 996 aDesc.SetFollow( pFollowDesc ); 997 rDoc.ChgPageDesc( nId, aDesc ); 998 pDesc = &const_cast<const SwDoc &>(rDoc).GetPageDesc( nId ); 999 } 1000 } 1001 break; 1002 } 1003 case SFX_STYLE_FAMILY_CHAR: 1004 case SFX_STYLE_FAMILY_FRAME: 1005 case SFX_STYLE_FAMILY_PSEUDO: 1006 break; 1007 default: 1008 ASSERT(!this, "unbekannte Style-Familie"); 1009 } 1010 1011 return sal_True; 1012 } 1013 1014 /*-------------------------------------------------------------------- 1015 Beschreibung: ueber Name und Family, Mask den ItemSet rausholen 1016 --------------------------------------------------------------------*/ 1017 1018 SfxItemSet& SwDocStyleSheet::GetItemSet() 1019 { 1020 if(!bPhysical) 1021 FillStyleSheet( FillPhysical ); 1022 1023 switch(nFamily) 1024 { 1025 case SFX_STYLE_FAMILY_CHAR: 1026 { 1027 ASSERT(pCharFmt, "Wo ist das SwCharFmt"); 1028 aCoreSet.Put(pCharFmt->GetAttrSet()); 1029 if(pCharFmt->DerivedFrom()) 1030 aCoreSet.SetParent(&pCharFmt->DerivedFrom()->GetAttrSet()); 1031 } 1032 break; 1033 case SFX_STYLE_FAMILY_PARA : 1034 case SFX_STYLE_FAMILY_FRAME: 1035 { 1036 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER ); 1037 aBoxInfo.SetTable( sal_False ); 1038 aBoxInfo.SetDist( sal_True); // Abstandsfeld immer anzeigen 1039 aBoxInfo.SetMinDist( sal_True );// Minimalgroesse in Tabellen und Absaetzen setzen 1040 aBoxInfo.SetDefDist( MIN_BORDER_DIST );// Default-Abstand immer setzen 1041 // Einzelne Linien koennen nur in Tabellen DontCare-Status haben 1042 aBoxInfo.SetValid( VALID_DISABLE, sal_True ); 1043 if ( nFamily == SFX_STYLE_FAMILY_PARA ) 1044 { 1045 ASSERT(pColl, "Wo ist die Collektion"); 1046 aCoreSet.Put(pColl->GetAttrSet()); 1047 aCoreSet.Put( aBoxInfo ); 1048 aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, pColl->IsAutoUpdateFmt())); 1049 if(pColl->DerivedFrom()) 1050 aCoreSet.SetParent(&pColl->DerivedFrom()->GetAttrSet()); 1051 } 1052 else 1053 { 1054 ASSERT(pFrmFmt, "Wo ist das FrmFmt"); 1055 aCoreSet.Put(pFrmFmt->GetAttrSet()); 1056 aCoreSet.Put( aBoxInfo ); 1057 aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, pFrmFmt->IsAutoUpdateFmt())); 1058 if(pFrmFmt->DerivedFrom()) 1059 aCoreSet.SetParent(&pFrmFmt->DerivedFrom()->GetAttrSet()); 1060 } 1061 } 1062 break; 1063 1064 case SFX_STYLE_FAMILY_PAGE : 1065 { 1066 ASSERT(pDesc, "Kein PageDescriptor"); 1067 ::PageDescToItemSet(*((SwPageDesc*)pDesc), aCoreSet); 1068 } 1069 break; 1070 1071 case SFX_STYLE_FAMILY_PSEUDO: 1072 { 1073 ASSERT(pNumRule, "Keine NumRule"); 1074 SvxNumRule aRule = pNumRule->MakeSvxNumRule(); 1075 aCoreSet.Put(SvxNumBulletItem(aRule)); 1076 } 1077 break; 1078 1079 default: 1080 ASSERT(!this, "unbekannte Style-Familie"); 1081 } 1082 // Member der Basisklasse 1083 pSet = &aCoreSet; 1084 1085 return aCoreSet; 1086 } 1087 1088 // --> OD 2008-02-13 #newlistlevelattrs# 1089 void SwDocStyleSheet::MergeIndentAttrsOfListStyle( SfxItemSet& rSet ) 1090 { 1091 if ( nFamily != SFX_STYLE_FAMILY_PARA ) 1092 { 1093 return; 1094 } 1095 1096 ASSERT( pColl, "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - missing paragraph style"); 1097 if ( pColl->AreListLevelIndentsApplicable() ) 1098 { 1099 ASSERT( pColl->GetItemState( RES_PARATR_NUMRULE ) == SFX_ITEM_SET, 1100 "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - list level indents are applicable at paragraph style, but no list style found. Serious defect -> please inform OD." ); 1101 const String sNumRule = pColl->GetNumRule().GetValue(); 1102 if( sNumRule.Len() ) 1103 { 1104 const SwNumRule* pRule = rDoc.FindNumRulePtr( sNumRule ); 1105 if( pRule ) 1106 { 1107 const SwNumFmt& rFmt = pRule->Get( 0 ); 1108 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) 1109 { 1110 SvxLRSpaceItem aLR( RES_LR_SPACE ); 1111 aLR.SetTxtLeft( rFmt.GetIndentAt() ); 1112 aLR.SetTxtFirstLineOfst( static_cast<short>(rFmt.GetFirstLineIndent()) ); 1113 rSet.Put( aLR ); 1114 } 1115 } 1116 } 1117 } 1118 } 1119 // <-- 1120 1121 /*-------------------------------------------------------------------- 1122 Beschreibung: ItemSet setzen 1123 --------------------------------------------------------------------*/ 1124 1125 // --> OD 2008-02-12 #newlistlevelattrs# 1126 // handling of parameter <bResetIndentAttrsAtParagraphStyle> 1127 void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet, 1128 const bool bResetIndentAttrsAtParagraphStyle ) 1129 { 1130 // gegebenenfalls Format erst ermitteln 1131 if(!bPhysical) 1132 FillStyleSheet( FillPhysical ); 1133 1134 SwImplShellAction aTmpSh( rDoc ); 1135 1136 ASSERT( &rSet != &aCoreSet, "SetItemSet mit eigenem Set ist nicht erlaubt" ); 1137 1138 // --> OD 2008-02-12 #newlistlevelattrs# 1139 if (rDoc.GetIDocumentUndoRedo().DoesUndo()) 1140 { 1141 SwRewriter aRewriter; 1142 aRewriter.AddRule( UNDO_ARG1, GetName() ); 1143 rDoc.GetIDocumentUndoRedo().StartUndo( UNDO_INSFMTATTR, &aRewriter ); 1144 } 1145 // <-- 1146 1147 SwFmt* pFmt = 0; 1148 SwPageDesc* pNewDsc = 0; 1149 sal_uInt16 nPgDscPos = 0; 1150 1151 switch(nFamily) 1152 { 1153 case SFX_STYLE_FAMILY_CHAR : 1154 { 1155 ASSERT(pCharFmt, "Wo ist das CharFormat"); 1156 pFmt = pCharFmt; 1157 } 1158 break; 1159 1160 case SFX_STYLE_FAMILY_PARA : 1161 { 1162 ASSERT(pColl, "Wo ist die Collection"); 1163 const SfxPoolItem* pAutoUpdate; 1164 if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_AUTO_STYLE_UPDATE,sal_False, &pAutoUpdate )) 1165 { 1166 pColl->SetAutoUpdateFmt(((const SfxBoolItem*)pAutoUpdate)->GetValue()); 1167 } 1168 1169 const SwCondCollItem* pCondItem; 1170 if( SFX_ITEM_SET != rSet.GetItemState( FN_COND_COLL, sal_False, 1171 (const SfxPoolItem**)&pCondItem )) 1172 pCondItem = 0; 1173 1174 if( RES_CONDTXTFMTCOLL == pColl->Which() && pCondItem ) 1175 { 1176 SwFmt* pFindFmt; 1177 const CommandStruct* pCmds = SwCondCollItem::GetCmds(); 1178 for(sal_uInt16 i = 0; i < COND_COMMAND_COUNT; i++) 1179 { 1180 SwCollCondition aCond( 0, pCmds[ i ].nCnd, pCmds[ i ].nSubCond ); 1181 ((SwConditionTxtFmtColl*)pColl)->RemoveCondition( aCond ); 1182 const String& rStyle = pCondItem->GetStyle( i ); 1183 if( rStyle.Len() && 1184 0 != ( pFindFmt = lcl_FindParaFmt( rDoc, rStyle, 0, sal_True ))) 1185 { 1186 aCond.RegisterToFormat( *pFindFmt ); 1187 ((SwConditionTxtFmtColl*)pColl)->InsertCondition( aCond ); 1188 } 1189 } 1190 1191 // Document auf die neue Bedingungen updaten 1192 SwCondCollCondChg aMsg( pColl ); 1193 pColl->ModifyNotification( &aMsg, &aMsg ); 1194 } 1195 else if( pCondItem && !pColl->GetDepends() ) 1196 { 1197 // keine bedingte Vorlage, dann erstmal erzeugen und 1198 // alle wichtigen Werte uebernehmen 1199 SwConditionTxtFmtColl* pCColl = rDoc.MakeCondTxtFmtColl( 1200 pColl->GetName(), (SwTxtFmtColl*)pColl->DerivedFrom() ); 1201 if( pColl != &pColl->GetNextTxtFmtColl() ) 1202 pCColl->SetNextTxtFmtColl( pColl->GetNextTxtFmtColl() ); 1203 1204 //pCColl->SetOutlineLevel( pColl->GetOutlineLevel() );//#outline level,zhaojianwei 1205 if( pColl->IsAssignedToListLevelOfOutlineStyle()) 1206 pCColl->AssignToListLevelOfOutlineStyle(pColl->GetAssignedOutlineStyleLevel()); 1207 else 1208 pCColl->DeleteAssignmentToListLevelOfOutlineStyle();//<--end,zhaojianwei 1209 1210 1211 1212 SwTxtFmtColl* pFindFmt; 1213 const CommandStruct* pCmds = SwCondCollItem::GetCmds(); 1214 for( sal_uInt16 i = 0; i < COND_COMMAND_COUNT; ++i ) 1215 { 1216 const String& rStyle = pCondItem->GetStyle( i ); 1217 if( rStyle.Len() && 1218 0 != ( pFindFmt = lcl_FindParaFmt( rDoc, rStyle, 0, sal_True ))) 1219 { 1220 pCColl->InsertCondition( SwCollCondition( pFindFmt, 1221 pCmds[ i ].nCnd, pCmds[ i ].nSubCond ) ); 1222 } 1223 } 1224 1225 rDoc.DelTxtFmtColl( pColl ); 1226 pColl = pCColl; 1227 } 1228 // --> OD 2008-02-12 #newlistlevelattrs# 1229 if ( bResetIndentAttrsAtParagraphStyle && 1230 rSet.GetItemState( RES_PARATR_NUMRULE, sal_False, 0 ) == SFX_ITEM_SET && 1231 rSet.GetItemState( RES_LR_SPACE, sal_False, 0 ) != SFX_ITEM_SET && 1232 pColl->GetItemState( RES_LR_SPACE, sal_False, 0 ) == SFX_ITEM_SET ) 1233 { 1234 rDoc.ResetAttrAtFormat( RES_LR_SPACE, *pColl ); 1235 } 1236 // <-- 1237 1238 // #i56252: If a standard numbering style is assigned to a standard paragraph style 1239 // we have to create a physical instance of the numbering style. If we do not and 1240 // neither the paragraph style nor the numbering style is used in the document 1241 // the numbering style will not be saved with the document and the assignment got lost. 1242 const SfxPoolItem* pNumRuleItem = 0; 1243 if( SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_NUMRULE, sal_False, &pNumRuleItem ) ) 1244 { // Setting a numbering rule? 1245 String sNumRule = ((SwNumRuleItem*)pNumRuleItem)->GetValue(); 1246 if( sNumRule.Len() ) 1247 { 1248 SwNumRule* pRule = rDoc.FindNumRulePtr( sNumRule ); 1249 if( !pRule ) 1250 { // Numbering rule not in use yet. 1251 sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( sNumRule, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE ); 1252 if( USHRT_MAX != nPoolId ) // It's a standard numbering rule 1253 { 1254 pRule = rDoc.GetNumRuleFromPool( nPoolId ); // Create numbering rule (physical) 1255 } 1256 } 1257 } 1258 } 1259 1260 pFmt = pColl; 1261 1262 sal_uInt16 nId = pColl->GetPoolFmtId() & 1263 ~ ( COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID ); 1264 switch( GetMask() & ( 0x0fff & ~SWSTYLEBIT_CONDCOLL ) ) 1265 { 1266 case SWSTYLEBIT_TEXT: 1267 nId |= COLL_TEXT_BITS; 1268 break; 1269 case SWSTYLEBIT_CHAPTER: 1270 nId |= COLL_DOC_BITS; 1271 break; 1272 case SWSTYLEBIT_LIST: 1273 nId |= COLL_LISTS_BITS; 1274 break; 1275 case SWSTYLEBIT_IDX: 1276 nId |= COLL_REGISTER_BITS; 1277 break; 1278 case SWSTYLEBIT_EXTRA: 1279 nId |= COLL_EXTRA_BITS; 1280 break; 1281 case SWSTYLEBIT_HTML: 1282 nId |= COLL_HTML_BITS; 1283 break; 1284 } 1285 pColl->SetPoolFmtId( nId ); 1286 break; 1287 } 1288 case SFX_STYLE_FAMILY_FRAME: 1289 { 1290 ASSERT(pFrmFmt, "Wo ist das FrmFmt"); 1291 const SfxPoolItem* pAutoUpdate; 1292 if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_AUTO_STYLE_UPDATE,sal_False, &pAutoUpdate )) 1293 { 1294 pFrmFmt->SetAutoUpdateFmt(((const SfxBoolItem*)pAutoUpdate)->GetValue()); 1295 } 1296 pFmt = pFrmFmt; 1297 } 1298 break; 1299 1300 case SFX_STYLE_FAMILY_PAGE : 1301 { 1302 ASSERT(pDesc, "Wo ist der PageDescriptor"); 1303 1304 if( rDoc.FindPageDescByName( pDesc->GetName(), &nPgDscPos )) 1305 { 1306 pNewDsc = new SwPageDesc( *pDesc ); 1307 // --> OD 2005-05-09 #i48949# - no undo actions for the 1308 // copy of the page style 1309 ::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo()); 1310 rDoc.CopyPageDesc(*pDesc, *pNewDsc); // #i7983# 1311 // <-- 1312 1313 pFmt = &pNewDsc->GetMaster(); 1314 } 1315 } 1316 break; 1317 1318 case SFX_STYLE_FAMILY_PSEUDO: 1319 { 1320 ASSERT(pNumRule, "Wo ist die NumRule"); 1321 1322 if (!pNumRule) 1323 break; 1324 1325 const SfxPoolItem* pItem; 1326 switch( rSet.GetItemState( SID_ATTR_NUMBERING_RULE, sal_False, &pItem )) 1327 { 1328 case SFX_ITEM_SET: 1329 { 1330 SvxNumRule* pSetRule = ((SvxNumBulletItem*)pItem)->GetNumRule(); 1331 pSetRule->UnLinkGraphics(); 1332 //SwNumRule aSetRule(rDoc.GetUniqueNumRuleName()); 1333 SwNumRule aSetRule(*pNumRule); 1334 aSetRule.SetSvxRule(*pSetRule, &rDoc); 1335 rDoc.ChgNumRuleFmts( aSetRule ); 1336 } 1337 break; 1338 case SFX_ITEM_DONTCARE: 1339 // NumRule auf default Werte 1340 // was sind die default Werte? 1341 { 1342 // --> OD 2008-02-11 #newlistlevelattrs# 1343 SwNumRule aRule( pNumRule->GetName(), 1344 // --> OD 2008-06-06 #i89178# 1345 numfunc::GetDefaultPositionAndSpaceMode() ); 1346 // <-- 1347 // <-- 1348 rDoc.ChgNumRuleFmts( aRule ); 1349 } 1350 break; 1351 } 1352 } 1353 break; 1354 1355 default: 1356 ASSERT(!this, "unbekannte Style-Familie"); 1357 } 1358 1359 if( pFmt && rSet.Count()) 1360 { 1361 SfxItemIter aIter( rSet ); 1362 const SfxPoolItem* pItem = aIter.GetCurItem(); 1363 while( sal_True ) 1364 { 1365 if( IsInvalidItem( pItem ) ) // Clearen 1366 { 1367 // --> OD 2008-02-12 #newlistlevelattrs# 1368 // use method <SwDoc::ResetAttrAtFormat(..)> in order to 1369 // create an Undo object for the attribute reset. 1370 // pFmt->ResetAttr( rSet.GetWhichByPos(aIter.GetCurPos())); 1371 rDoc.ResetAttrAtFormat( rSet.GetWhichByPos(aIter.GetCurPos()), 1372 *pFmt ); 1373 } 1374 1375 if( aIter.IsAtEnd() ) 1376 break; 1377 pItem = aIter.NextItem(); 1378 } 1379 SfxItemSet aSet(rSet); 1380 aSet.ClearInvalidItems(); 1381 1382 aCoreSet.ClearItem(); 1383 1384 if( pNewDsc ) 1385 { 1386 ::ItemSetToPageDesc( aSet, *pNewDsc ); 1387 rDoc.ChgPageDesc( nPgDscPos, *pNewDsc ); 1388 pDesc = &const_cast<const SwDoc &>(rDoc).GetPageDesc( nPgDscPos ); 1389 rDoc.PreDelPageDesc(pNewDsc); // #i7983# 1390 delete pNewDsc; 1391 } 1392 else 1393 rDoc.ChgFmt(*pFmt, aSet); // alles gesetzten Putten 1394 } 1395 else 1396 { 1397 aCoreSet.ClearItem(); 1398 if( pNewDsc ) // den muessen wir noch vernichten!! 1399 { 1400 rDoc.PreDelPageDesc(pNewDsc); // #i7983# 1401 delete pNewDsc; 1402 } 1403 } 1404 1405 // --> OD 2008-02-12 #newlistlevelattrs# 1406 if (rDoc.GetIDocumentUndoRedo().DoesUndo()) 1407 { 1408 rDoc.GetIDocumentUndoRedo().EndUndo(UNDO_END, 0); 1409 } 1410 // <-- 1411 } 1412 1413 void lcl_SaveStyles( sal_uInt16 nFamily, SvPtrarr& rArr, SwDoc& rDoc ) 1414 { 1415 switch( nFamily ) 1416 { 1417 case SFX_STYLE_FAMILY_CHAR: 1418 { 1419 const SwCharFmts& rTbl = *rDoc.GetCharFmts(); 1420 for( sal_uInt16 n = 0, nCnt = rTbl.Count(); n < nCnt; ++n ) 1421 { 1422 void* p = (void*)rTbl[ n ]; 1423 rArr.Insert( p, n ); 1424 } 1425 } 1426 break; 1427 case SFX_STYLE_FAMILY_PARA: 1428 { 1429 const SwTxtFmtColls& rTbl = *rDoc.GetTxtFmtColls(); 1430 for( sal_uInt16 n = 0, nCnt = rTbl.Count(); n < nCnt; ++n ) 1431 { 1432 void* p = (void*)rTbl[ n ]; 1433 rArr.Insert( p, n ); 1434 } 1435 } 1436 break; 1437 case SFX_STYLE_FAMILY_FRAME: 1438 { 1439 const SwFrmFmts& rTbl = *rDoc.GetFrmFmts(); 1440 for( sal_uInt16 n = 0, nCnt = rTbl.Count(); n < nCnt; ++n ) 1441 { 1442 void* p = (void*)rTbl[ n ]; 1443 rArr.Insert( p, n ); 1444 } 1445 } 1446 break; 1447 1448 case SFX_STYLE_FAMILY_PAGE: 1449 { 1450 for( sal_uInt16 n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n ) 1451 { 1452 void* p = 1453 (void*)&const_cast<const SwDoc &>(rDoc).GetPageDesc( n ); 1454 rArr.Insert( p, n ); 1455 } 1456 } 1457 break; 1458 1459 case SFX_STYLE_FAMILY_PSEUDO: 1460 { 1461 const SwNumRuleTbl& rTbl = rDoc.GetNumRuleTbl(); 1462 for( sal_uInt16 n = 0, nCnt = rTbl.Count(); n < nCnt; ++n ) 1463 { 1464 void* p = (void*)rTbl[ n ]; 1465 rArr.Insert( p, n ); 1466 } 1467 } 1468 break; 1469 } 1470 } 1471 1472 void lcl_DeleteInfoStyles( sal_uInt16 nFamily, SvPtrarr& rArr, SwDoc& rDoc ) 1473 { 1474 sal_uInt16 n, nCnt; 1475 switch( nFamily ) 1476 { 1477 case SFX_STYLE_FAMILY_CHAR: 1478 { 1479 SvUShorts aDelArr; 1480 const SwCharFmts& rTbl = *rDoc.GetCharFmts(); 1481 for( n = 0, nCnt = rTbl.Count(); n < nCnt; ++n ) 1482 { 1483 void* p = (void*)rTbl[ n ]; 1484 if( USHRT_MAX == rArr.GetPos( p )) 1485 aDelArr.Insert( n, 0 ); 1486 } 1487 for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n ) 1488 rDoc.DelCharFmt( aDelArr[ n ] ); 1489 } 1490 break; 1491 1492 case SFX_STYLE_FAMILY_PARA : 1493 { 1494 SvUShorts aDelArr; 1495 const SwTxtFmtColls& rTbl = *rDoc.GetTxtFmtColls(); 1496 for( n = 0, nCnt = rTbl.Count(); n < nCnt; ++n ) 1497 { 1498 void* p = (void*)rTbl[ n ]; 1499 if( USHRT_MAX == rArr.GetPos( p )) 1500 aDelArr.Insert( n, 0 ); 1501 } 1502 for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n ) 1503 rDoc.DelTxtFmtColl( aDelArr[ n ] ); 1504 } 1505 break; 1506 1507 case SFX_STYLE_FAMILY_FRAME: 1508 { 1509 SvPtrarr aDelArr; 1510 const SwFrmFmts& rTbl = *rDoc.GetFrmFmts(); 1511 for( n = 0, nCnt = rTbl.Count(); n < nCnt; ++n ) 1512 { 1513 void* p = (void*)rTbl[ n ]; 1514 if( USHRT_MAX == rArr.GetPos( p )) 1515 aDelArr.Insert( p, 0 ); 1516 } 1517 for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n ) 1518 rDoc.DelFrmFmt( (SwFrmFmt*)aDelArr[ n ] ); 1519 } 1520 break; 1521 1522 case SFX_STYLE_FAMILY_PAGE: 1523 { 1524 SvUShorts aDelArr; 1525 for( n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n ) 1526 { 1527 void* p = 1528 (void*)&const_cast<const SwDoc &>(rDoc).GetPageDesc( n ); 1529 if( USHRT_MAX == rArr.GetPos( p )) 1530 aDelArr.Insert( n, 0 ); 1531 } 1532 for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n ) 1533 rDoc.DelPageDesc( aDelArr[ n ] ); 1534 } 1535 break; 1536 1537 1538 case SFX_STYLE_FAMILY_PSEUDO: 1539 { 1540 SvPtrarr aDelArr; 1541 const SwNumRuleTbl& rTbl = rDoc.GetNumRuleTbl(); 1542 for( n = 0, nCnt = rTbl.Count(); n < nCnt; ++n ) 1543 { 1544 void* p = (void*)rTbl[ n ]; 1545 if( USHRT_MAX == rArr.GetPos( p )) 1546 aDelArr.Insert( p, 0 ); 1547 } 1548 for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n ) 1549 rDoc.DelNumRule( ((SwNumRule*)aDelArr[ n ])->GetName() ); 1550 } 1551 break; 1552 } 1553 } 1554 1555 /*-------------------------------------------------------------------- 1556 Beschreibung: Das Format ermitteln 1557 --------------------------------------------------------------------*/ 1558 1559 sal_Bool SwDocStyleSheet::FillStyleSheet( FillStyleType eFType ) 1560 { 1561 sal_Bool bRet = sal_False; 1562 sal_uInt16 nPoolId = USHRT_MAX; 1563 SwFmt* pFmt = 0; 1564 1565 sal_Bool bCreate = FillPhysical == eFType; 1566 sal_Bool bDeleteInfo = sal_False; 1567 sal_Bool bFillOnlyInfo = FillAllInfo == eFType; 1568 SvPtrarr aDelArr; 1569 1570 switch(nFamily) 1571 { 1572 case SFX_STYLE_FAMILY_CHAR: 1573 pCharFmt = lcl_FindCharFmt(rDoc, aName, this, bCreate ); 1574 bPhysical = 0 != pCharFmt; 1575 if( bFillOnlyInfo && !bPhysical ) 1576 { 1577 bDeleteInfo = sal_True; 1578 ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc ); 1579 pCharFmt = lcl_FindCharFmt(rDoc, aName, this, sal_True ); 1580 } 1581 1582 pFmt = pCharFmt; 1583 if( !bCreate && !pFmt ) 1584 { 1585 if( aName == *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD - 1586 RES_POOLCOLL_TEXT_BEGIN ] ) 1587 nPoolId = 0; 1588 else 1589 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); 1590 } 1591 1592 bRet = 0 != pCharFmt || USHRT_MAX != nPoolId; 1593 1594 if( bDeleteInfo ) 1595 pCharFmt = 0; 1596 break; 1597 1598 case SFX_STYLE_FAMILY_PARA: 1599 { 1600 pColl = lcl_FindParaFmt(rDoc, aName, this, bCreate); 1601 bPhysical = 0 != pColl; 1602 if( bFillOnlyInfo && !bPhysical ) 1603 { 1604 bDeleteInfo = sal_True; 1605 ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc ); 1606 pColl = lcl_FindParaFmt(rDoc, aName, this, sal_True ); 1607 } 1608 1609 pFmt = pColl; 1610 if( pColl ) 1611 PresetFollow( pColl->GetNextTxtFmtColl().GetName() ); 1612 else if( !bCreate ) 1613 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ); 1614 1615 bRet = 0 != pColl || USHRT_MAX != nPoolId; 1616 1617 if( bDeleteInfo ) 1618 pColl = 0; 1619 } 1620 break; 1621 1622 case SFX_STYLE_FAMILY_FRAME: 1623 pFrmFmt = lcl_FindFrmFmt(rDoc, aName, this, bCreate); 1624 bPhysical = 0 != pFrmFmt; 1625 if( bFillOnlyInfo && bPhysical ) 1626 { 1627 bDeleteInfo = sal_True; 1628 ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc ); 1629 pFrmFmt = lcl_FindFrmFmt(rDoc, aName, this, sal_True ); 1630 } 1631 pFmt = pFrmFmt; 1632 if( !bCreate && !pFmt ) 1633 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT ); 1634 1635 bRet = 0 != pFrmFmt || USHRT_MAX != nPoolId; 1636 1637 if( bDeleteInfo ) 1638 pFrmFmt = 0; 1639 break; 1640 1641 case SFX_STYLE_FAMILY_PAGE: 1642 pDesc = lcl_FindPageDesc(rDoc, aName, this, bCreate); 1643 bPhysical = 0 != pDesc; 1644 if( bFillOnlyInfo && !pDesc ) 1645 { 1646 bDeleteInfo = sal_True; 1647 ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc ); 1648 pDesc = lcl_FindPageDesc( rDoc, aName, this, sal_True ); 1649 } 1650 1651 if( pDesc ) 1652 { 1653 nPoolId = pDesc->GetPoolFmtId(); 1654 nHelpId = pDesc->GetPoolHelpId(); 1655 if( pDesc->GetPoolHlpFileId() != UCHAR_MAX ) 1656 aHelpFile = *rDoc.GetDocPattern( pDesc->GetPoolHlpFileId() ); 1657 else 1658 aHelpFile.Erase(); 1659 } 1660 else if( !bCreate ) 1661 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC ); 1662 SetMask( USER_FMT & nPoolId ? SFXSTYLEBIT_USERDEF : 0 ); 1663 1664 bRet = 0 != pDesc || USHRT_MAX != nPoolId; 1665 if( bDeleteInfo ) 1666 pDesc = 0; 1667 break; 1668 1669 case SFX_STYLE_FAMILY_PSEUDO: 1670 pNumRule = lcl_FindNumRule(rDoc, aName, this, bCreate); 1671 bPhysical = 0 != pNumRule; 1672 if( bFillOnlyInfo && !pNumRule ) 1673 { 1674 bDeleteInfo = sal_True; 1675 ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc ); 1676 pNumRule = lcl_FindNumRule( rDoc, aName, this, sal_True ); 1677 } 1678 1679 if( pNumRule ) 1680 { 1681 nPoolId = pNumRule->GetPoolFmtId(); 1682 nHelpId = pNumRule->GetPoolHelpId(); 1683 if( pNumRule->GetPoolHlpFileId() != UCHAR_MAX ) 1684 aHelpFile = *rDoc.GetDocPattern( pNumRule->GetPoolHlpFileId() ); 1685 else 1686 aHelpFile.Erase(); 1687 } 1688 else if( !bCreate ) 1689 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE ); 1690 SetMask( USER_FMT & nPoolId ? SFXSTYLEBIT_USERDEF : 0 ); 1691 1692 bRet = 0 != pNumRule || USHRT_MAX != nPoolId; 1693 1694 if( bDeleteInfo ) 1695 pNumRule = 0; 1696 break; 1697 default:; //prevent warning 1698 } 1699 1700 if( SFX_STYLE_FAMILY_CHAR == nFamily || 1701 SFX_STYLE_FAMILY_PARA == nFamily || 1702 SFX_STYLE_FAMILY_FRAME == nFamily ) 1703 { 1704 if( pFmt ) 1705 nPoolId = pFmt->GetPoolFmtId(); 1706 1707 sal_uInt16 _nMask = 0; 1708 if( pFmt == rDoc.GetDfltCharFmt() ) 1709 _nMask |= SFXSTYLEBIT_READONLY; 1710 else if( USER_FMT & nPoolId ) 1711 _nMask |= SFXSTYLEBIT_USERDEF; 1712 1713 switch ( COLL_GET_RANGE_BITS & nPoolId ) 1714 { 1715 case COLL_TEXT_BITS: _nMask |= SWSTYLEBIT_TEXT; break; 1716 case COLL_DOC_BITS : _nMask |= SWSTYLEBIT_CHAPTER; break; 1717 case COLL_LISTS_BITS: _nMask |= SWSTYLEBIT_LIST; break; 1718 case COLL_REGISTER_BITS: _nMask |= SWSTYLEBIT_IDX; break; 1719 case COLL_EXTRA_BITS: _nMask |= SWSTYLEBIT_EXTRA; break; 1720 case COLL_HTML_BITS: _nMask |= SWSTYLEBIT_HTML; break; 1721 } 1722 1723 if( pFmt ) 1724 { 1725 ASSERT( bPhysical, "Format nicht gefunden" ); 1726 1727 nHelpId = pFmt->GetPoolHelpId(); 1728 if( pFmt->GetPoolHlpFileId() != UCHAR_MAX ) 1729 aHelpFile = *rDoc.GetDocPattern( pFmt->GetPoolHlpFileId() ); 1730 else 1731 aHelpFile.Erase(); 1732 1733 if( RES_CONDTXTFMTCOLL == pFmt->Which() ) 1734 _nMask |= SWSTYLEBIT_CONDCOLL; 1735 } 1736 1737 SetMask( _nMask ); 1738 } 1739 if( bDeleteInfo && bFillOnlyInfo ) 1740 ::lcl_DeleteInfoStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc ); 1741 return bRet; 1742 } 1743 1744 /*-------------------------------------------------------------------- 1745 Beschreibung: Neues Format in der Core anlegen 1746 --------------------------------------------------------------------*/ 1747 1748 1749 void SwDocStyleSheet::Create() 1750 { 1751 switch(nFamily) 1752 { 1753 case SFX_STYLE_FAMILY_CHAR : 1754 pCharFmt = lcl_FindCharFmt( rDoc, aName ); 1755 if( !pCharFmt ) 1756 pCharFmt = rDoc.MakeCharFmt(aName, 1757 rDoc.GetDfltCharFmt()); 1758 pCharFmt->SetAuto( sal_False ); 1759 break; 1760 1761 case SFX_STYLE_FAMILY_PARA : 1762 pColl = lcl_FindParaFmt( rDoc, aName ); 1763 if( !pColl ) 1764 { 1765 SwTxtFmtColl *pPar = (*rDoc.GetTxtFmtColls())[0]; 1766 if( nMask & SWSTYLEBIT_CONDCOLL ) 1767 pColl = rDoc.MakeCondTxtFmtColl( aName, pPar ); 1768 else 1769 pColl = rDoc.MakeTxtFmtColl( aName, pPar ); 1770 } 1771 break; 1772 1773 case SFX_STYLE_FAMILY_FRAME: 1774 pFrmFmt = lcl_FindFrmFmt( rDoc, aName ); 1775 if( !pFrmFmt ) 1776 pFrmFmt = rDoc.MakeFrmFmt(aName, rDoc.GetDfltFrmFmt(), sal_False, sal_False); 1777 1778 break; 1779 1780 case SFX_STYLE_FAMILY_PAGE : 1781 pDesc = lcl_FindPageDesc( rDoc, aName ); 1782 if( !pDesc ) 1783 { 1784 sal_uInt16 nId = rDoc.MakePageDesc(aName); 1785 pDesc = &const_cast<const SwDoc &>(rDoc).GetPageDesc(nId); 1786 } 1787 break; 1788 1789 case SFX_STYLE_FAMILY_PSEUDO: 1790 pNumRule = lcl_FindNumRule( rDoc, aName ); 1791 if( !pNumRule ) 1792 { 1793 //JP 05.02.99: temp Namen erzeugen, damit kein ASSERT kommt 1794 String sTmpNm( aName ); 1795 if( !aName.Len() ) 1796 sTmpNm = rDoc.GetUniqueNumRuleName(); 1797 1798 // --> OD 2008-02-11 #newlistlevelattrs# 1799 SwNumRule* pRule = rDoc.GetNumRuleTbl()[ 1800 rDoc.MakeNumRule( sTmpNm, 0, sal_False, 1801 // --> OD 2008-06-06 #i89178# 1802 numfunc::GetDefaultPositionAndSpaceMode() ) ]; 1803 // <-- 1804 // <-- 1805 pRule->SetAutoRule( sal_False ); 1806 if( !aName.Len() ) 1807 { 1808 // --> OD 2008-07-08 #i91400# 1809 pRule->SetName( aName, rDoc ); 1810 // <-- 1811 } 1812 pNumRule = pRule; 1813 } 1814 break; 1815 default:; //prevent warning 1816 } 1817 bPhysical = sal_True; 1818 aCoreSet.ClearItem(); 1819 } 1820 1821 /*-------------------------------------------------------------------- 1822 Beschreibung: Konkrete Formate rausholen 1823 --------------------------------------------------------------------*/ 1824 1825 1826 1827 SwCharFmt* SwDocStyleSheet::GetCharFmt() 1828 { 1829 if(!bPhysical) 1830 FillStyleSheet( FillPhysical ); 1831 return pCharFmt; 1832 } 1833 1834 1835 SwTxtFmtColl* SwDocStyleSheet::GetCollection() 1836 { 1837 if(!bPhysical) 1838 FillStyleSheet( FillPhysical ); 1839 return pColl; 1840 } 1841 1842 1843 const SwPageDesc* SwDocStyleSheet::GetPageDesc() 1844 { 1845 if(!bPhysical) 1846 FillStyleSheet( FillPhysical ); 1847 return pDesc; 1848 } 1849 1850 const SwNumRule * SwDocStyleSheet::GetNumRule() 1851 { 1852 if(!bPhysical) 1853 FillStyleSheet( FillPhysical ); 1854 return pNumRule; 1855 } 1856 1857 void SwDocStyleSheet::SetNumRule(const SwNumRule& rRule) 1858 { 1859 DBG_ASSERT(pNumRule, "Wo ist die NumRule"); 1860 rDoc.ChgNumRuleFmts( rRule ); 1861 } 1862 1863 // Namen UND Familie aus String re-generieren 1864 // First() und Next() (s.u.) fuegen einen Kennbuchstaben an Pos.1 ein 1865 1866 void SwDocStyleSheet::PresetNameAndFamily(const String& rName) 1867 { 1868 switch( rName.GetChar(0) ) 1869 { 1870 case cPARA: nFamily = SFX_STYLE_FAMILY_PARA; break; 1871 case cFRAME: nFamily = SFX_STYLE_FAMILY_FRAME; break; 1872 case cPAGE: nFamily = SFX_STYLE_FAMILY_PAGE; break; 1873 case cNUMRULE: nFamily = SFX_STYLE_FAMILY_PSEUDO; break; 1874 default: nFamily = SFX_STYLE_FAMILY_CHAR; break; 1875 } 1876 aName = rName; 1877 aName.Erase( 0, 1 ); 1878 } 1879 1880 /*-------------------------------------------------------------------- 1881 Beschreibung: Ist das Format physikalisch schon vorhanden 1882 --------------------------------------------------------------------*/ 1883 1884 1885 void SwDocStyleSheet::SetPhysical(sal_Bool bPhys) 1886 { 1887 bPhysical = bPhys; 1888 1889 if(!bPhys) 1890 { 1891 pCharFmt = 0; 1892 pColl = 0; 1893 pFrmFmt = 0; 1894 pDesc = 0; 1895 } 1896 } 1897 1898 SwFrmFmt* SwDocStyleSheet::GetFrmFmt() 1899 { 1900 if(!bPhysical) 1901 FillStyleSheet( FillPhysical ); 1902 return pFrmFmt; 1903 } 1904 1905 1906 sal_Bool SwDocStyleSheet::IsUsed() const 1907 { 1908 if( !bPhysical ) 1909 { 1910 SwDocStyleSheet* pThis = (SwDocStyleSheet*)this; 1911 pThis->FillStyleSheet( FillOnlyName ); 1912 } 1913 1914 // immer noch nicht ? 1915 if( !bPhysical ) 1916 return sal_False; 1917 1918 const SwModify* pMod; 1919 switch( nFamily ) 1920 { 1921 case SFX_STYLE_FAMILY_CHAR : pMod = pCharFmt; break; 1922 case SFX_STYLE_FAMILY_PARA : pMod = pColl; break; 1923 case SFX_STYLE_FAMILY_FRAME: pMod = pFrmFmt; break; 1924 case SFX_STYLE_FAMILY_PAGE : pMod = pDesc; break; 1925 1926 case SFX_STYLE_FAMILY_PSEUDO: 1927 return pNumRule ? rDoc.IsUsed( *pNumRule ) : sal_False; 1928 1929 default: 1930 ASSERT(!this, "unbekannte Style-Familie"); 1931 return sal_False; 1932 } 1933 return rDoc.IsUsed( *pMod ); 1934 } 1935 1936 1937 sal_uLong SwDocStyleSheet::GetHelpId( String& rFile ) 1938 { 1939 static String sTemplateHelpFile = String::CreateFromAscii("swrhlppi.hlp"); 1940 1941 sal_uInt16 nId = 0; 1942 sal_uInt16 nPoolId = 0; 1943 unsigned char nFileId = UCHAR_MAX; 1944 1945 rFile = sTemplateHelpFile; 1946 1947 const SwFmt* pTmpFmt = 0; 1948 switch( nFamily ) 1949 { 1950 case SFX_STYLE_FAMILY_CHAR : 1951 if( !pCharFmt && 1952 0 == (pCharFmt = lcl_FindCharFmt( rDoc, aName, 0, sal_False )) ) 1953 { 1954 nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); 1955 return USHRT_MAX == nId ? 0 : nId; 1956 } 1957 pTmpFmt = pCharFmt; 1958 break; 1959 1960 case SFX_STYLE_FAMILY_PARA: 1961 if( !pColl && 1962 0 == ( pColl = lcl_FindParaFmt( rDoc, aName, 0, sal_False )) ) 1963 { 1964 nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ); 1965 return USHRT_MAX == nId ? 0 : nId; 1966 } 1967 pTmpFmt = pColl; 1968 break; 1969 1970 case SFX_STYLE_FAMILY_FRAME: 1971 if( !pFrmFmt && 1972 0 == ( pFrmFmt = lcl_FindFrmFmt( rDoc, aName, 0, sal_False ) ) ) 1973 { 1974 nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT ); 1975 return USHRT_MAX == nId ? 0 : nId; 1976 } 1977 pTmpFmt = pFrmFmt; 1978 break; 1979 1980 case SFX_STYLE_FAMILY_PAGE: 1981 if( !pDesc && 1982 0 == ( pDesc = lcl_FindPageDesc( rDoc, aName, 0, sal_False ) ) ) 1983 { 1984 nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC ); 1985 return USHRT_MAX == nId ? 0 : nId; 1986 } 1987 1988 nId = pDesc->GetPoolHelpId(); 1989 nFileId = pDesc->GetPoolHlpFileId(); 1990 nPoolId = pDesc->GetPoolFmtId(); 1991 break; 1992 1993 case SFX_STYLE_FAMILY_PSEUDO: 1994 if( !pNumRule && 1995 0 == ( pNumRule = lcl_FindNumRule( rDoc, aName, 0, sal_False ) ) ) 1996 { 1997 nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE ); 1998 return USHRT_MAX == nId ? 0 : nId; 1999 } 2000 2001 nId = pNumRule->GetPoolHelpId(); 2002 nFileId = pNumRule->GetPoolHlpFileId(); 2003 nPoolId = pNumRule->GetPoolFmtId(); 2004 break; 2005 2006 default: 2007 ASSERT(!this, "unbekannte Style-Familie"); 2008 return 0; 2009 } 2010 2011 if( pTmpFmt ) 2012 { 2013 nId = pTmpFmt->GetPoolHelpId(); 2014 nFileId = pTmpFmt->GetPoolHlpFileId(); 2015 nPoolId = pTmpFmt->GetPoolFmtId(); 2016 } 2017 2018 if( UCHAR_MAX != nFileId ) 2019 { 2020 const String *pTemplate = rDoc.GetDocPattern( nFileId ); 2021 if( pTemplate ) 2022 { 2023 // const String aHelpPath(MakeHelpPath(*pTemplate)); 2024 rFile = *pTemplate; 2025 } 2026 } 2027 else if( !IsPoolUserFmt( nPoolId ) ) 2028 { 2029 nId = nPoolId; 2030 } 2031 2032 // weil sich der SFX so anstellt mit der HilfeId: 2033 if( USHRT_MAX == nId ) 2034 nId = 0; // entsp. keine Hilfe anzeigen 2035 2036 return nId; 2037 } 2038 2039 2040 void SwDocStyleSheet::SetHelpId( const String& r, sal_uLong nId ) 2041 { 2042 sal_uInt8 nFileId = static_cast< sal_uInt8 >(rDoc.SetDocPattern( r )); 2043 sal_uInt16 nHId = static_cast< sal_uInt16 >(nId); //!! SFX hat eigenmaechtig auf sal_uLong umgestellt! 2044 2045 SwFmt* pTmpFmt = 0; 2046 switch( nFamily ) 2047 { 2048 case SFX_STYLE_FAMILY_CHAR : pTmpFmt = pCharFmt; break; 2049 case SFX_STYLE_FAMILY_PARA : pTmpFmt = pColl; break; 2050 case SFX_STYLE_FAMILY_FRAME: pTmpFmt = pFrmFmt; break; 2051 case SFX_STYLE_FAMILY_PAGE : 2052 ((SwPageDesc*)pDesc)->SetPoolHelpId( nHId ); 2053 ((SwPageDesc*)pDesc)->SetPoolHlpFileId( nFileId ); 2054 break; 2055 2056 case SFX_STYLE_FAMILY_PSEUDO: 2057 ((SwNumRule*)pNumRule)->SetPoolHelpId( nHId ); 2058 ((SwNumRule*)pNumRule)->SetPoolHlpFileId( nFileId ); 2059 break; 2060 2061 default: 2062 ASSERT(!this, "unbekannte Style-Familie"); 2063 return ; 2064 } 2065 if( pTmpFmt ) 2066 { 2067 pTmpFmt->SetPoolHelpId( nHId ); 2068 pTmpFmt->SetPoolHlpFileId( nFileId ); 2069 } 2070 } 2071 2072 2073 /* */ 2074 2075 /*-------------------------------------------------------------------- 2076 Beschreibung: Methoden fuer den DocStyleSheetPool 2077 --------------------------------------------------------------------*/ 2078 2079 SwDocStyleSheetPool::SwDocStyleSheetPool( SwDoc& rDocument, sal_Bool bOrg ) 2080 : SfxStyleSheetBasePool( rDocument.GetAttrPool() ) 2081 , mxStyleSheet( new SwDocStyleSheet( rDocument, aEmptyStr, *this, SFX_STYLE_FAMILY_CHAR, 0 ) ) 2082 , rDoc( rDocument ) 2083 { 2084 bOrganizer = bOrg; 2085 } 2086 2087 SwDocStyleSheetPool::~SwDocStyleSheetPool() 2088 { 2089 } 2090 2091 void SAL_CALL SwDocStyleSheetPool::acquire( ) throw () 2092 { 2093 comphelper::OWeakTypeObject::acquire(); 2094 } 2095 2096 void SAL_CALL SwDocStyleSheetPool::release( ) throw () 2097 { 2098 comphelper::OWeakTypeObject::release(); 2099 } 2100 2101 SfxStyleSheetBase& SwDocStyleSheetPool::Make( 2102 const String& rName, 2103 SfxStyleFamily eFam, 2104 sal_uInt16 _nMask, 2105 sal_uInt16 /*nPos*/ ) 2106 { 2107 mxStyleSheet->PresetName(rName); 2108 mxStyleSheet->PresetParent(aEmptyStr); 2109 mxStyleSheet->PresetFollow(aEmptyStr); 2110 mxStyleSheet->SetMask(_nMask) ; 2111 mxStyleSheet->SetFamily(eFam); 2112 mxStyleSheet->SetPhysical(sal_True); 2113 mxStyleSheet->Create(); 2114 2115 return *mxStyleSheet.get(); 2116 } 2117 2118 2119 SfxStyleSheetBase* SwDocStyleSheetPool::Create( const SfxStyleSheetBase& /*rOrg*/) 2120 { 2121 ASSERT(!this , "Create im SW-Stylesheet-Pool geht nicht" ); 2122 return NULL; 2123 } 2124 2125 2126 SfxStyleSheetBase* SwDocStyleSheetPool::Create( const String &, 2127 SfxStyleFamily, sal_uInt16 ) 2128 { 2129 ASSERT( !this, "Create im SW-Stylesheet-Pool geht nicht" ); 2130 return NULL; 2131 } 2132 2133 void SwDocStyleSheetPool::Replace( SfxStyleSheetBase& rSource, 2134 SfxStyleSheetBase& rTarget ) 2135 { 2136 SfxStyleFamily eFamily( rSource.GetFamily() ); 2137 if( rSource.HasParentSupport()) 2138 { 2139 const String& rParentName = rSource.GetParent(); 2140 if( 0 != rParentName.Len() ) 2141 { 2142 SfxStyleSheetBase* pParentOfNew = Find( rParentName, eFamily ); 2143 if( pParentOfNew ) 2144 rTarget.SetParent( rParentName ); 2145 } 2146 } 2147 if( rSource.HasFollowSupport()) 2148 { 2149 const String& rFollowName = rSource.GetFollow(); 2150 if( 0 != rFollowName.Len() ) 2151 { 2152 SfxStyleSheetBase* pFollowOfNew = Find( rFollowName, eFamily ); 2153 if( pFollowOfNew ) 2154 rTarget.SetFollow( rFollowName ); 2155 } 2156 } 2157 2158 SwImplShellAction aTmpSh( rDoc ); 2159 2160 sal_Bool bSwSrcPool = GetAppName() == rSource.GetPool().GetAppName(); 2161 if( SFX_STYLE_FAMILY_PAGE == eFamily && bSwSrcPool ) 2162 { 2163 // gesondert behandeln!! 2164 SwPageDesc* pDestDsc = 2165 (SwPageDesc*)((SwDocStyleSheet&)rTarget).GetPageDesc(); 2166 SwPageDesc* pCpyDsc = 2167 (SwPageDesc*)((SwDocStyleSheet&)rSource).GetPageDesc(); 2168 rDoc.CopyPageDesc( *pCpyDsc, *pDestDsc ); 2169 } 2170 else 2171 { 2172 const SwFmt *pSourceFmt = 0; 2173 SwFmt *pTargetFmt = 0; 2174 sal_uInt16 nPgDscPos = USHRT_MAX; 2175 switch( eFamily ) 2176 { 2177 case SFX_STYLE_FAMILY_CHAR : 2178 if( bSwSrcPool ) 2179 pSourceFmt = ((SwDocStyleSheet&)rSource).GetCharFmt(); 2180 pTargetFmt = ((SwDocStyleSheet&)rTarget).GetCharFmt(); 2181 break; 2182 case SFX_STYLE_FAMILY_PARA : 2183 if( bSwSrcPool ) 2184 pSourceFmt = ((SwDocStyleSheet&)rSource).GetCollection(); 2185 pTargetFmt = ((SwDocStyleSheet&)rTarget).GetCollection(); 2186 break; 2187 case SFX_STYLE_FAMILY_FRAME: 2188 if( bSwSrcPool ) 2189 pSourceFmt = ((SwDocStyleSheet&)rSource).GetFrmFmt(); 2190 pTargetFmt = ((SwDocStyleSheet&)rTarget).GetFrmFmt(); 2191 break; 2192 case SFX_STYLE_FAMILY_PAGE: 2193 if( bSwSrcPool ) 2194 pSourceFmt = &((SwDocStyleSheet&)rSource).GetPageDesc() 2195 ->GetMaster(); 2196 { 2197 SwPageDesc *pDesc = rDoc.FindPageDescByName( 2198 ((SwDocStyleSheet&)rTarget).GetPageDesc()->GetName(), 2199 &nPgDscPos ); 2200 2201 if( pDesc ) 2202 pTargetFmt = &pDesc->GetMaster(); 2203 } 2204 break; 2205 case SFX_STYLE_FAMILY_PSEUDO: 2206 // Eine NumRule besteht nur aus einem Item, also muss man 2207 // hier nichts loeschen. 2208 break; 2209 default:; //prevent warning 2210 } 2211 if( pTargetFmt ) 2212 { 2213 if( pSourceFmt ) 2214 pTargetFmt->DelDiffs( *pSourceFmt ); 2215 else if( USHRT_MAX != nPgDscPos ) 2216 pTargetFmt->ResetFmtAttr( RES_PAGEDESC, RES_FRMATR_END-1 ); 2217 else 2218 { 2219 // --> OD 2007-01-25 #i73790# - method renamed 2220 pTargetFmt->ResetAllFmtAttr(); 2221 // <-- 2222 } 2223 2224 if( USHRT_MAX != nPgDscPos ) 2225 rDoc.ChgPageDesc( nPgDscPos, 2226 const_cast<const SwDoc &>(rDoc). 2227 GetPageDesc(nPgDscPos) ); 2228 } 2229 ((SwDocStyleSheet&)rTarget).SetItemSet( rSource.GetItemSet() ); 2230 } 2231 } 2232 2233 SfxStyleSheetIteratorPtr SwDocStyleSheetPool::CreateIterator( SfxStyleFamily eFam, sal_uInt16 _nMask ) 2234 { 2235 return SfxStyleSheetIteratorPtr(new SwStyleSheetIterator( this, eFam, _nMask )); 2236 } 2237 2238 void SwDocStyleSheetPool::dispose() 2239 { 2240 mxStyleSheet.clear(); 2241 } 2242 2243 void SwDocStyleSheetPool::Remove( SfxStyleSheetBase* pStyle) 2244 { 2245 if( !pStyle ) 2246 return; 2247 2248 sal_Bool bBroadcast = sal_True; 2249 SwImplShellAction aTmpSh( rDoc ); 2250 const String& rName = pStyle->GetName(); 2251 switch( pStyle->GetFamily() ) 2252 { 2253 case SFX_STYLE_FAMILY_CHAR: 2254 { 2255 SwCharFmt* pFmt = lcl_FindCharFmt(rDoc, rName, 0, sal_False ); 2256 if(pFmt) 2257 rDoc.DelCharFmt(pFmt); 2258 } 2259 break; 2260 case SFX_STYLE_FAMILY_PARA: 2261 { 2262 SwTxtFmtColl* pColl = lcl_FindParaFmt(rDoc, rName, 0, sal_False ); 2263 if(pColl) 2264 rDoc.DelTxtFmtColl(pColl); 2265 } 2266 break; 2267 case SFX_STYLE_FAMILY_FRAME: 2268 { 2269 SwFrmFmt* pFmt = lcl_FindFrmFmt(rDoc, rName, 0, sal_False ); 2270 if(pFmt) 2271 rDoc.DelFrmFmt(pFmt); 2272 } 2273 break; 2274 case SFX_STYLE_FAMILY_PAGE : 2275 { 2276 sal_uInt16 nPos; 2277 if( rDoc.FindPageDescByName( rName, &nPos )) 2278 rDoc.DelPageDesc( nPos ); 2279 } 2280 break; 2281 2282 case SFX_STYLE_FAMILY_PSEUDO: 2283 { 2284 if( !rDoc.DelNumRule( rName ) ) 2285 // Broadcast nur versenden, wenn etwas geloescht wurde 2286 bBroadcast = sal_False; 2287 } 2288 break; 2289 2290 default: 2291 ASSERT(!this, "unbekannte Style-Familie"); 2292 bBroadcast = sal_False; 2293 } 2294 2295 if( bBroadcast ) 2296 Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_ERASED, *pStyle ) ); 2297 } 2298 2299 2300 2301 sal_Bool SwDocStyleSheetPool::SetParent( SfxStyleFamily eFam, 2302 const String &rStyle, const String &rParent ) 2303 { 2304 SwFmt* pFmt = 0, *pParent = 0; 2305 switch( eFam ) 2306 { 2307 case SFX_STYLE_FAMILY_CHAR : 2308 if( 0 != ( pFmt = lcl_FindCharFmt( rDoc, rStyle ) ) && rParent.Len() ) 2309 pParent = lcl_FindCharFmt(rDoc, rParent ); 2310 break; 2311 2312 case SFX_STYLE_FAMILY_PARA : 2313 if( 0 != ( pFmt = lcl_FindParaFmt( rDoc, rStyle ) ) && rParent.Len() ) 2314 pParent = lcl_FindParaFmt( rDoc, rParent ); 2315 break; 2316 2317 case SFX_STYLE_FAMILY_FRAME: 2318 if( 0 != ( pFmt = lcl_FindFrmFmt( rDoc, rStyle ) ) && rParent.Len() ) 2319 pParent = lcl_FindFrmFmt( rDoc, rParent ); 2320 break; 2321 2322 case SFX_STYLE_FAMILY_PAGE: 2323 case SFX_STYLE_FAMILY_PSEUDO: 2324 break; 2325 2326 default: 2327 ASSERT(!this, "unbekannte Style-Familie"); 2328 } 2329 2330 sal_Bool bRet = sal_False; 2331 if( pFmt && pFmt->DerivedFrom() && 2332 pFmt->DerivedFrom()->GetName() != rParent ) 2333 { 2334 { 2335 SwImplShellAction aTmpSh( rDoc ); 2336 bRet = pFmt->SetDerivedFrom( pParent ); 2337 } 2338 2339 if( bRet ) 2340 { 2341 // nur fuer das Broadcasting 2342 mxStyleSheet->PresetName( rStyle ); 2343 mxStyleSheet->PresetParent( rParent ); 2344 if( SFX_STYLE_FAMILY_PARA == eFam ) 2345 mxStyleSheet->PresetFollow( ((SwTxtFmtColl*)pFmt)-> 2346 GetNextTxtFmtColl().GetName() ); 2347 else 2348 mxStyleSheet->PresetFollow( aEmptyStr ); 2349 2350 Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, 2351 *(mxStyleSheet.get()) ) ); 2352 } 2353 } 2354 2355 return bRet; 2356 } 2357 2358 SfxStyleSheetBase* SwDocStyleSheetPool::Find( const String& rName, 2359 SfxStyleFamily eFam, sal_uInt16 n ) 2360 { 2361 sal_uInt16 nSMask = n; 2362 if( SFX_STYLE_FAMILY_PARA == eFam && rDoc.get(IDocumentSettingAccess::HTML_MODE) ) 2363 { 2364 // dann sind nur HTML-Vorlagen von Interesse 2365 if( USHRT_MAX == nSMask ) 2366 nSMask = SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF | SFXSTYLEBIT_USED; 2367 else 2368 nSMask &= SFXSTYLEBIT_USED | SFXSTYLEBIT_USERDEF | 2369 SWSTYLEBIT_CONDCOLL | SWSTYLEBIT_HTML; 2370 if( !nSMask ) 2371 nSMask = SWSTYLEBIT_HTML; 2372 } 2373 2374 const sal_Bool bSearchUsed = ( n != SFXSTYLEBIT_ALL && 2375 n & SFXSTYLEBIT_USED ) ? sal_True : sal_False; 2376 const SwModify* pMod = 0; 2377 2378 mxStyleSheet->SetPhysical( sal_False ); 2379 mxStyleSheet->PresetName( rName ); 2380 mxStyleSheet->SetFamily( eFam ); 2381 sal_Bool bFnd = mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName ); 2382 2383 if( mxStyleSheet->IsPhysical() ) 2384 { 2385 switch( eFam ) 2386 { 2387 case SFX_STYLE_FAMILY_CHAR: 2388 pMod = mxStyleSheet->GetCharFmt(); 2389 break; 2390 2391 case SFX_STYLE_FAMILY_PARA: 2392 pMod = mxStyleSheet->GetCollection(); 2393 break; 2394 2395 case SFX_STYLE_FAMILY_FRAME: 2396 pMod = mxStyleSheet->GetFrmFmt(); 2397 break; 2398 2399 case SFX_STYLE_FAMILY_PAGE: 2400 pMod = mxStyleSheet->GetPageDesc(); 2401 break; 2402 2403 case SFX_STYLE_FAMILY_PSEUDO: 2404 { 2405 const SwNumRule* pRule = mxStyleSheet->GetNumRule(); 2406 if( pRule && 2407 !(bSearchUsed && (bOrganizer || rDoc.IsUsed(*pRule)) ) && 2408 (( nSMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF 2409 ? !(pRule->GetPoolFmtId() & USER_FMT) 2410 // benutzte gesucht und keine gefunden 2411 : bSearchUsed )) 2412 bFnd = sal_False; 2413 } 2414 break; 2415 2416 default: 2417 ASSERT(!this, "unbekannte Style-Familie"); 2418 } 2419 } 2420 2421 // dann noch die Maske auswerten: 2422 if( pMod && !(bSearchUsed && (bOrganizer || rDoc.IsUsed(*pMod)) ) ) 2423 { 2424 const sal_uInt16 nId = SFX_STYLE_FAMILY_PAGE == eFam 2425 ? ((SwPageDesc*)pMod)->GetPoolFmtId() 2426 : ((SwFmt*)pMod)->GetPoolFmtId(); 2427 2428 if( ( nSMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF 2429 ? !(nId & USER_FMT) 2430 // benutzte gesucht und keine gefunden 2431 : bSearchUsed ) 2432 bFnd = sal_False; 2433 } 2434 return bFnd ? mxStyleSheet.get() : 0; 2435 } 2436 2437 /* */ 2438 2439 SwStyleSheetIterator::SwStyleSheetIterator( SwDocStyleSheetPool* pBase, 2440 SfxStyleFamily eFam, sal_uInt16 n ) 2441 : SfxStyleSheetIterator( pBase, eFam, n ), 2442 mxIterSheet( new SwDocStyleSheet( pBase->GetDoc(), aEmptyStr, *pBase, SFX_STYLE_FAMILY_CHAR, 0 ) ), 2443 mxStyleSheet( new SwDocStyleSheet( pBase->GetDoc(), aEmptyStr, *pBase, SFX_STYLE_FAMILY_CHAR, 0 ) ) 2444 { 2445 bFirstCalled = sal_False; 2446 nLastPos = 0; 2447 StartListening( *pBase ); 2448 } 2449 2450 SwStyleSheetIterator::~SwStyleSheetIterator() 2451 { 2452 EndListening( mxIterSheet->GetPool() ); 2453 } 2454 2455 sal_uInt16 SwStyleSheetIterator::Count() 2456 { 2457 // Liste richtig fuellen lassen !! 2458 if( !bFirstCalled ) 2459 First(); 2460 return aLst.Count(); 2461 } 2462 2463 SfxStyleSheetBase* SwStyleSheetIterator::operator[]( sal_uInt16 nIdx ) 2464 { 2465 // gefunden 2466 if( !bFirstCalled ) 2467 First(); 2468 mxStyleSheet->PresetNameAndFamily( *aLst[ nIdx ] ); 2469 mxStyleSheet->SetPhysical( sal_False ); 2470 mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName ); 2471 2472 return mxStyleSheet.get(); 2473 } 2474 2475 SfxStyleSheetBase* SwStyleSheetIterator::First() 2476 { 2477 // Alte Liste loeschen 2478 bFirstCalled = sal_True; 2479 nLastPos = 0; 2480 aLst.Erase(); 2481 2482 // aktuellen loeschen 2483 mxIterSheet->Reset(); 2484 2485 SwDoc& rDoc = ((SwDocStyleSheetPool*)pBasePool)->GetDoc(); 2486 const sal_uInt16 nSrchMask = nMask; 2487 const sal_Bool bIsSearchUsed = SearchUsed(); 2488 2489 const sal_Bool bOrganizer = ((SwDocStyleSheetPool*)pBasePool)->IsOrganizerMode(); 2490 2491 if( nSearchFamily == SFX_STYLE_FAMILY_CHAR 2492 || nSearchFamily == SFX_STYLE_FAMILY_ALL ) 2493 { 2494 const sal_uInt16 nArrLen = rDoc.GetCharFmts()->Count(); 2495 for( sal_uInt16 i = 0; i < nArrLen; i++ ) 2496 { 2497 SwCharFmt* pFmt = (*rDoc.GetCharFmts())[ i ]; 2498 if( pFmt->IsDefault() && pFmt != rDoc.GetDfltCharFmt() ) 2499 continue; 2500 2501 const sal_Bool bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(*pFmt)); 2502 if( !bUsed ) 2503 { 2504 // Standard ist keine Benutzervorlage #46181# 2505 const sal_uInt16 nId = rDoc.GetDfltCharFmt() == pFmt ? 2506 sal_uInt16( RES_POOLCHR_INET_NORMAL ): 2507 pFmt->GetPoolFmtId(); 2508 if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF 2509 ? !(nId & USER_FMT) 2510 // benutzte gesucht und keine gefunden 2511 : bIsSearchUsed ) 2512 continue; 2513 2514 if( rDoc.get(IDocumentSettingAccess::HTML_MODE) && !(nId & USER_FMT) && 2515 !( RES_POOLCHR_HTML_BEGIN <= nId && 2516 nId < RES_POOLCHR_HTML_END ) && 2517 RES_POOLCHR_INET_NORMAL != nId && 2518 RES_POOLCHR_INET_VISIT != nId && 2519 RES_POOLCHR_FOOTNOTE != nId && 2520 RES_POOLCHR_ENDNOTE != nId ) 2521 continue; 2522 } 2523 2524 aLst.Append( cCHAR, pFmt == rDoc.GetDfltCharFmt() 2525 ? (const String&) *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD - 2526 RES_POOLCOLL_TEXT_BEGIN ] 2527 : pFmt->GetName() ); 2528 } 2529 2530 // PoolFormate 2531 // 2532 if( nSrchMask == SFXSTYLEBIT_ALL ) 2533 { 2534 if( !rDoc.get(IDocumentSettingAccess::HTML_MODE) ) 2535 AppendStyleList(SwStyleNameMapper::GetChrFmtUINameArray(), 2536 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, cCHAR); 2537 else 2538 { 2539 aLst.Append( cCHAR, *SwStyleNameMapper::GetChrFmtUINameArray()[ 2540 RES_POOLCHR_INET_NORMAL - RES_POOLCHR_BEGIN ] ); 2541 aLst.Append( cCHAR, *SwStyleNameMapper::GetChrFmtUINameArray()[ 2542 RES_POOLCHR_INET_VISIT - RES_POOLCHR_BEGIN ] ); 2543 aLst.Append( cCHAR, *SwStyleNameMapper::GetChrFmtUINameArray()[ 2544 RES_POOLCHR_ENDNOTE - RES_POOLCHR_BEGIN ] ); 2545 aLst.Append( cCHAR, *SwStyleNameMapper::GetChrFmtUINameArray()[ 2546 RES_POOLCHR_FOOTNOTE - RES_POOLCHR_BEGIN ] ); 2547 } 2548 AppendStyleList(SwStyleNameMapper::GetHTMLChrFmtUINameArray(), 2549 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, cCHAR); 2550 } 2551 } 2552 2553 if( nSearchFamily == SFX_STYLE_FAMILY_PARA || 2554 nSearchFamily == SFX_STYLE_FAMILY_ALL ) 2555 { 2556 sal_uInt16 nSMask = nSrchMask; 2557 if( rDoc.get(IDocumentSettingAccess::HTML_MODE) ) 2558 { 2559 // dann sind nur HTML-Vorlagen von Interesse 2560 if( USHRT_MAX == nSMask ) 2561 nSMask = SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF | 2562 SFXSTYLEBIT_USED; 2563 else 2564 nSMask &= SFXSTYLEBIT_USED | SFXSTYLEBIT_USERDEF | 2565 SWSTYLEBIT_CONDCOLL | SWSTYLEBIT_HTML; 2566 if( !nSMask ) 2567 nSMask = SWSTYLEBIT_HTML; 2568 } 2569 2570 const sal_uInt16 nArrLen = rDoc.GetTxtFmtColls()->Count(); 2571 for( sal_uInt16 i = 0; i < nArrLen; i++ ) 2572 { 2573 SwTxtFmtColl* pColl = (*rDoc.GetTxtFmtColls())[ i ]; 2574 2575 if(pColl->IsDefault()) 2576 continue; 2577 2578 const sal_Bool bUsed = bOrganizer || rDoc.IsUsed(*pColl); 2579 if( !(bIsSearchUsed && bUsed )) 2580 { 2581 const sal_uInt16 nId = pColl->GetPoolFmtId(); 2582 switch ( (nSMask & ~SFXSTYLEBIT_USED) ) 2583 { 2584 case SFXSTYLEBIT_USERDEF: 2585 if(!IsPoolUserFmt(nId)) continue; 2586 break; 2587 case SWSTYLEBIT_TEXT: 2588 if((nId & COLL_GET_RANGE_BITS) != COLL_TEXT_BITS) continue; 2589 break; 2590 case SWSTYLEBIT_CHAPTER: 2591 if((nId & COLL_GET_RANGE_BITS) != COLL_DOC_BITS) continue; 2592 break; 2593 case SWSTYLEBIT_LIST: 2594 if((nId & COLL_GET_RANGE_BITS) != COLL_LISTS_BITS) continue; 2595 break; 2596 case SWSTYLEBIT_IDX: 2597 if((nId & COLL_GET_RANGE_BITS) != COLL_REGISTER_BITS) continue; 2598 break; 2599 case SWSTYLEBIT_EXTRA: 2600 if((nId & COLL_GET_RANGE_BITS) != COLL_EXTRA_BITS) continue; 2601 break; 2602 2603 case SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF: 2604 if(IsPoolUserFmt(nId)) 2605 break; 2606 // ansonten weiter 2607 case SWSTYLEBIT_HTML: 2608 if( (nId & COLL_GET_RANGE_BITS) != COLL_HTML_BITS) 2609 { 2610 // einige wollen wir aber auch in dieser Section sehen 2611 sal_Bool bWeiter = sal_True; 2612 switch( nId ) 2613 { 2614 case RES_POOLCOLL_SENDADRESS: // --> ADDRESS 2615 case RES_POOLCOLL_TABLE_HDLN: // --> TH 2616 case RES_POOLCOLL_TABLE: // --> TD 2617 case RES_POOLCOLL_TEXT: // --> P 2618 case RES_POOLCOLL_HEADLINE_BASE:// --> H 2619 case RES_POOLCOLL_HEADLINE1: // --> H1 2620 case RES_POOLCOLL_HEADLINE2: // --> H2 2621 case RES_POOLCOLL_HEADLINE3: // --> H3 2622 case RES_POOLCOLL_HEADLINE4: // --> H4 2623 case RES_POOLCOLL_HEADLINE5: // --> H5 2624 case RES_POOLCOLL_HEADLINE6: // --> H6 2625 case RES_POOLCOLL_STANDARD: // --> P 2626 case RES_POOLCOLL_FOOTNOTE: 2627 case RES_POOLCOLL_ENDNOTE: 2628 bWeiter = sal_False; 2629 break; 2630 } 2631 if( bWeiter ) 2632 continue; 2633 } 2634 break; 2635 case SWSTYLEBIT_CONDCOLL: 2636 if( RES_CONDTXTFMTCOLL != pColl->Which() ) continue; 2637 break; 2638 default: 2639 // benutzte gesucht und keine gefunden 2640 if( bIsSearchUsed ) 2641 continue; 2642 } 2643 } 2644 aLst.Append( cPARA, pColl->GetName() ); 2645 } 2646 2647 const sal_Bool bAll = nSMask == SFXSTYLEBIT_ALL; 2648 if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_TEXT ) 2649 AppendStyleList(SwStyleNameMapper::GetTextUINameArray(), 2650 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ); 2651 if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_CHAPTER ) 2652 AppendStyleList(SwStyleNameMapper::GetDocUINameArray(), 2653 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ; 2654 if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_LIST ) 2655 AppendStyleList(SwStyleNameMapper::GetListsUINameArray(), 2656 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ; 2657 if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_IDX ) 2658 AppendStyleList(SwStyleNameMapper::GetRegisterUINameArray(), 2659 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ; 2660 if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_EXTRA ) 2661 AppendStyleList(SwStyleNameMapper::GetExtraUINameArray(), 2662 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ; 2663 if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_CONDCOLL ) 2664 { 2665 if( !bIsSearchUsed || 2666 rDoc.IsPoolTxtCollUsed( RES_POOLCOLL_TEXT )) 2667 aLst.Append( cPARA, *SwStyleNameMapper::GetTextUINameArray()[ 2668 RES_POOLCOLL_TEXT - RES_POOLCOLL_TEXT_BEGIN ] ); 2669 } 2670 if ( bAll || 2671 (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_HTML || 2672 (nSMask & ~SFXSTYLEBIT_USED) == 2673 (SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF) ) 2674 { 2675 AppendStyleList(SwStyleNameMapper::GetHTMLUINameArray(), 2676 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ; 2677 if( !bAll ) 2678 { 2679 // dann auch die, die wir mappen: 2680 static sal_uInt16 aPoolIds[] = { 2681 RES_POOLCOLL_SENDADRESS, // --> ADDRESS 2682 RES_POOLCOLL_TABLE_HDLN, // --> TH 2683 RES_POOLCOLL_TABLE, // --> TD 2684 RES_POOLCOLL_STANDARD, // --> P 2685 RES_POOLCOLL_TEXT, // --> P 2686 RES_POOLCOLL_HEADLINE_BASE, // --> H 2687 RES_POOLCOLL_HEADLINE1, // --> H1 2688 RES_POOLCOLL_HEADLINE2, // --> H2 2689 RES_POOLCOLL_HEADLINE3, // --> H3 2690 RES_POOLCOLL_HEADLINE4, // --> H4 2691 RES_POOLCOLL_HEADLINE5, // --> H5 2692 RES_POOLCOLL_HEADLINE6, // --> H6 2693 RES_POOLCOLL_FOOTNOTE, 2694 RES_POOLCOLL_ENDNOTE, 2695 0 2696 }; 2697 2698 sal_uInt16* pPoolIds = aPoolIds; 2699 String s; 2700 while( *pPoolIds ) 2701 { 2702 if( !bIsSearchUsed || rDoc.IsPoolTxtCollUsed( *pPoolIds ) ) 2703 aLst.Append( cPARA, 2704 s = SwStyleNameMapper::GetUIName( *pPoolIds, s )); 2705 ++pPoolIds; 2706 } 2707 } 2708 } 2709 } 2710 2711 if( nSearchFamily == SFX_STYLE_FAMILY_FRAME || 2712 nSearchFamily == SFX_STYLE_FAMILY_ALL ) 2713 { 2714 const sal_uInt16 nArrLen = rDoc.GetFrmFmts()->Count(); 2715 for( sal_uInt16 i = 0; i < nArrLen; i++ ) 2716 { 2717 SwFrmFmt* pFmt = (*rDoc.GetFrmFmts())[ i ]; 2718 2719 if(pFmt->IsDefault() || pFmt->IsAuto()) 2720 { 2721 continue; 2722 } 2723 2724 const sal_uInt16 nId = pFmt->GetPoolFmtId(); 2725 sal_Bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(*pFmt)); 2726 if( !bUsed ) 2727 { 2728 if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF 2729 ? !(nId & USER_FMT) 2730 // benutzte gesucht und keine gefunden 2731 : bIsSearchUsed ) 2732 { 2733 continue; 2734 } 2735 } 2736 2737 aLst.Append( cFRAME, pFmt->GetName() ); 2738 } 2739 2740 // PoolFormate 2741 // 2742 if ( nSrchMask == SFXSTYLEBIT_ALL ) 2743 AppendStyleList(SwStyleNameMapper::GetFrmFmtUINameArray(), 2744 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, cFRAME); 2745 } 2746 2747 if( nSearchFamily == SFX_STYLE_FAMILY_PAGE || 2748 nSearchFamily == SFX_STYLE_FAMILY_ALL ) 2749 { 2750 const sal_uInt16 nCount = rDoc.GetPageDescCnt(); 2751 for(sal_uInt16 i = 0; i < nCount; ++i) 2752 { 2753 const SwPageDesc& rDesc = 2754 const_cast<const SwDoc &>(rDoc).GetPageDesc(i); 2755 const sal_uInt16 nId = rDesc.GetPoolFmtId(); 2756 sal_Bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rDesc)); 2757 if( !bUsed ) 2758 { 2759 if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF 2760 ? !(nId & USER_FMT) 2761 // benutzte gesucht und keine gefunden 2762 : bIsSearchUsed ) 2763 continue; 2764 } 2765 2766 aLst.Append( cPAGE, rDesc.GetName() ); 2767 } 2768 if ( nSrchMask == SFXSTYLEBIT_ALL ) 2769 AppendStyleList(SwStyleNameMapper::GetPageDescUINameArray(), 2770 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, cPAGE); 2771 } 2772 2773 if( nSearchFamily == SFX_STYLE_FAMILY_PSEUDO || 2774 nSearchFamily == SFX_STYLE_FAMILY_ALL ) 2775 { 2776 const SwNumRuleTbl& rNumTbl = rDoc.GetNumRuleTbl(); 2777 for(sal_uInt16 i = 0; i < rNumTbl.Count(); ++i) 2778 { 2779 const SwNumRule& rRule = *rNumTbl[ i ]; 2780 if( !rRule.IsAutoRule() ) 2781 { 2782 sal_Bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rRule) ); 2783 if( !bUsed ) 2784 { 2785 if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF 2786 ? !(rRule.GetPoolFmtId() & USER_FMT) 2787 // benutzte gesucht und keine gefunden 2788 : bIsSearchUsed ) 2789 continue; 2790 } 2791 2792 aLst.Append( cNUMRULE, rRule.GetName() ); 2793 } 2794 } 2795 if ( nSrchMask == SFXSTYLEBIT_ALL ) 2796 AppendStyleList(SwStyleNameMapper::GetNumRuleUINameArray(), 2797 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, cNUMRULE); 2798 } 2799 2800 if(aLst.Count() > 0) 2801 { 2802 nLastPos = USHRT_MAX; 2803 return Next(); 2804 } 2805 return 0; 2806 } 2807 2808 SfxStyleSheetBase* SwStyleSheetIterator::Next() 2809 { 2810 nLastPos++; 2811 if(aLst.Count() > 0 && nLastPos < aLst.Count()) 2812 { 2813 mxIterSheet->PresetNameAndFamily(*aLst[nLastPos]); 2814 mxIterSheet->SetPhysical( sal_False ); 2815 mxIterSheet->SetMask( nMask ); 2816 if(mxIterSheet->pSet) 2817 { 2818 mxIterSheet->pSet->ClearItem(0); 2819 mxIterSheet->pSet= 0; 2820 } 2821 return mxIterSheet.get(); 2822 } 2823 return 0; 2824 } 2825 2826 SfxStyleSheetBase* SwStyleSheetIterator::Find( const UniString& rName ) 2827 { 2828 // suchen 2829 if( !bFirstCalled ) 2830 First(); 2831 2832 nLastPos = lcl_FindName( aLst, nSearchFamily, rName ); 2833 if( USHRT_MAX != nLastPos ) 2834 { 2835 // gefunden 2836 mxStyleSheet->PresetNameAndFamily(*aLst[nLastPos]); 2837 // neuer Name gesetzt, also bestimme seine Daten 2838 mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName ); 2839 if( !mxStyleSheet->IsPhysical() ) 2840 mxStyleSheet->SetPhysical( sal_False ); 2841 2842 return mxStyleSheet.get(); 2843 } 2844 return 0; 2845 } 2846 2847 void SwStyleSheetIterator::AppendStyleList(const SvStringsDtor& rList, 2848 sal_Bool bTestUsed, 2849 sal_uInt16 nSection, char cType ) 2850 { 2851 if( bTestUsed ) 2852 { 2853 SwDoc& rDoc = ((SwDocStyleSheetPool*)pBasePool)->GetDoc(); 2854 for ( sal_uInt16 i=0; i < rList.Count(); ++i ) 2855 { 2856 sal_Bool bUsed = sal_False; 2857 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(*rList[i], (SwGetPoolIdFromName)nSection); 2858 switch ( nSection ) 2859 { 2860 case nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL: 2861 bUsed = rDoc.IsPoolTxtCollUsed( nId ); 2862 break; 2863 case nsSwGetPoolIdFromName::GET_POOLID_CHRFMT: 2864 bUsed = rDoc.IsPoolFmtUsed( nId ); 2865 break; 2866 case nsSwGetPoolIdFromName::GET_POOLID_FRMFMT: 2867 bUsed = rDoc.IsPoolFmtUsed( nId ); 2868 case nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC: 2869 bUsed = rDoc.IsPoolPageDescUsed( nId ); 2870 break; 2871 default: 2872 ASSERT( !this, "unknown PoolFmt-Id" ); 2873 } 2874 if ( bUsed ) 2875 aLst.Append( cType, *rList[i] ); 2876 } 2877 } 2878 else 2879 for ( sal_uInt16 i=0; i < rList.Count(); ++i ) 2880 aLst.Append( cType, *rList[i] ); 2881 } 2882 2883 void SwStyleSheetIterator::Notify( SfxBroadcaster&, const SfxHint& rHint ) 2884 { 2885 // suchen und aus der Anzeige-Liste entfernen !! 2886 if( rHint.ISA( SfxStyleSheetHint ) && 2887 SFX_STYLESHEET_ERASED == ((SfxStyleSheetHint&) rHint).GetHint() ) 2888 { 2889 SfxStyleSheetBase* pStyle = ((SfxStyleSheetHint&)rHint).GetStyleSheet(); 2890 2891 if (pStyle) 2892 { 2893 sal_uInt16 nTmpPos = lcl_FindName( aLst, pStyle->GetFamily(), 2894 pStyle->GetName() ); 2895 if( nTmpPos < aLst.Count() ) 2896 aLst.DeleteAndDestroy( nTmpPos ); 2897 } 2898 } 2899 } 2900 2901 2902