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