[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Dec 4 16:38:32 UTC 2019


 include/vcl/weldutils.hxx                 |  128 ++++++++++++++++++++++++++++++
 vcl/inc/unx/gtk/gtkinst.hxx               |   99 +----------------------
 vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx |    2 
 3 files changed, 136 insertions(+), 93 deletions(-)

New commits:
commit 20d5f61abfd47fc76da3be8241653fdb7ae10491
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Nov 13 21:28:12 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Dec 4 17:37:34 2019 +0100

    factor out 'weld::Widget as XWindow'
    
    Change-Id: I24b52c5b8908fdf1a66fd26b2dc438b9557afa6e
    Reviewed-on: https://gerrit.libreoffice.org/82641
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/weldutils.hxx b/include/vcl/weldutils.hxx
index 4144803e8b3d..764d343902df 100644
--- a/include/vcl/weldutils.hxx
+++ b/include/vcl/weldutils.hxx
@@ -10,8 +10,11 @@
 #ifndef INCLUDED_VCL_WELDUTILS_HXX
 #define INCLUDED_VCL_WELDUTILS_HXX
 
+#include <com/sun/star/awt/XWindow.hpp>
 #include <com/sun/star/frame/XFrame.hpp>
 #include <com/sun/star/uno/Reference.hxx>
+#include <comphelper/interfacecontainer2.hxx>
+#include <cppuhelper/compbase.hxx>
 #include <tools/link.hxx>
 #include <vcl/dllapi.h>
 
@@ -29,6 +32,131 @@ public:
     // fill in the label and icons for actions and dispatch the action on item click
     ToolbarUnoDispatcher(Toolbar& rToolbar, const css::uno::Reference<css::frame::XFrame>& rFrame);
 };
