bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / gallery2 / galbrws2.cxx
blobbfa02e4b522f33006bbcb9eaae9ced43227c9c81
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <comphelper/string.hxx>
22 #include <sot/formats.hxx>
23 #include <vcl/msgbox.hxx>
24 #include <svl/urlbmk.hxx>
25 #include <svl/stritem.hxx>
26 #include <svl/intitem.hxx>
27 #include <svl/eitem.hxx>
28 #include <svtools/transfer.hxx>
29 #include <sfx2/bindings.hxx>
30 #include <sfx2/dispatch.hxx>
31 #include <sfx2/viewfrm.hxx>
32 #include <sfx2/sfxsids.hrc>
33 #include <vcl/graphicfilter.hxx>
34 #include <editeng/brushitem.hxx>
35 #include "helpid.hrc"
36 #include "svx/gallery.hxx"
37 #include "galobj.hxx"
38 #include "svx/gallery1.hxx"
39 #include "svx/galtheme.hxx"
40 #include "svx/galctrl.hxx"
41 #include "svx/galmisc.hxx"
42 #include "galbrws2.hxx"
43 #include "gallery.hrc"
44 #include <vcl/svapp.hxx>
45 #include <vcl/settings.hxx>
46 #include <svx/fmmodel.hxx>
47 #include <svx/dialmgr.hxx>
48 #include <svx/svxdlg.hxx>
49 #include <svx/dialogs.hrc>
50 #include "GalleryControl.hxx"
52 #include <svx/svxcommands.h>
53 #include <svx/galleryitem.hxx>
54 #include <comphelper/processfactory.hxx>
55 #include <com/sun/star/frame/FrameSearchFlag.hpp>
56 #include <com/sun/star/gallery/GalleryItemType.hpp>
57 #include <com/sun/star/graphic/XGraphic.hpp>
58 #include <com/sun/star/style/GraphicLocation.hpp>
59 #include <map>
60 #include <boost/scoped_ptr.hpp>
62 #undef GALLERY_USE_CLIPBOARD
64 #define TBX_ID_ICON 1
65 #define TBX_ID_LIST 2
67 GalleryBrowserMode GalleryBrowser2::meInitMode = GALLERYBROWSERMODE_ICON;
69 struct DispatchInfo
71 css::util::URL TargetURL;
72 css::uno::Sequence< css::beans::PropertyValue > Arguments;
73 css::uno::Reference< css::frame::XDispatch > Dispatch;
76 IMPL_STATIC_LINK( GalleryBrowser2, AsyncDispatch_Impl, DispatchInfo*, pDispatchInfo )
78 if ( pDispatchInfo && pDispatchInfo->Dispatch.is() )
80 try
82 pDispatchInfo->Dispatch->dispatch( pDispatchInfo->TargetURL,
83 pDispatchInfo->Arguments );
85 catch ( const css::uno::Exception& )
90 delete pDispatchInfo;
91 return 0;
94 namespace
97 struct CommandInfo
99 css::util::URL URL;
100 css::uno::Reference< css::frame::XDispatch > Dispatch;
102 CommandInfo( const OUString &rURL )
104 URL.Complete = rURL;
108 class GalleryThemePopup : public ::cppu::WeakImplHelper1< css::frame::XStatusListener >
110 private:
111 const GalleryTheme* mpTheme;
112 sal_uIntPtr mnObjectPos;
113 bool mbPreview;
114 PopupMenu maPopupMenu;
115 PopupMenu maBackgroundPopup;
116 VclPtr<GalleryBrowser2> mpBrowser;
118 typedef std::map< int, CommandInfo > CommandInfoMap;
119 CommandInfoMap m_aCommandInfo;
121 static void Execute( const CommandInfo &rCmdInfo,
122 const css::uno::Sequence< css::beans::PropertyValue > &rArguments );
124 DECL_LINK( MenuSelectHdl, Menu* pMenu );
125 DECL_LINK( BackgroundMenuSelectHdl, Menu* pMenu );
126 public:
127 GalleryThemePopup( const GalleryTheme* pTheme,
128 sal_uIntPtr nObjectPos,
129 bool bPreview,
130 GalleryBrowser2* pBrowser );
131 virtual ~GalleryThemePopup();
133 void ExecutePopup( vcl::Window *pParent, const ::Point &aPos );
135 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent &rEvent) throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
136 virtual void SAL_CALL disposing( const css::lang::EventObject &rSource) throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
140 GalleryThemePopup::GalleryThemePopup(
141 const GalleryTheme* pTheme,
142 sal_uIntPtr nObjectPos,
143 bool bPreview,
144 GalleryBrowser2* pBrowser )
145 : mpTheme( pTheme )
146 , mnObjectPos( nObjectPos )
147 , mbPreview( bPreview )
148 , maPopupMenu( GAL_RES( RID_SVXMN_GALLERY2 ) )
149 , maBackgroundPopup()
150 , mpBrowser( pBrowser )
153 // SID_GALLERY_ENABLE_ADDCOPY
154 m_aCommandInfo.insert(
155 CommandInfoMap::value_type(
156 SID_GALLERY_ENABLE_ADDCOPY,
157 CommandInfo( OUString(CMD_SID_GALLERY_ENABLE_ADDCOPY ))));
158 // SID_GALLERY_BG_BRUSH
159 m_aCommandInfo.insert(
160 CommandInfoMap::value_type(
161 SID_GALLERY_BG_BRUSH,
162 CommandInfo(OUString(CMD_SID_GALLERY_BG_BRUSH ))));
163 // SID_GALLERY_FORMATS
164 m_aCommandInfo.insert(
165 CommandInfoMap::value_type(
166 SID_GALLERY_FORMATS,
167 CommandInfo(OUString(CMD_SID_GALLERY_FORMATS ))));
171 GalleryThemePopup::~GalleryThemePopup()
175 void SAL_CALL GalleryThemePopup::statusChanged(
176 const css::frame::FeatureStateEvent &rEvent )
177 throw ( css::uno::RuntimeException, std::exception )
179 const OUString &rURL = rEvent.FeatureURL.Complete;
180 if ( rURL == CMD_SID_GALLERY_ENABLE_ADDCOPY )
182 if ( !rEvent.IsEnabled )
184 maPopupMenu.EnableItem( MN_ADD, false );
187 else if ( rURL == CMD_SID_GALLERY_BG_BRUSH )
189 maBackgroundPopup.Clear();
190 if ( rEvent.IsEnabled )
192 OUString sItem;
193 css::uno::Sequence< OUString > sItems;
194 if ( ( rEvent.State >>= sItem ) && sItem.getLength() )
196 maBackgroundPopup.InsertItem( 1, sItem );
198 else if ( ( rEvent.State >>= sItems ) && sItems.getLength() )
200 const OUString *pStr = sItems.getConstArray();
201 const OUString *pEnd = pStr + sItems.getLength();
202 for ( sal_uInt16 nId = 1; pStr != pEnd; pStr++, nId++ )
204 maBackgroundPopup.InsertItem( nId, *pStr );
211 void SAL_CALL GalleryThemePopup::disposing(
212 const css::lang::EventObject &/*rSource*/)
213 throw ( css::uno::RuntimeException, std::exception )
217 void GalleryThemePopup::Execute(
218 const CommandInfo &rCmdInfo,
219 const css::uno::Sequence< css::beans::PropertyValue > &rArguments )
221 if ( rCmdInfo.Dispatch.is() )
223 DispatchInfo *pInfo = new DispatchInfo;
224 pInfo->TargetURL = rCmdInfo.URL;
225 pInfo->Arguments = rArguments;
226 pInfo->Dispatch = rCmdInfo.Dispatch;
228 if ( !Application::PostUserEvent(
229 LINK( 0, GalleryBrowser2, AsyncDispatch_Impl), pInfo ) )
230 delete pInfo;
234 void GalleryThemePopup::ExecutePopup( vcl::Window *pWindow, const ::Point &aPos )
236 css::uno::Reference< css::frame::XStatusListener > xThis( this );
238 const SgaObjKind eObjKind = mpTheme->GetObjectKind( mnObjectPos );
239 INetURLObject aURL;
241 const_cast< GalleryTheme* >( mpTheme )->GetURL( mnObjectPos, aURL );
242 const bool bValidURL = ( aURL.GetProtocol() != INetProtocol::NotValid );
244 maPopupMenu.EnableItem( MN_ADD, bValidURL && SGA_OBJ_SOUND != eObjKind );
246 maPopupMenu.EnableItem( MN_PREVIEW, bValidURL );
248 maPopupMenu.CheckItem( MN_PREVIEW, mbPreview );
250 if( mpTheme->IsReadOnly() || !mpTheme->GetObjectCount() )
252 maPopupMenu.EnableItem( MN_DELETE, false );
253 maPopupMenu.EnableItem( MN_TITLE, false );
255 if( mpTheme->IsReadOnly() )
256 maPopupMenu.EnableItem( MN_PASTECLIPBOARD, false );
258 if( !mpTheme->GetObjectCount() )
259 maPopupMenu.EnableItem( MN_COPYCLIPBOARD, false );
261 else
263 maPopupMenu.EnableItem( MN_DELETE, !mbPreview );
264 maPopupMenu.EnableItem( MN_TITLE, true );
265 maPopupMenu.EnableItem( MN_COPYCLIPBOARD, true );
266 maPopupMenu.EnableItem( MN_PASTECLIPBOARD, true );
269 #ifdef GALLERY_USE_CLIPBOARD
270 if( maPopupMenu.IsItemEnabled( MN_PASTECLIPBOARD ) )
272 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( this ) );
273 sal_Bool bEnable = sal_False;
275 if( aDataHelper.GetFormatCount() )
277 if( aDataHelper.HasFormat( SotClipboardFormatId::DRAWING ) ||
278 aDataHelper.HasFormat( SotClipboardFormatId::FILE_LIST ) ||
279 aDataHelper.HasFormat( SotClipboardFormatId::SIMPLE_FILE ) ||
280 aDataHelper.HasFormat( SotClipboardFormatId::SVXB ) ||
281 aDataHelper.HasFormat( SotClipboardFormatId::GDIMETAFILE ) ||
282 aDataHelper.HasFormat( SotClipboardFormatId::BITMAP ) )
284 bEnable = sal_True;
288 if( !bEnable )
289 maPopupMenu.EnableItem( MN_PASTECLIPBOARD, sal_False );
291 #else
292 maPopupMenu.EnableItem( MN_COPYCLIPBOARD, false );
293 maPopupMenu.EnableItem( MN_PASTECLIPBOARD, false );
294 #endif
296 // update status
297 css::uno::Reference< css::frame::XDispatchProvider> xDispatchProvider(
298 GalleryBrowser2::GetFrame(), css::uno::UNO_QUERY );
299 css::uno::Reference< css::util::XURLTransformer > xTransformer(
300 mpBrowser->GetURLTransformer() );
301 for ( CommandInfoMap::iterator it = m_aCommandInfo.begin();
302 it != m_aCommandInfo.end(); ++it )
306 CommandInfo &rCmdInfo = it->second;
307 if ( xTransformer.is() )
308 xTransformer->parseStrict( rCmdInfo.URL );
310 if ( xDispatchProvider.is() )
312 rCmdInfo.Dispatch = xDispatchProvider->queryDispatch(
313 rCmdInfo.URL,
314 OUString( "_self" ),
315 css::frame::FrameSearchFlag::SELF );
318 if ( rCmdInfo.Dispatch.is() )
320 rCmdInfo.Dispatch->addStatusListener( this, rCmdInfo.URL );
321 rCmdInfo.Dispatch->removeStatusListener( this, rCmdInfo.URL );
324 catch ( ... )
328 if( !maBackgroundPopup.GetItemCount() || ( eObjKind == SGA_OBJ_SVDRAW ) || ( eObjKind == SGA_OBJ_SOUND ) )
329 maPopupMenu.EnableItem( MN_BACKGROUND, false );
330 else
332 maPopupMenu.EnableItem( MN_BACKGROUND, true );
333 maPopupMenu.SetPopupMenu( MN_BACKGROUND, &maBackgroundPopup );
334 maBackgroundPopup.SetSelectHdl( LINK( this, GalleryThemePopup, BackgroundMenuSelectHdl ) );
337 maPopupMenu.RemoveDisabledEntries();
339 maPopupMenu.SetSelectHdl( LINK( this, GalleryThemePopup, MenuSelectHdl ) );
340 maPopupMenu.Execute( pWindow, aPos );
343 IMPL_LINK( GalleryThemePopup, MenuSelectHdl, Menu*, pMenu )
345 if( !pMenu )
346 return 0;
348 sal_uInt16 nId( pMenu->GetCurItemId() );
349 switch ( nId )
351 case( MN_ADD ):
353 const CommandInfoMap::const_iterator it = m_aCommandInfo.find( SID_GALLERY_FORMATS );
354 if ( it != m_aCommandInfo.end() )
355 mpBrowser->Dispatch( nId,
356 it->second.Dispatch,
357 it->second.URL );
359 break;
361 default:
362 mpBrowser->Execute( nId );
365 return 0;
368 IMPL_LINK( GalleryThemePopup, BackgroundMenuSelectHdl, Menu*, pMenu )
370 if( !pMenu )
371 return 0;
373 sal_uInt16 nPos( pMenu->GetCurItemId() - 1 );
374 OUString aURL( mpBrowser->GetURL().GetMainURL( INetURLObject::NO_DECODE ) );
375 OUString aFilterName( mpBrowser->GetFilterName() );
377 css::uno::Sequence< css::beans::PropertyValue > aArgs( 6 );
378 aArgs[0].Name = "Background.Transparent";
379 aArgs[0].Value <<= sal_Int32( 0 ); // 0 - 100
380 aArgs[1].Name = "Background.BackColor";
381 aArgs[1].Value <<= sal_Int32( - 1 );
382 aArgs[2].Name = "Background.URL";
383 aArgs[2].Value <<= aURL;
384 aArgs[3].Name = "Background.Filtername"; // FIXME should be FilterName
385 aArgs[3].Value <<= aFilterName;
386 aArgs[4].Name = "Background.Position";
387 aArgs[4].Value <<= css::style::GraphicLocation_TILED;
388 aArgs[5].Name = "Position";
389 aArgs[5].Value <<= nPos;
391 const CommandInfoMap::const_iterator it = m_aCommandInfo.find( SID_GALLERY_BG_BRUSH );
392 if ( it != m_aCommandInfo.end() )
393 Execute( it->second, aArgs );
395 return 0;
398 } // end anonymous namespace
401 GalleryToolBox::GalleryToolBox( GalleryBrowser2* pParent ) :
402 ToolBox( pParent, WB_TABSTOP )
406 void GalleryToolBox::KeyInput( const KeyEvent& rKEvt )
408 if( !static_cast< GalleryBrowser2* >( GetParent() )->KeyInput( rKEvt, this ) )
409 ToolBox::KeyInput( rKEvt );
413 GalleryBrowser2::GalleryBrowser2( vcl::Window* pParent, Gallery* pGallery ) :
414 Control ( pParent, WB_TABSTOP ),
415 mpGallery ( pGallery ),
416 mpCurTheme ( NULL ),
417 mpIconView ( VclPtr<GalleryIconView>::Create( this, nullptr ) ),
418 mpListView ( VclPtr<GalleryListView>::Create( this, nullptr ) ),
419 mpPreview ( VclPtr<GalleryPreview>::Create(this) ),
420 maViewBox ( VclPtr<GalleryToolBox>::Create(this) ),
421 maSeparator ( VclPtr<FixedLine>::Create(this, WB_VERT) ),
422 maInfoBar ( VclPtr<FixedText>::Create(this, WB_LEFT | WB_VCENTER) ),
423 mnCurActionPos ( 0xffffffff ),
424 meMode ( GALLERYBROWSERMODE_NONE ),
425 meLastMode ( GALLERYBROWSERMODE_NONE )
428 m_xContext.set( ::comphelper::getProcessComponentContext() );
430 m_xTransformer.set(
431 m_xContext->getServiceManager()->createInstanceWithContext(
432 OUString( "com.sun.star.util.URLTransformer" ), m_xContext ),
433 css::uno::UNO_QUERY );
435 Image aDummyImage;
436 const Link<> aSelectHdl( LINK( this, GalleryBrowser2, SelectObjectHdl ) );
437 vcl::Font aInfoFont( maInfoBar->GetControlFont() );
439 maMiscOptions.AddListenerLink( LINK( this, GalleryBrowser2, MiscHdl ) );
441 maViewBox->InsertItem( TBX_ID_ICON, aDummyImage );
442 maViewBox->SetItemBits( TBX_ID_ICON, ToolBoxItemBits::RADIOCHECK | ToolBoxItemBits::AUTOCHECK );
443 maViewBox->SetHelpId( TBX_ID_ICON, HID_GALLERY_ICONVIEW );
444 maViewBox->SetQuickHelpText( TBX_ID_ICON, GAL_RESSTR(RID_SVXSTR_GALLERY_ICONVIEW) );
446 maViewBox->InsertItem( TBX_ID_LIST, aDummyImage );
447 maViewBox->SetItemBits( TBX_ID_LIST, ToolBoxItemBits::RADIOCHECK | ToolBoxItemBits::AUTOCHECK );
448 maViewBox->SetHelpId( TBX_ID_LIST, HID_GALLERY_LISTVIEW );
449 maViewBox->SetQuickHelpText( TBX_ID_LIST, GAL_RESSTR(RID_SVXSTR_GALLERY_LISTVIEW) );
451 MiscHdl( NULL );
452 maViewBox->SetSelectHdl( LINK( this, GalleryBrowser2, SelectTbxHdl ) );
453 maViewBox->Show();
455 mpIconView->SetAccessibleName(SVX_RESSTR(RID_SVXSTR_GALLERY_THEMEITEMS));
456 mpListView->SetAccessibleName(SVX_RESSTR(RID_SVXSTR_GALLERY_THEMEITEMS));
458 maInfoBar->Show();
459 maSeparator->Show();
461 mpIconView->SetSelectHdl( aSelectHdl );
462 mpListView->SetSelectHdl( aSelectHdl );
464 InitSettings();
466 SetMode( ( GALLERYBROWSERMODE_PREVIEW != GalleryBrowser2::meInitMode ) ? GalleryBrowser2::meInitMode : GALLERYBROWSERMODE_ICON );
468 if(maInfoBar->GetText().isEmpty())
469 mpIconView->SetAccessibleRelationLabeledBy(mpIconView);
470 else
471 mpIconView->SetAccessibleRelationLabeledBy(maInfoBar.get());
472 mpIconView->SetAccessibleRelationMemberOf(mpIconView);
475 GalleryBrowser2::~GalleryBrowser2()
477 disposeOnce();
480 void GalleryBrowser2::dispose()
482 maMiscOptions.RemoveListenerLink( LINK( this, GalleryBrowser2, MiscHdl ) );
484 mpPreview.disposeAndClear();
485 mpListView.disposeAndClear();
486 mpIconView.disposeAndClear();
488 if( mpCurTheme )
489 mpGallery->ReleaseTheme( mpCurTheme, *this );
490 maSeparator.disposeAndClear();
491 maInfoBar.disposeAndClear();
492 maViewBox.disposeAndClear();
493 Control::dispose();
496 void GalleryBrowser2::InitSettings()
498 vcl::Font aInfoFont( maInfoBar->GetControlFont() );
500 aInfoFont.SetWeight( WEIGHT_BOLD );
501 aInfoFont.SetColor( GALLERY_FG_COLOR );
502 maInfoBar->SetControlFont( aInfoFont );
504 maInfoBar->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
505 maInfoBar->SetControlBackground( GALLERY_DLG_COLOR );
507 maSeparator->SetBackground( Wallpaper( GALLERY_BG_COLOR ) );
508 maSeparator->SetControlBackground( GALLERY_BG_COLOR );
509 maSeparator->SetControlForeground( GALLERY_FG_COLOR );
512 void GalleryBrowser2::DataChanged( const DataChangedEvent& rDCEvt )
514 if ( ( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) && ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ) )
515 InitSettings();
516 else
517 Control::DataChanged( rDCEvt );
520 void GalleryBrowser2::Resize()
522 Control::Resize();
524 mpIconView->Hide();
525 mpListView->Hide();
526 mpPreview->Hide();
528 const Size aOutSize( GetOutputSizePixel() );
529 const Size aBoxSize( maViewBox->GetOutputSizePixel() );
530 const long nOffset = 2, nSepWidth = 2;
531 const long nInfoBarX = aBoxSize.Width() + ( nOffset * 3 ) + nSepWidth;
532 const Point aPt( 0, aBoxSize.Height() + 3 );
533 const Size aSz( aOutSize.Width(), aOutSize.Height() - aPt.Y() );
535 maSeparator->SetPosSizePixel( Point( aBoxSize.Width() + nOffset, 0 ), Size( nSepWidth, aBoxSize.Height() ) );
536 maInfoBar->SetPosSizePixel( Point( nInfoBarX, 0 ), Size( aOutSize.Width() - nInfoBarX, aBoxSize.Height() ) );
538 mpIconView->SetPosSizePixel( aPt, aSz );
539 mpListView->SetPosSizePixel( aPt, aSz );
540 mpPreview->SetPosSizePixel( aPt, aSz );
542 switch( GetMode() )
544 case( GALLERYBROWSERMODE_ICON ): mpIconView->Show(); break;
545 case( GALLERYBROWSERMODE_LIST ): mpListView->Show(); break;
546 case( GALLERYBROWSERMODE_PREVIEW ): mpPreview->Show(); break;
548 default:
549 break;
553 void GalleryBrowser2::Notify( SfxBroadcaster&, const SfxHint& rHint )
555 const GalleryHint& rGalleryHint = static_cast<const GalleryHint&>(rHint);
557 switch( rGalleryHint.GetType() )
559 case( GalleryHintType::THEME_UPDATEVIEW ):
561 if( GALLERYBROWSERMODE_PREVIEW == GetMode() )
562 SetMode( meLastMode );
564 ImplUpdateViews( (sal_uInt16) rGalleryHint.GetData1() + 1 );
566 break;
568 default:
569 break;
573 sal_Int8 GalleryBrowser2::AcceptDrop( DropTargetHelper& rTarget, const AcceptDropEvent& )
575 sal_Int8 nRet = DND_ACTION_NONE;
577 if( mpCurTheme && !mpCurTheme->IsReadOnly() )
579 if( !mpCurTheme->IsDragging() )
581 if( rTarget.IsDropFormatSupported( SotClipboardFormatId::DRAWING ) ||
582 rTarget.IsDropFormatSupported( SotClipboardFormatId::FILE_LIST ) ||
583 rTarget.IsDropFormatSupported( SotClipboardFormatId::SIMPLE_FILE ) ||
584 rTarget.IsDropFormatSupported( SotClipboardFormatId::SVXB ) ||
585 rTarget.IsDropFormatSupported( SotClipboardFormatId::GDIMETAFILE ) ||
586 rTarget.IsDropFormatSupported( SotClipboardFormatId::BITMAP ) )
588 nRet = DND_ACTION_COPY;
591 else
592 nRet = DND_ACTION_COPY;
595 return nRet;
598 sal_Int8 GalleryBrowser2::ExecuteDrop( DropTargetHelper&, const ExecuteDropEvent& rEvt )
600 sal_Int8 nRet = DND_ACTION_NONE;
602 if( mpCurTheme )
604 Point aSelPos;
605 const sal_uIntPtr nItemId = ImplGetSelectedItemId( &rEvt.maPosPixel, aSelPos );
606 const sal_uIntPtr nInsertPos = (nItemId ? (nItemId - 1) : mpCurTheme->GetObjectCount());
608 if( mpCurTheme->IsDragging() )
609 mpCurTheme->ChangeObjectPos( mpCurTheme->GetDragPos(), nInsertPos );
610 else
611 nRet = mpCurTheme->InsertTransferable( rEvt.maDropEvent.Transferable, nInsertPos ) ? 1 : 0;
614 return nRet;
617 void GalleryBrowser2::StartDrag( vcl::Window*, const Point* pDragPoint )
619 if( mpCurTheme )
621 Point aSelPos;
622 const sal_uIntPtr nItemId = ImplGetSelectedItemId( pDragPoint, aSelPos );
624 if( nItemId )
625 mpCurTheme->StartDrag( this, nItemId - 1 );
629 void GalleryBrowser2::TogglePreview( vcl::Window*, const Point* )
631 SetMode( ( GALLERYBROWSERMODE_PREVIEW != GetMode() ) ? GALLERYBROWSERMODE_PREVIEW : meLastMode );
632 GetViewWindow()->GrabFocus();
635 void GalleryBrowser2::ShowContextMenu( vcl::Window*, const Point* pContextPoint )
637 Point aSelPos;
638 const sal_uIntPtr nItemId = ImplGetSelectedItemId( pContextPoint, aSelPos );
640 if( mpCurTheme && nItemId && ( nItemId <= mpCurTheme->GetObjectCount() ) )
642 ImplSelectItemId( nItemId );
644 css::uno::Reference< css::frame::XFrame > xFrame( GetFrame() );
645 if ( xFrame.is() )
647 mnCurActionPos = nItemId - 1;
648 rtl::Reference< GalleryThemePopup > rPopup(
649 new GalleryThemePopup(
650 mpCurTheme,
651 mnCurActionPos,
652 GALLERYBROWSERMODE_PREVIEW == GetMode(),
653 this ) );
654 rPopup->ExecutePopup( this, aSelPos );
659 bool GalleryBrowser2::KeyInput( const KeyEvent& rKEvt, vcl::Window* pWindow )
661 Point aSelPos;
662 const sal_uIntPtr nItemId = ImplGetSelectedItemId( NULL, aSelPos );
663 bool bRet = false;
664 svx::sidebar::GalleryControl* pParentControl = dynamic_cast<svx::sidebar::GalleryControl*>(GetParent());
665 if (pParentControl != NULL)
666 bRet = pParentControl->GalleryKeyInput(rKEvt, pWindow);
668 if( !bRet && !maViewBox->HasFocus() && nItemId && mpCurTheme )
670 sal_uInt16 nExecuteId = 0;
671 INetURLObject aURL;
673 const_cast< GalleryTheme* >( mpCurTheme )->GetURL( nItemId - 1, aURL );
675 const bool bValidURL = ( aURL.GetProtocol() != INetProtocol::NotValid );
676 bool bPreview = bValidURL;
677 bool bDelete = false;
678 bool bTitle = false;
680 if( !mpCurTheme->IsReadOnly() && mpCurTheme->GetObjectCount() )
682 bDelete = ( GALLERYBROWSERMODE_PREVIEW != GetMode() );
683 bTitle = true;
686 switch( rKEvt.GetKeyCode().GetCode() )
688 case( KEY_SPACE ):
689 case( KEY_RETURN ):
690 case( KEY_P ):
692 if( bPreview )
694 TogglePreview( pWindow );
695 bRet = true;
698 break;
700 case( KEY_INSERT ):
701 case( KEY_I ):
703 // Inserting a gallery item in the document must be dispatched
704 if( bValidURL )
706 Dispatch( MN_ADD );
707 return true;
710 break;
712 case( KEY_DELETE ):
713 case( KEY_D ):
715 if( bDelete )
716 nExecuteId = MN_DELETE;
718 break;
720 case( KEY_T ):
722 if( bTitle )
723 nExecuteId = MN_TITLE;
725 break;
727 default:
728 break;
731 if( nExecuteId )
733 Execute( nExecuteId );
734 bRet = true;
738 return bRet;
741 void GalleryBrowser2::SelectTheme( const OUString& rThemeName )
743 mpIconView.disposeAndClear();
744 mpListView.disposeAndClear();
745 mpPreview.disposeAndClear();
747 if( mpCurTheme )
748 mpGallery->ReleaseTheme( mpCurTheme, *this );
750 mpCurTheme = mpGallery->AcquireTheme( rThemeName, *this );
752 mpIconView = VclPtr<GalleryIconView>::Create( this, mpCurTheme );
753 mpListView = VclPtr<GalleryListView>::Create( this, mpCurTheme );
754 mpPreview = VclPtr<GalleryPreview>::Create( this, WB_TABSTOP | WB_BORDER, mpCurTheme );
756 mpIconView->SetAccessibleName(SVX_RESSTR(RID_SVXSTR_GALLERY_THEMEITEMS));
757 mpListView->SetAccessibleName(SVX_RESSTR(RID_SVXSTR_GALLERY_THEMEITEMS));
758 mpPreview->SetAccessibleName(SVX_RESSTR(RID_SVXSTR_GALLERY_PREVIEW));
760 const Link<> aSelectHdl( LINK( this, GalleryBrowser2, SelectObjectHdl ) );
762 mpIconView->SetSelectHdl( aSelectHdl );
763 mpListView->SetSelectHdl( aSelectHdl );
765 if( GALLERYBROWSERMODE_PREVIEW == GetMode() )
766 meMode = meLastMode;
768 Resize();
769 ImplUpdateViews( 1 );
771 maViewBox->EnableItem( TBX_ID_ICON, true );
772 maViewBox->EnableItem( TBX_ID_LIST, true );
773 maViewBox->CheckItem( ( GALLERYBROWSERMODE_ICON == GetMode() ) ? TBX_ID_ICON : TBX_ID_LIST, true );
775 if(maInfoBar->GetText().isEmpty())
776 mpIconView->SetAccessibleRelationLabeledBy(mpIconView);
777 else
778 mpIconView->SetAccessibleRelationLabeledBy(maInfoBar.get());
779 mpIconView->SetAccessibleRelationMemberOf(mpIconView);
782 void GalleryBrowser2::SetMode( GalleryBrowserMode eMode )
784 if( GetMode() != eMode )
786 meLastMode = GetMode();
788 switch( eMode )
790 case( GALLERYBROWSERMODE_ICON ):
792 mpListView->Hide();
794 mpPreview->Hide();
795 mpPreview->SetGraphic( Graphic() );
796 GalleryPreview::PreviewMedia( INetURLObject() );
798 mpIconView->Show();
800 maViewBox->EnableItem( TBX_ID_ICON, true );
801 maViewBox->EnableItem( TBX_ID_LIST, true );
803 maViewBox->CheckItem( TBX_ID_ICON, true );
804 maViewBox->CheckItem( TBX_ID_LIST, false );
806 break;
808 case( GALLERYBROWSERMODE_LIST ):
810 mpIconView->Hide();
812 mpPreview->Hide();
813 mpPreview->SetGraphic( Graphic() );
814 GalleryPreview::PreviewMedia( INetURLObject() );
816 mpListView->Show();
818 maViewBox->EnableItem( TBX_ID_ICON, true );
819 maViewBox->EnableItem( TBX_ID_LIST, true );
821 maViewBox->CheckItem( TBX_ID_ICON, false );
822 maViewBox->CheckItem( TBX_ID_LIST, true );
824 break;
826 case( GALLERYBROWSERMODE_PREVIEW ):
828 Graphic aGraphic;
829 Point aSelPos;
830 const sal_uIntPtr nItemId = ImplGetSelectedItemId( NULL, aSelPos );
832 if( nItemId )
834 const sal_uIntPtr nPos = nItemId - 1;
836 mpIconView->Hide();
837 mpListView->Hide();
839 if( mpCurTheme )
840 mpCurTheme->GetGraphic( nPos, aGraphic );
842 mpPreview->SetGraphic( aGraphic );
843 mpPreview->Show();
845 if( mpCurTheme && mpCurTheme->GetObjectKind( nPos ) == SGA_OBJ_SOUND )
846 GalleryPreview::PreviewMedia( mpCurTheme->GetObjectURL( nPos ) );
848 maViewBox->EnableItem( TBX_ID_ICON, false );
849 maViewBox->EnableItem( TBX_ID_LIST, false );
852 break;
854 default:
855 break;
858 GalleryBrowser2::meInitMode = meMode = eMode;
862 vcl::Window* GalleryBrowser2::GetViewWindow() const
864 vcl::Window* pRet;
866 switch( GetMode() )
868 case( GALLERYBROWSERMODE_LIST ): pRet = mpListView; break;
869 case( GALLERYBROWSERMODE_PREVIEW ): pRet = mpPreview; break;
871 default:
872 pRet = mpIconView;
873 break;
876 return pRet;
879 void GalleryBrowser2::Travel( GalleryBrowserTravel eTravel )
881 if( mpCurTheme )
883 Point aSelPos;
884 const sal_uIntPtr nItemId = ImplGetSelectedItemId( NULL, aSelPos );
886 if( nItemId )
888 sal_uIntPtr nNewItemId = nItemId;
890 switch( eTravel )
892 case( GALLERYBROWSERTRAVEL_FIRST ): nNewItemId = 1; break;
893 case( GALLERYBROWSERTRAVEL_LAST ): nNewItemId = mpCurTheme->GetObjectCount(); break;
894 case( GALLERYBROWSERTRAVEL_PREVIOUS ): nNewItemId--; break;
895 case( GALLERYBROWSERTRAVEL_NEXT ): nNewItemId++; break;
896 default:
897 break;
900 if( nNewItemId < 1 )
901 nNewItemId = 1;
902 else if( nNewItemId > mpCurTheme->GetObjectCount() )
903 nNewItemId = mpCurTheme->GetObjectCount();
905 if( nNewItemId != nItemId )
907 ImplSelectItemId( nNewItemId );
908 ImplUpdateInfoBar();
910 if( GALLERYBROWSERMODE_PREVIEW == GetMode() )
912 Graphic aGraphic;
913 const sal_uIntPtr nPos = nNewItemId - 1;
915 mpCurTheme->GetGraphic( nPos, aGraphic );
916 mpPreview->SetGraphic( aGraphic );
918 if( SGA_OBJ_SOUND == mpCurTheme->GetObjectKind( nPos ) )
919 GalleryPreview::PreviewMedia( mpCurTheme->GetObjectURL( nPos ) );
921 mpPreview->Invalidate();
928 void GalleryBrowser2::ImplUpdateViews( sal_uInt16 nSelectionId )
930 mpIconView->Hide();
931 mpListView->Hide();
932 mpPreview->Hide();
934 mpIconView->Clear();
935 mpListView->Clear();
937 if( mpCurTheme )
939 for( sal_uIntPtr i = 0, nCount = mpCurTheme->GetObjectCount(); i < nCount; )
941 mpListView->RowInserted( i++ );
942 mpIconView->InsertItem( (sal_uInt16) i );
945 ImplSelectItemId( ( ( nSelectionId > mpCurTheme->GetObjectCount() ) ? mpCurTheme->GetObjectCount() : nSelectionId ) );
948 switch( GetMode() )
950 case( GALLERYBROWSERMODE_ICON ): mpIconView->Show(); break;
951 case( GALLERYBROWSERMODE_LIST ): mpListView->Show(); break;
952 case( GALLERYBROWSERMODE_PREVIEW ): mpPreview->Show(); break;
954 default:
955 break;
958 ImplUpdateInfoBar();
961 void GalleryBrowser2::ImplUpdateInfoBar()
963 if( mpCurTheme )
964 maInfoBar->SetText( mpCurTheme->GetName() );
967 sal_uIntPtr GalleryBrowser2::ImplGetSelectedItemId( const Point* pSelPos, Point& rSelPos )
969 const Size aOutputSizePixel( GetOutputSizePixel() );
970 sal_uIntPtr nRet = 0;
972 if( GALLERYBROWSERMODE_PREVIEW == GetMode() )
974 nRet = ( ( GALLERYBROWSERMODE_ICON == meLastMode ) ? mpIconView->GetSelectItemId() : ( mpListView->FirstSelectedRow() + 1 ) );
976 if( pSelPos )
977 rSelPos = GetPointerPosPixel();
978 else
979 rSelPos = Point( aOutputSizePixel.Width() >> 1, aOutputSizePixel.Height() >> 1 );
981 else if( GALLERYBROWSERMODE_ICON == GetMode() )
983 if( pSelPos )
985 nRet = mpIconView->GetItemId( *pSelPos );
986 rSelPos = GetPointerPosPixel();
988 else
990 nRet = mpIconView->GetSelectItemId();
991 rSelPos = mpIconView->GetItemRect( (sal_uInt16) nRet ).Center();
994 else
996 if( pSelPos )
998 nRet = mpListView->GetRowAtYPosPixel( pSelPos->Y() ) + 1;
999 rSelPos = GetPointerPosPixel();
1001 else
1003 nRet = mpListView->FirstSelectedRow() + 1;
1004 rSelPos = mpListView->GetFieldRectPixel( (sal_uInt16) nRet, 1 ).Center();
1008 rSelPos.X() = std::max( std::min( rSelPos.X(), aOutputSizePixel.Width() - 1L ), 0L );
1009 rSelPos.Y() = std::max( std::min( rSelPos.Y(), aOutputSizePixel.Height() - 1L ), 0L );
1011 if( nRet && ( !mpCurTheme || ( nRet > mpCurTheme->GetObjectCount() ) ) )
1013 nRet = 0;
1016 return nRet;
1019 void GalleryBrowser2::ImplSelectItemId( sal_uIntPtr nItemId )
1021 if( nItemId )
1024 mpIconView->SelectItem( (sal_uInt16) nItemId );
1025 mpListView->SelectRow( nItemId - 1 );
1029 css::uno::Reference< css::frame::XFrame >
1030 GalleryBrowser2::GetFrame()
1032 css::uno::Reference< css::frame::XFrame > xFrame;
1033 SfxViewFrame* pCurrentViewFrame = SfxViewFrame::Current();
1034 if ( pCurrentViewFrame )
1036 SfxBindings& rBindings = pCurrentViewFrame->GetBindings();
1037 xFrame.set( rBindings.GetActiveFrame() );
1040 return xFrame;
1043 void GalleryBrowser2::Dispatch(
1044 sal_uInt16 nId,
1045 const css::uno::Reference< css::frame::XDispatch > &rxDispatch,
1046 const css::util::URL &rURL )
1048 Point aSelPos;
1049 const sal_uIntPtr nItemId = ImplGetSelectedItemId( NULL, aSelPos );
1051 if( !mpCurTheme || !nItemId )
1052 return;
1054 mnCurActionPos = nItemId - 1;
1056 switch( nId )
1058 case( MN_ADD ):
1060 css::uno::Reference< css::frame::XDispatch > xDispatch( rxDispatch );
1061 css::util::URL aURL = rURL;
1063 if ( !xDispatch.is() )
1065 css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider(
1066 GetFrame(), css::uno::UNO_QUERY );
1067 if ( !xDispatchProvider.is() || !m_xTransformer.is() )
1068 return;
1070 aURL.Complete = CMD_SID_GALLERY_FORMATS;
1071 m_xTransformer->parseStrict( aURL );
1072 xDispatch = xDispatchProvider->queryDispatch(
1073 aURL,
1074 OUString( "_self" ),
1075 css::frame::FrameSearchFlag::SELF );
1078 if ( !xDispatch.is() )
1079 return;
1081 sal_Int8 nType = 0;
1082 OUString aFileURL, aFilterName;
1083 css::uno::Reference< css::lang::XComponent > xDrawing;
1084 css::uno::Reference< css::graphic::XGraphic > xGraphic;
1086 aFilterName = GetFilterName();
1088 switch( mpCurTheme->GetObjectKind( mnCurActionPos ) )
1090 case( SGA_OBJ_BMP ):
1091 case( SGA_OBJ_ANIM ):
1092 case( SGA_OBJ_INET ):
1093 // TODO drawing objects are inserted as drawings only via drag&drop
1094 case( SGA_OBJ_SVDRAW ):
1095 nType = css::gallery::GalleryItemType::GRAPHIC;
1096 break;
1098 case ( SGA_OBJ_SOUND ) :
1099 nType = css::gallery::GalleryItemType::MEDIA;
1100 break;
1102 default:
1103 nType = css::gallery::GalleryItemType::EMPTY;
1104 break;
1107 Graphic aGraphic;
1108 bool bGraphic = mpCurTheme->GetGraphic( mnCurActionPos, aGraphic );
1109 if ( bGraphic && !!aGraphic )
1110 xGraphic.set( aGraphic.GetXGraphic() );
1111 OSL_ENSURE( xGraphic.is(), "gallery item is graphic, but the reference is invalid!" );
1113 css::uno::Sequence< css::beans::PropertyValue > aSeq( SVXGALLERYITEM_PARAMS );
1115 aSeq[0].Name = SVXGALLERYITEM_TYPE;
1116 aSeq[0].Value <<= nType;
1117 aSeq[1].Name = SVXGALLERYITEM_URL;
1118 aSeq[1].Value <<= aFileURL;
1119 aSeq[2].Name = SVXGALLERYITEM_FILTER;
1120 aSeq[2].Value <<= aFilterName;
1121 aSeq[3].Name = SVXGALLERYITEM_DRAWING;
1122 aSeq[3].Value <<= xDrawing;
1123 aSeq[4].Name = SVXGALLERYITEM_GRAPHIC;
1124 aSeq[4].Value <<= xGraphic;
1126 css::uno::Sequence< css::beans::PropertyValue > aArgs( 1 );
1127 aArgs[0].Name = SVXGALLERYITEM_ARGNAME;
1128 aArgs[0].Value <<= aSeq;
1130 DispatchInfo *pInfo = new DispatchInfo;
1131 pInfo->TargetURL = aURL;
1132 pInfo->Arguments = aArgs;
1133 pInfo->Dispatch = xDispatch;
1135 if ( !Application::PostUserEvent(
1136 LINK( 0, GalleryBrowser2, AsyncDispatch_Impl), pInfo ) )
1137 delete pInfo;
1139 break;
1141 default:
1142 break;
1146 void GalleryBrowser2::Execute( sal_uInt16 nId )
1148 Point aSelPos;
1149 const sal_uIntPtr nItemId = ImplGetSelectedItemId( NULL, aSelPos );
1151 if( mpCurTheme && nItemId )
1153 mnCurActionPos = nItemId - 1;
1155 switch( nId )
1157 case( MN_PREVIEW ):
1158 SetMode( ( GALLERYBROWSERMODE_PREVIEW != GetMode() ) ? GALLERYBROWSERMODE_PREVIEW : meLastMode );
1159 break;
1161 case( MN_DELETE ):
1163 if( !mpCurTheme->IsReadOnly() &&
1164 ScopedVclPtrInstance<MessageDialog>::Create(nullptr, "QueryDeleteObjectDialog","svx/ui/querydeleteobjectdialog.ui")->Execute() == RET_YES )
1166 mpCurTheme->RemoveObject( mnCurActionPos );
1169 break;
1171 case( MN_TITLE ):
1173 SgaObject* pObj = mpCurTheme->AcquireObject( mnCurActionPos );
1175 if( pObj )
1177 const OUString aOldTitle( GetItemText( *mpCurTheme, *pObj, GALLERY_ITEM_TITLE ) );
1179 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1180 if(pFact)
1182 boost::scoped_ptr<AbstractTitleDialog> aDlg(pFact->CreateTitleDialog( this, aOldTitle ));
1183 DBG_ASSERT(aDlg, "Dialog creation failed!");
1184 if( aDlg->Execute() == RET_OK )
1186 OUString aNewTitle( aDlg->GetTitle() );
1188 if( ( aNewTitle.isEmpty() && !pObj->GetTitle().isEmpty() ) || ( aNewTitle != aOldTitle ) )
1190 if( aNewTitle.isEmpty() )
1191 aNewTitle = "__<empty>__";
1193 pObj->SetTitle( aNewTitle );
1194 mpCurTheme->InsertObject( *pObj );
1198 GalleryTheme::ReleaseObject( pObj );
1202 break;
1204 case( MN_COPYCLIPBOARD ):
1206 vcl::Window* pWindow;
1208 switch( GetMode() )
1210 case( GALLERYBROWSERMODE_ICON ): pWindow = (vcl::Window*) mpIconView; break;
1211 case( GALLERYBROWSERMODE_LIST ): pWindow = (vcl::Window*) mpListView; break;
1212 case( GALLERYBROWSERMODE_PREVIEW ): pWindow = (vcl::Window*) mpPreview; break;
1214 default:
1215 pWindow = NULL;
1216 break;
1219 mpCurTheme->CopyToClipboard( pWindow, mnCurActionPos );
1221 break;
1223 case( MN_PASTECLIPBOARD ):
1225 if( !mpCurTheme->IsReadOnly() )
1227 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( this ) );
1228 mpCurTheme->InsertTransferable( aDataHelper.GetTransferable(), mnCurActionPos );
1231 break;
1233 default:
1234 break;
1239 OUString GalleryBrowser2::GetItemText( const GalleryTheme& rTheme, const SgaObject& rObj, sal_uIntPtr nItemTextFlags )
1241 OUString aRet;
1243 INetURLObject aURL(rObj.GetURL());
1245 if( nItemTextFlags & GALLERY_ITEM_THEMENAME )
1247 aRet += rTheme.GetName();
1248 aRet += " - ";
1251 if( nItemTextFlags & GALLERY_ITEM_TITLE )
1253 OUString aTitle( rObj.GetTitle() );
1255 if( aTitle.isEmpty() )
1256 aTitle = aURL.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_UNAMBIGUOUS );
1258 if( aTitle.isEmpty() )
1260 aTitle = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
1261 aTitle = aTitle.getToken( comphelper::string::getTokenCount(aTitle, '/') - 1, '/' );
1264 aRet += aTitle;
1267 if( nItemTextFlags & GALLERY_ITEM_PATH )
1269 const OUString aPath( aURL.getFSysPath( INetURLObject::FSYS_DETECT ) );
1271 if( !aPath.isEmpty() && ( nItemTextFlags & GALLERY_ITEM_TITLE ) )
1272 aRet += " (";
1274 aRet += aURL.getFSysPath( INetURLObject::FSYS_DETECT );
1276 if( !aPath.isEmpty() && ( nItemTextFlags & GALLERY_ITEM_TITLE ) )
1277 aRet += ")";
1280 return aRet;
1283 INetURLObject GalleryBrowser2::GetURL() const
1285 INetURLObject aURL;
1287 if( mpCurTheme && mnCurActionPos != 0xffffffff )
1288 aURL = mpCurTheme->GetObjectURL( mnCurActionPos );
1290 return aURL;
1293 OUString GalleryBrowser2::GetFilterName() const
1295 OUString aFilterName;
1297 if( mpCurTheme && mnCurActionPos != 0xffffffff )
1299 const SgaObjKind eObjKind = mpCurTheme->GetObjectKind( mnCurActionPos );
1301 if( ( SGA_OBJ_BMP == eObjKind ) || ( SGA_OBJ_ANIM == eObjKind ) )
1303 GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
1304 INetURLObject aURL;
1305 mpCurTheme->GetURL( mnCurActionPos, aURL );
1306 sal_uInt16 nFilter = rFilter.GetImportFormatNumberForShortName( aURL.GetExtension() );
1308 if( GRFILTER_FORMAT_DONTKNOW != nFilter )
1309 aFilterName = rFilter.GetImportFormatName( nFilter );
1313 return aFilterName;
1316 Graphic GalleryBrowser2::GetGraphic() const
1318 Graphic aGraphic;
1320 if( mpCurTheme && mnCurActionPos != 0xffffffff )
1321 mpCurTheme->GetGraphic( mnCurActionPos, aGraphic );
1323 return aGraphic;
1326 IMPL_LINK_NOARG(GalleryBrowser2, SelectObjectHdl)
1328 ImplUpdateInfoBar();
1329 return 0L;
1332 IMPL_LINK_TYPED( GalleryBrowser2, SelectTbxHdl, ToolBox*, pBox, void )
1334 if( pBox->GetCurItemId() == TBX_ID_ICON )
1335 SetMode( GALLERYBROWSERMODE_ICON );
1336 else if( pBox->GetCurItemId() == TBX_ID_LIST )
1337 SetMode( GALLERYBROWSERMODE_LIST );
1340 IMPL_LINK_NOARG(GalleryBrowser2, MiscHdl)
1342 maViewBox->SetOutStyle( maMiscOptions.GetToolboxStyle() );
1344 BitmapEx aIconBmpEx = BitmapEx( Image( GAL_RES( RID_SVXIMG_GALLERY_VIEW_ICON ) ).GetBitmapEx() );
1345 BitmapEx aListBmpEx = BitmapEx( Image( GAL_RES( RID_SVXIMG_GALLERY_VIEW_LIST ) ).GetBitmapEx() );
1347 if( maMiscOptions.AreCurrentSymbolsLarge() )
1349 const Size aLargeSize( 24, 24);
1351 aIconBmpEx.Scale( aLargeSize );
1352 aListBmpEx.Scale( aLargeSize );
1355 maViewBox->SetItemImage(TBX_ID_ICON, Image(aIconBmpEx));
1356 maViewBox->SetItemImage(TBX_ID_LIST, Image(aListBmpEx));
1357 maViewBox->SetSizePixel( maViewBox->CalcWindowSizePixel() );
1359 Resize();
1361 return 0L;
1364 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */