1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_connectivity.hxx"
26
27 #include "MacabDriver.hxx"
28 #include <cppuhelper/factory.hxx>
29
30 using namespace connectivity::macab;
31 using ::rtl::OUString;
32 using ::com::sun::star::uno::Reference;
33 using ::com::sun::star::uno::Sequence;
34 using ::com::sun::star::lang::XSingleServiceFactory;
35 using ::com::sun::star::lang::XMultiServiceFactory;
36
37 typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
38 (
39 const Reference< XMultiServiceFactory > & rServiceManager,
40 const OUString & rComponentName,
41 ::cppu::ComponentInstantiation pCreateFunction,
42 const Sequence< OUString > & rServiceNames,
43 rtl_ModuleCount* _pTemp
44 );
45
46 //---------------------------------------------------------------------------------------
47 struct ProviderRequest
48 {
49 Reference< XSingleServiceFactory > xRet;
50 Reference< XMultiServiceFactory > const xServiceManager;
51 OUString const sImplementationName;
52
ProviderRequestProviderRequest53 ProviderRequest(
54 void* pServiceManager,
55 sal_Char const* pImplementationName
56 )
57 : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
58 , sImplementationName(OUString::createFromAscii(pImplementationName))
59 {
60 }
61
62 inline
CREATE_PROVIDERProviderRequest63 sal_Bool CREATE_PROVIDER(
64 const OUString& Implname,
65 const Sequence< OUString > & Services,
66 ::cppu::ComponentInstantiation Factory,
67 createFactoryFunc creator
68 )
69 {
70 if (!xRet.is() && (Implname == sImplementationName))
71 try
72 {
73 xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
74 }
75 catch(...)
76 {
77 }
78 return xRet.is();
79 }
80
getProviderProviderRequest81 void* getProvider() const { return xRet.get(); }
82 };
83
84 //---------------------------------------------------------------------------------------
85
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)86 extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
87 const sal_Char **ppEnvTypeName,
88 uno_Environment **
89 )
90 {
91 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
92 }
93
94 //---------------------------------------------------------------------------------------
component_getFactory(const sal_Char * pImplementationName,void * pServiceManager,void *)95 extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
96 const sal_Char* pImplementationName,
97 void* pServiceManager,
98 void*)
99 {
100 void* pRet = 0;
101 if (pServiceManager)
102 {
103 ProviderRequest aReq(pServiceManager,pImplementationName);
104
105 aReq.CREATE_PROVIDER(
106 MacabDriver::getImplementationName_Static(),
107 MacabDriver::getSupportedServiceNames_Static(),
108 &MacabDriver::Create,
109 ::cppu::createSingleFactory)
110 ;
111
112 if (aReq.xRet.is())
113 aReq.xRet->acquire();
114
115 pRet = aReq.getProvider();
116 }
117
118 return pRet;
119 };
120
121
122