+
+typedef cppu::WeakComponentImplHelper<css::awt::XWindow> TransportAsXWindow_Base;
+
+class VCL_DLLPUBLIC TransportAsXWindow : public TransportAsXWindow_Base
+{
+private:
+    osl::Mutex m_aHelperMtx;
+    weld::Widget* m_pWeldWidget;
+
+    comphelper::OInterfaceContainerHelper2 m_aWindowListeners;
+    comphelper::OInterfaceContainerHelper2 m_aKeyListeners;
+    comphelper::OInterfaceContainerHelper2 m_aFocusListeners;
+    comphelper::OInterfaceContainerHelper2 m_aMouseListeners;
+    comphelper::OInterfaceContainerHelper2 m_aMotionListeners;
+    comphelper::OInterfaceContainerHelper2 m_aPaintListeners;
+
+public:
+    TransportAsXWindow(weld::Widget* pWeldWidget)
+        : TransportAsXWindow_Base(m_aHelperMtx)
+        , m_pWeldWidget(pWeldWidget)
+        , m_aWindowListeners(m_aHelperMtx)
+        , m_aKeyListeners(m_aHelperMtx)
+        , m_aFocusListeners(m_aHelperMtx)
+        , m_aMouseListeners(m_aHelperMtx)
+        , m_aMotionListeners(m_aHelperMtx)
+        , m_aPaintListeners(m_aHelperMtx)
+    {
+    }
+
+    weld::Widget* getWidget() const { return m_pWeldWidget; }
+
+    virtual void clear() { m_pWeldWidget = nullptr; }
+
+    // css::awt::XWindow
+    void SAL_CALL setPosSize(sal_Int32, sal_Int32, sal_Int32, sal_Int32, sal_Int16) override
+    {
+        throw css::uno::RuntimeException("not implemented");
+    }
+
+    css::awt::Rectangle SAL_CALL getPosSize() override
+    {
+        throw css::uno::RuntimeException("not implemented");
+    }
+
+    void SAL_CALL setVisible(sal_Bool bVisible) override { m_pWeldWidget->set_visible(bVisible); }
+
+    void SAL_CALL setEnable(sal_Bool bSensitive) override
+    {
+        m_pWeldWidget->set_sensitive(bSensitive);
+    }
+
+    void SAL_CALL setFocus() override { m_pWeldWidget->grab_focus(); }
+
+    void SAL_CALL
+    addWindowListener(const css::uno::Reference<css::awt::XWindowListener>& rListener) override
+    {
+        m_aWindowListeners.addInterface(rListener);
+    }
+
+    void SAL_CALL
+    removeWindowListener(const css::uno::Reference<css::awt::XWindowListener>& rListener) override
+    {
+        m_aWindowListeners.removeInterface(rListener);
+    }
+
+    void SAL_CALL
+    addFocusListener(const css::uno::Reference<css::awt::XFocusListener>& rListener) override
+    {
+        m_aFocusListeners.addInterface(rListener);
+    }
+
+    void SAL_CALL
+    removeFocusListener(const css::uno::Reference<css::awt::XFocusListener>& rListener) override
+    {
+        m_aFocusListeners.removeInterface(rListener);
+    }
+
+    void SAL_CALL
+    addKeyListener(const css::uno::Reference<css::awt::XKeyListener>& rListener) override
+    {
+        m_aKeyListeners.addInterface(rListener);
+    }
+
+    void SAL_CALL
+    removeKeyListener(const css::uno::Reference<css::awt::XKeyListener>& rListener) override
+    {
+        m_aKeyListeners.removeInterface(rListener);
+    }
+
+    void SAL_CALL
+    addMouseListener(const css::uno::Reference<css::awt::XMouseListener>& rListener) override
+    {
+        m_aMouseListeners.addInterface(rListener);
+    }
+
+    void SAL_CALL
+    removeMouseListener(const css::uno::Reference<css::awt::XMouseListener>& rListener) override
+    {
+        m_aMouseListeners.removeInterface(rListener);
+    }
+
+    void SAL_CALL addMouseMotionListener(
+        const css::uno::Reference<css::awt::XMouseMotionListener>& rListener) override
+    {
+        m_aMotionListeners.addInterface(rListener);
+    }
+
+    void SAL_CALL removeMouseMotionListener(
+        const css::uno::Reference<css::awt::XMouseMotionListener>& rListener) override
+    {
+        m_aMotionListeners.removeInterface(rListener);
+    }
+
+    void SAL_CALL
+    addPaintListener(const css::uno::Reference<css::awt::XPaintListener>& rListener) override
+    {
+        m_aPaintListeners.addInterface(rListener);
+    }
+
+    void SAL_CALL
+    removePaintListener(const css::uno::Reference<css::awt::XPaintListener>& rListener) override
+    {
+        m_aPaintListeners.removeInterface(rListener);
+    }
+};
 }
 
 #endif
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index b4a516b3a28a..1e0f86cf2cf2 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -34,6 +34,8 @@
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/awt/XWindow.hpp>
 #include <cppuhelper/compbase.hxx>
+#include <vcl/weld.hxx>
+#include <vcl/weldutils.hxx>
 #include <gtk/gtk.h>
 
 namespace vcl
@@ -257,30 +259,28 @@ private:
     mutable std::shared_ptr<vcl::unx::GtkPrintWrapper> m_xPrintWrapper;
 };
 
