Bump for 3.6-28
[LibreOffice.git] / connectivity / source / drivers / ado / Aservices.cxx
blob79c438a6d56fd26c540d814a48e5fa04f5a76eab
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 "ado/ADriver.hxx"
30 #include <cppuhelper/factory.hxx>
32 using namespace connectivity::ado;
33 using ::rtl::OUString;
34 using ::com::sun::star::uno::Reference;
35 using ::com::sun::star::uno::Sequence;
36 using ::com::sun::star::lang::XSingleServiceFactory;
37 using ::com::sun::star::lang::XMultiServiceFactory;
39 typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
41 const Reference< XMultiServiceFactory > & rServiceManager,
42 const OUString & rComponentName,
43 ::cppu::ComponentInstantiation pCreateFunction,
44 const Sequence< OUString > & rServiceNames ,
45 rtl_ModuleCount* _pT
48 //---------------------------------------------------------------------------------------
49 struct ProviderRequest
51 Reference< XSingleServiceFactory > xRet;
52 Reference< XMultiServiceFactory > const xServiceManager;
53 OUString const sImplementationName;
55 ProviderRequest(
56 void* pServiceManager,
57 sal_Char const* pImplementationName
59 : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
60 , sImplementationName(OUString::createFromAscii(pImplementationName))
64 inline
65 sal_Bool CREATE_PROVIDER(
66 const OUString& Implname,
67 const Sequence< OUString > & Services,
68 ::cppu::ComponentInstantiation Factory,
69 createFactoryFunc creator
72 if (!xRet.is() && (Implname == sImplementationName))
73 try
75 xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
77 catch(...)
80 return xRet.is();
83 void* getProvider() const { return xRet.get(); }
86 //---------------------------------------------------------------------------------------
87 extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
88 const sal_Char **ppEnvTypeName,
89 uno_Environment ** /*ppEnv*/)
91 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ":affine";
94 //---------------------------------------------------------------------------------------
95 extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
96 const sal_Char* pImplementationName,
97 void* pServiceManager,
98 void* /*pRegistryKey*/)
100 void* pRet = 0;
101 if (pServiceManager)
103 ProviderRequest aReq(pServiceManager,pImplementationName);
105 aReq.CREATE_PROVIDER(
106 ODriver::getImplementationName_Static(),
107 ODriver::getSupportedServiceNames_Static(),
108 ODriver_CreateInstance, ::cppu::createSingleFactory)
111 if(aReq.xRet.is())
112 aReq.xRet->acquire();
114 pRet = aReq.getProvider();
117 return pRet;
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */