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_sfx2.hxx" 26 27 #ifndef _MENU_HXX //autogen 28 #include <vcl/menu.hxx> 29 #endif 30 #include <svl/intitem.hxx> 31 #include <svl/stritem.hxx> 32 #include <svl/style.hxx> 33 #ifndef GCC 34 #endif 35 36 #define _SVSTDARR_STRINGSDTOR 37 #include <svl/svstdarr.hxx> 38 #include <comphelper/processfactory.hxx> 39 #include <comphelper/sequenceashashmap.hxx> 40 #include <unotools/intlwrapper.hxx> 41 #include <comphelper/processfactory.hxx> 42 #include <com/sun/star/container/XNameAccess.hpp> 43 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 44 #include <com/sun/star/beans/PropertyValue.hpp> 45 #include <com/sun/star/frame/XModuleManager.hpp> 46 47 #include "sfx2/sfxhelp.hxx" 48 #include <sfx2/app.hxx> 49 #include <sfx2/dispatch.hxx> 50 #include <sfx2/bindings.hxx> 51 #include <sfx2/templdlg.hxx> 52 #include "templdgi.hxx" 53 #include "tplcitem.hxx" 54 #include "sfxtypes.hxx" 55 #include <sfx2/styfitem.hxx> 56 #include <sfx2/objsh.hxx> 57 #include <sfx2/viewsh.hxx> 58 #include <sfx2/newstyle.hxx> 59 #include "sfx2/tplpitem.hxx" 60 #include "sfx2/sfxresid.hxx" 61 62 #include "templdlg.hrc" 63 #include <sfx2/sfx.hrc> 64 #include "dialog.hrc" 65 #include "arrdecl.hxx" 66 #include "fltfnc.hxx" 67 #include <sfx2/docfilt.hxx> 68 #include <sfx2/docfac.hxx> 69 #include "docvor.hxx" 70 #include <sfx2/doctempl.hxx> 71 #include <sfx2/module.hxx> 72 #include "sfx2/imgmgr.hxx" 73 #include "helpid.hrc" 74 #include "appdata.hxx" 75 #include <sfx2/viewfrm.hxx> 76 77 #include <comphelper/configurationhelper.hxx> 78 79 using namespace ::com::sun::star; 80 using namespace ::com::sun::star::beans; 81 using namespace ::com::sun::star::frame; 82 using namespace ::com::sun::star::uno; 83 84 //========================================================================= 85 86 // Fenster wird ab jetzt dynamisch erstellt. Daher hier R"ander usw. 87 88 #define SFX_TEMPLDLG_HFRAME 3 89 #define SFX_TEMPLDLG_VTOPFRAME 3 90 91 #define SFX_TEMPLDLG_VBOTFRAME 3 92 #define SFX_TEMPLDLG_MIDHSPACE 3 93 #define SFX_TEMPLDLG_MIDVSPACE 3 94 #define SFX_TEMPLDLG_FILTERHEIGHT 100 95 96 static sal_uInt16 nLastItemId = USHRT_MAX; 97 98 // filter box has maximum 12 entries visible 99 #define MAX_FILTER_ENTRIES 12 100 101 #define SFX_TEMPLDLG_FILTER_MAX 0xFFFF 102 #define SFX_TEMPLDLG_FILTER_HIERARCHICAL 0xFFFE 103 104 //========================================================================= 105 106 TYPEINIT0(SfxCommonTemplateDialog_Impl); 107 TYPEINIT1(SfxTemplateDialog_Impl,SfxCommonTemplateDialog_Impl); 108 TYPEINIT1(SfxTemplateCatalog_Impl,SfxCommonTemplateDialog_Impl); 109 110 SFX_IMPL_DOCKINGWINDOW(SfxTemplateDialogWrapper, SID_STYLE_DESIGNER) 111 112 //------------------------------------------------------------------------- 113 114 // Redirektionsfunktionen 115 116 SfxTemplateDialog::SfxTemplateDialog 117 ( 118 SfxBindings *pBind, 119 SfxChildWindow *pCW, 120 Window *pParent 121 ) 122 123 /* [Beschreibung] 124 Gestalterklasse. 125 */ 126 : SfxDockingWindow( pBind, pCW, pParent, SfxResId(DLG_STYLE_DESIGNER) ), 127 128 pImpl( new SfxTemplateDialog_Impl( pParent, pBind, this ) ) 129 130 { 131 pImpl->updateNonFamilyImages(); 132 } 133 134 //------------------------------------------------------------------------- 135 136 SfxTemplateDialog::~SfxTemplateDialog() 137 { 138 delete pImpl; 139 } 140 141 ISfxTemplateCommon* SfxTemplateDialog::GetISfxTemplateCommon() 142 { 143 return pImpl->GetISfxTemplateCommon(); 144 } 145 146 void SfxTemplateDialog::SetParagraphFamily() 147 { 148 // first select the paragraph family 149 pImpl->FamilySelect( SFX_STYLE_FAMILY_PARA ); 150 // then select the automatic filter 151 pImpl->SetAutomaticFilter(); 152 } 153 154 // ------------------------------------------------------------------------ 155 156 void SfxTemplateDialog::DataChanged( const DataChangedEvent& _rDCEvt ) 157 { 158 if ( ( DATACHANGED_SETTINGS == _rDCEvt.GetType() ) && 159 ( 0 != ( SETTINGS_STYLE & _rDCEvt.GetFlags() ) ) ) 160 { 161 pImpl->updateFamilyImages(); 162 pImpl->updateNonFamilyImages(); 163 } 164 165 SfxDockingWindow::DataChanged( _rDCEvt ); 166 } 167 168 //------------------------------------------------------------------------- 169 170 void SfxTemplateDialog::Update() 171 { 172 pImpl->Update(); 173 } 174 175 //------------------------------------------------------------------------- 176 177 void SfxTemplateDialog::Resize() 178 { 179 if(pImpl) 180 pImpl->Resize(); 181 SfxDockingWindow::Resize(); 182 } 183 184 185 //------------------------------------------------------------------------- 186 187 SfxChildAlignment SfxTemplateDialog::CheckAlignment(SfxChildAlignment eActAlign,SfxChildAlignment eAlign) 188 { 189 switch (eAlign) 190 { 191 case SFX_ALIGN_TOP: 192 case SFX_ALIGN_HIGHESTTOP: 193 case SFX_ALIGN_LOWESTTOP: 194 case SFX_ALIGN_BOTTOM: 195 case SFX_ALIGN_LOWESTBOTTOM: 196 case SFX_ALIGN_HIGHESTBOTTOM: 197 return eActAlign; 198 199 case SFX_ALIGN_LEFT: 200 case SFX_ALIGN_RIGHT: 201 case SFX_ALIGN_FIRSTLEFT: 202 case SFX_ALIGN_LASTLEFT: 203 case SFX_ALIGN_FIRSTRIGHT: 204 case SFX_ALIGN_LASTRIGHT: 205 return eAlign; 206 207 default: 208 return eAlign; 209 } 210 } 211 212 //------------------------------------------------------------------------- 213 214 SfxTemplateCatalog::SfxTemplateCatalog(Window *pParent, SfxBindings *pBindings) 215 : SfxModalDialog(pParent,SfxResId(RID_STYLECATALOG)) 216 { 217 pImpl = new SfxTemplateCatalog_Impl(pParent, pBindings, this); 218 } 219 220 //------------------------------------------------------------------------- 221 222 SfxTemplateCatalog::~SfxTemplateCatalog() 223 { 224 delete pImpl; 225 } 226 227 //------------------------------------------------------------------------- 228 229 void DropListBox_Impl::MouseButtonDown( const MouseEvent& rMEvt ) 230 { 231 nModifier = rMEvt.GetModifier(); 232 233 sal_Bool bHitEmptySpace = ( NULL == GetEntry( rMEvt.GetPosPixel(), sal_True ) ); 234 if( bHitEmptySpace && ( rMEvt.GetClicks() == 2 ) && rMEvt.IsMod1() ) 235 Control::MouseButtonDown( rMEvt ); 236 else 237 SvTreeListBox::MouseButtonDown( rMEvt ); 238 } 239 240 sal_Int8 DropListBox_Impl::AcceptDrop( const AcceptDropEvent& rEvt ) 241 242 /* [Description: ] 243 Drop is enabled as long as it is allowed to create a new style by example, i.e. to 244 create a style out of the current selection. 245 */ 246 247 { 248 if ( IsDropFormatSupported( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) ) 249 { 250 // special case: page styles are allowed to create new styles by example 251 // but not allowed to be created by drag and drop 252 if( pDialog->nActFamily == SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SFX_STYLE_FAMILY_PAGE ) || 253 pDialog->bNewByExampleDisabled ) 254 return DND_ACTION_NONE; 255 else 256 return DND_ACTION_COPY; 257 } 258 return SvTreeListBox::AcceptDrop( rEvt ); 259 } 260 261 //------------------------------------------------------------------------- 262 263 sal_Int8 DropListBox_Impl::ExecuteDrop( const ExecuteDropEvent& rEvt ) 264 { 265 // rEvt.maDropEvent.Context->acceptDrop( DND_ACTION_NONE ); 266 // rEvt.maDropEvent.Context->dropComplete( sal_True ); 267 268 sal_Int8 nRet = DND_ACTION_NONE; 269 SfxObjectShell* pDocShell = pDialog->GetObjectShell(); 270 TransferableDataHelper aHelper( rEvt.maDropEvent.Transferable ); 271 sal_uInt32 nFormatCount = aHelper.GetFormatCount(); 272 if ( pDocShell ) 273 { 274 sal_Bool bFormatFound = sal_False; 275 276 for ( sal_uInt32 i = 0; i < nFormatCount; ++i ) 277 { 278 SotFormatStringId nId = aHelper.GetFormat(i); 279 TransferableObjectDescriptor aDesc; 280 281 if ( aHelper.GetTransferableObjectDescriptor( nId, aDesc ) ) 282 { 283 if ( aDesc.maClassName == pDocShell->GetFactory().GetClassId() ) 284 { 285 PostUserEvent( LINK( this, DropListBox_Impl, OnAsyncExecuteDrop ), 0 ); 286 287 bFormatFound = sal_True; 288 nRet = rEvt.mnAction; 289 break; 290 } 291 } 292 } 293 294 if ( !bFormatFound ) 295 return SvTreeListBox::ExecuteDrop( rEvt ); 296 } 297 298 return nRet; 299 } 300 301 302 IMPL_LINK( DropListBox_Impl, OnAsyncExecuteDrop, SvLBoxEntry*, EMPTYARG ) 303 { 304 pDialog->ActionSelect( SID_STYLE_NEW_BY_EXAMPLE ); 305 return 0; 306 } 307 308 309 IMPL_LINK( DropListBox_Impl, OnAsyncExecuteError, void*, NOTINTERESTEDIN ) 310 { 311 (void)NOTINTERESTEDIN; // unused 312 ErrorHandler::HandleError( ERRCODE_IO_WRONGFORMAT ); 313 314 return 0; 315 } 316 317 318 long DropListBox_Impl::Notify( NotifyEvent& rNEvt ) 319 { 320 long nRet = 0; 321 if( rNEvt.GetType() == EVENT_KEYINPUT ) 322 { 323 const KeyCode& rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode(); 324 if(!rKeyCode.GetModifier()) 325 { 326 if( pDialog->bCanDel && KEY_DELETE == rKeyCode.GetCode()) 327 { 328 pDialog->DeleteHdl( NULL ); 329 nRet = 1; 330 } 331 else if( KEY_RETURN == rKeyCode.GetCode()) 332 { 333 GetDoubleClickHdl().Call(this); 334 nRet = 1; 335 } 336 } 337 } 338 if(!nRet) 339 nRet = SvTreeListBox::Notify( rNEvt ); 340 return nRet; 341 } 342 343 344 //------------------------------------------------------------------------- 345 346 347 SfxActionListBox::SfxActionListBox 348 ( 349 SfxCommonTemplateDialog_Impl* pParent, 350 WinBits nWinBits 351 ) 352 353 /* [Beschreibung] 354 355 ListBox- Klasse, die im Command-Handler ein PopupMenu (Gestalter 356 spezifisch) startet. 357 358 */ 359 360 : DropListBox_Impl(pParent->GetWindow(), nWinBits, pParent) 361 362 { 363 EnableContextMenuHandling(); 364 } 365 366 //------------------------------------------------------------------------- 367 368 SfxActionListBox::SfxActionListBox( SfxCommonTemplateDialog_Impl* pParent, 369 const ResId &rResId) : 370 DropListBox_Impl(pParent->GetWindow(), rResId, pParent) 371 { 372 EnableContextMenuHandling(); 373 } 374 375 //------------------------------------------------------------------------- 376 377 PopupMenu* SfxActionListBox::CreateContextMenu( void ) 378 { 379 //added by BerryJia for fixing Bug102739 2002-9-9 17:00(Beijing Time) 380 if( !( GetSelectionCount() > 0 ) ) 381 { 382 pDialog->EnableEdit( sal_False ); 383 pDialog->EnableDel( sal_False ); 384 } 385 return pDialog->CreateContextMenu(); 386 } 387 388 //------------------------------------------------------------------------- 389 390 SfxTemplateDialogWrapper::SfxTemplateDialogWrapper(Window *pParentWnd, 391 sal_uInt16 nId, SfxBindings *p, SfxChildWinInfo *pInfo) : 392 SfxChildWindow(pParentWnd, nId) 393 { 394 SfxTemplateDialog *pWin = new SfxTemplateDialog(p, this, pParentWnd); 395 pWindow = pWin; 396 eChildAlignment = SFX_ALIGN_NOALIGNMENT; 397 398 pWin->Initialize( pInfo ); 399 pWin->SetMinOutputSizePixel(pWin->pImpl->GetMinOutputSizePixel()); 400 } 401 402 void SfxTemplateDialogWrapper::SetParagraphFamily() 403 { 404 // forward to SfxTemplateDialog, because SfxTemplateDialog isn't exported 405 static_cast< SfxTemplateDialog* >( GetWindow() )->SetParagraphFamily(); 406 } 407 408 //========================================================================= 409 SV_DECL_PTRARR_DEL(ExpandedEntries, StringPtr,16,8) 410 SV_IMPL_PTRARR(ExpandedEntries, StringPtr) 411 412 /* [Beschreibung] 413 414 TreeListBox- Klasse f"ur die Anzeige der hierarchischen View 415 der Vorlagen 416 417 */ 418 419 class StyleTreeListBox_Impl : public DropListBox_Impl 420 { 421 private: 422 SvLBoxEntry* pCurEntry; 423 SfxCommonTemplateDialog_Impl* pCommon; 424 Link aDoubleClickLink; 425 Link aDropLink; 426 String aParent; 427 String aStyle; 428 429 protected: 430 virtual void Command( const CommandEvent& rMEvt ); 431 virtual long Notify( NotifyEvent& rNEvt ); 432 virtual sal_Bool DoubleClickHdl(); 433 virtual long ExpandingHdl(); 434 virtual void ExpandedHdl(); 435 virtual sal_Bool NotifyMoving(SvLBoxEntry* pTarget, 436 SvLBoxEntry* pEntry, 437 SvLBoxEntry*& rpNewParent, 438 sal_uIntPtr& rNewChildPos); 439 public: 440 StyleTreeListBox_Impl( SfxCommonTemplateDialog_Impl* pParent, WinBits nWinStyle = 0); 441 442 void SetDoubleClickHdl(const Link &rLink) { aDoubleClickLink = rLink; } 443 void SetDropHdl(const Link &rLink) { aDropLink = rLink; } 444 using SvLBox::GetParent; 445 const String& GetParent() const { return aParent; } 446 const String& GetStyle() const { return aStyle; } 447 void MakeExpanded_Impl(ExpandedEntries& rEntries) const; 448 449 virtual PopupMenu* CreateContextMenu( void ); 450 }; 451 452 //------------------------------------------------------------------------- 453 454 455 void StyleTreeListBox_Impl::MakeExpanded_Impl(ExpandedEntries& rEntries) const 456 { 457 SvLBoxEntry *pEntry; 458 sal_uInt16 nCount=0; 459 for(pEntry=(SvLBoxEntry*)FirstVisible();pEntry;pEntry=(SvLBoxEntry*)NextVisible(pEntry)) 460 { 461 if(IsExpanded(pEntry)) 462 { 463 StringPtr pString=new String(GetEntryText(pEntry)); 464 rEntries.Insert(pString,nCount++); 465 } 466 } 467 } 468 469 PopupMenu* StyleTreeListBox_Impl::CreateContextMenu() 470 { 471 return pDialog->CreateContextMenu(); 472 } 473 474 sal_Bool StyleTreeListBox_Impl::DoubleClickHdl() 475 476 /* [Beschreibung] 477 478 479 DoubleClick-Handler; ruft entsprechenden Link. 480 Virtuelle Methode aus SV. 481 482 */ 483 { 484 aDoubleClickLink.Call(this); 485 return sal_False; 486 } 487 488 //------------------------------------------------------------------------- 489 490 void StyleTreeListBox_Impl::Command( const CommandEvent& rCEvt ) 491 492 /* [Beschreibung] 493 494 Command Handler; dieser executed ein PopupMenu (Gestalter 495 spezifisch). 496 Virtuelle Methode aus SV. 497 498 */ 499 { 500 SvTreeListBox::Command(rCEvt); 501 } 502 503 //------------------------------------------------------------------------- 504 505 long StyleTreeListBox_Impl::Notify( NotifyEvent& rNEvt ) 506 { 507 // handle <RETURN> as double click 508 509 long nRet = 0; 510 if ( rNEvt.GetType() == EVENT_KEYINPUT ) 511 { 512 const KeyCode& rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode(); 513 if ( !rKeyCode.GetModifier() && KEY_RETURN == rKeyCode.GetCode() ) 514 { 515 aDoubleClickLink.Call( this ); 516 nRet = 1; 517 } 518 } 519 520 if ( !nRet ) 521 nRet = DropListBox_Impl::Notify( rNEvt ); 522 523 return nRet; 524 } 525 526 //------------------------------------------------------------------------- 527 528 sal_Bool StyleTreeListBox_Impl::NotifyMoving(SvLBoxEntry* pTarget, 529 SvLBoxEntry* pEntry, 530 SvLBoxEntry*& rpNewParent, 531 sal_uIntPtr& lPos) 532 /* [Beschreibung] 533 534 NotifyMoving Handler; dieser leitet per Link das Event an den Dialog 535 weiter. 536 Virtuelle Methode aus SV. 537 538 */ 539 { 540 if(!pTarget || !pEntry) 541 return sal_False; 542 aParent = GetEntryText(pTarget); 543 aStyle = GetEntryText(pEntry); 544 const sal_Bool bRet = (sal_Bool)aDropLink.Call(this); 545 rpNewParent = pTarget; 546 lPos=0; 547 IntlWrapper aIntlWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() ); 548 const CollatorWrapper* pCollator = aIntlWrapper.getCaseCollator(); 549 for(SvLBoxEntry *pTmpEntry=FirstChild(pTarget); 550 pTmpEntry && COMPARE_LESS==pCollator->compareString( 551 GetEntryText(pTmpEntry),GetEntryText(pEntry)); 552 pTmpEntry=NextSibling(pTmpEntry),lPos++) ; 553 554 return bRet? (sal_Bool)2: sal_False; 555 } 556 557 //------------------------------------------------------------------------- 558 559 long StyleTreeListBox_Impl::ExpandingHdl() 560 561 /* [Beschreibung] 562 563 ExpandingHdl Handler; der aktuelle Eintrag wird gemerkt. 564 Virtuelle Methode aus SV. 565 566 [Querverweise] 567 <StyleTreeListBox_Impl::ExpandedHdl()> 568 569 */ 570 { 571 pCurEntry = GetCurEntry(); 572 return sal_True; 573 } 574 575 //------------------------------------------------------------------------- 576 577 void StyleTreeListBox_Impl::ExpandedHdl() 578 579 /* [Beschreibung] 580 581 ExpandedHdl Handler; 582 Virtuelle Methode aus SV. 583 584 [Querverweise] 585 <StyleTreeListBox_Impl::ExpandingHdl()> 586 587 */ 588 589 { 590 SvLBoxEntry *pEntry = GetHdlEntry(); 591 if(!IsExpanded(pEntry) && pCurEntry != GetCurEntry()) 592 SelectAll( sal_False ); 593 pCurEntry = 0; 594 } 595 596 //------------------------------------------------------------------------- 597 598 StyleTreeListBox_Impl::StyleTreeListBox_Impl( 599 SfxCommonTemplateDialog_Impl* pParent, WinBits nWinStyle) : 600 DropListBox_Impl(pParent->GetWindow(), nWinStyle, pParent), 601 pCurEntry(0), 602 pCommon(pParent) 603 604 /* [Beschreibung] 605 606 Konstruktor StyleTreeListBox_Impl 607 608 */ 609 { 610 EnableContextMenuHandling(); 611 } 612 613 //------------------------------------------------------------------------- 614 //------------------------------------------------------------------------- 615 616 class StyleTreeArr_Impl; 617 618 619 /* [Beschreibung] 620 621 Interne Struktur f"ur den Aufbau der hierarchischen View 622 623 */ 624 625 struct StyleTree_Impl 626 { 627 String aName; 628 String aParent; 629 StyleTreeArr_Impl *pChilds; 630 sal_Bool bIsExpanded; 631 sal_Bool HasParent() const { return aParent.Len() != 0; } 632 633 StyleTree_Impl(const String &rName, const String &rParent): 634 aName(rName), aParent(rParent), pChilds(0), bIsExpanded(0) {} 635 ~StyleTree_Impl(); 636 void Put(StyleTree_Impl* pIns, sal_uIntPtr lPos=ULONG_MAX); 637 sal_uIntPtr Count(); 638 }; 639 640 typedef StyleTree_Impl* StyleTree_ImplPtr; 641 SV_DECL_PTRARR_DEL(StyleTreeArr_Impl, StyleTree_ImplPtr, 16, 8) 642 SV_IMPL_PTRARR(StyleTreeArr_Impl, StyleTree_ImplPtr) 643 644 645 sal_uIntPtr StyleTree_Impl::Count() 646 { 647 return pChilds ? pChilds->Count() : 0L; 648 } 649 650 //------------------------------------------------------------------------- 651 652 StyleTree_Impl::~StyleTree_Impl() 653 { 654 delete pChilds; 655 } 656 657 //------------------------------------------------------------------------- 658 659 void StyleTree_Impl::Put(StyleTree_Impl* pIns, sal_uIntPtr lPos) 660 { 661 if ( !pChilds ) 662 pChilds = new StyleTreeArr_Impl; 663 664 if ( ULONG_MAX == lPos ) 665 lPos = pChilds->Count(); 666 pChilds->Insert( pIns, (sal_uInt16)lPos ); 667 } 668 669 //------------------------------------------------------------------------- 670 671 StyleTreeArr_Impl &MakeTree_Impl(StyleTreeArr_Impl &rArr) 672 { 673 const sal_uInt16 nCount = rArr.Count(); 674 // Alle unter ihren Parents einordnen 675 sal_uInt16 i; 676 for(i = 0; i < nCount; ++i) 677 { 678 StyleTree_ImplPtr pEntry = rArr[i]; 679 if(pEntry->HasParent()) 680 { 681 for(sal_uInt16 j = 0; j < nCount; ++j) 682 { 683 StyleTree_ImplPtr pCmp = rArr[j]; 684 if(pCmp->aName == pEntry->aParent) 685 { 686 // initial sortiert einfuegen 687 sal_uInt16 ii; 688 IntlWrapper aIntlWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() ); 689 const CollatorWrapper* pCollator = aIntlWrapper.getCaseCollator(); 690 for ( ii = 0; 691 ii < pCmp->Count() && COMPARE_LESS == 692 pCollator->compareString( (*pCmp->pChilds)[ii]->aName, 693 pEntry->aName);++ii) ; 694 pCmp->Put(pEntry,ii); 695 break; 696 } 697 } 698 } 699 } 700 // alle, die schon unter ihrem Parent eingeordnet wurden 701 // entfernen 702 for(i = 0; i < rArr.Count(); ) 703 { 704 if(rArr[i]->HasParent()) 705 rArr.Remove(i); 706 else 707 ++i; 708 } 709 return rArr; 710 } 711 712 //------------------------------------------------------------------------- 713 714 715 inline sal_Bool IsExpanded_Impl( const ExpandedEntries& rEntries, 716 const String &rStr) 717 { 718 sal_uInt16 nCount=rEntries.Count(); 719 for(sal_uInt16 n=0;n<nCount;n++) 720 if(*rEntries[n]==rStr) 721 return sal_True; 722 return sal_False; 723 } 724 725 726 727 SvLBoxEntry* FillBox_Impl(SvTreeListBox *pBox, 728 StyleTree_ImplPtr pEntry, 729 const ExpandedEntries& rEntries, 730 SvLBoxEntry* pParent = 0) 731 { 732 SvLBoxEntry* pNewEntry = pBox->InsertEntry(pEntry->aName, pParent); 733 const sal_uInt16 nCount = pEntry->pChilds? pEntry->pChilds->Count(): 0; 734 for(sal_uInt16 i = 0; i < nCount; ++i) 735 FillBox_Impl(pBox, (*pEntry->pChilds)[i], rEntries, pNewEntry); 736 return pNewEntry; 737 } 738 739 //------------------------------------------------------------------------- 740 741 // Konstruktor 742 743 SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, SfxDockingWindow* pW ) : 744 745 aISfxTemplateCommon ( this ), 746 pBindings ( pB ), 747 pWindow ( pW ), 748 pModule ( NULL ), 749 pTimer ( NULL ), 750 m_pStyleFamiliesId ( NULL ), 751 pStyleSheetPool ( NULL ), 752 pTreeBox ( NULL ), 753 pCurObjShell ( NULL ), 754 xModuleManager ( ::comphelper::getProcessServiceFactory()->createInstance( 755 DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), UNO_QUERY ), 756 pbDeleted ( NULL ), 757 758 aFmtLb ( this, WB_BORDER | WB_TABSTOP | WB_SORT | WB_QUICK_SEARCH ), 759 aFilterLb ( pW, WB_BORDER | WB_DROPDOWN | WB_TABSTOP ), 760 761 nActFamily ( SFX_TEMPLDLG_FILTER_MAX ), 762 nActFilter ( 0 ), 763 nAppFilter ( 0 ), 764 765 bDontUpdate ( sal_False ), 766 bIsWater ( sal_False ), 767 bEnabled ( sal_True ), 768 bUpdate ( sal_False ), 769 bUpdateFamily ( sal_False ), 770 bCanEdit ( sal_False ), 771 bCanDel ( sal_False ), 772 bCanNew ( sal_True ), 773 bWaterDisabled ( sal_False ), 774 bNewByExampleDisabled ( sal_False ), 775 bUpdateByExampleDisabled( sal_False ), 776 bTreeDrag ( sal_True ), 777 bHierarchical ( sal_False ), 778 bBindingUpdate ( sal_True ) 779 { 780 aFmtLb.SetAccessibleName(SfxResId(STR_STYLE_ELEMTLIST)); 781 aFmtLb.SetHelpId( HID_TEMPLATE_FMT ); 782 aFilterLb.SetHelpId( HID_TEMPLATE_FILTER ); 783 aFmtLb.SetStyle( aFmtLb.GetStyle() | WB_SORT | WB_HIDESELECTION ); 784 Font aFont = aFmtLb.GetFont(); 785 aFont.SetWeight( WEIGHT_NORMAL ); 786 aFmtLb.SetFont( aFont ); 787 } 788 789 //------------------------------------------------------------------------- 790 791 SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, ModalDialog* pW ) : 792 793 aISfxTemplateCommon ( this ), 794 pBindings ( pB ), 795 pWindow ( pW ), 796 pModule ( NULL ), 797 pTimer ( NULL ), 798 pStyleSheetPool ( NULL ), 799 pTreeBox ( NULL ), 800 pCurObjShell ( NULL ), 801 pbDeleted ( NULL ), 802 803 aFmtLb ( this, SfxResId( BT_VLIST ) ), 804 aFilterLb ( pW, SfxResId( BT_FLIST ) ), 805 806 nActFamily ( SFX_TEMPLDLG_FILTER_MAX ), 807 nActFilter ( 0 ), 808 nAppFilter ( 0 ), 809 810 bDontUpdate ( sal_False ), 811 bIsWater ( sal_False ), 812 bEnabled ( sal_True ), 813 bUpdate ( sal_False ), 814 bUpdateFamily ( sal_False ), 815 bCanEdit ( sal_False ), 816 bCanDel ( sal_False ), 817 bCanNew ( sal_True ), 818 bWaterDisabled ( sal_False ), 819 bNewByExampleDisabled ( sal_False ), 820 bUpdateByExampleDisabled( sal_False ), 821 bTreeDrag ( sal_True ), 822 bHierarchical ( sal_False ), 823 bBindingUpdate ( sal_True ) 824 825 { 826 aFmtLb.SetStyle( aFmtLb.GetStyle() | WB_SORT ); 827 } 828 829 //------------------------------------------------------------------------- 830 831 sal_uInt16 SfxCommonTemplateDialog_Impl::StyleNrToInfoOffset(sal_uInt16 nId) 832 { 833 const SfxStyleFamilyItem *pItem=pStyleFamilies->GetObject(nId); 834 return SfxFamilyIdToNId(pItem->GetFamily())-1; 835 } 836 837 //------------------------------------------------------------------------- 838 839 void SfxTemplateDialog_Impl::EnableEdit(sal_Bool bEnable) 840 { 841 SfxCommonTemplateDialog_Impl::EnableEdit( bEnable ); 842 if( !bEnable || !bUpdateByExampleDisabled ) 843 EnableItem( SID_STYLE_UPDATE_BY_EXAMPLE, bEnable); 844 } 845 846 //------------------------------------------------------------------------- 847 848 849 sal_uInt16 SfxCommonTemplateDialog_Impl::InfoOffsetToStyleNr(sal_uInt16 nId) 850 { 851 for ( sal_uInt16 i=0;i<pStyleFamilies->Count();i++ ) 852 if ( SfxFamilyIdToNId(pStyleFamilies->GetObject(i)->GetFamily()) == nId+1 ) 853 return i; 854 DBG_ERROR("Style Nummer nicht gefunden"); 855 return 0; 856 } 857 858 859 //------------------------------------------------------------------------- 860 861 void SfxCommonTemplateDialog_Impl::ReadResource() 862 { 863 // globale Benutzer-Resource auslesen 864 sal_uInt16 i; 865 for(i = 0; i < MAX_FAMILIES; ++i) 866 pFamilyState[i] = 0; 867 868 SfxViewFrame* pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame(); 869 pCurObjShell = pViewFrame->GetObjectShell(); 870 ResMgr* pMgr = pCurObjShell ? pCurObjShell->GetResMgr() : NULL; 871 ResId aFamId( DLG_STYLE_DESIGNER, *pMgr ); 872 aFamId.SetRT(RSC_SFX_STYLE_FAMILIES); 873 m_pStyleFamiliesId = new ResId( aFamId.GetId(), *pMgr ); 874 m_pStyleFamiliesId->SetRT(RSC_SFX_STYLE_FAMILIES); 875 if( !pMgr || !pMgr->IsAvailable( aFamId ) ) 876 pStyleFamilies = new SfxStyleFamilies; 877 else 878 pStyleFamilies = new SfxStyleFamilies( aFamId ); 879 880 nActFilter = pCurObjShell ? 881 static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pCurObjShell ) ) : 882 SFX_TEMPLDLG_FILTER_MAX; 883 if ( pCurObjShell && SFX_TEMPLDLG_FILTER_MAX == nActFilter ) 884 nActFilter = pCurObjShell->GetAutoStyleFilterIndex(); 885 886 // Einfuegen in die Toolbox 887 // umgekehrte Reihenfolge, da immer vorne eingefuegt wird. 888 sal_uInt16 nCount = pStyleFamilies->Count(); 889 890 pBindings->ENTERREGISTRATIONS(); 891 892 for(i = 0; i < nCount; ++i) 893 { 894 sal_uInt16 nSlot = 0; 895 switch((sal_uInt16)pStyleFamilies->GetObject(i)->GetFamily()) 896 { 897 case SFX_STYLE_FAMILY_CHAR: nSlot = SID_STYLE_FAMILY1; break; 898 case SFX_STYLE_FAMILY_PARA: nSlot = SID_STYLE_FAMILY2; break; 899 case SFX_STYLE_FAMILY_FRAME:nSlot = SID_STYLE_FAMILY3; break; 900 case SFX_STYLE_FAMILY_PAGE: nSlot = SID_STYLE_FAMILY4; break; 901 case SFX_STYLE_FAMILY_PSEUDO: nSlot = SID_STYLE_FAMILY5; break; 902 default: DBG_ERROR("unbekannte StyleFamily"); break; 903 } 904 pBoundItems[i] = 905 new SfxTemplateControllerItem(nSlot, *this, *pBindings); 906 } 907 pBoundItems[i++] = new SfxTemplateControllerItem( 908 SID_STYLE_WATERCAN, *this, *pBindings); 909 pBoundItems[i++] = new SfxTemplateControllerItem( 910 SID_STYLE_NEW_BY_EXAMPLE, *this, *pBindings); 911 pBoundItems[i++] = new SfxTemplateControllerItem( 912 SID_STYLE_UPDATE_BY_EXAMPLE, *this, *pBindings); 913 pBoundItems[i++] = new SfxTemplateControllerItem( 914 SID_STYLE_NEW, *this, *pBindings); 915 pBoundItems[i++] = new SfxTemplateControllerItem( 916 SID_STYLE_DRAGHIERARCHIE, *this, *pBindings); 917 pBoundItems[i++] = new SfxTemplateControllerItem( 918 SID_STYLE_EDIT, *this, *pBindings); 919 pBoundItems[i++] = new SfxTemplateControllerItem( 920 SID_STYLE_DELETE, *this, *pBindings); 921 pBoundItems[i++] = new SfxTemplateControllerItem( 922 SID_STYLE_FAMILY, *this, *pBindings); 923 pBindings->LEAVEREGISTRATIONS(); 924 925 for(; i < COUNT_BOUND_FUNC; ++i) 926 pBoundItems[i] = 0; 927 928 StartListening(*pBindings); 929 930 //In umgekehrter Reihenfolge des Auftretens in den Stylefamilies einfuegen. 931 //Das ist fuer den Toolbar des Gestalters. Die Listbox des Kataloges achtet 932 //selbst auf korrekte Reihenfolge. 933 934 //Reihenfolgen: Reihenfolge in der Resource = Reihenfolge in Toolbar bzw. 935 //Listbox. 936 //Reihenfolge aufsteigender SIDs: Niedrige SIDs werden als erstes angezeigt, 937 //wenn Vorlagen mehrerer Familien aktiv sind. 938 939 // in the Writer the UpdateStyleByExample Toolbox button is removed and 940 // the NewStyle button gets a PopupMenu 941 if(nCount > 4) 942 ReplaceUpdateButtonByMenu(); 943 944 for( ; nCount--; ) 945 { 946 const SfxStyleFamilyItem *pItem = pStyleFamilies->GetObject( nCount ); 947 sal_uInt16 nId = SfxFamilyIdToNId( pItem->GetFamily() ); 948 InsertFamilyItem( nId, pItem ); 949 } 950 951 LoadedFamilies(); 952 953 sal_uInt16 nStart = SID_STYLE_FAMILY1; 954 sal_uInt16 nEnd = SID_STYLE_FAMILY4; 955 956 for ( i = nStart; i <= nEnd; i++ ) 957 pBindings->Update(i); 958 959 pModule = pCurObjShell ? pCurObjShell->GetModule() : NULL; 960 } 961 962 //------------------------------------------------------------------------- 963 964 void SfxCommonTemplateDialog_Impl::ClearResource() 965 { 966 ClearFamilyList(); 967 DELETEX(pStyleFamilies); 968 sal_uInt16 i; 969 for ( i = 0; i < MAX_FAMILIES; ++i ) 970 DELETEX(pFamilyState[i]); 971 for ( i = 0; i < COUNT_BOUND_FUNC; ++i ) 972 delete pBoundItems[i]; 973 pCurObjShell = NULL; 974 975 DELETEZ( m_pStyleFamiliesId ); 976 } 977 978 //------------------------------------------------------------------------- 979 980 void SfxCommonTemplateDialog_Impl::Initialize() 981 { 982 // globale Benutzer-Resource auslesen 983 ReadResource(); 984 pBindings->Invalidate( SID_STYLE_FAMILY ); 985 pBindings->Update( SID_STYLE_FAMILY ); 986 Update_Impl(); 987 988 aFilterLb.SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, FilterSelectHdl ) ); 989 aFmtLb.SetDoubleClickHdl( LINK( this, SfxCommonTemplateDialog_Impl, ApplyHdl ) ); 990 aFmtLb.SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, FmtSelectHdl ) ); 991 992 aFilterLb.Show(); 993 aFmtLb.Show(); 994 } 995 996 //------------------------------------------------------------------------- 997 998 SfxCommonTemplateDialog_Impl::~SfxCommonTemplateDialog_Impl() 999 { 1000 String aEmpty; 1001 if ( bIsWater ) 1002 Execute_Impl(SID_STYLE_WATERCAN, aEmpty, aEmpty, 0); 1003 GetWindow()->Hide(); 1004 DELETEX(pStyleFamilies); 1005 DELETEZ( m_pStyleFamiliesId ); 1006 sal_uInt16 i; 1007 for ( i = 0; i < MAX_FAMILIES; ++i ) 1008 DELETEX(pFamilyState[i]); 1009 for ( i = 0; i < COUNT_BOUND_FUNC; ++i ) 1010 delete pBoundItems[i]; 1011 if ( pStyleSheetPool ) 1012 EndListening(*pStyleSheetPool); 1013 pStyleSheetPool = NULL; 1014 delete pTreeBox; 1015 delete pTimer; 1016 if ( pbDeleted ) 1017 { 1018 pbDeleted->bDead = true; 1019 pbDeleted = NULL; 1020 } 1021 } 1022 1023 //------------------------------------------------------------------------- 1024 1025 sal_uInt16 SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SfxStyleFamily nFamily ) 1026 { 1027 switch ( nFamily ) 1028 { 1029 case SFX_STYLE_FAMILY_CHAR: return 1; 1030 case SFX_STYLE_FAMILY_PARA: return 2; 1031 case SFX_STYLE_FAMILY_FRAME: return 3; 1032 case SFX_STYLE_FAMILY_PAGE: return 4; 1033 case SFX_STYLE_FAMILY_PSEUDO: return 5; 1034 default: return 0; 1035 } 1036 } 1037 1038 void SfxCommonTemplateDialog_Impl::SetAutomaticFilter() 1039 { 1040 sal_uInt16 nCount = aFilterLb.GetEntryCount(); 1041 for ( sal_uInt16 i = 0; i < nCount; ++i ) 1042 { 1043 sal_uIntPtr nFlags = (sal_uIntPtr)aFilterLb.GetEntryData(i); 1044 if ( SFXSTYLEBIT_AUTO == nFlags ) 1045 { 1046 // automatic entry found -> select it 1047 aFilterLb.SelectEntryPos(i); 1048 // then call the handler to filter the styles 1049 FilterSelect( i - 1 ); 1050 break; 1051 } 1052 } 1053 } 1054 1055 //------------------------------------------------------------------------- 1056 1057 // Hilfsfunktion: Zugriff auf aktuelles Family-Item 1058 const SfxStyleFamilyItem *SfxCommonTemplateDialog_Impl::GetFamilyItem_Impl() const 1059 { 1060 const sal_uInt16 nCount = pStyleFamilies->Count(); 1061 for(sal_uInt16 i = 0; i < nCount; ++i) 1062 { 1063 const SfxStyleFamilyItem *pItem = pStyleFamilies->GetObject(i); 1064 // if(!pItem)continue; 1065 sal_uInt16 nId = SfxFamilyIdToNId(pItem->GetFamily()); 1066 if(nId == nActFamily) 1067 return pItem; 1068 } 1069 return 0; 1070 } 1071 1072 //------------------------------------------------------------------------- 1073 1074 void SfxCommonTemplateDialog_Impl::SelectStyle(const String &rStr) 1075 { 1076 const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl(); 1077 if ( !pItem ) 1078 return; 1079 const SfxStyleFamily eFam = pItem->GetFamily(); 1080 SfxStyleSheetBase* pStyle = pStyleSheetPool->Find( rStr, eFam, SFXSTYLEBIT_ALL ); 1081 if( pStyle ) 1082 EnableEdit( !(pStyle->GetMask() & SFXSTYLEBIT_READONLY) ); 1083 else 1084 EnableEdit(sal_False); 1085 1086 if ( pTreeBox ) 1087 { 1088 if ( rStr.Len() ) 1089 { 1090 SvLBoxEntry* pEntry = pTreeBox->First(); 1091 while ( pEntry ) 1092 { 1093 if ( pTreeBox->GetEntryText( pEntry ) == rStr ) 1094 { 1095 pTreeBox->MakeVisible( pEntry ); 1096 pTreeBox->Select( pEntry ); 1097 return; 1098 } 1099 pEntry = pTreeBox->Next( pEntry ); 1100 } 1101 } 1102 else 1103 pTreeBox->SelectAll( sal_False ); 1104 } 1105 else 1106 { 1107 sal_Bool bSelect = ( rStr.Len() > 0 ); 1108 if ( bSelect ) 1109 { 1110 SvLBoxEntry* pEntry = (SvLBoxEntry*)aFmtLb.FirstVisible(); 1111 while ( pEntry && aFmtLb.GetEntryText( pEntry ) != rStr ) 1112 pEntry = (SvLBoxEntry*)aFmtLb.NextVisible( pEntry ); 1113 if ( !pEntry ) 1114 bSelect = sal_False; 1115 else 1116 { 1117 aFmtLb.MakeVisible( pEntry ); 1118 aFmtLb.Select( pEntry ); 1119 bWaterDisabled = !HasSelectedStyle(); //added by BerryJia for fixing Bug76391 2003-1-22 1120 FmtSelectHdl( NULL ); 1121 } 1122 } 1123 1124 if ( !bSelect ) 1125 { 1126 aFmtLb.SelectAll( sal_False ); 1127 EnableEdit(sal_False); 1128 } 1129 } 1130 } 1131 1132 //------------------------------------------------------------------------- 1133 1134 String SfxCommonTemplateDialog_Impl::GetSelectedEntry() const 1135 { 1136 String aRet; 1137 if ( pTreeBox ) 1138 { 1139 SvLBoxEntry* pEntry = pTreeBox->FirstSelected(); 1140 if ( pEntry ) 1141 aRet = pTreeBox->GetEntryText( pEntry ); 1142 } 1143 else 1144 { 1145 SvLBoxEntry* pEntry = aFmtLb.FirstSelected(); 1146 if ( pEntry ) 1147 aRet = aFmtLb.GetEntryText( pEntry ); 1148 } 1149 return aRet; 1150 } 1151 1152 //------------------------------------------------------------------------- 1153 1154 void SfxCommonTemplateDialog_Impl::EnableTreeDrag( sal_Bool bEnable ) 1155 { 1156 if ( pStyleSheetPool ) 1157 { 1158 SfxStyleSheetBase* pStyle = pStyleSheetPool->First(); 1159 if ( pTreeBox ) 1160 { 1161 if ( pStyle && pStyle->HasParentSupport() && bEnable ) 1162 pTreeBox->SetDragDropMode(SV_DRAGDROP_CTRL_MOVE); 1163 else 1164 pTreeBox->SetDragDropMode(SV_DRAGDROP_NONE); 1165 } 1166 } 1167 bTreeDrag = bEnable; 1168 } 1169 1170 //------------------------------------------------------------------------- 1171 1172 void SfxCommonTemplateDialog_Impl::FillTreeBox() 1173 { 1174 DBG_ASSERT( pTreeBox, "FillTreeBox() without treebox"); 1175 if(pStyleSheetPool && nActFamily != SFX_TEMPLDLG_FILTER_MAX) 1176 { 1177 const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); 1178 pStyleSheetPool->SetSearchMask(pItem->GetFamily(), SFXSTYLEBIT_ALL); 1179 StyleTreeArr_Impl aArr; 1180 SfxStyleSheetBase *pStyle = pStyleSheetPool->First(); 1181 if(pStyle && pStyle->HasParentSupport() && bTreeDrag ) 1182 pTreeBox->SetDragDropMode(SV_DRAGDROP_CTRL_MOVE); 1183 else 1184 pTreeBox->SetDragDropMode(SV_DRAGDROP_NONE); 1185 while(pStyle) 1186 { 1187 StyleTree_ImplPtr pNew = 1188 new StyleTree_Impl(pStyle->GetName(), pStyle->GetParent()); 1189 aArr.Insert(pNew, aArr.Count()); 1190 pStyle = pStyleSheetPool->Next(); 1191 } 1192 MakeTree_Impl(aArr); 1193 ExpandedEntries aEntries; 1194 if(pTreeBox) 1195 ((const StyleTreeListBox_Impl *)pTreeBox)-> 1196 MakeExpanded_Impl( aEntries); 1197 pTreeBox->SetUpdateMode( sal_False ); 1198 pTreeBox->Clear(); 1199 const sal_uInt16 nCount = aArr.Count(); 1200 for(sal_uInt16 i = 0; i < nCount; ++i) 1201 FillBox_Impl(pTreeBox, aArr[i], aEntries); 1202 1203 // EnableEdit(sal_False); 1204 EnableItem(SID_STYLE_WATERCAN,sal_False); 1205 1206 SfxTemplateItem* pState = pFamilyState[nActFamily-1]; 1207 1208 if ( nCount ) 1209 pTreeBox->Expand( pTreeBox->First() ); 1210 1211 for ( SvLBoxEntry* pEntry = pTreeBox->First(); pEntry; pEntry = pTreeBox->Next( pEntry ) ) 1212 { 1213 if ( IsExpanded_Impl( aEntries, pTreeBox->GetEntryText( pEntry ) ) ) 1214 pTreeBox->Expand( pEntry ); 1215 } 1216 1217 pTreeBox->SetUpdateMode( sal_True ); 1218 1219 String aStyle; 1220 if(pState) //Aktuellen Eintrag selektieren 1221 aStyle = pState->GetStyleName(); 1222 SelectStyle(aStyle); 1223 EnableDelete(); 1224 } 1225 } 1226 1227 //------------------------------------------------------------------------- 1228 sal_Bool SfxCommonTemplateDialog_Impl::HasSelectedStyle() const 1229 { 1230 return pTreeBox? pTreeBox->FirstSelected() != 0: 1231 aFmtLb.GetSelectionCount() != 0; 1232 } 1233 1234 1235 //------------------------------------------------------------------------- 1236 1237 // intern: Aktualisierung der Anzeige 1238 void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(sal_uInt16 nFlags) // Flags, was aktualisiert werden soll (s.o.) 1239 { 1240 DBG_ASSERT(nFlags, "nichts zu tun"); 1241 const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); 1242 if (!pItem) 1243 { 1244 // Ist beim Vorlagenkatalog der Fall 1245 SfxTemplateItem **ppItem = pFamilyState; 1246 const sal_uInt16 nFamilyCount = pStyleFamilies->Count(); 1247 sal_uInt16 n; 1248 for(n=0;n<nFamilyCount;n++) 1249 if(ppItem[StyleNrToInfoOffset(n)])break; 1250 if ( n == nFamilyCount ) 1251 // passiert gelegentlich bei Beichten, Formularen etc.; weiss der Teufel warum 1252 return; 1253 ppItem+=StyleNrToInfoOffset(n); 1254 nAppFilter = (*ppItem)->GetValue(); 1255 FamilySelect( StyleNrToInfoOffset(n)+1 ); 1256 pItem = GetFamilyItem_Impl(); 1257 } 1258 1259 const SfxStyleFamily eFam = pItem->GetFamily(); 1260 1261 SfxFilterTupel *pT = pItem->GetFilterList().GetObject(nActFilter); 1262 sal_uInt16 nFilter = pT ? pItem->GetFilterList().GetObject(nActFilter)->nFlags : 0; 1263 if(!nFilter) // automatisch 1264 nFilter = nAppFilter; 1265 1266 DBG_ASSERT(pStyleSheetPool, "kein StyleSheetPool"); 1267 if(pStyleSheetPool) 1268 { 1269 pStyleSheetPool->SetSearchMask(eFam, nFilter); 1270 pItem = GetFamilyItem_Impl(); 1271 if((nFlags & UPDATE_FAMILY) == UPDATE_FAMILY) 1272 { 1273 CheckItem(nActFamily, sal_True); // Button in Toolbox checken 1274 aFilterLb.SetUpdateMode(sal_False); 1275 aFilterLb.Clear(); 1276 //insert hierarchical at the beginning 1277 sal_uInt16 nPos = aFilterLb.InsertEntry(String(SfxResId(STR_STYLE_FILTER_HIERARCHICAL)), 0); 1278 aFilterLb.SetEntryData( nPos, (void*)(sal_uIntPtr)SFXSTYLEBIT_ALL ); 1279 const SfxStyleFilter& rFilter = pItem->GetFilterList(); 1280 for(sal_uInt16 i = 0; i < rFilter.Count(); ++i) 1281 { 1282 sal_uIntPtr nFilterFlags = rFilter.GetObject(i)->nFlags; 1283 nPos = aFilterLb.InsertEntry( rFilter.GetObject(i)->aName ); 1284 aFilterLb.SetEntryData( nPos, (void*)nFilterFlags ); 1285 } 1286 if(nActFilter < aFilterLb.GetEntryCount() - 1) 1287 aFilterLb.SelectEntryPos(nActFilter + 1); 1288 else 1289 { 1290 nActFilter = 0; 1291 aFilterLb.SelectEntryPos(1); 1292 SfxFilterTupel *pActT = rFilter.GetObject(nActFilter); 1293 sal_uInt16 nFilterFlags = pActT ? rFilter.GetObject(nActFilter)->nFlags : 0; 1294 pStyleSheetPool->SetSearchMask(eFam, nFilterFlags); 1295 } 1296 1297 //Falls in Treedarstellung wieder Family Hierarchie selektieren 1298 if(pTreeBox) 1299 aFilterLb.SelectEntry(String(SfxResId(STR_STYLE_FILTER_HIERARCHICAL))); 1300 1301 // show maximum 12 entries 1302 aFilterLb.SetDropDownLineCount( MAX_FILTER_ENTRIES ); 1303 aFilterLb.SetUpdateMode(sal_True); 1304 } 1305 else 1306 { 1307 if( nActFilter < aFilterLb.GetEntryCount() - 1) 1308 aFilterLb.SelectEntryPos(nActFilter + 1); 1309 else 1310 { 1311 nActFilter = 0; 1312 aFilterLb.SelectEntryPos(1); 1313 } 1314 } 1315 1316 if(nFlags & UPDATE_FAMILY_LIST) 1317 { 1318 // EnableEdit(sal_False); 1319 EnableItem(SID_STYLE_WATERCAN,sal_False); 1320 1321 SfxStyleSheetBase *pStyle = pStyleSheetPool->First(); 1322 SvLBoxEntry* pEntry = aFmtLb.First(); 1323 SvStringsDtor aStrings; 1324 1325 while( pStyle ) 1326 { 1327 //Bubblesort 1328 for( sal_uInt16 nPos = aStrings.Count() + 1 ; nPos-- ;) 1329 { 1330 if( !nPos || *aStrings[nPos-1] < pStyle->GetName() ) 1331 { 1332 // Die Namen stehen in den Styles, also nicht kopieren 1333 // Reingefallen!: Writer hat insgesamt nur 1 Style 1334 aStrings.Insert( 1335 new String( pStyle->GetName() ), nPos ); 1336 break; 1337 } 1338 } 1339 pStyle = pStyleSheetPool->Next(); 1340 } 1341 1342 1343 sal_uInt16 nCount = aStrings.Count(); 1344 sal_uInt16 nPos = 0; 1345 while( nPos < nCount && pEntry && 1346 *aStrings[ nPos ] == aFmtLb.GetEntryText( pEntry ) ) 1347 { 1348 nPos++; 1349 pEntry = aFmtLb.Next( pEntry ); 1350 } 1351 1352 if( nPos < nCount || pEntry ) 1353 { 1354 // Box mit den Vorlagen fuellen 1355 aFmtLb.SetUpdateMode(sal_False); 1356 aFmtLb.Clear(); 1357 1358 nPos = 0; 1359 while( nPos < nCount ) 1360 aFmtLb.InsertEntry( *aStrings.GetObject( nPos++ )); 1361 aFmtLb.SetUpdateMode(sal_True); 1362 } 1363 // aktuelle Vorlage anzeigen 1364 SfxTemplateItem *pState = pFamilyState[nActFamily-1]; 1365 String aStyle; 1366 if(pState) //Aktuellen Eintrag selektieren 1367 aStyle = pState->GetStyleName(); 1368 SelectStyle(aStyle); 1369 EnableDelete(); 1370 } 1371 } 1372 } 1373 1374 //------------------------------------------------------------------------- 1375 1376 // Aktualisierung Anzeige: Gie\skanne an/aus 1377 void SfxCommonTemplateDialog_Impl::SetWaterCanState(const SfxBoolItem *pItem) 1378 { 1379 // EnableItem(SID_STYLE_WATERCAN, pItem != 0); 1380 bWaterDisabled = pItem == 0; 1381 //added by BerryJia for fixing Bug76391 2003-1-7 1382 if(!bWaterDisabled) 1383 bWaterDisabled = !HasSelectedStyle(); 1384 1385 if(pItem && !bWaterDisabled) 1386 { 1387 CheckItem(SID_STYLE_WATERCAN, pItem->GetValue()); 1388 EnableItem( SID_STYLE_WATERCAN, sal_True ); 1389 } 1390 else 1391 if(!bWaterDisabled) 1392 EnableItem(SID_STYLE_WATERCAN, sal_True); 1393 else 1394 EnableItem(SID_STYLE_WATERCAN, sal_False); 1395 1396 //Waehrend Giesskannenmodus Statusupdates ignorieren. 1397 1398 sal_uInt16 nCount=pStyleFamilies->Count(); 1399 pBindings->EnterRegistrations(); 1400 for(sal_uInt16 n=0; n<nCount; n++) 1401 { 1402 SfxControllerItem *pCItem=pBoundItems[n]; 1403 sal_Bool bChecked = pItem && pItem->GetValue(); 1404 if( pCItem->IsBound() == bChecked ) 1405 { 1406 if( !bChecked ) 1407 pCItem->ReBind(); 1408 else 1409 pCItem->UnBind(); 1410 } 1411 } 1412 pBindings->LeaveRegistrations(); 1413 } 1414 1415 //------------------------------------------------------------------------- 1416 1417 // Item mit dem Status einer Family wird kopiert und gemerkt 1418 // (Aktualisierung erfolgt, wenn alle Stati aktualisiert worden sind. 1419 // Siehe auch: <SfxBindings::AddDoneHdl(const Link &)> 1420 1421 void SfxCommonTemplateDialog_Impl::SetFamilyState( sal_uInt16 nSlotId, const SfxTemplateItem* pItem ) 1422 { 1423 sal_uInt16 nIdx = nSlotId - SID_STYLE_FAMILY_START; 1424 DELETEZ(pFamilyState[nIdx]); 1425 if ( pItem ) 1426 pFamilyState[nIdx] = new SfxTemplateItem(*pItem); 1427 bUpdate = sal_True; 1428 1429 // Wenn verwendete Vorlagen ( wie zum Teufel findet man das heraus ?? ) 1430 bUpdateFamily = sal_True; 1431 } 1432 1433 //------------------------------------------------------------------------- 1434 1435 // Benachrichtigung durch SfxBindings, da"s die Aktualisierung 1436 // beendet ist. St"o\st die Aktualisierung der Anzeige an. 1437 1438 void SfxCommonTemplateDialog_Impl::Update_Impl() 1439 { 1440 sal_Bool bDocChanged=sal_False; 1441 SfxStyleSheetBasePool* pNewPool = NULL; 1442 SfxViewFrame* pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame(); 1443 SfxObjectShell* pDocShell = pViewFrame->GetObjectShell(); 1444 if( pDocShell ) 1445 pNewPool = pDocShell->GetStyleSheetPool(); 1446 1447 if ( pNewPool != pStyleSheetPool && pDocShell ) 1448 { 1449 SfxModule* pNewModule = pDocShell->GetModule(); 1450 if( pNewModule && pNewModule != pModule ) 1451 { 1452 ClearResource(); 1453 ReadResource(); 1454 } 1455 if ( pStyleSheetPool ) 1456 { 1457 EndListening(*pStyleSheetPool); 1458 pStyleSheetPool = 0; 1459 } 1460 1461 if ( pNewPool ) 1462 { 1463 StartListening(*pNewPool); 1464 pStyleSheetPool = pNewPool; 1465 bDocChanged=sal_True; 1466 } 1467 // InvalidateBindings(); 1468 } 1469 1470 if (bUpdateFamily) 1471 UpdateFamily_Impl(); 1472 1473 sal_uInt16 i; 1474 for(i = 0; i < MAX_FAMILIES; ++i) 1475 if(pFamilyState[i]) 1476 break; 1477 if(i == MAX_FAMILIES || !pNewPool) 1478 // nichts erlaubt 1479 return; 1480 1481 SfxTemplateItem *pItem = 0; 1482 // aktueller Bereich nicht innerhalb der erlaubten Bereiche 1483 // oder Default 1484 if(nActFamily == SFX_TEMPLDLG_FILTER_MAX || 0 == (pItem = pFamilyState[nActFamily-1] ) ) 1485 { 1486 CheckItem(nActFamily, sal_False); 1487 SfxTemplateItem **ppItem = pFamilyState; 1488 const sal_uInt16 nFamilyCount = pStyleFamilies->Count(); 1489 sal_uInt16 n; 1490 for(n=0;n<nFamilyCount;n++) 1491 if(ppItem[StyleNrToInfoOffset(n)])break; 1492 ppItem+=StyleNrToInfoOffset(n); 1493 1494 nAppFilter = (*ppItem)->GetValue(); 1495 FamilySelect( StyleNrToInfoOffset(n)+1 ); 1496 1497 pItem = *ppItem; 1498 } 1499 else if( bDocChanged ) 1500 { 1501 // andere DocShell -> alles neu 1502 CheckItem( nActFamily, sal_True ); 1503 nActFilter = static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pDocShell ) ); 1504 if ( SFX_TEMPLDLG_FILTER_MAX == nActFilter ) 1505 nActFilter = pDocShell->GetAutoStyleFilterIndex(); 1506 1507 nAppFilter = pItem->GetValue(); 1508 if(!pTreeBox) 1509 { 1510 UpdateStyles_Impl(UPDATE_FAMILY_LIST); 1511 } 1512 else 1513 FillTreeBox(); 1514 } 1515 else 1516 { 1517 // anderer Filter fuer automatisch 1518 CheckItem( nActFamily, sal_True ); 1519 const SfxStyleFamilyItem *pStyleItem = GetFamilyItem_Impl(); 1520 if(0 == pStyleItem->GetFilterList().GetObject(nActFilter)->nFlags 1521 && nAppFilter != pItem->GetValue()) 1522 { 1523 nAppFilter = pItem->GetValue(); 1524 if(!pTreeBox) 1525 UpdateStyles_Impl(UPDATE_FAMILY_LIST); 1526 else 1527 FillTreeBox(); 1528 } 1529 else 1530 nAppFilter = pItem->GetValue(); 1531 } 1532 const String aStyle(pItem->GetStyleName()); 1533 SelectStyle(aStyle); 1534 EnableDelete(); 1535 EnableNew( bCanNew ); 1536 } 1537 1538 //------------------------------------------------------------------------- 1539 1540 IMPL_LINK( SfxCommonTemplateDialog_Impl, TimeOut, Timer *, pTim ) 1541 { 1542 (void)pTim; // unused 1543 if(!bDontUpdate) 1544 { 1545 bDontUpdate=sal_True; 1546 if(!pTreeBox) 1547 UpdateStyles_Impl(UPDATE_FAMILY_LIST); 1548 else 1549 { 1550 FillTreeBox(); 1551 SfxTemplateItem *pState = pFamilyState[nActFamily-1]; 1552 if(pState) 1553 { 1554 const String aStyle(pState->GetStyleName()); 1555 SelectStyle(aStyle); 1556 EnableDelete(); 1557 } 1558 } 1559 bDontUpdate=sal_False; 1560 DELETEZ(pTimer); 1561 } 1562 else 1563 pTimer->Start(); 1564 return 0; 1565 } 1566 1567 1568 //------------------------------------------------------------------------- 1569 void SfxCommonTemplateDialog_Impl::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint) 1570 { 1571 // Aktualisierung anstossen 1572 if(rHint.Type() == TYPE(SfxSimpleHint)) 1573 { 1574 switch(((SfxSimpleHint&) rHint ).GetId()) 1575 { 1576 case SFX_HINT_UPDATEDONE: 1577 { 1578 SfxViewFrame *pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame(); 1579 SfxObjectShell *pDocShell = pViewFrame->GetObjectShell(); 1580 if ( 1581 bUpdate && 1582 ( 1583 !IsCheckedItem(SID_STYLE_WATERCAN) || 1584 (pDocShell && pDocShell->GetStyleSheetPool() != pStyleSheetPool) 1585 ) 1586 ) 1587 { 1588 bUpdate = sal_False; 1589 Update_Impl(); 1590 } 1591 else if ( bUpdateFamily ) 1592 { 1593 UpdateFamily_Impl(); 1594 } 1595 1596 if( pStyleSheetPool ) 1597 { 1598 String aStr = GetSelectedEntry(); 1599 if( aStr.Len() && pStyleSheetPool ) 1600 { 1601 const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); 1602 if( !pItem ) break; 1603 const SfxStyleFamily eFam = pItem->GetFamily(); 1604 SfxStyleSheetBase *pStyle = 1605 pStyleSheetPool->Find( 1606 aStr, eFam, SFXSTYLEBIT_ALL ); 1607 if( pStyle ) 1608 EnableEdit( 1609 !(pStyle->GetMask() & SFXSTYLEBIT_READONLY) ); 1610 else 1611 EnableEdit(sal_False); 1612 } 1613 } 1614 break; 1615 } 1616 // noetig, wenn zwichen Dokumenten umgeschaltet wird, 1617 // aber in beiden Dokumenten die gleiche Vorlage gilt. 1618 // Nicht sofort Update_Impl rufen, fuer den Fall da\s eines 1619 // der Dokumente ein internes InPlaceObjekt ist! 1620 case SFX_HINT_DOCCHANGED: 1621 bUpdate = sal_True; 1622 break; 1623 case SFX_HINT_DYING: 1624 { 1625 EndListening(*pStyleSheetPool); 1626 pStyleSheetPool=0; 1627 break; 1628 } 1629 } 1630 } 1631 1632 // Timer nicht aufsetzen, wenn der StyleSheetPool in die Kiste geht, denn 1633 // es kann sein, da\s sich ein neuer erst anmeldet, nachdem der Timer 1634 // abgelaufen ist - macht sich schlecht in UpdateStyles_Impl() ! 1635 1636 sal_uIntPtr nId = rHint.ISA(SfxSimpleHint) ? ( (SfxSimpleHint&)rHint ).GetId() : 0; 1637 1638 if(!bDontUpdate && nId != SFX_HINT_DYING && 1639 (rHint.Type() == TYPE(SfxStyleSheetPoolHint)|| 1640 rHint.Type() == TYPE(SfxStyleSheetHint) || 1641 rHint.Type() == TYPE( SfxStyleSheetHintExtended ))) 1642 { 1643 if(!pTimer) 1644 { 1645 pTimer=new Timer; 1646 pTimer->SetTimeout(500); 1647 pTimer->SetTimeoutHdl(LINK(this,SfxCommonTemplateDialog_Impl,TimeOut)); 1648 } 1649 pTimer->Start(); 1650 1651 } 1652 } 1653 1654 1655 //------------------------------------------------------------------------- 1656 1657 // Anderer Filter; kann durch den Benutzer umgeschaltet werden 1658 // oder als Folge von Neu oder Bearbeiten, wenn die aktuelle 1659 // Vorlage einem anderen Filter zugewiesen wurde. 1660 void SfxCommonTemplateDialog_Impl::FilterSelect( 1661 sal_uInt16 nEntry, // Idx des neuen Filters 1662 sal_Bool bForce ) // Aktualisierung erzwingen, auch wenn der neue Filter gleich dem aktuellen ist 1663 { 1664 if( nEntry != nActFilter || bForce ) 1665 { 1666 nActFilter = nEntry; 1667 SfxViewFrame *pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame(); 1668 SfxObjectShell *pDocShell = pViewFrame->GetObjectShell(); 1669 if (pDocShell) 1670 { 1671 pDocShell->SetAutoStyleFilterIndex(nActFilter); 1672 SaveFactoryStyleFilter( pDocShell, nActFilter ); 1673 } 1674 1675 SfxStyleSheetBasePool *pOldStyleSheetPool = pStyleSheetPool; 1676 pStyleSheetPool = pDocShell? pDocShell->GetStyleSheetPool(): 0; 1677 if ( pOldStyleSheetPool != pStyleSheetPool ) 1678 { 1679 if ( pOldStyleSheetPool ) 1680 EndListening(*pOldStyleSheetPool); 1681 if ( pStyleSheetPool ) 1682 StartListening(*pOldStyleSheetPool); 1683 } 1684 1685 UpdateStyles_Impl(UPDATE_FAMILY_LIST); 1686 } 1687 } 1688 1689 //------------------------------------------------------------------------- 1690 1691 // Intern: Ausf"uhren von Funktionen "uber den Dispatcher 1692 sal_Bool SfxCommonTemplateDialog_Impl::Execute_Impl( 1693 sal_uInt16 nId, const String &rStr, const String& rRefStr, sal_uInt16 nFamily, 1694 sal_uInt16 nMask, sal_uInt16 *pIdx, const sal_uInt16* pModifier) 1695 { 1696 SfxDispatcher &rDispatcher = *SFX_APP()->GetDispatcher_Impl(); 1697 SfxStringItem aItem(nId, rStr); 1698 SfxUInt16Item aFamily(SID_STYLE_FAMILY, nFamily); 1699 SfxUInt16Item aMask( SID_STYLE_MASK, nMask ); 1700 SfxStringItem aUpdName(SID_STYLE_UPD_BY_EX_NAME, rStr); 1701 SfxStringItem aRefName( SID_STYLE_REFERENCE, rRefStr ); 1702 const SfxPoolItem* pItems[ 6 ]; 1703 sal_uInt16 nCount = 0; 1704 if( rStr.Len() ) 1705 pItems[ nCount++ ] = &aItem; 1706 pItems[ nCount++ ] = &aFamily; 1707 if( nMask ) 1708 pItems[ nCount++ ] = &aMask; 1709 if(SID_STYLE_UPDATE_BY_EXAMPLE == nId) 1710 { 1711 //Sonderloesung fuer Numerierungsupdate im Writer 1712 const String aTemplName(GetSelectedEntry()); 1713 aUpdName.SetValue(aTemplName); 1714 pItems[ nCount++ ] = &aUpdName; 1715 } 1716 if ( rRefStr.Len() ) 1717 pItems[ nCount++ ] = &aRefName; 1718 1719 pItems[ nCount++ ] = 0; 1720 1721 Deleted aDeleted; 1722 pbDeleted = &aDeleted; 1723 sal_uInt16 nModi = pModifier ? *pModifier : 0; 1724 const SfxPoolItem* pItem = rDispatcher.Execute( 1725 nId, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD | SFX_CALLMODE_MODAL, 1726 pItems, nModi ); 1727 1728 // FIXME: Dialog can be destroyed while in Execute() check stack variable for dtor flag! 1729 if ( !pItem || aDeleted() ) 1730 return sal_False; 1731 1732 if ( nId == SID_STYLE_NEW || SID_STYLE_EDIT == nId ) 1733 { 1734 SfxUInt16Item *pFilterItem = PTR_CAST(SfxUInt16Item, pItem); 1735 DBG_ASSERT(pFilterItem, "SfxUINT16Item erwartet"); 1736 sal_uInt16 nFilterFlags = pFilterItem->GetValue() & ~SFXSTYLEBIT_USERDEF; 1737 if(!nFilterFlags) // Benutzervorlage? 1738 nFilterFlags = pFilterItem->GetValue(); 1739 const SfxStyleFamilyItem *pFamilyItem = GetFamilyItem_Impl(); 1740 const sal_uInt16 nFilterCount = (sal_uInt16) pFamilyItem->GetFilterList().Count(); 1741 1742 for ( sal_uInt16 i = 0; i < nFilterCount; ++i ) 1743 { 1744 const SfxFilterTupel *pTupel = 1745 pFamilyItem->GetFilterList().GetObject(i); 1746 1747 if ( ( pTupel->nFlags & nFilterFlags ) == nFilterFlags && pIdx ) 1748 *pIdx = i; 1749 } 1750 } 1751 1752 // Reset destroyed flag otherwise we use the pointer in the dtor 1753 // where the local stack object is already destroyed. This would 1754 // overwrite objects on the stack!! See #i100110 1755 pbDeleted = NULL; 1756 return sal_True; 1757 } 1758 1759 //------------------------------------------------------------------------- 1760 1761 // Handler der Listbox der Filter 1762 IMPL_LINK( SfxCommonTemplateDialog_Impl, FilterSelectHdl, ListBox *, pBox ) 1763 { 1764 if ( pBox->GetSelectEntry() == String(SfxResId(STR_STYLE_FILTER_HIERARCHICAL)) ) 1765 { 1766 if ( !bHierarchical ) 1767 { 1768 // TreeView einschalten 1769 bHierarchical=sal_True; 1770 const String aSelectEntry( GetSelectedEntry()); 1771 aFmtLb.Hide(); 1772 // aFilterLb.Disable(); 1773 1774 pTreeBox = new StyleTreeListBox_Impl( 1775 this, WB_HASBUTTONS | WB_HASLINES | 1776 WB_BORDER | WB_TABSTOP | WB_HASLINESATROOT | 1777 WB_HASBUTTONSATROOT | WB_HIDESELECTION | WB_QUICK_SEARCH ); 1778 pTreeBox->SetFont( aFmtLb.GetFont() ); 1779 1780 pTreeBox->SetPosSizePixel(aFmtLb.GetPosPixel(), aFmtLb.GetSizePixel()); 1781 pTreeBox->SetNodeDefaultImages(); 1782 pTreeBox->SetSelectHdl( 1783 LINK(this, SfxCommonTemplateDialog_Impl, FmtSelectHdl)); 1784 ((StyleTreeListBox_Impl*)pTreeBox)-> 1785 SetDoubleClickHdl( 1786 LINK(this, SfxCommonTemplateDialog_Impl, ApplyHdl)); 1787 ((StyleTreeListBox_Impl*)pTreeBox)-> 1788 SetDropHdl(LINK(this, SfxCommonTemplateDialog_Impl, DropHdl)); 1789 pTreeBox->SetIndent(10); 1790 1791 FillTreeBox(); 1792 SelectStyle(aSelectEntry); 1793 pTreeBox->SetAccessibleName(SfxResId(STR_STYLE_ELEMTLIST)); 1794 pTreeBox->Show(); 1795 1796 // Save the filter state 1797 SfxViewFrame *pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame(); 1798 SfxObjectShell *pDocShell = pViewFrame->GetObjectShell(); 1799 if (pDocShell) 1800 { 1801 // only in the configuration 1802 // SetAutoStyleFilterIndex would update nActFilter 1803 // which should only contain a valid listbox entry 1804 SaveFactoryStyleFilter( pDocShell, SFX_TEMPLDLG_FILTER_HIERARCHICAL ); 1805 } 1806 } 1807 } 1808 1809 else 1810 { 1811 DELETEZ(pTreeBox); 1812 aFmtLb.Show(); 1813 // aFilterLb.Enable(); 1814 // Falls bHierarchical, kann sich die Familie geaendert haben 1815 // minus one since hierarchical is inserted at the start 1816 FilterSelect(pBox->GetSelectEntryPos() - 1, bHierarchical ); 1817 bHierarchical=sal_False; 1818 // UpdateStyles_Impl(UPDATE_FAMILY_LIST); // Anzeige aktualisieren 1819 } 1820 1821 return 0; 1822 } 1823 1824 //------------------------------------------------------------------------- 1825 1826 // Select-Handler der Toolbox 1827 void SfxCommonTemplateDialog_Impl::FamilySelect(sal_uInt16 nEntry) 1828 { 1829 if( nEntry != nActFamily ) 1830 { 1831 CheckItem( nActFamily, sal_False ); 1832 nActFamily = nEntry; 1833 SfxDispatcher* pDispat = pBindings->GetDispatcher_Impl(); 1834 SfxUInt16Item aItem( SID_STYLE_FAMILY, nEntry ); 1835 pDispat->Execute( SID_STYLE_FAMILY, SFX_CALLMODE_SYNCHRON, &aItem, 0L ); 1836 pBindings->Invalidate( SID_STYLE_FAMILY ); 1837 pBindings->Update( SID_STYLE_FAMILY ); 1838 UpdateFamily_Impl(); 1839 } 1840 } 1841 1842 //------------------------------------------------------------------------- 1843 1844 void SfxCommonTemplateDialog_Impl::ActionSelect(sal_uInt16 nEntry) 1845 { 1846 String aEmpty; 1847 switch(nEntry) 1848 { 1849 case SID_STYLE_WATERCAN: 1850 { 1851 const sal_Bool bState = IsCheckedItem(nEntry); 1852 sal_Bool bCheck; 1853 SfxBoolItem aBool; 1854 // wenn eine Vorlage ausgewaehlt ist. 1855 if(!bState && aFmtLb.GetSelectionCount()) 1856 { 1857 const String aTemplName( 1858 GetSelectedEntry()); 1859 Execute_Impl( 1860 SID_STYLE_WATERCAN, aTemplName, aEmpty, 1861 (sal_uInt16)GetFamilyItem_Impl()->GetFamily() ); 1862 bCheck = sal_True; 1863 } 1864 else 1865 { 1866 Execute_Impl(SID_STYLE_WATERCAN, aEmpty, aEmpty, 0); 1867 bCheck = sal_False; 1868 } 1869 CheckItem(nEntry, bCheck); 1870 aBool.SetValue(bCheck); 1871 SetWaterCanState(&aBool); 1872 break; 1873 } 1874 case SID_STYLE_NEW_BY_EXAMPLE: 1875 { 1876 if(pStyleSheetPool && nActFamily != SFX_TEMPLDLG_FILTER_MAX) 1877 { 1878 const SfxStyleFamily eFam=GetFamilyItem_Impl()->GetFamily(); 1879 //pStyleSheetPool->GetSearchFamily(); 1880 const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); 1881 sal_uInt16 nFilter; 1882 if(pItem&&nActFilter!=SFX_TEMPLDLG_FILTER_MAX) 1883 { 1884 nFilter = pItem->GetFilterList().GetObject( 1885 nActFilter)->nFlags; 1886 if(!nFilter) // automatisch 1887 nFilter = nAppFilter; 1888 } 1889 else 1890 nFilter=pStyleSheetPool->GetSearchMask(); 1891 pStyleSheetPool->SetSearchMask( eFam, SFXSTYLEBIT_USERDEF ); 1892 1893 SfxNewStyleDlg *pDlg = 1894 // why? : FloatingWindow must not be parent of a modal dialog 1895 new SfxNewStyleDlg(pWindow, *pStyleSheetPool); 1896 if(RET_OK == pDlg->Execute()) 1897 { 1898 pStyleSheetPool->SetSearchMask(eFam, nFilter); 1899 const String aTemplName(pDlg->GetName()); 1900 Execute_Impl(SID_STYLE_NEW_BY_EXAMPLE, 1901 aTemplName, aEmpty, 1902 (sal_uInt16)GetFamilyItem_Impl()->GetFamily(), 1903 nFilter); 1904 } 1905 pStyleSheetPool->SetSearchMask( eFam, nFilter ); 1906 delete pDlg; 1907 } 1908 break; 1909 } 1910 case SID_STYLE_UPDATE_BY_EXAMPLE: 1911 { 1912 Execute_Impl(SID_STYLE_UPDATE_BY_EXAMPLE, 1913 aEmpty, aEmpty, 1914 (sal_uInt16)GetFamilyItem_Impl()->GetFamily()); 1915 break; 1916 } 1917 case SID_TEMPLATE_LOAD: 1918 SFX_APP()->GetDispatcher_Impl()->Execute(nEntry); 1919 break; 1920 default: DBG_ERROR("not implemented"); break; 1921 } 1922 } 1923 1924 //------------------------------------------------------------------------- 1925 1926 static rtl::OUString getModuleIdentifier( const Reference< XModuleManager >& i_xModMgr, SfxObjectShell* i_pObjSh ) 1927 { 1928 DBG_ASSERT( i_xModMgr.is(), "getModuleIdentifier(): no XModuleManager" ); 1929 DBG_ASSERT( i_pObjSh, "getModuleIdentifier(): no ObjectShell" ); 1930 1931 ::rtl::OUString sIdentifier; 1932 1933 try 1934 { 1935 sIdentifier = i_xModMgr->identify( i_pObjSh->GetModel() ); 1936 } 1937 catch ( ::com::sun::star::frame::UnknownModuleException& ) 1938 { 1939 DBG_WARNING( "getModuleIdentifier(): unknown module" ); 1940 } 1941 catch ( Exception& ) 1942 { 1943 DBG_ERRORFILE( "getModuleIdentifier(): exception of XModuleManager::identify()" ); 1944 } 1945 1946 return sIdentifier; 1947 } 1948 1949 //------------------------------------------------------------------------- 1950 1951 sal_Int32 SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter( SfxObjectShell* i_pObjSh ) 1952 { 1953 DBG_ASSERT( i_pObjSh, "SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter(): no ObjectShell" ); 1954 sal_Int32 nFilter = -1; 1955 1956 Sequence< PropertyValue > lProps; 1957 Reference< ::com::sun::star::container::XNameAccess > xContainer( xModuleManager, UNO_QUERY ); 1958 if ( xContainer.is() ) 1959 { 1960 ::comphelper::SequenceAsHashMap aFactoryProps( 1961 xContainer->getByName( getModuleIdentifier( xModuleManager, i_pObjSh ) ) ); 1962 sal_Int32 nDefault = -1; 1963 nFilter = aFactoryProps.getUnpackedValueOrDefault( DEFINE_CONST_UNICODE("ooSetupFactoryStyleFilter"), nDefault ); 1964 } 1965 1966 return nFilter; 1967 } 1968 1969 //------------------------------------------------------------------------- 1970 1971 void SfxCommonTemplateDialog_Impl::SaveFactoryStyleFilter( SfxObjectShell* i_pObjSh, sal_Int32 i_nFilter ) 1972 { 1973 DBG_ASSERT( i_pObjSh, "SfxCommonTemplateDialog_Impl::SaveFactoryStyleFilter(): no ObjectShell" ); 1974 Reference< ::com::sun::star::container::XNameReplace > xContainer( xModuleManager, UNO_QUERY ); 1975 if ( xContainer.is() ) 1976 { 1977 Sequence< PropertyValue > lProps(1); 1978 lProps[0].Name = DEFINE_CONST_UNICODE("ooSetupFactoryStyleFilter"); 1979 lProps[0].Value = makeAny( i_nFilter );; 1980 xContainer->replaceByName( getModuleIdentifier( xModuleManager, i_pObjSh ), makeAny( lProps ) ); 1981 } 1982 } 1983 1984 //------------------------------------------------------------------------- 1985 1986 IMPL_LINK( SfxCommonTemplateDialog_Impl, DropHdl, StyleTreeListBox_Impl *, pBox ) 1987 { 1988 bDontUpdate=sal_True; 1989 const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); 1990 const SfxStyleFamily eFam = pItem->GetFamily(); 1991 long ret= pStyleSheetPool->SetParent(eFam,pBox->GetStyle(), pBox->GetParent())? 1L: 0L; 1992 bDontUpdate=sal_False; 1993 return ret; 1994 } 1995 1996 //------------------------------------------------------------------------- 1997 1998 // Handler des Neu-Buttons 1999 void SfxCommonTemplateDialog_Impl::NewHdl(void *) 2000 { 2001 String aEmpty; 2002 if ( nActFamily != SFX_TEMPLDLG_FILTER_MAX ) 2003 { 2004 Window* pTmp; 2005 pTmp = Application::GetDefDialogParent(); 2006 if ( ISA(SfxTemplateDialog_Impl) ) 2007 Application::SetDefDialogParent( pWindow->GetParent() ); 2008 else 2009 Application::SetDefDialogParent( pWindow ); 2010 2011 const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); 2012 const SfxStyleFamily eFam=pItem->GetFamily(); 2013 sal_uInt16 nMask; 2014 if(pItem&&nActFilter!=SFX_TEMPLDLG_FILTER_MAX) 2015 { 2016 nMask = pItem->GetFilterList().GetObject( 2017 nActFilter)->nFlags; 2018 if(!nMask) // automatisch 2019 nMask = nAppFilter; 2020 } 2021 else 2022 nMask=pStyleSheetPool->GetSearchMask(); 2023 2024 pStyleSheetPool->SetSearchMask(eFam,nMask); 2025 2026 Execute_Impl(SID_STYLE_NEW, 2027 aEmpty, GetSelectedEntry(), 2028 ( sal_uInt16 )GetFamilyItem_Impl()->GetFamily(), 2029 nMask); 2030 2031 Application::SetDefDialogParent( pTmp ); 2032 2033 /* { 2034 DBG_ASSERT(nFilter < aFilterLb.GetEntryCount(), 2035 "Filter ueberindiziert"); 2036 2037 if(!pTreeBox) 2038 { 2039 // aFilterLb.SelectEntryPos(nFilter); 2040 FilterSelect(nActFilter, sal_True); 2041 } 2042 else 2043 { 2044 FillTreeBox(); 2045 SfxTemplateItem *pState = pFamilyState[nActFamily-1]; 2046 if(pState) 2047 { 2048 const String aStyle(pState->GetStyleName()); 2049 SelectStyle(aStyle); 2050 } 2051 EnableDelete(); 2052 }*/ 2053 // } 2054 } 2055 } 2056 2057 //------------------------------------------------------------------------- 2058 2059 // Handler des Bearbeiten-Buttons 2060 void SfxCommonTemplateDialog_Impl::EditHdl(void *) 2061 { 2062 if(IsInitialized() && HasSelectedStyle()) 2063 { 2064 sal_uInt16 nFilter = nActFilter; 2065 String aTemplName(GetSelectedEntry()); 2066 const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); 2067 const SfxStyleFamily eFam = pItem->GetFamily(); 2068 pStyleSheetPool->Find(aTemplName,eFam,SFXSTYLEBIT_ALL); // -Wall required?? 2069 Window* pTmp; 2070 //DefModalDialogParent setzen fuer 2071 //Modalitaet der nachfolgenden Dialoge 2072 pTmp = Application::GetDefDialogParent(); 2073 if ( ISA(SfxTemplateDialog_Impl) ) 2074 Application::SetDefDialogParent( pWindow->GetParent() ); 2075 else 2076 Application::SetDefDialogParent( pWindow ); 2077 if ( Execute_Impl( SID_STYLE_EDIT, aTemplName, String(), 2078 (sal_uInt16)GetFamilyItem_Impl()->GetFamily(), 0, &nFilter ) ) 2079 { 2080 // DBG_ASSERT(nFilter < aFilterLb.GetEntryCount(), "Filter ueberindiziert"); 2081 // aTemplName = pStyle->GetName(); 2082 // kann durch Bearbeiten umbenannt worden sein 2083 /* if(!pTreeBox) 2084 { 2085 // aFilterLb.SelectEntryPos(nFilter); 2086 // FilterSelect(nFilter, sal_True); 2087 } 2088 else 2089 FillTreeBox();*/ 2090 } 2091 Application::SetDefDialogParent( pTmp ); 2092 } 2093 } 2094 2095 //------------------------------------------------------------------------- 2096 2097 // Handler des L"oschen-Buttons 2098 void SfxCommonTemplateDialog_Impl::DeleteHdl(void *) 2099 { 2100 if ( IsInitialized() && HasSelectedStyle() ) 2101 { 2102 const String aTemplName( GetSelectedEntry() ); 2103 const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl(); 2104 SfxStyleSheetBase* pStyle = 2105 pStyleSheetPool->Find( aTemplName, pItem->GetFamily(), SFXSTYLEBIT_ALL ); 2106 if ( pStyle ) 2107 { 2108 String aMsg; 2109 if ( pStyle->IsUsed() ) 2110 aMsg = String( SfxResId( STR_DELETE_STYLE_USED ) ); 2111 aMsg += String ( SfxResId( STR_DELETE_STYLE ) ); 2112 aMsg.SearchAndReplaceAscii( "$1", aTemplName ); 2113 #if defined UNX 2114 QueryBox aBox( SFX_APP()->GetTopWindow(), WB_YES_NO | WB_DEF_NO, aMsg ); 2115 #else 2116 QueryBox aBox( GetWindow(), WB_YES_NO | WB_DEF_NO , aMsg ); 2117 #endif 2118 if ( RET_YES == aBox.Execute() ) 2119 { 2120 PrepareDeleteAction(); 2121 2122 if ( pTreeBox ) // Damit die Treelistbox beim L"oschen nicht zuklappt 2123 { 2124 bDontUpdate = sal_True; 2125 } 2126 Execute_Impl( SID_STYLE_DELETE, aTemplName, 2127 String(), (sal_uInt16)GetFamilyItem_Impl()->GetFamily() ); 2128 2129 if ( pTreeBox ) 2130 { 2131 pTreeBox->RemoveParentKeepChilds( pTreeBox->FirstSelected() ); 2132 bDontUpdate = sal_False; 2133 } 2134 } 2135 } 2136 } 2137 } 2138 2139 //------------------------------------------------------------------------- 2140 2141 void SfxCommonTemplateDialog_Impl::EnableDelete() 2142 { 2143 if(IsInitialized() && HasSelectedStyle()) 2144 { 2145 DBG_ASSERT(pStyleSheetPool, "Kein StyleSheetPool"); 2146 const String aTemplName(GetSelectedEntry()); 2147 const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); 2148 const SfxStyleFamily eFam = pItem->GetFamily(); 2149 sal_uInt16 nFilter = 0; 2150 if(pItem->GetFilterList().Count() > nActFilter) 2151 nFilter = pItem->GetFilterList().GetObject(nActFilter)->nFlags; 2152 if(!nFilter) // automatisch 2153 nFilter = nAppFilter; 2154 const SfxStyleSheetBase *pStyle = 2155 pStyleSheetPool->Find(aTemplName,eFam, 2156 pTreeBox? SFXSTYLEBIT_ALL: nFilter); 2157 DBG_ASSERT(pStyle, "Style nicht gefunden"); 2158 if(pStyle && pStyle->IsUserDefined()) 2159 { 2160 EnableDel(sal_True); 2161 } 2162 else 2163 { 2164 EnableDel(sal_False); 2165 } 2166 } 2167 else 2168 { 2169 EnableDel(sal_False); 2170 } 2171 // rBindings.Invalidate( SID_STYLE_DELETE ); 2172 // rBindings.Update( SID_STYLE_DELETE ); 2173 } 2174 2175 //------------------------------------------------------------------------- 2176 2177 // nach Selektion eines Eintrags den Focus gfs. wieder auf das App-Fenster 2178 // setzen 2179 void SfxCommonTemplateDialog_Impl::ResetFocus() 2180 { 2181 if(ISA(SfxTemplateDialog_Impl)) 2182 { 2183 SfxViewFrame *pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame(); 2184 SfxViewShell *pVu = pViewFrame->GetViewShell(); 2185 Window *pAppWin = pVu ? pVu->GetWindow(): 0; 2186 if(pAppWin) 2187 pAppWin->GrabFocus(); 2188 } 2189 } 2190 2191 //------------------------------------------------------------------------- 2192 2193 // Doppelclick auf ein StyleSheet in der ListBox, wird angewendet. 2194 IMPL_LINK( SfxCommonTemplateDialog_Impl, ApplyHdl, Control *, pControl ) 2195 { 2196 (void)pControl; //unused 2197 // nur, wenn dieser Bereich erlaubt ist 2198 if ( IsInitialized() && 0 != pFamilyState[nActFamily-1] && 2199 GetSelectedEntry().Len() ) 2200 { 2201 sal_uInt16 nModifier = aFmtLb.GetModifier(); 2202 Execute_Impl(SID_STYLE_APPLY, 2203 GetSelectedEntry(), String(), 2204 ( sal_uInt16 )GetFamilyItem_Impl()->GetFamily(), 2205 0, 0, &nModifier ); 2206 if(ISA(SfxTemplateCatalog_Impl)) 2207 ((SfxTemplateCatalog_Impl*) this)->pReal->EndDialog(RET_OK); 2208 } 2209 ResetFocus(); 2210 return 0; 2211 } 2212 2213 //------------------------------------------------------------------------- 2214 2215 // Selektion einer Vorlage w"ahrend des Watercan-Status 2216 IMPL_LINK( SfxCommonTemplateDialog_Impl, FmtSelectHdl, SvTreeListBox *, pListBox ) 2217 { 2218 // HilfePI antriggern, wenn von Call als Handler und Bereich erlaubt ist 2219 if( !pListBox || pListBox->IsSelected( pListBox->GetHdlEntry() ) ) 2220 { 2221 // nur, wenn Giesskanne an ist 2222 if ( IsInitialized() && 2223 IsCheckedItem(SID_STYLE_WATERCAN) && 2224 // nur, wenn dieser Bereich erlaubt ist 2225 0 != pFamilyState[nActFamily-1] ) 2226 { 2227 String aEmpty; 2228 Execute_Impl(SID_STYLE_WATERCAN, 2229 aEmpty, aEmpty, 0); 2230 Execute_Impl(SID_STYLE_WATERCAN, 2231 GetSelectedEntry(), aEmpty, 2232 ( sal_uInt16 )GetFamilyItem_Impl()->GetFamily()); 2233 } 2234 // EnableEdit(sal_True); 2235 EnableItem(SID_STYLE_WATERCAN, !bWaterDisabled); 2236 EnableDelete(); 2237 } 2238 if( pListBox ) 2239 SelectStyle( pListBox->GetEntryText( pListBox->GetHdlEntry() )); 2240 2241 return 0; 2242 } 2243 2244 //------------------------------------------------------------------------- 2245 2246 IMPL_LINK( SfxCommonTemplateDialog_Impl, MenuSelectHdl, Menu *, pMenu ) 2247 { 2248 if( pMenu ) 2249 { 2250 nLastItemId = pMenu->GetCurItemId(); 2251 Application::PostUserEvent( 2252 LINK( this, SfxCommonTemplateDialog_Impl, MenuSelectHdl ), 0 ); 2253 return sal_True; 2254 } 2255 2256 switch(nLastItemId) { 2257 case ID_NEW: NewHdl(0); break; 2258 case ID_EDIT: EditHdl(0); break; 2259 case ID_DELETE: DeleteHdl(0); break; 2260 default: return sal_False; 2261 } 2262 return sal_True; 2263 } 2264 2265 // ----------------------------------------------------------------------- 2266 2267 void SfxCommonTemplateDialog_Impl::ExecuteContextMenu_Impl( const Point& rPos, Window* pWin ) 2268 { 2269 // Bug# 94152: This part should never be called, because before this happens, the TreeListBox should captured this! 2270 DBG_ASSERT( sal_False, "+SfxCommonTemplateDialog_Impl::ExecuteContextMenu_Impl(): How could this happen? Please infirm developer ASAP!" ); 2271 2272 PopupMenu* pMenu = CreateContextMenu(); 2273 pMenu->Execute( pWin, rPos ); 2274 delete pMenu; 2275 } 2276 2277 // ----------------------------------------------------------------------- 2278 2279 SfxStyleFamily SfxCommonTemplateDialog_Impl::GetActualFamily() const 2280 { 2281 const SfxStyleFamilyItem *pFamilyItem = GetFamilyItem_Impl(); 2282 if( !pFamilyItem || nActFamily == SFX_TEMPLDLG_FILTER_MAX ) 2283 return SFX_STYLE_FAMILY_PARA; 2284 else 2285 return pFamilyItem->GetFamily(); 2286 } 2287 2288 // ----------------------------------------------------------------------- 2289 2290 void SfxCommonTemplateDialog_Impl::EnableExample_Impl(sal_uInt16 nId, sal_Bool bEnable) 2291 { 2292 if( nId == SID_STYLE_NEW_BY_EXAMPLE ) 2293 bNewByExampleDisabled = !bEnable; 2294 else if( nId == SID_STYLE_UPDATE_BY_EXAMPLE ) 2295 bUpdateByExampleDisabled = !bEnable; 2296 EnableItem(nId, bEnable); 2297 } 2298 2299 void SfxCommonTemplateDialog_Impl::PrepareDeleteAction() 2300 { 2301 } 2302 2303 // ----------------------------------------------------------------------- 2304 2305 PopupMenu* SfxCommonTemplateDialog_Impl::CreateContextMenu( void ) 2306 { 2307 if ( bBindingUpdate ) 2308 { 2309 pBindings->Invalidate( SID_STYLE_NEW, sal_True, sal_False ); 2310 pBindings->Update( SID_STYLE_NEW ); 2311 bBindingUpdate = sal_False; 2312 } 2313 PopupMenu* pMenu = new PopupMenu( SfxResId( MN_CONTEXT_TEMPLDLG ) ); 2314 pMenu->SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, MenuSelectHdl ) ); 2315 pMenu->EnableItem( ID_EDIT, bCanEdit ); 2316 pMenu->EnableItem( ID_DELETE, bCanDel ); 2317 pMenu->EnableItem( ID_NEW, bCanNew ); 2318 2319 return pMenu; 2320 } 2321 2322 // ------------------------------------------------------------------------ 2323 2324 SfxTemplateDialog_Impl::SfxTemplateDialog_Impl( 2325 Window* /*pParent*/, SfxBindings* pB, SfxTemplateDialog* pDlgWindow ) : 2326 2327 SfxCommonTemplateDialog_Impl( pB, pDlgWindow ), 2328 2329 m_pFloat ( pDlgWindow ), 2330 m_bZoomIn ( sal_False ), 2331 m_aActionTbL ( pDlgWindow, this ), 2332 m_aActionTbR ( pDlgWindow, SfxResId( TB_ACTION ) ) 2333 2334 { 2335 pDlgWindow->FreeResource(); 2336 2337 // Read the filter stored in the configuration 2338 // This is already done in ReadResource(), invoked by Initialize() 2339 // and stored in nActFilter, but we can't rely on nActFilter's value 2340 // because it is changed in UpdateStyles_Impl 2341 SfxViewFrame* pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame(); 2342 pCurObjShell = pViewFrame->GetObjectShell(); 2343 const sal_uInt16 nConfigFilter = pCurObjShell ? 2344 static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pCurObjShell ) ) : 0; 2345 2346 Initialize(); 2347 2348 m_aActionTbL.SetSelectHdl(LINK(this, SfxTemplateDialog_Impl, ToolBoxLSelect)); 2349 m_aActionTbR.SetSelectHdl(LINK(this, SfxTemplateDialog_Impl, ToolBoxRSelect)); 2350 m_aActionTbR.SetDropdownClickHdl(LINK(this, SfxTemplateDialog_Impl, ToolBoxRClick)); 2351 m_aActionTbL.Show(); 2352 m_aActionTbR.Show(); 2353 Font aFont=aFilterLb.GetFont(); 2354 aFont.SetWeight( WEIGHT_NORMAL ); 2355 aFilterLb.SetFont( aFont ); 2356 m_aActionTbL.SetHelpId( HID_TEMPLDLG_TOOLBOX_LEFT ); 2357 2358 if ( nConfigFilter == SFX_TEMPLDLG_FILTER_HIERARCHICAL ) 2359 { 2360 bHierarchical = sal_False; 2361 aFilterLb.SelectEntry(String(SfxResId(STR_STYLE_FILTER_HIERARCHICAL))); 2362 FilterSelectHdl(&aFilterLb); 2363 } 2364 } 2365 2366 // ------------------------------------------------------------------------ 2367 2368 void SfxTemplateDialog_Impl::EnableFamilyItem( sal_uInt16 nId, sal_Bool bEnable ) 2369 { 2370 m_aActionTbL.EnableItem( nId, bEnable ); 2371 } 2372 2373 //------------------------------------------------------------------------- 2374 2375 void SfxTemplateDialog_Impl::InsertFamilyItem(sal_uInt16 nId,const SfxStyleFamilyItem *pItem) 2376 { 2377 rtl::OString sHelpId; 2378 switch( (sal_uInt16) pItem->GetFamily() ) 2379 { 2380 case SFX_STYLE_FAMILY_CHAR: sHelpId = ".uno:CharStyle"; break; 2381 case SFX_STYLE_FAMILY_PARA: sHelpId = ".uno:ParaStyle"; break; 2382 case SFX_STYLE_FAMILY_FRAME: sHelpId = ".uno:FrameStyle"; break; 2383 case SFX_STYLE_FAMILY_PAGE: sHelpId = ".uno:PageStyle"; break; 2384 case SFX_STYLE_FAMILY_PSEUDO: sHelpId = ".uno:ListStyle"; break; 2385 default: DBG_ERROR("unknown StyleFamily"); break; 2386 } 2387 m_aActionTbL.InsertItem( nId, pItem->GetImage(), pItem->GetText(), 0, 0); 2388 m_aActionTbL.SetHelpId( nId, sHelpId ); 2389 } 2390 2391 // ------------------------------------------------------------------------ 2392 2393 void SfxTemplateDialog_Impl::ReplaceUpdateButtonByMenu() 2394 { 2395 m_aActionTbR.HideItem(SID_STYLE_UPDATE_BY_EXAMPLE); 2396 m_aActionTbR.SetItemBits( SID_STYLE_NEW_BY_EXAMPLE, 2397 TIB_DROPDOWNONLY|m_aActionTbR.GetItemBits( SID_STYLE_NEW_BY_EXAMPLE )); 2398 } 2399 2400 // ------------------------------------------------------------------------ 2401 void SfxTemplateDialog_Impl::updateFamilyImages() 2402 { 2403 if ( !m_pStyleFamiliesId ) 2404 // we do not have a resource id to load the new images from 2405 return; 2406 2407 // let the families collection update the images 2408 sal_Bool bIsHighContrast = m_pFloat->GetSettings().GetStyleSettings().GetHighContrastMode(); 2409 pStyleFamilies->updateImages( *m_pStyleFamiliesId, bIsHighContrast ? BMP_COLOR_HIGHCONTRAST : BMP_COLOR_NORMAL ); 2410 2411 // and set the new images on our toolbox 2412 sal_uInt16 nLoop = pStyleFamilies->Count(); 2413 for( ; nLoop--; ) 2414 { 2415 const SfxStyleFamilyItem *pItem = pStyleFamilies->GetObject( nLoop ); 2416 sal_uInt16 nId = SfxFamilyIdToNId( pItem->GetFamily() ); 2417 m_aActionTbL.SetItemImage( nId, pItem->GetImage() ); 2418 } 2419 } 2420 2421 // ------------------------------------------------------------------------ 2422 void SfxTemplateDialog_Impl::updateNonFamilyImages() 2423 { 2424 m_aActionTbR.SetImageList( ImageList( SfxResId( 2425 m_pFloat->GetSettings().GetStyleSettings().GetHighContrastMode() ? IMG_LST_STYLE_DESIGNER_HC 2426 : DLG_STYLE_DESIGNER ) ) ); 2427 } 2428 2429 // ------------------------------------------------------------------------ 2430 2431 void SfxTemplateDialog_Impl::ClearFamilyList() 2432 { 2433 m_aActionTbL.Clear(); 2434 } 2435 2436 //------------------------------------------------------------------------- 2437 2438 void SfxCommonTemplateDialog_Impl::InvalidateBindings() 2439 { 2440 pBindings->Invalidate(SID_STYLE_NEW_BY_EXAMPLE, sal_True, sal_False); 2441 pBindings->Update( SID_STYLE_NEW_BY_EXAMPLE ); 2442 pBindings->Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE, sal_True, sal_False); 2443 pBindings->Update( SID_STYLE_UPDATE_BY_EXAMPLE ); 2444 pBindings->Invalidate( SID_STYLE_WATERCAN, sal_True, sal_False); 2445 pBindings->Update( SID_STYLE_WATERCAN ); 2446 pBindings->Invalidate( SID_STYLE_NEW, sal_True, sal_False ); 2447 pBindings->Update( SID_STYLE_NEW ); 2448 pBindings->Invalidate( SID_STYLE_DRAGHIERARCHIE, sal_True, sal_False ); 2449 pBindings->Update( SID_STYLE_DRAGHIERARCHIE ); 2450 } 2451 2452 //------------------------------------------------------------------------- 2453 2454 SfxTemplateDialog_Impl::~SfxTemplateDialog_Impl() 2455 { 2456 /* 2457 SfxImageManager* pImgMgr = pBindings->GetImageManager(); 2458 if ( pImgMgr ) 2459 { 2460 pImgMgr->ReleaseToolBox( &m_aActionTbL ); 2461 pImgMgr->ReleaseToolBox( &m_aActionTbR ); 2462 } 2463 */ 2464 } 2465 2466 //------------------------------------------------------------------------- 2467 2468 void SfxTemplateDialog_Impl::LoadedFamilies() 2469 { 2470 updateFamilyImages(); 2471 Resize(); 2472 } 2473 2474 //------------------------------------------------------------------------- 2475 2476 // "Uberladener Resize-Handler ( StarView ) 2477 // Die Groesse der Listboxen wird angepasst 2478 void SfxTemplateDialog_Impl::Resize() 2479 { 2480 FloatingWindow *pF = m_pFloat->GetFloatingWindow(); 2481 if ( pF ) 2482 { 2483 // if(pF->IsZoomedIn() && m_bZoomIn==sal_False) 2484 // pF->SetText(String(SfxResId( DLG_STYLE_DESIGNER ))); 2485 // if(!pF->IsZoomedIn() && m_bZoomIn==sal_True && GetFamilyItem_Impl()) 2486 // UpdateStyles_Impl(UPDATE_FAMILY); //Bereich wieder in Titel schreiben 2487 m_bZoomIn = pF->IsRollUp(); 2488 if ( m_bZoomIn ) 2489 return; 2490 } 2491 2492 Size aDlgSize=m_pFloat->PixelToLogic(m_pFloat->GetOutputSizePixel()); 2493 Size aSizeATL=m_pFloat->PixelToLogic(m_aActionTbL.CalcWindowSizePixel()); 2494 Size aSizeATR=m_pFloat->PixelToLogic(m_aActionTbR.CalcWindowSizePixel()); 2495 Size aMinSize = GetMinOutputSizePixel(); 2496 2497 long nListHeight = m_pFloat->PixelToLogic( aFilterLb.GetSizePixel() ).Height(); 2498 long nWidth = aDlgSize.Width()- 2 * SFX_TEMPLDLG_HFRAME; 2499 2500 m_aActionTbL.SetPosSizePixel(m_pFloat->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME,SFX_TEMPLDLG_VTOPFRAME)), 2501 m_pFloat->LogicToPixel(aSizeATL)); 2502 2503 // Die Position der rechten Toolbox nur ver"andern, wenn das Fenster 2504 // breit genug ist 2505 Point aPosATR(aDlgSize.Width()-SFX_TEMPLDLG_HFRAME-aSizeATR.Width(),SFX_TEMPLDLG_VTOPFRAME); 2506 if(aDlgSize.Width() >= aMinSize.Width()) 2507 m_aActionTbR.SetPosPixel(m_pFloat->LogicToPixel(aPosATR)); 2508 else 2509 m_aActionTbR.SetPosPixel( m_pFloat->LogicToPixel( 2510 Point( SFX_TEMPLDLG_HFRAME + aSizeATL.Width() + SFX_TEMPLDLG_MIDHSPACE, 2511 SFX_TEMPLDLG_VTOPFRAME ) ) ); 2512 2513 m_aActionTbR.SetSizePixel(m_pFloat->LogicToPixel(aSizeATR)); 2514 2515 Point aFilterPos( 2516 m_pFloat->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME, 2517 aDlgSize.Height()-SFX_TEMPLDLG_VBOTFRAME-nListHeight)) ); 2518 2519 Size aFilterSize( 2520 m_pFloat->LogicToPixel(Size(nWidth,SFX_TEMPLDLG_FILTERHEIGHT)) ); 2521 2522 Point aFmtPos( 2523 m_pFloat->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME, SFX_TEMPLDLG_VTOPFRAME + 2524 SFX_TEMPLDLG_MIDVSPACE+aSizeATL.Height())) ); 2525 Size aFmtSize( 2526 m_pFloat->LogicToPixel(Size(nWidth, 2527 aDlgSize.Height() - SFX_TEMPLDLG_VBOTFRAME - 2528 SFX_TEMPLDLG_VTOPFRAME - 2*SFX_TEMPLDLG_MIDVSPACE- 2529 nListHeight-aSizeATL.Height())) ); 2530 2531 // Die Position der Listboxen nur ver"andern, wenn das Fenster 2532 // hoch genug ist 2533 if(aDlgSize.Height() >= aMinSize.Height()) 2534 { 2535 aFilterLb.SetPosPixel(aFilterPos); 2536 aFmtLb.SetPosPixel( aFmtPos ); 2537 if(pTreeBox) 2538 pTreeBox->SetPosPixel(aFmtPos); 2539 } 2540 else 2541 aFmtSize.Height() += aFilterSize.Height(); 2542 2543 aFilterLb.SetSizePixel(aFilterSize); 2544 aFmtLb.SetSizePixel( aFmtSize ); 2545 if(pTreeBox) 2546 pTreeBox->SetSizePixel(aFmtSize); 2547 } 2548 2549 // ----------------------------------------------------------------------- 2550 2551 2552 Size SfxTemplateDialog_Impl::GetMinOutputSizePixel() 2553 { 2554 Size aSizeATL=m_pFloat->PixelToLogic(m_aActionTbL.CalcWindowSizePixel()); 2555 Size aSizeATR=m_pFloat->PixelToLogic(m_aActionTbR.CalcWindowSizePixel()); 2556 Size aMinSize=Size( 2557 aSizeATL.Width()+aSizeATR.Width()+ 2558 2*SFX_TEMPLDLG_HFRAME + SFX_TEMPLDLG_MIDHSPACE, 2559 4*aSizeATL.Height()+2*SFX_TEMPLDLG_MIDVSPACE); 2560 return aMinSize; 2561 } 2562 2563 //------------------------------------------------------------------------- 2564 2565 void SfxTemplateDialog_Impl::Command( const CommandEvent& rCEvt ) 2566 { 2567 if(COMMAND_CONTEXTMENU == rCEvt.GetCommand()) 2568 ExecuteContextMenu_Impl( rCEvt.GetMousePosPixel(), m_pFloat ); 2569 else 2570 m_pFloat->Command(rCEvt); 2571 } 2572 2573 //------------------------------------------------------------------------- 2574 2575 void SfxTemplateDialog_Impl::EnableItem(sal_uInt16 nMesId, sal_Bool bCheck) 2576 { 2577 String aEmpty; 2578 switch(nMesId) 2579 { 2580 case SID_STYLE_WATERCAN : 2581 if(!bCheck && IsCheckedItem(SID_STYLE_WATERCAN)) 2582 Execute_Impl(SID_STYLE_WATERCAN, aEmpty, aEmpty, 0); 2583 case SID_STYLE_NEW_BY_EXAMPLE: 2584 case SID_STYLE_UPDATE_BY_EXAMPLE: 2585 m_aActionTbR.EnableItem(nMesId,bCheck); 2586 break; 2587 } 2588 } 2589 2590 //------------------------------------------------------------------------- 2591 2592 void SfxTemplateDialog_Impl::CheckItem(sal_uInt16 nMesId, sal_Bool bCheck) 2593 { 2594 switch(nMesId) 2595 { 2596 case SID_STYLE_WATERCAN : 2597 bIsWater=bCheck; 2598 m_aActionTbR.CheckItem(SID_STYLE_WATERCAN,bCheck); 2599 break; 2600 default: 2601 m_aActionTbL.CheckItem(nMesId,bCheck); break; 2602 } 2603 } 2604 2605 //------------------------------------------------------------------------- 2606 2607 sal_Bool SfxTemplateDialog_Impl::IsCheckedItem(sal_uInt16 nMesId) 2608 { 2609 switch(nMesId) 2610 { 2611 case SID_STYLE_WATERCAN : 2612 return m_aActionTbR.GetItemState(SID_STYLE_WATERCAN)==STATE_CHECK; 2613 default: 2614 return m_aActionTbL.GetItemState(nMesId)==STATE_CHECK; 2615 } 2616 } 2617 2618 //------------------------------------------------------------------------- 2619 2620 IMPL_LINK_INLINE_START( SfxTemplateDialog_Impl, ToolBoxLSelect, ToolBox *, pBox ) 2621 { 2622 const sal_uInt16 nEntry = pBox->GetCurItemId(); 2623 FamilySelect(nEntry); 2624 return 0; 2625 } 2626 IMPL_LINK_INLINE_END( SfxTemplateDialog_Impl, ToolBoxLSelect, ToolBox *, pBox ) 2627 2628 //------------------------------------------------------------------------- 2629 ::rtl::OUString lcl_GetLabel(uno::Any& rAny) 2630 { 2631 ::rtl::OUString sRet; 2632 uno::Sequence< beans::PropertyValue >aPropSeq; 2633 if ( rAny >>= aPropSeq ) 2634 { 2635 for( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) 2636 { 2637 if ( aPropSeq[i].Name.equalsAscii( "Label" )) 2638 { 2639 aPropSeq[i].Value >>= sRet; 2640 break; 2641 } 2642 } 2643 } 2644 return sRet; 2645 } 2646 //------------------------------------------------------------------------- 2647 2648 IMPL_LINK( SfxTemplateDialog_Impl, ToolBoxRSelect, ToolBox *, pBox ) 2649 { 2650 const sal_uInt16 nEntry = pBox->GetCurItemId(); 2651 if(nEntry != SID_STYLE_NEW_BY_EXAMPLE || 2652 TIB_DROPDOWN != (pBox->GetItemBits(nEntry)&TIB_DROPDOWN)) 2653 ActionSelect(nEntry); 2654 return 0; 2655 } 2656 //------------------------------------------------------------------------- 2657 IMPL_LINK( SfxTemplateDialog_Impl, ToolBoxRClick, ToolBox *, pBox ) 2658 { 2659 const sal_uInt16 nEntry = pBox->GetCurItemId(); 2660 if(nEntry == SID_STYLE_NEW_BY_EXAMPLE && 2661 TIB_DROPDOWN == (pBox->GetItemBits(nEntry)&TIB_DROPDOWN)) 2662 { 2663 //create a popup menu in Writer 2664 PopupMenu *pMenu = new PopupMenu; 2665 uno::Reference< container::XNameAccess > xNameAccess( 2666 ::comphelper::getProcessServiceFactory()-> 2667 createInstance( ::rtl::OUString::createFromAscii( 2668 "com.sun.star.frame.UICommandDescription") ), uno::UNO_QUERY ); 2669 uno::Reference< container::XNameAccess > xUICommands; 2670 if ( xNameAccess.is() ) 2671 { 2672 rtl::OUString sTextDoc = ::rtl::OUString::createFromAscii("com.sun.star.text.TextDocument"); 2673 if(xNameAccess->hasByName(sTextDoc)) 2674 { 2675 uno::Any a = xNameAccess->getByName( sTextDoc ); 2676 a >>= xUICommands; 2677 } 2678 } 2679 if(!xUICommands.is()) 2680 return 0; 2681 try 2682 { 2683 uno::Sequence< beans::PropertyValue > aPropSeq; 2684 uno::Any aCommand = xUICommands->getByName(::rtl::OUString::createFromAscii(".uno:StyleNewByExample")); 2685 ::rtl::OUString sLabel = lcl_GetLabel( aCommand ); 2686 pMenu->InsertItem( SID_STYLE_NEW_BY_EXAMPLE, sLabel ); 2687 pMenu->SetHelpId(SID_STYLE_NEW_BY_EXAMPLE, HID_TEMPLDLG_NEWBYEXAMPLE); 2688 2689 aCommand = xUICommands->getByName(::rtl::OUString::createFromAscii(".uno:StyleUpdateByExample")); 2690 sLabel = lcl_GetLabel( aCommand ); 2691 2692 pMenu->InsertItem( SID_STYLE_UPDATE_BY_EXAMPLE, sLabel ); 2693 pMenu->SetHelpId(SID_STYLE_UPDATE_BY_EXAMPLE, HID_TEMPLDLG_UPDATEBYEXAMPLE); 2694 2695 aCommand = xUICommands->getByName(::rtl::OUString::createFromAscii(".uno:LoadStyles")); 2696 sLabel = lcl_GetLabel( aCommand ); 2697 pMenu->InsertItem( SID_TEMPLATE_LOAD, sLabel ); 2698 pMenu->SetHelpId(SID_TEMPLATE_LOAD, ".uno:LoadStyles"); 2699 2700 pMenu->SetSelectHdl(LINK(this, SfxTemplateDialog_Impl, MenuSelectHdl)); 2701 pMenu->Execute( pBox, 2702 pBox->GetItemRect(nEntry), 2703 POPUPMENU_EXECUTE_DOWN ); 2704 pBox->EndSelection(); 2705 } 2706 catch(uno::Exception&) 2707 { 2708 } 2709 delete pMenu; 2710 pBox->Invalidate(); 2711 } 2712 return 0; 2713 } 2714 //------------------------------------------------------------------------- 2715 IMPL_LINK( SfxTemplateDialog_Impl, MenuSelectHdl, Menu*, pMenu) 2716 { 2717 sal_uInt16 nMenuId = pMenu->GetCurItemId(); 2718 ActionSelect(nMenuId); 2719 return 0; 2720 } 2721 //------------------------------------------------------------------------- 2722 2723 SfxTemplateCatalog_Impl::SfxTemplateCatalog_Impl( Window* /*pParent*/, SfxBindings* pB, 2724 SfxTemplateCatalog* pTmpWindow ) : 2725 2726 SfxCommonTemplateDialog_Impl( pB, pTmpWindow ), 2727 2728 aFamList ( pTmpWindow, SfxResId( BT_TOOL ) ), 2729 aOkBtn ( pTmpWindow, SfxResId( BT_OK ) ), 2730 aCancelBtn ( pTmpWindow, SfxResId( BT_CANCEL ) ), 2731 aNewBtn ( pTmpWindow, SfxResId( BT_NEW ) ), 2732 aChangeBtn ( pTmpWindow, SfxResId( BT_EDIT ) ), 2733 aDelBtn ( pTmpWindow, SfxResId( BT_DEL ) ), 2734 aOrgBtn ( pTmpWindow, SfxResId( BT_ORG ) ), 2735 aHelpBtn ( pTmpWindow, SfxResId( BT_HELP ) ), 2736 pReal ( pTmpWindow ), 2737 aHelper ( pTmpWindow ) 2738 2739 { 2740 aNewBtn.Disable(); 2741 aDelBtn.Disable(); 2742 aChangeBtn.Disable(); 2743 2744 SFX_APP()->Get_Impl()->pTemplateCommon = GetISfxTemplateCommon(); 2745 pTmpWindow->FreeResource(); 2746 2747 Initialize(); 2748 2749 aFamList.SetSelectHdl( LINK( this, SfxTemplateCatalog_Impl, FamListSelect ) ); 2750 aOkBtn.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl, OkHdl ) ); 2751 aCancelBtn.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl, CancelHdl ) ); 2752 aNewBtn.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl, NewHdl ) ); 2753 aDelBtn.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl, DelHdl ) ); 2754 aChangeBtn.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl, ChangeHdl ) ); 2755 aOrgBtn.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl, OrgHdl ) ); 2756 } 2757 2758 //------------------------------------------------------------------------- 2759 2760 SfxTemplateCatalog_Impl::~SfxTemplateCatalog_Impl() 2761 { 2762 SFX_APP()->Get_Impl()->pTemplateCommon = 0; 2763 } 2764 2765 //------------------------------------------------------------------------- 2766 2767 IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, OkHdl, Button *, pButton ) 2768 { 2769 (void)pButton; //unused 2770 ApplyHdl( NULL ); 2771 pReal->EndDialog( RET_OK ); 2772 return 0; 2773 } 2774 IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, OkHdl, Button *, pButton ) 2775 2776 //------------------------------------------------------------------------- 2777 2778 IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, CancelHdl, Button *, pButton ) 2779 { 2780 (void)pButton; //unused 2781 pReal->EndDialog( RET_CANCEL ); 2782 return 0; 2783 } 2784 IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, CancelHdl, Button *, pButton ) 2785 2786 //------------------------------------------------------------------------- 2787 2788 IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, NewHdl, Button *, pButton ) 2789 { 2790 (void)pButton; //unused 2791 aCancelBtn.SetText( String( SfxResId( STR_CLOSE ) ) ); 2792 SfxCommonTemplateDialog_Impl::NewHdl( NULL ); 2793 return 0; 2794 } 2795 IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, NewHdl, Button *, pButton ) 2796 2797 //------------------------------------------------------------------------- 2798 2799 IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, ChangeHdl, Button *, pButton ) 2800 { 2801 (void)pButton; //unused 2802 aCancelBtn.SetText( String( SfxResId( STR_CLOSE ) ) ); 2803 SfxCommonTemplateDialog_Impl::EditHdl( NULL ); 2804 return 0; 2805 } 2806 IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, ChangeHdl, Button *, pButton ) 2807 2808 //------------------------------------------------------------------------- 2809 2810 IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, DelHdl, Button *, pButton ) 2811 { 2812 (void)pButton; //unused 2813 SfxCommonTemplateDialog_Impl::DeleteHdl( NULL ); 2814 return 0; 2815 } 2816 IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, DelHdl, Button *, pButton ) 2817 2818 //------------------------------------------------------------------------- 2819 2820 IMPL_LINK( SfxTemplateCatalog_Impl, OrgHdl, Button *, pButton ) 2821 { 2822 (void)pButton; //unused 2823 aCancelBtn.SetText( String( SfxResId( STR_CLOSE ) ) ); 2824 SfxDocumentTemplates aTemplates; 2825 aTemplates.Construct(); 2826 SfxTemplateOrganizeDlg* pDlg = new SfxTemplateOrganizeDlg( pReal, &aTemplates ); 2827 const short nRet = pDlg->Execute(); 2828 delete pDlg; 2829 if ( RET_OK == nRet ) 2830 Update_Impl(); 2831 else if ( RET_EDIT_STYLE == nRet ) 2832 pReal->EndDialog( RET_CANCEL ); 2833 return 0; 2834 } 2835 2836 //------------------------------------------------------------------------- 2837 2838 void SfxTemplateCatalog_Impl::EnableEdit( sal_Bool bEnable ) 2839 { 2840 SfxCommonTemplateDialog_Impl::EnableEdit( bEnable ); 2841 aChangeBtn.Enable( bEnable ); 2842 } 2843 2844 //------------------------------------------------------------------------- 2845 2846 void SfxTemplateCatalog_Impl::EnableDel( sal_Bool bEnable ) 2847 { 2848 SfxCommonTemplateDialog_Impl::EnableDel( bEnable ); 2849 aDelBtn.Enable( bEnable ); 2850 } 2851 2852 void SfxTemplateCatalog_Impl::EnableNew(sal_Bool bEnable) 2853 { 2854 SfxCommonTemplateDialog_Impl::EnableNew( bEnable ); 2855 aNewBtn.Enable( bEnable ); 2856 } 2857 2858 //------------------------------------------------------------------------- 2859 2860 IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, FamListSelect, ListBox *, pList ) 2861 { 2862 const sal_uInt16 nEntry = aFamIds[pList->GetSelectEntryPos()]; 2863 FamilySelect(nEntry); 2864 return 0; 2865 } 2866 IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, FamListSelect, ListBox *, pList ) 2867 2868 //------------------------------------------------------------------------- 2869 2870 void SfxTemplateCatalog_Impl::EnableItem( sal_uInt16 nMesId, sal_Bool bCheck ) 2871 { 2872 if ( nMesId == SID_STYLE_WATERCAN ) 2873 aOkBtn.Enable( bCheck ); 2874 if ( nMesId > SFX_STYLE_FAMILY_PSEUDO || nMesId < SFX_STYLE_FAMILY_CHAR ) 2875 return; 2876 2877 /* for(sal_uInt16 i=0;i<aFamIds.Count&&aFamIds[i]!=nMesId;i++); 2878 if(i!=aFamIds.Count()) 2879 aFamList.SelectEntry(aFamIds[i]); 2880 else 2881 DBG_ERROR("Entry nicht gefunden");*/ 2882 2883 } 2884 2885 //------------------------------------------------------------------------- 2886 2887 void SfxTemplateCatalog_Impl::CheckItem(sal_uInt16 nMesId, sal_Bool /*bCheck*/) 2888 { 2889 if ( nMesId > SFX_STYLE_FAMILY_PSEUDO || nMesId < SFX_STYLE_FAMILY_CHAR ) 2890 return; 2891 sal_uInt16 i; 2892 for ( i = 0; i < aFamIds.Count() && aFamIds[i] != nMesId; i++ ) ; 2893 aFamList.SelectEntryPos(i); 2894 } 2895 2896 //------------------------------------------------------------------------- 2897 2898 sal_Bool SfxTemplateCatalog_Impl::IsCheckedItem(sal_uInt16 nMesId) 2899 { 2900 if ( nMesId > SFX_STYLE_FAMILY_PSEUDO || nMesId < SFX_STYLE_FAMILY_CHAR ) 2901 return sal_False; 2902 sal_uInt16 i; 2903 for ( i = 0; i < aFamIds.Count() && aFamIds[i] != nMesId; i++ ) 2904 ; 2905 return aFamList.IsEntrySelected( String::CreateFromInt32(i) ); 2906 } 2907 2908 //------------------------------------------------------------------------- 2909 2910 // Der Katalog muss nur das Disablen beherrschen, da waehrend seiner 2911 // Lebenszeit keine Selektionsaenderungen vorgenommen werden koennen 2912 void SfxTemplateCatalog_Impl::EnableFamilyItem( sal_uInt16 nId, sal_Bool bEnable ) 2913 { 2914 if ( !bEnable ) 2915 for ( sal_uInt16 nPos = aFamIds.Count(); nPos--; ) 2916 if ( aFamIds[ nPos ] == nId ) 2917 { 2918 aFamIds.Remove( nPos ); 2919 aFamList.RemoveEntry( nPos ); 2920 } 2921 } 2922 2923 void SfxTemplateCatalog_Impl::InsertFamilyItem( sal_uInt16 nId, const SfxStyleFamilyItem* pItem ) 2924 { 2925 if ( nId > SFX_STYLE_FAMILY_PSEUDO || nId < SFX_STYLE_FAMILY_CHAR ) 2926 return; 2927 aFamList.InsertEntry( pItem->GetText(), 0 ); 2928 aFamIds.Insert( nId, 0 ); 2929 } 2930 2931 void SfxTemplateCatalog_Impl::ClearFamilyList() 2932 { 2933 aFamList.Clear(); 2934 aFamIds.Remove( 0, aFamIds.Count() ); 2935 } 2936 2937 void SfxTemplateCatalog_Impl::PrepareDeleteAction() 2938 { 2939 aDelBtn.Disable(); 2940 aCancelBtn.SetText( String( SfxResId( STR_CLOSE ) ) ); 2941 } 2942 2943 2944 void SfxCommonTemplateDialog_Impl::SetFamily( sal_uInt16 nId ) 2945 { 2946 if ( nId != nActFamily ) 2947 { 2948 if ( nActFamily != SFX_TEMPLDLG_FILTER_MAX ) 2949 CheckItem( nActFamily, sal_False ); 2950 nActFamily = nId; 2951 if ( nId != SFX_TEMPLDLG_FILTER_MAX ) 2952 bUpdateFamily = sal_True; 2953 } 2954 } 2955 2956 void SfxCommonTemplateDialog_Impl::UpdateFamily_Impl() 2957 { 2958 bUpdateFamily = sal_False; 2959 2960 SfxDispatcher* pDispat = pBindings->GetDispatcher_Impl(); 2961 SfxViewFrame *pViewFrame = pDispat->GetFrame(); 2962 SfxObjectShell *pDocShell = pViewFrame->GetObjectShell(); 2963 2964 SfxStyleSheetBasePool *pOldStyleSheetPool = pStyleSheetPool; 2965 pStyleSheetPool = pDocShell? pDocShell->GetStyleSheetPool(): 0; 2966 if ( pOldStyleSheetPool != pStyleSheetPool ) 2967 { 2968 if ( pOldStyleSheetPool ) 2969 EndListening(*pOldStyleSheetPool); 2970 if ( pStyleSheetPool ) 2971 StartListening(*pOldStyleSheetPool); 2972 } 2973 2974 bWaterDisabled = sal_False; 2975 bCanNew = sal_True; 2976 bTreeDrag = sal_True; 2977 bUpdateByExampleDisabled = sal_False; 2978 2979 if ( pStyleSheetPool ) 2980 { 2981 if(!pTreeBox) 2982 UpdateStyles_Impl(UPDATE_FAMILY | UPDATE_FAMILY_LIST); 2983 else 2984 { 2985 UpdateStyles_Impl(UPDATE_FAMILY); 2986 FillTreeBox(); 2987 } 2988 } 2989 2990 InvalidateBindings(); 2991 2992 if ( IsCheckedItem( SID_STYLE_WATERCAN ) && 2993 // nur, wenn dieser Bereich erlaubt ist 2994 0 != pFamilyState[ nActFamily - 1 ] ) 2995 Execute_Impl( SID_STYLE_APPLY, GetSelectedEntry(), 2996 String(), (sal_uInt16)GetFamilyItem_Impl()->GetFamily() ); 2997 } 2998 void SfxCommonTemplateDialog_Impl::ReplaceUpdateButtonByMenu() 2999 { 3000 //does nothing 3001 } 3002 3003 void SfxTemplateDialog::StateChanged( StateChangedType nStateChange ) 3004 { 3005 if ( nStateChange == STATE_CHANGE_INITSHOW ) 3006 { 3007 SfxViewFrame *pFrame = GetBindings().GetDispatcher_Impl()->GetFrame(); 3008 Window* pEditWin = pFrame->GetViewShell()->GetWindow(); 3009 3010 Size aSize = pEditWin->GetSizePixel(); 3011 Point aPoint = pEditWin->OutputToScreenPixel( pEditWin->GetPosPixel() ); 3012 aPoint = GetParent()->ScreenToOutputPixel( aPoint ); 3013 Size aWinSize = GetSizePixel(); 3014 aPoint.X() += aSize.Width() - aWinSize.Width() - 20; 3015 aPoint.Y() += aSize.Height() / 2 - aWinSize.Height() / 2; 3016 SetFloatingPos( aPoint ); 3017 } 3018 3019 SfxDockingWindow::StateChanged( nStateChange ); 3020 } 3021 3022 /*-- 10.12.2003 11:44:35--------------------------------------------------- 3023 3024 -----------------------------------------------------------------------*/ 3025 DropToolBox_Impl::DropToolBox_Impl(Window* pParent, SfxTemplateDialog_Impl* pTemplateDialog) : 3026 ToolBox(pParent), 3027 DropTargetHelper(this), 3028 rParent(*pTemplateDialog) 3029 { 3030 } 3031 /*-- 10.12.2003 11:44:35--------------------------------------------------- 3032 3033 -----------------------------------------------------------------------*/ 3034 DropToolBox_Impl::~DropToolBox_Impl() 3035 { 3036 } 3037 /*-- 10.12.2003 11:44:35--------------------------------------------------- 3038 3039 -----------------------------------------------------------------------*/ 3040 sal_Int8 DropToolBox_Impl::AcceptDrop( const AcceptDropEvent& rEvt ) 3041 { 3042 sal_Int8 nReturn = DND_ACTION_NONE; 3043 sal_uInt16 nItemId = GetItemId( rEvt.maPosPixel ); 3044 if(USHRT_MAX != nItemId && !IsItemChecked( nItemId )) 3045 { 3046 SetCurItemId(nItemId); 3047 GetSelectHdl().Call(this); 3048 } 3049 // special case: page styles are allowed to create new styles by example 3050 // but not allowed to be created by drag and drop 3051 if ( nItemId != SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SFX_STYLE_FAMILY_PAGE )&& 3052 IsDropFormatSupported( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) && 3053 !rParent.bNewByExampleDisabled ) 3054 { 3055 nReturn = DND_ACTION_COPY; 3056 } 3057 return nReturn; 3058 } 3059 /*-- 10.12.2003 11:44:35--------------------------------------------------- 3060 3061 -----------------------------------------------------------------------*/ 3062 sal_Int8 DropToolBox_Impl::ExecuteDrop( const ExecuteDropEvent& rEvt ) 3063 { 3064 return rParent.aFmtLb.ExecuteDrop(rEvt); 3065 } 3066 3067