vcl: Drop logic to create drop target by service name

DropTarget_createInstance, which would have been called
when trying to create a drop target via service name,
calls SalInstance::CreateDropTarget with the default
null `pSysEnv` param.

For all cases except headless mode or when running unit tests,
that calls the platform/VCL-specific SalInstance::ImplCreateDropTarget
overrides, which would unconditionally dereference the
null `pSysEnv`.

Since this logic to create a drop target by service
name is unused, presumably since

    commit 031576105c
    Author: Jan-Marek Glogowski <glogow@fbihome.de>
    Date:   Thu Jan 6 14:16:53 2022 +0100

        VCL move platform code from mouse.cxx into plugins

        ... by moving it into ImplCreate(DragSource|DropTarget).

        The existing Create* variant now checks for headless mode and the
        IsRunningUnitTest flag, before creating the platform variants.
        There are two small helpers to initialize either X11 or Ole based
        UNO DnD interace implementations.

        Unfortunatly Windows requires to move two dtrans header files, but
        at least any other changes are minimal.

, drop it altogether.

com::sun::datatransfer::dnd.X11DropTarget is a published
UNO service (see offapi/com/sun/star/datatransfer/dnd/X11DropTarget.idl),
so leave the specification in the IDL file around, even if there
is no way to create an instance via external code (macros, extensions).
That's not new with this commit, since the service was
only meant to be supported by the gen VCL plugin on Linux
previously, but then, trying to create an instance would
crash in X11SalInstance::ImplCreateDropTarget due to
dereferencing the null `pSysEnv`.

The XInitialization interface as mentioned in the IDL file:

    /** The service expects an instance of
        com::sun::awt::XDisplayConnection
         as the first parameter. The second parameter must be a long
        that contains an XWindow window which shall be registered
        as drop target.
    */
    interface com::sun::lang::XInitialization;

hasn't been implemented any more since

    commit 30b4c1d787
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Fri Jul 4 10:01:23 2025 +0200

        gen: Simplify DropTarget init, don't use XInitialization

, but also before then, an XDisplayConnection to pass
as a param to the XInitilization::initialize implementation
couldn't be retrieved via external code, see the
commit message of

    commit 7a9108a48e
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Fri Jul 4 11:16:24 2025 +0200

        vcl: Stop implementing XDisplayConnection

for more details.

The published service com::sun::datatransfer::dnd::OleDropTarget
is Windows-specific in its description. Quoting from
offapi/com/sun/star/datatransfer/dnd/OleDropTarget.idl:

    /** The service expects a windows window handle. It is passed as unsigned long.
    */
    interface com::sun::lang::XInitialization;

, while it was also used on macOS internally
before the above-mentioned
031576105c.

The actual Windows implementation has a separate
UNO constructor (see vcl/vclplug_win.component)
and should therefore be unaffected by this change.

If the X11-specific X11DropTarget service were actually
relevant, it should probably be implemented similarly
(specifically for the gen VCL plugin only, without
reintroducing the rest of the logic dropped in this
commit.)

Searches for "com.sun.star.datatransfer.dnd.X11DropTarget"
and "com.sun.star.datatransfer.dnd.OleDropTarget"
in Google and on Ask [1] didn't give any results that would
suggest that these services would actually be used by
existing third party code.

Change-Id: I93c099b82e209efe11f30bbc4f5fa0a6e1fff992
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187726
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
This commit is contained in:
Michael Weghorn
2025-07-11 13:47:54 +02:00
parent 487942961d
commit 44da22e03b
7 changed files with 0 additions and 59 deletions

View File

