summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-07-13 16:23:14 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-14 10:26:23 +0200
commit02add49081fc52838a8cff8746c647a0286544c1 (patch)
tree0f0c3d64e311a131cf0447779382af1f4f1540fd /connectivity
parente200a08f0982cc9f5993deeee03eb8ce2a110e71 (diff)
connectivity/firebird: create instances with uno constructors
See tdf#74608 for motivation. Change-Id: Ibac6bae417b664f9132ddc7d6dd539a85da28674 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98686 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/Library_firebird_sdbc.mk1
-rw-r--r--connectivity/source/drivers/firebird/Driver.cxx36
-rw-r--r--connectivity/source/drivers/firebird/Driver.hxx8
-rw-r--r--connectivity/source/drivers/firebird/Services.cxx109
-rw-r--r--connectivity/source/drivers/firebird/firebird_sdbc.component5
5 files changed, 16 insertions, 143 deletions
diff --git a/connectivity/Library_firebird_sdbc.mk b/connectivity/Library_firebird_sdbc.mk
index 2c6eb559b033..5fb596ef8fb4 100644
--- a/connectivity/Library_firebird_sdbc.mk
+++ b/connectivity/Library_firebird_sdbc.mk
@@ -54,7 +54,6 @@ $(eval $(call gb_Library_add_exception_objects,firebird_sdbc,\
connectivity/source/drivers/firebird/PreparedStatement \
connectivity/source/drivers/firebird/ResultSet \
connectivity/source/drivers/firebird/ResultSetMetaData \
- connectivity/source/drivers/firebird/Services \
connectivity/source/drivers/firebird/Statement \
connectivity/source/drivers/firebird/StatementCommonBase \
connectivity/source/drivers/firebird/Table \
diff --git a/connectivity/source/drivers/firebird/Driver.cxx b/connectivity/source/drivers/firebird/Driver.cxx
index aa6f0d9d5c57..71613408df24 100644
--- a/connectivity/source/drivers/firebird/Driver.cxx
+++ b/connectivity/source/drivers/firebird/Driver.cxx
@@ -44,16 +44,6 @@ using namespace ::osl;
using namespace connectivity::firebird;
-namespace connectivity::firebird
-{
- Reference< XInterface > FirebirdDriver_CreateInstance(
- const Reference< XMultiServiceFactory >& _rxFactory)
- {
- SAL_INFO("connectivity.firebird", "FirebirdDriver_CreateInstance()" );
- return *(new FirebirdDriver(comphelper::getComponentContext(_rxFactory)));
- }
-}
-
// Static const variables
namespace {
const char our_sFirebirdTmpVar[] = "FIREBIRD_TMP";
@@ -133,20 +123,9 @@ void FirebirdDriver::disposing()
ODriver_BASE::disposing();
}
-//----- static ServiceInfo ---------------------------------------------------
-OUString FirebirdDriver::getImplementationName_Static()
-{
- return "com.sun.star.comp.sdbc.firebird.Driver";
-}
-
-Sequence< OUString > FirebirdDriver::getSupportedServiceNames_Static()
-{
- return { "com.sun.star.sdbc.Driver", "com.sun.star.sdbcx.Driver" };
-}
-
OUString SAL_CALL FirebirdDriver::getImplementationName()
{
- return getImplementationName_Static();
+ return "com.sun.star.comp.sdbc.firebird.Driver";
}
sal_Bool SAL_CALL FirebirdDriver::supportsService(const OUString& _rServiceName)
@@ -156,7 +135,7 @@ sal_Bool SAL_CALL FirebirdDriver::supportsService(const OUString& _rServiceName)
Sequence< OUString > SAL_CALL FirebirdDriver::getSupportedServiceNames()
{
- return getSupportedServiceNames_Static();
+ return { "com.sun.star.sdbc.Driver", "com.sun.star.sdbcx.Driver" };
}
// ---- XDriver -------------------------------------------------------------
@@ -238,5 +217,16 @@ namespace connectivity::firebird
} // namespace
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+connectivity_FirebirdDriver_get_implementation(
+ css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
+{
+ try {
+ return cppu::acquire(new FirebirdDriver(context));
+ } catch (...) {
+ return nullptr;
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/firebird/Driver.hxx b/connectivity/source/drivers/firebird/Driver.hxx
index 39534c3a1c6d..acace9d13298 100644
--- a/connectivity/source/drivers/firebird/Driver.hxx
+++ b/connectivity/source/drivers/firebird/Driver.hxx
@@ -38,9 +38,6 @@ namespace connectivity
// 3: Is IB6 -- minimum required for delimited identifiers.
const int FIREBIRD_SQL_DIALECT = 3;
- /// @throws css::uno::Exception
- css::uno::Reference< css::uno::XInterface > FirebirdDriver_CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory);
-
typedef ::cppu::WeakComponentImplHelper< css::sdbc::XDriver,
css::sdbcx::XDataDefinitionSupplier,
css::lang::XServiceInfo > ODriver_BASE;
@@ -66,11 +63,6 @@ namespace connectivity
// 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;
diff --git a/connectivity/source/drivers/firebird/Services.cxx b/connectivity/source/drivers/firebird/Services.cxx
deleted file mode 100644
index e72133692f07..000000000000
--- a/connectivity/source/drivers/firebird/Services.cxx
+++ /dev/null
@@ -1,109 +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 "Driver.hxx"
-
-#include <cppuhelper/factory.hxx>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-#include <sal/types.h>
-
-using namespace connectivity::firebird;
-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* _pTemp
- );
-
-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* firebird_sdbc_component_getFactory(
- const char* pImplementationName,
- void* pServiceManager,
- void*)
-{
- void* pRet = nullptr;
- if (pServiceManager)
- {
- ProviderRequest aReq(pServiceManager,pImplementationName);
-
- aReq.CREATE_PROVIDER(
- FirebirdDriver::getImplementationName_Static(),
- FirebirdDriver::getSupportedServiceNames_Static(),
- FirebirdDriver_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/drivers/firebird/firebird_sdbc.component b/connectivity/source/drivers/firebird/firebird_sdbc.component
index b56d4e0bcae7..d80755a24d0d 100644
--- a/connectivity/source/drivers/firebird/firebird_sdbc.component
+++ b/connectivity/source/drivers/firebird/firebird_sdbc.component
@@ -9,8 +9,9 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
- prefix="firebird_sdbc" xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.comp.sdbc.firebird.Driver">
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.sdbc.firebird.Driver"
+ constructor="connectivity_FirebirdDriver_get_implementation">
<service name="com.sun.star.sdbc.Driver"/>
<service name="com.sun.star.sdbcx.Driver"/>
</implementation>