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