summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorKai Ahrens <ka@openoffice.org>2002-02-07 14:41:38 +0000
committerKai Ahrens <ka@openoffice.org>2002-02-07 14:41:38 +0000
commit4801fd703ffa8e651ae96029dd0e590c13447770 (patch)
tree5ef2af49b2cd79a8c45b928700589990e917f067 /svx
parent82e233e1920da0e9a35a1478c9845cbe1fafd5ca (diff)
#96960#: accessibility for Gallery
Diffstat (limited to 'svx')
-rw-r--r--svx/source/gallery2/galbrws.cxx42
-rw-r--r--svx/source/gallery2/galbrws1.cxx304
-rw-r--r--svx/source/gallery2/galbrws1.hxx31
-rw-r--r--svx/source/gallery2/galbrws2.cxx417
4 files changed, 568 insertions, 226 deletions
diff --git a/svx/source/gallery2/galbrws.cxx b/svx/source/gallery2/galbrws.cxx
index dfa6d462cf71..7ca0fef17da9 100644
--- a/svx/source/gallery2/galbrws.cxx
+++ b/svx/source/gallery2/galbrws.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: galbrws.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: ka $ $Date: 2001-05-16 10:05:18 $
+ * last change: $Author: ka $ $Date: 2002-02-07 15:41:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -156,6 +156,44 @@ void GalleryBrowser::Resize()
// -----------------------------------------------------------------------------
+BOOL GalleryBrowser::KeyInput( const KeyEvent& rKEvt, Window* pWindow )
+{
+ const USHORT nCode = rKEvt.GetKeyCode().GetCode();
+ BOOL bForward = FALSE;
+ BOOL bRet = ( !rKEvt.GetKeyCode().IsMod1() &&
+ ( ( KEY_TAB == nCode ) || ( KEY_F6 == nCode && rKEvt.GetKeyCode().IsMod2() ) ) );
+
+ if( bRet )
+ {
+ if( !rKEvt.GetKeyCode().IsShift() )
+ {
+ if( mpBrowser1->mpThemes->HasChildPathFocus( TRUE ) )
+ mpBrowser2->GetViewWindow()->GrabFocus();
+ else if( mpBrowser2->GetViewWindow()->HasFocus() )
+// mpBrowser2->maViewBox.GrabFocus();
+// else if( mpBrowser2->maViewBox.HasFocus() )
+ mpBrowser1->maNewTheme.GrabFocus();
+ else
+ mpBrowser1->mpThemes->GrabFocus();
+ }
+ else
+ {
+ if( mpBrowser1->mpThemes->HasChildPathFocus( TRUE ) )
+ mpBrowser1->maNewTheme.GrabFocus();
+ else if( mpBrowser1->maNewTheme.HasFocus() )
+// mpBrowser2->maViewBox.GrabFocus();
+// else if( mpBrowser2->maViewBox.HasFocus() )
+ mpBrowser2->GetViewWindow()->GrabFocus();
+ else
+ mpBrowser1->mpThemes->GrabFocus();
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
BOOL GalleryBrowser::Close()
{
return SfxDockingWindow::Close();
diff --git a/svx/source/gallery2/galbrws1.cxx b/svx/source/gallery2/galbrws1.cxx
index 0e503d781238..4dd52878723c 100644
--- a/svx/source/gallery2/galbrws1.cxx
+++ b/svx/source/gallery2/galbrws1.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: galbrws1.cxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: ka $ $Date: 2001-10-31 17:04:45 $
+ * last change: $Author: ka $ $Date: 2002-02-07 15:41:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -75,6 +75,8 @@
#include <com/sun/star/util/DateTime.hpp>
#endif
+#include <algorithm>
+
// --------------
// - Namespaces -
// --------------
@@ -84,6 +86,29 @@ using namespace ::rtl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::ucb;
+// -----------------
+// - GalleryButton -
+// -----------------
+
+GalleryButton::GalleryButton( GalleryBrowser1* pParent, WinBits nWinBits ) :
+ PushButton( pParent, nWinBits )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+GalleryButton::~GalleryButton()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryButton::KeyInput( const KeyEvent& rKEvt )
+{
+ if( !static_cast< GalleryBrowser1* >( GetParent() )->KeyInput( rKEvt, this ) )
+ PushButton::KeyInput( rKEvt );
+}
+
// -----------------------
// - GalleryThemeListBox -
// -----------------------
@@ -103,17 +128,24 @@ GalleryThemeListBox::~GalleryThemeListBox()
long GalleryThemeListBox::PreNotify( NotifyEvent& rNEvt )
{
- long nRet = ListBox::PreNotify( rNEvt );
+ long nDone = 0;
if( rNEvt.GetType() == EVENT_COMMAND )
{
const CommandEvent* pCEvt = rNEvt.GetCommandEvent();
- if( pCEvt->GetCommand() == COMMAND_CONTEXTMENU )
- ( (GalleryBrowser1*) GetParent() )->ShowContextMenu();
+ if( pCEvt && pCEvt->GetCommand() == COMMAND_CONTEXTMENU )
+ static_cast< GalleryBrowser1* >( GetParent() )->ShowContextMenu();
}
+ else if( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
- return nRet;
+ if( pKEvt )
+ nDone = static_cast< GalleryBrowser1* >( GetParent() )->KeyInput( *pKEvt, this );
+ }
+
+ return( nDone ? nDone : ListBox::PreNotify( rNEvt ) );
}
// -------------------
@@ -240,94 +272,18 @@ void GalleryBrowser1::ImplFillExchangeData( const GalleryTheme* pThm, ExchangeDa
// -----------------------------------------------------------------------------
-void GalleryBrowser1::Resize()
-{
- Control::Resize();
- ImplAdjustControls();
-}
-
-// -----------------------------------------------------------------------------
-
-void GalleryBrowser1::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+::std::vector< USHORT > GalleryBrowser1::ImplGetExecuteVector()
{
- const GalleryHint& rGalleryHint = (const GalleryHint&) rHint;
-
- switch( rGalleryHint.GetType() )
- {
- case( GALLERY_HINT_THEME_CREATED ):
- ImplInsertThemeEntry( mpGallery->GetThemeInfo( rGalleryHint.GetThemeName() ) );
- break;
-
- case( GALLERY_HINT_THEME_RENAMED ):
- {
- const USHORT nCurSelectPos = mpThemes->GetSelectEntryPos();
- const USHORT nRenameEntryPos = mpThemes->GetEntryPos( rGalleryHint.GetThemeName() );
-
- mpThemes->RemoveEntry( rGalleryHint.GetThemeName() );
- ImplInsertThemeEntry( mpGallery->GetThemeInfo( rGalleryHint.GetStringData() ) );
-
- if( nCurSelectPos == nRenameEntryPos )
- {
- mpThemes->SelectEntry( rGalleryHint.GetStringData() );
- SelectThemeHdl( NULL );
- }
- }
- break;
-
- case( GALLERY_HINT_THEME_REMOVED ):
- {
- mpThemes->RemoveEntry( rGalleryHint.GetThemeName() );
- }
- break;
-
- case( GALLERY_HINT_CLOSE_THEME ):
- {
- const USHORT nCurSelectPos = mpThemes->GetSelectEntryPos();
- const USHORT nCloseEntryPos = mpThemes->GetEntryPos( rGalleryHint.GetThemeName() );
-
- if( nCurSelectPos == nCloseEntryPos )
- {
- if( nCurSelectPos < ( mpThemes->GetEntryCount() - 1 ) )
- mpThemes->SelectEntryPos( nCurSelectPos + 1 );
- else if( nCurSelectPos )
- mpThemes->SelectEntryPos( nCurSelectPos - 1 );
- else
- mpThemes->SetNoSelection();
-
- SelectThemeHdl( NULL );
- }
- }
- break;
-
- default:
- break;
- }
-}
-
-// -----------------------------------------------------------------------------
-
-void GalleryBrowser1::ShowContextMenu()
-{
- Application::PostUserEvent( LINK( this, GalleryBrowser1, ShowContextMenuHdl ), this );
-}
-
-// -----------------------------------------------------------------------------
-
-IMPL_LINK( GalleryBrowser1, ShowContextMenuHdl, void*, p )
-{
- GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this );
+ ::std::vector< USHORT > aExecVector;
+ GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this );
if( pTheme )
{
- PopupMenu aMenu( GAL_RESID( RID_SVXMN_GALLERY1 ) );
BOOL bUpdateAllowed, bRenameAllowed, bRemoveAllowed;
static const BOOL bIdDialog = ( getenv( "GALLERY_ENABLE_ID_DIALOG" ) != NULL );
-
if( pTheme->IsReadOnly() )
- {
bUpdateAllowed = bRenameAllowed = bRemoveAllowed = FALSE;
- }
else if( pTheme->IsImported() )
{
bUpdateAllowed = FALSE;
@@ -341,27 +297,30 @@ IMPL_LINK( GalleryBrowser1, ShowContextMenuHdl, void*, p )
else
bUpdateAllowed = bRenameAllowed = bRemoveAllowed = TRUE;
- aMenu.EnableItem( MN_ACTUALIZE, bUpdateAllowed && pTheme->GetObjectCount() );
- aMenu.EnableItem( MN_RENAME, bRenameAllowed );
- aMenu.EnableItem( MN_DELETE, bRemoveAllowed );
- aMenu.EnableItem( MN_ASSIGN_ID, bIdDialog && !pTheme->IsReadOnly() && !pTheme->IsImported() );
+ if( bUpdateAllowed && pTheme->GetObjectCount() )
+ aExecVector.push_back( MN_ACTUALIZE );
- mpGallery->ReleaseTheme( pTheme, *this );
+ if( bRenameAllowed )
+ aExecVector.push_back( MN_RENAME );
- aMenu.SetSelectHdl( LINK( this, GalleryBrowser1, PopupMenuHdl ) );
- aMenu.RemoveDisabledEntries();
- aMenu.Execute( this, GetPointerPosPixel() );
+ if( bRemoveAllowed )
+ aExecVector.push_back( MN_DELETE );
+
+ if( bIdDialog && !pTheme->IsReadOnly() && !pTheme->IsImported() )
+ aExecVector.push_back( MN_ASSIGN_ID );
+
+ aExecVector.push_back( MN_PROPERTIES );
+
+ mpGallery->ReleaseTheme( pTheme, *this );
}
- return 0L;
+ return aExecVector;
}
// -----------------------------------------------------------------------------
-IMPL_LINK( GalleryBrowser1, PopupMenuHdl, Menu*, pMenu )
+void GalleryBrowser1::ImplExecute( USHORT nId )
{
- const USHORT nId = pMenu->GetCurItemId();
-
switch( nId )
{
case( MN_ACTUALIZE ):
@@ -460,16 +419,165 @@ IMPL_LINK( GalleryBrowser1, PopupMenuHdl, Menu*, pMenu )
}
break;
}
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser1::Resize()
+{
+ Control::Resize();
+ ImplAdjustControls();
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser1::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ const GalleryHint& rGalleryHint = (const GalleryHint&) rHint;
+
+ switch( rGalleryHint.GetType() )
+ {
+ case( GALLERY_HINT_THEME_CREATED ):
+ ImplInsertThemeEntry( mpGallery->GetThemeInfo( rGalleryHint.GetThemeName() ) );
+ break;
+
+ case( GALLERY_HINT_THEME_RENAMED ):
+ {
+ const USHORT nCurSelectPos = mpThemes->GetSelectEntryPos();
+ const USHORT nRenameEntryPos = mpThemes->GetEntryPos( rGalleryHint.GetThemeName() );
+
+ mpThemes->RemoveEntry( rGalleryHint.GetThemeName() );
+ ImplInsertThemeEntry( mpGallery->GetThemeInfo( rGalleryHint.GetStringData() ) );
+
+ if( nCurSelectPos == nRenameEntryPos )
+ {
+ mpThemes->SelectEntry( rGalleryHint.GetStringData() );
+ SelectThemeHdl( NULL );
+ }
+ }
+ break;
+
+ case( GALLERY_HINT_THEME_REMOVED ):
+ {
+ mpThemes->RemoveEntry( rGalleryHint.GetThemeName() );
+ }
+ break;
+
+ case( GALLERY_HINT_CLOSE_THEME ):
+ {
+ const USHORT nCurSelectPos = mpThemes->GetSelectEntryPos();
+ const USHORT nCloseEntryPos = mpThemes->GetEntryPos( rGalleryHint.GetThemeName() );
+
+ if( nCurSelectPos == nCloseEntryPos )
+ {
+ if( nCurSelectPos < ( mpThemes->GetEntryCount() - 1 ) )
+ mpThemes->SelectEntryPos( nCurSelectPos + 1 );
+ else if( nCurSelectPos )
+ mpThemes->SelectEntryPos( nCurSelectPos - 1 );
+ else
+ mpThemes->SetNoSelection();
+
+ SelectThemeHdl( NULL );
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser1::ShowContextMenu()
+{
+ Application::PostUserEvent( LINK( this, GalleryBrowser1, ShowContextMenuHdl ), this );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryBrowser1::KeyInput( const KeyEvent& rKEvt, Window* pWindow )
+{
+ BOOL bRet = static_cast< GalleryBrowser* >( GetParent() )->KeyInput( rKEvt, pWindow );
+
+ if( !bRet )
+ {
+ ::std::vector< USHORT > aExecVector( ImplGetExecuteVector() );
+ USHORT nExecuteId = 0;
+
+ switch( rKEvt.GetKeyCode().GetCode() )
+ {
+ case( KEY_I ):
+ case( KEY_INSERT ):
+ {
+ ClickNewThemeHdl( NULL );
+ }
+ break;
+
+ case( KEY_U ):
+ nExecuteId = MN_ACTUALIZE;
+ break;
+
+ case( KEY_DELETE ):
+ case( KEY_D ):
+ nExecuteId = MN_DELETE;
+ break;
+
+ case( KEY_R ):
+ nExecuteId = MN_RENAME;
+ break;
+
+ case( KEY_RETURN ):
+ nExecuteId = rKEvt.GetKeyCode().IsMod1() ? MN_PROPERTIES : 0;
+ break;
+ }
+
+ if( nExecuteId && ( ::std::find( aExecVector.begin(), aExecVector.end(), nExecuteId ) != aExecVector.end() ) )
+ {
+ ImplExecute( nExecuteId );
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( GalleryBrowser1, ShowContextMenuHdl, void*, p )
+{
+ ::std::vector< USHORT > aExecVector( ImplGetExecuteVector() );
+
+ if( aExecVector.size() )
+ {
+ PopupMenu aMenu( GAL_RESID( RID_SVXMN_GALLERY1 ) );
+
+ aMenu.EnableItem( MN_ACTUALIZE, ::std::find( aExecVector.begin(), aExecVector.end(), MN_ACTUALIZE ) != aExecVector.end() );
+ aMenu.EnableItem( MN_RENAME, ::std::find( aExecVector.begin(), aExecVector.end(), MN_RENAME ) != aExecVector.end() );
+ aMenu.EnableItem( MN_DELETE, ::std::find( aExecVector.begin(), aExecVector.end(), MN_DELETE ) != aExecVector.end() );
+ aMenu.EnableItem( MN_ASSIGN_ID, ::std::find( aExecVector.begin(), aExecVector.end(), MN_ASSIGN_ID ) != aExecVector.end() );
+ aMenu.EnableItem( MN_PROPERTIES, ::std::find( aExecVector.begin(), aExecVector.end(), MN_PROPERTIES ) != aExecVector.end() );
+ aMenu.SetSelectHdl( LINK( this, GalleryBrowser1, PopupMenuHdl ) );
+ aMenu.RemoveDisabledEntries();
+ aMenu.Execute( this, GetPointerPosPixel() );
+ }
return 0L;
}
// -----------------------------------------------------------------------------
+IMPL_LINK( GalleryBrowser1, PopupMenuHdl, Menu*, pMenu )
+{
+ ImplExecute( pMenu->GetCurItemId() );
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+
IMPL_LINK( GalleryBrowser1, SelectThemeHdl, void*, p )
{
( (GalleryBrowser*) GetParent() )->ThemeSelectionHasChanged();
-
return 0L;
}
diff --git a/svx/source/gallery2/galbrws1.hxx b/svx/source/gallery2/galbrws1.hxx
index 44be9eb86188..1fafd0ea79c5 100644
--- a/svx/source/gallery2/galbrws1.hxx
+++ b/svx/source/gallery2/galbrws1.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: galbrws1.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: ka $ $Date: 2000-12-01 14:03:35 $
+ * last change: $Author: ka $ $Date: 2002-02-07 15:41:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,16 +62,32 @@
#include <vcl/lstbox.hxx>
#include <vcl/button.hxx>
#include <vcl/menu.hxx>
+#include <svtools/lstner.hxx>
+#include <vector>
#include "galbrws.hxx"
+// -----------------
+// - GalleryButton -
+// -----------------
+
+class GalleryButton : public PushButton
+{
+private:
+
+ virtual void KeyInput( const KeyEvent& rKEvt );
+
+public:
+
+ GalleryButton( GalleryBrowser1* pParent, WinBits nWinBits );
+ ~GalleryButton();
+};
+
// -----------------------
// - GalleryThemeListBox -
// -----------------------
class GalleryThemeListBox : public ListBox
{
-private:
-
protected:
virtual long PreNotify( NotifyEvent& rNEvt );
@@ -88,21 +104,25 @@ public:
class Gallery;
class GalleryThemeEntry;
+class GalleryTheme;
struct ExchangeData;
class GalleryBrowser1 : public Control, SfxListener
{
+ friend class GalleryBrowser;
friend class GalleryThemeListBox;
private:
- PushButton maNewTheme;
+ GalleryButton maNewTheme;
GalleryThemeListBox* mpThemes;
Gallery* mpGallery;
void ImplAdjustControls();
ULONG ImplInsertThemeEntry( const GalleryThemeEntry* pEntry );
void ImplFillExchangeData( const GalleryTheme* pThm, ExchangeData& rData );
+ ::std::vector< USHORT > ImplGetExecuteVector();
+ void ImplExecute( USHORT nId );
// Control
virtual void Resize();
@@ -125,4 +145,5 @@ public:
String GetSelectedTheme() { return mpThemes->GetEntryCount() ? mpThemes->GetEntry( mpThemes->GetSelectEntryPos() ) : String(); }
void ShowContextMenu();
+ BOOL KeyInput( const KeyEvent& rKEvt, Window* pWindow );
};
diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx
index 680ca765b139..93b01aeb962a 100644
--- a/svx/source/gallery2/galbrws2.cxx
+++ b/svx/source/gallery2/galbrws2.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: galbrws2.cxx,v $
*
- * $Revision: 1.26 $
+ * $Revision: 1.27 $
*
- * last change: $Author: ka $ $Date: 2001-10-25 10:32:00 $
+ * last change: $Author: ka $ $Date: 2002-02-07 15:41:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -296,6 +296,29 @@ void GalleryThemePopup::StateChanged( USHORT nSID, SfxItemState eState, const Sf
}
}
+// ------------------
+// - GalleryToolBox -
+// ------------------
+
+GalleryToolBox::GalleryToolBox( GalleryBrowser2* pParent ) :
+ ToolBox( pParent )
+{
+}
+
+// ------------------------------------------------------------------------
+
+GalleryToolBox::~GalleryToolBox()
+{
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryToolBox::KeyInput( const KeyEvent& rKEvt )
+{
+ if( !static_cast< GalleryBrowser2* >( GetParent() )->KeyInput( rKEvt, this ) )
+ ToolBox::KeyInput( rKEvt );
+}
+
// -------------------
// - GalleryBrowser2 -
// -------------------
@@ -503,6 +526,87 @@ void GalleryBrowser2::ShowContextMenu( Window* pWindow, const Point* pContextPoi
// -----------------------------------------------------------------------------
+BOOL GalleryBrowser2::KeyInput( const KeyEvent& rKEvt, Window* pWindow )
+{
+ const ULONG nItemId = ImplGetSelectedItemId( NULL );
+ BOOL bRet = static_cast< GalleryBrowser* >( GetParent() )->KeyInput( rKEvt, pWindow );
+
+ if( !bRet && nItemId && mpCurTheme )
+ {
+ USHORT nExecuteId = 0;
+ const SgaObjKind eObjKind = mpCurTheme->GetObjectKind( nItemId - 1 );
+ INetURLObject aURL;
+
+ const_cast< GalleryTheme* >( mpCurTheme )->GetURL( nItemId - 1, aURL );
+
+ const BOOL bValidURL = ( aURL.GetProtocol() != INET_PROT_NOT_VALID );
+ BOOL bPreview = bValidURL;
+ BOOL bAdd = ( bValidURL && SGA_OBJ_SOUND != eObjKind );
+ BOOL bAddLink = ( bValidURL && SGA_OBJ_SVDRAW != eObjKind && SGA_OBJ_SOUND != eObjKind );
+ BOOL bDelete = FALSE;
+ BOOL bTitle = FALSE;
+
+ if( !mpCurTheme->IsReadOnly() && mpCurTheme->GetObjectCount() )
+ {
+ bDelete = ( GALLERYBROWSERMODE_PREVIEW != GetMode() );
+ bTitle = TRUE;
+ }
+
+ switch( rKEvt.GetKeyCode().GetCode() )
+ {
+ case( KEY_SPACE ):
+ case( KEY_RETURN ):
+ case( KEY_P ):
+ {
+ if( bPreview )
+ {
+ TogglePreview( pWindow );
+ bRet = TRUE;
+ }
+ }
+ break;
+
+ case( KEY_INSERT ):
+ case( KEY_I ):
+ {
+ if( bAddLink && rKEvt.GetKeyCode().IsShift() && rKEvt.GetKeyCode().IsMod1() )
+ nExecuteId = MN_ADD_LINK;
+ else if( bAdd )
+ nExecuteId = MN_ADD;
+ }
+ break;
+
+ case( KEY_DELETE ):
+ case( KEY_D ):
+ {
+ if( bDelete )
+ nExecuteId = MN_DELETE;
+ }
+ break;
+
+ case( KEY_T ):
+ {
+ if( bTitle )
+ nExecuteId = MN_TITLE;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if( nExecuteId )
+ {
+ ImplExecute( nExecuteId );
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
void GalleryBrowser2::SelectTheme( const String& rThemeName )
{
delete mpIconView, mpIconView = NULL;
@@ -617,6 +721,73 @@ void GalleryBrowser2::SetMode( GalleryBrowserMode eMode )
// -----------------------------------------------------------------------------
+Window* GalleryBrowser2::GetViewWindow() const
+{
+ Window* pRet;
+
+ switch( GetMode() )
+ {
+ case( GALLERYBROWSERMODE_LIST ): pRet = mpListView; break;
+ case( GALLERYBROWSERMODE_PREVIEW ): pRet = mpPreview; break;
+
+ default:
+ pRet = mpIconView;
+ break;
+ }
+
+ return pRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser2::Travel( GalleryBrowserTravel eTravel )
+{
+ if( mpCurTheme )
+ {
+ const ULONG nItemId = ImplGetSelectedItemId( NULL );
+
+ if( nItemId )
+ {
+ ULONG nNewItemId = nItemId;
+
+ switch( eTravel )
+ {
+ case( GALLERYBROWSERTRAVEL_FIRST ): nNewItemId = 1; break;
+ case( GALLERYBROWSERTRAVEL_LAST ): nNewItemId = mpCurTheme->GetObjectCount(); break;
+ case( GALLERYBROWSERTRAVEL_PREVIOUS ): nNewItemId--; break;
+ case( GALLERYBROWSERTRAVEL_NEXT ): nNewItemId++; break;
+ }
+
+ if( nNewItemId < 1 )
+ nNewItemId = 1;
+ else if( nNewItemId > mpCurTheme->GetObjectCount() )
+ nNewItemId = mpCurTheme->GetObjectCount();
+
+ if( nNewItemId != nItemId )
+ {
+ ImplSelectItemId( nNewItemId );
+ ImplUpdateInfoBar();
+
+ if( GALLERYBROWSERMODE_PREVIEW == GetMode() )
+ {
+ Graphic aGraphic;
+ const ULONG nPos = nNewItemId - 1;
+
+ mpCurTheme->GetGraphic( nPos, aGraphic );
+ mpPreview->SetGraphic( aGraphic );
+
+ if( SGA_OBJ_SOUND == mpCurTheme->GetObjectKind( nPos ) )
+ mpPreview->PreviewSound( mpCurTheme->GetObjectURL( nPos ) );
+
+ mpPreview->Invalidate();
+ }
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
void GalleryBrowser2::ImplUpdateViews( USHORT nSelectionId )
{
mpIconView->Hide();
@@ -710,6 +881,128 @@ void GalleryBrowser2::ImplSelectItemId( ULONG nItemId )
// -----------------------------------------------------------------------------
+void GalleryBrowser2::ImplExecute( USHORT nId )
+{
+ const ULONG nItemId = ImplGetSelectedItemId( NULL );
+
+ if( mpCurTheme && nItemId )
+ {
+ mnCurActionPos = nItemId - 1;
+
+ switch( nId )
+ {
+ case( MN_ADD ):
+ case( MN_ADD_LINK ):
+ {
+ sal_uInt32 nFormat;
+
+ mbCurActionIsLinkage = ( MN_ADD_LINK == nId );
+
+ switch( mpCurTheme->GetObjectKind( mnCurActionPos ) )
+ {
+ case( SGA_OBJ_BMP ):
+ case( SGA_OBJ_ANIM ):
+ case( SGA_OBJ_INET ):
+ nFormat = SGA_FORMAT_GRAPHIC | SGA_FORMAT_STRING;
+ break;
+
+ case ( SGA_OBJ_SOUND ) :
+ nFormat = SGA_FORMAT_SOUND | SGA_FORMAT_STRING;
+ break;
+
+ case( SGA_OBJ_SVDRAW ):
+ nFormat = SGA_FORMAT_GRAPHIC | SGA_FORMAT_SVDRAW | SGA_FORMAT_STRING;
+ break;
+
+ default :
+ break;
+ }
+
+ const SfxUInt32Item aItem( SID_GALLERY_FORMATS, nFormat );
+ SfxViewFrame::Current()->GetBindings().GetDispatcher()->Execute(
+ SID_GALLERY_FORMATS, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
+ }
+ break;
+
+ case( MN_PREVIEW ):
+ SetMode( ( GALLERYBROWSERMODE_PREVIEW != GetMode() ) ? GALLERYBROWSERMODE_PREVIEW : meLastMode );
+ break;
+
+ case( MN_DELETE ):
+ {
+ if( !mpCurTheme->IsReadOnly() &&
+ QueryBox( NULL, WB_YES_NO, String( GAL_RESID( RID_SVXSTR_GALLERY_DELETEOBJ ) ) ).Execute() == RET_YES )
+ {
+ mpCurTheme->RemoveObject( mnCurActionPos );
+ }
+ }
+ break;
+
+ case( MN_TITLE ):
+ {
+ SgaObject* pObj = mpCurTheme->AcquireObject( mnCurActionPos );
+
+ if( pObj )
+ {
+ const String aOldTitle( GetItemText( *mpCurTheme, *pObj, GALLERY_ITEM_TITLE ) );
+ TitleDialog aDlg( this, aOldTitle );
+
+ if( aDlg.Execute() == RET_OK )
+ {
+ String aNewTitle( aDlg.GetTitle() );
+
+ if( ( !aNewTitle.Len() && pObj->GetTitle().Len() ) || ( aNewTitle != aOldTitle ) )
+ {
+ if( !aNewTitle.Len() )
+ aNewTitle = String( RTL_CONSTASCII_USTRINGPARAM( "__<empty>__" ) );
+
+ pObj->SetTitle( aNewTitle );
+ mpCurTheme->InsertObject( *pObj );
+ }
+ }
+
+ mpCurTheme->ReleaseObject( pObj );
+ }
+ }
+ break;
+
+ case( MN_COPYCLIPBOARD ):
+ {
+ Window* pWindow;
+
+ switch( GetMode() )
+ {
+ case( GALLERYBROWSERMODE_ICON ): pWindow = (Window*) mpIconView; break;
+ case( GALLERYBROWSERMODE_LIST ): pWindow = (Window*) mpListView; break;
+ case( GALLERYBROWSERMODE_PREVIEW ): pWindow = (Window*) mpPreview; break;
+
+ default:
+ pWindow = NULL;
+ break;
+ }
+
+ mpCurTheme->CopyToClipboard( pWindow, mnCurActionPos );
+ }
+ break;
+
+ case( MN_PASTECLIPBOARD ):
+ {
+ if( !mpCurTheme->IsReadOnly() )
+ {
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( this ) );
+ mpCurTheme->InsertTransferable( aDataHelper.GetTransferable(), mnCurActionPos );
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
String GalleryBrowser2::GetItemText( const GalleryTheme& rTheme, const SgaObject& rObj, ULONG nItemTextFlags )
{
INetURLObject aURL;
@@ -835,125 +1128,7 @@ BOOL GalleryBrowser2::IsLinkage() const
IMPL_LINK( GalleryBrowser2, MenuSelectHdl, Menu*, pMenu )
{
if( pMenu )
- {
- const USHORT nId = pMenu->GetCurItemId();
- const ULONG nItemId = ImplGetSelectedItemId( NULL );
-
- if( mpCurTheme && nItemId )
- {
- mnCurActionPos = nItemId - 1;
-
- switch( nId )
- {
- case( MN_ADD ):
- case( MN_ADD_LINK ):
- {
- sal_uInt32 nFormat;
-
- mbCurActionIsLinkage = ( MN_ADD_LINK == nId );
-
- switch( mpCurTheme->GetObjectKind( mnCurActionPos ) )
- {
- case( SGA_OBJ_BMP ):
- case( SGA_OBJ_ANIM ):
- case( SGA_OBJ_INET ):
- nFormat = SGA_FORMAT_GRAPHIC | SGA_FORMAT_STRING;
- break;
-
- case ( SGA_OBJ_SOUND ) :
- nFormat = SGA_FORMAT_SOUND | SGA_FORMAT_STRING;
- break;
-
- case( SGA_OBJ_SVDRAW ):
- nFormat = SGA_FORMAT_GRAPHIC | SGA_FORMAT_SVDRAW | SGA_FORMAT_STRING;
- break;
-
- default :
- break;
- }
-
- const SfxUInt32Item aItem( SID_GALLERY_FORMATS, nFormat );
- SfxViewFrame::Current()->GetBindings().GetDispatcher()->Execute(
- SID_GALLERY_FORMATS, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
- }
- break;
-
- case( MN_PREVIEW ):
- SetMode( ( GALLERYBROWSERMODE_PREVIEW != GetMode() ) ? GALLERYBROWSERMODE_PREVIEW : meLastMode );
- break;
-
- case( MN_DELETE ):
- {
- if( !mpCurTheme->IsReadOnly() &&
- QueryBox( NULL, WB_YES_NO, String( GAL_RESID( RID_SVXSTR_GALLERY_DELETEOBJ ) ) ).Execute() == RET_YES )
- {
- mpCurTheme->RemoveObject( mnCurActionPos );
- }
- }
- break;
-
- case( MN_TITLE ):
- {
- SgaObject* pObj = mpCurTheme->AcquireObject( mnCurActionPos );
-
- if( pObj )
- {
- const String aOldTitle( GetItemText( *mpCurTheme, *pObj, GALLERY_ITEM_TITLE ) );
- TitleDialog aDlg( this, aOldTitle );
-
- if( aDlg.Execute() == RET_OK )
- {
- String aNewTitle( aDlg.GetTitle() );
-
- if( ( !aNewTitle.Len() && pObj->GetTitle().Len() ) || ( aNewTitle != aOldTitle ) )
- {
- if( !aNewTitle.Len() )
- aNewTitle = String( RTL_CONSTASCII_USTRINGPARAM( "__<empty>__" ) );
-
- pObj->SetTitle( aNewTitle );
- mpCurTheme->InsertObject( *pObj );
- }
- }
-
- mpCurTheme->ReleaseObject( pObj );
- }
- }
- break;
-
- case( MN_COPYCLIPBOARD ):
- {
- Window* pWindow;
-
- switch( GetMode() )
- {
- case( GALLERYBROWSERMODE_ICON ): pWindow = (Window*) mpIconView; break;
- case( GALLERYBROWSERMODE_LIST ): pWindow = (Window*) mpListView; break;
- case( GALLERYBROWSERMODE_PREVIEW ): pWindow = (Window*) mpPreview; break;
-
- default:
- pWindow = NULL;
- break;
- }
-
- mpCurTheme->CopyToClipboard( pWindow, mnCurActionPos );
- }
- break;
-
- case( MN_PASTECLIPBOARD ):
- {
- if( !mpCurTheme->IsReadOnly() )
- {
- TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( this ) );
- mpCurTheme->InsertTransferable( aDataHelper.GetTransferable(), mnCurActionPos );
- }
- }
- break;
-
- default:
- break;
- }
- }
- }
+ ImplExecute( pMenu->GetCurItemId() );
return 0;
}