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