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 | |
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>
-rw-r--r-- | framework/inc/uielement/toolbarmodemenucontroller.hxx | 9 | ||||
-rw-r--r-- | framework/source/uielement/toolbarmodemenucontroller.cxx | 82 | ||||
-rw-r--r-- | sfx2/sdi/sfx.sdi | 2 | ||||
-rw-r--r-- | sfx2/source/appl/appserv.cxx | 8 |
4 files changed, 8 insertions, 93 deletions
diff --git a/framework/inc/uielement/toolbarmodemenucontroller.hxx b/framework/inc/uielement/toolbarmodemenucontroller.hxx index 6fe03f455206..44f667dcb8d2 100644 --- a/framework/inc/uielement/toolbarmodemenucontroller.hxx +++ b/framework/inc/uielement/toolbarmodemenucontroller.hxx @@ -53,15 +53,6 @@ namespace framework // XEventListener virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; - struct ExecuteInfo - { - css::uno::Reference< css::frame::XDispatch > xDispatch; - css::util::URL aTargetURL; - css::uno::Sequence< css::beans::PropertyValue > aArgs; - }; - - DECL_STATIC_LINK( ToolbarModeMenuController, ExecuteHdl_Impl, void*, void ); - private: void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu ); 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* diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 888a0e4b41da..a50b5f1a17a6 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -2615,7 +2615,7 @@ SfxVoidItem Notebookbar SID_NOTEBOOKBAR (SfxStringItem File SID_NOTEBOOKBAR) [ AutoUpdate = TRUE, - FastCall = FALSE, + FastCall = TRUE, ReadOnlyDoc = TRUE, Toggle = FALSE, Container = FALSE, diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 68f80d7e99e3..b07974a9b34a 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -892,6 +892,10 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) } } + // Show/Hide the Notebookbar + const SfxStringItem pItem(SID_NOTEBOOKBAR, aNewName); + pViewFrame->GetDispatcher()->ExecuteList(SID_NOTEBOOKBAR, SfxCallMode::SYNCHRON, {&pItem}); + // Show toolbars for ( const OUString& rName : std::as_const(aMandatoryToolbars) ) { @@ -929,10 +933,6 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) } } - // Show/Hide the Notebookbar - const SfxPoolItem* pItem; - pViewFrame->GetDispatcher()->QueryState( SID_NOTEBOOKBAR, pItem ); - // Save settings if ( pViewFrame == SfxViewFrame::Current() ) { |