summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-07-13 15:24:10 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-13 18:33:34 +0200
commit4c8f4cf3dd6f8d0fd575d3a4d50a332556fdc289 (patch)
tree6c4ee1021c25524d8c3f323674561aa1f992fd19 /connectivity
parent15f44cb6fbf2459dca522e4f5b7f525fd1d6c5e7 (diff)
connectivity/mysql: create instances with uno constructors
See tdf#74608 for motivation. Change-Id: Ifbfe7fe0aa54cd250efe4a55e9e648a74fd4dc04 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98666 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/Library_mysql_jdbc.mk1
-rw-r--r--connectivity/source/drivers/mysql_jdbc/YDriver.cxx37
-rw-r--r--connectivity/source/drivers/mysql_jdbc/Yservices.cxx66
-rw-r--r--connectivity/source/drivers/mysql_jdbc/mysql_jdbc.component5
-rw-r--r--connectivity/source/inc/mysql/YDriver.hxx7
5 files changed, 19 insertions, 97 deletions
diff --git a/connectivity/Library_mysql_jdbc.mk b/connectivity/Library_mysql_jdbc.mk
index 43c1c81b320f..b6916ce784b1 100644
--- a/connectivity/Library_mysql_jdbc.mk
+++ b/connectivity/Library_mysql_jdbc.mk
@@ -42,7 +42,6 @@ $(eval $(call gb_Library_add_exception_objects,mysql_jdbc,\
connectivity/source/drivers/mysql_jdbc/YColumns \
connectivity/source/drivers/mysql_jdbc/YUser \
connectivity/source/drivers/mysql_jdbc/YUsers \
- connectivity/source/drivers/mysql_jdbc/Yservices \
))
# vim: set noet sw=4 ts=4:
diff --git a/connectivity/source/drivers/mysql_jdbc/YDriver.cxx b/connectivity/source/drivers/mysql_jdbc/YDriver.cxx
index de6c0fdab812..69d4bfbb77e1 100644
--- a/connectivity/source/drivers/mysql_jdbc/YDriver.cxx
+++ b/connectivity/source/drivers/mysql_jdbc/YDriver.cxx
@@ -41,15 +41,6 @@ using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::lang;
-namespace mysql
-{
-Reference<XInterface>
-ODriverDelegator_CreateInstance(const Reference<css::lang::XMultiServiceFactory>& _rxFac)
-{
- return *(new ODriverDelegator(comphelper::getComponentContext(_rxFac)));
-}
-}
-
namespace
{
OUString getJavaDriverClass(css::uno::Sequence<css::beans::PropertyValue> const& info)
@@ -388,19 +379,9 @@ ODriverDelegator::getDataDefinitionByURL(const OUString& url, const Sequence<Pro
// XServiceInfo
-OUString ODriverDelegator::getImplementationName_Static()
-{
- return "org.openoffice.comp.drivers.MySQL.Driver";
-}
-
-Sequence<OUString> ODriverDelegator::getSupportedServiceNames_Static()
-{
- return { "com.sun.star.sdbc.Driver", "com.sun.star.sdbcx.Driver" };
-}
-
OUString SAL_CALL ODriverDelegator::getImplementationName()
{
- return getImplementationName_Static();
+ return "org.openoffice.comp.drivers.MySQL.Driver";
}
sal_Bool SAL_CALL ODriverDelegator::supportsService(const OUString& _rServiceName)
@@ -410,9 +391,23 @@ sal_Bool SAL_CALL ODriverDelegator::supportsService(const OUString& _rServiceNam
Sequence<OUString> SAL_CALL ODriverDelegator::getSupportedServiceNames()
{
- return getSupportedServiceNames_Static();
+ return { "com.sun.star.sdbc.Driver", "com.sun.star.sdbcx.Driver" };
}
} // namespace connectivity
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+connectivity_mysql_ODriverDelegator_get_implementation(css::uno::XComponentContext* context,
+ css::uno::Sequence<css::uno::Any> const&)
+{
+ try
+ {
+ return cppu::acquire(new connectivity::ODriverDelegator(context));
+ }
+ catch (...)
+ {
+ return nullptr;
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mysql_jdbc/Yservices.cxx b/connectivity/source/drivers/mysql_jdbc/Yservices.cxx
deleted file mode 100644
index a19e489bd07e..000000000000
--- a/connectivity/source/drivers/mysql_jdbc/Yservices.cxx
+++ /dev/null
@@ -1,66 +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 <mysql/YDriver.hxx>
-#include <cppuhelper/factory.hxx>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-
-using namespace connectivity::mysql;
-using ::com::sun::star::lang::XMultiServiceFactory;
-using ::com::sun::star::lang::XSingleServiceFactory;
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
-
-typedef Reference<XSingleServiceFactory> (*createFactoryFunc)(
- const Reference<XMultiServiceFactory>& rServiceManager, const OUString& rComponentName,
- ::cppu::ComponentInstantiation pCreateFunction, const Sequence<OUString>& rServiceNames,
- rtl_ModuleCount*);
-
-extern "C" SAL_DLLPUBLIC_EXPORT void*
-mysql_jdbc_component_getFactory(const char* pImplementationName, void* pServiceManager,
- void* /*pRegistryKey*/)
-{
- if (!pServiceManager)
- {
- return nullptr;
- }
-
- Reference<XSingleServiceFactory> xRet;
- const Reference<XMultiServiceFactory> xServiceManager(
- static_cast<XMultiServiceFactory*>(pServiceManager));
- const OUString sImplementationName(OUString::createFromAscii(pImplementationName));
-
- if (ODriverDelegator::getImplementationName_Static() == sImplementationName)
- try
- {
- xRet = ::cppu::createSingleFactory(xServiceManager, sImplementationName,
- ODriverDelegator_CreateInstance,
- ODriverDelegator::getSupportedServiceNames_Static());
- }
- catch (...)
- {
- }
-
- if (xRet.is())
- xRet->acquire();
-
- return xRet.get();
-};
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mysql_jdbc/mysql_jdbc.component b/connectivity/source/drivers/mysql_jdbc/mysql_jdbc.component
index 0a1d157e93ad..7ecd7a441846 100644
--- a/connectivity/source/drivers/mysql_jdbc/mysql_jdbc.component
+++ b/connectivity/source/drivers/mysql_jdbc/mysql_jdbc.component
@@ -18,8 +18,9 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
- prefix="mysql_jdbc" xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="org.openoffice.comp.drivers.MySQL.Driver">
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="org.openoffice.comp.drivers.MySQL.Driver"
+ constructor="connectivity_mysql_ODriverDelegator_get_implementation">
<service name="com.sun.star.sdbc.Driver"/>
<service name="com.sun.star.sdbcx.Driver"/>
</implementation>
diff --git a/connectivity/source/inc/mysql/YDriver.hxx b/connectivity/source/inc/mysql/YDriver.hxx
index a44f6604802b..f4065dcc7fb0 100644
--- a/connectivity/source/inc/mysql/YDriver.hxx
+++ b/connectivity/source/inc/mysql/YDriver.hxx
@@ -41,9 +41,6 @@ namespace connectivity
namespace mysql
{
- /// @throws css::uno::Exception
- css::uno::Reference< css::uno::XInterface > ODriverDelegator_CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxMSF);
-
typedef ::cppu::WeakComponentImplHelper< css::sdbc::XDriver
, css::sdbcx::XDataDefinitionSupplier
, css::lang::XServiceInfo
@@ -86,10 +83,6 @@ namespace connectivity
// XServiceInfo
DECLARE_SERVICE_INFO();
- /// @throws css::uno::RuntimeException
- static OUString getImplementationName_Static( );
- /// @throws css::uno::RuntimeException
- static css::uno::Sequence< OUString > getSupportedServiceNames_Static( );
// XDriver
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL connect( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override;