1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 31 32 #include <sot/formats.hxx> 33 #include <vcl/msgbox.hxx> 34 #include <svtools/valueset.hxx> 35 #include <svl/urlbmk.hxx> 36 #include <svl/stritem.hxx> 37 #include <svl/intitem.hxx> 38 #include <svl/eitem.hxx> 39 #include <svtools/transfer.hxx> 40 #include <sfx2/bindings.hxx> 41 #include <sfx2/dispatch.hxx> 42 #include <sfx2/viewfrm.hxx> 43 #include <sfx2/sfxsids.hrc> 44 #include "svtools/filter.hxx" 45 #include <editeng/brshitem.hxx> 46 #include "helpid.hrc" 47 #include "svx/gallery.hxx" 48 #include "galobj.hxx" 49 #include "svx/gallery1.hxx" 50 #include "svx/galtheme.hxx" 51 #include "svx/galctrl.hxx" 52 #include "svx/galmisc.hxx" 53 #include "galbrws2.hxx" 54 #include "gallery.hrc" 55 #include <vcl/svapp.hxx> 56 #include <svx/fmmodel.hxx> 57 #include <svx/dialmgr.hxx> 58 #include <svx/svxdlg.hxx> 59 #include <svx/dialogs.hrc> 60 61 // ----------- 62 // - Defines - 63 // ----------- 64 65 #undef GALLERY_USE_CLIPBOARD 66 67 #define TBX_ID_ICON 1 68 #define TBX_ID_LIST 2 69 70 // ----------- 71 // - statics - 72 // ----------- 73 74 GalleryBrowserMode GalleryBrowser2::meInitMode = GALLERYBROWSERMODE_ICON; 75 76 // -------------------------- 77 // - GalleryBackgroundPopup - 78 // -------------------------- 79 80 class GalleryBackgroundPopup : public PopupMenu, public SfxControllerItem 81 { 82 const GalleryTheme* mpTheme; 83 sal_uIntPtr mnObjectPos; 84 85 virtual void Select(); 86 virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ); 87 88 public: 89 90 GalleryBackgroundPopup( const GalleryTheme* pTheme, sal_uIntPtr nObjectPos ); 91 ~GalleryBackgroundPopup(); 92 }; 93 94 // ------------------------------------------------------------------------ 95 DBG_NAME(GalleryBackgroundPopup) 96 97 GalleryBackgroundPopup::GalleryBackgroundPopup( const GalleryTheme* pTheme, sal_uIntPtr nObjectPos ) : 98 SfxControllerItem ( SID_GALLERY_BG_BRUSH, SfxViewFrame::Current()->GetBindings() ), 99 mpTheme ( pTheme ), 100 mnObjectPos ( nObjectPos ) 101 { 102 DBG_CTOR(GalleryBackgroundPopup,NULL); 103 104 SfxViewFrame::Current()->GetBindings().Update( SID_GALLERY_BG_BRUSH ); 105 RemoveDisabledEntries(); 106 } 107 108 // ------------------------------------------------------------------------ 109 110 GalleryBackgroundPopup::~GalleryBackgroundPopup() 111 { 112 113 DBG_DTOR(GalleryBackgroundPopup,NULL); 114 } 115 116 // ------------------------------------------------------------------------ 117 118 void GalleryBackgroundPopup::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pItem ) 119 { 120 if ( ( nSID == SID_GALLERY_BG_BRUSH ) && pItem && ( eState != SFX_ITEM_DISABLED ) ) 121 { 122 SfxStringListItem* pStrLstItem; 123 SfxStringItem* pStrItem; 124 125 PopupMenu::Clear(); 126 127 if( ( pStrLstItem = PTR_CAST( SfxStringListItem, pItem ) ) != NULL ) 128 { 129 List* pList = pStrLstItem->GetList(); 130 131 if( pList ) 132 for ( sal_uIntPtr i = 0, nCount = pList->Count(); i < nCount; i++ ) 133 InsertItem( (sal_uInt16) i + 1, *(String*) pList->GetObject( i ) ); 134 } 135 else if( ( pStrItem = PTR_CAST( SfxStringItem, pItem ) ) != NULL ) 136 InsertItem( 1, pStrItem->GetValue() ); 137 else 138 { 139 DBG_ERROR( "SgaBGPopup::StateChanged(...): Wrong item type!" ); 140 } 141 } 142 } 143 144 // ------------------------------------------------------------------------ 145 146 void GalleryBackgroundPopup::Select() 147 { 148 Menu::Select(); 149 150 const INetURLObject aURL( mpTheme->GetObjectURL( mnObjectPos ) ); 151 const SvxBrushItem aBrushItem( aURL.GetMainURL( INetURLObject::NO_DECODE ), String(), GPOS_TILED, SID_GALLERY_BG_BRUSH ); 152 const SfxUInt16Item aPosItem( SID_GALLERY_BG_POS, GetCurItemId() - 1 ); 153 const SfxStringItem aPathItem( SID_FILE_NAME, aURL.GetMainURL( INetURLObject::NO_DECODE ) ); 154 155 SfxViewFrame::Current()->GetBindings().GetDispatcher()->Execute( SID_GALLERY_BG_BRUSH, 156 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, 157 &aBrushItem, &aPosItem, &aPathItem, 0L ); 158 } 159 160 // --------------------- 161 // - GalleryThemePopup - 162 // --------------------- 163 164 class GalleryThemePopup : public PopupMenu, public SfxControllerItem 165 { 166 GalleryBackgroundPopup maBackgroundPopup; 167 const GalleryTheme* mpTheme; 168 sal_uIntPtr mnObjectPos; 169 sal_Bool mbPreview; 170 171 virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ); 172 173 public: 174 175 GalleryThemePopup( const GalleryTheme* pTheme, sal_uIntPtr nObjectPos, sal_Bool bPreview ); 176 ~GalleryThemePopup(); 177 }; 178 179 // ------------------------------------------------------------------------ 180 DBG_NAME(GalleryThemePopup) 181 182 GalleryThemePopup::GalleryThemePopup( const GalleryTheme* pTheme, sal_uIntPtr nObjectPos, sal_Bool bPreview ) : 183 PopupMenu ( GAL_RESID( RID_SVXMN_GALLERY2 ) ), 184 SfxControllerItem ( SID_GALLERY_ENABLE_ADDCOPY, SfxViewFrame::Current()->GetBindings() ), 185 maBackgroundPopup ( pTheme, nObjectPos ), 186 mpTheme ( pTheme ), 187 mnObjectPos ( nObjectPos ), 188 mbPreview ( bPreview ) 189 { 190 DBG_CTOR(GalleryThemePopup,NULL); 191 192 const SgaObjKind eObjKind = mpTheme->GetObjectKind( mnObjectPos ); 193 PopupMenu* pAddMenu = GetPopupMenu( MN_ADDMENU ); 194 SfxBindings& rBindings = SfxViewFrame::Current()->GetBindings(); 195 INetURLObject aURL; 196 197 const_cast< GalleryTheme* >( mpTheme )->GetURL( mnObjectPos, aURL ); 198 const sal_Bool bValidURL = ( aURL.GetProtocol() != INET_PROT_NOT_VALID ); 199 200 pAddMenu->EnableItem( MN_ADD, bValidURL && SGA_OBJ_SOUND != eObjKind ); 201 pAddMenu->EnableItem( MN_ADD_LINK, bValidURL && SGA_OBJ_SVDRAW != eObjKind ); 202 203 EnableItem( MN_ADDMENU, pAddMenu->IsItemEnabled( MN_ADD ) || pAddMenu->IsItemEnabled( MN_ADD_LINK ) ); 204 EnableItem( MN_PREVIEW, bValidURL ); 205 206 CheckItem( MN_PREVIEW, mbPreview ); 207 208 if( mpTheme->IsReadOnly() || !mpTheme->GetObjectCount() ) 209 { 210 EnableItem( MN_DELETE, sal_False ); 211 EnableItem( MN_TITLE, sal_False ); 212 213 if( mpTheme->IsReadOnly() ) 214 EnableItem( MN_PASTECLIPBOARD, sal_False ); 215 216 if( !mpTheme->GetObjectCount() ) 217 EnableItem( MN_COPYCLIPBOARD, sal_False ); 218 } 219 else 220 { 221 EnableItem( MN_DELETE, !bPreview ); 222 EnableItem( MN_TITLE, sal_True ); 223 EnableItem( MN_COPYCLIPBOARD, sal_True ); 224 EnableItem( MN_PASTECLIPBOARD, sal_True ); 225 } 226 227 #ifdef GALLERY_USE_CLIPBOARD 228 if( IsItemEnabled( MN_PASTECLIPBOARD ) ) 229 { 230 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( this ) ); 231 sal_Bool bEnable = sal_False; 232 233 if( aDataHelper.GetFormatCount() ) 234 { 235 if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ) || 236 aDataHelper.HasFormat( SOT_FORMAT_FILE_LIST ) || 237 aDataHelper.HasFormat( FORMAT_FILE ) || 238 aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ) || 239 aDataHelper.HasFormat( FORMAT_GDIMETAFILE ) || 240 aDataHelper.HasFormat( FORMAT_BITMAP ) ) 241 { 242 bEnable = sal_True; 243 } 244 } 245 246 if( !bEnable ) 247 EnableItem( MN_PASTECLIPBOARD, sal_False ); 248 } 249 #else 250 EnableItem( MN_COPYCLIPBOARD, sal_False ); 251 EnableItem( MN_PASTECLIPBOARD, sal_False ); 252 #endif 253 254 if( !maBackgroundPopup.GetItemCount() || ( eObjKind == SGA_OBJ_SVDRAW ) || ( eObjKind == SGA_OBJ_SOUND ) ) 255 pAddMenu->EnableItem( MN_BACKGROUND, sal_False ); 256 else 257 { 258 pAddMenu->EnableItem( MN_BACKGROUND, sal_True ); 259 pAddMenu->SetPopupMenu( MN_BACKGROUND, &maBackgroundPopup ); 260 } 261 262 rBindings.Update( SID_GALLERY_ENABLE_ADDCOPY ); 263 RemoveDisabledEntries(); 264 } 265 266 // ------------------------------------------------------------------------ 267 268 GalleryThemePopup::~GalleryThemePopup() 269 { 270 271 DBG_DTOR(GalleryThemePopup,NULL); 272 } 273 274 // ------------------------------------------------------------------------ 275 276 void GalleryThemePopup::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pItem ) 277 { 278 if( ( nSID == SID_GALLERY_ENABLE_ADDCOPY ) && pItem && ( eState != SFX_ITEM_DISABLED ) ) 279 { 280 SfxBoolItem* pBoolItem = PTR_CAST( SfxBoolItem, pItem ); 281 const SgaObjKind eObjKind = mpTheme->GetObjectKind( mnObjectPos ); 282 283 DBG_ASSERT( pBoolItem || pBoolItem == 0, "SfxBoolItem erwartet!"); 284 285 GetPopupMenu( MN_ADDMENU )->EnableItem( MN_ADD, pBoolItem->GetValue() && ( eObjKind != SGA_OBJ_SOUND ) ); 286 } 287 } 288 289 // ------------------ 290 // - GalleryToolBox - 291 // ------------------ 292 DBG_NAME(GalleryToolBox) 293 294 GalleryToolBox::GalleryToolBox( GalleryBrowser2* pParent ) : 295 ToolBox( pParent, WB_TABSTOP ) 296 { 297 DBG_CTOR(GalleryToolBox,NULL); 298 299 } 300 301 // ------------------------------------------------------------------------ 302 303 GalleryToolBox::~GalleryToolBox() 304 { 305 306 DBG_DTOR(GalleryToolBox,NULL); 307 } 308 309 // ------------------------------------------------------------------------ 310 311 void GalleryToolBox::KeyInput( const KeyEvent& rKEvt ) 312 { 313 if( !static_cast< GalleryBrowser2* >( GetParent() )->KeyInput( rKEvt, this ) ) 314 ToolBox::KeyInput( rKEvt ); 315 } 316 317 // ------------------- 318 // - GalleryBrowser2 - 319 // ------------------- 320 DBG_NAME(GalleryBrowser2) 321 322 GalleryBrowser2::GalleryBrowser2( GalleryBrowser* pParent, const ResId& rResId, Gallery* pGallery ) : 323 Control ( pParent, rResId ), 324 mpGallery ( pGallery ), 325 mpCurTheme ( NULL ), 326 mpIconView ( new GalleryIconView( this, NULL ) ), 327 mpListView ( new GalleryListView( this, NULL ) ), 328 mpPreview ( new GalleryPreview( this, NULL ) ), 329 maViewBox ( this ), 330 maSeparator ( this, WB_VERT ), 331 maInfoBar ( this, WB_LEFT | WB_VCENTER ), 332 mnCurActionPos ( 0xffffffff ), 333 meMode ( GALLERYBROWSERMODE_NONE ), 334 meLastMode ( GALLERYBROWSERMODE_NONE ), 335 mbCurActionIsLinkage( sal_False ) 336 { 337 DBG_CTOR(GalleryBrowser2,NULL); 338 339 Image aDummyImage; 340 const Link aSelectHdl( LINK( this, GalleryBrowser2, SelectObjectHdl ) ); 341 Font aInfoFont( maInfoBar.GetControlFont() ); 342 343 maMiscOptions.AddListenerLink( LINK( this, GalleryBrowser2, MiscHdl ) ); 344 345 maViewBox.InsertItem( TBX_ID_ICON, aDummyImage ); 346 maViewBox.SetItemBits( TBX_ID_ICON, TIB_RADIOCHECK | TIB_AUTOCHECK ); 347 maViewBox.SetHelpId( TBX_ID_ICON, HID_GALLERY_ICONVIEW ); 348 maViewBox.SetQuickHelpText( TBX_ID_ICON, String( GAL_RESID( RID_SVXSTR_GALLERY_ICONVIEW ) ) ); 349 350 maViewBox.InsertItem( TBX_ID_LIST, aDummyImage ); 351 maViewBox.SetItemBits( TBX_ID_LIST, TIB_RADIOCHECK | TIB_AUTOCHECK ); 352 maViewBox.SetHelpId( TBX_ID_LIST, HID_GALLERY_LISTVIEW ); 353 maViewBox.SetQuickHelpText( TBX_ID_LIST, String( GAL_RESID( RID_SVXSTR_GALLERY_LISTVIEW ) ) ); 354 355 maViewBox.SetBorder( 0, 1 ); 356 MiscHdl( NULL ); 357 maViewBox.SetSelectHdl( LINK( this, GalleryBrowser2, SelectTbxHdl ) ); 358 maViewBox.Show(); 359 360 mpIconView->SetAccessibleName(String( SVX_RES( RID_SVXSTR_GALLERY_THEMEITEMS ) )); 361 mpListView->SetAccessibleName(String( SVX_RES( RID_SVXSTR_GALLERY_THEMEITEMS ) )); 362 363 maInfoBar.Show(); 364 maSeparator.Show(); 365 366 mpIconView->SetSelectHdl( aSelectHdl ); 367 mpListView->SetSelectHdl( aSelectHdl ); 368 369 InitSettings(); 370 371 SetMode( ( GALLERYBROWSERMODE_PREVIEW != GalleryBrowser2::meInitMode ) ? GalleryBrowser2::meInitMode : GALLERYBROWSERMODE_ICON ); 372 373 if(maInfoBar.GetText().Len() == 0) 374 mpIconView->SetAccessibleRelationLabeledBy(mpIconView); 375 else 376 mpIconView->SetAccessibleRelationLabeledBy(&maInfoBar); 377 mpIconView->SetAccessibleRelationMemberOf(mpIconView); 378 } 379 380 // ----------------------------------------------------------------------------- 381 382 GalleryBrowser2::~GalleryBrowser2() 383 { 384 maMiscOptions.RemoveListenerLink( LINK( this, GalleryBrowser2, MiscHdl ) ); 385 386 delete mpPreview; 387 delete mpListView; 388 delete mpIconView; 389 390 if( mpCurTheme ) 391 mpGallery->ReleaseTheme( mpCurTheme, *this ); 392 393 DBG_DTOR(GalleryBrowser2,NULL); 394 } 395 396 // ----------------------------------------------------------------------------- 397 398 void GalleryBrowser2::InitSettings() 399 { 400 Font aInfoFont( maInfoBar.GetControlFont() ); 401 402 aInfoFont.SetWeight( WEIGHT_BOLD ); 403 aInfoFont.SetColor( GALLERY_FG_COLOR ); 404 maInfoBar.SetControlFont( aInfoFont ); 405 406 maInfoBar.SetBackground( Wallpaper( GALLERY_DLG_COLOR ) ); 407 maInfoBar.SetControlBackground( GALLERY_DLG_COLOR ); 408 409 maSeparator.SetBackground( Wallpaper( GALLERY_BG_COLOR ) ); 410 maSeparator.SetControlBackground( GALLERY_BG_COLOR ); 411 maSeparator.SetControlForeground( GALLERY_FG_COLOR ); 412 } 413 414 // ----------------------------------------------------------------------------- 415 416 void GalleryBrowser2::DataChanged( const DataChangedEvent& rDCEvt ) 417 { 418 if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) 419 InitSettings(); 420 else 421 Control::DataChanged( rDCEvt ); 422 } 423 424 // ----------------------------------------------------------------------------- 425 426 void GalleryBrowser2::Resize() 427 { 428 Control::Resize(); 429 430 mpIconView->Hide(); 431 mpListView->Hide(); 432 mpPreview->Hide(); 433 434 const Size aOutSize( GetOutputSizePixel() ); 435 const Size aBoxSize( maViewBox.GetOutputSizePixel() ); 436 const long nOffset = 2, nSepWidth = 2; 437 const long nInfoBarX = aBoxSize.Width() + ( nOffset * 3 ) + nSepWidth; 438 const Point aPt( 0, aBoxSize.Height() + 3 ); 439 const Size aSz( aOutSize.Width(), aOutSize.Height() - aPt.Y() ); 440 441 maSeparator.SetPosSizePixel( Point( aBoxSize.Width() + nOffset, 0 ), Size( nSepWidth, aBoxSize.Height() ) ); 442 maInfoBar.SetPosSizePixel( Point( nInfoBarX, 0 ), Size( aOutSize.Width() - nInfoBarX, aBoxSize.Height() ) ); 443 444 mpIconView->SetPosSizePixel( aPt, aSz ); 445 mpListView->SetPosSizePixel( aPt, aSz ); 446 mpPreview->SetPosSizePixel( aPt, aSz ); 447 448 switch( GetMode() ) 449 { 450 case( GALLERYBROWSERMODE_ICON ): mpIconView->Show(); break; 451 case( GALLERYBROWSERMODE_LIST ): mpListView->Show(); break; 452 case( GALLERYBROWSERMODE_PREVIEW ): mpPreview->Show(); break; 453 454 default: 455 break; 456 } 457 } 458 459 // ----------------------------------------------------------------------------- 460 461 void GalleryBrowser2::Notify( SfxBroadcaster&, const SfxHint& rHint ) 462 { 463 const GalleryHint& rGalleryHint = (const GalleryHint&) rHint; 464 465 switch( rGalleryHint.GetType() ) 466 { 467 case( GALLERY_HINT_THEME_UPDATEVIEW ): 468 { 469 if( GALLERYBROWSERMODE_PREVIEW == GetMode() ) 470 SetMode( meLastMode ); 471 472 ImplUpdateViews( (sal_uInt16) rGalleryHint.GetData1() + 1 ); 473 } 474 break; 475 476 default: 477 break; 478 } 479 } 480 481 // ----------------------------------------------------------------------------- 482 483 sal_Int8 GalleryBrowser2::AcceptDrop( DropTargetHelper& rTarget, const AcceptDropEvent& ) 484 { 485 sal_Int8 nRet = DND_ACTION_NONE; 486 487 if( mpCurTheme && !mpCurTheme->IsReadOnly() && !mpCurTheme ->IsImported() ) 488 { 489 if( !mpCurTheme->IsDragging() ) 490 { 491 if( rTarget.IsDropFormatSupported( SOT_FORMATSTR_ID_DRAWING ) || 492 rTarget.IsDropFormatSupported( SOT_FORMAT_FILE_LIST ) || 493 rTarget.IsDropFormatSupported( FORMAT_FILE ) || 494 rTarget.IsDropFormatSupported( SOT_FORMATSTR_ID_SVXB ) || 495 rTarget.IsDropFormatSupported( FORMAT_GDIMETAFILE ) || 496 rTarget.IsDropFormatSupported( FORMAT_BITMAP ) ) 497 { 498 nRet = DND_ACTION_COPY; 499 } 500 } 501 else 502 nRet = DND_ACTION_COPY; 503 } 504 505 return nRet; 506 } 507 508 // ----------------------------------------------------------------------------- 509 510 sal_Int8 GalleryBrowser2::ExecuteDrop( DropTargetHelper&, const ExecuteDropEvent& rEvt ) 511 { 512 sal_Int8 nRet = DND_ACTION_NONE; 513 514 if( mpCurTheme ) 515 { 516 Point aSelPos; 517 const sal_uIntPtr nItemId = ImplGetSelectedItemId( &rEvt.maPosPixel, aSelPos ); 518 const sal_uIntPtr nInsertPos = ( nItemId ? ( nItemId - 1 ) : LIST_APPEND ); 519 520 if( mpCurTheme->IsDragging() ) 521 mpCurTheme->ChangeObjectPos( mpCurTheme->GetDragPos(), nInsertPos ); 522 else 523 nRet = mpCurTheme->InsertTransferable( rEvt.maDropEvent.Transferable, nInsertPos ); 524 } 525 526 return nRet; 527 } 528 529 // ----------------------------------------------------------------------------- 530 531 void GalleryBrowser2::StartDrag( Window*, const Point* pDragPoint ) 532 { 533 if( mpCurTheme ) 534 { 535 Point aSelPos; 536 const sal_uIntPtr nItemId = ImplGetSelectedItemId( pDragPoint, aSelPos ); 537 538 if( nItemId ) 539 mpCurTheme->StartDrag( this, nItemId - 1 ); 540 } 541 } 542 543 // ----------------------------------------------------------------------------- 544 545 void GalleryBrowser2::TogglePreview( Window*, const Point* ) 546 { 547 SetMode( ( GALLERYBROWSERMODE_PREVIEW != GetMode() ) ? GALLERYBROWSERMODE_PREVIEW : meLastMode ); 548 GetViewWindow()->GrabFocus(); 549 } 550 551 // ----------------------------------------------------------------------------- 552 553 void GalleryBrowser2::ShowContextMenu( Window*, const Point* pContextPoint ) 554 { 555 Point aSelPos; 556 const sal_uIntPtr nItemId = ImplGetSelectedItemId( pContextPoint, aSelPos ); 557 558 if( mpCurTheme && nItemId && ( nItemId <= mpCurTheme->GetObjectCount() ) ) 559 { 560 ImplSelectItemId( nItemId ); 561 562 SfxViewFrame* pCurrentViewFrame = SfxViewFrame::Current(); 563 if ( pCurrentViewFrame ) 564 { 565 SfxBindings& rBindings = pCurrentViewFrame->GetBindings(); 566 rBindings.ENTERREGISTRATIONS(); 567 GalleryThemePopup aMenu( mpCurTheme, nItemId - 1, GALLERYBROWSERMODE_PREVIEW == GetMode() ); 568 rBindings.LEAVEREGISTRATIONS(); 569 aMenu.SetSelectHdl( LINK( this, GalleryBrowser2, MenuSelectHdl ) ); 570 aMenu.Execute( this, aSelPos ); 571 } 572 } 573 } 574 575 // ----------------------------------------------------------------------------- 576 577 sal_Bool GalleryBrowser2::KeyInput( const KeyEvent& rKEvt, Window* pWindow ) 578 { 579 Point aSelPos; 580 const sal_uIntPtr nItemId = ImplGetSelectedItemId( NULL, aSelPos ); 581 sal_Bool bRet = static_cast< GalleryBrowser* >( GetParent() )->KeyInput( rKEvt, pWindow ); 582 583 if( !bRet && !maViewBox.HasFocus() && nItemId && mpCurTheme ) 584 { 585 sal_uInt16 nExecuteId = 0; 586 const SgaObjKind eObjKind = mpCurTheme->GetObjectKind( nItemId - 1 ); 587 INetURLObject aURL; 588 589 const_cast< GalleryTheme* >( mpCurTheme )->GetURL( nItemId - 1, aURL ); 590 591 const sal_Bool bValidURL = ( aURL.GetProtocol() != INET_PROT_NOT_VALID ); 592 sal_Bool bPreview = bValidURL; 593 sal_Bool bAdd = bValidURL; 594 sal_Bool bAddLink = ( bValidURL && SGA_OBJ_SVDRAW != eObjKind ); 595 sal_Bool bDelete = sal_False; 596 sal_Bool bTitle = sal_False; 597 598 if( !mpCurTheme->IsReadOnly() && mpCurTheme->GetObjectCount() ) 599 { 600 bDelete = ( GALLERYBROWSERMODE_PREVIEW != GetMode() ); 601 bTitle = sal_True; 602 } 603 604 switch( rKEvt.GetKeyCode().GetCode() ) 605 { 606 case( KEY_SPACE ): 607 case( KEY_RETURN ): 608 case( KEY_P ): 609 { 610 if( bPreview ) 611 { 612 TogglePreview( pWindow ); 613 bRet = sal_True; 614 } 615 } 616 break; 617 618 case( KEY_INSERT ): 619 case( KEY_I ): 620 { 621 if( bAddLink && rKEvt.GetKeyCode().IsShift() && rKEvt.GetKeyCode().IsMod1() ) 622 nExecuteId = MN_ADD_LINK; 623 else if( bAdd ) 624 nExecuteId = MN_ADD; 625 } 626 break; 627 628 case( KEY_DELETE ): 629 case( KEY_D ): 630 { 631 if( bDelete ) 632 nExecuteId = MN_DELETE; 633 } 634 break; 635 636 case( KEY_T ): 637 { 638 if( bTitle ) 639 nExecuteId = MN_TITLE; 640 } 641 break; 642 643 default: 644 break; 645 } 646 647 if( nExecuteId ) 648 { 649 ImplExecute( nExecuteId ); 650 bRet = sal_True; 651 } 652 } 653 654 return bRet; 655 } 656 657 // ----------------------------------------------------------------------------- 658 659 void GalleryBrowser2::SelectTheme( const String& rThemeName ) 660 { 661 delete mpIconView, mpIconView = NULL; 662 delete mpListView, mpListView = NULL; 663 delete mpPreview, mpPreview = NULL; 664 665 if( mpCurTheme ) 666 mpGallery->ReleaseTheme( mpCurTheme, *this ); 667 668 mpCurTheme = mpGallery->AcquireTheme( rThemeName, *this ); 669 670 mpIconView = new GalleryIconView( this, mpCurTheme ); 671 mpListView = new GalleryListView( this, mpCurTheme ); 672 mpPreview = new GalleryPreview( this, mpCurTheme ); 673 674 mpIconView->SetAccessibleName(String( SVX_RES( RID_SVXSTR_GALLERY_THEMEITEMS ) )); 675 mpListView->SetAccessibleName(String( SVX_RES( RID_SVXSTR_GALLERY_THEMEITEMS ) )); 676 mpPreview->SetAccessibleName(String( SVX_RES( RID_SVXSTR_GALLERY_PREVIEW ) )); 677 678 const Link aSelectHdl( LINK( this, GalleryBrowser2, SelectObjectHdl ) ); 679 680 mpIconView->SetSelectHdl( aSelectHdl ); 681 mpListView->SetSelectHdl( aSelectHdl ); 682 683 if( GALLERYBROWSERMODE_PREVIEW == GetMode() ) 684 meMode = meLastMode; 685 686 Resize(); 687 ImplUpdateViews( 1 ); 688 689 maViewBox.EnableItem( TBX_ID_ICON, sal_True ); 690 maViewBox.EnableItem( TBX_ID_LIST, sal_True ); 691 maViewBox.CheckItem( ( GALLERYBROWSERMODE_ICON == GetMode() ) ? TBX_ID_ICON : TBX_ID_LIST, sal_True ); 692 693 if(maInfoBar.GetText().Len() == 0) 694 mpIconView->SetAccessibleRelationLabeledBy(mpIconView); 695 else 696 mpIconView->SetAccessibleRelationLabeledBy(&maInfoBar); 697 mpIconView->SetAccessibleRelationMemberOf(mpIconView); 698 } 699 700 // ----------------------------------------------------------------------------- 701 702 void GalleryBrowser2::SetMode( GalleryBrowserMode eMode ) 703 { 704 if( GetMode() != eMode ) 705 { 706 meLastMode = GetMode(); 707 708 switch( eMode ) 709 { 710 case( GALLERYBROWSERMODE_ICON ): 711 { 712 mpListView->Hide(); 713 714 mpPreview->Hide(); 715 mpPreview->SetGraphic( Graphic() ); 716 mpPreview->PreviewMedia( INetURLObject() ); 717 718 mpIconView->Show(); 719 720 maViewBox.EnableItem( TBX_ID_ICON, sal_True ); 721 maViewBox.EnableItem( TBX_ID_LIST, sal_True ); 722 723 maViewBox.CheckItem( TBX_ID_ICON, sal_True ); 724 maViewBox.CheckItem( TBX_ID_LIST, sal_False ); 725 } 726 break; 727 728 case( GALLERYBROWSERMODE_LIST ): 729 { 730 mpIconView->Hide(); 731 732 mpPreview->Hide(); 733 mpPreview->SetGraphic( Graphic() ); 734 mpPreview->PreviewMedia( INetURLObject() ); 735 736 mpListView->Show(); 737 738 maViewBox.EnableItem( TBX_ID_ICON, sal_True ); 739 maViewBox.EnableItem( TBX_ID_LIST, sal_True ); 740 741 maViewBox.CheckItem( TBX_ID_ICON, sal_False ); 742 maViewBox.CheckItem( TBX_ID_LIST, sal_True ); 743 } 744 break; 745 746 case( GALLERYBROWSERMODE_PREVIEW ): 747 { 748 Graphic aGraphic; 749 Point aSelPos; 750 const sal_uIntPtr nItemId = ImplGetSelectedItemId( NULL, aSelPos ); 751 752 if( nItemId ) 753 { 754 const sal_uIntPtr nPos = nItemId - 1; 755 756 mpIconView->Hide(); 757 mpListView->Hide(); 758 759 if( mpCurTheme ) 760 mpCurTheme->GetGraphic( nPos, aGraphic ); 761 762 mpPreview->SetGraphic( aGraphic ); 763 mpPreview->Show(); 764 765 if( mpCurTheme && mpCurTheme->GetObjectKind( nPos ) == SGA_OBJ_SOUND ) 766 mpPreview->PreviewMedia( mpCurTheme->GetObjectURL( nPos ) ); 767 768 maViewBox.EnableItem( TBX_ID_ICON, sal_False ); 769 maViewBox.EnableItem( TBX_ID_LIST, sal_False ); 770 } 771 } 772 break; 773 774 default: 775 break; 776 } 777 778 GalleryBrowser2::meInitMode = meMode = eMode; 779 } 780 } 781 782 // ----------------------------------------------------------------------------- 783 784 Window* GalleryBrowser2::GetViewWindow() const 785 { 786 Window* pRet; 787 788 switch( GetMode() ) 789 { 790 case( GALLERYBROWSERMODE_LIST ): pRet = mpListView; break; 791 case( GALLERYBROWSERMODE_PREVIEW ): pRet = mpPreview; break; 792 793 default: 794 pRet = mpIconView; 795 break; 796 } 797 798 return pRet; 799 } 800 801 // ----------------------------------------------------------------------------- 802 803 void GalleryBrowser2::Travel( GalleryBrowserTravel eTravel ) 804 { 805 if( mpCurTheme ) 806 { 807 Point aSelPos; 808 const sal_uIntPtr nItemId = ImplGetSelectedItemId( NULL, aSelPos ); 809 810 if( nItemId ) 811 { 812 sal_uIntPtr nNewItemId = nItemId; 813 814 switch( eTravel ) 815 { 816 case( GALLERYBROWSERTRAVEL_FIRST ): nNewItemId = 1; break; 817 case( GALLERYBROWSERTRAVEL_LAST ): nNewItemId = mpCurTheme->GetObjectCount(); break; 818 case( GALLERYBROWSERTRAVEL_PREVIOUS ): nNewItemId--; break; 819 case( GALLERYBROWSERTRAVEL_NEXT ): nNewItemId++; break; 820 default: 821 break; 822 } 823 824 if( nNewItemId < 1 ) 825 nNewItemId = 1; 826 else if( nNewItemId > mpCurTheme->GetObjectCount() ) 827 nNewItemId = mpCurTheme->GetObjectCount(); 828 829 if( nNewItemId != nItemId ) 830 { 831 ImplSelectItemId( nNewItemId ); 832 ImplUpdateInfoBar(); 833 834 if( GALLERYBROWSERMODE_PREVIEW == GetMode() ) 835 { 836 Graphic aGraphic; 837 const sal_uIntPtr nPos = nNewItemId - 1; 838 839 mpCurTheme->GetGraphic( nPos, aGraphic ); 840 mpPreview->SetGraphic( aGraphic ); 841 842 if( SGA_OBJ_SOUND == mpCurTheme->GetObjectKind( nPos ) ) 843 mpPreview->PreviewMedia( mpCurTheme->GetObjectURL( nPos ) ); 844 845 mpPreview->Invalidate(); 846 } 847 } 848 } 849 } 850 } 851 852 // ----------------------------------------------------------------------------- 853 854 void GalleryBrowser2::ImplUpdateViews( sal_uInt16 nSelectionId ) 855 { 856 mpIconView->Hide(); 857 mpListView->Hide(); 858 mpPreview->Hide(); 859 860 mpIconView->Clear(); 861 mpListView->Clear(); 862 863 if( mpCurTheme ) 864 { 865 for( sal_uIntPtr i = 0, nCount = mpCurTheme->GetObjectCount(); i < nCount; ) 866 { 867 mpListView->RowInserted( i++ ); 868 mpIconView->InsertItem( (sal_uInt16) i ); 869 } 870 871 ImplSelectItemId( ( ( nSelectionId > mpCurTheme->GetObjectCount() ) ? mpCurTheme->GetObjectCount() : nSelectionId ) ); 872 } 873 874 switch( GetMode() ) 875 { 876 case( GALLERYBROWSERMODE_ICON ): mpIconView->Show(); break; 877 case( GALLERYBROWSERMODE_LIST ): mpListView->Show(); break; 878 case( GALLERYBROWSERMODE_PREVIEW ): mpPreview->Show(); break; 879 880 default: 881 break; 882 } 883 884 ImplUpdateInfoBar(); 885 } 886 887 // ----------------------------------------------------------------------------- 888 889 void GalleryBrowser2::ImplUpdateInfoBar() 890 { 891 String aInfoText; 892 893 if( mpCurTheme ) 894 { 895 Point aSelPos; 896 const sal_uIntPtr nItemId = ImplGetSelectedItemId( NULL, aSelPos ); 897 898 if( nItemId ) 899 { 900 const sal_uIntPtr nPos = nItemId - 1; 901 902 aInfoText = mpCurTheme->GetName(); 903 904 if( nPos < mpCurTheme->GetObjectCount() ) 905 { 906 SgaObject* pObj = mpCurTheme->AcquireObject( nPos ); 907 908 if( pObj ) 909 { 910 aInfoText = GetItemText( *mpCurTheme, *pObj, GALLERY_ITEM_THEMENAME | GALLERY_ITEM_TITLE | GALLERY_ITEM_PATH ); 911 mpCurTheme->ReleaseObject( pObj ); 912 } 913 } 914 } 915 } 916 917 maInfoBar.SetText( aInfoText ); 918 } 919 920 // ----------------------------------------------------------------------------- 921 922 sal_uIntPtr GalleryBrowser2::ImplGetSelectedItemId( const Point* pSelPos, Point& rSelPos ) 923 { 924 const Size aOutputSizePixel( GetOutputSizePixel() ); 925 sal_uIntPtr nRet = 0; 926 927 if( GALLERYBROWSERMODE_PREVIEW == GetMode() ) 928 { 929 nRet = ( ( GALLERYBROWSERMODE_ICON == meLastMode ) ? mpIconView->GetSelectItemId() : ( mpListView->FirstSelectedRow() + 1 ) ); 930 931 if( pSelPos ) 932 rSelPos = GetPointerPosPixel(); 933 else 934 rSelPos = Point( aOutputSizePixel.Width() >> 1, aOutputSizePixel.Height() >> 1 ); 935 } 936 else if( GALLERYBROWSERMODE_ICON == GetMode() ) 937 { 938 if( pSelPos ) 939 { 940 nRet = mpIconView->GetItemId( *pSelPos ); 941 rSelPos = GetPointerPosPixel(); 942 } 943 else 944 { 945 nRet = mpIconView->GetSelectItemId(); 946 rSelPos = mpIconView->GetItemRect( (sal_uInt16) nRet ).Center(); 947 } 948 } 949 else 950 { 951 if( pSelPos ) 952 { 953 nRet = mpListView->GetRowAtYPosPixel( pSelPos->Y() ) + 1; 954 rSelPos = GetPointerPosPixel(); 955 } 956 else 957 { 958 nRet = mpListView->FirstSelectedRow() + 1; 959 rSelPos = mpListView->GetFieldRectPixel( (sal_uInt16) nRet, 1 ).Center(); 960 } 961 } 962 963 rSelPos.X() = Max( Min( rSelPos.X(), aOutputSizePixel.Width() - 1L ), 0L ); 964 rSelPos.Y() = Max( Min( rSelPos.Y(), aOutputSizePixel.Height() - 1L ), 0L ); 965 966 if( nRet && ( !mpCurTheme || ( nRet > mpCurTheme->GetObjectCount() ) ) ) 967 { 968 nRet = 0; 969 } 970 971 return nRet; 972 } 973 974 // ----------------------------------------------------------------------------- 975 976 void GalleryBrowser2::ImplSelectItemId( sal_uIntPtr nItemId ) 977 { 978 if( nItemId ) 979 { 980 981 mpIconView->SelectItem( (sal_uInt16) nItemId ); 982 mpListView->SelectRow( nItemId - 1 ); 983 } 984 } 985 986 // ----------------------------------------------------------------------------- 987 988 void GalleryBrowser2::ImplExecute( sal_uInt16 nId ) 989 { 990 Point aSelPos; 991 const sal_uIntPtr nItemId = ImplGetSelectedItemId( NULL, aSelPos ); 992 993 if( mpCurTheme && nItemId ) 994 { 995 mnCurActionPos = nItemId - 1; 996 997 switch( nId ) 998 { 999 case( MN_ADD ): 1000 case( MN_ADD_LINK ): 1001 { 1002 sal_uInt32 nFormat = 0; 1003 1004 mbCurActionIsLinkage = ( MN_ADD_LINK == nId ); 1005 1006 switch( mpCurTheme->GetObjectKind( mnCurActionPos ) ) 1007 { 1008 case( SGA_OBJ_BMP ): 1009 case( SGA_OBJ_ANIM ): 1010 case( SGA_OBJ_INET ): 1011 nFormat = SGA_FORMAT_GRAPHIC | SGA_FORMAT_STRING; 1012 break; 1013 1014 case ( SGA_OBJ_SOUND ) : 1015 nFormat = SGA_FORMAT_SOUND | SGA_FORMAT_STRING; 1016 break; 1017 1018 case( SGA_OBJ_SVDRAW ): 1019 nFormat = SGA_FORMAT_GRAPHIC | SGA_FORMAT_SVDRAW | SGA_FORMAT_STRING; 1020 break; 1021 1022 default : 1023 break; 1024 } 1025 1026 const SfxUInt32Item aItem( SID_GALLERY_FORMATS, nFormat ); 1027 SfxViewFrame::Current()->GetBindings().GetDispatcher()->Execute( 1028 SID_GALLERY_FORMATS, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L ); 1029 } 1030 break; 1031 1032 case( MN_PREVIEW ): 1033 SetMode( ( GALLERYBROWSERMODE_PREVIEW != GetMode() ) ? GALLERYBROWSERMODE_PREVIEW : meLastMode ); 1034 break; 1035 1036 case( MN_DELETE ): 1037 { 1038 if( !mpCurTheme->IsReadOnly() && 1039 QueryBox( NULL, WB_YES_NO, String( GAL_RESID( RID_SVXSTR_GALLERY_DELETEOBJ ) ) ).Execute() == RET_YES ) 1040 { 1041 mpCurTheme->RemoveObject( mnCurActionPos ); 1042 } 1043 } 1044 break; 1045 1046 case( MN_TITLE ): 1047 { 1048 SgaObject* pObj = mpCurTheme->AcquireObject( mnCurActionPos ); 1049 1050 if( pObj ) 1051 { 1052 const String aOldTitle( GetItemText( *mpCurTheme, *pObj, GALLERY_ITEM_TITLE ) ); 1053 //CHINA001 TitleDialog aDlg( this, aOldTitle ); 1054 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 1055 if(pFact) 1056 { 1057 AbstractTitleDialog* aDlg = pFact->CreateTitleDialog( this, aOldTitle ); 1058 DBG_ASSERT(aDlg, "Dialogdiet fail!");//CHINA001 1059 if( aDlg->Execute() == RET_OK )//CHINA001 if( aDlg.Execute() == RET_OK ) 1060 { 1061 String aNewTitle( aDlg->GetTitle() );//CHINA001 String aNewTitle( aDlg.GetTitle() ); 1062 1063 if( ( !aNewTitle.Len() && pObj->GetTitle().Len() ) || ( aNewTitle != aOldTitle ) ) 1064 { 1065 if( !aNewTitle.Len() ) 1066 aNewTitle = String( RTL_CONSTASCII_USTRINGPARAM( "__<empty>__" ) ); 1067 1068 pObj->SetTitle( aNewTitle ); 1069 mpCurTheme->InsertObject( *pObj ); 1070 } 1071 } 1072 1073 mpCurTheme->ReleaseObject( pObj ); 1074 delete aDlg; //add CHINA001 1075 } 1076 } 1077 } 1078 break; 1079 1080 case( MN_COPYCLIPBOARD ): 1081 { 1082 Window* pWindow; 1083 1084 switch( GetMode() ) 1085 { 1086 case( GALLERYBROWSERMODE_ICON ): pWindow = (Window*) mpIconView; break; 1087 case( GALLERYBROWSERMODE_LIST ): pWindow = (Window*) mpListView; break; 1088 case( GALLERYBROWSERMODE_PREVIEW ): pWindow = (Window*) mpPreview; break; 1089 1090 default: 1091 pWindow = NULL; 1092 break; 1093 } 1094 1095 mpCurTheme->CopyToClipboard( pWindow, mnCurActionPos ); 1096 } 1097 break; 1098 1099 case( MN_PASTECLIPBOARD ): 1100 { 1101 if( !mpCurTheme->IsReadOnly() ) 1102 { 1103 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( this ) ); 1104 mpCurTheme->InsertTransferable( aDataHelper.GetTransferable(), mnCurActionPos ); 1105 } 1106 } 1107 break; 1108 1109 default: 1110 break; 1111 } 1112 } 1113 } 1114 1115 // ----------------------------------------------------------------------------- 1116 1117 String GalleryBrowser2::GetItemText( const GalleryTheme& rTheme, const SgaObject& rObj, sal_uIntPtr nItemTextFlags ) 1118 { 1119 INetURLObject aURL; 1120 String aRet; 1121 1122 if( rTheme.IsImported() ) 1123 { 1124 aURL = rTheme.GetParent()->GetImportURL( rTheme.GetName() ); 1125 1126 aURL.removeSegment(); 1127 aURL.Append( rObj.GetURL().GetName() ); 1128 } 1129 else 1130 aURL = rObj.GetURL(); 1131 1132 if( nItemTextFlags & GALLERY_ITEM_THEMENAME ) 1133 { 1134 aRet += rTheme.GetName(); 1135 aRet += String( RTL_CONSTASCII_USTRINGPARAM( " - " ) ); 1136 } 1137 1138 if( nItemTextFlags & GALLERY_ITEM_TITLE ) 1139 { 1140 String aTitle( rObj.GetTitle() ); 1141 1142 if( !aTitle.Len() ) 1143 aTitle = aURL.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_UNAMBIGUOUS ); 1144 1145 if( !aTitle.Len() ) 1146 { 1147 aTitle = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ); 1148 aTitle = aTitle.GetToken( aTitle.GetTokenCount( '/' ) - 1, '/' ); 1149 } 1150 1151 aRet += aTitle; 1152 } 1153 1154 if( nItemTextFlags & GALLERY_ITEM_PATH ) 1155 { 1156 const String aPath( aURL.getFSysPath( INetURLObject::FSYS_DETECT ) ); 1157 1158 if( aPath.Len() && ( nItemTextFlags & GALLERY_ITEM_TITLE ) ) 1159 aRet += String( RTL_CONSTASCII_USTRINGPARAM( " (" ) ); 1160 1161 aRet += String(aURL.getFSysPath( INetURLObject::FSYS_DETECT )); 1162 1163 if( aPath.Len() && ( nItemTextFlags & GALLERY_ITEM_TITLE ) ) 1164 aRet += ')'; 1165 } 1166 1167 return aRet; 1168 } 1169 1170 // ----------------------------------------------------------------------------- 1171 1172 INetURLObject GalleryBrowser2::GetURL() const 1173 { 1174 INetURLObject aURL; 1175 1176 if( mpCurTheme && mnCurActionPos != 0xffffffff ) 1177 aURL = mpCurTheme->GetObjectURL( mnCurActionPos ); 1178 1179 return aURL; 1180 } 1181 1182 // ----------------------------------------------------------------------------- 1183 1184 String GalleryBrowser2::GetFilterName() const 1185 { 1186 String aFilterName; 1187 1188 if( mpCurTheme && mnCurActionPos != 0xffffffff ) 1189 { 1190 const SgaObjKind eObjKind = mpCurTheme->GetObjectKind( mnCurActionPos ); 1191 1192 if( ( SGA_OBJ_BMP == eObjKind ) || ( SGA_OBJ_ANIM == eObjKind ) ) 1193 { 1194 GraphicFilter* pFilter = GraphicFilter::GetGraphicFilter(); 1195 INetURLObject aURL; mpCurTheme->GetURL( mnCurActionPos, aURL ); 1196 sal_uInt16 nFilter = pFilter->GetImportFormatNumberForShortName( aURL.GetExtension() ); 1197 1198 if( GRFILTER_FORMAT_DONTKNOW != nFilter ) 1199 aFilterName = pFilter->GetImportFormatName( nFilter ); 1200 } 1201 } 1202 1203 return aFilterName; 1204 } 1205 1206 // ----------------------------------------------------------------------------- 1207 1208 Graphic GalleryBrowser2::GetGraphic() const 1209 { 1210 Graphic aGraphic; 1211 1212 if( mpCurTheme && mnCurActionPos != 0xffffffff ) 1213 mpCurTheme->GetGraphic( mnCurActionPos, aGraphic ); 1214 1215 return aGraphic; 1216 } 1217 1218 // ----------------------------------------------------------------------------- 1219 1220 sal_Bool GalleryBrowser2::GetVCDrawModel( FmFormModel& rModel ) const 1221 { 1222 sal_Bool bRet = sal_False; 1223 1224 if( mpCurTheme && mnCurActionPos != 0xffffffff ) 1225 bRet = mpCurTheme->GetModel( mnCurActionPos, rModel ); 1226 1227 return bRet; 1228 } 1229 1230 // ----------------------------------------------------------------------------- 1231 1232 sal_Bool GalleryBrowser2::IsLinkage() const 1233 { 1234 return mbCurActionIsLinkage; 1235 } 1236 1237 // ----------------------------------------------------------------------------- 1238 1239 IMPL_LINK( GalleryBrowser2, MenuSelectHdl, Menu*, pMenu ) 1240 { 1241 if( pMenu ) 1242 ImplExecute( pMenu->GetCurItemId() ); 1243 1244 return 0; 1245 } 1246 1247 // ----------------------------------------------------------------------------- 1248 1249 IMPL_LINK( GalleryBrowser2, SelectObjectHdl, void*, EMPTYARG ) 1250 { 1251 ImplUpdateInfoBar(); 1252 return 0L; 1253 } 1254 1255 // ----------------------------------------------------------------------------- 1256 1257 IMPL_LINK( GalleryBrowser2, SelectTbxHdl, ToolBox*, pBox ) 1258 { 1259 if( pBox->GetCurItemId() == TBX_ID_ICON ) 1260 SetMode( GALLERYBROWSERMODE_ICON ); 1261 else if( pBox->GetCurItemId() == TBX_ID_LIST ) 1262 SetMode( GALLERYBROWSERMODE_LIST ); 1263 1264 return 0L; 1265 } 1266 1267 // ----------------------------------------------------------------------------- 1268 1269 IMPL_LINK( GalleryBrowser2, MiscHdl, void*, EMPTYARG ) 1270 { 1271 const sal_Bool bHC = maViewBox.GetSettings().GetStyleSettings().GetHighContrastMode(); 1272 1273 maViewBox.SetOutStyle( maMiscOptions.GetToolboxStyle() ); 1274 1275 BitmapEx aIconBmpEx = BitmapEx( Image( GAL_RESID( bHC? RID_SVXIMG_GALLERY_VIEW_ICON_HC : RID_SVXIMG_GALLERY_VIEW_ICON ) ).GetBitmapEx() ); 1276 BitmapEx aListBmpEx = BitmapEx( Image( GAL_RESID( bHC? RID_SVXIMG_GALLERY_VIEW_LIST_HC : RID_SVXIMG_GALLERY_VIEW_LIST ) ).GetBitmapEx() ); 1277 1278 if( maMiscOptions.AreCurrentSymbolsLarge() ) 1279 { 1280 const Size aLargeSize( 24, 24); 1281 1282 aIconBmpEx.Scale( aLargeSize ); 1283 aListBmpEx.Scale( aLargeSize ); 1284 } 1285 1286 maViewBox.SetItemImage( TBX_ID_ICON, aIconBmpEx ); 1287 maViewBox.SetItemImage( TBX_ID_LIST, aListBmpEx ); 1288 maViewBox.SetSizePixel( maViewBox.CalcWindowSizePixel() ); 1289 1290 Resize(); 1291 1292 return 0L; 1293 } 1294