Bump for 3.6-28
[LibreOffice.git] / connectivity / source / drivers / odbc / oservices.cxx
blob645272a151dd5329482fb37418760ca1ab45b1e0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "ORealDriver.hxx"
30 #include "odbc/ODriver.hxx"
31 #include <cppuhelper/factory.hxx>
33 using namespace connectivity::odbc;
34 using ::rtl::OUString;
35 using ::com::sun::star::uno::Reference;
36 using ::com::sun::star::uno::Sequence;
37 using ::com::sun::star::lang::XSingleServiceFactory;
38 using ::com::sun::star::lang::XMultiServiceFactory;
40 typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
42 const Reference< XMultiServiceFactory > & rServiceManager,
43 const OUString & rComponentName,
44 ::cppu::ComponentInstantiation pCreateFunction,
45 const Sequence< OUString > & rServiceNames,
46 rtl_ModuleCount* _pTemp
49 //---------------------------------------------------------------------------------------
50 struct ProviderRequest
52 Reference< XSingleServiceFactory > xRet;
53 Reference< XMultiServiceFactory > const xServiceManager;
54 OUString const sImplementationName;
56 ProviderRequest(
57 void* pServiceManager,
58 sal_Char const* pImplementationName
60 : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
61 , sImplementationName(OUString::createFromAscii(pImplementationName))
65 inline
66 sal_Bool CREATE_PROVIDER(
67 const OUString& Implname,
68 const Sequence< OUString > & Services,
69 ::cppu::ComponentInstantiation Factory,
70 createFactoryFunc creator
73 if (!xRet.is() && (Implname == sImplementationName))
74 try
76 xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
78 catch(...)
81 return xRet.is();
84 void* getProvider() const { return xRet.get(); }
87 //---------------------------------------------------------------------------------------
88 extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
89 const sal_Char* pImplementationName,
90 void* pServiceManager,
91 void* /*pRegistryKey*/)
93 void* pRet = 0;
94 if (pServiceManager)
96 ProviderRequest aReq(pServiceManager,pImplementationName);
98 aReq.CREATE_PROVIDER(
99 ODBCDriver::getImplementationName_Static(),
100 ODBCDriver::getSupportedServiceNames_Static(),
101 ODBCDriver_CreateInstance, ::cppu::createSingleFactory)
104 if(aReq.xRet.is())
105 aReq.xRet->acquire();
107 pRet = aReq.getProvider();
110 return pRet;
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */