xref: /trunk/main/svx/source/gallery2/galbrws1.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 
31 #include <tools/datetime.hxx>
32 #include <unotools/datetime.hxx>
33 #include <vcl/msgbox.hxx>
34 #include <ucbhelper/content.hxx>
35 #include <sfx2/app.hxx>
36 #include "helpid.hrc"
37 #include "svx/gallery1.hxx"
38 #include "svx/galtheme.hxx"
39 #include "svx/galmisc.hxx"
40 #include "galbrws1.hxx"
41 #include <com/sun/star/util/DateTime.hpp>
42 #include "gallery.hrc"
43 #include <algorithm>
44 #include <svx/dialogs.hrc>
45 #include <svx/dialmgr.hxx>
46 
47 #include <svx/svxdlg.hxx> //CHINA001
48 //CHINA001 #include <svx/dialogs.hrc> //CHINA001
49 
50 // --------------
51 // - Namespaces -
52 // --------------
53 
54 using namespace ::rtl;
55 using namespace ::com::sun::star;
56 
57 // -----------------
58 // - GalleryButton -
59 // -----------------
60 DBG_NAME(GalleryButton)
61 
62 GalleryButton::GalleryButton( GalleryBrowser1* pParent, WinBits nWinBits ) :
63     PushButton( pParent, nWinBits )
64 {
65     DBG_CTOR(GalleryButton,NULL);
66 
67 }
68 
69 // -----------------------------------------------------------------------------
70 
71 GalleryButton::~GalleryButton()
72 {
73 
74     DBG_DTOR(GalleryButton,NULL);
75 }
76 
77 // -----------------------------------------------------------------------------
78 
79 void GalleryButton::KeyInput( const KeyEvent& rKEvt )
80 {
81     if( !static_cast< GalleryBrowser1* >( GetParent() )->KeyInput( rKEvt, this ) )
82         PushButton::KeyInput( rKEvt );
83 }
84 
85 // -----------------------
86 // - GalleryThemeListBox -
87 // -----------------------
88 DBG_NAME(GalleryThemeListBox)
89 
90 GalleryThemeListBox::GalleryThemeListBox( GalleryBrowser1* pParent, WinBits nWinBits ) :
91 	ListBox( pParent, nWinBits )
92 {
93     DBG_CTOR(GalleryThemeListBox,NULL);
94 
95     InitSettings();
96 }
97 
98 // -----------------------------------------------------------------------------
99 
100 GalleryThemeListBox::~GalleryThemeListBox()
101 {
102 
103     DBG_DTOR(GalleryThemeListBox,NULL);
104 }
105 
106 // ------------------------------------------------------------------------
107 
108 void GalleryThemeListBox::InitSettings()
109 {
110 	SetBackground( Wallpaper( GALLERY_BG_COLOR ) );
111 	SetControlBackground( GALLERY_BG_COLOR );
112 	SetControlForeground( GALLERY_FG_COLOR );
113 }
114 
115 // -----------------------------------------------------------------------
116 
117 void GalleryThemeListBox::DataChanged( const DataChangedEvent& rDCEvt )
118 {
119 	if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
120 		InitSettings();
121 	else
122 		ListBox::DataChanged( rDCEvt );
123 }
124 
125 // -----------------------------------------------------------------------------
126 
127 long GalleryThemeListBox::PreNotify( NotifyEvent& rNEvt )
128 {
129     long nDone = 0;
130 
131 	if( rNEvt.GetType() == EVENT_COMMAND )
132 	{
133 		const CommandEvent* pCEvt = rNEvt.GetCommandEvent();
134 
135 		if( pCEvt && pCEvt->GetCommand() == COMMAND_CONTEXTMENU )
136 			static_cast< GalleryBrowser1* >( GetParent() )->ShowContextMenu();
137 	}
138     else if( rNEvt.GetType() == EVENT_KEYINPUT )
139     {
140 		const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
141 
142         if( pKEvt )
143             nDone = static_cast< GalleryBrowser1* >( GetParent() )->KeyInput( *pKEvt, this );
144     }
145 
146 	return( nDone ? nDone : ListBox::PreNotify( rNEvt ) );
147 }
148 
149 // -------------------
150 // - GalleryBrowser1 -
151 // -------------------
152 DBG_NAME(GalleryBrowser1)
153 
154 GalleryBrowser1::GalleryBrowser1( GalleryBrowser* pParent, const ResId& rResId, Gallery* pGallery ) :
155     Control               ( pParent, rResId ),
156     maNewTheme            ( this, WB_3DLOOK ),
157     mpThemes              ( new GalleryThemeListBox( this, WB_TABSTOP | WB_3DLOOK | WB_BORDER | WB_HSCROLL | WB_VSCROLL | WB_AUTOHSCROLL | WB_SORT ) ),
158     mpGallery             ( pGallery ),
159     mpExchangeData        ( new ExchangeData ),
160     mpThemePropsDlgItemSet( NULL ),
161     aImgNormal            ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_NORMAL ) ),
162     aImgDefault           ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_DEFAULT ) ),
163     aImgReadOnly          ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_READONLY ) ),
164     aImgImported          ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_IMPORTED ) )
165 {
166     DBG_CTOR(GalleryBrowser1,NULL);
167 
168 	StartListening( *mpGallery );
169 
170 	maNewTheme.SetHelpId( HID_GALLERY_NEWTHEME );
171 	maNewTheme.SetText( String( GAL_RESID( RID_SVXSTR_GALLERY_CREATETHEME ) ) );
172 	maNewTheme.SetClickHdl( LINK( this, GalleryBrowser1, ClickNewThemeHdl ) );
173 
174 	// disable creation of new themes if a writable directory is not available
175 	if( mpGallery->GetUserURL().GetProtocol() == INET_PROT_NOT_VALID )
176 	    maNewTheme.Disable();
177 
178 	mpThemes->SetHelpId( HID_GALLERY_THEMELIST );
179 	mpThemes->SetSelectHdl( LINK( this, GalleryBrowser1, SelectThemeHdl ) );
180 	mpThemes->SetAccessibleName(String(SVX_RES( RID_SVXSTR_GALLERYPROPS_GALTHEME ) ) );
181 
182 	for( sal_uIntPtr i = 0, nCount = mpGallery->GetThemeCount(); i < nCount; i++ )
183 		ImplInsertThemeEntry( mpGallery->GetThemeInfo( i ) );
184 
185 	ImplAdjustControls();
186 	maNewTheme.Show( sal_True );
187 	mpThemes->Show( sal_True );
188 }
189 
190 // -----------------------------------------------------------------------------
191 
192 GalleryBrowser1::~GalleryBrowser1()
193 {
194 	EndListening( *mpGallery );
195 	delete mpThemes;
196 	mpThemes = NULL;
197     delete mpExchangeData;
198     mpExchangeData = NULL;
199 
200     DBG_DTOR(GalleryBrowser1,NULL);
201 }
202 
203 // -----------------------------------------------------------------------------
204 
205 sal_uIntPtr GalleryBrowser1::ImplInsertThemeEntry( const GalleryThemeEntry* pEntry )
206 {
207 	static const sal_Bool bShowHiddenThemes = ( getenv( "GALLERY_SHOW_HIDDEN_THEMES" ) != NULL );
208 
209 	sal_uIntPtr nRet = LISTBOX_ENTRY_NOTFOUND;
210 
211 	if( pEntry && ( !pEntry->IsHidden() || bShowHiddenThemes ) )
212 	{
213 		const Image* pImage;
214 
215 		if( pEntry->IsImported() )
216 			pImage = &aImgImported;
217 		else if( pEntry->IsReadOnly() )
218 			pImage = &aImgReadOnly;
219 		else if( pEntry->IsDefault() )
220 			pImage = &aImgDefault;
221 		else
222 			pImage = &aImgNormal;
223 
224 		nRet = mpThemes->InsertEntry( pEntry->GetThemeName(), *pImage );
225 	}
226 
227 	return nRet;
228 }
229 
230 // -----------------------------------------------------------------------------
231 
232 void GalleryBrowser1::ImplAdjustControls()
233 {
234 	const Size	aOutSize( GetOutputSizePixel() );
235 	const long	nNewThemeHeight = LogicToPixel( Size( 0, 14 ), MAP_APPFONT ).Height();
236     const long  nStartY = nNewThemeHeight + 4;
237 
238 	maNewTheme.SetPosSizePixel( Point(),
239 								Size( aOutSize.Width(), nNewThemeHeight ) );
240 
241 	mpThemes->SetPosSizePixel( Point( 0, nStartY ),
242 							   Size( aOutSize.Width(), aOutSize.Height() - nStartY ) );
243 }
244 
245 // -----------------------------------------------------------------------------
246 
247 void GalleryBrowser1::ImplFillExchangeData( const GalleryTheme* pThm, ExchangeData& rData )
248 {
249 	rData.pTheme = (GalleryTheme*) pThm;
250 	rData.aEditedTitle = pThm->GetName();
251 
252 	try
253 	{
254 		::ucbhelper::Content aCnt( pThm->GetThmURL().GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment >() );
255 		util::DateTime	aDateTimeModified;
256 		DateTime		aDateTime;
257 
258 		aCnt.getPropertyValue( OUString::createFromAscii( "DateModified" ) ) >>= aDateTimeModified;
259 		::utl::typeConvert( aDateTimeModified, aDateTime );
260 		rData.aThemeChangeDate = aDateTime;
261 		rData.aThemeChangeTime = aDateTime;
262 	}
263 	catch( const ucb::ContentCreationException& )
264 	{
265 	}
266 	catch( const uno::RuntimeException& )
267 	{
268 	}
269 	catch( const uno::Exception& )
270 	{
271 	}
272 }
273 
274 // -----------------------------------------------------------------------------
275 
276 void GalleryBrowser1::ImplGetExecuteVector(::std::vector< sal_uInt16 >& o_aExec)
277 {
278 	GalleryTheme*           pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this );
279 
280 	if( pTheme )
281 	{
282 		sal_Bool                bUpdateAllowed, bRenameAllowed, bRemoveAllowed;
283 		static const sal_Bool	bIdDialog = ( getenv( "GALLERY_ENABLE_ID_DIALOG" ) != NULL );
284 
285 		if( pTheme->IsReadOnly() )
286 			bUpdateAllowed = bRenameAllowed = bRemoveAllowed = sal_False;
287 		else if( pTheme->IsImported() )
288 		{
289 			bUpdateAllowed = sal_False;
290 			bRenameAllowed = bRemoveAllowed = sal_True;
291 		}
292 		else if( pTheme->IsDefault() )
293 		{
294 			bUpdateAllowed = bRenameAllowed = sal_True;
295 			bRemoveAllowed = sal_False;
296 		}
297 		else
298 			bUpdateAllowed = bRenameAllowed = bRemoveAllowed = sal_True;
299 
300         if( bUpdateAllowed && pTheme->GetObjectCount() )
301             o_aExec.push_back( MN_ACTUALIZE );
302 
303         if( bRenameAllowed )
304             o_aExec.push_back( MN_RENAME );
305 
306         if( bRemoveAllowed )
307             o_aExec.push_back( MN_DELETE );
308 
309         if( bIdDialog && !pTheme->IsReadOnly() && !pTheme->IsImported() )
310             o_aExec.push_back( MN_ASSIGN_ID );
311 
312         o_aExec.push_back( MN_PROPERTIES );
313 
314 		mpGallery->ReleaseTheme( pTheme, *this );
315     }
316 }
317 
318 // -----------------------------------------------------------------------------
319 
320 void GalleryBrowser1::ImplGalleryThemeProperties( const String & rThemeName, bool bCreateNew )
321 {
322     DBG_ASSERT(!mpThemePropsDlgItemSet, "mpThemePropsDlgItemSet already set!");
323     mpThemePropsDlgItemSet = new SfxItemSet( SFX_APP()->GetPool() );
324     GalleryTheme*   pTheme = mpGallery->AcquireTheme( rThemeName, *this );
325 
326     ImplFillExchangeData( pTheme, *mpExchangeData );
327 
328     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
329     DBG_ASSERT(pFact, "Got no AbstractDialogFactory!");
330     VclAbstractDialog2* pThemeProps = pFact->CreateGalleryThemePropertiesDialog( NULL, mpExchangeData, mpThemePropsDlgItemSet );
331     DBG_ASSERT(pThemeProps, "Got no GalleryThemePropertiesDialog!");
332 
333     if ( bCreateNew )
334     {
335         pThemeProps->StartExecuteModal(
336             LINK( this, GalleryBrowser1, EndNewThemePropertiesDlgHdl ) );
337     }
338     else
339     {
340         pThemeProps->StartExecuteModal(
341             LINK( this, GalleryBrowser1, EndThemePropertiesDlgHdl ) );
342     }
343 }
344 
345 // -----------------------------------------------------------------------------
346 
347 void GalleryBrowser1::ImplEndGalleryThemeProperties( VclAbstractDialog2* pDialog, bool bCreateNew )
348 {
349     long nRet = pDialog->GetResult();
350 
351     if( nRet == RET_OK )
352     {
353         String aName( mpExchangeData->pTheme->GetName() );
354 
355         if( mpExchangeData->aEditedTitle.Len() && aName != mpExchangeData->aEditedTitle )
356         {
357             const String    aOldName( aName );
358             String          aTitle( mpExchangeData->aEditedTitle );
359             sal_uInt16          nCount = 0;
360 
361             while( mpGallery->HasTheme( aTitle ) && ( nCount++ < 16000 ) )
362             {
363                 aTitle = mpExchangeData->aEditedTitle;
364                 aTitle += ' ';
365                 aTitle += String::CreateFromInt32( nCount );
366             }
367 
368             mpGallery->RenameTheme( aOldName, aTitle );
369         }
370 
371         if ( bCreateNew )
372         {
373             mpThemes->SelectEntry( mpExchangeData->pTheme->GetName() );
374             SelectThemeHdl( NULL );
375         }
376     }
377 
378     String aThemeName( mpExchangeData->pTheme->GetName() );
379     mpGallery->ReleaseTheme( mpExchangeData->pTheme, *this );
380 
381     if ( bCreateNew && ( nRet != RET_OK ) )
382     {
383         mpGallery->RemoveTheme( aThemeName );
384     }
385 
386     // destroy mpThemeProps asynchronously
387     Application::PostUserEvent( LINK( this, GalleryBrowser1, DestroyThemePropertiesDlgHdl ) );
388 }
389 
390 // -----------------------------------------------------------------------------
391 
392 IMPL_LINK( GalleryBrowser1, EndNewThemePropertiesDlgHdl, VclAbstractDialog2*, pDialog )
393 {
394     ImplEndGalleryThemeProperties( pDialog, true );
395     return 0L;
396 }
397 
398 // -----------------------------------------------------------------------------
399 
400 IMPL_LINK( GalleryBrowser1, EndThemePropertiesDlgHdl, VclAbstractDialog2*, pDialog )
401 {
402     ImplEndGalleryThemeProperties( pDialog, false );
403     return 0L;
404 }
405 
406 // -----------------------------------------------------------------------------
407 
408 IMPL_LINK( GalleryBrowser1, DestroyThemePropertiesDlgHdl, VclAbstractDialog2*, pDialog )
409 {
410     delete pDialog;
411     delete mpThemePropsDlgItemSet;
412     mpThemePropsDlgItemSet = 0;
413     return 0L;
414 }
415 
416 // -----------------------------------------------------------------------------
417 
418 void GalleryBrowser1::ImplExecute( sal_uInt16 nId )
419 {
420 	switch( nId )
421 	{
422 		case( MN_ACTUALIZE ):
423 		{
424 			GalleryTheme*		pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this );
425 			//CHINA001 ActualizeProgress	aActualizeProgress( this, pTheme );
426 			SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
427 			if(pFact)
428 			{
429 				VclAbstractRefreshableDialog* aActualizeProgress = pFact->CreateActualizeProgressDialog( this, pTheme );
430 				DBG_ASSERT(aActualizeProgress, "Dialogdiet fail!");//CHINA001
431 
432 				aActualizeProgress->Update();  //CHINA001 aActualizeProgress.Update();
433 				aActualizeProgress->Execute(); //CHINA001 aActualizeProgress.Execute();
434 				mpGallery->ReleaseTheme( pTheme, *this );
435 				delete aActualizeProgress;		//add CHINA001
436 			}
437 		}
438 		break;
439 
440 		case( MN_DELETE  ):
441 		{
442 			if( QueryBox( NULL, WB_YES_NO, String( GAL_RESID( RID_SVXSTR_GALLERY_DELETETHEME ) ) ).Execute() == RET_YES )
443 				mpGallery->RemoveTheme( mpThemes->GetSelectEntry() );
444 		}
445 		break;
446 
447 		case( MN_RENAME ):
448 		{
449 			GalleryTheme*	pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this );
450 			const String	aOldName( pTheme->GetName() );
451 			//CHINA001 TitleDialog		aDlg( this, aOldName );
452 			SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
453 			DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
454 			AbstractTitleDialog* aDlg = pFact->CreateTitleDialog( this, aOldName );
455 			DBG_ASSERT(aDlg, "Dialogdiet fail!");//CHINA001
456 
457 			if( aDlg->Execute() == RET_OK ) //CHINA001 if( aDlg.Execute() == RET_OK )
458 			{
459 				const String aNewName( aDlg->GetTitle() ); //CHINA001 aDlg.GetTitle() );
460 
461 				if( aNewName.Len() && ( aNewName != aOldName ) )
462 				{
463 					String	aName( aNewName );
464 					sal_uInt16	nCount = 0;
465 
466 					while( mpGallery->HasTheme( aName ) && ( nCount++ < 16000 ) )
467 					{
468 						aName = aNewName;
469 						aName += ' ';
470 						aName += String::CreateFromInt32( nCount );
471 					}
472 
473 					mpGallery->RenameTheme( aOldName, aName );
474 				}
475 			}
476 			mpGallery->ReleaseTheme( pTheme, *this );
477 			delete aDlg; //add CHINA001
478 		}
479 		break;
480 
481 		case( MN_ASSIGN_ID ):
482 		{
483 			GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this );
484 
485 			if( pTheme && !pTheme->IsReadOnly() && !pTheme->IsImported() )
486 			{
487 				//CHINA001 GalleryIdDialog aDlg( this, pTheme );
488 				SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
489 				if(pFact)
490 				{
491 					AbstractGalleryIdDialog* aDlg = pFact->CreateGalleryIdDialog( this, pTheme );
492 					DBG_ASSERT(aDlg, "Dialogdiet fail!");//CHINA001
493 
494 					if( aDlg->Execute() == RET_OK ) //CHINA001 if( aDlg.Execute() == RET_OK )
495 						pTheme->SetId( aDlg->GetId(), sal_True ); //CHINA001 pTheme->SetId( aDlg.GetId(), sal_True );
496 					delete aDlg; //add CHINA001
497 				}
498 			}
499 
500 			mpGallery->ReleaseTheme( pTheme, *this );
501 		}
502 		break;
503 
504 		case( MN_PROPERTIES ):
505 		{
506             ImplGalleryThemeProperties( GetSelectedTheme(), false );
507 		}
508 		break;
509 	}
510 }
511 
512 // -----------------------------------------------------------------------------
513 
514 void GalleryBrowser1::Resize()
515 {
516 	Control::Resize();
517 	ImplAdjustControls();
518 }
519 
520 // -----------------------------------------------------------------------------
521 
522 void GalleryBrowser1::GetFocus()
523 {
524 	Control::GetFocus();
525 	if( mpThemes )
526 		mpThemes->GrabFocus();
527 }
528 
529 // -----------------------------------------------------------------------------
530 
531 void GalleryBrowser1::Notify( SfxBroadcaster&, const SfxHint& rHint )
532 {
533 	const GalleryHint& rGalleryHint = (const GalleryHint&) rHint;
534 
535 	switch( rGalleryHint.GetType() )
536 	{
537 		case( GALLERY_HINT_THEME_CREATED ):
538 			ImplInsertThemeEntry( mpGallery->GetThemeInfo( rGalleryHint.GetThemeName() ) );
539 		break;
540 
541 		case( GALLERY_HINT_THEME_RENAMED ):
542 		{
543 			const sal_uInt16 nCurSelectPos = mpThemes->GetSelectEntryPos();
544 			const sal_uInt16 nRenameEntryPos = mpThemes->GetEntryPos( rGalleryHint.GetThemeName() );
545 
546 			mpThemes->RemoveEntry( rGalleryHint.GetThemeName() );
547 			ImplInsertThemeEntry( mpGallery->GetThemeInfo( rGalleryHint.GetStringData() ) );
548 
549 			if( nCurSelectPos == nRenameEntryPos )
550 			{
551 				mpThemes->SelectEntry( rGalleryHint.GetStringData() );
552 				SelectThemeHdl( NULL );
553 			}
554 		}
555 		break;
556 
557 		case( GALLERY_HINT_THEME_REMOVED ):
558 		{
559 			mpThemes->RemoveEntry( rGalleryHint.GetThemeName() );
560 		}
561 		break;
562 
563 		case( GALLERY_HINT_CLOSE_THEME ):
564 		{
565 			const sal_uInt16 nCurSelectPos = mpThemes->GetSelectEntryPos();
566 			const sal_uInt16 nCloseEntryPos = mpThemes->GetEntryPos( rGalleryHint.GetThemeName() );
567 
568 			if( nCurSelectPos == nCloseEntryPos )
569 			{
570 				if( nCurSelectPos < ( mpThemes->GetEntryCount() - 1 ) )
571 					mpThemes->SelectEntryPos( nCurSelectPos + 1 );
572 				else if( nCurSelectPos )
573 					mpThemes->SelectEntryPos( nCurSelectPos - 1 );
574 				else
575 					mpThemes->SetNoSelection();
576 
577 				SelectThemeHdl( NULL );
578 			}
579 		}
580 		break;
581 
582 		default:
583 		break;
584 	}
585 }
586 
587 // -----------------------------------------------------------------------------
588 
589 void GalleryBrowser1::ShowContextMenu()
590 {
591 	Application::PostUserEvent( LINK( this, GalleryBrowser1, ShowContextMenuHdl ), this );
592 }
593 
594 // -----------------------------------------------------------------------------
595 
596 sal_Bool GalleryBrowser1::KeyInput( const KeyEvent& rKEvt, Window* pWindow )
597 {
598     sal_Bool bRet = static_cast< GalleryBrowser* >( GetParent() )->KeyInput( rKEvt, pWindow );
599 
600     if( !bRet )
601     {
602         ::std::vector< sal_uInt16 > aExecVector;
603         ImplGetExecuteVector(aExecVector);
604         sal_uInt16                  nExecuteId = 0;
605         sal_Bool                    bMod1 = rKEvt.GetKeyCode().IsMod1();
606 
607         switch( rKEvt.GetKeyCode().GetCode() )
608         {
609             case( KEY_INSERT ):
610                 ClickNewThemeHdl( NULL );
611             break;
612 
613             case( KEY_I ):
614             {
615                 if( bMod1 )
616                    ClickNewThemeHdl( NULL );
617             }
618             break;
619 
620             case( KEY_U ):
621             {
622                 if( bMod1 )
623                     nExecuteId = MN_ACTUALIZE;
624             }
625             break;
626 
627             case( KEY_DELETE ):
628                 nExecuteId = MN_DELETE;
629             break;
630 
631             case( KEY_D ):
632             {
633                 if( bMod1 )
634                     nExecuteId = MN_DELETE;
635             }
636             break;
637 
638             case( KEY_R ):
639             {
640                 if( bMod1 )
641                     nExecuteId = MN_RENAME;
642             }
643             break;
644 
645             case( KEY_RETURN ):
646             {
647                 if( bMod1 )
648                     nExecuteId = MN_PROPERTIES;
649             }
650             break;
651         }
652 
653         if( nExecuteId && ( ::std::find( aExecVector.begin(), aExecVector.end(), nExecuteId ) != aExecVector.end() ) )
654         {
655             ImplExecute( nExecuteId );
656             bRet = sal_True;
657         }
658     }
659 
660     return bRet;
661 }
662 
663 // -----------------------------------------------------------------------------
664 
665 IMPL_LINK( GalleryBrowser1, ShowContextMenuHdl, void*, EMPTYARG )
666 {
667     ::std::vector< sal_uInt16 > aExecVector;
668     ImplGetExecuteVector(aExecVector);
669 
670     if( !aExecVector.empty() )
671     {
672 		PopupMenu aMenu( GAL_RESID( RID_SVXMN_GALLERY1 ) );
673 
674 		aMenu.EnableItem( MN_ACTUALIZE, ::std::find( aExecVector.begin(), aExecVector.end(), MN_ACTUALIZE ) != aExecVector.end() );
675 		aMenu.EnableItem( MN_RENAME, ::std::find( aExecVector.begin(), aExecVector.end(), MN_RENAME ) != aExecVector.end() );
676 		aMenu.EnableItem( MN_DELETE, ::std::find( aExecVector.begin(), aExecVector.end(), MN_DELETE ) != aExecVector.end() );
677 		aMenu.EnableItem( MN_ASSIGN_ID, ::std::find( aExecVector.begin(), aExecVector.end(), MN_ASSIGN_ID ) != aExecVector.end() );
678 		aMenu.EnableItem( MN_PROPERTIES, ::std::find( aExecVector.begin(), aExecVector.end(), MN_PROPERTIES ) != aExecVector.end() );
679 		aMenu.SetSelectHdl( LINK( this, GalleryBrowser1, PopupMenuHdl ) );
680 		aMenu.RemoveDisabledEntries();
681 
682 		const Rectangle aThemesRect( mpThemes->GetPosPixel(), mpThemes->GetOutputSizePixel() );
683 		Point			aSelPos( mpThemes->GetBoundingRectangle( mpThemes->GetSelectEntryPos() ).Center() );
684 
685 		aSelPos.X() = Max( Min( aSelPos.X(), aThemesRect.Right() ), aThemesRect.Left() );
686 		aSelPos.Y() = Max( Min( aSelPos.Y(), aThemesRect.Bottom() ), aThemesRect.Top() );
687 
688 		aMenu.Execute( this, aSelPos );
689 	}
690 
691 	return 0L;
692 }
693 
694 // -----------------------------------------------------------------------------
695 
696 IMPL_LINK( GalleryBrowser1, PopupMenuHdl, Menu*, pMenu )
697 {
698     ImplExecute( pMenu->GetCurItemId() );
699     return 0L;
700 }
701 
702 // -----------------------------------------------------------------------------
703 
704 IMPL_LINK( GalleryBrowser1, SelectThemeHdl, void*, EMPTYARG )
705 {
706 	( (GalleryBrowser*) GetParent() )->ThemeSelectionHasChanged();
707 	return 0L;
708 }
709 
710 // -----------------------------------------------------------------------------
711 
712 IMPL_LINK( GalleryBrowser1, ClickNewThemeHdl, void*, EMPTYARG )
713 {
714 	String	aNewTheme( GAL_RESID( RID_SVXSTR_GALLERY_NEWTHEME ) );
715 	String	aName( aNewTheme );
716 	sal_uIntPtr	nCount = 0;
717 
718 	while( mpGallery->HasTheme( aName ) && ( nCount++ < 16000 ) )
719 	{
720 		aName = aNewTheme;
721 		aName += ' ';
722 		aName += String::CreateFromInt32( nCount );
723 	}
724 
725 	if( !mpGallery->HasTheme( aName ) && mpGallery->CreateTheme( aName ) )
726 	{
727         ImplGalleryThemeProperties( aName, true );
728 	}
729 
730 	return 0L;
731 }
732 
733