Bump for 3.6-28
[LibreOffice.git] / connectivity / source / drivers / flat / Eservices.cxx
blobbc361e4961eb9d6b62ed4a18665bf1a33f905cfa
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 "flat/EDriver.hxx"
30 #include <cppuhelper/factory.hxx>
32 using namespace connectivity::flat;
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_getFactory(
88 const sal_Char* pImplementationName,
89 void* pServiceManager,
90 void* /*pRegistryKey*/)
92 void* pRet = 0;
93 if (pServiceManager)
95 ProviderRequest aReq(pServiceManager,pImplementationName);
97 aReq.CREATE_PROVIDER(
98 ODriver::getImplementationName_Static(),
99 ODriver::getSupportedServiceNames_Static(),
100 ODriver_CreateInstance, ::cppu::createSingleFactory)
103 if(aReq.xRet.is())
104 aReq.xRet->acquire();
106 pRet = aReq.getProvider();
109 return pRet;
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */