summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-04-14 14:33:10 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-04-14 14:34:08 +0100
commitc908096d9e0ffd9c869bb6431f15b5ac15280b35 (patch)
tree7cb9558c3523ae4fcafb1cdd8bf6b7d8aaba9bd0 /svx
parentcf8c82e1abd1961dcb88446acb84e70ca94819cf (diff)
convert gallery menu to .ui
Change-Id: I69b7b9d06d01c205dc1906578d590c17c4eab460
Diffstat (limited to 'svx')
-rw-r--r--svx/UIConfig_svx.mk1
-rw-r--r--svx/inc/galbrws2.hxx2
-rw-r--r--svx/inc/gallery.hrc5
-rw-r--r--svx/inc/helpid.hrc3
-rw-r--r--svx/source/gallery2/galbrws2.cxx163
-rw-r--r--svx/source/gallery2/gallery.src65
-rw-r--r--svx/uiconfig/ui/gallerymenu2.ui65
7 files changed, 120 insertions, 184 deletions
diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk
index b210e4b4a358..ce4e14e9b62d 100644
--- a/svx/UIConfig_svx.mk
+++ b/svx/UIConfig_svx.mk
@@ -43,6 +43,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\
svx/uiconfig/ui/fontworkgallerydialog \
svx/uiconfig/ui/fontworkspacingdialog \
svx/uiconfig/ui/formlinkwarndialog \
+ svx/uiconfig/ui/gallerymenu2 \
svx/uiconfig/ui/headfootformatpage \
svx/uiconfig/ui/imapdialog \
svx/uiconfig/ui/imapmenu \
diff --git a/svx/inc/galbrws2.hxx b/svx/inc/galbrws2.hxx
index 3db2b5a37203..a68e1d329cdf 100644
--- a/svx/inc/galbrws2.hxx
+++ b/svx/inc/galbrws2.hxx
@@ -162,7 +162,7 @@ public:
static css::uno::Reference< css::frame::XFrame > GetFrame();
const css::uno::Reference< css::util::XURLTransformer >& GetURLTransformer() const { return m_xTransformer; }
- void Execute( sal_uInt16 nId );
+ void Execute(const OString &rIdent);
void Dispatch( sal_uInt16 nId,
const css::uno::Reference< css::frame::XDispatch > &rxDispatch,
const css::util::URL &rURL );
diff --git a/svx/inc/gallery.hrc b/svx/inc/gallery.hrc
index 61b6df4bcb5f..1c1f0fd3b1a8 100644
--- a/svx/inc/gallery.hrc
+++ b/svx/inc/gallery.hrc
@@ -33,7 +33,6 @@
// Controls for Gallery
#define RID_SVXMN_GALLERY1 (RID_SVX_GALLERY_START + 36)
-#define RID_SVXMN_GALLERY2 (RID_SVX_GALLERY_START + 37)
// Images
#define RID_SVXBMP_THEME_NORMAL (RID_SVX_GALLERY_START + 48)
@@ -56,10 +55,6 @@
#define MN_ADD 6
#define MN_PREVIEW 10
#define MN_DELETE 12
-#define MN_BACKGROUND 14
-#define MN_TITLE 15
-#define MN_COPYCLIPBOARD 16
-#define MN_PASTECLIPBOARD 17
#define MN_ACTUALIZE 21
#define MN_RENAME 22
diff --git a/svx/inc/helpid.hrc b/svx/inc/helpid.hrc
index 1844d102e9bb..3ba81a7a2706 100644
--- a/svx/inc/helpid.hrc
+++ b/svx/inc/helpid.hrc
@@ -35,10 +35,7 @@
#define HID_GALLERY_ICONVIEW "SVX_HID_GALLERY_ICONVIEW"
#define HID_GALLERY_LISTVIEW "SVX_HID_GALLERY_LISTVIEW"
#define HID_GALLERY_MN_ADD "SVX_HID_GALLERY_MN_ADD"
-#define HID_GALLERY_MN_BACKGROUND "SVX_HID_GALLERY_MN_BACKGROUND"
-#define HID_GALLERY_MN_COPYCLIPBOARD "SVX_HID_GALLERY_MN_COPYCLIPBOARD"
#define HID_GALLERY_MN_DELETE "SVX_HID_GALLERY_MN_DELETE"
-#define HID_GALLERY_MN_PASTECLIPBOARD "SVX_HID_GALLERY_MN_PASTECLIPBOARD"
#define HID_GALLERY_MN_PREVIEW "SVX_HID_GALLERY_MN_PREVIEW"
#define HID_GALLERY_NEWTHEME "SVX_HID_GALLERY_NEWTHEME"
#define HID_GALLERY_PROPERTIES "SVX_HID_GALLERY_PROPERTIES"
diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx
index 2f3927b5f6cd..1701ffcf0dd6 100644
--- a/svx/source/gallery2/galbrws2.cxx
+++ b/svx/source/gallery2/galbrws2.cxx
@@ -112,7 +112,8 @@ private:
const GalleryTheme* mpTheme;
sal_uIntPtr mnObjectPos;
bool mbPreview;
- ScopedVclPtr<PopupMenu> mpPopupMenu;
+ VclBuilder maBuilder;
+ VclPtr<PopupMenu> mpPopupMenu;
VclPtr<PopupMenu> mpBackgroundPopup;
VclPtr<GalleryBrowser2> mpBrowser;
@@ -145,11 +146,12 @@ GalleryThemePopup::GalleryThemePopup(
: mpTheme( pTheme )
, mnObjectPos( nObjectPos )
, mbPreview( bPreview )
- , mpPopupMenu( VclPtr<PopupMenu>::Create(GAL_RES( RID_SVXMN_GALLERY2 )) )
+ , maBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "svx/ui/gallerymenu2.ui", "")
+ , mpPopupMenu(maBuilder.get_menu("menu"))
, mpBackgroundPopup( VclPtr<PopupMenu>::Create() )
, mpBrowser( pBrowser )
{
- mpPopupMenu->SetPopupMenu( MN_BACKGROUND, mpBackgroundPopup );
+ mpPopupMenu->SetPopupMenu(mpPopupMenu->GetItemId("background"), mpBackgroundPopup);
// SID_GALLERY_ENABLE_ADDCOPY
m_aCommandInfo.insert(
@@ -177,7 +179,7 @@ void SAL_CALL GalleryThemePopup::statusChanged(
{
if ( !rEvent.IsEnabled )
{
- mpPopupMenu->EnableItem( MN_ADD, false );
+ mpPopupMenu->EnableItem(mpPopupMenu->GetItemId("add"), false);
}
}
else if ( rURL == CMD_SID_GALLERY_BG_BRUSH )
@@ -236,34 +238,22 @@ void GalleryThemePopup::ExecutePopup( vcl::Window *pWindow, const ::Point &aPos
const_cast< GalleryTheme* >( mpTheme )->GetURL( mnObjectPos, aURL );
const bool bValidURL = ( aURL.GetProtocol() != INetProtocol::NotValid );
- mpPopupMenu->EnableItem( MN_ADD, bValidURL && SgaObjKind::Sound != eObjKind );
+ mpPopupMenu->EnableItem(mpPopupMenu->GetItemId("add"), bValidURL && SgaObjKind::Sound != eObjKind);
- mpPopupMenu->EnableItem( MN_PREVIEW, bValidURL );
-
- mpPopupMenu->CheckItem( MN_PREVIEW, mbPreview );
+ mpPopupMenu->EnableItem(mpPopupMenu->GetItemId("preview"), bValidURL);
+ mpPopupMenu->CheckItem(mpPopupMenu->GetItemId("preview"), mbPreview);
if( mpTheme->IsReadOnly() || !mpTheme->GetObjectCount() )
{
- mpPopupMenu->EnableItem( MN_DELETE, false );
- mpPopupMenu->EnableItem( MN_TITLE, false );
-
- if( mpTheme->IsReadOnly() )
- mpPopupMenu->EnableItem( MN_PASTECLIPBOARD, false );
-
- if( !mpTheme->GetObjectCount() )
- mpPopupMenu->EnableItem( MN_COPYCLIPBOARD, false );
+ mpPopupMenu->EnableItem(mpPopupMenu->GetItemId("delete"), false);
+ mpPopupMenu->EnableItem(mpPopupMenu->GetItemId("title"), false);
}
else
{
- mpPopupMenu->EnableItem( MN_DELETE, !mbPreview );
- mpPopupMenu->EnableItem( MN_TITLE );
- mpPopupMenu->EnableItem( MN_COPYCLIPBOARD );
- mpPopupMenu->EnableItem( MN_PASTECLIPBOARD );
+ mpPopupMenu->EnableItem(mpPopupMenu->GetItemId("delete"), !mbPreview);
+ mpPopupMenu->EnableItem(mpPopupMenu->GetItemId("title"));
}
- mpPopupMenu->EnableItem( MN_COPYCLIPBOARD, false );
- mpPopupMenu->EnableItem( MN_PASTECLIPBOARD, false );
-
// update status
css::uno::Reference< css::frame::XDispatchProvider> xDispatchProvider(
GalleryBrowser2::GetFrame(), css::uno::UNO_QUERY );
@@ -298,10 +288,10 @@ void GalleryThemePopup::ExecutePopup( vcl::Window *pWindow, const ::Point &aPos
}
if( !mpBackgroundPopup->GetItemCount() || ( eObjKind == SgaObjKind::SvDraw ) || ( eObjKind == SgaObjKind::Sound ) )
- mpPopupMenu->EnableItem( MN_BACKGROUND, false );
+ mpPopupMenu->EnableItem(mpPopupMenu->GetItemId("background"), false);
else
{
- mpPopupMenu->EnableItem( MN_BACKGROUND );
+ mpPopupMenu->EnableItem(mpPopupMenu->GetItemId("background"));
mpBackgroundPopup->SetSelectHdl( LINK( this, GalleryThemePopup, BackgroundMenuSelectHdl ) );
}
@@ -316,22 +306,15 @@ IMPL_LINK( GalleryThemePopup, MenuSelectHdl, Menu*, pMenu, bool )
if( !pMenu )
return false;
- sal_uInt16 nId( pMenu->GetCurItemId() );
- switch ( nId )
+ OString sIdent(pMenu->GetCurItemIdent());
+ if (sIdent == "add")
{
- case MN_ADD:
- {
- const CommandInfoMap::const_iterator it = m_aCommandInfo.find( SID_GALLERY_FORMATS );
- if ( it != m_aCommandInfo.end() )
- mpBrowser->Dispatch( nId,
- it->second.Dispatch,
- it->second.URL );
- }
- break;
-
- default:
- mpBrowser->Execute( nId );
+ const CommandInfoMap::const_iterator it = m_aCommandInfo.find( SID_GALLERY_FORMATS );
+ if (it != m_aCommandInfo.end())
+ mpBrowser->Dispatch(MN_ADD, it->second.Dispatch, it->second.URL);
}
+ else
+ mpBrowser->Execute(sIdent);
return false;
}
@@ -636,7 +619,7 @@ bool GalleryBrowser2::KeyInput( const KeyEvent& rKEvt, vcl::Window* pWindow )
if( !bRet && !maViewBox->HasFocus() && nItemId && mpCurTheme )
{
- sal_uInt16 nExecuteId = 0;
+ OString sExecuteIdent;
INetURLObject aURL;
mpCurTheme->GetURL( nItemId - 1, aURL );
@@ -682,14 +665,14 @@ bool GalleryBrowser2::KeyInput( const KeyEvent& rKEvt, vcl::Window* pWindow )
case KEY_D:
{
if( bDelete )
- nExecuteId = MN_DELETE;
+ sExecuteIdent = "delete";
}
break;
case KEY_T:
{
if( bTitle )
- nExecuteId = MN_TITLE;
+ sExecuteIdent = "title";
}
break;
@@ -697,9 +680,9 @@ bool GalleryBrowser2::KeyInput( const KeyEvent& rKEvt, vcl::Window* pWindow )
break;
}
- if( nExecuteId )
+ if (!sExecuteIdent.isEmpty())
{
- Execute( nExecuteId );
+ Execute(sExecuteIdent);
bRet = true;
}
}
@@ -1109,7 +1092,7 @@ void GalleryBrowser2::Dispatch(
}
}
-void GalleryBrowser2::Execute( sal_uInt16 nId )
+void GalleryBrowser2::Execute(const OString &rIdent)
{
Point aSelPos;
const sal_uIntPtr nItemId = ImplGetSelectedItemId( nullptr, aSelPos );
@@ -1118,86 +1101,46 @@ void GalleryBrowser2::Execute( sal_uInt16 nId )
{
mnCurActionPos = nItemId - 1;
- switch( nId )
+ if (rIdent == "preview")
+ SetMode( ( GALLERYBROWSERMODE_PREVIEW != GetMode() ) ? GALLERYBROWSERMODE_PREVIEW : meLastMode );
+ else if (rIdent == "delete")
{
- case MN_PREVIEW:
- SetMode( ( GALLERYBROWSERMODE_PREVIEW != GetMode() ) ? GALLERYBROWSERMODE_PREVIEW : meLastMode );
- break;
-
- case MN_DELETE:
+ if( !mpCurTheme->IsReadOnly() &&
+ ScopedVclPtrInstance<MessageDialog>(nullptr, "QueryDeleteObjectDialog","svx/ui/querydeleteobjectdialog.ui")->Execute() == RET_YES )
{
- if( !mpCurTheme->IsReadOnly() &&
- ScopedVclPtrInstance<MessageDialog>(nullptr, "QueryDeleteObjectDialog","svx/ui/querydeleteobjectdialog.ui")->Execute() == RET_YES )
- {
- mpCurTheme->RemoveObject( mnCurActionPos );
- }
+ mpCurTheme->RemoveObject( mnCurActionPos );
}
- break;
+ }
+ else if (rIdent == "title")
+ {
+ SgaObject* pObj = mpCurTheme->AcquireObject( mnCurActionPos );
- case MN_TITLE:
+ if( pObj )
{
- SgaObject* pObj = mpCurTheme->AcquireObject( mnCurActionPos );
+ const OUString aOldTitle( GetItemText( *mpCurTheme, *pObj, GalleryItemFlags::Title ) );
- if( pObj )
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
{
- const OUString aOldTitle( GetItemText( *mpCurTheme, *pObj, GalleryItemFlags::Title ) );
-
- SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- if(pFact)
+ ScopedVclPtr<AbstractTitleDialog> aDlg(pFact->CreateTitleDialog( this, aOldTitle ));
+ DBG_ASSERT(aDlg, "Dialog creation failed!");
+ if( aDlg->Execute() == RET_OK )
{
- ScopedVclPtr<AbstractTitleDialog> aDlg(pFact->CreateTitleDialog( this, aOldTitle ));
- DBG_ASSERT(aDlg, "Dialog creation failed!");
- if( aDlg->Execute() == RET_OK )
- {
- OUString aNewTitle( aDlg->GetTitle() );
+ OUString aNewTitle( aDlg->GetTitle() );
- if( ( aNewTitle.isEmpty() && !pObj->GetTitle().isEmpty() ) || ( aNewTitle != aOldTitle ) )
- {
- if( aNewTitle.isEmpty() )
- aNewTitle = "__<empty>__";
+ if( ( aNewTitle.isEmpty() && !pObj->GetTitle().isEmpty() ) || ( aNewTitle != aOldTitle ) )
+ {
+ if( aNewTitle.isEmpty() )
+ aNewTitle = "__<empty>__";
- pObj->SetTitle( aNewTitle );
- mpCurTheme->InsertObject( *pObj );
- }
+ pObj->SetTitle( aNewTitle );
+ mpCurTheme->InsertObject( *pObj );
}
-
- GalleryTheme::ReleaseObject( pObj );
}
- }
- }
- break;
-
- case MN_COPYCLIPBOARD:
- {
- vcl::Window* pWindow;
-
- switch( GetMode() )
- {
- case GALLERYBROWSERMODE_ICON: pWindow = static_cast<vcl::Window*>(mpIconView); break;
- case GALLERYBROWSERMODE_LIST: pWindow = static_cast<vcl::Window*>(mpListView); break;
- case GALLERYBROWSERMODE_PREVIEW: pWindow = static_cast<vcl::Window*>(mpPreview); break;
-
- default:
- pWindow = nullptr;
- break;
- }
- mpCurTheme->CopyToClipboard( pWindow, mnCurActionPos );
- }
- break;
-
- case MN_PASTECLIPBOARD:
- {
- if( !mpCurTheme->IsReadOnly() )
- {
- TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( this ) );
- mpCurTheme->InsertTransferable( aDataHelper.GetTransferable(), mnCurActionPos );
+ GalleryTheme::ReleaseObject( pObj );
}
}
- break;
-
- default:
- break;
}
}
}
diff --git a/svx/source/gallery2/gallery.src b/svx/source/gallery2/gallery.src
index cf9bb15bf136..cde9bc433a6e 100644
--- a/svx/source/gallery2/gallery.src
+++ b/svx/source/gallery2/gallery.src
@@ -159,69 +159,4 @@ Menu RID_SVXMN_GALLERY1
};
};
-Menu RID_SVXMN_GALLERY2
-{
- ItemList =
- {
- MenuItem
- {
- Identifier = MN_ADD ;
- HelpId = HID_GALLERY_MN_ADD ;
- Text [ en-US ] = "~Insert" ;
- };
- MenuItem
- {
- Identifier = MN_BACKGROUND ;
- HelpId = HID_GALLERY_MN_BACKGROUND ;
- Text [ en-US ] = "Insert as Bac~kground" ;
- };
- MenuItem
- {
- Separator = TRUE ;
- };
- MenuItem
- {
- Identifier = MN_PREVIEW ;
- HelpId = HID_GALLERY_MN_PREVIEW ;
- Text [ en-US ] = "~Preview" ;
- };
- MenuItem
- {
- Separator = TRUE ;
- };
- MenuItem
- {
- Identifier = MN_TITLE ;
- HelpId = HID_GALLERY_TITLE;
- Text [ en-US ] = "~Title" ;
- };
- MenuItem
- {
- Separator = TRUE ;
- };
- MenuItem
- {
- Identifier = MN_DELETE ;
- HelpId = HID_GALLERY_MN_DELETE ;
- Text [ en-US ] = "~Delete" ;
- };
- MenuItem
- {
- Separator = TRUE ;
- };
- MenuItem
- {
- Identifier = MN_COPYCLIPBOARD;
- HelpId = HID_GALLERY_MN_COPYCLIPBOARD;
- Text [ en-US ] = "~Copy" ;
- };
- MenuItem
- {
- Identifier = MN_PASTECLIPBOARD;
- HelpId = HID_GALLERY_MN_PASTECLIPBOARD;
- Text [ en-US ] = "~Insert" ;
- };
- };
-};
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/uiconfig/ui/gallerymenu2.ui b/svx/uiconfig/ui/gallerymenu2.ui
new file mode 100644
index 000000000000..3fda767be80b
--- /dev/null
+++ b/svx/uiconfig/ui/gallerymenu2.ui
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.0 -->
+<interface>
+ <requires lib="gtk+" version="3.10"/>
+ <object class="GtkMenu" id="menu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuItem" id="add">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Insert</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="background">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Insert as Bac_kground</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparatorMenuItem" id="menuitem1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkCheckMenuItem" id="preview">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Preview</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparatorMenuItem" id="menuitem2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="title">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Title</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparatorMenuItem" id="menuitem3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="delete">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Delete</property>
+ </object>
+ </child>
+ </object>
+</interface>