vcl/inc/qt5/QtDragAndDrop.hxx |   27 ++++------------
 vcl/inc/unx/gtk/gtkinst.hxx   |   22 ++++++-------
 vcl/qt5/QtDragAndDrop.cxx     |   62 ++++++++++---------------------------
 vcl/qt5/QtInstance.cxx        |    8 +++-
 vcl/unx/gtk3/gtkinst.cxx      |   70 +++++++++++++++---------------------------
 5 files changed, 65 insertions(+), 124 deletions(-)

New commits:
commit 0e808d1d87d7294b6d6f35e6ec68803c42b5298a
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri May 9 14:54:41 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sat May 10 17:32:30 2025 +0200

    tdf#164380 gtk: No longer use vcl::X11DnDHelper, XInitialization
    
    This is the gtk3/gtk4 version of
    
        Change-Id: Ia8a4d305dfcb3916ba44596b31614e2467701514
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Fri May 9 14:27:58 2025 +0200
    
            tdf#164380 qt: No longer use vcl::X11DnDHelper, XInitialization
    
    , see that commit's message for more details.
    
    For the GTK based VCL plugins, leave the default
    ctor for both classes in place, because that one is
    also called from elsewhere; but there, XInitialization::initialize
    is not called at all, so leave the logic for the default
    ctor unchanged (and call it from the new ctor taking
    one param).
    
    No change in behavior intended, and drag'n'drop to/from
    Firefox to Writer was still working as expected in a quick test.
    
    Change-Id: Icade8e26f055a7efd75a1aa1a0d3e058ab09daaa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185109
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index 319622abb0ba..d0d4855eb4f4 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -124,9 +124,9 @@ public:
 
 class GtkDnDTransferable;
 
-class GtkInstDropTarget final : public 
cppu::WeakComponentImplHelper<css::datatransfer::dnd::XDropTarget,
-                                                           
css::lang::XInitialization,
-                                                           
css::lang::XServiceInfo>
+class GtkInstDropTarget final
+    : public cppu::WeakComponentImplHelper<css::datatransfer::dnd::XDropTarget,
+                                           css::lang::XServiceInfo>
 {
     osl::Mutex m_aMutex;
     GtkSalFrame* m_pFrame;
@@ -137,11 +137,10 @@ class GtkInstDropTarget final : public 
cppu::WeakComponentImplHelper<css::datatr
     
std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> 
m_aListeners;
 public:
     GtkInstDropTarget();
+    GtkInstDropTarget(sal_IntPtr nFrame);
     virtual ~GtkInstDropTarget() override;
 
-    // XInitialization
-    virtual void        SAL_CALL initialize(const 
css::uno::Sequence<css::uno::Any>& rArgs) override;
-            void        deinitialize();
+    void deinitialize();
 
     // XDropTarget
     virtual void        SAL_CALL addDropTargetListener(const 
css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>&) override;
@@ -182,9 +181,9 @@ public:
 #endif
 };
 
-class GtkInstDragSource final : public 
cppu::WeakComponentImplHelper<css::datatransfer::dnd::XDragSource,
-                                                           
css::lang::XInitialization,
-                                                           
css::lang::XServiceInfo>
+class GtkInstDragSource final
+    : public cppu::WeakComponentImplHelper<css::datatransfer::dnd::XDragSource,
+                                           css::lang::XServiceInfo>
 {
     osl::Mutex m_aMutex;
     GtkSalFrame* m_pFrame;
@@ -197,6 +196,7 @@ public:
         , m_pFrame(nullptr)
     {
     }
+    GtkInstDragSource(sal_IntPtr nFrame);
 
     void set_datatransfer(const 
css::uno::Reference<css::datatransfer::XTransferable>& rTrans,
                           const 
css::uno::Reference<css::datatransfer::dnd::XDragSourceListener>& rListener);
@@ -217,9 +217,7 @@ public:
         const css::uno::Reference< css::datatransfer::XTransferable >& 
transferable,
         const css::uno::Reference< css::datatransfer::dnd::XDragSourceListener 
>& listener) override;
 
-    // XInitialization
-    virtual void        SAL_CALL initialize(const 
css::uno::Sequence<css::uno::Any >& rArguments) override;
-            void        deinitialize();
+    void deinitialize();
 
     OUString SAL_CALL getImplementationName() override;
 
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index f8b15b5cd0c6..2703421d59d6 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -1622,6 +1622,16 @@ GtkInstDropTarget::GtkInstDropTarget()
 {
 }
 
