[Libreoffice-commits] core.git: dtrans/Library_dnd.mk dtrans/source dtrans/util

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 24 11:26:28 UTC 2020


 dtrans/Library_dnd.mk                |    1 
 dtrans/source/win32/dnd/dndentry.cxx |   88 -----------------------------------
 dtrans/source/win32/dnd/globals.hxx  |    6 --
 dtrans/source/win32/dnd/source.cxx   |   11 +++-
 dtrans/source/win32/dnd/target.cxx   |   11 +++-
 dtrans/util/dnd.component            |    8 +--
 6 files changed, 23 insertions(+), 102 deletions(-)

New commits:
commit b827eefd6397dc34b49a03e186146aed6cd80042
Author:     Noel Grandin <noel at peralex.com>
AuthorDate: Tue Jul 21 15:05:56 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jul 24 13:25:45 2020 +0200

    dtrans/dnd: create instances with uno constructors
    
    See tdf#74608 for motivation.
    
    Change-Id: I39821b05dc5148870e0bd9291e21815f4868b5ee
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99160
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/dtrans/Library_dnd.mk b/dtrans/Library_dnd.mk
index 8eecd53db50c..930b552827e1 100644
--- a/dtrans/Library_dnd.mk
+++ b/dtrans/Library_dnd.mk
@@ -48,7 +48,6 @@ $(eval $(call gb_Library_use_static_libraries,dnd,\
 ))
 
 $(eval $(call gb_Library_add_exception_objects,dnd,\
-	dtrans/source/win32/dnd/dndentry \
 	dtrans/source/win32/dnd/globals \
 	dtrans/source/win32/dnd/idroptarget \
 	dtrans/source/win32/dnd/sourcecontext \
diff --git a/dtrans/source/win32/dnd/dndentry.cxx b/dtrans/source/win32/dnd/dndentry.cxx
deleted file mode 100644
index 0a44283e52b9..000000000000
--- a/dtrans/source/win32/dnd/dndentry.cxx
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <cppuhelper/factory.hxx>
-#include <comphelper/processfactory.hxx>
-#include <com/sun/star/container/XSet.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-
-#include "source.hxx"
-#include "target.hxx"
-
-using namespace ::com::sun::star::uno       ;
-using namespace ::com::sun::star::registry  ;
-using namespace ::cppu                      ;
-using namespace ::com::sun::star::lang;
-
-static Reference< XInterface > createDragSource( const Reference< XMultiServiceFactory >& rServiceManager )
-{
-    DragSource* pSource= new DragSource( comphelper::getComponentContext(rServiceManager) );
-    return Reference<XInterface>( static_cast<XInitialization*>(pSource), UNO_QUERY);
-}
-
-static Reference< XInterface > createDropTarget( const Reference< XMultiServiceFactory >& rServiceManager )
-{
-    DropTarget* pTarget= new DropTarget( comphelper::getComponentContext(rServiceManager) );
-    return Reference<XInterface>( static_cast<XInitialization*>(pTarget), UNO_QUERY);
-}
-
-extern "C"
-{
-
-SAL_DLLPUBLIC_EXPORT void*
-dnd_component_getFactory( const char* pImplName, void* pSrvManager, void* /*pRegistryKey*/ )
-{
-    void* pRet = nullptr;
-    Reference< XSingleServiceFactory > xFactory;
-
-    if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, DNDSOURCE_IMPL_NAME ) ) )
-    {
-        Sequence< OUString > aSNS { DNDSOURCE_SERVICE_NAME };
-
-        xFactory= createSingleFactory(
-            static_cast< XMultiServiceFactory* > ( pSrvManager ),
-            OUString::createFromAscii( pImplName ),
-            createDragSource,
-            aSNS);
-
-    }
-    else if( pSrvManager && ( 0 == rtl_str_compare( pImplName, DNDTARGET_IMPL_NAME ) ) )
-    {
-        Sequence< OUString > aSNS { DNDTARGET_SERVICE_NAME };
-
-        xFactory= createSingleFactory(
-            static_cast< XMultiServiceFactory* > ( pSrvManager ),
-            OUString::createFromAscii( pImplName ),
-            createDropTarget,
-            aSNS);
-
-    }
-
-    if ( xFactory.is() )
-    {
-        xFactory->acquire();
-        pRet = xFactory.get();
-    }
-
-    return pRet;
-}
-
-} // extern "C"
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dtrans/source/win32/dnd/globals.hxx b/dtrans/source/win32/dnd/globals.hxx
index 7851c2eec142..6c1a31f84a7f 100644
--- a/dtrans/source/win32/dnd/globals.hxx
+++ b/dtrans/source/win32/dnd/globals.hxx
@@ -29,12 +29,6 @@ namespace com::sun::star::datatransfer { class XTransferable; }
 #include <wtypes.h>
 #include <sal/types.h>
 