-typedef cppu::WeakComponentImplHelper<css::awt::XWindow> SalGtkXWindow_Base;
-
-class SalGtkXWindow final : public SalGtkXWindow_Base
+class SalGtkXWindow final : public weld::TransportAsXWindow
 {
 private:
-    osl::Mutex m_aHelperMtx;
     weld::Window* m_pWeldWidget;
     GtkWidget* m_pWidget;
 public:
 
     SalGtkXWindow(weld::Window* pWeldWidget, GtkWidget* pWidget)
-        : SalGtkXWindow_Base(m_aHelperMtx)
+        : TransportAsXWindow(pWeldWidget)
         , m_pWeldWidget(pWeldWidget)
         , m_pWidget(pWidget)
     {
     }
 
-    void clear()
+    virtual void clear() override
     {
         m_pWeldWidget = nullptr;
         m_pWidget = nullptr;
+        TransportAsXWindow::clear();
     }
 
-    GtkWidget* getWidget() const
+    GtkWidget* getGtkWidget() const
     {
         return m_pWidget;
     }
@@ -289,91 +289,6 @@ public:
     {
         return m_pWeldWidget;
     }
-
-    // css::awt::XWindow
-    void SAL_CALL setPosSize(sal_Int32, sal_Int32, sal_Int32, sal_Int32, sal_Int16) override
-    {
-        throw css::uno::RuntimeException("not implemented");
-    }
-
-    css::awt::Rectangle SAL_CALL getPosSize() override
-    {
-        throw css::uno::RuntimeException("not implemented");
-    }
-
-    void SAL_CALL setVisible(sal_Bool) override
-    {
-        throw css::uno::RuntimeException("not implemented");
-    }
-
-    void SAL_CALL setEnable(sal_Bool) override
-    {
-        throw css::uno::RuntimeException("not implemented");
-    }
-
-    void SAL_CALL setFocus() override
-    {
-        throw css::uno::RuntimeException("not implemented");
-    }
-
-    void SAL_CALL addWindowListener(const css::uno::Reference< css::awt::XWindowListener >& ) override
-    {
-        throw css::uno::RuntimeException("not implemented");
-    }
-    void SAL_CALL removeWindowListener(const css::uno::Reference< css::awt::XWindowListener >& ) override
-    {
-        throw css::uno::RuntimeException("not implemented");
-    }
-
-    void SAL_CALL addFocusListener(const css::uno::Reference< css::awt::XFocusListener >& ) override
-    {
-        throw css::uno::RuntimeException("not implemented");
-    }
-
-    void SAL_CALL removeFocusListener(const css::uno::Reference< css::awt::XFocusListener >& ) override
-    {
-        throw css::uno::RuntimeException("not implemented");
-    }
-
-    void SAL_CALL addKeyListener(const css::uno::Reference< css::awt::XKeyListener >& ) override
-    {
-        throw css::uno::RuntimeException("not implemented");
-    }
-
-    void SAL_CALL removeKeyListener(const css::uno::Reference< css::awt::XKeyListener >& ) override
-    {
-        throw css::uno::RuntimeException("not implemented");
-    }
-
-    void SAL_CALL addMouseListener(const css::uno::Reference< css::awt::XMouseListener >& ) override
-    {
-        throw css::uno::RuntimeException("not implemented");
-    }
-
-    void SAL_CALL removeMouseListener(const css::uno::Reference< css::awt::XMouseListener >& ) override
-    {
-        throw css::uno::RuntimeException("not implemented");
-    }
-
-    void SAL_CALL addMouseMotionListener(const css::uno::Reference< css::awt::XMouseMotionListener >& ) override
-    {
-        throw css::uno::RuntimeException("not implemented");
-    }
-
-    void SAL_CALL removeMouseMotionListener(const css::uno::Reference< css::awt::XMouseMotionListener >& ) override
-    {
-        throw css::uno::RuntimeException("not implemented");
-    }
-
-    void SAL_CALL addPaintListener(const css::uno::Reference< css::awt::XPaintListener >& ) override
-    {
-        throw css::uno::RuntimeException("not implemented");
-    }
-
-    void SAL_CALL removePaintListener(const css::uno::Reference< css::awt::XPaintListener >& ) override
-    {
-        throw css::uno::RuntimeException("not implemented");
-    }
 };
 
 GdkPixbuf* load_icon_by_name(const OUString& rIconName);
diff --git a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx
index 5cfab0ada3aa..1015fcf67992 100644
--- a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx
+++ b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx
@@ -1580,7 +1580,7 @@ void SAL_CALL SalGtkFilePicker::initialize( const uno::Sequence<uno::Any>& aArgu
     if (xParentWindow.is())
     {
         if (SalGtkXWindow* pGtkXWindow = dynamic_cast<SalGtkXWindow*>(xParentWindow.get()))
-            m_pParentWidget = pGtkXWindow->getWidget();
+            m_pParentWidget = pGtkXWindow->getGtkWidget();
         else
         {
             css::uno::Reference<css::awt::XSystemDependentWindowPeer> xSysDepWin(xParentWindow, css::uno::UNO_QUERY);


More information about the Libreoffice-commits mailing list