framework/inc/uielement/newmenucontroller.hxx | 2 framework/source/uielement/newmenucontroller.cxx | 82 ++++------------------- include/svtools/popupmenucontrollerbase.hxx | 2 svtools/source/uno/popupmenucontrollerbase.cxx | 6 + 4 files changed, 20 insertions(+), 72 deletions(-)
New commits: commit cea3b8762bfb7f0da19bab8a3d468bcbf987eb0f Author: Maxim Monastirsky <[email protected]> Date: Sun Nov 6 21:31:15 2016 +0200 NewMenuController: Fix template manager icon The current logic is swapped. MenuAttributes::aImageId can be only handled by SvFileInformationManager, while the menu item command is what might be (in case of .uno command) handled by CommandInfoProvider. This gone wrong in tdf#96059 which wrongly assumed that GetImageFromURL is equivalent to what's provided by CommandInfoProvider (so other places should be checked too). Change-Id: Ia487c602753dde3fb0d0462ef4b3d63209398b36 diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx index 09ca33e..e8963fd 100644 --- a/framework/source/uielement/newmenucontroller.cxx +++ b/framework/source/uielement/newmenucontroller.cxx @@ -72,7 +72,6 @@ DEFINE_INIT_SERVICE ( NewMenuController, {} ) void NewMenuController::setMenuImages( PopupMenu* pPopupMenu, bool bSetImages ) { sal_uInt16 nItemCount = pPopupMenu->GetItemCount(); - Image aImage; Reference< XFrame > xFrame( m_xFrame ); for ( sal_uInt16 i = 0; i < nItemCount; i++ ) @@ -82,39 +81,23 @@ void NewMenuController::setMenuImages( PopupMenu* pPopupMenu, bool bSetImages ) { if ( bSetImages ) { - bool bImageSet( false ); OUString aImageId; - + OUString aCmd( pPopupMenu->GetItemCommand( nItemId ) ); sal_uLong nAttributePtr = pPopupMenu->GetUserValue(sal::static_int_cast<sal_uInt16>(i)); MenuAttributes* pAttributes = reinterpret_cast<MenuAttributes *>(nAttributePtr); if (pAttributes) aImageId = pAttributes->aImageId; - if ( !aImageId.isEmpty() ) - { - aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aImageId, xFrame); - if ( !!aImage ) - { - bImageSet = true; - pPopupMenu->SetItemImage( nItemId, aImage ); - } - } - - if ( !bImageSet ) - { - OUString aCmd( pPopupMenu->GetItemCommand( nItemId ) ); - if ( !aCmd.isEmpty() ) - { - INetURLObject aURLObj( aCmd ); - aImage = SvFileInformationManager::GetImageNoDefault( aURLObj ); - } + INetURLObject aURLObj( aImageId.isEmpty() ? aCmd : aImageId ); + Image aImage = SvFileInformationManager::GetImageNoDefault( aURLObj ); + if ( !aImage ) + aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aCmd, xFrame); - if ( !!aImage ) - pPopupMenu->SetItemImage( nItemId, aImage ); - } + if ( !!aImage ) + pPopupMenu->SetItemImage( nItemId, aImage ); } else - pPopupMenu->SetItemImage( nItemId, aImage ); + pPopupMenu->SetItemImage( nItemId, Image() ); } } } commit 5bd6b61a7cad81d8385e5bc4ea0e6546b1eb7314 Author: Maxim Monastirsky <[email protected]> Date: Sun Nov 6 20:46:04 2016 +0200 NewMenuController: Remove duplicate async dispatch handling Change-Id: I881e6781c5ba82b0b998891532f8b7c281567b73 diff --git a/framework/inc/uielement/newmenucontroller.hxx b/framework/inc/uielement/newmenucontroller.hxx index 869650e..8b52dbb 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 971e5f5..09ca33e 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 4214c66..4fcfad4 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 aacc8e9..1c0f343 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 ) ); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