-#define DNDSOURCE_SERVICE_NAME  "com.sun.star.datatransfer.dnd.OleDragSource"
-#define DNDSOURCE_IMPL_NAME  "com.sun.star.comp.datatransfer.dnd.OleDragSource_V1"
-
-#define DNDTARGET_SERVICE_NAME  "com.sun.star.datatransfer.dnd.OleDropTarget"
-#define DNDTARGET_IMPL_NAME  "com.sun.star.comp.datatransfer.dnd.OleDropTarget_V1"
-
 // This maps key states as occur as parameter, e.g. in IDropTarget::DragEnter,
 // IDropSource::QueryContinueDrag, to actions as are declared in
 // css::datatransfer::dnd::DNDConstants ( ACTION_MOVE etc).
diff --git a/dtrans/source/win32/dnd/source.cxx b/dtrans/source/win32/dnd/source.cxx
index c797684d233c..8df8325191f4 100644
--- a/dtrans/source/win32/dnd/source.cxx
+++ b/dtrans/source/win32/dnd/source.cxx
@@ -278,7 +278,7 @@ dwEffect
 // XServiceInfo
 OUString SAL_CALL DragSource::getImplementationName(  )
 {
-    return DNDSOURCE_IMPL_NAME;
+    return "com.sun.star.comp.datatransfer.dnd.OleDragSource_V1";
 }
 // XServiceInfo
 sal_Bool SAL_CALL DragSource::supportsService( const OUString& ServiceName )
@@ -288,7 +288,14 @@ sal_Bool SAL_CALL DragSource::supportsService( const OUString& ServiceName )
 
 Sequence< OUString > SAL_CALL DragSource::getSupportedServiceNames(  )
 {
-    return { DNDSOURCE_SERVICE_NAME };
+    return { "com.sun.star.datatransfer.dnd.OleDragSource" };
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+dtrans_DragSource_get_implementation(
+    css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
+{
+    return cppu::acquire(static_cast<cppu::OWeakObject*>(new DragSource(context)));
 }
 
 /** This function is called as extra thread from
diff --git a/dtrans/source/win32/dnd/target.cxx b/dtrans/source/win32/dnd/target.cxx
index 7592eb390962..2bbd34027ef6 100644
--- a/dtrans/source/win32/dnd/target.cxx
+++ b/dtrans/source/win32/dnd/target.cxx
@@ -248,7 +248,7 @@ DWORD WINAPI DndTargetOleSTAFunc(LPVOID pParams)
 // XServiceInfo
 OUString SAL_CALL DropTarget::getImplementationName(  )
 {
-    return DNDTARGET_IMPL_NAME;
+    return "com.sun.star.comp.datatransfer.dnd.OleDropTarget_V1";
 }
 // XServiceInfo
 sal_Bool SAL_CALL DropTarget::supportsService( const OUString& ServiceName )
@@ -258,7 +258,7 @@ sal_Bool SAL_CALL DropTarget::supportsService( const OUString& ServiceName )
 
 Sequence< OUString > SAL_CALL DropTarget::getSupportedServiceNames(  )
 {
-    return { DNDTARGET_SERVICE_NAME };
+    return { "com.sun.star.datatransfer.dnd.OleDropTarget" };
 }
 
 // XDropTarget
@@ -625,4 +625,11 @@ inline sal_Int8 DropTarget::getFilteredActions( DWORD grfKeyState, DWORD dwEffec
     return actions &  m_nDefaultActions;
 }
 
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+dtrans_DropTarget_get_implementation(
+    css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
+{
+    return cppu::acquire(static_cast<cppu::OWeakObject*>(new DropTarget(context)));
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dtrans/util/dnd.component b/dtrans/util/dnd.component
index 2fdc916c514a..8a3f5feebbb2 100644
--- a/dtrans/util/dnd.component
+++ b/dtrans/util/dnd.component
@@ -18,11 +18,13 @@
  -->
 
 <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
-    prefix="dnd" xmlns="http://openoffice.org/2010/uno-components">
-  <implementation name="com.sun.star.comp.datatransfer.dnd.OleDragSource_V1">
+    xmlns="http://openoffice.org/2010/uno-components">
+  <implementation name="com.sun.star.comp.datatransfer.dnd.OleDragSource_V1"
+	constructor="dtrans_DragSource_get_implementation">
     <service name="com.sun.star.datatransfer.dnd.OleDragSource"/>
   </implementation>
-  <implementation name="com.sun.star.comp.datatransfer.dnd.OleDropTarget_V1">
+  <implementation name="com.sun.star.comp.datatransfer.dnd.OleDropTarget_V1"
+	constructor="dtrans_DropTarget_get_implementation">
     <service name="com.sun.star.datatransfer.dnd.OleDropTarget"/>
   </implementation>
 </component>


More information about the Libreoffice-commits mailing list