xref: /aoo41x/main/svx/source/gallery2/galctrl.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svx.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <vcl/svapp.hxx>
32*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
33*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
34*cdf0e10cSrcweir #include <avmedia/mediaplayer.hxx>
35*cdf0e10cSrcweir #include "helpid.hrc"
36*cdf0e10cSrcweir #include "galbrws2.hxx"
37*cdf0e10cSrcweir #include "svx/galtheme.hxx"
38*cdf0e10cSrcweir #include "svx/galmisc.hxx"
39*cdf0e10cSrcweir #include "svx/galctrl.hxx"
40*cdf0e10cSrcweir #include "editeng/AccessibleStringWrap.hxx"
41*cdf0e10cSrcweir #include <editeng/svxfont.hxx>
42*cdf0e10cSrcweir #include "galobj.hxx"
43*cdf0e10cSrcweir #include <avmedia/mediawindow.hxx>
44*cdf0e10cSrcweir #include "gallery.hrc"
45*cdf0e10cSrcweir #include <svtools/filter.hxx>
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir // -----------
48*cdf0e10cSrcweir // - Defines -
49*cdf0e10cSrcweir // -----------
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir #define GALLERY_BRWBOX_TITLE    1
52*cdf0e10cSrcweir #define GALLERY_BRWBOX_PATH     2
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir // ------------------
55*cdf0e10cSrcweir // - GalleryPreview -
56*cdf0e10cSrcweir // ------------------
57*cdf0e10cSrcweir DBG_NAME(GalleryPreview)
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir GalleryPreview::GalleryPreview( GalleryBrowser2* pParent, GalleryTheme* pTheme ) :
60*cdf0e10cSrcweir 	Window( pParent, WB_TABSTOP | WB_BORDER ),
61*cdf0e10cSrcweir 	DropTargetHelper( this ),
62*cdf0e10cSrcweir     DragSourceHelper( this ),
63*cdf0e10cSrcweir     mpTheme( pTheme )
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir     DBG_CTOR(GalleryPreview,NULL);
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir 	SetHelpId( HID_GALLERY_WINDOW );
68*cdf0e10cSrcweir     InitSettings();
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir // ------------------------------------------------------------------------
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir GalleryPreview::GalleryPreview( Window* pParent, const ResId & rResId  ) :
74*cdf0e10cSrcweir 	Window( pParent, rResId ),
75*cdf0e10cSrcweir 	DropTargetHelper( this ),
76*cdf0e10cSrcweir     DragSourceHelper( this ),
77*cdf0e10cSrcweir     mpTheme( NULL )
78*cdf0e10cSrcweir {
79*cdf0e10cSrcweir     DBG_CTOR(GalleryPreview,NULL);
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 	SetHelpId( HID_GALLERY_PREVIEW );
82*cdf0e10cSrcweir     InitSettings();
83*cdf0e10cSrcweir }
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir // ------------------------------------------------------------------------
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir GalleryPreview::~GalleryPreview()
88*cdf0e10cSrcweir {
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir     DBG_DTOR(GalleryPreview,NULL);
91*cdf0e10cSrcweir }
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir bool GalleryPreview::SetGraphic( const INetURLObject& _aURL )
95*cdf0e10cSrcweir {
96*cdf0e10cSrcweir 	bool bRet = true;
97*cdf0e10cSrcweir 	Graphic	aGraphic;
98*cdf0e10cSrcweir     if( ::avmedia::MediaWindow::isMediaURL( _aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) )
99*cdf0e10cSrcweir 	{
100*cdf0e10cSrcweir 		aGraphic = BitmapEx( GAL_RESID( RID_SVXBMP_GALLERY_MEDIA ) );
101*cdf0e10cSrcweir 	}
102*cdf0e10cSrcweir 	else
103*cdf0e10cSrcweir 	{
104*cdf0e10cSrcweir 		GraphicFilter*  pFilter = GraphicFilter::GetGraphicFilter();
105*cdf0e10cSrcweir 		GalleryProgress aProgress( pFilter );
106*cdf0e10cSrcweir         if( pFilter->ImportGraphic( aGraphic, _aURL, GRFILTER_FORMAT_DONTKNOW ) )
107*cdf0e10cSrcweir 			bRet = false;
108*cdf0e10cSrcweir 	}
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 	SetGraphic( aGraphic );
111*cdf0e10cSrcweir 	Invalidate();
112*cdf0e10cSrcweir 	return bRet;
113*cdf0e10cSrcweir }
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir // ------------------------------------------------------------------------
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir void GalleryPreview::InitSettings()
118*cdf0e10cSrcweir {
119*cdf0e10cSrcweir 	SetBackground( Wallpaper( GALLERY_BG_COLOR ) );
120*cdf0e10cSrcweir 	SetControlBackground( GALLERY_BG_COLOR );
121*cdf0e10cSrcweir 	SetControlForeground( GALLERY_FG_COLOR );
122*cdf0e10cSrcweir }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir // -----------------------------------------------------------------------
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir void GalleryPreview::DataChanged( const DataChangedEvent& rDCEvt )
127*cdf0e10cSrcweir {
128*cdf0e10cSrcweir 	if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
129*cdf0e10cSrcweir 		InitSettings();
130*cdf0e10cSrcweir 	else
131*cdf0e10cSrcweir 		Window::DataChanged( rDCEvt );
132*cdf0e10cSrcweir }
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir // ------------------------------------------------------------------------
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir sal_Bool GalleryPreview::ImplGetGraphicCenterRect( const Graphic& rGraphic, Rectangle& rResultRect ) const
137*cdf0e10cSrcweir {
138*cdf0e10cSrcweir 	const Size	aWinSize( GetOutputSizePixel() );
139*cdf0e10cSrcweir 	Size		aNewSize( LogicToPixel( rGraphic.GetPrefSize(), rGraphic.GetPrefMapMode() ) );
140*cdf0e10cSrcweir 	sal_Bool		bRet = sal_False;
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 	if( aNewSize.Width() && aNewSize.Height() )
143*cdf0e10cSrcweir 	{
144*cdf0e10cSrcweir 		// scale to fit window
145*cdf0e10cSrcweir 		const double fGrfWH = (double) aNewSize.Width() / aNewSize.Height();
146*cdf0e10cSrcweir 		const double fWinWH = (double) aWinSize.Width() / aWinSize.Height();
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 		if ( fGrfWH < fWinWH )
149*cdf0e10cSrcweir 		{
150*cdf0e10cSrcweir 			aNewSize.Width() = (long) ( aWinSize.Height() * fGrfWH );
151*cdf0e10cSrcweir 			aNewSize.Height()= aWinSize.Height();
152*cdf0e10cSrcweir 		}
153*cdf0e10cSrcweir 		else
154*cdf0e10cSrcweir 		{
155*cdf0e10cSrcweir 			aNewSize.Width() = aWinSize.Width();
156*cdf0e10cSrcweir 			aNewSize.Height()= (long) ( aWinSize.Width() / fGrfWH);
157*cdf0e10cSrcweir 		}
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 		const Point aNewPos( ( aWinSize.Width()  - aNewSize.Width() ) >> 1,
160*cdf0e10cSrcweir 							 ( aWinSize.Height() - aNewSize.Height() ) >> 1 );
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 		rResultRect = Rectangle( aNewPos, aNewSize );
163*cdf0e10cSrcweir 		bRet = sal_True;
164*cdf0e10cSrcweir 	}
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 	return bRet;
167*cdf0e10cSrcweir }
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir // ------------------------------------------------------------------------
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir void GalleryPreview::Paint( const Rectangle& rRect )
172*cdf0e10cSrcweir {
173*cdf0e10cSrcweir 	Window::Paint( rRect );
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir 	if( ImplGetGraphicCenterRect( aGraphicObj.GetGraphic(), aPreviewRect ) )
176*cdf0e10cSrcweir 	{
177*cdf0e10cSrcweir 		const Point aPos( aPreviewRect.TopLeft() );
178*cdf0e10cSrcweir 		const Size	aSize( aPreviewRect.GetSize() );
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir 		if( aGraphicObj.IsAnimated() )
181*cdf0e10cSrcweir 			aGraphicObj.StartAnimation( this, aPos, aSize );
182*cdf0e10cSrcweir 		else
183*cdf0e10cSrcweir 			aGraphicObj.Draw( this, aPos, aSize );
184*cdf0e10cSrcweir 	}
185*cdf0e10cSrcweir }
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir // ------------------------------------------------------------------------
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir void GalleryPreview::MouseButtonDown( const MouseEvent& rMEvt )
190*cdf0e10cSrcweir {
191*cdf0e10cSrcweir     if( mpTheme && ( rMEvt.GetClicks() == 2 ) )
192*cdf0e10cSrcweir         ( (GalleryBrowser2*) GetParent() )->TogglePreview( this );
193*cdf0e10cSrcweir }
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir // ------------------------------------------------------------------------
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir void GalleryPreview::Command(const CommandEvent& rCEvt )
198*cdf0e10cSrcweir {
199*cdf0e10cSrcweir 	Window::Command( rCEvt );
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir     if( mpTheme && ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) )
202*cdf0e10cSrcweir         ( (GalleryBrowser2*) GetParent() )->ShowContextMenu( this,
203*cdf0e10cSrcweir 			( rCEvt.IsMouseEvent() ? &rCEvt.GetMousePosPixel() : NULL ) );
204*cdf0e10cSrcweir }
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir // ------------------------------------------------------------------------
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir void GalleryPreview::KeyInput( const KeyEvent& rKEvt )
209*cdf0e10cSrcweir {
210*cdf0e10cSrcweir     if( mpTheme )
211*cdf0e10cSrcweir     {
212*cdf0e10cSrcweir         GalleryBrowser2* pBrowser = static_cast< GalleryBrowser2* >( GetParent() );
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir         switch( rKEvt.GetKeyCode().GetCode() )
215*cdf0e10cSrcweir         {
216*cdf0e10cSrcweir             case( KEY_BACKSPACE ):
217*cdf0e10cSrcweir                 pBrowser->TogglePreview( this );
218*cdf0e10cSrcweir             break;
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir             case( KEY_HOME ):
221*cdf0e10cSrcweir                 pBrowser->Travel( GALLERYBROWSERTRAVEL_FIRST );
222*cdf0e10cSrcweir             break;
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir             case( KEY_END ):
225*cdf0e10cSrcweir                 pBrowser->Travel( GALLERYBROWSERTRAVEL_LAST );
226*cdf0e10cSrcweir             break;
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir             case( KEY_LEFT ):
229*cdf0e10cSrcweir             case( KEY_UP ):
230*cdf0e10cSrcweir                 pBrowser->Travel( GALLERYBROWSERTRAVEL_PREVIOUS );
231*cdf0e10cSrcweir             break;
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir             case( KEY_RIGHT ):
234*cdf0e10cSrcweir             case( KEY_DOWN ):
235*cdf0e10cSrcweir                 pBrowser->Travel( GALLERYBROWSERTRAVEL_NEXT );
236*cdf0e10cSrcweir             break;
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir             default:
239*cdf0e10cSrcweir             {
240*cdf0e10cSrcweir                 if( !pBrowser->KeyInput( rKEvt, this ) )
241*cdf0e10cSrcweir                     Window::KeyInput( rKEvt );
242*cdf0e10cSrcweir             }
243*cdf0e10cSrcweir             break;
244*cdf0e10cSrcweir         }
245*cdf0e10cSrcweir     }
246*cdf0e10cSrcweir     else
247*cdf0e10cSrcweir         Window::KeyInput( rKEvt );
248*cdf0e10cSrcweir }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir // ------------------------------------------------------------------------
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir sal_Int8 GalleryPreview::AcceptDrop( const AcceptDropEvent& rEvt )
253*cdf0e10cSrcweir {
254*cdf0e10cSrcweir     sal_Int8 nRet;
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir     if( mpTheme )
257*cdf0e10cSrcweir         nRet = ( (GalleryBrowser2*) GetParent() )->AcceptDrop( *this, rEvt );
258*cdf0e10cSrcweir     else
259*cdf0e10cSrcweir         nRet = DND_ACTION_NONE;
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir     return nRet;
262*cdf0e10cSrcweir }
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir // ------------------------------------------------------------------------
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir sal_Int8 GalleryPreview::ExecuteDrop( const ExecuteDropEvent& rEvt )
267*cdf0e10cSrcweir {
268*cdf0e10cSrcweir     sal_Int8 nRet;
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir     if( mpTheme )
271*cdf0e10cSrcweir         nRet = ( (GalleryBrowser2*) GetParent() )->ExecuteDrop( *this, rEvt );
272*cdf0e10cSrcweir     else
273*cdf0e10cSrcweir         nRet = DND_ACTION_NONE;
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir     return nRet;
276*cdf0e10cSrcweir }
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir // ------------------------------------------------------------------------
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir void GalleryPreview::StartDrag( sal_Int8, const Point& )
281*cdf0e10cSrcweir {
282*cdf0e10cSrcweir     if( mpTheme )
283*cdf0e10cSrcweir         ( (GalleryBrowser2*) GetParent() )->StartDrag( this );
284*cdf0e10cSrcweir }
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir // ------------------------------------------------------------------------
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir void GalleryPreview::PreviewMedia( const INetURLObject& rURL )
289*cdf0e10cSrcweir {
290*cdf0e10cSrcweir 	if( rURL.GetProtocol() != INET_PROT_NOT_VALID )
291*cdf0e10cSrcweir 	{
292*cdf0e10cSrcweir 		::avmedia::MediaFloater* pFloater = AVMEDIA_MEDIAWINDOW();
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir 		if( !pFloater )
295*cdf0e10cSrcweir 		{
296*cdf0e10cSrcweir 			SfxViewFrame::Current()->GetBindings().GetDispatcher()->Execute( SID_AVMEDIA_PLAYER, SFX_CALLMODE_SYNCHRON );
297*cdf0e10cSrcweir 			pFloater = AVMEDIA_MEDIAWINDOW();
298*cdf0e10cSrcweir 		}
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir 		if( pFloater )
301*cdf0e10cSrcweir 			pFloater->setURL( rURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ), true );
302*cdf0e10cSrcweir 	}
303*cdf0e10cSrcweir }
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir // ------------------------------------------------------------------------
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir // -------------------
308*cdf0e10cSrcweir // - GalleryIconView -
309*cdf0e10cSrcweir // -------------------
310*cdf0e10cSrcweir DBG_NAME(GalleryIconView)
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir GalleryIconView::GalleryIconView( GalleryBrowser2* pParent, GalleryTheme* pTheme ) :
313*cdf0e10cSrcweir 		ValueSet( pParent, WB_TABSTOP | WB_3DLOOK | WB_BORDER | WB_ITEMBORDER | WB_DOUBLEBORDER | WB_VSCROLL | WB_FLATVALUESET ),
314*cdf0e10cSrcweir 		DropTargetHelper( this ),
315*cdf0e10cSrcweir         DragSourceHelper( this ),
316*cdf0e10cSrcweir 		mpTheme	( pTheme )
317*cdf0e10cSrcweir {
318*cdf0e10cSrcweir     DBG_CTOR(GalleryIconView,NULL);
319*cdf0e10cSrcweir 	EnableFullItemMode( sal_False );
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir 	SetHelpId( HID_GALLERY_WINDOW );
322*cdf0e10cSrcweir     InitSettings();
323*cdf0e10cSrcweir 	SetExtraSpacing( 2 );
324*cdf0e10cSrcweir 	SetItemWidth( S_THUMB + 6 );
325*cdf0e10cSrcweir 	SetItemHeight( S_THUMB + 6 );
326*cdf0e10cSrcweir }
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir // ------------------------------------------------------------------------
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir GalleryIconView::~GalleryIconView()
331*cdf0e10cSrcweir {
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir     DBG_DTOR(GalleryIconView,NULL);
334*cdf0e10cSrcweir }
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir // ------------------------------------------------------------------------
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir void GalleryIconView::InitSettings()
339*cdf0e10cSrcweir {
340*cdf0e10cSrcweir 	SetBackground( Wallpaper( GALLERY_BG_COLOR ) );
341*cdf0e10cSrcweir 	SetControlBackground( GALLERY_BG_COLOR );
342*cdf0e10cSrcweir 	SetControlForeground( GALLERY_FG_COLOR );
343*cdf0e10cSrcweir 	SetColor( GALLERY_BG_COLOR );
344*cdf0e10cSrcweir }
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir // -----------------------------------------------------------------------
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir void GalleryIconView::DataChanged( const DataChangedEvent& rDCEvt )
349*cdf0e10cSrcweir {
350*cdf0e10cSrcweir 	if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
351*cdf0e10cSrcweir 		InitSettings();
352*cdf0e10cSrcweir 	else
353*cdf0e10cSrcweir 		ValueSet::DataChanged( rDCEvt );
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir // ------------------------------------------------------------------------
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir void GalleryIconView::UserDraw( const UserDrawEvent& rUDEvt )
359*cdf0e10cSrcweir {
360*cdf0e10cSrcweir 	const sal_uInt16 nId = rUDEvt.GetItemId();
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir 	if( nId && mpTheme )
363*cdf0e10cSrcweir 	{
364*cdf0e10cSrcweir 		SgaObject* pObj = mpTheme->AcquireObject( nId - 1 );
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir 		if( pObj )
367*cdf0e10cSrcweir 		{
368*cdf0e10cSrcweir 			const Rectangle&	rRect = rUDEvt.GetRect();
369*cdf0e10cSrcweir 			OutputDevice*		pDev = rUDEvt.GetDevice();
370*cdf0e10cSrcweir 			Graphic 			aGraphic;
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir 			if( pObj->IsThumbBitmap() )
373*cdf0e10cSrcweir 			{
374*cdf0e10cSrcweir 				Bitmap aBmp( pObj->GetThumbBmp() );
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir 				if( pObj->GetObjKind() == SGA_OBJ_SOUND )
377*cdf0e10cSrcweir 					aBmp.Replace( COL_LIGHTMAGENTA, COL_WHITE );
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir 				if( ( pDev->GetBitCount() <= 8 ) && ( aBmp.GetBitCount() >= 8 ) )
380*cdf0e10cSrcweir 					aBmp.Dither( BMP_DITHER_FLOYD );
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir 				aGraphic = aBmp;
383*cdf0e10cSrcweir 			}
384*cdf0e10cSrcweir 			else
385*cdf0e10cSrcweir 				aGraphic = pObj->GetThumbMtf();
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir 			Size aSize( aGraphic.GetSizePixel( pDev ) );
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir 			if ( aSize.Width() && aSize.Height() )
390*cdf0e10cSrcweir 			{
391*cdf0e10cSrcweir 				if( ( aSize.Width() > rRect.GetWidth() ) || ( aSize.Height() > rRect.GetHeight() ) )
392*cdf0e10cSrcweir 				{
393*cdf0e10cSrcweir 					Point			aNewPos;
394*cdf0e10cSrcweir 					const double	fBmpWH	= (double) aSize.Width() / aSize.Height();
395*cdf0e10cSrcweir 					const double	fThmpWH = (double) rRect.GetWidth() / rRect.GetHeight();
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir 					// Bitmap an Thumbgroesse anpassen
398*cdf0e10cSrcweir 					if ( fBmpWH < fThmpWH )
399*cdf0e10cSrcweir 					{
400*cdf0e10cSrcweir 						aSize.Width() = (long) ( rRect.GetHeight() * fBmpWH );
401*cdf0e10cSrcweir 						aSize.Height()= rRect.GetHeight();
402*cdf0e10cSrcweir 					}
403*cdf0e10cSrcweir 					else
404*cdf0e10cSrcweir 					{
405*cdf0e10cSrcweir 						aSize.Width() = rRect.GetWidth();
406*cdf0e10cSrcweir 						aSize.Height()= (long) ( rRect.GetWidth() / fBmpWH );
407*cdf0e10cSrcweir 					}
408*cdf0e10cSrcweir 				}
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir 				const Point aPos( ( ( rRect.GetWidth() - aSize.Width() ) >> 1 ) + rRect.Left(),
411*cdf0e10cSrcweir 								  ( ( rRect.GetHeight() - aSize.Height() ) >> 1 ) + rRect.Top() );
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir 				aGraphic.Draw( pDev, aPos, aSize );
414*cdf0e10cSrcweir 			}
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir 			SetItemText( nId, GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_TITLE) );
417*cdf0e10cSrcweir 			mpTheme->ReleaseObject( pObj );
418*cdf0e10cSrcweir 		}
419*cdf0e10cSrcweir 	}
420*cdf0e10cSrcweir }
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir // ------------------------------------------------------------------------
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir void GalleryIconView::MouseButtonDown( const MouseEvent& rMEvt )
425*cdf0e10cSrcweir {
426*cdf0e10cSrcweir     ValueSet::MouseButtonDown( rMEvt );
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir     if( rMEvt.GetClicks() == 2 )
429*cdf0e10cSrcweir         ( (GalleryBrowser2*) GetParent() )->TogglePreview( this, &rMEvt.GetPosPixel() );
430*cdf0e10cSrcweir }
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir // ------------------------------------------------------------------------
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir void GalleryIconView::Command( const CommandEvent& rCEvt )
435*cdf0e10cSrcweir {
436*cdf0e10cSrcweir 	ValueSet::Command( rCEvt );
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir     if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
439*cdf0e10cSrcweir 	{
440*cdf0e10cSrcweir         ( (GalleryBrowser2*) GetParent() )->ShowContextMenu( this,
441*cdf0e10cSrcweir 			( rCEvt.IsMouseEvent() ? &rCEvt.GetMousePosPixel() : NULL ) );
442*cdf0e10cSrcweir 	}
443*cdf0e10cSrcweir }
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir // ------------------------------------------------------------------------
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir void GalleryIconView::KeyInput( const KeyEvent& rKEvt )
448*cdf0e10cSrcweir {
449*cdf0e10cSrcweir     if( !mpTheme || !static_cast< GalleryBrowser2* >( GetParent() )->KeyInput( rKEvt, this ) )
450*cdf0e10cSrcweir         ValueSet::KeyInput( rKEvt );
451*cdf0e10cSrcweir }
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir // ------------------------------------------------------------------------
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir sal_Int8 GalleryIconView::AcceptDrop( const AcceptDropEvent& rEvt )
456*cdf0e10cSrcweir {
457*cdf0e10cSrcweir 	return( static_cast< GalleryBrowser2* >( GetParent() )->AcceptDrop( *this, rEvt ) );
458*cdf0e10cSrcweir }
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir // ------------------------------------------------------------------------
461*cdf0e10cSrcweir 
462*cdf0e10cSrcweir sal_Int8 GalleryIconView::ExecuteDrop( const ExecuteDropEvent& rEvt )
463*cdf0e10cSrcweir {
464*cdf0e10cSrcweir 	return(	static_cast< GalleryBrowser2* >( GetParent() )->ExecuteDrop( *this, rEvt ) );
465*cdf0e10cSrcweir }
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir // ------------------------------------------------------------------------
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir void GalleryIconView::StartDrag( sal_Int8, const Point& )
470*cdf0e10cSrcweir {
471*cdf0e10cSrcweir 	const CommandEvent	aEvt( GetPointerPosPixel(), COMMAND_STARTDRAG, sal_True );
472*cdf0e10cSrcweir 	Region				aRegion;
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir 	// call this to initiate dragging for ValueSet
475*cdf0e10cSrcweir     ValueSet::StartDrag( aEvt, aRegion );
476*cdf0e10cSrcweir     static_cast< GalleryBrowser2* >( GetParent() )->StartDrag( this );
477*cdf0e10cSrcweir }
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir // -------------------
480*cdf0e10cSrcweir // - GalleryListView -
481*cdf0e10cSrcweir // -------------------
482*cdf0e10cSrcweir DBG_NAME(GalleryListView)
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir GalleryListView::GalleryListView( GalleryBrowser2* pParent, GalleryTheme* pTheme ) :
485*cdf0e10cSrcweir     BrowseBox( pParent, WB_TABSTOP | WB_3DLOOK | WB_BORDER ),
486*cdf0e10cSrcweir     mpTheme( pTheme ),
487*cdf0e10cSrcweir     mnCurRow( 0 ),
488*cdf0e10cSrcweir     mbInit( sal_False )
489*cdf0e10cSrcweir {
490*cdf0e10cSrcweir     DBG_CTOR(GalleryListView,NULL);
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir 	SetHelpId( HID_GALLERY_WINDOW );
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir     InitSettings();
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir     SetMode( BROWSER_AUTO_VSCROLL | BROWSER_AUTOSIZE_LASTCOL );
497*cdf0e10cSrcweir     SetDataRowHeight( 28 );
498*cdf0e10cSrcweir 	InsertDataColumn( GALLERY_BRWBOX_TITLE, String( GAL_RESID( RID_SVXSTR_GALLERY_TITLE ) ), 256  );
499*cdf0e10cSrcweir 	InsertDataColumn( GALLERY_BRWBOX_PATH, String( GAL_RESID( RID_SVXSTR_GALLERY_PATH ) ), 256 );
500*cdf0e10cSrcweir }
501*cdf0e10cSrcweir 
502*cdf0e10cSrcweir // ------------------------------------------------------------------------
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir GalleryListView::~GalleryListView()
505*cdf0e10cSrcweir {
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir     DBG_DTOR(GalleryListView,NULL);
508*cdf0e10cSrcweir }
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir // ------------------------------------------------------------------------
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir void GalleryListView::InitSettings()
513*cdf0e10cSrcweir {
514*cdf0e10cSrcweir 	SetBackground( Wallpaper( GALLERY_BG_COLOR ) );
515*cdf0e10cSrcweir 	SetControlBackground( GALLERY_BG_COLOR );
516*cdf0e10cSrcweir 	SetControlForeground( GALLERY_FG_COLOR );
517*cdf0e10cSrcweir }
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir // -----------------------------------------------------------------------
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir void GalleryListView::DataChanged( const DataChangedEvent& rDCEvt )
522*cdf0e10cSrcweir {
523*cdf0e10cSrcweir 	if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
524*cdf0e10cSrcweir 		InitSettings();
525*cdf0e10cSrcweir 	else
526*cdf0e10cSrcweir 		BrowseBox::DataChanged( rDCEvt );
527*cdf0e10cSrcweir }
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir // ------------------------------------------------------------------------
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir sal_Bool GalleryListView::SeekRow( long nRow )
532*cdf0e10cSrcweir {
533*cdf0e10cSrcweir     mnCurRow = nRow;
534*cdf0e10cSrcweir     return sal_True;
535*cdf0e10cSrcweir }
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir // -----------------------------------------------------------------------------
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir String GalleryListView::GetCellText(long _nRow, sal_uInt16 nColumnId) const
540*cdf0e10cSrcweir {
541*cdf0e10cSrcweir 	String sRet;
542*cdf0e10cSrcweir 	if( mpTheme && ( _nRow < static_cast< long >( mpTheme->GetObjectCount() ) ) )
543*cdf0e10cSrcweir 	{
544*cdf0e10cSrcweir     	SgaObject* pObj = mpTheme->AcquireObject( _nRow );
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir 		if( pObj )
547*cdf0e10cSrcweir 		{
548*cdf0e10cSrcweir 			sRet = GalleryBrowser2::GetItemText( *mpTheme, *pObj,
549*cdf0e10cSrcweir 				( GALLERY_BRWBOX_TITLE == nColumnId ) ? GALLERY_ITEM_TITLE : GALLERY_ITEM_PATH );
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir 		    mpTheme->ReleaseObject( pObj );
552*cdf0e10cSrcweir 		}
553*cdf0e10cSrcweir 	}
554*cdf0e10cSrcweir 
555*cdf0e10cSrcweir 	return sRet;;
556*cdf0e10cSrcweir }
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir // -----------------------------------------------------------------------------
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir Rectangle GalleryListView::GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex)
561*cdf0e10cSrcweir {
562*cdf0e10cSrcweir     DBG_ASSERT(_nColumnPos >= 0 && _nColumnPos <= USHRT_MAX, "GalleryListView::GetFieldCharacterBounds: _nColumnId overflow");
563*cdf0e10cSrcweir 	Rectangle aRect;
564*cdf0e10cSrcweir 	if ( SeekRow(_nRow) )
565*cdf0e10cSrcweir 	{
566*cdf0e10cSrcweir         SvxFont aFont( GetFont() );
567*cdf0e10cSrcweir         AccessibleStringWrap aStringWrap( *this, aFont, GetCellText(_nRow, sal::static_int_cast<sal_uInt16>( GetColumnId( sal::static_int_cast<sal_uInt16>(_nColumnPos) ) ) ) );
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir         // get the bounds inside the string
570*cdf0e10cSrcweir         aStringWrap.GetCharacterBounds(nIndex, aRect);
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir         // offset to
573*cdf0e10cSrcweir 	}
574*cdf0e10cSrcweir 	return aRect;
575*cdf0e10cSrcweir }
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir // -----------------------------------------------------------------------------
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir sal_Int32 GalleryListView::GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint)
580*cdf0e10cSrcweir {
581*cdf0e10cSrcweir     DBG_ASSERT(_nColumnPos >= 0 && _nColumnPos <= USHRT_MAX, "GalleryListView::GetFieldIndexAtPoint: _nColumnId overflow");
582*cdf0e10cSrcweir 	sal_Int32 nRet = -1;
583*cdf0e10cSrcweir 	if ( SeekRow(_nRow) )
584*cdf0e10cSrcweir 	{
585*cdf0e10cSrcweir         SvxFont aFont( GetFont() );
586*cdf0e10cSrcweir         AccessibleStringWrap aStringWrap( *this, aFont, GetCellText(_nRow, sal::static_int_cast<sal_uInt16>(GetColumnId(sal::static_int_cast<sal_uInt16>(_nColumnPos)))) );
587*cdf0e10cSrcweir         nRet = aStringWrap.GetIndexAtPoint(_rPoint);
588*cdf0e10cSrcweir 	}
589*cdf0e10cSrcweir 	return nRet;
590*cdf0e10cSrcweir }
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir // ------------------------------------------------------------------------
593*cdf0e10cSrcweir 
594*cdf0e10cSrcweir void GalleryListView::PaintField( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId ) const
595*cdf0e10cSrcweir {
596*cdf0e10cSrcweir     rDev.Push( PUSH_CLIPREGION );
597*cdf0e10cSrcweir     rDev.IntersectClipRegion( rRect );
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir 	if( mpTheme && ( mnCurRow < mpTheme->GetObjectCount() ) )
600*cdf0e10cSrcweir 	{
601*cdf0e10cSrcweir     	SgaObject* pObj = mpTheme->AcquireObject( mnCurRow );
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir 		if( pObj )
604*cdf0e10cSrcweir 		{
605*cdf0e10cSrcweir             const long nTextPosY = rRect.Top() + ( ( rRect.GetHeight() - rDev.GetTextHeight() ) >> 1 );
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir             if( GALLERY_BRWBOX_TITLE == nColumnId )
608*cdf0e10cSrcweir             {
609*cdf0e10cSrcweir                 Rectangle       aOutputRect( rRect.TopLeft(), Size( rRect.GetHeight(), rRect.GetHeight() ) );
610*cdf0e10cSrcweir     			GraphicObject   aGrfObj;
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir                 if( pObj->GetObjKind() == SGA_OBJ_SOUND )
613*cdf0e10cSrcweir                     aGrfObj = Graphic( BitmapEx( GAL_RESID( RID_SVXBMP_GALLERY_MEDIA ) ) );
614*cdf0e10cSrcweir                 else if( pObj->IsThumbBitmap() )
615*cdf0e10cSrcweir 				    aGrfObj = Graphic( pObj->GetThumbBmp() );
616*cdf0e10cSrcweir 			    else
617*cdf0e10cSrcweir 				    aGrfObj = Graphic( pObj->GetThumbMtf() );
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir 			    Size aSize( rDev.LogicToPixel( aGrfObj.GetPrefSize(), aGrfObj.GetPrefMapMode() ) );
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir 			    if( aSize.Width() && aSize.Height() )
622*cdf0e10cSrcweir 			    {
623*cdf0e10cSrcweir 				    if( ( aSize.Width() > aOutputRect.GetWidth() ) || ( aSize.Height() > aOutputRect.GetHeight() ) )
624*cdf0e10cSrcweir 				    {
625*cdf0e10cSrcweir 					    Point			aNewPos;
626*cdf0e10cSrcweir 					    const double	fBmpWH	= (double) aSize.Width() / aSize.Height();
627*cdf0e10cSrcweir 					    const double	fThmpWH = (double) aOutputRect.GetWidth() / aOutputRect.GetHeight();
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir 					    // Bitmap an Thumbgroesse anpassen
630*cdf0e10cSrcweir 					    if ( fBmpWH < fThmpWH )
631*cdf0e10cSrcweir 					    {
632*cdf0e10cSrcweir 						    aSize.Width() = (long) ( aOutputRect.GetHeight() * fBmpWH );
633*cdf0e10cSrcweir 						    aSize.Height()= aOutputRect.GetHeight();
634*cdf0e10cSrcweir 					    }
635*cdf0e10cSrcweir 					    else
636*cdf0e10cSrcweir 					    {
637*cdf0e10cSrcweir 						    aSize.Width() = aOutputRect.GetWidth();
638*cdf0e10cSrcweir 						    aSize.Height()= (long) ( aOutputRect.GetWidth() / fBmpWH );
639*cdf0e10cSrcweir 					    }
640*cdf0e10cSrcweir 				    }
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir                     aSize.Width() = Max( aSize.Width(), 4L );
643*cdf0e10cSrcweir                     aSize.Height() = Max( aSize.Height(), 4L );
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir 				    const Point aPos( ( ( aOutputRect.GetWidth() - aSize.Width() ) >> 1 ) + aOutputRect.Left(),
646*cdf0e10cSrcweir 								      ( ( aOutputRect.GetHeight() - aSize.Height() ) >> 1 ) + aOutputRect.Top() );
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir 				    aGrfObj.Draw( &rDev, aPos, aSize );
649*cdf0e10cSrcweir 			    }
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir 			    rDev.DrawText( Point( aOutputRect.Right() + 6, nTextPosY ), GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_TITLE ) );
652*cdf0e10cSrcweir             }
653*cdf0e10cSrcweir             else if( GALLERY_BRWBOX_PATH == nColumnId )
654*cdf0e10cSrcweir                 rDev.DrawText( Point( rRect.Left(), nTextPosY ), GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_PATH ) );
655*cdf0e10cSrcweir 
656*cdf0e10cSrcweir 		    mpTheme->ReleaseObject( pObj );
657*cdf0e10cSrcweir 		}
658*cdf0e10cSrcweir 	}
659*cdf0e10cSrcweir 
660*cdf0e10cSrcweir     rDev.Pop();
661*cdf0e10cSrcweir }
662*cdf0e10cSrcweir 
663*cdf0e10cSrcweir // ------------------------------------------------------------------------
664*cdf0e10cSrcweir 
665*cdf0e10cSrcweir void GalleryListView::Command( const CommandEvent& rCEvt )
666*cdf0e10cSrcweir {
667*cdf0e10cSrcweir 	BrowseBox::Command( rCEvt );
668*cdf0e10cSrcweir 
669*cdf0e10cSrcweir     if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
670*cdf0e10cSrcweir 	{
671*cdf0e10cSrcweir 		const Point* pPos = NULL;
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir 		if( rCEvt.IsMouseEvent() && ( GetRowAtYPosPixel( rCEvt.GetMousePosPixel().Y() ) != BROWSER_ENDOFSELECTION ) )
674*cdf0e10cSrcweir 			pPos = &rCEvt.GetMousePosPixel();
675*cdf0e10cSrcweir 
676*cdf0e10cSrcweir 		( (GalleryBrowser2*) GetParent() )->ShowContextMenu( this, pPos );
677*cdf0e10cSrcweir 	}
678*cdf0e10cSrcweir }
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir // ------------------------------------------------------------------------
681*cdf0e10cSrcweir 
682*cdf0e10cSrcweir void GalleryListView::KeyInput( const KeyEvent& rKEvt )
683*cdf0e10cSrcweir {
684*cdf0e10cSrcweir     if( !mpTheme || !static_cast< GalleryBrowser2* >( GetParent() )->KeyInput( rKEvt, this ) )
685*cdf0e10cSrcweir         BrowseBox::KeyInput( rKEvt );
686*cdf0e10cSrcweir }
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir // ------------------------------------------------------------------------
689*cdf0e10cSrcweir 
690*cdf0e10cSrcweir void GalleryListView::DoubleClick( const BrowserMouseEvent& rEvt )
691*cdf0e10cSrcweir {
692*cdf0e10cSrcweir     BrowseBox::DoubleClick( rEvt );
693*cdf0e10cSrcweir 
694*cdf0e10cSrcweir     if( rEvt.GetRow() != BROWSER_ENDOFSELECTION )
695*cdf0e10cSrcweir         ( (GalleryBrowser2*) GetParent() )->TogglePreview( this, &rEvt.GetPosPixel() );
696*cdf0e10cSrcweir }
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir // ------------------------------------------------------------------------
699*cdf0e10cSrcweir 
700*cdf0e10cSrcweir void GalleryListView::Select()
701*cdf0e10cSrcweir {
702*cdf0e10cSrcweir     if( maSelectHdl.IsSet() )
703*cdf0e10cSrcweir         maSelectHdl.Call( this );
704*cdf0e10cSrcweir }
705*cdf0e10cSrcweir 
706*cdf0e10cSrcweir // ------------------------------------------------------------------------
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir sal_Int8 GalleryListView::AcceptDrop( const BrowserAcceptDropEvent& )
709*cdf0e10cSrcweir {
710*cdf0e10cSrcweir     sal_Int8 nRet = DND_ACTION_NONE;
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir    	if( mpTheme && !mpTheme->IsReadOnly() && !mpTheme ->IsImported() )
713*cdf0e10cSrcweir 	{
714*cdf0e10cSrcweir 		if( !mpTheme->IsDragging() )
715*cdf0e10cSrcweir 			nRet = DND_ACTION_COPY;
716*cdf0e10cSrcweir 		else
717*cdf0e10cSrcweir 			nRet = DND_ACTION_COPY;
718*cdf0e10cSrcweir 	}
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir 	return nRet;
721*cdf0e10cSrcweir }
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir // ------------------------------------------------------------------------
724*cdf0e10cSrcweir 
725*cdf0e10cSrcweir sal_Int8 GalleryListView::ExecuteDrop( const BrowserExecuteDropEvent& rEvt )
726*cdf0e10cSrcweir {
727*cdf0e10cSrcweir     ExecuteDropEvent aEvt( rEvt );
728*cdf0e10cSrcweir 
729*cdf0e10cSrcweir     aEvt.maPosPixel.Y() += GetTitleHeight();
730*cdf0e10cSrcweir 
731*cdf0e10cSrcweir     return(	( (GalleryBrowser2*) GetParent() )->ExecuteDrop( *this, aEvt ) );
732*cdf0e10cSrcweir }
733*cdf0e10cSrcweir 
734*cdf0e10cSrcweir // ------------------------------------------------------------------------
735*cdf0e10cSrcweir 
736*cdf0e10cSrcweir void GalleryListView::StartDrag( sal_Int8, const Point& rPosPixel )
737*cdf0e10cSrcweir {
738*cdf0e10cSrcweir     ( (GalleryBrowser2*) GetParent() )->StartDrag( this, &rPosPixel );
739*cdf0e10cSrcweir }
740