diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-13 16:37:26 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-14 09:03:43 +0200 |
commit | 8f7fd5145f2d6b150293875a67f7171a17fef64f (patch) | |
tree | 8919a862bd9a46a012f297c6a1178727571c39d1 /connectivity | |
parent | 27ae032f793ecae63ff231339cb18c4b2ec64206 (diff) |
connectivity/evoab: create instances with uno constructors
See tdf#74608 for motivation.
Change-Id: I30f1fdca220e64e087a1de2f8a6ab1f2e7ba8a45
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98687
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/Library_evoab.mk | 1 | ||||
-rw-r--r-- | connectivity/source/drivers/evoab2/NDriver.cxx | 36 | ||||
-rw-r--r-- | connectivity/source/drivers/evoab2/NDriver.hxx | 18 | ||||
-rw-r--r-- | connectivity/source/drivers/evoab2/NServices.cxx | 108 | ||||
-rw-r--r-- | connectivity/source/drivers/evoab2/evoab.component | 5 |
5 files changed, 20 insertions, 148 deletions
diff --git a/connectivity/Library_evoab.mk b/connectivity/Library_evoab.mk index ee325f4464c6..28327f060bcf 100644 --- a/connectivity/Library_evoab.mk +++ b/connectivity/Library_evoab.mk @@ -50,7 +50,6 @@ $(eval $(call gb_Library_add_exception_objects,evoab,\ connectivity/source/drivers/evoab2/NDatabaseMetaData \ connectivity/source/drivers/evoab2/NStatement \ connectivity/source/drivers/evoab2/NPreparedStatement \ - connectivity/source/drivers/evoab2/NServices \ connectivity/source/drivers/evoab2/NResultSet \ connectivity/source/drivers/evoab2/NResultSetMetaData \ connectivity/source/drivers/evoab2/EApi \ diff --git a/connectivity/source/drivers/evoab2/NDriver.cxx b/connectivity/source/drivers/evoab2/NDriver.cxx index 0155fa6a611b..ab6eb8ee48eb 100644 --- a/connectivity/source/drivers/evoab2/NDriver.cxx +++ b/connectivity/source/drivers/evoab2/NDriver.cxx @@ -36,8 +36,8 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::ucb; -OEvoabDriver::OEvoabDriver(const Reference< XMultiServiceFactory >& _rxFactory) : - ODriver_BASE( m_aMutex ), m_xFactory( _rxFactory ) +OEvoabDriver::OEvoabDriver(const Reference< XComponentContext >& _rxContext) : + ODriver_BASE( m_aMutex ), m_xContext( _rxContext ) { } @@ -73,26 +73,14 @@ void OEvoabDriver::disposing() // static ServiceInfo -OUString OEvoabDriver::getImplementationName_Static( ) + +OUString SAL_CALL OEvoabDriver::getImplementationName( ) { return EVOAB_DRIVER_IMPL_NAME; // this name is referenced in the configuration and in the evoab.xml // Please take care when changing it. } - -Sequence< OUString > OEvoabDriver::getSupportedServiceNames_Static( ) -{ - // which service is supported - // for more information @see com.sun.star.sdbc.Driver - return Sequence<OUString>{ "com.sun.star.sdbc.Driver" }; -} - -OUString SAL_CALL OEvoabDriver::getImplementationName( ) -{ - return getImplementationName_Static(); -} - sal_Bool SAL_CALL OEvoabDriver::supportsService( const OUString& _rServiceName ) { return cppu::supportsService(this, _rServiceName); @@ -100,15 +88,12 @@ sal_Bool SAL_CALL OEvoabDriver::supportsService( const OUString& _rServiceName ) Sequence< OUString > SAL_CALL OEvoabDriver::getSupportedServiceNames( ) { - return getSupportedServiceNames_Static(); + // which service is supported + // for more information @see com.sun.star.sdbc.Driver + return { "com.sun.star.sdbc.Driver" }; } -css::uno::Reference< css::uno::XInterface > connectivity::evoab::OEvoabDriver_CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory) -{ - return *(new OEvoabDriver(_rxFactory)); -} - Reference< XConnection > SAL_CALL OEvoabDriver::connect( const OUString& url, const Sequence< PropertyValue >& info ) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -162,4 +147,11 @@ bool OEvoabDriver::acceptsURL_Stat( const OUString& url ) } +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +connectivity_OEvoabDriver_get_implementation( + css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new OEvoabDriver(context)); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/evoab2/NDriver.hxx b/connectivity/source/drivers/evoab2/NDriver.hxx index a2c12a87ff05..d492e9bb5288 100644 --- a/connectivity/source/drivers/evoab2/NDriver.hxx +++ b/connectivity/source/drivers/evoab2/NDriver.hxx @@ -22,7 +22,6 @@ #include <com/sun/star/sdbc/XDriver.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <comphelper/processfactory.hxx> #include <cppuhelper/compbase.hxx> #include <connectivity/CommonTools.hxx> @@ -32,10 +31,6 @@ namespace connectivity { namespace evoab { - /// @throws css::uno::Exception - css::uno::Reference< css::uno::XInterface > OEvoabDriver_CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory); - - typedef ::cppu::WeakComponentImplHelper< css::sdbc::XDriver, css::lang::XServiceInfo > ODriver_BASE; @@ -44,21 +39,15 @@ namespace connectivity { ::osl::Mutex m_aMutex; connectivity::OWeakRefArray m_xConnections; - css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; + css::uno::Reference< css::uno::XComponentContext > m_xContext; public: - explicit OEvoabDriver(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory); + explicit OEvoabDriver(const css::uno::Reference< css::uno::XComponentContext >& ); virtual ~OEvoabDriver() override; // 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; virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; @@ -73,8 +62,7 @@ namespace connectivity virtual sal_Int32 SAL_CALL getMinorVersion( ) override; public: - css::uno::Reference< css::uno::XComponentContext > - getComponentContext( ) const { return comphelper::getComponentContext( m_xFactory ); } + css::uno::Reference< css::uno::XComponentContext > getComponentContext( ) const { return m_xContext; } // static methods static bool acceptsURL_Stat( const OUString& url ); diff --git a/connectivity/source/drivers/evoab2/NServices.cxx b/connectivity/source/drivers/evoab2/NServices.cxx deleted file mode 100644 index 0fc8f8d07e98..000000000000 --- a/connectivity/source/drivers/evoab2/NServices.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 "NDriver.hxx" -#include <cppuhelper/factory.hxx> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <osl/diagnose.h> - -using namespace connectivity::evoab; -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(const css::uno::Exception&) - { - OSL_FAIL("Service Creation Exception"); - } - } - return xRet.is(); - } - - void* getProvider() const { return xRet.get(); } -}; - -} - -extern "C" SAL_DLLPUBLIC_EXPORT void* evoab2_component_getFactory( - const char* pImplementationName, - void* pServiceManager, - void* /*pRegistryKey*/) -{ - void* pRet = nullptr; - if (pServiceManager) - { - ProviderRequest aReq(pServiceManager,pImplementationName); - - aReq.CREATE_PROVIDER( - OEvoabDriver::getImplementationName_Static(), - OEvoabDriver::getSupportedServiceNames_Static(), - OEvoabDriver_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/evoab2/evoab.component b/connectivity/source/drivers/evoab2/evoab.component index 6bd8cb5e38bb..c0928c178f61 100644 --- a/connectivity/source/drivers/evoab2/evoab.component +++ b/connectivity/source/drivers/evoab2/evoab.component @@ -18,8 +18,9 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="evoab2" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.sdbc.evoab.OEvoabDriver"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.sdbc.evoab.OEvoabDriver" + constructor="connectivity_OEvoabDriver_get_implementation"> <service name="com.sun.star.sdbc.Driver"/> </implementation> </component> |