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 "dbase/DDriver.hxx"
30 #include <cppuhelper/factory.hxx>
32 using namespace connectivity::dbase
;
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
,
48 //---------------------------------------------------------------------------------------
49 struct ProviderRequest
51 Reference
< XSingleServiceFactory
> xRet
;
52 Reference
< XMultiServiceFactory
> const xServiceManager
;
53 OUString
const sImplementationName
;
56 void* pServiceManager
,
57 sal_Char
const* pImplementationName
59 : xServiceManager(reinterpret_cast<XMultiServiceFactory
*>(pServiceManager
))
60 , sImplementationName(OUString::createFromAscii(pImplementationName
))
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
))
75 xRet
= creator( xServiceManager
, sImplementationName
,Factory
, Services
,0);
83 void* getProvider() const { return xRet
.get(); }
86 //---------------------------------------------------------------------------------------
87 extern "C" SAL_DLLPUBLIC_EXPORT
void* SAL_CALL
component_getFactory(
88 const sal_Char
* pImplementationName
,
89 void* pServiceManager
,
90 void* /*pRegistryKey*/)
95 ProviderRequest
aReq(pServiceManager
,pImplementationName
);
98 ODriver::getImplementationName_Static(),
99 ODriver::getSupportedServiceNames_Static(),
100 ODriver_CreateInstance
, ::cppu::createSingleFactory
)
104 aReq
.xRet
->acquire();
106 pRet
= aReq
.getProvider();
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */