connectivity/Library_evoab.mk | 1 connectivity/Library_macab1.mk | 1 connectivity/source/drivers/evoab2/NDriver.cxx | 36 ++---- connectivity/source/drivers/evoab2/NDriver.hxx | 18 --- connectivity/source/drivers/evoab2/NServices.cxx | 108 -------------------- connectivity/source/drivers/evoab2/evoab.component | 5 connectivity/source/drivers/macab/MacabDriver.cxx | 25 +--- connectivity/source/drivers/macab/MacabDriver.hxx | 11 -- connectivity/source/drivers/macab/MacabServices.cxx | 107 ------------------- connectivity/source/drivers/macab/macab1.component | 5 10 files changed, 32 insertions(+), 285 deletions(-)
New commits: commit d1b37f5ff3d69e60355612899043bbc202a15735 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Mon Jul 13 18:45:38 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jul 14 09:04:05 2020 +0200 connectivity/macab: create instances with uno constructors See tdf#74608 for motivation. Change-Id: I418417284ede616ed36d213b378260e321913cce Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98674 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/connectivity/Library_macab1.mk b/connectivity/Library_macab1.mk index 263d0b10e543..58eca126917a 100644 --- a/connectivity/Library_macab1.mk +++ b/connectivity/Library_macab1.mk @@ -35,7 +35,6 @@ $(eval $(call gb_Library_set_include,macab1,\ $(eval $(call gb_Library_add_exception_objects,macab1,\ connectivity/source/drivers/macab/MacabDriver \ - connectivity/source/drivers/macab/MacabServices \ )) # vim: set noet sw=4 ts=4: diff --git a/connectivity/source/drivers/macab/MacabDriver.cxx b/connectivity/source/drivers/macab/MacabDriver.cxx index 9f6a1bec70ea..ee3d55407aa9 100644 --- a/connectivity/source/drivers/macab/MacabDriver.cxx +++ b/connectivity/source/drivers/macab/MacabDriver.cxx @@ -213,23 +213,10 @@ void MacabDriver::disposing() WeakComponentImplHelperBase::disposing(); } -// static ServiceInfo - -OUString MacabDriver::getImplementationName_Static( ) -{ - return "com.sun.star.comp.sdbc.macab.Driver"; -} - -Sequence< OUString > MacabDriver::getSupportedServiceNames_Static( ) -{ - // which service is supported - // for more information @see com.sun.star.sdbc.Driver - return { "com.sun.star.sdbc.Driver" }; -} OUString SAL_CALL MacabDriver::getImplementationName( ) { - return getImplementationName_Static(); + return "com.sun.star.comp.sdbc.macab.Driver"; } sal_Bool SAL_CALL MacabDriver::supportsService( const OUString& _rServiceName ) @@ -239,7 +226,9 @@ sal_Bool SAL_CALL MacabDriver::supportsService( const OUString& _rServiceName ) Sequence< OUString > SAL_CALL MacabDriver::getSupportedServiceNames( ) { - return getSupportedServiceNames_Static(); + // which service is supported + // for more information @see com.sun.star.sdbc.Driver + return { "com.sun.star.sdbc.Driver" }; } Reference< XConnection > SAL_CALL MacabDriver::connect( const OUString& url, const Sequence< PropertyValue >& info ) @@ -312,9 +301,11 @@ OUString MacabDriver::impl_getConfigurationSettingsPath() return "/org.openoffice.Office.DataAccess/DriverSettings/com.sun.star.comp.sdbc.macab.Driver"; } -Reference< XInterface > MacabDriver::Create( const Reference< XMultiServiceFactory >& _rxFactory ) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +connectivity_MacabDriver_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) { - return *(new MacabDriver(comphelper::getComponentContext(_rxFactory))); + return cppu::acquire(new MacabDriver(context)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/MacabDriver.hxx b/connectivity/source/drivers/macab/MacabDriver.hxx index 0d389712fbd5..4c9412c9642a 100644 --- a/connectivity/source/drivers/macab/MacabDriver.hxx +++ b/connectivity/source/drivers/macab/MacabDriver.hxx @@ -118,15 +118,6 @@ namespace connectivity MacabImplModule m_aImplModule; public: - /// @throws css::uno::Exception - static css::uno::Reference< css::uno::XInterface > Create(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory); - - // XServiceInfo - static versions - /// @throws css::uno::RuntimeException - static OUString getImplementationName_Static( ); - /// @throws css::uno::RuntimeException - static css::uno::Sequence< OUString > getSupportedServiceNames_Static( ); - css::uno::Reference< css::uno::XComponentContext > const & getComponentContext() const { return m_xContext; } @@ -134,8 +125,8 @@ namespace connectivity */ static OUString impl_getConfigurationSettingsPath(); - protected: explicit MacabDriver(const css::uno::Reference< css::uno::XComponentContext >& _rxContext); + protected: // OComponentHelper virtual void SAL_CALL disposing() override; diff --git a/connectivity/source/drivers/macab/MacabServices.cxx b/connectivity/source/drivers/macab/MacabServices.cxx deleted file mode 100644 index a1cfc340c51a..000000000000 --- a/connectivity/source/drivers/macab/MacabServices.cxx +++ /dev/null @@ -1,107 +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 "MacabDriver.hxx" -#include <cppuhelper/factory.hxx> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> - -using namespace connectivity::macab; -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(...) - { - } - return xRet.is(); - } - - void* getProvider() const { return xRet.get(); } -}; - -} - -extern "C" SAL_DLLPUBLIC_EXPORT void* macab_component_getFactory( - const char* pImplementationName, - void* pServiceManager, - void*) -{ - void* pRet = nullptr; - if (pServiceManager) - { - ProviderRequest aReq(pServiceManager,pImplementationName); - - aReq.CREATE_PROVIDER( - MacabDriver::getImplementationName_Static(), - MacabDriver::getSupportedServiceNames_Static(), - &MacabDriver::Create, - ::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/macab/macab1.component b/connectivity/source/drivers/macab/macab1.component index 84d17a9cbf78..7cbc0d9c8720 100644 --- a/connectivity/source/drivers/macab/macab1.component +++ b/connectivity/source/drivers/macab/macab1.component @@ -18,8 +18,9 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="macab" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.sdbc.macab.Driver"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.sdbc.macab.Driver" + constructor="connectivity_MacabDriver_get_implementation"> <service name="com.sun.star.sdbc.Driver"/> </implementation> </component> commit 8f7fd5145f2d6b150293875a67f7171a17fef64f Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Jul 13 16:37:26 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jul 14 09:03:43 2020 +0200 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.gran...@collabora.co.uk> 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> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits