diff --git a/connectivity/Library_odbc.mk b/connectivity/Library_odbc.mk index 1d1c82cf174c..ae2b131c3649 100644 --- a/connectivity/Library_odbc.mk +++ b/connectivity/Library_odbc.mk @@ -44,7 +44,6 @@ $(eval $(call gb_Library_use_libraries,odbc,\ )) $(eval $(call gb_Library_add_exception_objects,odbc,\ - connectivity/source/drivers/odbc/oservices \ connectivity/source/drivers/odbc/ORealDriver \ connectivity/source/drivers/odbc/OFunctions \ connectivity/source/drivers/odbc/OPreparedStatement \ diff --git a/connectivity/source/drivers/odbc/ODriver.cxx b/connectivity/source/drivers/odbc/ODriver.cxx index 42dbff07ba95..b4318d43b18b 100644 --- a/connectivity/source/drivers/odbc/ODriver.cxx +++ b/connectivity/source/drivers/odbc/ODriver.cxx @@ -31,9 +31,9 @@ using namespace com::sun::star::lang; using namespace com::sun::star::beans; using namespace com::sun::star::sdbc; -ODBCDriver::ODBCDriver(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory) +ODBCDriver::ODBCDriver(const css::uno::Reference< css::uno::XComponentContext >& _rxContext) :ODriver_BASE(m_aMutex) - ,m_xORB(_rxFactory) + ,m_xContext(_rxContext) ,m_pDriverHandle(SQL_NULL_HANDLE) { } @@ -56,7 +56,7 @@ void ODBCDriver::disposing() // static ServiceInfo -OUString ODBCDriver::getImplementationName_Static( ) +OUString ODBCDriver::getImplementationName( ) { return "com.sun.star.comp.sdbc.ODBCDriver"; // this name is referenced in the configuration and in the odbc.xml @@ -64,29 +64,18 @@ OUString ODBCDriver::getImplementationName_Static( ) } -Sequence< OUString > ODBCDriver::getSupportedServiceNames_Static( ) +Sequence< OUString > ODBCDriver::getSupportedServiceNames( ) { return { "com.sun.star.sdbc.Driver" }; } -OUString SAL_CALL ODBCDriver::getImplementationName( ) -{ - return getImplementationName_Static(); -} - sal_Bool SAL_CALL ODBCDriver::supportsService( const OUString& _rServiceName ) { return cppu::supportsService(this, _rServiceName); } -Sequence< OUString > SAL_CALL ODBCDriver::getSupportedServiceNames( ) -{ - return getSupportedServiceNames_Static(); -} - - Reference< XConnection > SAL_CALL ODBCDriver::connect( const OUString& url, const Sequence< PropertyValue >& info ) { if ( ! acceptsURL(url) ) diff --git a/connectivity/source/drivers/odbc/ORealDriver.cxx b/connectivity/source/drivers/odbc/ORealDriver.cxx index 47576954a8f2..28c054b45f7c 100644 --- a/connectivity/source/drivers/odbc/ORealDriver.cxx +++ b/connectivity/source/drivers/odbc/ORealDriver.cxx @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "ORealDriver.hxx" #include #include #include @@ -32,7 +31,7 @@ namespace connectivity::odbc virtual oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const override; virtual SQLHANDLE EnvironmentHandle(OUString &_rPath) override; public: - explicit ORealOdbcDriver(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory) : ODBCDriver(_rxFactory) {} + explicit ORealOdbcDriver(const css::uno::Reference< css::uno::XComponentContext >& _rxContext) : ODBCDriver(_rxContext) {} }; } @@ -259,11 +258,6 @@ oslGenericFunction ORealOdbcDriver::getOdbcFunction(ODBC3SQLFunctionId _nIndex) } -css::uno::Reference< css::uno::XInterface > ODBCDriver_CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory) -{ - return *(new ORealOdbcDriver(_rxFactory)); -} - // ODBC Environment (common for all Connections): SQLHANDLE ORealOdbcDriver::EnvironmentHandle(OUString &_rPath) { @@ -286,7 +280,12 @@ SQLHANDLE ORealOdbcDriver::EnvironmentHandle(OUString &_rPath) return m_pDriverHandle; } - } +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +connectivity_odbc_ORealOdbcDriver_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence const&) +{ + return cppu::acquire(new connectivity::odbc::ORealOdbcDriver(context)); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/odbc/ORealDriver.hxx b/connectivity/source/drivers/odbc/ORealDriver.hxx deleted file mode 100644 index cfecb38936d2..000000000000 --- a/connectivity/source/drivers/odbc/ORealDriver.hxx +++ /dev/null @@ -1,42 +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 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_ODBC_OREALDRIVER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_ODBC_OREALDRIVER_HXX - -#include - -#include - -namespace com::sun::star { - namespace lang { class XMultiServiceFactory; } - namespace uno { class XInterface; } -} - -namespace connectivity::odbc { - -/// @throws css::uno::Exception -css::uno::Reference< css::uno::XInterface > -ODBCDriver_CreateInstance( css::uno::Reference< css::lang::XMultiServiceFactory > const & factory); - -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/odbc/odbc.component b/connectivity/source/drivers/odbc/odbc.component index 4fa186ea2a0e..4d3348378bc9 100644 --- a/connectivity/source/drivers/odbc/odbc.component +++ b/connectivity/source/drivers/odbc/odbc.component @@ -18,8 +18,9 @@ --> - + xmlns="http://openoffice.org/2010/uno-components"> + diff --git a/connectivity/source/drivers/odbc/oservices.cxx b/connectivity/source/drivers/odbc/oservices.cxx deleted file mode 100644 index 6461f8dde48f..000000000000 --- a/connectivity/source/drivers/odbc/oservices.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 "ORealDriver.hxx" -#include -#include -#include - -using namespace connectivity::odbc; -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(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* odbc_component_getFactory( - const char* pImplementationName, - void* pServiceManager, - void* /*pRegistryKey*/) -{ - void* pRet = nullptr; - if (pServiceManager) - { - ProviderRequest aReq(pServiceManager,pImplementationName); - - aReq.CREATE_PROVIDER( - ODBCDriver::getImplementationName_Static(), - ODBCDriver::getSupportedServiceNames_Static(), - ODBCDriver_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/inc/odbc/ODriver.hxx b/connectivity/source/inc/odbc/ODriver.hxx index c38eb502a215..29262aea777e 100644 --- a/connectivity/source/inc/odbc/ODriver.hxx +++ b/connectivity/source/inc/odbc/ODriver.hxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include @@ -43,24 +43,19 @@ namespace connectivity::odbc // of all the Connection objects // for this Driver - css::uno::Reference< css::lang::XMultiServiceFactory > m_xORB; + css::uno::Reference< css::uno::XComponentContext > m_xContext; SQLHANDLE m_pDriverHandle; virtual SQLHANDLE EnvironmentHandle(OUString &_rPath) = 0; public: - ODBCDriver(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory); + ODBCDriver(const css::uno::Reference< css::uno::XComponentContext >& rxContext); // only possibility to get the odbc functions virtual oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const = 0; // 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; @@ -74,7 +69,7 @@ namespace connectivity::odbc virtual sal_Int32 SAL_CALL getMajorVersion( ) override; virtual sal_Int32 SAL_CALL getMinorVersion( ) override; - const css::uno::Reference< css::lang::XMultiServiceFactory >& getORB() const { return m_xORB; } + const css::uno::Reference< css::uno::XComponentContext >& getContext() const { return m_xContext; } }; }