+GtkInstDropTarget::GtkInstDropTarget(sal_IntPtr nFrame)
+    : GtkInstDropTarget()
+{
+    assert(nFrame && "missing SalFrame");
+
+    m_pFrame = reinterpret_cast<GtkSalFrame*>(nFrame);
+    m_pFrame->registerDropTarget(this);
+    m_bActive = true;
+}
+
 OUString SAL_CALL GtkInstDropTarget::getImplementationName()
 {
     return u"com.sun.star.datatransfer.dnd.VclGtkDropTarget"_ustr;
@@ -1650,28 +1660,6 @@ void GtkInstDropTarget::deinitialize()
     m_bActive = false;
 }
 
-void GtkInstDropTarget::initialize(const Sequence<Any>& rArguments)
-{
-    if (rArguments.getLength() < 2)
-    {
-        throw RuntimeException(u"DropTarget::initialize: Cannot install window 
event handler"_ustr,
-                               getXWeak());
-    }
-
-    sal_IntPtr nFrame = 0;
-    rArguments.getConstArray()[1] >>= nFrame;
-
-    if (!nFrame)
-    {
-        throw RuntimeException(u"DropTarget::initialize: missing 
SalFrame"_ustr,
-                               getXWeak());
-    }
-
-    m_pFrame = reinterpret_cast<GtkSalFrame*>(nFrame);
-    m_pFrame->registerDropTarget(this);
-    m_bActive = true;
-}
-
 void GtkInstDropTarget::addDropTargetListener( const Reference< 
css::datatransfer::dnd::XDropTargetListener >& xListener)
 {
     ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
@@ -1756,7 +1744,18 @@ void GtkInstDropTarget::setDefaultActions(sal_Int8 
nDefaultActions)
 
 Reference<XInterface> GtkInstance::ImplCreateDropTarget(const SystemEnvData* 
pSysEnv)
 {
-    return vcl::X11DnDHelper(new GtkInstDropTarget(), pSysEnv->aShellWindow);
+    css::uno::Reference<css::datatransfer::dnd::XDropTarget> xRet
+        = new GtkInstDropTarget(pSysEnv->aShellWindow);
+    return xRet;
+}
+
+GtkInstDragSource::GtkInstDragSource(sal_IntPtr nFrame)
+    : GtkInstDragSource()
+{
+    assert(nFrame && "missing SalFrame");
+
+    m_pFrame = reinterpret_cast<GtkSalFrame*>(nFrame);
+    m_pFrame->registerDragSource(this);
 }
 
 GtkInstDragSource::~GtkInstDragSource()
@@ -1786,27 +1785,6 @@ sal_Int32 GtkInstDragSource::getDefaultCursor( sal_Int8 )
     return 0;
 }
 
