connectivity/Library_odbc.mk                     |    1 
 connectivity/source/drivers/odbc/ODriver.cxx     |   19 ----
 connectivity/source/drivers/odbc/ORealDriver.cxx |   15 +--
 connectivity/source/drivers/odbc/ORealDriver.hxx |   42 --------
 connectivity/source/drivers/odbc/odbc.component  |    5 -
 connectivity/source/drivers/odbc/oservices.cxx   |  108 -----------------------
 connectivity/source/inc/odbc/ODriver.hxx         |   13 --
 7 files changed, 18 insertions(+), 185 deletions(-)

New commits:
commit d812521ec4e142d5fe291b1a2e8d167b41ee744c
Author:     Noel Grandin <n...@peralex.com>
AuthorDate: Wed Jul 22 10:26:19 2020 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Jul 23 11:56:22 2020 +0200

    connectivity/odbc: create instances with uno constructors
    
    See tdf#74608 for motivation.
    
    Change-Id: I7cc971c7a99950a05804ae73f132c68e0c5a0625
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99186
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/connectivity/Library_odbc.mk b/connectivity/Library_odbc.mk
index 1d1c82cf174c..ae2b131c3649 100644
--- a/connectivity/Library_odbc.mk
+++ b/connectivity/Library_odbc.mk
@@ -44,7 +44,6 @@ $(eval $(call gb_Library_use_libraries,odbc,\
 ))
 
 $(eval $(call gb_Library_add_exception_objects,odbc,\
-       connectivity/source/drivers/odbc/oservices \
        connectivity/source/drivers/odbc/ORealDriver \
        connectivity/source/drivers/odbc/OFunctions \
        connectivity/source/drivers/odbc/OPreparedStatement \
diff --git a/connectivity/source/drivers/odbc/ODriver.cxx 
b/connectivity/source/drivers/odbc/ODriver.cxx
index 42dbff07ba95..b4318d43b18b 100644
--- a/connectivity/source/drivers/odbc/ODriver.cxx
+++ b/connectivity/source/drivers/odbc/ODriver.cxx
@@ -31,9 +31,9 @@ using namespace com::sun::star::lang;
 using namespace com::sun::star::beans;
 using namespace com::sun::star::sdbc;
 
-ODBCDriver::ODBCDriver(const css::uno::Reference< 
css::lang::XMultiServiceFactory >& _rxFactory)
+ODBCDriver::ODBCDriver(const css::uno::Reference< css::uno::XComponentContext 
>& _rxContext)
     :ODriver_BASE(m_aMutex)
-    ,m_xORB(_rxFactory)
+    ,m_xContext(_rxContext)
     ,m_pDriverHandle(SQL_NULL_HANDLE)
 {
 }
@@ -56,7 +56,7 @@ void ODBCDriver::disposing()
 
 // static ServiceInfo
 
-OUString ODBCDriver::getImplementationName_Static(  )
+OUString ODBCDriver::getImplementationName(  )
 {
     return "com.sun.star.comp.sdbc.ODBCDriver";
         // this name is referenced in the configuration and in the odbc.xml
@@ -64,29 +64,18 @@ OUString ODBCDriver::getImplementationName_Static(  )
 }
 
 
-Sequence< OUString > ODBCDriver::getSupportedServiceNames_Static(  )
+Sequence< OUString > ODBCDriver::getSupportedServiceNames(  )
 {
     return { "com.sun.star.sdbc.Driver" };
 }
 
 
-OUString SAL_CALL ODBCDriver::getImplementationName(  )
-{
-    return getImplementationName_Static();
-}
-
 sal_Bool SAL_CALL ODBCDriver::supportsService( const OUString& _rServiceName )
 {
     return cppu::supportsService(this, _rServiceName);
 }
 
 
-Sequence< OUString > SAL_CALL ODBCDriver::getSupportedServiceNames(  )
-{
-    return getSupportedServiceNames_Static();
-}
-
-
 Reference< XConnection > SAL_CALL ODBCDriver::connect( const OUString& url, 
const Sequence< PropertyValue >& info )
 {
     if ( ! acceptsURL(url) )
diff --git a/connectivity/source/drivers/odbc/ORealDriver.cxx 
b/connectivity/source/drivers/odbc/ORealDriver.cxx
index 47576954a8f2..28c054b45f7c 100644
--- a/connectivity/source/drivers/odbc/ORealDriver.cxx
+++ b/connectivity/source/drivers/odbc/ORealDriver.cxx
@@ -17,7 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "ORealDriver.hxx"
 #include <odbc/ODriver.hxx>
 #include <odbc/OTools.hxx>
 #include <odbc/OFunctions.hxx>
@@ -32,7 +31,7 @@ namespace connectivity::odbc
             virtual oslGenericFunction  getOdbcFunction(ODBC3SQLFunctionId 
_nIndex)  const override;
             virtual SQLHANDLE   EnvironmentHandle(OUString &_rPath) override;
         public:
-            explicit ORealOdbcDriver(const css::uno::Reference< 
css::lang::XMultiServiceFactory >& _rxFactory) : ODBCDriver(_rxFactory) {}
+            explicit ORealOdbcDriver(const css::uno::Reference< 
css::uno::XComponentContext >& _rxContext) : ODBCDriver(_rxContext) {}
         };
 
         }
@@ -259,11 +258,6 @@ oslGenericFunction 
ORealOdbcDriver::getOdbcFunction(ODBC3SQLFunctionId _nIndex)
 }
 
 
