diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-07-13 18:45:38 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-14 09:04:05 +0200 |
commit | d1b37f5ff3d69e60355612899043bbc202a15735 (patch) | |
tree | 561da110d4986d08b5e7d059a2b90accc01bdf60 /connectivity/source | |
parent | 8f7fd5145f2d6b150293875a67f7171a17fef64f (diff) |
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.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity/source')
-rw-r--r-- | connectivity/source/drivers/macab/MacabDriver.cxx | 25 | ||||
-rw-r--r-- | connectivity/source/drivers/macab/MacabDriver.hxx | 11 | ||||
-rw-r--r-- | connectivity/source/drivers/macab/MacabServices.cxx | 107 | ||||
-rw-r--r-- | connectivity/source/drivers/macab/macab1.component | 5 |
4 files changed, 12 insertions, 136 deletions
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> |