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