-void GtkInstDragSource::initialize(const css::uno::Sequence<css::uno::Any >& 
rArguments)
-{
-    if (rArguments.getLength() < 2)
-    {
-        throw RuntimeException(u"DragSource::initialize: Cannot install window 
event handler"_ustr,
-                               getXWeak());
-    }
-
-    sal_IntPtr nFrame = 0;
-    rArguments.getConstArray()[1] >>= nFrame;
-
-    if (!nFrame)
-    {
-        throw RuntimeException(u"DragSource::initialize: missing 
SalFrame"_ustr,
-                               getXWeak());
-    }
-
-    m_pFrame = reinterpret_cast<GtkSalFrame*>(nFrame);
-    m_pFrame->registerDragSource(this);
-}
-
 OUString SAL_CALL GtkInstDragSource::getImplementationName()
 {
     return u"com.sun.star.datatransfer.dnd.VclGtkDragSource"_ustr;
@@ -1825,7 +1803,9 @@ css::uno::Sequence<OUString> SAL_CALL 
GtkInstDragSource::getSupportedServiceName
 
 Reference<XInterface> GtkInstance::ImplCreateDragSource(const SystemEnvData* 
pSysEnv)
 {
-    return vcl::X11DnDHelper(new GtkInstDragSource(), pSysEnv->aShellWindow);
+    css::uno::Reference<css::datatransfer::dnd::XDragSource> xRet
+        = new GtkInstDragSource(pSysEnv->aShellWindow);
+    return xRet;
 }
 
 namespace {
commit 6f066661936301b4bced4e3ed91c8331804cd0c5
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri May 9 14:27:58 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sat May 10 17:32:22 2025 +0200

    tdf#164380 qt: No longer use vcl::X11DnDHelper, XInitialization
    
    Stop using vcl::X11DnDHelper to initialize
    QtDragSource and QtDropTarget.
    vcl::X11DnDHelper uses the XInitialization interface
    to pass the display connection and window via
    XInitialization::initialize.
    
    However, the display connection isn't used, and
    the window handle is already known, so instead
    pass those directly to the QtDragSource and QtDropTarget
    ctors, and stop supporting the XInitialization interface
    altogether.
    
    The parameters passed to XInitialization::initialize
    are documented for the X11DragSource and X11DropTarget
    services in their .idl files, but those are not relevant
    here in the Qt implementation, because this one is only
    supporting the XDragSource and XDropTarget
    interfaces and not reporting the service names including
    the "11" in the name (i.e. specific to the X/X11 window system)
    in the name as supported.
    
    Change-Id: Ia8a4d305dfcb3916ba44596b31614e2467701514
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185108
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/inc/qt5/QtDragAndDrop.hxx b/vcl/inc/qt5/QtDragAndDrop.hxx
index c768c57ad635..5f55dbe5a822 100644
--- a/vcl/inc/qt5/QtDragAndDrop.hxx
+++ b/vcl/inc/qt5/QtDragAndDrop.hxx
@@ -12,26 +12,20 @@
 
 #include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <cppuhelper/compbase.hxx>
 
 class QtFrame;
 
-class QtDragSource final
-    : public cppu::WeakComponentImplHelper<css::datatransfer::dnd::XDragSource,
-                                           css::lang::XInitialization, 
css::lang::XServiceInfo>
+class QtDragSource final : public 
cppu::WeakComponentImplHelper<css::datatransfer::dnd::XDragSource,
+                                                                
css::lang::XServiceInfo>
 {
     osl::Mutex m_aMutex;
     QtFrame* m_pFrame;
     css::uno::Reference<css::datatransfer::dnd::XDragSourceListener> 
m_xListener;
 
 public:
-    QtDragSource()
-        : WeakComponentImplHelper(m_aMutex)
-        , m_pFrame(nullptr)
-    {
-    }
+    QtDragSource(sal_IntPtr nFrame);
 
     virtual ~QtDragSource() override;
 
@@ -44,9 +38,6 @@ public:
         const css::uno::Reference<css::datatransfer::XTransferable>& 
transferable,
         const 
css::uno::Reference<css::datatransfer::dnd::XDragSourceListener>& listener) 
override;
 
-    // XInitialization
-    virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& 
rArguments) override;
-
     OUString SAL_CALL getImplementationName() override;
 
     sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override;
@@ -57,10 +48,9 @@ public:
 };
 
 class QtDropTarget final
-    : public cppu::WeakComponentImplHelper<css::datatransfer::dnd::XDropTarget,
-                                           
css::datatransfer::dnd::XDropTargetDragContext,
-                                           
css::datatransfer::dnd::XDropTargetDropContext,
-                                           css::lang::XInitialization, 
css::lang::XServiceInfo>
+    : public cppu::WeakComponentImplHelper<
+          css::datatransfer::dnd::XDropTarget, 
css::datatransfer::dnd::XDropTargetDragContext,
+          css::datatransfer::dnd::XDropTargetDropContext, 
css::lang::XServiceInfo>
 {
     osl::Mutex m_aMutex;
     QtFrame* m_pFrame;
@@ -71,12 +61,9 @@ class QtDropTarget final
     bool m_bDropSuccessful;
 
 public:
-    QtDropTarget();
+    QtDropTarget(sal_IntPtr nFrame);
     virtual ~QtDropTarget() override;
 
-    // XInitialization
-    virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& 
rArgs) override;
-
     // XDropTarget
     virtual void SAL_CALL addDropTargetListener(
         const 
css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>&) override;
diff --git a/vcl/qt5/QtDragAndDrop.cxx b/vcl/qt5/QtDragAndDrop.cxx
index 4d40de24d2ca..4207a3881444 100644
--- a/vcl/qt5/QtDragAndDrop.cxx
+++ b/vcl/qt5/QtDragAndDrop.cxx
@@ -23,32 +23,21 @@
 
 using namespace com::sun::star;
 
