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>
This commit is contained in:
parent
e200a08f09
commit
02add49081
5 changed files with 16 additions and 143 deletions
|
@ -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 \
|
||||
|
|
|
@ -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: */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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: */
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue