framework/inc/uielement/toolbarmanager.hxx | 5 -- framework/source/fwe/classes/sfxhelperfunctions.cxx | 23 ---------- framework/source/uielement/toolbarmanager.cxx | 42 ++++---------------- include/framework/sfxhelperfunctions.hxx | 19 --------- include/sfx2/tbxctrl.hxx | 1 sfx2/source/appl/app.cxx | 12 ----- 6 files changed, 12 insertions(+), 90 deletions(-)
New commits: commit f87c7018fa5641eeecd788907ea66892514255a6 Author: Maxim Monastirsky <momonas...@gmail.com> AuthorDate: Sun Jul 17 15:43:17 2022 +0300 Commit: Maxim Monastirsky <momonas...@gmail.com> CommitDate: Sun Jul 17 22:36:53 2022 +0200 No need for SfxWeldToolBoxControllerFactory sfx2::sidebar::ControllerFactory::CreateToolBoxController only supports creating controllers using the uno factory, or GenericToolbarController as a fallback. Given that we already handle the uno factory case in ToolBarManager::CreateControllers, all this complexity is really just for creating GenericToolbarController with a different ctor, which we can do locally as well. Change-Id: I3a5a3cda95a6c5db97615286e93630214f76cbfc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137149 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky <momonas...@gmail.com> diff --git a/framework/inc/uielement/toolbarmanager.hxx b/framework/inc/uielement/toolbarmanager.hxx index 17840c46fe95..2e7cd1c01a9a 100644 --- a/framework/inc/uielement/toolbarmanager.hxx +++ b/framework/inc/uielement/toolbarmanager.hxx @@ -64,10 +64,6 @@ public: virtual void Init() = 0; virtual void Destroy() = 0; virtual css::uno::Reference<css::awt::XWindow> GetInterface() = 0; - virtual css::uno::Reference<css::frame::XStatusListener> CreateToolBoxController( - const css::uno::Reference<css::frame::XFrame>& rFrame, - ToolBoxItemId nId, - const OUString& aCommandURL ) = 0; virtual void InsertItem(ToolBoxItemId nId, const OUString& rString, const OUString& rCommandURL, @@ -230,6 +226,7 @@ class ToolBarManager final : public ToolbarManager_Base std::unique_ptr<ToolBarManagerImpl> m_pImpl; VclPtr<ToolBox> m_pToolBar; + weld::Toolbar* m_pWeldedToolBar; OUString m_aModuleIdentifier; OUString m_aResourceName; diff --git a/framework/source/fwe/classes/sfxhelperfunctions.cxx b/framework/source/fwe/classes/sfxhelperfunctions.cxx index 170f3e7156bb..5a1cc0d716d5 100644 --- a/framework/source/fwe/classes/sfxhelperfunctions.cxx +++ b/framework/source/fwe/classes/sfxhelperfunctions.cxx @@ -24,7 +24,6 @@ #include <svtools/statusbarcontroller.hxx> static pfunc_setToolBoxControllerCreator pToolBoxControllerCreator = nullptr; -static pfunc_setWeldToolBoxControllerCreator pWeldToolBoxControllerCreator = nullptr; static pfunc_setStatusBarControllerCreator pStatusBarControllerCreator = nullptr; static pfunc_getRefreshToolbars pRefreshToolbars = nullptr; static pfunc_createDockingWindow pCreateDockingWindow = nullptr; @@ -58,28 +57,6 @@ rtl::Reference<svt::ToolboxController> CreateToolBoxController( const Reference< return nullptr; } -pfunc_setWeldToolBoxControllerCreator SetWeldToolBoxControllerCreator( pfunc_setWeldToolBoxControllerCreator pSetWeldToolBoxControllerCreator ) -{ - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - pfunc_setWeldToolBoxControllerCreator pOldSetToolBoxControllerCreator = pWeldToolBoxControllerCreator; - pWeldToolBoxControllerCreator = pSetWeldToolBoxControllerCreator; - return pOldSetToolBoxControllerCreator; -} - -css::uno::Reference<css::frame::XToolbarController> CreateWeldToolBoxController( const Reference< XFrame >& rFrame, weld::Toolbar* pToolbar, weld::Builder* pBuilder, const OUString& aCommandURL ) -{ - pfunc_setWeldToolBoxControllerCreator pFactory = nullptr; - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - pFactory = pWeldToolBoxControllerCreator; - } - - if ( pFactory ) - return (*pFactory)( rFrame, pToolbar, pBuilder, aCommandURL ); - else - return nullptr; -} - pfunc_setStatusBarControllerCreator SetStatusBarControllerCreator( pfunc_setStatusBarControllerCreator pSetStatusBarControllerCreator ) { ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index a632828b5c8c..587cd8b61ad8 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -200,19 +200,6 @@ public: return VCLUnoHelper::GetInterface(m_pToolBar); } - virtual css::uno::Reference<css::frame::XStatusListener> CreateToolBoxController( - const css::uno::Reference<css::frame::XFrame>& rFrame, - ToolBoxItemId nId, - const OUString& rCommandURL ) override - { - rtl::Reference<svt::ToolboxController> pController - = ::framework::CreateToolBoxController( rFrame, m_pToolBar, nId, rCommandURL ); - css::uno::Reference<css::frame::XStatusListener> xListener; - if (pController) - xListener = pController; - return xListener; - } - virtual void ConnectCallbacks(ToolBarManager* pManager) override { m_pManager = pManager; @@ -422,20 +409,7 @@ public: virtual css::uno::Reference<css::awt::XWindow> GetInterface() override { - return new weld::TransportAsXWindow(m_pWeldedToolBar); - } - - virtual css::uno::Reference<css::frame::XStatusListener> CreateToolBoxController( - const css::uno::Reference<css::frame::XFrame>& rFrame, - ToolBoxItemId /*nId*/, - const OUString& rCommandURL ) override - { - css::uno::Reference<css::frame::XToolbarController> xController - = ::framework::CreateWeldToolBoxController(rFrame, m_pWeldedToolBar, m_pBuilder, rCommandURL); - css::uno::Reference<css::frame::XStatusListener> xListener; - if (xController.is()) - xListener = css::uno::Reference<css::frame::XStatusListener>( xController, UNO_QUERY ); - return xListener; + return new weld::TransportAsXWindow(m_pWeldedToolBar, m_pBuilder); } virtual void ConnectCallbacks(ToolBarManager* pManager) override @@ -583,6 +557,7 @@ ToolBarManager::ToolBarManager( const Reference< XComponentContext >& rxContext, m_nContextMinPos(0), m_pImpl( new VclToolBarManager( pToolBar ) ), m_pToolBar( pToolBar ), + m_pWeldedToolBar( nullptr ), m_aResourceName(std::move( aResourceName )), m_xFrame( rFrame ), m_xContext( rxContext ), @@ -603,7 +578,7 @@ ToolBarManager::ToolBarManager( const Reference< XComponentContext >& rxContext, m_eSymbolSize( SvtMiscOptions().GetCurrentSymbolsSize() ), m_nContextMinPos(0), m_pImpl( new WeldToolBarManager( pToolBar, pBuilder ) ), - m_pToolBar( nullptr ), + m_pWeldedToolBar( pToolBar ), m_aResourceName(std::move( aResourceName )), m_xFrame( rFrame ), m_xContext( rxContext ), @@ -1134,7 +1109,8 @@ void ToolBarManager::CreateControllers() if ( !xController.is() && bCreate ) { - xController = m_pImpl->CreateToolBoxController( m_xFrame, nId, aCommandURL ); + if ( m_pToolBar ) + xController = CreateToolBoxController( m_xFrame, m_pToolBar, nId, aCommandURL ); if ( !xController ) { if ( aCommandURL.startsWith( ".uno:StyleApply?" ) ) @@ -1164,10 +1140,12 @@ void ToolBarManager::CreateControllers() xController = xStatusListener; } - else if (m_pToolBar) + else { - xController.set( - new GenericToolbarController( m_xContext, m_xFrame, m_pToolBar, nId, aCommandURL )); + if ( m_pToolBar ) + xController.set( new GenericToolbarController( m_xContext, m_xFrame, m_pToolBar, nId, aCommandURL )); + else + xController.set( new GenericToolbarController( m_xContext, m_xFrame, *m_pWeldedToolBar, aCommandURL )); // Accessibility support: Set toggle button role for specific commands sal_Int32 nProps = vcl::CommandInfoProvider::GetPropertiesForCommand(aCommandURL, m_aModuleIdentifier); diff --git a/include/framework/sfxhelperfunctions.hxx b/include/framework/sfxhelperfunctions.hxx index 36de22f54e67..c0f4dc38ff62 100644 --- a/include/framework/sfxhelperfunctions.hxx +++ b/include/framework/sfxhelperfunctions.hxx @@ -24,17 +24,13 @@ #include <rtl/ref.hxx> #include <vcl/toolboxid.hxx> -namespace com::sun::star::frame { class XFrame; class XToolbarController; } +namespace com::sun::star::frame { class XFrame; } namespace com::sun::star::uno { template <typename > class Reference; } namespace svt { class StatusbarController; } namespace svt { class ToolboxController; } class StatusBar; class ToolBox; -namespace weld { - class Toolbar; - class Builder; -}; typedef rtl::Reference<svt::ToolboxController> ( *pfunc_setToolBoxControllerCreator)( const css::uno::Reference< css::frame::XFrame >& rFrame, @@ -42,12 +38,6 @@ typedef rtl::Reference<svt::ToolboxController> ( *pfunc_setToolBoxControllerCrea ToolBoxItemId nID, const OUString& aCommandURL ); -typedef css::uno::Reference<css::frame::XToolbarController> ( *pfunc_setWeldToolBoxControllerCreator)( - const css::uno::Reference< css::frame::XFrame >& rFrame, - weld::Toolbar* pToolbar, - weld::Builder* pBuilder, - const OUString& aCommandURL ); - typedef rtl::Reference<svt::StatusbarController> ( *pfunc_setStatusBarControllerCreator)( const css::uno::Reference< css::frame::XFrame >& rFrame, StatusBar* pStatusBar, @@ -75,13 +65,6 @@ FWK_DLLPUBLIC rtl::Reference<svt::ToolboxController> CreateToolBoxController( ToolBoxItemId nID, const OUString& aCommandURL ); -FWK_DLLPUBLIC pfunc_setWeldToolBoxControllerCreator SetWeldToolBoxControllerCreator( pfunc_setWeldToolBoxControllerCreator pSetToolBoxControllerCreator ); -FWK_DLLPUBLIC css::uno::Reference<css::frame::XToolbarController> CreateWeldToolBoxController( - const css::uno::Reference< css::frame::XFrame >& rFrame, - weld::Toolbar* pToolbar, - weld::Builder* pBuilder, - const OUString& aCommandURL ); - FWK_DLLPUBLIC pfunc_setStatusBarControllerCreator SetStatusBarControllerCreator( pfunc_setStatusBarControllerCreator pSetStatusBarControllerCreator ); FWK_DLLPUBLIC rtl::Reference<svt::StatusbarController> CreateStatusBarController( const css::uno::Reference< css::frame::XFrame >& rFrame, diff --git a/include/sfx2/tbxctrl.hxx b/include/sfx2/tbxctrl.hxx index e3953c4e5b7a..d513c0807b21 100644 --- a/include/sfx2/tbxctrl.hxx +++ b/include/sfx2/tbxctrl.hxx @@ -31,7 +31,6 @@ namespace com::sun::star::frame { class XDispatchProvider; } namespace com::sun::star::frame { class XFrame; } namespace vcl { class Window; } -namespace com::sun::star::frame { class XToolbarController; } class InterimItemWindow; class SfxToolBoxControl; diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx index cd4acc552132..760ab1ca9cb1 100644 --- a/sfx2/source/appl/app.cxx +++ b/sfx2/source/appl/app.cxx @@ -49,7 +49,6 @@ #include <sfx2/sfxdlg.hxx> #include <sfx2/stbitem.hxx> #include <sfx2/dockwin.hxx> -#include <sidebar/ControllerFactory.hxx> #include <officecfg/Office/Common.hxx> #include <rtl/strbuf.hxx> @@ -87,16 +86,6 @@ SfxModule* SfxApplication::GetModule(SfxToolsModule nSharedLib) return g_pSfxApplication->pImpl->aModules[nSharedLib].get(); } -namespace { - css::uno::Reference<css::frame::XToolbarController> SfxWeldToolBoxControllerFactory( const css::uno::Reference< css::frame::XFrame >& rFrame, weld::Toolbar* pToolbar, weld::Builder* pBuilder, const OUString& aCommandURL ) - { - SolarMutexGuard aGuard; - - return sfx2::sidebar::ControllerFactory::CreateToolBoxController( - *pToolbar, *pBuilder, aCommandURL, rFrame, rFrame->getController(), false); - } -} - SfxApplication* SfxApplication::GetOrCreate() { static std::mutex theApplicationMutex; @@ -116,7 +105,6 @@ SfxApplication* SfxApplication::GetOrCreate() ::framework::SetRefreshToolbars( RefreshToolbars ); ::framework::SetToolBoxControllerCreator( SfxToolBoxControllerFactory ); - ::framework::SetWeldToolBoxControllerCreator( SfxWeldToolBoxControllerFactory ); ::framework::SetStatusBarControllerCreator( SfxStatusBarControllerFactory ); ::framework::SetDockingWindowCreator( SfxDockingWindowFactory ); ::framework::SetIsDockingWindowVisible( IsDockingWindowVisible );