-QtDragSource::~QtDragSource() {}
-
-sal_Bool QtDragSource::isDragImageSupported() { return true; }
-
-sal_Int32 QtDragSource::getDefaultCursor(sal_Int8) { return 0; }
-
-void QtDragSource::initialize(const css::uno::Sequence<css::uno::Any>& 
rArguments)
+QtDragSource::QtDragSource(sal_IntPtr nFrame)
+    : WeakComponentImplHelper(m_aMutex)
 {
-    if (rArguments.getLength() < 2)
-    {
-        throw uno::RuntimeException(
-            u"DragSource::initialize: Cannot install window event 
handler"_ustr, getXWeak());
-    }
-
-    sal_IntPtr nFrame = 0;
-    rArguments.getConstArray()[1] >>= nFrame;
-
-    if (!nFrame)
-    {
-        throw uno::RuntimeException(u"DragSource::initialize: missing 
SalFrame"_ustr, getXWeak());
-    }
+    assert(nFrame && "missing SalFrame");
 
     m_pFrame = reinterpret_cast<QtFrame*>(nFrame);
     m_pFrame->registerDragSource(this);
 }
 
+QtDragSource::~QtDragSource() {}
+
+sal_Bool QtDragSource::isDragImageSupported() { return true; }
+
+sal_Int32 QtDragSource::getDefaultCursor(sal_Int8) { return 0; }
+
 void QtDragSource::startDrag(
     const datatransfer::dnd::DragGestureEvent& /*rEvent*/, sal_Int8 
sourceActions,
     sal_Int32 /*cursor*/, sal_Int32 /*image*/,
@@ -102,12 +91,18 @@ css::uno::Sequence<OUString> SAL_CALL 
QtDragSource::getSupportedServiceNames()
     return { u"com.sun.star.datatransfer.dnd.QtDragSource"_ustr };
 }
 
-QtDropTarget::QtDropTarget()
+QtDropTarget::QtDropTarget(sal_IntPtr nFrame)
     : WeakComponentImplHelper(m_aMutex)
-    , m_pFrame(nullptr)
     , m_bActive(false)
     , m_nDefaultActions(0)
 {
+    assert(nFrame && "missing SalFrame");
+
+    m_nDropAction = datatransfer::dnd::DNDConstants::ACTION_NONE;
+
+    m_pFrame = reinterpret_cast<QtFrame*>(nFrame);
+    m_pFrame->registerDropTarget(this);
+    m_bActive = true;
 }
 
 OUString SAL_CALL QtDropTarget::getImplementationName()
@@ -127,29 +122,6 @@ css::uno::Sequence<OUString> SAL_CALL 
QtDropTarget::getSupportedServiceNames()
 
 QtDropTarget::~QtDropTarget() {}
 
-void QtDropTarget::initialize(const uno::Sequence<uno::Any>& rArguments)
-{
-    if (rArguments.getLength() < 2)
-    {
-        throw uno::RuntimeException(
-            u"DropTarget::initialize: Cannot install window event 
handler"_ustr, getXWeak());
-    }
-
-    sal_IntPtr nFrame = 0;
-    rArguments.getConstArray()[1] >>= nFrame;
-
-    if (!nFrame)
-    {
-        throw uno::RuntimeException(u"DropTarget::initialize: missing 
SalFrame"_ustr, getXWeak());
-    }
-
-    m_nDropAction = datatransfer::dnd::DNDConstants::ACTION_NONE;
-
-    m_pFrame = reinterpret_cast<QtFrame*>(nFrame);
-    m_pFrame->registerDropTarget(this);
-    m_bActive = true;
-}
-
 void QtDropTarget::addDropTargetListener(
     const uno::Reference<css::datatransfer::dnd::XDropTargetListener>& 
xListener)
 {
diff --git a/vcl/qt5/QtInstance.cxx b/vcl/qt5/QtInstance.cxx
index e5f4362b8b6f..e894fa285252 100644
--- a/vcl/qt5/QtInstance.cxx
+++ b/vcl/qt5/QtInstance.cxx
@@ -661,13 +661,17 @@ QtInstance::CreateClipboard(const 
css::uno::Sequence<css::uno::Any>& arguments)
 css::uno::Reference<css::uno::XInterface>
 QtInstance::ImplCreateDragSource(const SystemEnvData* pSysEnv)
 {
-    return vcl::X11DnDHelper(new QtDragSource(), pSysEnv->aShellWindow);
+    css::uno::Reference<css::datatransfer::dnd::XDragSource> xRet
+        = new QtDragSource(pSysEnv->aShellWindow);
+    return xRet;
 }
 
 css::uno::Reference<css::uno::XInterface>
 QtInstance::ImplCreateDropTarget(const SystemEnvData* pSysEnv)
 {
-    return vcl::X11DnDHelper(new QtDropTarget(), pSysEnv->aShellWindow);
+    css::uno::Reference<css::datatransfer::dnd::XDropTarget> xRet
+        = new QtDropTarget(pSysEnv->aShellWindow);
+    return xRet;
 }
 
 const cairo_font_options_t* QtInstance::GetCairoFontOptions()

Reply via email to