diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2020-08-12 23:36:52 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2020-08-14 17:03:41 +0200 |
commit | c5301f215fec9016c3a75ff4a6a0c6c22f152718 (patch) | |
tree | 7a4f147999967eeb161dbf4383ad19e20db5f4de /framework/source/uielement/generictoolbarcontroller.cxx | |
parent | f3cb59c46398b3a0646b8b374d5626f715fa6884 (diff) |
Replace MenuToolbarController with the usual approach for menu buttons
i.e. ResourceMenuController + GenericPopupToolbarController.
(Decl. of both isn't available in a header file, so they are instantiated
via the service manager for now. This is a bit weird for something from
the same module, but should not make any difference in practice.)
Change-Id: Ia3fc7ba82b0f6e1a43aa7b5e56e2cff7e039d877
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100725
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'framework/source/uielement/generictoolbarcontroller.cxx')
-rw-r--r-- | framework/source/uielement/generictoolbarcontroller.cxx | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/framework/source/uielement/generictoolbarcontroller.cxx b/framework/source/uielement/generictoolbarcontroller.cxx index b13739932b32..8bea883d90d6 100644 --- a/framework/source/uielement/generictoolbarcontroller.cxx +++ b/framework/source/uielement/generictoolbarcontroller.cxx @@ -21,30 +21,22 @@ #include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/frame/status/ItemStatus.hpp> #include <com/sun/star/frame/status/Visibility.hpp> -#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> -#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp> #include <com/sun/star/frame/ControlCommand.hpp> -#include <svtools/toolboxcontroller.hxx> #include <vcl/svapp.hxx> #include <vcl/toolbox.hxx> #include <tools/urlobj.hxx> #include <strings.hrc> #include <classes/fwkresid.hxx> -#include <uielement/menubarmanager.hxx> -using namespace ::com::sun::star::awt; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::frame::status; -using namespace ::com::sun::star::util; -using namespace ::com::sun::star::container; namespace framework { @@ -281,93 +273,6 @@ IMPL_STATIC_LINK( GenericToolbarController, ExecuteHdl_Impl, void*, p, void ) delete pExecuteInfo; } -void MenuToolbarController::dispose() -{ - try - { - if ( m_xMenuManager.is() ) - m_xMenuManager->dispose(); - } - catch( const Exception& ) {} - - m_xMenuManager.clear(); - m_xMenuDesc.clear(); - pMenu.disposeAndClear(); -} - -void MenuToolbarController::initialize( const css::uno::Sequence< css::uno::Any >& rArgs ) -{ - ToolboxController::initialize( rArgs ); - - css::uno::Reference< css::container::XIndexAccess > xMenuContainer; - try - { - css::uno::Reference< css::frame::XController > xController( m_xFrame->getController() ); - css::uno::Reference< css::ui::XUIConfigurationManagerSupplier > xSupplier( xController->getModel(), css::uno::UNO_QUERY_THROW ); - css::uno::Reference< css::ui::XUIConfigurationManager > xConfigManager( xSupplier->getUIConfigurationManager() ); - xMenuContainer.set( xConfigManager->getSettings( m_aCommandURL, false ) ); - } - catch( const css::uno::Exception& ) - {} - - if ( !xMenuContainer.is() ) - { - try - { - css::uno::Reference< css::ui::XModuleUIConfigurationManagerSupplier > xSupplier( - css::ui::theModuleUIConfigurationManagerSupplier::get( m_xContext ) ); - css::uno::Reference< css::ui::XUIConfigurationManager > xConfigManager( - xSupplier->getUIConfigurationManager( m_sModuleName ) ); - xMenuContainer.set( xConfigManager->getSettings( m_aCommandURL, false ) ); - } - catch( const css::uno::Exception& ) - {} - } - - if ( !(xMenuContainer.is() && xMenuContainer->getCount()) ) - return; - - Sequence< PropertyValue > aProps; - // drop down menu info is currently the first ( and only ) menu in the menusettings container - xMenuContainer->getByIndex(0) >>= aProps; - for ( const auto& aProp : std::as_const(aProps) ) - { - if ( aProp.Name == "ItemDescriptorContainer" ) - { - aProp.Value >>= m_xMenuDesc; - break; - } - } - - ToolBox* pToolBox = nullptr; - sal_uInt16 nId = 0; - if ( getToolboxId( nId, &pToolBox ) ) - pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY ); -} - -Reference< XWindow > SAL_CALL -MenuToolbarController::createPopupWindow() -{ - if ( !pMenu ) - { - pMenu = VclPtr<PopupMenu>::Create(); - css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( m_xFrame, css::uno::UNO_QUERY ); - sal_uInt16 m_nMenuId = 1; - MenuBarManager::FillMenu( m_nMenuId, pMenu, m_sModuleName, m_xMenuDesc, xDispatchProvider ); - m_xMenuManager.set( new MenuBarManager( m_xContext, m_xFrame, m_xUrlTransformer, xDispatchProvider, m_sModuleName, pMenu, false, false ) ); - } - - ToolBox* pToolBox = nullptr; - sal_uInt16 nId = 0; - if ( !getToolboxId( nId, &pToolBox ) ) - return nullptr; - - pToolBox->SetItemDown( m_nToolBoxId, true ); - pMenu->Execute( pToolBox, pToolBox->GetItemRect( nId ), PopupMenuFlags::ExecuteDown ); - pToolBox->SetItemDown( m_nToolBoxId, false ); - - return nullptr; -} } // namespace /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |