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 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> 28 #include <com/sun/star/beans/XPropertySet.hpp> 29 #include <com/sun/star/container/XNameAccess.hpp> 30 31 #include <hintids.hxx> 32 #include <sfx2/app.hxx> 33 #include <svl/whiter.hxx> 34 #include <sfx2/templdlg.hxx> 35 #include <sfx2/tplpitem.hxx> 36 #include <sfx2/request.hxx> 37 #include <sfx2/dispatch.hxx> 38 #include <sfx2/newstyle.hxx> 39 #include <sfx2/printer.hxx> 40 #include <svl/macitem.hxx> 41 #include <editeng/brshitem.hxx> 42 #include <svl/stritem.hxx> 43 #include <svl/languageoptions.hxx> 44 #include <editeng/eeitem.hxx> 45 #include <svx/htmlmode.hxx> 46 #include <swmodule.hxx> 47 #include <wdocsh.hxx> 48 #include <fmtfsize.hxx> 49 #include <fchrfmt.hxx> 50 #include <svtools/htmlcfg.hxx> 51 #include <SwStyleNameMapper.hxx> 52 #include <SwRewriter.hxx> 53 #include <numrule.hxx> 54 #include <swundo.hxx> 55 56 #include "view.hxx" 57 #include "wrtsh.hxx" 58 #include "docsh.hxx" 59 #include "uitool.hxx" 60 #include "cmdid.h" 61 #include "globals.hrc" 62 #include "viewopt.hxx" 63 #include <doc.hxx> 64 #include <IDocumentUndoRedo.hxx> 65 #include "swstyle.h" 66 #include "frmfmt.hxx" 67 #include "charfmt.hxx" 68 #include "poolfmt.hxx" 69 #include "pagedesc.hxx" 70 #include "docstyle.hxx" 71 #include "uiitems.hxx" 72 #include "fmtcol.hxx" 73 #include "frmmgr.hxx" //SwFrmValid 74 #include "swevent.hxx" 75 #include "edtwin.hxx" 76 #include "unochart.hxx" 77 78 #include "app.hrc" 79 #include <fmtui.hrc> 80 #include "swabstdlg.hxx" 81 // --> OD 2008-03-27 #refactorlists# 82 #include <list.hxx> 83 // <-- 84 85 #include <paratr.hxx> //#outline level,add by zhaojianwei 86 87 using namespace ::com::sun::star; 88 89 /*-------------------------------------------------------------------- 90 Beschreibung: 91 --------------------------------------------------------------------*/ 92 93 94 void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh) 95 { 96 SfxWhichIter aIter(rSet); 97 sal_uInt16 nWhich = aIter.FirstWhich(); 98 sal_uInt16 nActualFamily = USHRT_MAX; 99 100 SwWrtShell* pShell = pSh ? pSh : GetWrtShell(); 101 if(!pShell) 102 { 103 while (nWhich) 104 { 105 rSet.DisableItem(nWhich); 106 nWhich = aIter.NextWhich(); 107 } 108 return; 109 } 110 else 111 { 112 SfxViewFrame* pFrame = pShell->GetView().GetViewFrame(); 113 const ISfxTemplateCommon* pCommon = SFX_APP()->GetCurrentTemplateCommon(pFrame->GetBindings()); 114 if( pCommon ) 115 nActualFamily = static_cast< sal_uInt16 >(pCommon->GetActualFamily()); 116 } 117 118 while (nWhich) 119 { 120 // aktuelle Vorlage zu jeder Familie ermitteln 121 // 122 String aName; 123 switch (nWhich) 124 { 125 case SID_STYLE_APPLY: 126 {//hier wird die Vorlage und ihre Familie an die StyleBox 127 //uebergeben, damit diese Familie angezeigt wird 128 if(pShell->IsFrmSelected()) 129 { 130 SwFrmFmt* pFmt = pShell->GetCurFrmFmt(); 131 if( pFmt ) 132 aName = pFmt->GetName(); 133 } 134 else 135 { 136 SwTxtFmtColl* pColl = pShell->GetCurTxtFmtColl(); 137 if(pColl) 138 aName = pColl->GetName(); 139 } 140 rSet.Put(SfxTemplateItem(nWhich, aName)); 141 } 142 break; 143 case SID_STYLE_FAMILY1: 144 if( !pShell->IsFrmSelected() ) 145 { 146 SwCharFmt* pFmt = pShell->GetCurCharFmt(); 147 if(pFmt) 148 aName = pFmt->GetName(); 149 else 150 aName = *SwStyleNameMapper::GetTextUINameArray()[ 151 RES_POOLCOLL_STANDARD - RES_POOLCOLL_TEXT_BEGIN ]; 152 rSet.Put(SfxTemplateItem(nWhich, aName)); 153 } 154 break; 155 156 case SID_STYLE_FAMILY2: 157 if(!pShell->IsFrmSelected()) 158 { 159 SwTxtFmtColl* pColl = pShell->GetCurTxtFmtColl(); 160 if(pColl) 161 aName = pColl->GetName(); 162 163 SfxTemplateItem aItem(nWhich, aName); 164 165 sal_uInt16 nMask = 0; 166 if( pDoc->get(IDocumentSettingAccess::HTML_MODE) ) 167 nMask = SWSTYLEBIT_HTML; 168 else 169 { 170 const int nSelection = pShell->GetFrmType(0,sal_True); 171 if(pShell->GetCurTOX()) 172 nMask = SWSTYLEBIT_IDX ; 173 else if(nSelection & FRMTYPE_HEADER || 174 nSelection & FRMTYPE_FOOTER || 175 nSelection & FRMTYPE_TABLE || 176 nSelection & FRMTYPE_FLY_ANY || 177 nSelection & FRMTYPE_FOOTNOTE || 178 nSelection & FRMTYPE_FTNPAGE) 179 nMask = SWSTYLEBIT_EXTRA; 180 else 181 nMask = SWSTYLEBIT_TEXT; 182 } 183 184 aItem.SetValue(nMask); 185 rSet.Put(aItem); 186 } 187 188 break; 189 190 case SID_STYLE_FAMILY3: 191 192 if( pDoc->get(IDocumentSettingAccess::HTML_MODE) ) 193 rSet.DisableItem( nWhich ); 194 else 195 { 196 SwFrmFmt* pFmt = pShell->GetCurFrmFmt(); 197 if(pFmt && pShell->IsFrmSelected()) 198 { 199 aName = pFmt->GetName(); 200 rSet.Put(SfxTemplateItem(nWhich, aName)); 201 } 202 } 203 break; 204 205 case SID_STYLE_FAMILY4: 206 { 207 SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get(); 208 if( pDoc->get(IDocumentSettingAccess::HTML_MODE) && !pHtmlOpt->IsPrintLayoutExtension()) 209 rSet.DisableItem( nWhich ); 210 else 211 { 212 sal_uInt16 n = pShell->GetCurPageDesc( sal_False ); 213 if( n < pShell->GetPageDescCnt() ) 214 aName = pShell->GetPageDesc( n ).GetName(); 215 216 rSet.Put(SfxTemplateItem(nWhich, aName)); 217 } 218 } 219 break; 220 case SID_STYLE_FAMILY5: 221 { 222 const SwNumRule* pRule = pShell->GetCurNumRule(); 223 if( pRule ) 224 aName = pRule->GetName(); 225 226 rSet.Put(SfxTemplateItem(nWhich, aName)); 227 } 228 break; 229 230 case SID_STYLE_WATERCAN: 231 { 232 SwEditWin& rEdtWin = pShell->GetView().GetEditWin(); 233 SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate(); 234 rSet.Put(SfxBoolItem(nWhich, pApply && pApply->eType != 0)); 235 } 236 break; 237 case SID_STYLE_UPDATE_BY_EXAMPLE: 238 if( pShell->IsFrmSelected() 239 ? SFX_STYLE_FAMILY_FRAME != nActualFamily 240 : ( SFX_STYLE_FAMILY_FRAME == nActualFamily || 241 SFX_STYLE_FAMILY_PAGE == nActualFamily || 242 (SFX_STYLE_FAMILY_PSEUDO == nActualFamily && !pShell->GetCurNumRule())) ) 243 { 244 rSet.DisableItem( nWhich ); 245 } 246 break; 247 248 case SID_STYLE_NEW_BY_EXAMPLE: 249 if( (pShell->IsFrmSelected() 250 ? SFX_STYLE_FAMILY_FRAME != nActualFamily 251 : SFX_STYLE_FAMILY_FRAME == nActualFamily) || 252 (SFX_STYLE_FAMILY_PSEUDO == nActualFamily && !pShell->GetCurNumRule()) ) 253 { 254 rSet.DisableItem( nWhich ); 255 } 256 break; 257 258 default: 259 DBG_ERROR( "Invalid SlotId"); 260 } 261 nWhich = aIter.NextWhich(); 262 } 263 } 264 265 266 /*-------------------------------------------------------------------- 267 Beschreibung: StyleSheet-Requeste auswerten 268 --------------------------------------------------------------------*/ 269 270 271 void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) 272 { 273 sal_uInt16 nSlot = rReq.GetSlot(); 274 sal_uInt16 nRet = 0xffff; 275 276 const SfxItemSet* pArgs = rReq.GetArgs(); 277 const SfxPoolItem* pItem; 278 SwWrtShell* pActShell = 0; 279 sal_Bool bSetReturn = sal_True; 280 switch (nSlot) 281 { 282 case SID_STYLE_NEW: 283 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILY, 284 sal_False, &pItem )) 285 { 286 sal_uInt16 nFamily = ((const SfxUInt16Item*)pItem)->GetValue(); 287 288 String sName; 289 sal_uInt16 nMask = 0; 290 if( SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_NEW, 291 sal_False, &pItem )) 292 sName = ((const SfxStringItem*)pItem)->GetValue(); 293 if( SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_MASK, 294 sal_False, &pItem )) 295 nMask = ((const SfxUInt16Item*)pItem)->GetValue(); 296 String sParent; 297 if( SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_REFERENCE, 298 sal_False, &pItem )) 299 sParent = ((const SfxStringItem*)pItem)->GetValue(); 300 301 nRet = Edit( sName, sParent, nFamily, nMask, sal_True, sal_False, 0, rReq.IsAPI() ); 302 } 303 break; 304 305 case SID_STYLE_APPLY: 306 if( !pArgs ) 307 { 308 GetView()->GetViewFrame()->GetDispatcher()->Execute(SID_STYLE_DESIGNER, sal_False); 309 break; 310 } 311 else 312 { 313 // convert internal StyleName to DisplayName (slot implementation uses the latter) 314 SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, SID_APPLY_STYLE, sal_False ); 315 SFX_REQUEST_ARG( rReq, pFamilyItem, SfxStringItem, SID_STYLE_FAMILYNAME, sal_False ); 316 if ( pFamilyItem && pNameItem ) 317 { 318 uno::Reference< style::XStyleFamiliesSupplier > xModel(GetModel(), uno::UNO_QUERY); 319 try 320 { 321 uno::Reference< container::XNameAccess > xStyles; 322 uno::Reference< container::XNameAccess > xCont = xModel->getStyleFamilies(); 323 xCont->getByName(pFamilyItem->GetValue()) >>= xStyles; 324 uno::Reference< beans::XPropertySet > xInfo; 325 xStyles->getByName( pNameItem->GetValue() ) >>= xInfo; 326 ::rtl::OUString aUIName; 327 xInfo->getPropertyValue( ::rtl::OUString::createFromAscii("DisplayName") ) >>= aUIName; 328 if ( aUIName.getLength() ) 329 rReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aUIName ) ); 330 } 331 catch( uno::Exception& ) 332 { 333 } 334 } 335 } 336 337 // intentionally no break 338 339 case SID_STYLE_EDIT: 340 case SID_STYLE_DELETE: 341 case SID_STYLE_WATERCAN: 342 case SID_STYLE_FAMILY: 343 case SID_STYLE_UPDATE_BY_EXAMPLE: 344 case SID_STYLE_NEW_BY_EXAMPLE: 345 { 346 String aParam; 347 sal_uInt16 nFamily = SFX_STYLE_FAMILY_PARA; 348 sal_uInt16 nMask = 0; 349 350 if( !pArgs ) 351 { 352 nFamily = SFX_STYLE_FAMILY_PARA; 353 354 switch (nSlot) 355 { 356 case SID_STYLE_NEW_BY_EXAMPLE: 357 { 358 SfxNewStyleDlg *pDlg = new SfxNewStyleDlg( 0, 359 *GetStyleSheetPool()); 360 if(RET_OK == pDlg->Execute()) 361 { 362 aParam = pDlg->GetName(); 363 rReq.AppendItem(SfxStringItem(nSlot, aParam)); 364 } 365 366 delete pDlg; 367 } 368 break; 369 370 case SID_STYLE_UPDATE_BY_EXAMPLE: 371 case SID_STYLE_EDIT: 372 { 373 SwTxtFmtColl* pColl = GetWrtShell()->GetCurTxtFmtColl(); 374 if(pColl) 375 { 376 aParam = pColl->GetName(); 377 rReq.AppendItem(SfxStringItem(nSlot, aParam)); 378 } 379 } 380 break; 381 } 382 } 383 else 384 { 385 ASSERT( pArgs->Count(), "SfxBug ItemSet ist leer"); 386 387 SwWrtShell* pShell = GetWrtShell(); 388 if( SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem )) 389 aParam = ((const SfxStringItem*)pItem)->GetValue(); 390 391 if( SFX_ITEM_SET == pArgs->GetItemState(SID_STYLE_FAMILY, 392 sal_False, &pItem )) 393 nFamily = ((const SfxUInt16Item*)pItem)->GetValue(); 394 395 if( SFX_ITEM_SET == pArgs->GetItemState(SID_STYLE_FAMILYNAME, sal_False, &pItem )) 396 { 397 String aFamily = ((const SfxStringItem*)pItem)->GetValue(); 398 if(aFamily.CompareToAscii("CharacterStyles") == COMPARE_EQUAL) 399 nFamily = SFX_STYLE_FAMILY_CHAR; 400 else 401 if(aFamily.CompareToAscii("ParagraphStyles") == COMPARE_EQUAL) 402 nFamily = SFX_STYLE_FAMILY_PARA; 403 else 404 if(aFamily.CompareToAscii("PageStyles") == COMPARE_EQUAL) 405 nFamily = SFX_STYLE_FAMILY_PAGE; 406 else 407 if(aFamily.CompareToAscii("FrameStyles") == COMPARE_EQUAL) 408 nFamily = SFX_STYLE_FAMILY_FRAME; 409 else 410 if(aFamily.CompareToAscii("NumberingStyles") == COMPARE_EQUAL) 411 nFamily = SFX_STYLE_FAMILY_PSEUDO; 412 } 413 414 if( SFX_ITEM_SET == pArgs->GetItemState(SID_STYLE_MASK, 415 sal_False, &pItem )) 416 nMask = ((const SfxUInt16Item*)pItem)->GetValue(); 417 if( SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_WRTSHELL, 418 sal_False, &pItem )) 419 pActShell = pShell = (SwWrtShell*)((SwPtrItem*)pItem)->GetValue(); 420 421 if( nSlot == SID_STYLE_UPDATE_BY_EXAMPLE ) 422 { 423 switch( nFamily ) 424 { 425 case SFX_STYLE_FAMILY_PARA: 426 { 427 SwTxtFmtColl* pColl = pShell->GetCurTxtFmtColl(); 428 if(pColl) 429 aParam = pColl->GetName(); 430 } 431 break; 432 case SFX_STYLE_FAMILY_FRAME: 433 { 434 SwFrmFmt* pFrm = pWrtShell->GetCurFrmFmt(); 435 if( pFrm ) 436 aParam = pFrm->GetName(); 437 } 438 break; 439 case SFX_STYLE_FAMILY_CHAR: 440 { 441 SwCharFmt* pChar = pWrtShell->GetCurCharFmt(); 442 if( pChar ) 443 aParam = pChar->GetName(); 444 } 445 break; 446 case SFX_STYLE_FAMILY_PSEUDO: 447 if(SFX_ITEM_SET == pArgs->GetItemState(SID_STYLE_UPD_BY_EX_NAME, sal_False, &pItem)) 448 { 449 aParam = ((const SfxStringItem*)pItem)->GetValue(); 450 } 451 break; 452 } 453 rReq.AppendItem(SfxStringItem(nSlot, aParam)); 454 } 455 } 456 if (aParam.Len() || nSlot == SID_STYLE_WATERCAN ) 457 { 458 switch(nSlot) 459 { 460 case SID_STYLE_EDIT: 461 nRet = Edit(aParam, aEmptyStr, nFamily, nMask, sal_False, sal_False, pActShell ); 462 break; 463 case SID_STYLE_DELETE: 464 nRet = Delete(aParam, nFamily); 465 break; 466 case SID_STYLE_APPLY: 467 // Shellwechsel in ApplyStyles 468 nRet = ApplyStyles(aParam, nFamily, pActShell, rReq.GetModifier() ); 469 break; 470 case SID_STYLE_WATERCAN: 471 nRet = DoWaterCan(aParam, nFamily); 472 break; 473 case SID_STYLE_UPDATE_BY_EXAMPLE: 474 nRet = UpdateStyle(aParam, nFamily, pActShell); 475 break; 476 case SID_STYLE_NEW_BY_EXAMPLE: 477 { 478 nRet = MakeByExample(aParam, nFamily, nMask, pActShell ); 479 SfxTemplateDialog* pDlg = SFX_APP()->GetTemplateDialog(); 480 481 if(pDlg && pDlg->IsVisible()) 482 pDlg->Update(); 483 } 484 break; 485 486 default: 487 DBG_ERROR( "Falsche Slot-Id"); 488 } 489 490 rReq.Done(); 491 } 492 493 break; 494 } 495 } 496 497 if(bSetReturn) 498 { 499 if(rReq.IsAPI()) // Basic bekommt nur sal_True oder sal_False 500 rReq.SetReturnValue(SfxUInt16Item(nSlot, nRet !=0)); 501 else 502 rReq.SetReturnValue(SfxUInt16Item(nSlot, nRet)); 503 } 504 505 } 506 507 /*-------------------------------------------------------------------- 508 Beschreibung: Edit 509 --------------------------------------------------------------------*/ 510 511 512 sal_uInt16 SwDocShell::Edit( const String &rName, const String &rParent, sal_uInt16 nFamily, sal_uInt16 nMask, 513 sal_Bool bNew, sal_Bool bColumn, SwWrtShell* pActShell, 514 sal_Bool bBasic ) 515 { 516 ASSERT(GetWrtShell(), "Keine Shell, keine Styles"); 517 SfxStyleSheetBase *pStyle = 0; 518 519 sal_uInt16 nRet = nMask; 520 sal_Bool bModified = pDoc->IsModified(); 521 522 if( bNew ) 523 { 524 if( SFXSTYLEBIT_ALL != nMask && SFXSTYLEBIT_USED != nMask ) 525 nMask |= SFXSTYLEBIT_USERDEF; 526 else 527 nMask = SFXSTYLEBIT_USERDEF; 528 529 pStyle = &mxBasePool->Make( rName, (SfxStyleFamily)nFamily, nMask ); 530 531 // die aktuellen als Parent setzen 532 SwDocStyleSheet* pDStyle = (SwDocStyleSheet*)pStyle; 533 switch( nFamily ) 534 { 535 case SFX_STYLE_FAMILY_PARA: 536 { 537 if(rParent.Len()) 538 { 539 SwTxtFmtColl* pColl = pWrtShell->FindTxtFmtCollByName( rParent ); 540 if(!pColl) 541 { 542 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rParent, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL); 543 if(USHRT_MAX != nId) 544 pColl = pWrtShell->GetTxtCollFromPool( nId ); 545 } 546 pDStyle->GetCollection()->SetDerivedFrom( pColl ); 547 pDStyle->PresetParent( rParent ); 548 549 //#outline level,add by zhaojianwei 550 /*When a new paragraph style is created based on a "to outline style 551 assigned" paragraph style, the outline level attribute and the list 552 style attribute of the new paragraph style have to be set to 0 553 respectively "".*/ 554 if( pColl->IsAssignedToListLevelOfOutlineStyle()) 555 { 556 SwNumRuleItem aItem(aEmptyStr); 557 pDStyle->GetCollection()->SetFmtAttr( aItem ); 558 pDStyle->GetCollection()->SetAttrOutlineLevel( 0 ); 559 } 560 //<-end,zhaojianwei 561 562 } 563 else 564 { 565 SwTxtFmtColl* pColl = pWrtShell->GetCurTxtFmtColl(); 566 pDStyle->GetCollection()->SetDerivedFrom( pColl ); 567 if( pColl ) 568 pDStyle->PresetParent( pColl->GetName() ); 569 } 570 } 571 break; 572 case SFX_STYLE_FAMILY_CHAR: 573 { 574 if(rParent.Len()) 575 { 576 SwCharFmt* pCFmt = pWrtShell->FindCharFmtByName( rParent ); 577 if(!pCFmt) 578 { 579 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rParent, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT); 580 if(USHRT_MAX != nId) 581 pCFmt = pWrtShell->GetCharFmtFromPool( nId ); 582 } 583 584 pDStyle->GetCharFmt()->SetDerivedFrom( pCFmt ); 585 pDStyle->PresetParent( rParent ); 586 } 587 else 588 { 589 SwCharFmt* pCFmt = pWrtShell->GetCurCharFmt(); 590 pDStyle->GetCharFmt()->SetDerivedFrom( pCFmt ); 591 if( pCFmt ) 592 pDStyle->PresetParent( pCFmt->GetName() ); 593 } 594 } 595 break; 596 case SFX_STYLE_FAMILY_FRAME : 597 { 598 if(rParent.Len()) 599 { 600 SwFrmFmt* pFFmt = pWrtShell->GetDoc()->FindFrmFmtByName( rParent ); 601 if(!pFFmt) 602 { 603 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rParent, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT); 604 if(USHRT_MAX != nId) 605 pFFmt = pWrtShell->GetFrmFmtFromPool( nId ); 606 } 607 pDStyle->GetFrmFmt()->SetDerivedFrom( pFFmt ); 608 pDStyle->PresetParent( rParent ); 609 } 610 } 611 break; 612 } 613 } 614 else 615 { 616 pStyle = mxBasePool->Find( rName, (SfxStyleFamily)nFamily ); 617 ASSERT(pStyle, "Vorlage nicht gefunden"); 618 } 619 620 if(!pStyle) 621 return sal_False; 622 623 // Dialoge zusammenstoepseln 624 // 625 rtl::Reference< SwDocStyleSheet > xTmp( new SwDocStyleSheet( *(SwDocStyleSheet*)pStyle ) ); 626 if( SFX_STYLE_FAMILY_PARA == nFamily ) 627 { 628 SfxItemSet& rSet = xTmp->GetItemSet(); 629 ::SwToSfxPageDescAttr( rSet ); 630 // erstmal nur eine Null 631 rSet.Put(SwBackgroundDestinationItem(SID_PARA_BACKGRND_DESTINATION, 0)); 632 // --> OD 2008-02-13 #newlistlevelattrs# 633 // merge list level indent attributes into the item set if needed 634 xTmp->MergeIndentAttrsOfListStyle( rSet ); 635 // <-- 636 } 637 /* else if( SFX_STYLE_FAMILY_FRAME == nFamily ) 638 { 639 // Auskommentiert wegen Bug #45776 (per default keine Breite&Groesse in Rahmenvorlagen) 640 SfxItemSet& rSet = aTmp.GetItemSet(); 641 if( SFX_ITEM_SET != rSet.GetItemState( RES_FRM_SIZE )) 642 { 643 // dann sollten wir spaetesten hier eines anlegen 644 SwFrmValid aFrmDefValues; 645 rSet.Put( SwFmtFrmSize( ATT_VAR_SIZE, aFrmDefValues.nWidth, 646 aFrmDefValues.nHeight )); 647 } 648 }*/ 649 else if( SFX_STYLE_FAMILY_CHAR == nFamily ) 650 { 651 SfxItemSet& rSet = xTmp->GetItemSet(); 652 const SfxPoolItem *pTmpBrush; 653 if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_BACKGROUND, 654 sal_True, &pTmpBrush ) ) 655 { 656 SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) ); 657 aTmpBrush.SetWhich( RES_BACKGROUND ); 658 rSet.Put( aTmpBrush ); 659 } 660 } 661 if (!bBasic) 662 { 663 // vor dem Dialog wird der HtmlMode an der DocShell versenkt 664 sal_uInt16 nHtmlMode = ::GetHtmlMode(this); 665 666 // In HTML mode, we do not always have a printer. In order to show 667 // the correct page size in the Format - Page dialog, we have to 668 // get one here. 669 SwWrtShell* pCurrShell = ( pActShell ? pActShell : pWrtShell ); 670 if( ( HTMLMODE_ON & nHtmlMode ) && 671 !pCurrShell->getIDocumentDeviceAccess()->getPrinter( false ) ) 672 pCurrShell->InitPrt( pCurrShell->getIDocumentDeviceAccess()->getPrinter( true ) ); 673 674 PutItem(SfxUInt16Item(SID_HTML_MODE, nHtmlMode)); 675 FieldUnit eMetric = ::GetDfltMetric(0 != (HTMLMODE_ON&nHtmlMode)); 676 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric))); 677 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 678 DBG_ASSERT(pFact, "Dialogdiet fail!"); 679 SfxAbstractTabDialog* pDlg = pFact->CreateTemplateDialog( DLG_TEMPLATE_BASE, 680 0, *(xTmp.get()), nFamily, bColumn, 681 pActShell ? pActShell : pWrtShell, bNew); 682 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 683 if(RET_OK == pDlg->Execute()) 684 { 685 GetWrtShell()->StartAllAction(); 686 687 // nur bei Absatz-Vorlagen die Maske neu setzen 688 if( bNew ) 689 { 690 nRet = SFX_STYLE_FAMILY_PARA == pStyle->GetFamily() 691 ? xTmp->GetMask() 692 : SFXSTYLEBIT_USERDEF; 693 } 694 else if( pStyle->GetMask() != xTmp->GetMask() ) 695 nRet = xTmp->GetMask(); 696 697 if( SFX_STYLE_FAMILY_PARA == nFamily ) 698 { 699 SfxItemSet aSet( *pDlg->GetOutputItemSet() ); 700 ::SfxToSwPageDescAttr( *GetWrtShell(), aSet ); 701 // --> OD 2008-02-12 #newlistlevelattrs# 702 // reset indent attributes at paragraph style, if a list style 703 // will be applied and no indent attributes will be applied. 704 xTmp->SetItemSet( aSet, true ); 705 // <-- 706 } 707 else 708 { 709 if(SFX_STYLE_FAMILY_PAGE == nFamily) 710 { 711 static const sal_uInt16 aInval[] = { 712 SID_IMAGE_ORIENTATION, 713 SID_ATTR_CHAR_FONT, 714 FN_INSERT_CTRL, FN_INSERT_OBJ_CTRL, 0}; 715 pView->GetViewFrame()->GetBindings().Invalidate(aInval); 716 } 717 SfxItemSet aTmpSet( *pDlg->GetOutputItemSet() ); 718 if( SFX_STYLE_FAMILY_CHAR == nFamily ) 719 { 720 const SfxPoolItem *pTmpBrush; 721 if( SFX_ITEM_SET == aTmpSet.GetItemState( RES_BACKGROUND, 722 sal_False, &pTmpBrush ) ) 723 { 724 SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) ); 725 aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND ); 726 aTmpSet.Put( aTmpBrush ); 727 } 728 aTmpSet.ClearItem( RES_BACKGROUND ); 729 } 730 xTmp->SetItemSet( aTmpSet ); 731 732 if( SFX_STYLE_FAMILY_PAGE == nFamily && SvtLanguageOptions().IsCTLFontEnabled() ) 733 { 734 const SfxPoolItem *pItem = NULL; 735 if( aTmpSet.GetItemState( GetPool().GetTrueWhich( SID_ATTR_FRAMEDIRECTION, sal_False ) , sal_True, &pItem ) == SFX_ITEM_SET ) 736 SwChartHelper::DoUpdateAllCharts( pDoc ); 737 } 738 } 739 if(SFX_STYLE_FAMILY_PAGE == nFamily) 740 pView->InvalidateRulerPos(); 741 742 if( bNew ) 743 mxBasePool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *xTmp.get() ) ); 744 745 // JP 19.09.97: 746 // Dialog vorm EndAction zerstoeren - bei Seitenvorlagen kann 747 // muss der ItemSet zerstoert werden, damit die Cursor aus den 748 // Kopf-/Fusszeilen entfernt werden. Sonst kommts zu GPFs!!! 749 delete pDlg; 750 751 pDoc->SetModified(); 752 if( !bModified ) // Bug 57028 753 { 754 pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified(); 755 } 756 757 GetWrtShell()->EndAllAction(); 758 } 759 else 760 { 761 if( bNew ) 762 { 763 // #116530# 764 //pBasePool->Erase( &aTmp ); 765 GetWrtShell()->Undo(1); 766 pDoc->GetIDocumentUndoRedo().ClearRedo(); 767 } 768 769 if( !bModified ) 770 pDoc->ResetModified(); 771 delete pDlg; 772 } 773 } 774 else 775 { 776 // vor dem Dialog wird der HtmlMode an der DocShell versenkt 777 PutItem(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(this))); 778 779 GetWrtShell()->StartAllAction(); 780 781 // nur bei Absatz-Vorlagen die Maske neu setzen 782 if( bNew ) 783 { 784 nRet = SFX_STYLE_FAMILY_PARA == pStyle->GetFamily() 785 ? xTmp->GetMask() 786 : SFXSTYLEBIT_USERDEF; 787 } 788 else if( pStyle->GetMask() != xTmp->GetMask() ) 789 nRet = xTmp->GetMask(); 790 791 if( SFX_STYLE_FAMILY_PARA == nFamily ) 792 ::SfxToSwPageDescAttr( *GetWrtShell(), xTmp->GetItemSet() ); 793 else 794 { 795 SfxItemSet aTmpSet( xTmp->GetItemSet() ); 796 if( SFX_STYLE_FAMILY_CHAR == nFamily ) 797 { 798 const SfxPoolItem *pTmpBrush; 799 if( SFX_ITEM_SET == aTmpSet.GetItemState( RES_BACKGROUND, 800 sal_False, &pTmpBrush ) ) 801 { 802 SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) ); 803 aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND ); 804 aTmpSet.Put( aTmpBrush ); 805 } 806 aTmpSet.ClearItem( RES_BACKGROUND ); 807 } 808 xTmp->SetItemSet( aTmpSet ); 809 } 810 if(SFX_STYLE_FAMILY_PAGE == nFamily) 811 pView->InvalidateRulerPos(); 812 813 if( bNew ) 814 mxBasePool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *xTmp.get() ) ); 815 816 pDoc->SetModified(); 817 if( !bModified ) // Bug 57028 818 { 819 pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified(); 820 } 821 GetWrtShell()->EndAllAction(); 822 } 823 824 return nRet; 825 } 826 827 /*-------------------------------------------------------------------- 828 Beschreibung: Delete 829 --------------------------------------------------------------------*/ 830 831 832 sal_uInt16 SwDocShell::Delete(const String &rName, sal_uInt16 nFamily) 833 { 834 SfxStyleSheetBase *pStyle = mxBasePool->Find(rName, (SfxStyleFamily)nFamily); 835 836 if(pStyle) 837 { 838 ASSERT(GetWrtShell(), "Keine Shell, keine Styles"); 839 840 GetWrtShell()->StartAllAction(); 841 mxBasePool->Remove(pStyle); 842 GetWrtShell()->EndAllAction(); 843 844 return sal_True; 845 } 846 return sal_False; 847 } 848 849 /*-------------------------------------------------------------------- 850 Beschreibung: Vorlage anwenden 851 --------------------------------------------------------------------*/ 852 853 854 sal_uInt16 SwDocShell::ApplyStyles(const String &rName, sal_uInt16 nFamily, 855 SwWrtShell* pShell, sal_uInt16 nMode ) 856 { 857 SwDocStyleSheet* pStyle = 858 (SwDocStyleSheet*)mxBasePool->Find(rName, (SfxStyleFamily)nFamily); 859 860 ASSERT(pStyle, "Wo ist der StyleSheet"); 861 if(!pStyle) 862 return sal_False; 863 864 SwWrtShell *pSh = pShell ? pShell : GetWrtShell(); 865 866 ASSERT( pSh, "Keine Shell, keine Styles"); 867 868 pSh->StartAllAction(); 869 870 switch(nFamily) 871 { 872 case SFX_STYLE_FAMILY_CHAR: 873 { 874 SwFmtCharFmt aFmt(pStyle->GetCharFmt()); 875 pSh->SetAttr( aFmt, (nMode & KEY_SHIFT) ? 876 nsSetAttrMode::SETATTR_DONTREPLACE : nsSetAttrMode::SETATTR_DEFAULT ); 877 break; 878 } 879 case SFX_STYLE_FAMILY_PARA: 880 { 881 // --> OD 2007-11-06 #i62675# 882 // clear also list attributes at affected text nodes, if paragraph 883 // style has the list style attribute set. 884 pSh->SetTxtFmtColl( pStyle->GetCollection(), true ); 885 // <-- 886 break; 887 } 888 case SFX_STYLE_FAMILY_FRAME: 889 { 890 if ( pSh->IsFrmSelected() ) 891 pSh->SetFrmFmt( pStyle->GetFrmFmt() ); 892 break; 893 } 894 case SFX_STYLE_FAMILY_PAGE: 895 { 896 pSh->SetPageStyle(pStyle->GetPageDesc()->GetName()); 897 break; 898 } 899 case SFX_STYLE_FAMILY_PSEUDO: 900 { 901 // --> OD 2008-02-08 #newlistlevelattrs# 902 // reset indent attribute on applying list style 903 // --> OD 2008-03-17 #refactorlists# 904 // continue list of list style 905 const SwNumRule* pNumRule = pStyle->GetNumRule(); 906 const String sListIdForStyle =pNumRule->GetDefaultListId(); 907 pSh->SetCurNumRule( *pNumRule, false, sListIdForStyle, true ); 908 // <-- 909 break; 910 } 911 default: 912 DBG_ERROR("Unbekannte Familie"); 913 } 914 pSh->EndAllAction(); 915 916 return nFamily; 917 } 918 919 /*-------------------------------------------------------------------- 920 Beschreibung: Giesskanne starten 921 --------------------------------------------------------------------*/ 922 923 924 925 sal_uInt16 SwDocShell::DoWaterCan(const String &rName, sal_uInt16 nFamily) 926 { 927 ASSERT(GetWrtShell(), "Keine Shell, keine Styles"); 928 929 SwEditWin& rEdtWin = pView->GetEditWin(); 930 SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate(); 931 sal_Bool bWaterCan = !(pApply && pApply->eType != 0); 932 if( !rName.Len() ) 933 bWaterCan = sal_False; 934 SwApplyTemplate aTemplate; 935 aTemplate.eType = nFamily; 936 937 if(bWaterCan) 938 { 939 SwDocStyleSheet* pStyle = 940 (SwDocStyleSheet*)mxBasePool->Find(rName, (SfxStyleFamily)nFamily); 941 942 ASSERT(pStyle, "Wo ist der StyleSheet"); 943 if(!pStyle) return nFamily; 944 945 switch(nFamily) 946 { 947 case SFX_STYLE_FAMILY_CHAR: 948 aTemplate.aColl.pCharFmt = pStyle->GetCharFmt(); 949 break; 950 case SFX_STYLE_FAMILY_PARA: 951 aTemplate.aColl.pTxtColl = pStyle->GetCollection(); 952 break; 953 case SFX_STYLE_FAMILY_FRAME: 954 aTemplate.aColl.pFrmFmt = pStyle->GetFrmFmt(); 955 break; 956 case SFX_STYLE_FAMILY_PAGE: 957 aTemplate.aColl.pPageDesc = (SwPageDesc*)pStyle->GetPageDesc(); 958 break; 959 case SFX_STYLE_FAMILY_PSEUDO: 960 aTemplate.aColl.pNumRule = (SwNumRule*)pStyle->GetNumRule(); 961 break; 962 963 default: 964 DBG_ERROR( "Unbekannte Familie"); 965 } 966 } 967 else 968 aTemplate.eType = 0; 969 970 // Template anwenden 971 pView->GetEditWin().SetApplyTemplate(aTemplate); 972 973 return nFamily; 974 } 975 976 /*-------------------------------------------------------------------- 977 Beschreibung: Vorlage Updaten 978 --------------------------------------------------------------------*/ 979 980 981 sal_uInt16 SwDocShell::UpdateStyle(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell) 982 { 983 SwWrtShell* pCurrWrtShell = pShell ? pShell : GetWrtShell(); 984 ASSERT(GetWrtShell(), "Keine Shell, keine Styles"); 985 986 SwDocStyleSheet* pStyle = 987 (SwDocStyleSheet*)mxBasePool->Find(rName, (SfxStyleFamily)nFamily); 988 989 if(!pStyle) 990 return nFamily; 991 992 switch(nFamily) 993 { 994 case SFX_STYLE_FAMILY_PARA: 995 { 996 SwTxtFmtColl* pColl = pStyle->GetCollection(); 997 if(pColl && !pColl->IsDefault()) 998 { 999 GetWrtShell()->StartAllAction(); 1000 1001 SwRewriter aRewriter; 1002 aRewriter.AddRule(UNDO_ARG1, pColl->GetName()); 1003 1004 GetWrtShell()->StartUndo(UNDO_INSFMTATTR, &aRewriter); 1005 GetWrtShell()->FillByEx(pColl); 1006 // Vorlage auch anwenden, um harte Attributierung 1007 // zu entfernen 1008 GetWrtShell()->SetTxtFmtColl( pColl ); 1009 GetWrtShell()->EndUndo(); 1010 GetWrtShell()->EndAllAction(); 1011 } 1012 break; 1013 } 1014 case SFX_STYLE_FAMILY_FRAME: 1015 { 1016 SwFrmFmt* pFrm = pStyle->GetFrmFmt(); 1017 if( pCurrWrtShell->IsFrmSelected() && pFrm && !pFrm->IsDefault() ) 1018 { 1019 SfxItemSet aSet( GetPool(), aFrmFmtSetRange ); 1020 pCurrWrtShell->StartAllAction(); 1021 pCurrWrtShell->GetFlyFrmAttr( aSet ); 1022 1023 // --> OD 2009-12-28 #i105535# 1024 // no update of anchor attribute 1025 aSet.ClearItem( RES_ANCHOR ); 1026 // <-- 1027 1028 pFrm->SetFmtAttr( aSet ); 1029 1030 // Vorlage auch anwenden, um harte Attributierung 1031 // zu entfernen 1032 pCurrWrtShell->SetFrmFmt( pFrm, sal_True ); 1033 pCurrWrtShell->EndAllAction(); 1034 } 1035 } 1036 break; 1037 case SFX_STYLE_FAMILY_CHAR: 1038 { 1039 SwCharFmt* pChar = pStyle->GetCharFmt(); 1040 if( pChar && !pChar->IsDefault() ) 1041 { 1042 pCurrWrtShell->StartAllAction(); 1043 pCurrWrtShell->FillByEx(pChar); 1044 // Vorlage auch anwenden, um harte Attributierung 1045 // zu entfernen 1046 pCurrWrtShell->EndAllAction(); 1047 } 1048 1049 } 1050 break; 1051 case SFX_STYLE_FAMILY_PSEUDO: 1052 { 1053 const SwNumRule* pCurRule; 1054 if( pStyle->GetNumRule() && 1055 0 != ( pCurRule = pCurrWrtShell->GetCurNumRule() )) 1056 { 1057 SwNumRule aRule( *pCurRule ); 1058 // --> OD 2008-07-08 #i91400# 1059 aRule.SetName( pStyle->GetNumRule()->GetName(), 1060 *(pCurrWrtShell->GetDoc()) ); 1061 // <-- 1062 pCurrWrtShell->ChgNumRuleFmts( aRule ); 1063 } 1064 } 1065 break; 1066 } 1067 return nFamily; 1068 } 1069 1070 /*-------------------------------------------------------------------- 1071 Beschreibung: NewByExample 1072 --------------------------------------------------------------------*/ 1073 1074 1075 sal_uInt16 SwDocShell::MakeByExample( const String &rName, sal_uInt16 nFamily, 1076 sal_uInt16 nMask, SwWrtShell* pShell ) 1077 { 1078 SwWrtShell* pCurrWrtShell = pShell ? pShell : GetWrtShell(); 1079 SwDocStyleSheet* pStyle = (SwDocStyleSheet*)mxBasePool->Find( 1080 rName, (SfxStyleFamily)nFamily ); 1081 if(!pStyle) 1082 { 1083 // JP 07.07.95: behalte die akt. Maske vom PI bei, dadurch werden 1084 // neue sofort in den sichtbaren Bereich einsortiert 1085 if( SFXSTYLEBIT_ALL == nMask || SFXSTYLEBIT_USED == nMask ) 1086 nMask = SFXSTYLEBIT_USERDEF; 1087 else 1088 nMask |= SFXSTYLEBIT_USERDEF; 1089 1090 pStyle = (SwDocStyleSheet*)&mxBasePool->Make(rName, 1091 (SfxStyleFamily)nFamily, nMask ); 1092 } 1093 1094 switch(nFamily) 1095 { 1096 case SFX_STYLE_FAMILY_PARA: 1097 { 1098 SwTxtFmtColl* pColl = pStyle->GetCollection(); 1099 if(pColl && !pColl->IsDefault()) 1100 { 1101 pCurrWrtShell->StartAllAction(); 1102 pCurrWrtShell->FillByEx(pColl); 1103 // Vorlage auch anwenden, um harte Attributierung 1104 // zu entfernen 1105 pColl->SetDerivedFrom(pCurrWrtShell->GetCurTxtFmtColl()); 1106 1107 // setze die Maske noch an der Collection: 1108 sal_uInt16 nId = pColl->GetPoolFmtId() & 0x87ff; 1109 switch( nMask & 0x0fff ) 1110 { 1111 case SWSTYLEBIT_TEXT: 1112 nId |= COLL_TEXT_BITS; 1113 break; 1114 case SWSTYLEBIT_CHAPTER: 1115 nId |= COLL_DOC_BITS; 1116 break; 1117 case SWSTYLEBIT_LIST: 1118 nId |= COLL_LISTS_BITS; 1119 break; 1120 case SWSTYLEBIT_IDX: 1121 nId |= COLL_REGISTER_BITS; 1122 break; 1123 case SWSTYLEBIT_EXTRA: 1124 nId |= COLL_EXTRA_BITS; 1125 break; 1126 case SWSTYLEBIT_HTML: 1127 nId |= COLL_HTML_BITS; 1128 break; 1129 } 1130 pColl->SetPoolFmtId(nId); 1131 1132 pCurrWrtShell->SetTxtFmtColl(pColl); 1133 pCurrWrtShell->EndAllAction(); 1134 } 1135 } 1136 break; 1137 case SFX_STYLE_FAMILY_FRAME: 1138 { 1139 SwFrmFmt* pFrm = pStyle->GetFrmFmt(); 1140 if(pCurrWrtShell->IsFrmSelected() && pFrm && !pFrm->IsDefault()) 1141 { 1142 pCurrWrtShell->StartAllAction(); 1143 1144 SfxItemSet aSet(GetPool(), aFrmFmtSetRange ); 1145 pCurrWrtShell->GetFlyFrmAttr( aSet ); 1146 1147 SwFrmFmt* pFFmt = pCurrWrtShell->GetCurFrmFmt(); 1148 pFrm->SetDerivedFrom( pFFmt ); 1149 1150 // JP 10.06.98: nur automatische Orientierungen uebernehmen 1151 /* #61359# jetzt auch wieder alle Orientierungen 1152 const SfxPoolItem* pItem; 1153 if( SFX_ITEM_SET == aSet.GetItemState( RES_VERT_ORIENT, 1154 sal_False, &pItem ) && 1155 text::VertOrientation::NONE == ((SwFmtVertOrient*)pItem)->GetVertOrient()) 1156 aSet.ClearItem( RES_VERT_ORIENT ); 1157 1158 if( SFX_ITEM_SET == aSet.GetItemState( RES_HORI_ORIENT, 1159 sal_False, &pItem ) && 1160 text::HoriOrientation::NONE == ((SwFmtHoriOrient*)pItem)->GetHoriOrient()) 1161 aSet.ClearItem( RES_HORI_ORIENT ); 1162 */ 1163 1164 pFrm->SetFmtAttr( aSet ); 1165 // Vorlage auch anwenden, um harte Attributierung 1166 // zu entfernen 1167 pCurrWrtShell->SetFrmFmt( pFrm ); 1168 pCurrWrtShell->EndAllAction(); 1169 } 1170 } 1171 break; 1172 case SFX_STYLE_FAMILY_CHAR: 1173 { 1174 SwCharFmt* pChar = pStyle->GetCharFmt(); 1175 if(pChar && !pChar->IsDefault()) 1176 { 1177 pCurrWrtShell->StartAllAction(); 1178 pCurrWrtShell->FillByEx( pChar ); 1179 pChar->SetDerivedFrom( pCurrWrtShell->GetCurCharFmt() ); 1180 SwFmtCharFmt aFmt( pChar ); 1181 pCurrWrtShell->SetAttr( aFmt ); 1182 pCurrWrtShell->EndAllAction(); 1183 } 1184 } 1185 break; 1186 1187 case SFX_STYLE_FAMILY_PAGE: 1188 { 1189 pCurrWrtShell->StartAllAction(); 1190 sal_uInt16 nPgDsc = pCurrWrtShell->GetCurPageDesc(); 1191 SwPageDesc& rSrc = (SwPageDesc&)pCurrWrtShell->GetPageDesc( nPgDsc ); 1192 SwPageDesc& rDest = *(SwPageDesc*)pStyle->GetPageDesc(); 1193 1194 sal_uInt16 nPoolId = rDest.GetPoolFmtId(); 1195 sal_uInt16 nHId = rDest.GetPoolHelpId(); 1196 sal_uInt8 nHFId = rDest.GetPoolHlpFileId(); 1197 1198 pCurrWrtShell->GetDoc()->CopyPageDesc( rSrc, rDest ); 1199 1200 // PoolId darf NIE kopiert werden! 1201 rDest.SetPoolFmtId( nPoolId ); 1202 rDest.SetPoolHelpId( nHId ); 1203 rDest.SetPoolHlpFileId( nHFId ); 1204 1205 // werden Kopf-/Fusszeilen angelegt, so gibt es kein Undo mehr! 1206 pCurrWrtShell->GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj(); 1207 1208 pCurrWrtShell->EndAllAction(); 1209 } 1210 break; 1211 1212 case SFX_STYLE_FAMILY_PSEUDO: 1213 { 1214 pCurrWrtShell->StartAllAction(); 1215 1216 SwNumRule aRule( *pCurrWrtShell->GetCurNumRule() ); 1217 String sOrigRule( aRule.GetName() ); 1218 // --> OD 2008-07-08 #i91400# 1219 aRule.SetName( pStyle->GetNumRule()->GetName(), 1220 *(pCurrWrtShell->GetDoc()) ); 1221 // <-- 1222 pCurrWrtShell->ChgNumRuleFmts( aRule ); 1223 1224 pCurrWrtShell->ReplaceNumRule( sOrigRule, aRule.GetName() ); 1225 1226 1227 pCurrWrtShell->EndAllAction(); 1228 } 1229 break; 1230 } 1231 return nFamily; 1232 } 1233 1234 void SwDocShell::LoadStyles( SfxObjectShell& rSource ) 1235 { 1236 _LoadStyles(rSource, sal_False); 1237 } 1238 /* -----------------16.05.2003 15:45----------------- 1239 bPreserveCurrentDocument determines whether SetFixFields() is called 1240 This call modifies the source document. This mustn't happen when the source 1241 is a document the user is working on. 1242 Calls of ::LoadStyles() normally use files especially loaded for the purpose 1243 of importing styles. 1244 --------------------------------------------------*/ 1245 void SwDocShell::_LoadStyles( SfxObjectShell& rSource, sal_Bool bPreserveCurrentDocument ) 1246 { 1247 /* [Beschreibung] 1248 1249 Diese Methode wird vom SFx gerufen, wenn aus einer Dokument-Vorlage 1250 Styles nachgeladen werden sollen. Bestehende Styles soll dabei 1251 "uberschrieben werden. Das Dokument mu"s daher neu formatiert werden. 1252 Daher werden die Applikationen in der Regel diese Methode "uberladen 1253 und in ihrer Implementierung die Implementierung der Basisklasse 1254 rufen. 1255 */ 1256 // ist die Source unser Document, dann uebernehmen wir das 1257 // abpruefen selbst (wesentlich schneller und laeuft nicht ueber 1258 // die Kruecke SfxStylePool 1259 if( rSource.ISA( SwDocShell )) 1260 { 1261 //JP 28.05.99: damit die Kopf-/Fusszeilen nicht den fixen Inhalt 1262 // der Vorlage erhalten, einmal alle FixFelder der 1263 // Source aktualisieren 1264 if(!bPreserveCurrentDocument) 1265 ((SwDocShell&)rSource).pDoc->SetFixFields(false, NULL); 1266 if( pWrtShell ) 1267 { 1268 pWrtShell->StartAllAction(); 1269 pDoc->ReplaceStyles( *((SwDocShell&)rSource).pDoc ); 1270 pWrtShell->EndAllAction(); 1271 } 1272 else 1273 { 1274 sal_Bool bModified = pDoc->IsModified(); 1275 pDoc->ReplaceStyles( *((SwDocShell&)rSource).pDoc ); 1276 if( !bModified && pDoc->IsModified() && !pView ) 1277 { 1278 // die View wird spaeter angelegt, ueberschreibt aber das 1279 // Modify-Flag. Per Undo ist sowieso nichts mehr zu machen 1280 pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified(); 1281 } 1282 } 1283 } 1284 else 1285 SfxObjectShell::LoadStyles( rSource ); 1286 } 1287 1288 1289 void SwDocShell::FormatPage( const String& rPage, sal_Bool bColumn, SwWrtShell* pActShell ) 1290 { 1291 Edit( rPage, aEmptyStr, SFX_STYLE_FAMILY_PAGE, 0, sal_False, bColumn, pActShell); 1292 } 1293 1294 Bitmap SwDocShell::GetStyleFamilyBitmap( SfxStyleFamily eFamily, BmpColorMode eColorMode ) 1295 { 1296 if( SFX_STYLE_FAMILY_PSEUDO == eFamily ) 1297 { 1298 if ( eColorMode == BMP_COLOR_NORMAL ) 1299 return Bitmap( SW_RES( BMP_STYLES_FAMILY_NUM )); 1300 else 1301 return Bitmap( SW_RES( BMP_STYLES_FAMILY_NUM_HC )); 1302 } 1303 1304 return SfxObjectShell::GetStyleFamilyBitmap( eFamily, eColorMode ); 1305 } 1306 1307 1308 1309