diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2016-11-06 20:46:04 +0200 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2016-11-06 21:36:25 +0200 |
commit | 5bd6b61a7cad81d8385e5bc4ea0e6546b1eb7314 (patch) | |
tree | b8c810b55d4fefffd73fa56c4381430e7d22bf0d | |
parent | afe235a0abf9ef91a353a4d0dccf56961abd2fbf (diff) |
NewMenuController: Remove duplicate async dispatch handling
Change-Id: I881e6781c5ba82b0b998891532f8b7c281567b73
-rw-r--r-- | framework/inc/uielement/newmenucontroller.hxx | 2 | ||||
-rw-r--r-- | framework/source/uielement/newmenucontroller.cxx | 49 | ||||
-rw-r--r-- | include/svtools/popupmenucontrollerbase.hxx | 2 | ||||
-rw-r--r-- | svtools/source/uno/popupmenucontrollerbase.cxx | 6 |
4 files changed, 12 insertions, 47 deletions
diff --git a/framework/inc/uielement/newmenucontroller.hxx b/framework/inc/uielement/newmenucontroller.hxx index 869650ea7a94..8b52dbb6d104 100644 --- a/framework/inc/uielement/newmenucontroller.hxx +++ b/framework/inc/uielement/newmenucontroller.hxx @@ -77,8 +77,6 @@ namespace framework // XEventListener virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw ( css::uno::RuntimeException, std::exception ) override; - DECL_STATIC_LINK( NewMenuController, ExecuteHdl_Impl, void*, void ); - private: virtual void impl_setPopupMenu() override; diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx index 971e5f535a45..09ca33e28f5c 100644 --- a/framework/source/uielement/newmenucontroller.cxx +++ b/framework/source/uielement/newmenucontroller.cxx @@ -407,58 +407,38 @@ void SAL_CALL NewMenuController::statusChanged( const FeatureStateEvent& ) throw void SAL_CALL NewMenuController::itemSelected( const css::awt::MenuEvent& rEvent ) throw (RuntimeException, std::exception) { Reference< css::awt::XPopupMenu > xPopupMenu; - Reference< XDispatch > xDispatch; - Reference< XDispatchProvider > xDispatchProvider; Reference< XComponentContext > xContext; - Reference< XURLTransformer > xURLTransformer; osl::ClearableMutexGuard aLock( m_aMutex ); - xPopupMenu = m_xPopupMenu; - xDispatchProvider.set( m_xFrame, UNO_QUERY ); - xContext = m_xContext; - xURLTransformer = m_xURLTransformer; + xPopupMenu = m_xPopupMenu; + xContext = m_xContext; aLock.clear(); - css::util::URL aTargetURL; - Sequence< PropertyValue > aArgsList( 1 ); - - if ( xPopupMenu.is() && xDispatchProvider.is() ) + if ( xPopupMenu.is() ) { VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(VCLXPopupMenu::GetImplementation( xPopupMenu )); if ( pPopupMenu ) { + OUString aURL; OUString aTargetFrame( m_aTargetFrame ); { SolarMutexGuard aSolarMutexGuard; PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu()); - aTargetURL.Complete = pVCLPopupMenu->GetItemCommand(rEvent.MenuId); + aURL = pVCLPopupMenu->GetItemCommand(rEvent.MenuId); sal_uLong nAttributePtr = pVCLPopupMenu->GetUserValue(rEvent.MenuId); MenuAttributes* pAttributes = reinterpret_cast<MenuAttributes *>(nAttributePtr); if (pAttributes) aTargetFrame = pAttributes->aTargetFrame; } - xURLTransformer->parseStrict( aTargetURL ); - + Sequence< PropertyValue > aArgsList( 1 ); aArgsList[0].Name = "Referer"; aArgsList[0].Value = makeAny( OUString( "private:user" )); - xDispatch = xDispatchProvider->queryDispatch( aTargetURL, aTargetFrame, 0 ); + dispatchCommand( aURL, aArgsList, aTargetFrame ); } } - - if ( xDispatch.is() ) - { - // Call dispatch asynchronously as we can be destroyed while dispatch is - // executed. VCL is not able to survive this as it wants to call listeners - // after select!!! - NewDocument* pNewDocument = new NewDocument; - pNewDocument->xDispatch = xDispatch; - pNewDocument->aTargetURL = aTargetURL; - pNewDocument->aArgSeq = aArgsList; - Application::PostUserEvent( LINK(nullptr, NewMenuController, ExecuteHdl_Impl), pNewDocument ); - } } void SAL_CALL NewMenuController::itemActivated( const css::awt::MenuEvent& ) throw (RuntimeException, std::exception) @@ -548,21 +528,6 @@ void SAL_CALL NewMenuController::initialize( const Sequence< Any >& aArguments ) } } -IMPL_STATIC_LINK( NewMenuController, ExecuteHdl_Impl, void*, p, void ) -{ - NewDocument* pNewDocument = static_cast<NewDocument*>(p); -/* i62706: Don't catch all exceptions. We hide all problems here and are not able - to handle them on higher levels. - 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! - pNewDocument->xDispatch->dispatch( pNewDocument->aTargetURL, pNewDocument->aArgSeq ); - delete pNewDocument; -} - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/popupmenucontrollerbase.hxx b/include/svtools/popupmenucontrollerbase.hxx index 4214c6678abe..4fcfad407b20 100644 --- a/include/svtools/popupmenucontrollerbase.hxx +++ b/include/svtools/popupmenucontrollerbase.hxx @@ -95,7 +95,7 @@ namespace svt // XEventListener virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw ( css::uno::RuntimeException, std::exception ) override; - void dispatchCommand( const OUString& sCommandURL, const css::uno::Sequence< css::beans::PropertyValue >& rArgs ); + void dispatchCommand( const OUString& sCommandURL, const css::uno::Sequence< css::beans::PropertyValue >& rArgs, const OUString& sTarget = OUString() ); protected: void throwIfDisposed() throw ( css::uno::RuntimeException ); diff --git a/svtools/source/uno/popupmenucontrollerbase.cxx b/svtools/source/uno/popupmenucontrollerbase.cxx index aacc8e988a77..1c0f3431f8f7 100644 --- a/svtools/source/uno/popupmenucontrollerbase.cxx +++ b/svtools/source/uno/popupmenucontrollerbase.cxx @@ -124,7 +124,9 @@ void SAL_CALL PopupMenuControllerBase::itemSelected( const awt::MenuEvent& rEven } } -void PopupMenuControllerBase::dispatchCommand( const OUString& sCommandURL, const css::uno::Sequence< css::beans::PropertyValue >& rArgs ) +void PopupMenuControllerBase::dispatchCommand( const OUString& sCommandURL, + const css::uno::Sequence< css::beans::PropertyValue >& rArgs, + const OUString& sTarget ) { osl::MutexGuard aLock( m_aMutex ); @@ -137,7 +139,7 @@ void PopupMenuControllerBase::dispatchCommand( const OUString& sCommandURL, cons aURL.Complete = sCommandURL; m_xURLTransformer->parseStrict( aURL ); - Reference< XDispatch > xDispatch( xDispatchProvider->queryDispatch( aURL, OUString(), 0 ), UNO_QUERY_THROW ); + Reference< XDispatch > xDispatch( xDispatchProvider->queryDispatch( aURL, sTarget, 0 ), UNO_QUERY_THROW ); Application::PostUserEvent( LINK(nullptr, PopupMenuControllerBase, ExecuteHdl_Impl), new PopupMenuControllerBaseDispatchInfo( xDispatch, aURL, rArgs ) ); |