-css::uno::Reference< css::uno::XInterface > ODBCDriver_CreateInstance(const 
css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory)
-{
-    return *(new ORealOdbcDriver(_rxFactory));
-}
-
 // ODBC Environment (common for all Connections):
 SQLHANDLE ORealOdbcDriver::EnvironmentHandle(OUString &_rPath)
 {
@@ -286,7 +280,12 @@ SQLHANDLE ORealOdbcDriver::EnvironmentHandle(OUString 
&_rPath)
     return m_pDriverHandle;
 }
 
-
 }
 
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+connectivity_odbc_ORealOdbcDriver_get_implementation(
+    css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> 
const&)
+{
+    return cppu::acquire(new connectivity::odbc::ORealOdbcDriver(context));
+}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/odbc/ORealDriver.hxx 
b/connectivity/source/drivers/odbc/ORealDriver.hxx
deleted file mode 100644
index cfecb38936d2..000000000000
--- a/connectivity/source/drivers/odbc/ORealDriver.hxx
+++ /dev/null
@@ -1,42 +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 .
- */
-
-#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_ODBC_OREALDRIVER_HXX
-#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_ODBC_OREALDRIVER_HXX
-
-#include <sal/config.h>
-
-#include <com/sun/star/uno/Reference.hxx>
-
-namespace com::sun::star {
-    namespace lang { class XMultiServiceFactory; }
-    namespace uno { class XInterface; }
-}
-
-namespace connectivity::odbc {
-
-/// @throws css::uno::Exception
-css::uno::Reference< css::uno::XInterface >
-ODBCDriver_CreateInstance( css::uno::Reference< 
css::lang::XMultiServiceFactory > const & factory);
-
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/odbc/odbc.component 
b/connectivity/source/drivers/odbc/odbc.component
index 4fa186ea2a0e..4d3348378bc9 100644
--- a/connectivity/source/drivers/odbc/odbc.component
+++ b/connectivity/source/drivers/odbc/odbc.component
@@ -18,8 +18,9 @@
  -->
 
 <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
-    prefix="odbc" xmlns="http://openoffice.org/2010/uno-components";>
-  <implementation name="com.sun.star.comp.sdbc.ODBCDriver">
+    xmlns="http://openoffice.org/2010/uno-components";>
+  <implementation name="com.sun.star.comp.sdbc.ODBCDriver"
+       constructor="connectivity_odbc_ORealOdbcDriver_get_implementation">
     <service name="com.sun.star.sdbc.Driver"/>
   </implementation>
 </component>
diff --git a/connectivity/source/drivers/odbc/oservices.cxx 
b/connectivity/source/drivers/odbc/oservices.cxx
deleted file mode 100644
index 6461f8dde48f..000000000000
--- a/connectivity/source/drivers/odbc/oservices.cxx
+++ /dev/null
@@ -1,108 +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 "ORealDriver.hxx"
-#include <odbc/ODriver.hxx>
-#include <cppuhelper/factory.hxx>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-
-using namespace connectivity::odbc;
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
-using ::com::sun::star::lang::XSingleServiceFactory;
-using ::com::sun::star::lang::XMultiServiceFactory;
-
-typedef Reference< XSingleServiceFactory > (*createFactoryFunc)
-        (
-            const Reference< XMultiServiceFactory > & rServiceManager,
-            const OUString & rComponentName,
-            ::cppu::ComponentInstantiation pCreateFunction,
-            const Sequence< OUString > & rServiceNames,
-            rtl_ModuleCount*
-        );
-
-namespace {
-
-struct ProviderRequest
-{
-    Reference< XSingleServiceFactory > xRet;
-    Reference< XMultiServiceFactory > const xServiceManager;
-    OUString const sImplementationName;
-
-    ProviderRequest(
-        void* pServiceManager,
-        char const* pImplementationName
-    )
-    : xServiceManager(static_cast<XMultiServiceFactory*>(pServiceManager))
-    , sImplementationName(OUString::createFromAscii(pImplementationName))
-    {
-    }
-
-    bool CREATE_PROVIDER(
-                const OUString& Implname,
-                const Sequence< OUString > & Services,
-                ::cppu::ComponentInstantiation Factory,
-                createFactoryFunc creator
-            )
-    {
-        if (!xRet.is() && (Implname == sImplementationName))
-        {
-            try
-            {
-                xRet = creator( xServiceManager, sImplementationName,Factory, 
Services,nullptr);
-            }
-            catch(...)
-            {
-            }
-        }
-        return xRet.is();
-    }
-
-    void* getProvider() const { return xRet.get(); }
-};
-
-}
-
-extern "C" SAL_DLLPUBLIC_EXPORT void* odbc_component_getFactory(
-                    const char* pImplementationName,
-                    void* pServiceManager,
-                    void* /*pRegistryKey*/)
-{
-    void* pRet = nullptr;
-    if (pServiceManager)
-    {
-        ProviderRequest aReq(pServiceManager,pImplementationName);
-
-        aReq.CREATE_PROVIDER(
-            ODBCDriver::getImplementationName_Static(),
-            ODBCDriver::getSupportedServiceNames_Static(),
-            ODBCDriver_CreateInstance, ::cppu::createSingleFactory)
-        ;
-
-        if(aReq.xRet.is())
-            aReq.xRet->acquire();
-
-        pRet = aReq.getProvider();
-    }
-
-    return pRet;
-};
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/inc/odbc/ODriver.hxx 
b/connectivity/source/inc/odbc/ODriver.hxx
index c38eb502a215..29262aea777e 100644
--- a/connectivity/source/inc/odbc/ODriver.hxx
+++ b/connectivity/source/inc/odbc/ODriver.hxx
@@ -22,7 +22,7 @@
 
 #include <com/sun/star/sdbc/XDriver.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
 #include <cppuhelper/compbase.hxx>
 #include <connectivity/odbc.hxx>
 #include <odbc/odbcbasedllapi.hxx>
@@ -43,24 +43,19 @@ namespace connectivity::odbc
                                                         //  of all the 
Connection objects
                                                         //  for this Driver
 
-            css::uno::Reference< css::lang::XMultiServiceFactory > m_xORB;
+            css::uno::Reference< css::uno::XComponentContext > m_xContext;
             SQLHANDLE   m_pDriverHandle;
 
             virtual SQLHANDLE   EnvironmentHandle(OUString &_rPath) = 0;
 
         public:
 
-            ODBCDriver(const css::uno::Reference< 
css::lang::XMultiServiceFactory >& _rxFactory);
+            ODBCDriver(const css::uno::Reference< css::uno::XComponentContext 
>& rxContext);
 
             // only possibility to get the odbc functions
             virtual oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId 
_nIndex)  const = 0;
             // OComponentHelper
             virtual void SAL_CALL disposing() override;
-            // XInterface
-            /// @throws css::uno::RuntimeException
-            static OUString getImplementationName_Static(  );
-            /// @throws css::uno::RuntimeException
-            static css::uno::Sequence< OUString > 
getSupportedServiceNames_Static(  );
 
             // XServiceInfo
             virtual OUString SAL_CALL getImplementationName(  ) override;
@@ -74,7 +69,7 @@ namespace connectivity::odbc
             virtual sal_Int32 SAL_CALL getMajorVersion(  ) override;
             virtual sal_Int32 SAL_CALL getMinorVersion(  ) override;
 
-            const css::uno::Reference< css::lang::XMultiServiceFactory >& 
getORB() const { return m_xORB; }
+            const css::uno::Reference< css::uno::XComponentContext >& 
getContext() const { return m_xContext; }
         };
 
 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to