xref: /aoo41x/main/extensions/source/ole/servreg.cxx (revision 2a97ec55)
1*2a97ec55SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2a97ec55SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2a97ec55SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2a97ec55SAndrew Rist  * distributed with this work for additional information
6*2a97ec55SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2a97ec55SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2a97ec55SAndrew Rist  * "License"); you may not use this file except in compliance
9*2a97ec55SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2a97ec55SAndrew Rist  *
11*2a97ec55SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2a97ec55SAndrew Rist  *
13*2a97ec55SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2a97ec55SAndrew Rist  * software distributed under the License is distributed on an
15*2a97ec55SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2a97ec55SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2a97ec55SAndrew Rist  * specific language governing permissions and limitations
18*2a97ec55SAndrew Rist  * under the License.
19*2a97ec55SAndrew Rist  *
20*2a97ec55SAndrew Rist  *************************************************************/
21*2a97ec55SAndrew Rist 
22*2a97ec55SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_extensions.hxx"
26cdf0e10cSrcweir #include <rtl/unload.h>
27cdf0e10cSrcweir #include <osl/time.h>
28cdf0e10cSrcweir #include "ole2uno.hxx"
29cdf0e10cSrcweir #include "servprov.hxx"
30cdf0e10cSrcweir #include <rtl/ustring.hxx>
31cdf0e10cSrcweir #include <cppuhelper/factory.hxx>
32cdf0e10cSrcweir using namespace rtl;
33cdf0e10cSrcweir using namespace ole_adapter;
34cdf0e10cSrcweir using namespace cppu;
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace ole_adapter
37cdf0e10cSrcweir {
38cdf0e10cSrcweir rtl_StandardModuleCount globalModuleCount= MODULE_COUNT_INIT;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 
ConverterProvider_CreateInstance2(const Reference<XMultiServiceFactory> & xSMgr)42cdf0e10cSrcweir Reference<XInterface> SAL_CALL ConverterProvider_CreateInstance2(	const Reference<XMultiServiceFactory> & xSMgr)
43cdf0e10cSrcweir 							throw(Exception)
44cdf0e10cSrcweir {
45cdf0e10cSrcweir 	Reference<XInterface> xService = *new OleConverter_Impl2( xSMgr);
46cdf0e10cSrcweir 	return xService;
47cdf0e10cSrcweir }
48cdf0e10cSrcweir 
ConverterProvider_CreateInstanceVar1(const Reference<XMultiServiceFactory> & xSMgr)49cdf0e10cSrcweir Reference<XInterface> SAL_CALL ConverterProvider_CreateInstanceVar1(	const Reference<XMultiServiceFactory> & xSMgr)
50cdf0e10cSrcweir 							throw(Exception)
51cdf0e10cSrcweir {
52cdf0e10cSrcweir 	Reference<XInterface> xService = *new OleConverter_Impl2( xSMgr, UNO_OBJECT_WRAPPER_REMOTE_OPT, IUNKNOWN_WRAPPER_IMPL);
53cdf0e10cSrcweir 	return xService;
54cdf0e10cSrcweir }
55cdf0e10cSrcweir 
OleClient_CreateInstance(const Reference<XMultiServiceFactory> & xSMgr)56cdf0e10cSrcweir Reference<XInterface> SAL_CALL OleClient_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr)
57cdf0e10cSrcweir 							throw(Exception)
58cdf0e10cSrcweir {
59cdf0e10cSrcweir 	Reference<XInterface> xService = *new OleClient_Impl( xSMgr);
60cdf0e10cSrcweir 	return xService;
61cdf0e10cSrcweir }
62cdf0e10cSrcweir 
OleServer_CreateInstance(const Reference<XMultiServiceFactory> & xSMgr)63cdf0e10cSrcweir Reference<XInterface> SAL_CALL OleServer_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr)
64cdf0e10cSrcweir 							throw (Exception)
65cdf0e10cSrcweir {
66cdf0e10cSrcweir 	Reference<XInterface > xService = *new OleServer_Impl(xSMgr);
67cdf0e10cSrcweir 	return xService;
68cdf0e10cSrcweir }
69cdf0e10cSrcweir } // end namespace
70cdf0e10cSrcweir 
component_getFactory(const sal_Char * pImplName,void * pServiceManager,void *)71cdf0e10cSrcweir extern "C" void * SAL_CALL component_getFactory(
72cdf0e10cSrcweir 	const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
73cdf0e10cSrcweir {
74cdf0e10cSrcweir 	void * pRet = 0;
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	OUString aImplName( OUString::createFromAscii( pImplName ) );
77cdf0e10cSrcweir 	Reference< XSingleServiceFactory > xFactory;
78cdf0e10cSrcweir 	Sequence<OUString> seqServiceNames;
79cdf0e10cSrcweir 	if (pServiceManager && aImplName.equals(  reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleConverter2")  ))
80cdf0e10cSrcweir 	{
81cdf0e10cSrcweir 		xFactory=  createSingleFactory( reinterpret_cast< XMultiServiceFactory*>(pServiceManager),
82cdf0e10cSrcweir 										 OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleConverter2")),
83cdf0e10cSrcweir 										 ConverterProvider_CreateInstance2, seqServiceNames,
84cdf0e10cSrcweir 										 &globalModuleCount.modCnt );
85cdf0e10cSrcweir 	}
86cdf0e10cSrcweir 	else if (pServiceManager && aImplName.equals(  reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleConverterVar1")  ))
87cdf0e10cSrcweir 	{
88cdf0e10cSrcweir 		xFactory= createSingleFactory( reinterpret_cast<XMultiServiceFactory*>(pServiceManager),
89cdf0e10cSrcweir 									   OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleConverterVar1")),
90cdf0e10cSrcweir 									   ConverterProvider_CreateInstanceVar1, seqServiceNames,
91cdf0e10cSrcweir 									   &globalModuleCount.modCnt );
92cdf0e10cSrcweir 	}
93cdf0e10cSrcweir 	else if(pServiceManager && aImplName.equals(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleClient")))
94cdf0e10cSrcweir 	{
95cdf0e10cSrcweir 		xFactory= createSingleFactory( reinterpret_cast< XMultiServiceFactory*>(pServiceManager),
96cdf0e10cSrcweir 									   OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleClient")),
97cdf0e10cSrcweir 									   OleClient_CreateInstance, seqServiceNames,
98cdf0e10cSrcweir 									   &globalModuleCount.modCnt);
99cdf0e10cSrcweir 	}
100cdf0e10cSrcweir 	else if(pServiceManager && aImplName.equals(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleServer")))
101cdf0e10cSrcweir 	{
102cdf0e10cSrcweir 		xFactory= createOneInstanceFactory( reinterpret_cast< XMultiServiceFactory*>(pServiceManager),
103cdf0e10cSrcweir 											OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleServer")),
104cdf0e10cSrcweir 											OleServer_CreateInstance, seqServiceNames,
105cdf0e10cSrcweir 											&globalModuleCount.modCnt);
106cdf0e10cSrcweir 	}
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	if (xFactory.is())
109cdf0e10cSrcweir 	{
110cdf0e10cSrcweir 		xFactory->acquire();
111cdf0e10cSrcweir 		pRet = xFactory.get();
112cdf0e10cSrcweir 	}
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	return pRet;
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)118cdf0e10cSrcweir extern "C" void SAL_CALL component_getImplementationEnvironment(
119cdf0e10cSrcweir 	const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
120cdf0e10cSrcweir {
121cdf0e10cSrcweir 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
122cdf0e10cSrcweir }
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 
component_canUnload(TimeValue * libUnused)125cdf0e10cSrcweir extern "C"	sal_Bool component_canUnload( TimeValue* libUnused)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir 	return globalModuleCount.canUnload( &globalModuleCount, libUnused);
128cdf0e10cSrcweir }
129