diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2020-08-10 18:35:22 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2020-08-11 10:33:00 +0200 |
commit | 3239708375c81005d66627c09d1907848cd0cfda (patch) | |
tree | bd2f8424cbaa579627022d2f71e9f4ba88c3d7ea /framework/source | |
parent | 7841adec312b4993156cdbd9702223e8f1f34132 (diff) |
Simplify toolbar mode switching
Change-Id: I3bd809ce3ef661f6566a73e639fbd5e4bb1b7e3f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100439
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'framework/source')
-rw-r--r-- | framework/source/uielement/toolbarmodemenucontroller.cxx | 82 |
1 files changed, 3 insertions, 79 deletions
diff --git a/framework/source/uielement/toolbarmodemenucontroller.cxx b/framework/source/uielement/toolbarmodemenucontroller.cxx index c2f48162145d..86dbda38f5b9 100644 --- a/framework/source/uielement/toolbarmodemenucontroller.cxx +++ b/framework/source/uielement/toolbarmodemenucontroller.cxx @@ -36,6 +36,7 @@ #include <rtl/ustrbuf.hxx> #include <sal/log.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertysequence.hxx> #include <comphelper/types.hxx> #include <svtools/miscopt.hxx> #include <unotools/confignode.hxx> @@ -226,65 +227,8 @@ void SAL_CALL ToolbarModeMenuController::statusChanged( const FeatureStateEvent& // XMenuListener void SAL_CALL ToolbarModeMenuController::itemSelected( const css::awt::MenuEvent& rEvent ) { - Reference< css::awt::XPopupMenu > xPopupMenu; - Reference< XURLTransformer > xURLTransformer; - Reference< XFrame > xFrame; - - { - osl::MutexGuard aLock(m_aMutex); - xPopupMenu = m_xPopupMenu; - xURLTransformer = m_xURLTransformer; - xFrame = m_xFrame; - } - - if ( !xPopupMenu.is() ) - return; - - VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( xPopupMenu )); - if ( !pPopupMenu ) - return; - - SolarMutexGuard aSolarMutexGuard; - PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu()); - OUString aCmd( pVCLPopupMenu->GetItemCommand( rEvent.MenuId )); - - { - URL aTargetURL; - Sequence<PropertyValue> aArgs; - - aTargetURL.Complete = ".uno:Notebookbar?File:string=" + aCmd; - xURLTransformer->parseStrict( aTargetURL ); - Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - if ( xDispatchProvider.is() ) - { - Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( - aTargetURL, OUString(), 0 ); - - ExecuteInfo* pExecuteInfo = new ExecuteInfo; - pExecuteInfo->xDispatch = xDispatch; - pExecuteInfo->aTargetURL = aTargetURL; - pExecuteInfo->aArgs = aArgs; - Application::PostUserEvent( LINK(nullptr,ToolbarModeMenuController, ExecuteHdl_Impl), pExecuteInfo ); - } - } - - URL aTargetURL; - Sequence<PropertyValue> aArgs; - - aTargetURL.Complete = ".uno:ToolbarMode?Mode:string=" + aCmd; - xURLTransformer->parseStrict( aTargetURL ); - Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - if ( xDispatchProvider.is() ) - { - Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( - aTargetURL, OUString(), 0 ); - - ExecuteInfo* pExecuteInfo = new ExecuteInfo; - pExecuteInfo->xDispatch = xDispatch; - pExecuteInfo->aTargetURL = aTargetURL; - pExecuteInfo->aArgs = aArgs; - Application::PostUserEvent( LINK(nullptr, ToolbarModeMenuController, ExecuteHdl_Impl), pExecuteInfo ); - } + auto aArgs(comphelper::InitPropertySequence({{"Mode", makeAny(m_xPopupMenu->getCommand(rEvent.MenuId))}})); + dispatchCommand(m_aCommandURL, aArgs); } void SAL_CALL ToolbarModeMenuController::itemActivated( const css::awt::MenuEvent& ) @@ -351,26 +295,6 @@ void SAL_CALL ToolbarModeMenuController::setPopupMenu( const Reference< css::awt } } -IMPL_STATIC_LINK( ToolbarModeMenuController, ExecuteHdl_Impl, void*, p, void ) -{ - ExecuteInfo* pExecuteInfo = static_cast<ExecuteInfo*>(p); - try - { - // Asynchronous execution as this can lead to our own destruction! - // Framework can recycle our current frame and the layout manager disposes all user interface - // elements if a component gets detached from its frame! - if ( pExecuteInfo->xDispatch.is() ) - { - pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs ); - } - } - catch ( const Exception& ) - { - } - - delete pExecuteInfo; -} - } extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* |