dbaccess/UIConfig_dbapp.mk | 1 dbaccess/source/ui/app/AppController.cxx | 7 dbaccess/source/ui/app/AppController.hxx | 1 dbaccess/source/ui/app/app.src | 130 ---------- dbaccess/source/ui/browser/unodatbr.cxx | 5 dbaccess/source/ui/control/dbtreelistbox.cxx | 69 ++++- dbaccess/source/ui/inc/callbacks.hxx | 8 dbaccess/source/ui/inc/dbtreelistbox.hxx | 6 dbaccess/source/ui/inc/dbu_resource.hrc | 1 dbaccess/source/ui/inc/unodatbr.hxx | 1 dbaccess/uiconfig/dbapp/popupmenu/edit.xml | 34 ++ officecfg/registry/data/org/openoffice/Office/UI/BaseWindowState.xcu | 5 officecfg/registry/data/org/openoffice/Office/UI/DbuCommands.xcu | 8 13 files changed, 129 insertions(+), 147 deletions(-)
New commits: commit 17b1ebbf86ceabe2e9cabf9626ca94fae3fb9216 Author: Maxim Monastirsky <momonas...@gmail.com> Date: Sun Oct 30 19:28:52 2016 +0200 Allow using xml menus in DBTreeListBox Change-Id: I8dfab0ae5d64b416123ab5690b43cf2db77d92dc diff --git a/dbaccess/source/ui/control/dbtreelistbox.cxx b/dbaccess/source/ui/control/dbtreelistbox.cxx index 6c0562a..2f6e2c7 100644 --- a/dbaccess/source/ui/control/dbtreelistbox.cxx +++ b/dbaccess/source/ui/control/dbtreelistbox.cxx @@ -30,10 +30,13 @@ #include <com/sun/star/util/URL.hpp> #include <cppuhelper/implbase.hxx> #include <comphelper/interfacecontainer2.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <vcl/help.hxx> #include <vcl/commandinfoprovider.hxx> #include <dbaccess/IController.hxx> #include <framework/actiontriggerhelper.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <vcl/svapp.hxx> #include "svtools/treelistentry.hxx" @@ -83,6 +86,7 @@ void DBTreeListBox::init() DBTreeListBox::~DBTreeListBox() { + assert(!m_xMenuController.is()); disposeOnce(); } @@ -555,12 +559,41 @@ VclPtr<PopupMenu> DBTreeListBox::CreateContextMenu() if ( !m_pContextMenuProvider ) return pContextMenu; - // the basic context menu - pContextMenu.reset( m_pContextMenuProvider->getContextMenu( *this ) ); - // disable what is not available currently - lcl_enableEntries( pContextMenu.get(), m_pContextMenuProvider->getCommandController() ); - // set images - lcl_insertMenuItemImages( *pContextMenu, m_pContextMenuProvider->getCommandController() ); + OUString aResourceName( m_pContextMenuProvider->getContextMenuResourceName( *this ) ); + OUString aMenuIdentifier; + + if ( aResourceName.isEmpty() ) + { + // the basic context menu + pContextMenu.reset( m_pContextMenuProvider->getContextMenu( *this ) ); + // disable what is not available currently + lcl_enableEntries( pContextMenu.get(), m_pContextMenuProvider->getCommandController() ); + // set images + lcl_insertMenuItemImages( *pContextMenu, m_pContextMenuProvider->getCommandController() ); + } + else + { + css::uno::Sequence< css::uno::Any > aArgs( 3 ); + aArgs[0] <<= comphelper::makePropertyValue( "Value", aResourceName ); + aArgs[1] <<= comphelper::makePropertyValue( "Frame", m_pContextMenuProvider->getCommandController().getXController()->getFrame() ); + aArgs[2] <<= comphelper::makePropertyValue( "IsContextMenu", true ); + + css::uno::Reference< css::uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); + m_xMenuController.set( xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + "com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext ), css::uno::UNO_QUERY ); + + css::uno::Reference< css::awt::XPopupMenu > xPopupMenu( xContext->getServiceManager()->createInstanceWithContext( + "com.sun.star.awt.PopupMenu", xContext ), css::uno::UNO_QUERY ); + + if ( !m_xMenuController.is() || !xPopupMenu.is() ) + return pContextMenu; + + m_xMenuController->setPopupMenu( xPopupMenu ); + pContextMenu.reset( static_cast< PopupMenu* >( VCLXMenu::GetImplementation( xPopupMenu )->GetMenu() ) ); + pContextMenu->AddEventListener( LINK( this, DBTreeListBox, MenuEventListener ) ); + aMenuIdentifier = "private:resource/popupmenu/" + aResourceName; + } + // allow context menu interception ::comphelper::OInterfaceContainerHelper2* pInterceptors = m_pContextMenuProvider->getContextMenuInterceptors(); if ( !pInterceptors || !pInterceptors->getLength() ) @@ -571,7 +604,7 @@ VclPtr<PopupMenu> DBTreeListBox::CreateContextMenu() aEvent.ExecutePosition.X = -1; aEvent.ExecutePosition.Y = -1; aEvent.ActionTriggerContainer = ::framework::ActionTriggerHelper::CreateActionTriggerContainerFromMenu( - pContextMenu.get(), nullptr ); + pContextMenu.get(), &aMenuIdentifier ); aEvent.Selection = new SelectionSupplier( m_pContextMenuProvider->getCurrentSelection( *this ) ); ::comphelper::OInterfaceIteratorHelper2 aIter( *pInterceptors ); @@ -617,16 +650,15 @@ VclPtr<PopupMenu> DBTreeListBox::CreateContextMenu() if ( bModifiedMenu ) { - // the interceptor(s) modified the menu description => create a new PopupMenu - VclPtrInstance<PopupMenu> pModifiedMenu; + pContextMenu->Clear(); ::framework::ActionTriggerHelper::CreateMenuFromActionTriggerContainer( - pModifiedMenu, aEvent.ActionTriggerContainer ); + pContextMenu, aEvent.ActionTriggerContainer ); aEvent.ActionTriggerContainer.clear(); - pContextMenu.reset( pModifiedMenu ); // the interceptors only know command URLs, but our menus primarily work // with IDs -> we need to translate the commands to IDs - lcl_adjustMenuItemIDs( *pModifiedMenu, m_pContextMenuProvider->getCommandController() ); + if ( aResourceName.isEmpty() ) + lcl_adjustMenuItemIDs( *pContextMenu, m_pContextMenuProvider->getCommandController() ); } return pContextMenu; @@ -634,10 +666,21 @@ VclPtr<PopupMenu> DBTreeListBox::CreateContextMenu() void DBTreeListBox::ExecuteContextMenuAction( sal_uInt16 _nSelectedPopupEntry ) { - if ( m_pContextMenuProvider && _nSelectedPopupEntry ) + if ( !m_xMenuController.is() && m_pContextMenuProvider && _nSelectedPopupEntry ) m_pContextMenuProvider->getCommandController().executeChecked( _nSelectedPopupEntry, Sequence< PropertyValue >() ); } +IMPL_LINK( DBTreeListBox, MenuEventListener, VclMenuEvent&, rMenuEvent, void ) +{ + if ( rMenuEvent.GetId() == VCLEVENT_OBJECT_DYING ) + { + css::uno::Reference< css::lang::XComponent > xComponent( m_xMenuController, css::uno::UNO_QUERY ); + if ( xComponent.is() ) + xComponent->dispose(); + m_xMenuController.clear(); + } +} + IMPL_LINK_NOARG(DBTreeListBox, OnTimeOut, Timer*, void) { implStopSelectionTimer(); diff --git a/dbaccess/source/ui/inc/dbtreelistbox.hxx b/dbaccess/source/ui/inc/dbtreelistbox.hxx index 4c091db..2c7aeb9 100644 --- a/dbaccess/source/ui/inc/dbtreelistbox.hxx +++ b/dbaccess/source/ui/inc/dbtreelistbox.hxx @@ -22,6 +22,7 @@ #include "ScrollHelper.hxx" #include "moduledbu.hxx" +#include <com/sun/star/frame/XPopupMenuController.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <svtools/treelistbox.hxx> @@ -58,8 +59,8 @@ namespace dbaui std::set<SvTreeListEntry*> m_aSelectedEntries; SvTreeListEntry* m_pDragedEntry; IControlActionListener* m_pActionListener; - IContextMenuProvider* - m_pContextMenuProvider; + IContextMenuProvider* m_pContextMenuProvider; + css::uno::Reference<css::frame::XPopupMenuController> m_xMenuController; Link<SvTreeListEntry*,bool> m_aPreExpandHandler; // handler to be called before a node is expanded Link<LinkParamNone*,void> m_aSelChangeHdl; // handler to be called (asynchronously) when the selection changes in any way @@ -74,6 +75,7 @@ namespace dbaui DECL_LINK( OnResetEntry, void*, void ); DECL_LINK( ScrollUpHdl, LinkParamNone*, void ); DECL_LINK( ScrollDownHdl, LinkParamNone*, void ); + DECL_LINK( MenuEventListener, VclMenuEvent&, void ); public: DBTreeListBox( vcl::Window* pParent, WinBits nWinStyle=0); commit 96febd383cf2b72e66f18ea2b7a8be09a102080b Author: Maxim Monastirsky <momonas...@gmail.com> Date: Sun Oct 30 18:01:21 2016 +0200 Add resource name method to IContextMenuProvider Change-Id: I218fd18101f8f7039052fe8a065096e4c9809adb diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index 3c6860d..c414c63 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.cxx @@ -2281,9 +2281,14 @@ void OApplicationController::onDeleteEntry() executeChecked(nId,Sequence<PropertyValue>()); } +OUString OApplicationController::getContextMenuResourceName( Control& /*_rControl*/ ) const +{ + return OUString("edit"); +} + VclPtr<PopupMenu> OApplicationController::getContextMenu( Control& /*_rControl*/ ) const { - return VclPtr<PopupMenu>::Create( ModuleRes( RID_MENU_APP_EDIT ) ); + return nullptr; } IController& OApplicationController::getCommandController() diff --git a/dbaccess/source/ui/app/AppController.hxx b/dbaccess/source/ui/app/AppController.hxx index ded0069..6c5bcfd 100644 --- a/dbaccess/source/ui/app/AppController.hxx +++ b/dbaccess/source/ui/app/AppController.hxx @@ -521,6 +521,7 @@ namespace dbaui virtual sal_Int8 executeDrop( const ExecuteDropEvent& _rEvt ) override; // IContextMenuProvider + virtual OUString getContextMenuResourceName( Control& _rControl ) const override; virtual VclPtr<PopupMenu> getContextMenu( Control& _rControl ) const override; virtual IController& getCommandController() override; virtual ::comphelper::OInterfaceContainerHelper2* diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index f42a386..5aa5f4f 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -3469,6 +3469,11 @@ bool SbaTableQueryBrowser::requestQuickHelp( const SvTreeListEntry* _pEntry, OUS return false; } +OUString SbaTableQueryBrowser::getContextMenuResourceName( Control& ) const +{ + return OUString(); +} + VclPtr<PopupMenu> SbaTableQueryBrowser::getContextMenu( Control& _rControl ) const { OSL_PRECOND( &m_pTreeView->getListBox() == &_rControl, diff --git a/dbaccess/source/ui/inc/callbacks.hxx b/dbaccess/source/ui/inc/callbacks.hxx index c9e98ea..9d1c95e 100644 --- a/dbaccess/source/ui/inc/callbacks.hxx +++ b/dbaccess/source/ui/inc/callbacks.hxx @@ -68,6 +68,14 @@ namespace dbaui class SAL_NO_VTABLE IContextMenuProvider { public: + /** returns the context menu resource name for the control + + Supposed to be a valid name from uiconfig/<module>/popupmenu folder. + Nevertheless, the getContextMenu method will not be evaluated, as long + as this method returns non-empty string. + */ + virtual OUString getContextMenuResourceName( Control& _rControl ) const = 0; + /** returns the context menu for the control Note that the menu does not need to care for the controls selection, or its diff --git a/dbaccess/source/ui/inc/dbu_resource.hrc b/dbaccess/source/ui/inc/dbu_resource.hrc index 83ccc95..4c6cd08 100644 --- a/dbaccess/source/ui/inc/dbu_resource.hrc +++ b/dbaccess/source/ui/inc/dbu_resource.hrc @@ -133,7 +133,6 @@ #define RID_QUERYFUNCTION_POPUPMENU RID_MENU_START + 6 #define RID_TABLEDESIGNROWPOPUPMENU RID_MENU_START + 7 #define RID_SBA_RTF_PKEYPOPUP RID_MENU_START + 9 -#define RID_MENU_APP_EDIT RID_MENU_START + 10 #define RID_MENU_APP_PREVIEW RID_MENU_START + 12 #define MENU_BROWSER_DEFAULTCONTEXT RID_MENU_START + 14 #define RID_MENU_JOINVIEW_CONNECTION RID_MENU_START + 16 diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx index f8bd65a..93118a4 100644 --- a/dbaccess/source/ui/inc/unodatbr.hxx +++ b/dbaccess/source/ui/inc/unodatbr.hxx @@ -230,6 +230,7 @@ namespace dbaui virtual sal_Int8 executeDrop( const ExecuteDropEvent& _rEvt ) override; // IContextMenuProvider + virtual OUString getContextMenuResourceName( Control& _rControl ) const override; virtual VclPtr<PopupMenu> getContextMenu( Control& _rControl ) const override; virtual IController& getCommandController() override; virtual ::comphelper::OInterfaceContainerHelper2* commit d1dd9269f1c9f0efc7fb44087fb172d66f54a8fa Author: Maxim Monastirsky <momonas...@gmail.com> Date: Tue Oct 25 11:05:39 2016 +0300 Convert RID_MENU_APP_EDIT to xml Change-Id: I6868624b1726b1044e741a1fc0cdabe703f84c31 diff --git a/dbaccess/UIConfig_dbapp.mk b/dbaccess/UIConfig_dbapp.mk index f810f4b..1dbab2a 100644 --- a/dbaccess/UIConfig_dbapp.mk +++ b/dbaccess/UIConfig_dbapp.mk @@ -14,6 +14,7 @@ $(eval $(call gb_UIConfig_add_menubarfiles,modules/dbapp,\ )) $(eval $(call gb_UIConfig_add_popupmenufiles,modules/dbapp,\ + dbaccess/uiconfig/dbapp/popupmenu/edit \ dbaccess/uiconfig/dbapp/popupmenu/new \ )) diff --git a/dbaccess/source/ui/app/app.src b/dbaccess/source/ui/app/app.src index 3b4f124..04dce61 100644 --- a/dbaccess/source/ui/app/app.src +++ b/dbaccess/source/ui/app/app.src @@ -21,8 +21,6 @@ #include "browserids.hxx" #include "dbaccess_helpid.hrc" -#define MN_PROPS 25 - String RID_STR_NEW_FORM { Text [ en-US ] = "Create Form in Design View..." ; @@ -80,134 +78,6 @@ String RID_STR_REPORTS_CONTAINER { Text [ en-US ] = "Reports" ; }; - -Menu RID_MENU_APP_EDIT -{ - ItemList = - { - MenuItem - { - Identifier = SID_COPY ; - Command = ".uno:Copy" ; - Text [ en-US ] = "~Copy" ; - }; - MenuItem - { - Identifier = SID_PASTE ; - Command = ".uno:Paste" ; - Text [ en-US ] = "~Paste" ; - }; - MenuItem - { - Identifier = SID_DB_APP_PASTE_SPECIAL; - Text[ en-US ] = "Paste Special..."; - Command = ".uno:PasteSpecial"; - }; - MenuItem - { - Separator = TRUE ; - }; - MenuItem - { - Identifier = SID_DB_APP_DELETE; - Text[ en-US ] = "Delete"; - Command = ".uno:DBDelete"; - }; - MenuItem - { - Identifier = SID_DB_APP_RENAME; - Text[ en-US ] = "Rename"; - Command = ".uno:DBRename"; - }; - MenuItem - { - Identifier = SID_DB_APP_EDIT; - Text[ en-US ] = "Edit"; - Command = ".uno:DBEdit"; - }; - MenuItem - { - Identifier = SID_DB_APP_EDIT_SQL_VIEW; - Text [ en-US ] = "Edit in SQL View..."; - Command = ".uno:DBEditSqlView"; - }; - MenuItem - { - Identifier = SID_DB_APP_OPEN; - Text[ en-US ] = "Open"; - Command = ".uno:DBOpen"; - }; - MenuItem - { - Identifier = SID_DB_APP_CONVERTTOVIEW; - Text[ en-US ] = "Create as View"; - Command = ".uno:DBConvertToView"; - }; - MenuItem - { - Identifier = SID_FORM_CREATE_REPWIZ_PRE_SEL; - Text [ en-US ] = "Form Wizard..."; - Command = ".uno:DBNewFormAutoPilotWithPreSelection"; - }; - MenuItem - { - Identifier = SID_APP_NEW_REPORT_PRE_SEL; - Command = ".uno:DBNewReportWithPreSelection"; - Text [ en-US ] = "Report..." ; - }; - MenuItem - { - Identifier = SID_REPORT_CREATE_REPWIZ_PRE_SEL ; - Text[ en-US ] = "Report Wizard..."; - - Command = ".uno:DBNewReportAutoPilotWithPreSelection"; - }; - MenuItem - { - Separator = TRUE ; - }; - MenuItem - { - Identifier = SID_SELECTALL; - Text[ en-US ] = "Select All"; - Command = ".uno:SelectAll"; - }; - MenuItem - { - Separator = TRUE ; - }; - MenuItem - { - Identifier = MN_PROPS; - Text[ en-US ] = "~Database"; - SubMenu = Menu - { - ItemList = - { - MenuItem - { - Identifier = SID_DB_APP_DSPROPS; - Text[ en-US ] = "Properties..."; - Command = ".uno:DBDSProperties"; - }; - MenuItem - { - Identifier = SID_DB_APP_DSCONNECTION_TYPE; - Text[ en-US ] = "Connection Type..."; - Command = ".uno:DBDSConnectionType"; - }; - MenuItem - { - Identifier = SID_DB_APP_DSADVANCED_SETTINGS; - Text[ en-US ] = "Advanced Settings..."; - Command = ".uno:DBDSAdvancedSettings"; - }; - }; - }; - }; - }; -}; - String STR_QUERY_DELETE_DATASOURCE { Text [ en-US ] = "Do you want to delete the data source '%1'?" ; diff --git a/dbaccess/uiconfig/dbapp/popupmenu/edit.xml b/dbaccess/uiconfig/dbapp/popupmenu/edit.xml new file mode 100644 index 0000000..5f67d0b --- /dev/null +++ b/dbaccess/uiconfig/dbapp/popupmenu/edit.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * +--> +<menu:menupopup xmlns:menu="http://openoffice.org/2001/menu"> + <menu:menuitem menu:id=".uno:Copy"/> + <menu:menuitem menu:id=".uno:Paste"/> + <menu:menuitem menu:id=".uno:PasteSpecial"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:DBDelete"/> + <menu:menuitem menu:id=".uno:DBRename"/> + <menu:menuitem menu:id=".uno:DBEdit"/> + <menu:menuitem menu:id=".uno:DBEditSqlView"/> + <menu:menuitem menu:id=".uno:DBOpen"/> + <menu:menuitem menu:id=".uno:DBConvertToView"/> + <menu:menuitem menu:id=".uno:DBNewFormAutoPilotWithPreSelection"/> + <menu:menuitem menu:id=".uno:DBNewReportWithPreSelection"/> + <menu:menuitem menu:id=".uno:DBNewReportAutoPilotWithPreSelection"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:SelectAll"/> + <menu:menuseparator/> + <menu:menu menu:id=".uno:DBDatabasePropertiesMenu"> + <menu:menupopup> + <menu:menuitem menu:id=".uno:DBDSProperties"/> + <menu:menuitem menu:id=".uno:DBDSConnectionType"/> + <menu:menuitem menu:id=".uno:DBDSAdvancedSettings"/> + </menu:menupopup> + </menu:menu> +</menu:menupopup> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/BaseWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/BaseWindowState.xcu index 234cb58..72d0943 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/BaseWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/BaseWindowState.xcu @@ -3,6 +3,11 @@ <oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:install="http://openoffice.org/2004/installation" oor:name="BaseWindowState" oor:package="org.openoffice.Office.UI"> <node oor:name="UIElements"> <node oor:name="States"> + <node oor:name="private:resource/popupmenu/edit" oor:op="replace"> + <prop oor:name="UIName" oor:type="xs:string"> + <value xml:lang="en-US">Database Object</value> + </prop> + </node> <node oor:name="private:resource/toolbar/tableobjectbar" oor:op="replace"> <prop oor:name="DockPos" oor:type="xs:string"> <value>0,0</value> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/DbuCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/DbuCommands.xcu index 3c44bef..d6cdfc0 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/DbuCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/DbuCommands.xcu @@ -114,6 +114,9 @@ <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">Open Database Object...</value> </prop> + <prop oor:name="PopupLabel" oor:type="xs:string"> + <value xml:lang="en-US">Open...</value> + </prop> </node> <node oor:name=".uno:DBTableDelete" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> @@ -277,6 +280,11 @@ <value xml:lang="en-US">Form Wizard...</value> </prop> </node> + <node oor:name=".uno:DBNewReportWithPreSelection" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Report...</value> + </prop> + </node> <node oor:name=".uno:DBNewReportAutoPilot" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">Report Wizard...</value> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits