sd/source/ui/inc/ViewTabBar.hxx  |    7 ++++---
 sd/source/ui/view/ViewTabBar.cxx |   35 ++++++++++-------------------------
 2 files changed, 14 insertions(+), 28 deletions(-)

New commits:
commit 6b1f83880372868fb61c84dbe3230910cdbb386f
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Jan 25 10:29:12 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Jan 26 08:32:42 2023 +0000

    use more concrete types in sd
    
    Change-Id: I545858fe18e8a436fd2dda7402c825eac28fb2fa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146156
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sd/source/ui/inc/ViewTabBar.hxx b/sd/source/ui/inc/ViewTabBar.hxx
index 61670cc1432b..36c2aa6f84a7 100644
--- a/sd/source/ui/inc/ViewTabBar.hxx
+++ b/sd/source/ui/inc/ViewTabBar.hxx
@@ -35,6 +35,7 @@ namespace com::sun::star::frame { class XController; }
 namespace vcl { class Window; }
 
 namespace sd {
+    class DrawController;
     class ViewShellBase;
     class ViewTabBar;
 }
@@ -72,7 +73,7 @@ class ViewTabBar final
 public:
     ViewTabBar (
         const css::uno::Reference< css::drawing::framework::XResourceId>& 
rxViewTabBarId,
-        const css::uno::Reference< css::frame::XController>& rxController);
+        const rtl::Reference< ::sd::DrawController>& rxController);
     virtual ~ViewTabBar() override;
 
     virtual void disposing(std::unique_lock<std::mutex>&) override;
@@ -148,7 +149,7 @@ public:
 
 private:
     VclPtr<TabBarControl> mpTabControl;
-    css::uno::Reference<css::frame::XController> mxController;
+    rtl::Reference<::sd::DrawController> mxController;
     css::uno::Reference<css::drawing::framework::XConfigurationController> 
mxConfigurationController;
     typedef ::std::vector<css::drawing::framework::TabBarButton> 
TabBarButtonList;
     TabBarButtonList maTabBarButtons;
@@ -168,7 +169,7 @@ private:
     */
     static vcl::Window* GetAnchorWindow(
         const css::uno::Reference<css::drawing::framework::XResourceId>& 
rxViewTabBarId,
-        const css::uno::Reference<css::frame::XController>& rxController);
+        const rtl::Reference<::sd::DrawController>& rxController);
 };
 
 } // end of namespace sd
diff --git a/sd/source/ui/view/ViewTabBar.cxx b/sd/source/ui/view/ViewTabBar.cxx
index 09925e32d37b..81f71b12638e 100644
--- a/sd/source/ui/view/ViewTabBar.cxx
+++ b/sd/source/ui/view/ViewTabBar.cxx
@@ -59,7 +59,7 @@ bool IsEqual (const TabBarButton& rButton1, const 
TabBarButton& rButton2)
 
 ViewTabBar::ViewTabBar (
     const Reference<XResourceId>& rxViewTabBarId,
-    const Reference<frame::XController>& rxController)
+    const rtl::Reference<::sd::DrawController>& rxController)
     : 
mpTabControl(VclPtr<TabBarControl>::Create(GetAnchorWindow(rxViewTabBarId,rxController),
 this)),
       mxController(rxController),
       mxViewTabBarId(rxViewTabBarId),
@@ -68,20 +68,13 @@ ViewTabBar::ViewTabBar (
 {
     // Tunnel through the controller and use the ViewShellBase to obtain the
     // view frame.
-    try
-    {
-        if (auto pController = 
dynamic_cast<DrawController*>(mxController.get()))
-            mpViewShellBase = pController->GetViewShellBase();
-    }
-    catch (const RuntimeException&)
-    {
-    }
+    if (mxController)
+        mpViewShellBase = mxController->GetViewShellBase();
 
     // Register as listener at XConfigurationController.
-    Reference<XControllerManager> xControllerManager (mxController, UNO_QUERY);
-    if (xControllerManager.is())
+    if (mxController.is())
     {
-        mxConfigurationController = 
xControllerManager->getConfigurationController();
+        mxConfigurationController = mxController->getConfigurationController();
         if (mxConfigurationController.is())
         {
             mxConfigurationController->addConfigurationChangeListener(
@@ -139,21 +132,15 @@ void ViewTabBar::disposing(std::unique_lock<std::mutex>&)
 
 vcl::Window* ViewTabBar::GetAnchorWindow(
     const Reference<XResourceId>& rxViewTabBarId,
-    const Reference<frame::XController>& rxController)
+    const rtl::Reference<::sd::DrawController>& rxController)
 {
     vcl::Window* pWindow = nullptr;
     ViewShellBase* pBase = nullptr;
 
     // Tunnel through the controller and use the ViewShellBase to obtain the
     // view frame.
-    try
-    {
-        if (auto pController = 
dynamic_cast<DrawController*>(rxController.get()))
-            pBase = pController->GetViewShellBase();
-    }
-    catch (const RuntimeException&)
-    {
-    }
+    if (rxController)
+        pBase = rxController->GetViewShellBase();
 
     // The ViewTabBar supports at the moment only the center pane.
     if (rxViewTabBarId.is()
@@ -170,9 +157,8 @@ vcl::Window* ViewTabBar::GetAnchorWindow(
         Reference<XPane> xPane;
         try
         {
-            Reference<XControllerManager> xControllerManager (rxController, 
UNO_QUERY_THROW);
             Reference<XConfigurationController> xCC (
-                xControllerManager->getConfigurationController());
+                rxController->getConfigurationController());
             if (xCC.is())
                 xPane.set(xCC->getResource(rxViewTabBarId->getAnchor()), 
UNO_QUERY);
         }
@@ -269,9 +255,8 @@ bool ViewTabBar::ActivatePage(size_t nIndex)
 {
     try
     {
-        Reference<XControllerManager> xControllerManager 
(mxController,UNO_QUERY_THROW);
         Reference<XConfigurationController> xConfigurationController (
-            xControllerManager->getConfigurationController());
+            mxController->getConfigurationController());
         if ( ! xConfigurationController.is())
             throw RuntimeException();
         Reference<XView> xView;

Reply via email to