update dev300-m58
[ooovba.git] / svx / source / gallery2 / galbrws1.cxx
blobff3a01ae6dce0f6e06c2550254ab466cecdb41b3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: galbrws1.cxx,v $
10 * $Revision: 1.34 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include <tools/datetime.hxx>
35 #include <unotools/datetime.hxx>
36 #include <vcl/msgbox.hxx>
37 #include <ucbhelper/content.hxx>
38 #include <sfx2/app.hxx>
39 #include "helpid.hrc"
40 #include "gallery1.hxx"
41 #include "galtheme.hxx"
42 #include "galmisc.hxx"
43 #include "galdlg.hxx"
44 #include "galbrws1.hxx"
45 #include <com/sun/star/util/DateTime.hpp>
47 #include <algorithm>
49 #include <svx/svxdlg.hxx> //CHINA001
50 //CHINA001 #include <svx/dialogs.hrc> //CHINA001
52 // --------------
53 // - Namespaces -
54 // --------------
56 using namespace ::rtl;
57 using namespace ::com::sun::star;
59 // -----------------
60 // - GalleryButton -
61 // -----------------
63 GalleryButton::GalleryButton( GalleryBrowser1* pParent, WinBits nWinBits ) :
64 PushButton( pParent, nWinBits )
68 // -----------------------------------------------------------------------------
70 GalleryButton::~GalleryButton()
74 // -----------------------------------------------------------------------------
76 void GalleryButton::KeyInput( const KeyEvent& rKEvt )
78 if( !static_cast< GalleryBrowser1* >( GetParent() )->KeyInput( rKEvt, this ) )
79 PushButton::KeyInput( rKEvt );
82 // -----------------------
83 // - GalleryThemeListBox -
84 // -----------------------
86 GalleryThemeListBox::GalleryThemeListBox( GalleryBrowser1* pParent, WinBits nWinBits ) :
87 ListBox( pParent, nWinBits )
89 InitSettings();
92 // -----------------------------------------------------------------------------
94 GalleryThemeListBox::~GalleryThemeListBox()
98 // ------------------------------------------------------------------------
100 void GalleryThemeListBox::InitSettings()
102 SetBackground( Wallpaper( GALLERY_BG_COLOR ) );
103 SetControlBackground( GALLERY_BG_COLOR );
104 SetControlForeground( GALLERY_FG_COLOR );
107 // -----------------------------------------------------------------------
109 void GalleryThemeListBox::DataChanged( const DataChangedEvent& rDCEvt )
111 if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
112 InitSettings();
113 else
114 ListBox::DataChanged( rDCEvt );
117 // -----------------------------------------------------------------------------
119 long GalleryThemeListBox::PreNotify( NotifyEvent& rNEvt )
121 long nDone = 0;
123 if( rNEvt.GetType() == EVENT_COMMAND )
125 const CommandEvent* pCEvt = rNEvt.GetCommandEvent();
127 if( pCEvt && pCEvt->GetCommand() == COMMAND_CONTEXTMENU )
128 static_cast< GalleryBrowser1* >( GetParent() )->ShowContextMenu();
130 else if( rNEvt.GetType() == EVENT_KEYINPUT )
132 const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
134 if( pKEvt )
135 nDone = static_cast< GalleryBrowser1* >( GetParent() )->KeyInput( *pKEvt, this );
138 return( nDone ? nDone : ListBox::PreNotify( rNEvt ) );
141 // -------------------
142 // - GalleryBrowser1 -
143 // -------------------
145 GalleryBrowser1::GalleryBrowser1( GalleryBrowser* pParent, const ResId& rResId, Gallery* pGallery ) :
146 Control ( pParent, rResId ),
147 maNewTheme ( this, WB_3DLOOK ),
148 mpThemes ( new GalleryThemeListBox( this, WB_TABSTOP | WB_3DLOOK | WB_BORDER | WB_HSCROLL | WB_VSCROLL | WB_AUTOHSCROLL | WB_SORT ) ),
149 mpGallery ( pGallery ),
150 mpExchangeData ( new ExchangeData ),
151 mpThemePropsDlgItemSet( NULL ),
152 aImgNormal ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_NORMAL ) ),
153 aImgDefault ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_DEFAULT ) ),
154 aImgReadOnly ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_READONLY ) ),
155 aImgImported ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_IMPORTED ) )
157 StartListening( *mpGallery );
159 maNewTheme.SetHelpId( HID_GALLERY_NEWTHEME );
160 maNewTheme.SetText( String( GAL_RESID( RID_SVXSTR_GALLERY_CREATETHEME ) ) );
161 maNewTheme.SetClickHdl( LINK( this, GalleryBrowser1, ClickNewThemeHdl ) );
163 // disable creation of new themes if a writable directory is not available
164 if( mpGallery->GetUserURL().GetProtocol() == INET_PROT_NOT_VALID )
165 maNewTheme.Disable();
167 mpThemes->SetHelpId( HID_GALLERY_THEMELIST );
168 mpThemes->SetSelectHdl( LINK( this, GalleryBrowser1, SelectThemeHdl ) );
170 for( ULONG i = 0, nCount = mpGallery->GetThemeCount(); i < nCount; i++ )
171 ImplInsertThemeEntry( mpGallery->GetThemeInfo( i ) );
173 ImplAdjustControls();
174 maNewTheme.Show( TRUE );
175 mpThemes->Show( TRUE );
178 // -----------------------------------------------------------------------------
180 GalleryBrowser1::~GalleryBrowser1()
182 EndListening( *mpGallery );
183 delete mpThemes;
184 mpThemes = NULL;
185 delete mpExchangeData;
186 mpExchangeData = NULL;
189 // -----------------------------------------------------------------------------
191 ULONG GalleryBrowser1::ImplInsertThemeEntry( const GalleryThemeEntry* pEntry )
193 static const BOOL bShowHiddenThemes = ( getenv( "GALLERY_SHOW_HIDDEN_THEMES" ) != NULL );
195 ULONG nRet = LISTBOX_ENTRY_NOTFOUND;
197 if( pEntry && ( !pEntry->IsHidden() || bShowHiddenThemes ) )
199 const Image* pImage;
201 if( pEntry->IsImported() )
202 pImage = &aImgImported;
203 else if( pEntry->IsReadOnly() )
204 pImage = &aImgReadOnly;
205 else if( pEntry->IsDefault() )
206 pImage = &aImgDefault;
207 else
208 pImage = &aImgNormal;
210 nRet = mpThemes->InsertEntry( pEntry->GetThemeName(), *pImage );
213 return nRet;
216 // -----------------------------------------------------------------------------
218 void GalleryBrowser1::ImplAdjustControls()
220 const Size aOutSize( GetOutputSizePixel() );
221 const long nNewThemeHeight = LogicToPixel( Size( 0, 14 ), MAP_APPFONT ).Height();
222 const long nStartY = nNewThemeHeight + 4;
224 maNewTheme.SetPosSizePixel( Point(),
225 Size( aOutSize.Width(), nNewThemeHeight ) );
227 mpThemes->SetPosSizePixel( Point( 0, nStartY ),
228 Size( aOutSize.Width(), aOutSize.Height() - nStartY ) );
231 // -----------------------------------------------------------------------------
233 void GalleryBrowser1::ImplFillExchangeData( const GalleryTheme* pThm, ExchangeData& rData )
235 rData.pTheme = (GalleryTheme*) pThm;
236 rData.aEditedTitle = pThm->GetName();
240 ::ucbhelper::Content aCnt( pThm->GetThmURL().GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment >() );
241 util::DateTime aDateTimeModified;
242 DateTime aDateTime;
244 aCnt.getPropertyValue( OUString::createFromAscii( "DateModified" ) ) >>= aDateTimeModified;
245 ::utl::typeConvert( aDateTimeModified, aDateTime );
246 rData.aThemeChangeDate = aDateTime;
247 rData.aThemeChangeTime = aDateTime;
249 catch( const ucb::ContentCreationException& )
252 catch( const uno::RuntimeException& )
255 catch( const uno::Exception& )
260 // -----------------------------------------------------------------------------
262 ::std::vector< USHORT > GalleryBrowser1::ImplGetExecuteVector()
264 ::std::vector< USHORT > aExecVector;
265 GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this );
267 if( pTheme )
269 BOOL bUpdateAllowed, bRenameAllowed, bRemoveAllowed;
270 static const BOOL bIdDialog = ( getenv( "GALLERY_ENABLE_ID_DIALOG" ) != NULL );
272 if( pTheme->IsReadOnly() )
273 bUpdateAllowed = bRenameAllowed = bRemoveAllowed = FALSE;
274 else if( pTheme->IsImported() )
276 bUpdateAllowed = FALSE;
277 bRenameAllowed = bRemoveAllowed = TRUE;
279 else if( pTheme->IsDefault() )
281 bUpdateAllowed = bRenameAllowed = TRUE;
282 bRemoveAllowed = FALSE;
284 else
285 bUpdateAllowed = bRenameAllowed = bRemoveAllowed = TRUE;
287 if( bUpdateAllowed && pTheme->GetObjectCount() )
288 aExecVector.push_back( MN_ACTUALIZE );
290 if( bRenameAllowed )
291 aExecVector.push_back( MN_RENAME );
293 if( bRemoveAllowed )
294 aExecVector.push_back( MN_DELETE );
296 if( bIdDialog && !pTheme->IsReadOnly() && !pTheme->IsImported() )
297 aExecVector.push_back( MN_ASSIGN_ID );
299 aExecVector.push_back( MN_PROPERTIES );
301 mpGallery->ReleaseTheme( pTheme, *this );
304 return aExecVector;
307 // -----------------------------------------------------------------------------
309 void GalleryBrowser1::ImplGalleryThemeProperties( const String & rThemeName, bool bCreateNew )
311 DBG_ASSERT(!mpThemePropsDlgItemSet, "mpThemePropsDlgItemSet already set!");
312 mpThemePropsDlgItemSet = new SfxItemSet( SFX_APP()->GetPool() );
313 GalleryTheme* pTheme = mpGallery->AcquireTheme( rThemeName, *this );
315 ImplFillExchangeData( pTheme, *mpExchangeData );
317 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
318 DBG_ASSERT(pFact, "Got no AbstractDialogFactory!");
319 VclAbstractDialog2* pThemeProps = pFact->CreateGalleryThemePropertiesDialog( NULL, mpExchangeData, mpThemePropsDlgItemSet, RID_SVXTABDLG_GALLERYTHEME );
320 DBG_ASSERT(pThemeProps, "Got no GalleryThemePropertiesDialog!");
322 if ( bCreateNew )
324 pThemeProps->StartExecuteModal(
325 LINK( this, GalleryBrowser1, EndNewThemePropertiesDlgHdl ) );
327 else
329 pThemeProps->StartExecuteModal(
330 LINK( this, GalleryBrowser1, EndThemePropertiesDlgHdl ) );
334 // -----------------------------------------------------------------------------
336 void GalleryBrowser1::ImplEndGalleryThemeProperties( VclAbstractDialog2* pDialog, bool bCreateNew )
338 long nRet = pDialog->GetResult();
340 if( nRet == RET_OK )
342 String aName( mpExchangeData->pTheme->GetName() );
344 if( mpExchangeData->aEditedTitle.Len() && aName != mpExchangeData->aEditedTitle )
346 const String aOldName( aName );
347 String aTitle( mpExchangeData->aEditedTitle );
348 USHORT nCount = 0;
350 while( mpGallery->HasTheme( aTitle ) && ( nCount++ < 16000 ) )
352 aTitle = mpExchangeData->aEditedTitle;
353 aTitle += ' ';
354 aTitle += String::CreateFromInt32( nCount );
357 mpGallery->RenameTheme( aOldName, aTitle );
360 if ( bCreateNew )
362 mpThemes->SelectEntry( mpExchangeData->pTheme->GetName() );
363 SelectThemeHdl( NULL );
367 String aThemeName( mpExchangeData->pTheme->GetName() );
368 mpGallery->ReleaseTheme( mpExchangeData->pTheme, *this );
370 if ( bCreateNew && ( nRet != RET_OK ) )
372 mpGallery->RemoveTheme( aThemeName );
375 // destroy mpThemeProps asynchronously
376 Application::PostUserEvent( LINK( this, GalleryBrowser1, DestroyThemePropertiesDlgHdl ) );
379 // -----------------------------------------------------------------------------
381 IMPL_LINK( GalleryBrowser1, EndNewThemePropertiesDlgHdl, VclAbstractDialog2*, pDialog )
383 ImplEndGalleryThemeProperties( pDialog, true );
384 return 0L;
387 // -----------------------------------------------------------------------------
389 IMPL_LINK( GalleryBrowser1, EndThemePropertiesDlgHdl, VclAbstractDialog2*, pDialog )
391 ImplEndGalleryThemeProperties( pDialog, false );
392 return 0L;
395 // -----------------------------------------------------------------------------
397 IMPL_LINK( GalleryBrowser1, DestroyThemePropertiesDlgHdl, VclAbstractDialog2*, pDialog )
399 delete pDialog;
400 delete mpThemePropsDlgItemSet;
401 mpThemePropsDlgItemSet = 0;
402 return 0L;
405 // -----------------------------------------------------------------------------
407 void GalleryBrowser1::ImplExecute( USHORT nId )
409 switch( nId )
411 case( MN_ACTUALIZE ):
413 GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this );
414 //CHINA001 ActualizeProgress aActualizeProgress( this, pTheme );
415 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
416 if(pFact)
418 VclAbstractRefreshableDialog* aActualizeProgress = pFact->CreateActualizeProgressDialog( this, pTheme, RID_SVXDLG_GALLERY_ACTUALIZE_PROGRESS );
419 DBG_ASSERT(aActualizeProgress, "Dialogdiet fail!");//CHINA001
421 aActualizeProgress->Update(); //CHINA001 aActualizeProgress.Update();
422 aActualizeProgress->Execute(); //CHINA001 aActualizeProgress.Execute();
423 mpGallery->ReleaseTheme( pTheme, *this );
424 delete aActualizeProgress; //add CHINA001
427 break;
429 case( MN_DELETE ):
431 if( QueryBox( NULL, WB_YES_NO, String( GAL_RESID( RID_SVXSTR_GALLERY_DELETETHEME ) ) ).Execute() == RET_YES )
432 mpGallery->RemoveTheme( mpThemes->GetSelectEntry() );
434 break;
436 case( MN_RENAME ):
438 GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this );
439 const String aOldName( pTheme->GetName() );
440 //CHINA001 TitleDialog aDlg( this, aOldName );
441 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
442 DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
443 AbstractTitleDialog* aDlg = pFact->CreateTitleDialog( this, aOldName, RID_SVXDLG_GALLERY_TITLE );
444 DBG_ASSERT(aDlg, "Dialogdiet fail!");//CHINA001
446 if( aDlg->Execute() == RET_OK ) //CHINA001 if( aDlg.Execute() == RET_OK )
448 const String aNewName( aDlg->GetTitle() ); //CHINA001 aDlg.GetTitle() );
450 if( aNewName.Len() && ( aNewName != aOldName ) )
452 String aName( aNewName );
453 USHORT nCount = 0;
455 while( mpGallery->HasTheme( aName ) && ( nCount++ < 16000 ) )
457 aName = aNewName;
458 aName += ' ';
459 aName += String::CreateFromInt32( nCount );
462 mpGallery->RenameTheme( aOldName, aName );
465 mpGallery->ReleaseTheme( pTheme, *this );
466 delete aDlg; //add CHINA001
468 break;
470 case( MN_ASSIGN_ID ):
472 GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this );
474 if( pTheme && !pTheme->IsReadOnly() && !pTheme->IsImported() )
476 //CHINA001 GalleryIdDialog aDlg( this, pTheme );
477 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
478 if(pFact)
480 AbstractGalleryIdDialog* aDlg = pFact->CreateGalleryIdDialog( this, pTheme, RID_SVXDLG_GALLERY_THEMEID );
481 DBG_ASSERT(aDlg, "Dialogdiet fail!");//CHINA001
483 if( aDlg->Execute() == RET_OK ) //CHINA001 if( aDlg.Execute() == RET_OK )
484 pTheme->SetId( aDlg->GetId(), TRUE ); //CHINA001 pTheme->SetId( aDlg.GetId(), TRUE );
485 delete aDlg; //add CHINA001
489 mpGallery->ReleaseTheme( pTheme, *this );
491 break;
493 case( MN_PROPERTIES ):
495 ImplGalleryThemeProperties( GetSelectedTheme(), false );
497 break;
501 // -----------------------------------------------------------------------------
503 void GalleryBrowser1::Resize()
505 Control::Resize();
506 ImplAdjustControls();
509 // -----------------------------------------------------------------------------
511 void GalleryBrowser1::GetFocus()
513 Control::GetFocus();
514 if( mpThemes )
515 mpThemes->GrabFocus();
518 // -----------------------------------------------------------------------------
520 void GalleryBrowser1::Notify( SfxBroadcaster&, const SfxHint& rHint )
522 const GalleryHint& rGalleryHint = (const GalleryHint&) rHint;
524 switch( rGalleryHint.GetType() )
526 case( GALLERY_HINT_THEME_CREATED ):
527 ImplInsertThemeEntry( mpGallery->GetThemeInfo( rGalleryHint.GetThemeName() ) );
528 break;
530 case( GALLERY_HINT_THEME_RENAMED ):
532 const USHORT nCurSelectPos = mpThemes->GetSelectEntryPos();
533 const USHORT nRenameEntryPos = mpThemes->GetEntryPos( rGalleryHint.GetThemeName() );
535 mpThemes->RemoveEntry( rGalleryHint.GetThemeName() );
536 ImplInsertThemeEntry( mpGallery->GetThemeInfo( rGalleryHint.GetStringData() ) );
538 if( nCurSelectPos == nRenameEntryPos )
540 mpThemes->SelectEntry( rGalleryHint.GetStringData() );
541 SelectThemeHdl( NULL );
544 break;
546 case( GALLERY_HINT_THEME_REMOVED ):
548 mpThemes->RemoveEntry( rGalleryHint.GetThemeName() );
550 break;
552 case( GALLERY_HINT_CLOSE_THEME ):
554 const USHORT nCurSelectPos = mpThemes->GetSelectEntryPos();
555 const USHORT nCloseEntryPos = mpThemes->GetEntryPos( rGalleryHint.GetThemeName() );
557 if( nCurSelectPos == nCloseEntryPos )
559 if( nCurSelectPos < ( mpThemes->GetEntryCount() - 1 ) )
560 mpThemes->SelectEntryPos( nCurSelectPos + 1 );
561 else if( nCurSelectPos )
562 mpThemes->SelectEntryPos( nCurSelectPos - 1 );
563 else
564 mpThemes->SetNoSelection();
566 SelectThemeHdl( NULL );
569 break;
571 default:
572 break;
576 // -----------------------------------------------------------------------------
578 void GalleryBrowser1::ShowContextMenu()
580 Application::PostUserEvent( LINK( this, GalleryBrowser1, ShowContextMenuHdl ), this );
583 // -----------------------------------------------------------------------------
585 BOOL GalleryBrowser1::KeyInput( const KeyEvent& rKEvt, Window* pWindow )
587 BOOL bRet = static_cast< GalleryBrowser* >( GetParent() )->KeyInput( rKEvt, pWindow );
589 if( !bRet )
591 ::std::vector< USHORT > aExecVector( ImplGetExecuteVector() );
592 USHORT nExecuteId = 0;
593 BOOL bMod1 = rKEvt.GetKeyCode().IsMod1();
595 switch( rKEvt.GetKeyCode().GetCode() )
597 case( KEY_INSERT ):
598 ClickNewThemeHdl( NULL );
599 break;
601 case( KEY_I ):
603 if( bMod1 )
604 ClickNewThemeHdl( NULL );
606 break;
608 case( KEY_U ):
610 if( bMod1 )
611 nExecuteId = MN_ACTUALIZE;
613 break;
615 case( KEY_DELETE ):
616 nExecuteId = MN_DELETE;
617 break;
619 case( KEY_D ):
621 if( bMod1 )
622 nExecuteId = MN_DELETE;
624 break;
626 case( KEY_R ):
628 if( bMod1 )
629 nExecuteId = MN_RENAME;
631 break;
633 case( KEY_RETURN ):
635 if( bMod1 )
636 nExecuteId = MN_PROPERTIES;
638 break;
641 if( nExecuteId && ( ::std::find( aExecVector.begin(), aExecVector.end(), nExecuteId ) != aExecVector.end() ) )
643 ImplExecute( nExecuteId );
644 bRet = TRUE;
648 return bRet;
651 // -----------------------------------------------------------------------------
653 IMPL_LINK( GalleryBrowser1, ShowContextMenuHdl, void*, EMPTYARG )
655 ::std::vector< USHORT > aExecVector( ImplGetExecuteVector() );
657 if( aExecVector.size() )
659 PopupMenu aMenu( GAL_RESID( RID_SVXMN_GALLERY1 ) );
661 aMenu.EnableItem( MN_ACTUALIZE, ::std::find( aExecVector.begin(), aExecVector.end(), MN_ACTUALIZE ) != aExecVector.end() );
662 aMenu.EnableItem( MN_RENAME, ::std::find( aExecVector.begin(), aExecVector.end(), MN_RENAME ) != aExecVector.end() );
663 aMenu.EnableItem( MN_DELETE, ::std::find( aExecVector.begin(), aExecVector.end(), MN_DELETE ) != aExecVector.end() );
664 aMenu.EnableItem( MN_ASSIGN_ID, ::std::find( aExecVector.begin(), aExecVector.end(), MN_ASSIGN_ID ) != aExecVector.end() );
665 aMenu.EnableItem( MN_PROPERTIES, ::std::find( aExecVector.begin(), aExecVector.end(), MN_PROPERTIES ) != aExecVector.end() );
666 aMenu.SetSelectHdl( LINK( this, GalleryBrowser1, PopupMenuHdl ) );
667 aMenu.RemoveDisabledEntries();
669 const Rectangle aThemesRect( mpThemes->GetPosPixel(), mpThemes->GetOutputSizePixel() );
670 Point aSelPos( mpThemes->GetBoundingRectangle( mpThemes->GetSelectEntryPos() ).Center() );
672 aSelPos.X() = Max( Min( aSelPos.X(), aThemesRect.Right() ), aThemesRect.Left() );
673 aSelPos.Y() = Max( Min( aSelPos.Y(), aThemesRect.Bottom() ), aThemesRect.Top() );
675 aMenu.Execute( this, aSelPos );
678 return 0L;
681 // -----------------------------------------------------------------------------
683 IMPL_LINK( GalleryBrowser1, PopupMenuHdl, Menu*, pMenu )
685 ImplExecute( pMenu->GetCurItemId() );
686 return 0L;
689 // -----------------------------------------------------------------------------
691 IMPL_LINK( GalleryBrowser1, SelectThemeHdl, void*, EMPTYARG )
693 ( (GalleryBrowser*) GetParent() )->ThemeSelectionHasChanged();
694 return 0L;
697 // -----------------------------------------------------------------------------
699 IMPL_LINK( GalleryBrowser1, ClickNewThemeHdl, void*, EMPTYARG )
701 String aNewTheme( GAL_RESID( RID_SVXSTR_GALLERY_NEWTHEME ) );
702 String aName( aNewTheme );
703 ULONG nCount = 0;
705 while( mpGallery->HasTheme( aName ) && ( nCount++ < 16000 ) )
707 aName = aNewTheme;
708 aName += ' ';
709 aName += String::CreateFromInt32( nCount );
712 if( !mpGallery->HasTheme( aName ) && mpGallery->CreateTheme( aName ) )
714 ImplGalleryThemeProperties( aName, true );
717 return 0L;