svx/source/devtools/DevelopmentToolDockingWindow.cxx |   58 --------------
 svx/source/devtools/SelectionChangeHandler.hxx       |   74 +++++++++++++++++++
 2 files changed, 77 insertions(+), 55 deletions(-)

New commits:
commit 187305951fc76805198cd63cbb955aa1576690ac
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri Feb 5 17:39:05 2021 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Thu Feb 11 00:32:32 2021 +0100

    devtools: move SelectionChangeHandler to its own file
    
    Change-Id: I78d3712caedeb2ad4741e3706beb43051a978801
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110466
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/svx/source/devtools/DevelopmentToolDockingWindow.cxx 
b/svx/source/devtools/DevelopmentToolDockingWindow.cxx
index d7dbd5731022..9ba52a5d5751 100644
--- a/svx/source/devtools/DevelopmentToolDockingWindow.cxx
+++ b/svx/source/devtools/DevelopmentToolDockingWindow.cxx
@@ -41,68 +41,16 @@
 #include <sfx2/viewfrm.hxx>
 
 #include <com/sun/star/frame/XController.hpp>
-#include <com/sun/star/view/XSelectionSupplier.hpp>
 
 #include <cppuhelper/compbase.hxx>
 #include <cppuhelper/basemutex.hxx>
 
+#include "SelectionChangeHandler.hxx"
+
 using namespace css;
 
 namespace
 {
-typedef cppu::WeakComponentImplHelper<css::view::XSelectionChangeListener>
-    SelectionChangeHandlerInterfaceBase;
-
-class SelectionChangeHandler final : private ::cppu::BaseMutex,
-                                     public SelectionChangeHandlerInterfaceBase
-{
-private:
-    css::uno::Reference<css::frame::XController> mxController;
-    VclPtr<DevelopmentToolDockingWindow> mpDockingWindow;
-
-public:
-    SelectionChangeHandler(const css::uno::Reference<css::frame::XController>& 
rxController,
-                           DevelopmentToolDockingWindow* pDockingWindow)
-        : SelectionChangeHandlerInterfaceBase(m_aMutex)
-        , mxController(rxController)
-        , mpDockingWindow(pDockingWindow)
-    {
-        connect();
-    }
-
-    ~SelectionChangeHandler() { mpDockingWindow.disposeAndClear(); }
-
-    virtual void SAL_CALL selectionChanged(const css::lang::EventObject& 
/*rEvent*/) override
-    {
-        uno::Reference<view::XSelectionSupplier> xSupplier(mxController, 
uno::UNO_QUERY);
-        if (xSupplier.is())
-        {
-            uno::Any aAny = xSupplier->getSelection();
-            auto xInterface = aAny.get<uno::Reference<uno::XInterface>>();
-            mpDockingWindow->selectionChanged(xInterface);
-        }
-    }
-
-    void connect()
-    {
-        uno::Reference<view::XSelectionSupplier> xSupplier(mxController, 
uno::UNO_QUERY);
-        xSupplier->addSelectionChangeListener(this);
-    }
-
-    void disconnect()
-    {
-        uno::Reference<view::XSelectionSupplier> xSupplier(mxController, 
uno::UNO_QUERY);
-        xSupplier->removeSelectionChangeListener(this);
-    }
-
-    virtual void SAL_CALL disposing(const css::lang::EventObject& /*rEvent*/) 
override {}
-    virtual void SAL_CALL disposing() override {}
-
-private:
-    SelectionChangeHandler(const SelectionChangeHandler&) = delete;
-    SelectionChangeHandler& operator=(const SelectionChangeHandler&) = delete;
-};
-
 uno::Reference<reflection::XIdlClass>
 TypeToIdlClass(const uno::Type& rType, const 
uno::Reference<uno::XComponentContext>& xContext)
 {
@@ -568,7 +516,7 @@ void DevelopmentToolDockingWindow::dispose()
     auto* pSelectionChangeHandler
         = dynamic_cast<SelectionChangeHandler*>(mxSelectionListener.get());
     if (pSelectionChangeHandler)
-        pSelectionChangeHandler->disconnect();
+        pSelectionChangeHandler->stopListening();
 
     mxSelectionListener = uno::Reference<view::XSelectionChangeListener>();
     maDocumentModelTreeHandler.dispose();
diff --git a/svx/source/devtools/SelectionChangeHandler.hxx 
b/svx/source/devtools/SelectionChangeHandler.hxx
new file mode 100644
index 000000000000..b719eb5ee916
--- /dev/null
+++ b/svx/source/devtools/SelectionChangeHandler.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+#include <memory>
+
+#include <svx/devtools/DevelopmentToolDockingWindow.hxx>
+
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+
+#include <cppuhelper/compbase.hxx>
+#include <cppuhelper/basemutex.hxx>
+
+typedef cppu::WeakComponentImplHelper<css::view::XSelectionChangeListener>
+    SelectionChangeHandlerInterfaceBase;
+
+class SelectionChangeHandler final : private ::cppu::BaseMutex,
+                                     public SelectionChangeHandlerInterfaceBase
+{
+private:
+    css::uno::Reference<css::frame::XController> mxController;
+    VclPtr<DevelopmentToolDockingWindow> mpDockingWindow;
+
+public:
+    SelectionChangeHandler(const css::uno::Reference<css::frame::XController>& 
rxController,
+                           DevelopmentToolDockingWindow* pDockingWindow)
+        : SelectionChangeHandlerInterfaceBase(m_aMutex)
+        , mxController(rxController)
+        , mpDockingWindow(pDockingWindow)
+    {
+        css::uno::Reference<css::view::XSelectionSupplier> 
xSupplier(mxController,
+                                                                     
css::uno::UNO_QUERY);
+        xSupplier->addSelectionChangeListener(this);
+    }
+
+    ~SelectionChangeHandler() { mpDockingWindow.disposeAndClear(); }
+
+    virtual void SAL_CALL selectionChanged(const css::lang::EventObject& 
/*rEvent*/) override
+    {
+        css::uno::Reference<css::view::XSelectionSupplier> 
xSupplier(mxController,
+                                                                     
css::uno::UNO_QUERY);
+        if (xSupplier.is())
+        {
+            css::uno::Any aAny = xSupplier->getSelection();
+            auto xInterface = 
aAny.get<css::uno::Reference<css::uno::XInterface>>();
+            mpDockingWindow->selectionChanged(xInterface);
+        }
+    }
+
+    void stopListening()
+    {
+        css::uno::Reference<css::view::XSelectionSupplier> 
xSupplier(mxController,
+                                                                     
css::uno::UNO_QUERY);
+        xSupplier->removeSelectionChangeListener(this);
+    }
+
+    virtual void SAL_CALL disposing(const css::lang::EventObject& /*rEvent*/) 
override {}
+    virtual void SAL_CALL disposing() override {}
+
+private:
+    SelectionChangeHandler(const SelectionChangeHandler&) = delete;
+    SelectionChangeHandler& operator=(const SelectionChangeHandler&) = delete;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to