From 5355f52b14d7237ba0f9fdd910eca579292242bd Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 16 Jan 2023 15:55:28 +0200 Subject: XUnoTunnel->dynamic_cast in sd::DrawController Just past the concrete type down through a couple of layers, rather than using a generic type and then casting Change-Id: I7ba6c83463f3db7176b72cb7e764d3659706ae78 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145638 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sd/source/ui/framework/factories/BasicPaneFactory.cxx | 3 +-- sd/source/ui/framework/factories/BasicViewFactory.cxx | 3 +-- sd/source/ui/framework/factories/PresentationFactory.cxx | 2 +- sd/source/ui/framework/module/CenterViewFocusModule.cxx | 12 +++++------- sd/source/ui/framework/module/CenterViewFocusModule.hxx | 5 +++-- sd/source/ui/framework/module/DrawModule.cxx | 3 ++- sd/source/ui/framework/module/ImpressModule.cxx | 3 ++- sd/source/ui/framework/module/PresentationModule.cxx | 2 +- sd/source/ui/framework/module/ShellStackGuard.cxx | 11 ++++------- sd/source/ui/framework/module/ShellStackGuard.hxx | 4 +++- sd/source/ui/framework/module/ToolBarModule.cxx | 12 +++++------- sd/source/ui/framework/module/ToolBarModule.hxx | 4 +++- sd/source/ui/inc/DrawController.hxx | 10 +--------- sd/source/ui/inc/framework/DrawModule.hxx | 7 ++++++- sd/source/ui/inc/framework/ImpressModule.hxx | 7 ++++++- sd/source/ui/inc/framework/PresentationModule.hxx | 7 ++++++- sd/source/ui/sidebar/PanelFactory.cxx | 2 +- sd/source/ui/slidesorter/shell/SlideSorterService.cxx | 3 +-- sd/source/ui/unoidl/DrawController.cxx | 13 ------------- sd/source/ui/view/GraphicViewShellBase.cxx | 3 ++- sd/source/ui/view/ImpressViewShellBase.cxx | 5 +++-- sd/source/ui/view/PresentationViewShellBase.cxx | 4 ++-- sd/source/ui/view/ViewTabBar.cxx | 6 ++---- 23 files changed, 61 insertions(+), 70 deletions(-) (limited to 'sd/source/ui') diff --git a/sd/source/ui/framework/factories/BasicPaneFactory.cxx b/sd/source/ui/framework/factories/BasicPaneFactory.cxx index c01d315a3d9c..64cec425ad54 100644 --- a/sd/source/ui/framework/factories/BasicPaneFactory.cxx +++ b/sd/source/ui/framework/factories/BasicPaneFactory.cxx @@ -132,8 +132,7 @@ void SAL_CALL BasicPaneFactory::initialize (const Sequence& aArguments) // Tunnel through the controller to obtain access to the ViewShellBase. try { - Reference xTunnel (xController, UNO_QUERY_THROW); - if (auto pController = comphelper::getFromUnoTunnel(xTunnel)) + if (auto pController = dynamic_cast(xController.get())) mpViewShellBase = pController->GetViewShellBase(); } catch(RuntimeException&) diff --git a/sd/source/ui/framework/factories/BasicViewFactory.cxx b/sd/source/ui/framework/factories/BasicViewFactory.cxx index 5e862c6aebc2..6a6b8065e180 100644 --- a/sd/source/ui/framework/factories/BasicViewFactory.cxx +++ b/sd/source/ui/framework/factories/BasicViewFactory.cxx @@ -237,8 +237,7 @@ void SAL_CALL BasicViewFactory::initialize (const Sequence& aArguments) Reference xController (aArguments[0], UNO_QUERY_THROW); // Tunnel through the controller to obtain a ViewShellBase. - Reference xTunnel (xController, UNO_QUERY_THROW); - ::sd::DrawController* pController = comphelper::getFromUnoTunnel(xTunnel); + ::sd::DrawController* pController = dynamic_cast(xController.get()); if (pController != nullptr) mpBase = pController->GetViewShellBase(); diff --git a/sd/source/ui/framework/factories/PresentationFactory.cxx b/sd/source/ui/framework/factories/PresentationFactory.cxx index c1d408856187..73c2d4bdb732 100644 --- a/sd/source/ui/framework/factories/PresentationFactory.cxx +++ b/sd/source/ui/framework/factories/PresentationFactory.cxx @@ -113,7 +113,7 @@ void SAL_CALL PresentationFactory::releaseResource ( { ThrowIfDisposed(); - auto pController = comphelper::getFromUnoTunnel(mxController); + auto pController = dynamic_cast(mxController.get()); if (pController != nullptr) { ViewShellBase* pBase = pController->GetViewShellBase(); diff --git a/sd/source/ui/framework/module/CenterViewFocusModule.cxx b/sd/source/ui/framework/module/CenterViewFocusModule.cxx index f5de61ca65d6..2c799e04bbb1 100644 --- a/sd/source/ui/framework/module/CenterViewFocusModule.cxx +++ b/sd/source/ui/framework/module/CenterViewFocusModule.cxx @@ -39,20 +39,18 @@ namespace sd::framework { //===== CenterViewFocusModule ==================================================== -CenterViewFocusModule::CenterViewFocusModule (Reference const & rxController) +CenterViewFocusModule::CenterViewFocusModule (rtl::Reference const & rxController) : mbValid(false), mpBase(nullptr), mbNewViewCreated(false) { - Reference xControllerManager (rxController, UNO_QUERY); - if (xControllerManager.is()) + if (rxController.is()) { - mxConfigurationController = xControllerManager->getConfigurationController(); + mxConfigurationController = rxController->getConfigurationController(); // Tunnel through the controller to obtain a ViewShellBase. - auto pController = comphelper::getFromUnoTunnel(rxController); - if (pController != nullptr) - mpBase = pController->GetViewShellBase(); + if (rxController != nullptr) + mpBase = rxController->GetViewShellBase(); // Check, if all required objects do exist. if (mxConfigurationController.is() && mpBase!=nullptr) diff --git a/sd/source/ui/framework/module/CenterViewFocusModule.hxx b/sd/source/ui/framework/module/CenterViewFocusModule.hxx index c6d5d348e3b2..e721562db029 100644 --- a/sd/source/ui/framework/module/CenterViewFocusModule.hxx +++ b/sd/source/ui/framework/module/CenterViewFocusModule.hxx @@ -21,6 +21,7 @@ #include #include +#include namespace com::sun::star::drawing::framework { @@ -33,6 +34,7 @@ class XController; namespace sd { +class DrawController; class ViewShellBase; } @@ -49,8 +51,7 @@ typedef comphelper::WeakComponentImplHelper const& rxController); + explicit CenterViewFocusModule(rtl::Reference const& rxController); virtual ~CenterViewFocusModule() override; virtual void disposing(std::unique_lock&) override; diff --git a/sd/source/ui/framework/module/DrawModule.cxx b/sd/source/ui/framework/module/DrawModule.cxx index 17f4671fcb7f..aaa2d90bb38a 100644 --- a/sd/source/ui/framework/module/DrawModule.cxx +++ b/sd/source/ui/framework/module/DrawModule.cxx @@ -23,13 +23,14 @@ #include "CenterViewFocusModule.hxx" #include "SlideSorterModule.hxx" #include "ToolBarModule.hxx" +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; namespace sd::framework { -void DrawModule::Initialize(Reference const& rxController) +void DrawModule::Initialize(rtl::Reference const& rxController) { new sd::framework::CenterViewFocusModule(rxController); new sd::framework::SlideSorterModule(rxController, FrameworkHelper::msLeftDrawPaneURL); diff --git a/sd/source/ui/framework/module/ImpressModule.cxx b/sd/source/ui/framework/module/ImpressModule.cxx index 139b250fd002..f89212e4a0a8 100644 --- a/sd/source/ui/framework/module/ImpressModule.cxx +++ b/sd/source/ui/framework/module/ImpressModule.cxx @@ -25,13 +25,14 @@ #include "SlideSorterModule.hxx" #include "ToolBarModule.hxx" #include "ShellStackGuard.hxx" +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; namespace sd::framework { -void ImpressModule::Initialize (Reference const & rxController) +void ImpressModule::Initialize (rtl::Reference const & rxController) { new CenterViewFocusModule(rxController); new ViewTabBarModule( diff --git a/sd/source/ui/framework/module/PresentationModule.cxx b/sd/source/ui/framework/module/PresentationModule.cxx index fb0ac0558d80..c1ff16159d68 100644 --- a/sd/source/ui/framework/module/PresentationModule.cxx +++ b/sd/source/ui/framework/module/PresentationModule.cxx @@ -26,7 +26,7 @@ using namespace ::com::sun::star::uno; namespace sd::framework { -void PresentationModule::Initialize(Reference const& rxController) +void PresentationModule::Initialize(rtl::Reference const& rxController) { new sd::framework::CenterViewFocusModule(rxController); } diff --git a/sd/source/ui/framework/module/ShellStackGuard.cxx b/sd/source/ui/framework/module/ShellStackGuard.cxx index 83d73b055a54..d7dcfb0f2923 100644 --- a/sd/source/ui/framework/module/ShellStackGuard.cxx +++ b/sd/source/ui/framework/module/ShellStackGuard.cxx @@ -38,19 +38,16 @@ namespace sd::framework { //===== CenterViewFocusModule ==================================================== -ShellStackGuard::ShellStackGuard (Reference const & rxController) +ShellStackGuard::ShellStackGuard (rtl::Reference const & rxController) : mpBase(nullptr), maPrinterPollingIdle("sd ShellStackGuard PrinterPollingIdle") { - Reference xControllerManager (rxController, UNO_QUERY); - if (xControllerManager.is()) + if (rxController.is()) { - mxConfigurationController = xControllerManager->getConfigurationController(); + mxConfigurationController = rxController->getConfigurationController(); // Tunnel through the controller to obtain a ViewShellBase. - auto pController = comphelper::getFromUnoTunnel(rxController); - if (pController != nullptr) - mpBase = pController->GetViewShellBase(); + mpBase = rxController->GetViewShellBase(); } if (mxConfigurationController.is()) diff --git a/sd/source/ui/framework/module/ShellStackGuard.hxx b/sd/source/ui/framework/module/ShellStackGuard.hxx index 72b7ed2c6603..fe94037816f9 100644 --- a/sd/source/ui/framework/module/ShellStackGuard.hxx +++ b/sd/source/ui/framework/module/ShellStackGuard.hxx @@ -23,6 +23,7 @@ #include +#include #include #include #include @@ -38,6 +39,7 @@ class XController; namespace sd { +class DrawController; class ViewShellBase; } @@ -59,7 +61,7 @@ typedef comphelper::WeakComponentImplHelper const& rxController); + explicit ShellStackGuard(rtl::Reference const& rxController); virtual ~ShellStackGuard() override; virtual void disposing(std::unique_lock&) override; diff --git a/sd/source/ui/framework/module/ToolBarModule.cxx b/sd/source/ui/framework/module/ToolBarModule.cxx index 3cecf7b031f0..de7f3e583126 100644 --- a/sd/source/ui/framework/module/ToolBarModule.cxx +++ b/sd/source/ui/framework/module/ToolBarModule.cxx @@ -41,20 +41,18 @@ namespace sd::framework { //===== ToolBarModule ========================================================= ToolBarModule::ToolBarModule ( - const Reference& rxController) + const rtl::Reference& rxController) : mpBase(nullptr), mbMainViewSwitchUpdatePending(false) { // Tunnel through the controller to obtain a ViewShellBase. - auto pController = comphelper::getFromUnoTunnel(rxController); - if (pController != nullptr) - mpBase = pController->GetViewShellBase(); + if (rxController != nullptr) + mpBase = rxController->GetViewShellBase(); - Reference xControllerManager (rxController, UNO_QUERY); - if (!xControllerManager.is()) + if (!rxController.is()) return; - mxConfigurationController = xControllerManager->getConfigurationController(); + mxConfigurationController = rxController->getConfigurationController(); if (!mxConfigurationController.is()) return; diff --git a/sd/source/ui/framework/module/ToolBarModule.hxx b/sd/source/ui/framework/module/ToolBarModule.hxx index f9189657de04..bf0c017ef981 100644 --- a/sd/source/ui/framework/module/ToolBarModule.hxx +++ b/sd/source/ui/framework/module/ToolBarModule.hxx @@ -23,12 +23,14 @@ #include #include #include +#include #include namespace com::sun::star::drawing::framework { class XConfigurationController; } namespace com::sun::star::frame { class XController; } namespace sd { +class DrawController; class ViewShellBase; } @@ -50,7 +52,7 @@ public: This is the access point to the drawing framework. */ explicit ToolBarModule ( - const css::uno::Reference& rxController); + const rtl::Reference& rxController); virtual ~ToolBarModule() override; virtual void disposing(std::unique_lock&) override; diff --git a/sd/source/ui/inc/DrawController.hxx b/sd/source/ui/inc/DrawController.hxx index 2c15e26eb601..c2f4f7be215d 100644 --- a/sd/source/ui/inc/DrawController.hxx +++ b/sd/source/ui/inc/DrawController.hxx @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -51,8 +50,7 @@ typedef ::cppu::ImplInheritanceHelper < css::drawing::XDrawView, css::view::XSelectionChangeListener, css::view::XFormLayerAccess, - css::drawing::framework::XControllerManager, - css::lang::XUnoTunnel + css::drawing::framework::XControllerManager > DrawControllerInterfaceBase; class BroadcastHelperOwner @@ -159,8 +157,6 @@ public: */ void ReleaseViewShellBase(); - static const css::uno::Sequence& getUnoTunnelId(); - DECLARE_XINTERFACE() DECLARE_XTYPEPROVIDER() @@ -220,10 +216,6 @@ public: virtual css::uno::Reference SAL_CALL getModuleController() override; - // XUnoTunnel - - virtual sal_Int64 SAL_CALL getSomething (const css::uno::Sequence& rId) override; - private: /** This method must return the name to index table. This table contains all property names and types of this object. diff --git a/sd/source/ui/inc/framework/DrawModule.hxx b/sd/source/ui/inc/framework/DrawModule.hxx index 79a59b4f9030..819091998687 100644 --- a/sd/source/ui/inc/framework/DrawModule.hxx +++ b/sd/source/ui/inc/framework/DrawModule.hxx @@ -20,6 +20,7 @@ #pragma once #include +#include namespace com::sun::star::frame { @@ -29,6 +30,10 @@ namespace com::sun::star::uno { template class Reference; } +namespace sd +{ +class DrawController; +} namespace sd::framework { @@ -38,7 +43,7 @@ namespace sd::framework class DrawModule { public: - static void Initialize(css::uno::Reference const& rxController); + static void Initialize(rtl::Reference const& rxController); }; } // end of namespace sd::framework diff --git a/sd/source/ui/inc/framework/ImpressModule.hxx b/sd/source/ui/inc/framework/ImpressModule.hxx index da7ede9d9952..fc4e2b83978d 100644 --- a/sd/source/ui/inc/framework/ImpressModule.hxx +++ b/sd/source/ui/inc/framework/ImpressModule.hxx @@ -20,6 +20,7 @@ #pragma once #include +#include namespace com::sun::star::frame { @@ -29,6 +30,10 @@ namespace com::sun::star::uno { template class Reference; } +namespace sd +{ +class DrawController; +} namespace sd::framework { @@ -38,7 +43,7 @@ namespace sd::framework class ImpressModule { public: - static void Initialize(css::uno::Reference const& rxController); + static void Initialize(rtl::Reference const& rxController); }; } // end of namespace sd::framework diff --git a/sd/source/ui/inc/framework/PresentationModule.hxx b/sd/source/ui/inc/framework/PresentationModule.hxx index f6dcfbc695da..437534f707f9 100644 --- a/sd/source/ui/inc/framework/PresentationModule.hxx +++ b/sd/source/ui/inc/framework/PresentationModule.hxx @@ -20,6 +20,7 @@ #pragma once #include +#include namespace com::sun::star::frame { @@ -29,6 +30,10 @@ namespace com::sun::star::uno { template class Reference; } +namespace sd +{ +class DrawController; +} namespace sd::framework { @@ -38,7 +43,7 @@ namespace sd::framework class PresentationModule { public: - static void Initialize(css::uno::Reference const& rxController); + static void Initialize(rtl::Reference const& rxController); }; } // end of namespace sd::framework diff --git a/sd/source/ui/sidebar/PanelFactory.cxx b/sd/source/ui/sidebar/PanelFactory.cxx index c7ca8c25c4c8..752f3db7f1ac 100644 --- a/sd/source/ui/sidebar/PanelFactory.cxx +++ b/sd/source/ui/sidebar/PanelFactory.cxx @@ -79,7 +79,7 @@ Reference SAL_CALL PanelFactory::createUIElement ( // Tunnel through the controller to obtain a ViewShellBase. ViewShellBase* pBase = nullptr; - auto pController = comphelper::getFromUnoTunnel(xFrame->getController()); + rtl::Reference pController = dynamic_cast(xFrame->getController().get()); if (pController != nullptr) pBase = pController->GetViewShellBase(); if (pBase == nullptr) diff --git a/sd/source/ui/slidesorter/shell/SlideSorterService.cxx b/sd/source/ui/slidesorter/shell/SlideSorterService.cxx index a086f3b9e209..fa65cba421b4 100644 --- a/sd/source/ui/slidesorter/shell/SlideSorterService.cxx +++ b/sd/source/ui/slidesorter/shell/SlideSorterService.cxx @@ -78,8 +78,7 @@ void SAL_CALL SlideSorterService::initialize (const Sequence& rArguments) // Tunnel through the controller to obtain a ViewShellBase. ViewShellBase* pBase = nullptr; - Reference xTunnel (xController, UNO_QUERY_THROW); - ::sd::DrawController* pController = comphelper::getFromUnoTunnel(xTunnel); + ::sd::DrawController* pController = dynamic_cast(xController.get()); if (pController != nullptr) pBase = pController->GetViewShellBase(); diff --git a/sd/source/ui/unoidl/DrawController.cxx b/sd/source/ui/unoidl/DrawController.cxx index 41c30e23e45d..f33e9038131f 100644 --- a/sd/source/ui/unoidl/DrawController.cxx +++ b/sd/source/ui/unoidl/DrawController.cxx @@ -551,19 +551,6 @@ Reference SAL_CALL return mxModuleController; } -//===== XUnoTunnel ============================================================ - -const Sequence& DrawController::getUnoTunnelId() -{ - static const comphelper::UnoIdInit theDrawControllerUnoTunnelId; - return theDrawControllerUnoTunnelId.getSeq(); -} - -sal_Int64 SAL_CALL DrawController::getSomething (const Sequence& rId) -{ - return comphelper::getSomethingImpl(rId, this); -} - //===== Properties ============================================================ void DrawController::FillPropertyTable ( diff --git a/sd/source/ui/view/GraphicViewShellBase.cxx b/sd/source/ui/view/GraphicViewShellBase.cxx index d58c8a0d2479..573c9fc2a058 100644 --- a/sd/source/ui/view/GraphicViewShellBase.cxx +++ b/sd/source/ui/view/GraphicViewShellBase.cxx @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -84,7 +85,7 @@ void GraphicViewShellBase::Execute(SfxRequest& rRequest) void GraphicViewShellBase::InitializeFramework() { - css::uno::Reference xController(GetController()); + rtl::Reference xController(&GetDrawController()); sd::framework::DrawModule::Initialize(xController); } diff --git a/sd/source/ui/view/ImpressViewShellBase.cxx b/sd/source/ui/view/ImpressViewShellBase.cxx index 96b0b5aa9154..9b28213970ec 100644 --- a/sd/source/ui/view/ImpressViewShellBase.cxx +++ b/sd/source/ui/view/ImpressViewShellBase.cxx @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -87,8 +88,8 @@ void ImpressViewShellBase::Execute (SfxRequest& rRequest) void ImpressViewShellBase::InitializeFramework() { - css::uno::Reference - xController (GetController()); + rtl::Reference + xController (&GetDrawController()); sd::framework::ImpressModule::Initialize(xController); } diff --git a/sd/source/ui/view/PresentationViewShellBase.cxx b/sd/source/ui/view/PresentationViewShellBase.cxx index 789afbbdde86..9c1faff02713 100644 --- a/sd/source/ui/view/PresentationViewShellBase.cxx +++ b/sd/source/ui/view/PresentationViewShellBase.cxx @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -84,8 +85,7 @@ PresentationViewShellBase::~PresentationViewShellBase() void PresentationViewShellBase::InitializeFramework() { - css::uno::Reference - xController (GetController()); + rtl::Reference xController (&GetDrawController()); sd::framework::PresentationModule::Initialize(xController); } diff --git a/sd/source/ui/view/ViewTabBar.cxx b/sd/source/ui/view/ViewTabBar.cxx index d9fdd2addfdf..6e9f23e3b674 100644 --- a/sd/source/ui/view/ViewTabBar.cxx +++ b/sd/source/ui/view/ViewTabBar.cxx @@ -70,8 +70,7 @@ ViewTabBar::ViewTabBar ( // view frame. try { - Reference xTunnel (mxController, UNO_QUERY_THROW); - if (auto pController = comphelper::getFromUnoTunnel(xTunnel)) + if (auto pController = dynamic_cast(mxController.get())) mpViewShellBase = pController->GetViewShellBase(); } catch (const RuntimeException&) @@ -149,8 +148,7 @@ vcl::Window* ViewTabBar::GetAnchorWindow( // view frame. try { - Reference xTunnel (rxController, UNO_QUERY_THROW); - if (auto pController = comphelper::getFromUnoTunnel(xTunnel)) + if (auto pController = dynamic_cast(rxController.get())) pBase = pController->GetViewShellBase(); } catch (const RuntimeException&) -- cgit v1.2.3