@ -357,11 +357,6 @@ void Test::createInstance(
{
expImpl = "com.sun.star.datatransfer.dnd.VclGenericDragSource";
expServs = {u"com.sun.star.datatransfer.dnd.GenericDragSource"_ustr};
} else if (name == "com.sun.star.comp.datatransfer.dnd.OleDropTarget_V1"
|| name == "com.sun.star.datatransfer.dnd.XdndDropTarget")
{
expImpl = "com.sun.star.datatransfer.dnd.VclGenericDropTarget";
expServs = {u"com.sun.star.datatransfer.dnd.GenericDropTarget"_ustr};
#endif
} else if (name == "com.sun.star.ui.dialogs.FolderPicker") {
// FolderPicker is a wrapper returning either a platform-specific or the

View File

@ -41,13 +41,6 @@ OUString DragSource_getImplementationName();
css::uno::Reference<css::uno::XInterface> DragSource_createInstance(
css::uno::Reference<css::lang::XMultiServiceFactory > const &);
css::uno::Sequence<OUString> DropTarget_getSupportedServiceNames();
OUString DropTarget_getImplementationName();
css::uno::Reference<css::uno::XInterface> DropTarget_createInstance(
css::uno::Reference<css::lang::XMultiServiceFactory > const &);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -376,37 +376,6 @@ void GenericDropTarget::setDefaultActions( sal_Int8)
{
}
Sequence< OUString > DropTarget_getSupportedServiceNames()
{
#if defined MACOSX
return { "com.sun.star.datatransfer.dnd.OleDropTarget" };
#elif defined UNX
return { u"com.sun.star.datatransfer.dnd.X11DropTarget"_ustr };
#else
return GenericDropTarget::getSupportedServiceNames_static();
#endif
}
OUString DropTarget_getImplementationName()
{
return
#if defined MACOSX
"com.sun.star.comp.datatransfer.dnd.OleDropTarget_V1"
#elif defined UNX
u"com.sun.star.datatransfer.dnd.XdndDropTarget"_ustr
#else
"com.sun.star.datatransfer.dnd.VclGenericDropTarget"
#endif
;
}
Reference< XInterface > DropTarget_createInstance( const Reference< XMultiServiceFactory >& )
{
SolarMutexGuard aGuard;
Reference< XInterface > xResult = ImplGetSVData()->mpDefInst->CreateDropTarget();
return xResult;
}
} // namespace vcl
/*

View File

@ -45,12 +45,6 @@ extern "C" {
xMgr, vcl::DragSource_getImplementationName(), vcl::DragSource_createInstance,
vcl::DragSource_getSupportedServiceNames() );
}
else if( vcl::DropTarget_getImplementationName().equalsAscii( pImplementationName ) )
{
xFactory = ::cppu::createSingleFactory(
xMgr, vcl::DropTarget_getImplementationName(), vcl::DropTarget_createInstance,
vcl::DropTarget_getSupportedServiceNames() );
}
if( xFactory.is() )
{

View File

@ -23,10 +23,6 @@
<service name="com.sun.star.datatransfer.dnd.OleDragSource"/>
<optional/>
</implementation>
<implementation name="com.sun.star.comp.datatransfer.dnd.OleDropTarget_V1">
<service name="com.sun.star.datatransfer.dnd.OleDropTarget"/>
<optional/>
</implementation>
<implementation name="com.sun.star.comp.graphic.GraphicMapper"
constructor="com_sun_star_comp_graphic_GraphicMapper_get_implementation">
<service name="com.sun.star.graphic.GraphicMapper"/>
@ -45,10 +41,6 @@
<service name="com.sun.star.datatransfer.clipboard.SystemClipboard"/>
<optional/>
</implementation>
<implementation name="com.sun.star.datatransfer.dnd.XdndDropTarget">
<service name="com.sun.star.datatransfer.dnd.X11DropTarget"/>
<optional/>
</implementation>
<implementation name="com.sun.star.datatransfer.dnd.XdndSupport">
<service name="com.sun.star.datatransfer.dnd.X11DragSource"/>
<optional/>

View File

@ -5,7 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
com.sun.star.comp.datatransfer.dnd.OleDragSource_V1
com.sun.star.comp.datatransfer.dnd.OleDropTarget_V1
com.sun.star.datatransfer.clipboard.AquaClipboard
com.sun.star.frame.VCLSessionManagerClient
org.libreoffice.uitest.UITest

View File

@ -4,7 +4,6 @@
# 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/.
com.sun.star.datatransfer.dnd.XdndDropTarget
com.sun.star.datatransfer.dnd.XdndSupport
com.sun.star.datatransfer.X11ClipboardSupport
com.sun.star.frame.VCLSessionManagerClient