diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-13 16:17:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-14 09:09:31 +0200 |
commit | 3616a43f8d7da0379a7f6441c4900304de40952a (patch) | |
tree | 438625cf1625390411ab0555fc3ee3134f14b68a /connectivity/source/drivers | |
parent | c69a54ebb232f22e6a07d5a2ec06f9097fce45a6 (diff) |
connectivity/hsqldb: create instances with uno constructors
See tdf#74608 for motivation.
Change-Id: I80d9c854640073038d1a4d79997111912d924f69
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98685
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity/source/drivers')
-rw-r--r-- | connectivity/source/drivers/hsqldb/HDriver.cxx | 34 | ||||
-rw-r--r-- | connectivity/source/drivers/hsqldb/Hservices.cxx | 108 | ||||
-rw-r--r-- | connectivity/source/drivers/hsqldb/hsqldb.component | 5 |
3 files changed, 16 insertions, 131 deletions
diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx index 05b9478a9f12..87c940a1c17c 100644 --- a/connectivity/source/drivers/hsqldb/HDriver.cxx +++ b/connectivity/source/drivers/hsqldb/HDriver.cxx @@ -71,13 +71,8 @@ namespace connectivity using namespace css::util; using namespace css::reflection; - namespace hsqldb - { - Reference< XInterface > ODriverDelegator_CreateInstance(const Reference< css::lang::XMultiServiceFactory >& _rxFac) - { - return *(new ODriverDelegator(comphelper::getComponentContext(_rxFac))); - } - } + constexpr OUStringLiteral IMPL_NAME = "com.sun.star.sdbcx.comp.hsqldb.Driver"; + ODriverDelegator::ODriverDelegator(const Reference< XComponentContext >& _rxContext) @@ -140,7 +135,7 @@ namespace connectivity { OUString aConfigPath = "/org.openoffice.Office.DataAccess/DriverSettings/" + - ODriverDelegator::getImplementationName_Static() + + IMPL_NAME + "/PermittedJavaMethods"; ::utl::OConfigurationTreeRoot aConfig( ::utl::OConfigurationTreeRoot::createWithComponentContext( _rxContext, aConfigPath ) ); @@ -475,20 +470,9 @@ namespace connectivity // XServiceInfo - - OUString ODriverDelegator::getImplementationName_Static( ) - { - return "com.sun.star.sdbcx.comp.hsqldb.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 IMPL_NAME; } sal_Bool SAL_CALL ODriverDelegator::supportsService( const OUString& _rServiceName ) @@ -498,7 +482,7 @@ namespace connectivity Sequence< OUString > SAL_CALL ODriverDelegator::getSupportedServiceNames( ) { - return getSupportedServiceNames_Static(); + return { "com.sun.star.sdbc.Driver", "com.sun.star.sdbcx.Driver" }; } void SAL_CALL ODriverDelegator::createCatalog( const Sequence< PropertyValue >& /*info*/ ) @@ -867,4 +851,12 @@ namespace connectivity } // namespace connectivity +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +connectivity_hsqldb_ODriverDelegator_implementation( + css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new connectivity::ODriverDelegator(context)); +} + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/hsqldb/Hservices.cxx b/connectivity/source/drivers/hsqldb/Hservices.cxx deleted file mode 100644 index 5ca8a0962636..000000000000 --- a/connectivity/source/drivers/hsqldb/Hservices.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 <hsqldb/HDriver.hxx> -#include <cppuhelper/factory.hxx> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> - -using namespace connectivity::hsqldb; -using css::uno::Reference; -using css::uno::Sequence; -using css::lang::XSingleServiceFactory; -using css::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* hsqldb_component_getFactory( - const char* pImplementationName, - void* pServiceManager, - void* /*pRegistryKey*/) -{ - void* pRet = nullptr; - if (pServiceManager) - { - ProviderRequest aReq(pServiceManager,pImplementationName); - - aReq.CREATE_PROVIDER( - ODriverDelegator::getImplementationName_Static(), - ODriverDelegator::getSupportedServiceNames_Static(), - ODriverDelegator_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/hsqldb/hsqldb.component b/connectivity/source/drivers/hsqldb/hsqldb.component index ab8318861416..a541e02aa8d8 100644 --- a/connectivity/source/drivers/hsqldb/hsqldb.component +++ b/connectivity/source/drivers/hsqldb/hsqldb.component @@ -18,8 +18,9 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="hsqldb" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.sdbcx.comp.hsqldb.Driver"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.sdbcx.comp.hsqldb.Driver" + constructor="connectivity_hsqldb_ODriverDelegator_implementation"> <service name="com.sun.star.sdbc.Driver"/> <service name="com.sun.star.sdbcx.Driver"/> </implementation> |