xref: /AOO41X/main/extensions/source/ole/servprov.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_extensions.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #ifdef __MINGW32__
32*cdf0e10cSrcweir #define INITGUID
33*cdf0e10cSrcweir #include <initguid.h>
34*cdf0e10cSrcweir #else
35*cdf0e10cSrcweir #include "ole2uno.hxx"
36*cdf0e10cSrcweir #include "unoconversionutilities.hxx"
37*cdf0e10cSrcweir #endif
38*cdf0e10cSrcweir #include "servprov.hxx"
39*cdf0e10cSrcweir #include "unoobjw.hxx"
40*cdf0e10cSrcweir #include "oleobjw.hxx"
41*cdf0e10cSrcweir #include <rtl/unload.h>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #include <tools/presys.h>
44*cdf0e10cSrcweir #define _WIN32_WINNT 0x0400
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #if defined(_MSC_VER) && (_MSC_VER >= 1300)
47*cdf0e10cSrcweir #undef _DEBUG
48*cdf0e10cSrcweir #endif
49*cdf0e10cSrcweir #include <atlbase.h>
50*cdf0e10cSrcweir extern CComModule _Module;
51*cdf0e10cSrcweir #include <atlcom.h>
52*cdf0e10cSrcweir #include <tools/postsys.h>
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir using namespace std;
56*cdf0e10cSrcweir using namespace cppu;
57*cdf0e10cSrcweir using namespace rtl;
58*cdf0e10cSrcweir using namespace osl;
59*cdf0e10cSrcweir using namespace com::sun::star::lang;
60*cdf0e10cSrcweir using namespace com::sun::star::uno;
61*cdf0e10cSrcweir using namespace com::sun::star::bridge;
62*cdf0e10cSrcweir using namespace com::sun::star::bridge::ModelDependent;
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir namespace ole_adapter
67*cdf0e10cSrcweir {
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir #include <initguid.h>
70*cdf0e10cSrcweir // prior 5.2 ( src569 ver m)
71*cdf0e10cSrcweir // {3ECF78F0-B149-11D2-8EBE-00105AD848AF}
72*cdf0e10cSrcweir //DEFINE_GUID(OID_ServiceManager, 0x3ECF78F0, 0xB149, 0x11d2, 0x8E, 0xBE, 0x00, 0x10, 0x5A, 0xD8, 0x48, 0xAF);
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir #ifndef OWNGUID
75*cdf0e10cSrcweir // GUID used since 5.2 ( src569 m)
76*cdf0e10cSrcweir // {82154420-0FBF-11d4-8313-005004526AB4}
77*cdf0e10cSrcweir DEFINE_GUID(OID_ServiceManager, 0x82154420, 0xfbf, 0x11d4, 0x83, 0x13, 0x0, 0x50, 0x4, 0x52, 0x6a, 0xb4);
78*cdf0e10cSrcweir #else
79*cdf0e10cSrcweir // Alternative GUID
80*cdf0e10cSrcweir // {D9BB9D1D-BFA9-4357-9F11-9A2E9061F06E}
81*cdf0e10cSrcweir DEFINE_GUID(OID_ServiceManager, 0xd9bb9d1d, 0xbfa9, 0x4357, 0x9f, 0x11, 0x9a, 0x2e, 0x90, 0x61, 0xf0, 0x6e);
82*cdf0e10cSrcweir #endif
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir extern	rtl_StandardModuleCount globalModuleCount;
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir /*****************************************************************************
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	class implementation ProviderOleWrapper_Impl
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir *****************************************************************************/
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir ProviderOleWrapper_Impl::ProviderOleWrapper_Impl(const Reference<XMultiServiceFactory>& smgr,
93*cdf0e10cSrcweir 												 const Reference<XSingleServiceFactory>& xSFact, GUID* pGuid)
94*cdf0e10cSrcweir 	: m_xSingleServiceFactory(xSFact),
95*cdf0e10cSrcweir 	  m_smgr( smgr)
96*cdf0e10cSrcweir {
97*cdf0e10cSrcweir 	m_guid = *pGuid;
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 	Reference<XInterface> xInt = smgr->createInstance(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.oleautomation.BridgeSupplier"));
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 	if (xInt.is())
102*cdf0e10cSrcweir 	{
103*cdf0e10cSrcweir 		Any a= xInt->queryInterface( ::getCppuType( reinterpret_cast<
104*cdf0e10cSrcweir 												  Reference< XBridgeSupplier2>* >(0)));
105*cdf0e10cSrcweir 		a >>= m_bridgeSupplier;
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir 	}
108*cdf0e10cSrcweir }
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir ProviderOleWrapper_Impl::~ProviderOleWrapper_Impl()
111*cdf0e10cSrcweir {
112*cdf0e10cSrcweir }
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir sal_Bool ProviderOleWrapper_Impl::registerClass()
115*cdf0e10cSrcweir {
116*cdf0e10cSrcweir 	HRESULT hresult;
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 	o2u_attachCurrentThread();
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 	hresult = CoRegisterClassObject(
121*cdf0e10cSrcweir 			m_guid,
122*cdf0e10cSrcweir 			this,
123*cdf0e10cSrcweir 			CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
124*cdf0e10cSrcweir 			REGCLS_MULTIPLEUSE,
125*cdf0e10cSrcweir 			&m_factoryHandle);
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 	return (hresult == NOERROR);
128*cdf0e10cSrcweir }
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir sal_Bool ProviderOleWrapper_Impl::deregisterClass()
131*cdf0e10cSrcweir {
132*cdf0e10cSrcweir 	HRESULT hresult = CoRevokeClassObject(m_factoryHandle);
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 	return (hresult == NOERROR);
135*cdf0e10cSrcweir }
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir STDMETHODIMP ProviderOleWrapper_Impl::QueryInterface(REFIID riid, void FAR* FAR* ppv)
138*cdf0e10cSrcweir {
139*cdf0e10cSrcweir     if(IsEqualIID(riid, IID_IUnknown))
140*cdf0e10cSrcweir 	{
141*cdf0e10cSrcweir 		AddRef();
142*cdf0e10cSrcweir 		*ppv = (IUnknown*) (IClassFactory*) this;
143*cdf0e10cSrcweir 		return NOERROR;
144*cdf0e10cSrcweir     }
145*cdf0e10cSrcweir     else if (IsEqualIID(riid, IID_IClassFactory))
146*cdf0e10cSrcweir 	{
147*cdf0e10cSrcweir 		AddRef();
148*cdf0e10cSrcweir 		*ppv = (IClassFactory*) this;
149*cdf0e10cSrcweir 		return NOERROR;
150*cdf0e10cSrcweir 	}
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     *ppv = NULL;
153*cdf0e10cSrcweir     return ResultFromScode(E_NOINTERFACE);
154*cdf0e10cSrcweir }
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir STDMETHODIMP_(ULONG) ProviderOleWrapper_Impl::AddRef()
157*cdf0e10cSrcweir {
158*cdf0e10cSrcweir 	return osl_incrementInterlockedCount( &m_refCount);
159*cdf0e10cSrcweir }
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir STDMETHODIMP_(ULONG) ProviderOleWrapper_Impl::Release()
162*cdf0e10cSrcweir {
163*cdf0e10cSrcweir     MutexGuard aGuard( Mutex::getGlobalMutex());
164*cdf0e10cSrcweir     ULONG refCount = --m_refCount;
165*cdf0e10cSrcweir 	if (m_refCount == 0)
166*cdf0e10cSrcweir 	{
167*cdf0e10cSrcweir 		delete this;
168*cdf0e10cSrcweir 	}
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir     return refCount;
171*cdf0e10cSrcweir }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir STDMETHODIMP ProviderOleWrapper_Impl::CreateInstance(IUnknown FAR* punkOuter,
174*cdf0e10cSrcweir 													 REFIID riid,
175*cdf0e10cSrcweir     												 void FAR* FAR* ppv)
176*cdf0e10cSrcweir {
177*cdf0e10cSrcweir 	HRESULT ret = ResultFromScode(E_UNEXPECTED);
178*cdf0e10cSrcweir 	punkOuter = NULL;
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir 	Reference<XInterface> xInstance;
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir 	if (m_xSingleServiceFactory.is())
183*cdf0e10cSrcweir 	{
184*cdf0e10cSrcweir 		xInstance = m_xSingleServiceFactory->createInstance();
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir 		if (xInstance.is())
187*cdf0e10cSrcweir 		{
188*cdf0e10cSrcweir 			Any usrAny(&xInstance, getCppuType( & xInstance));
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir 			sal_uInt8 arId[16];
191*cdf0e10cSrcweir 			rtl_getGlobalProcessId( arId );
192*cdf0e10cSrcweir 			Any oleAny = m_bridgeSupplier->createBridge(usrAny,
193*cdf0e10cSrcweir 										Sequence<sal_Int8>((sal_Int8*)arId, 16),
194*cdf0e10cSrcweir 										UNO,
195*cdf0e10cSrcweir 										OLE);
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir 			if (oleAny.getValueTypeClass() == getCppuType( (sal_uInt32 *)0).getTypeClass())
199*cdf0e10cSrcweir 			{
200*cdf0e10cSrcweir 				VARIANT* pVariant = *(VARIANT**)oleAny.getValue();
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 				if (pVariant->vt == VT_DISPATCH)
203*cdf0e10cSrcweir 				{
204*cdf0e10cSrcweir 		    		ret = pVariant->pdispVal->QueryInterface(riid, ppv);
205*cdf0e10cSrcweir 				}
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 				VariantClear(pVariant);
208*cdf0e10cSrcweir 				CoTaskMemFree(pVariant);
209*cdf0e10cSrcweir 			}
210*cdf0e10cSrcweir 		}
211*cdf0e10cSrcweir 	}
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir 	return ret;
214*cdf0e10cSrcweir }
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir STDMETHODIMP ProviderOleWrapper_Impl::LockServer(int /*fLock*/)
217*cdf0e10cSrcweir {
218*cdf0e10cSrcweir     return NOERROR;
219*cdf0e10cSrcweir }
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir /*****************************************************************************
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir 	class implementation OneInstanceOleWrapper_Impl
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir *****************************************************************************/
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir OneInstanceOleWrapper_Impl::OneInstanceOleWrapper_Impl(  const Reference<XMultiServiceFactory>& smgr,
228*cdf0e10cSrcweir 														 const Reference<XInterface>& xInst,
229*cdf0e10cSrcweir                                                          GUID* pGuid,
230*cdf0e10cSrcweir                                                          sal_Bool bAsApplication )
231*cdf0e10cSrcweir 	: m_xInst(xInst), m_refCount(0),
232*cdf0e10cSrcweir 	  m_smgr( smgr),
233*cdf0e10cSrcweir       m_factoryHandle( 0 ),
234*cdf0e10cSrcweir       m_bAsApplication( bAsApplication ),
235*cdf0e10cSrcweir       m_nApplRegHandle( 0 )
236*cdf0e10cSrcweir {
237*cdf0e10cSrcweir 	m_guid = *pGuid;
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir 	Reference<XInterface> xInt = m_smgr->createInstance(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.oleautomation.BridgeSupplier"));
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir 	if (xInt.is())
242*cdf0e10cSrcweir 	{
243*cdf0e10cSrcweir 		Any a= xInt->queryInterface( getCppuType(
244*cdf0e10cSrcweir 			reinterpret_cast< Reference<XBridgeSupplier2>*>(0)));
245*cdf0e10cSrcweir 		a >>= m_bridgeSupplier;
246*cdf0e10cSrcweir 	}
247*cdf0e10cSrcweir }
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir OneInstanceOleWrapper_Impl::~OneInstanceOleWrapper_Impl()
250*cdf0e10cSrcweir {
251*cdf0e10cSrcweir }
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir sal_Bool OneInstanceOleWrapper_Impl::registerClass()
254*cdf0e10cSrcweir {
255*cdf0e10cSrcweir 	HRESULT hresult;
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir 	o2u_attachCurrentThread();
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir 	hresult = CoRegisterClassObject(
260*cdf0e10cSrcweir 			m_guid,
261*cdf0e10cSrcweir 			this,
262*cdf0e10cSrcweir 			CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
263*cdf0e10cSrcweir 			REGCLS_MULTIPLEUSE,
264*cdf0e10cSrcweir 			&m_factoryHandle);
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir     if ( hresult == NOERROR && m_bAsApplication )
267*cdf0e10cSrcweir         hresult = RegisterActiveObject( this, m_guid, ACTIVEOBJECT_WEAK, &m_nApplRegHandle );
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir 	return (hresult == NOERROR);
270*cdf0e10cSrcweir }
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir sal_Bool OneInstanceOleWrapper_Impl::deregisterClass()
273*cdf0e10cSrcweir {
274*cdf0e10cSrcweir     HRESULT hresult1 = NOERROR;
275*cdf0e10cSrcweir     if ( m_bAsApplication )
276*cdf0e10cSrcweir         hresult1 = RevokeActiveObject( m_nApplRegHandle, NULL );
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir 	HRESULT hresult2 = CoRevokeClassObject(m_factoryHandle);
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir 	return (hresult1 == NOERROR && hresult2 == NOERROR);
281*cdf0e10cSrcweir }
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir STDMETHODIMP OneInstanceOleWrapper_Impl::QueryInterface(REFIID riid, void FAR* FAR* ppv)
284*cdf0e10cSrcweir {
285*cdf0e10cSrcweir     if(IsEqualIID(riid, IID_IUnknown))
286*cdf0e10cSrcweir 	{
287*cdf0e10cSrcweir 		AddRef();
288*cdf0e10cSrcweir 		*ppv = (IUnknown*) (IClassFactory*) this;
289*cdf0e10cSrcweir 		return NOERROR;
290*cdf0e10cSrcweir     }
291*cdf0e10cSrcweir     else if (IsEqualIID(riid, IID_IClassFactory))
292*cdf0e10cSrcweir 	{
293*cdf0e10cSrcweir 		AddRef();
294*cdf0e10cSrcweir 		*ppv = (IClassFactory*) this;
295*cdf0e10cSrcweir 		return NOERROR;
296*cdf0e10cSrcweir 	}
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir     *ppv = NULL;
299*cdf0e10cSrcweir     return ResultFromScode(E_NOINTERFACE);
300*cdf0e10cSrcweir }
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir STDMETHODIMP_(ULONG) OneInstanceOleWrapper_Impl::AddRef()
303*cdf0e10cSrcweir {
304*cdf0e10cSrcweir 	return osl_incrementInterlockedCount( &m_refCount);
305*cdf0e10cSrcweir }
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir STDMETHODIMP_(ULONG) OneInstanceOleWrapper_Impl::Release()
308*cdf0e10cSrcweir {
309*cdf0e10cSrcweir     MutexGuard oGuard( Mutex::getGlobalMutex());
310*cdf0e10cSrcweir 	ULONG refCount = --m_refCount;
311*cdf0e10cSrcweir 	if ( m_refCount == 0)
312*cdf0e10cSrcweir 	{
313*cdf0e10cSrcweir 		delete this;
314*cdf0e10cSrcweir 	}
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir     return refCount;
317*cdf0e10cSrcweir }
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir STDMETHODIMP OneInstanceOleWrapper_Impl::CreateInstance(IUnknown FAR* punkOuter,
320*cdf0e10cSrcweir 													 	REFIID riid,
321*cdf0e10cSrcweir     												 	void FAR* FAR* ppv)
322*cdf0e10cSrcweir {
323*cdf0e10cSrcweir 	HRESULT ret = ResultFromScode(E_UNEXPECTED);
324*cdf0e10cSrcweir 	punkOuter = NULL;
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir 	if (m_xInst.is())
327*cdf0e10cSrcweir 	{
328*cdf0e10cSrcweir 		Any usrAny(&m_xInst, getCppuType( &m_xInst));
329*cdf0e10cSrcweir 		sal_uInt8 arId[16];
330*cdf0e10cSrcweir 		rtl_getGlobalProcessId( arId);
331*cdf0e10cSrcweir 		Any oleAny = m_bridgeSupplier->createBridge(usrAny,
332*cdf0e10cSrcweir 										Sequence<sal_Int8>( (sal_Int8*)arId, 16),
333*cdf0e10cSrcweir 										UNO,
334*cdf0e10cSrcweir 										OLE);
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 		if (oleAny.getValueTypeClass() == TypeClass_UNSIGNED_LONG)
338*cdf0e10cSrcweir 		{
339*cdf0e10cSrcweir 			VARIANT* pVariant = *(VARIANT**)oleAny.getValue();
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir 			if ((pVariant->vt == VT_UNKNOWN) || (pVariant->vt == VT_DISPATCH))
342*cdf0e10cSrcweir 			{
343*cdf0e10cSrcweir 	    		ret = pVariant->punkVal->QueryInterface(riid, ppv);
344*cdf0e10cSrcweir 			}
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir 			VariantClear(pVariant);
347*cdf0e10cSrcweir 			CoTaskMemFree(pVariant);
348*cdf0e10cSrcweir 		}
349*cdf0e10cSrcweir 	}
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir 	return ret;
352*cdf0e10cSrcweir }
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir STDMETHODIMP OneInstanceOleWrapper_Impl::LockServer(int /*fLock*/)
355*cdf0e10cSrcweir {
356*cdf0e10cSrcweir     return NOERROR;
357*cdf0e10cSrcweir }
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir /*****************************************************************************
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir 	class implementation OleConverter_Impl2
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir *****************************************************************************/
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir OleConverter_Impl2::OleConverter_Impl2( const Reference<XMultiServiceFactory> &smgr):
367*cdf0e10cSrcweir 	UnoConversionUtilities<OleConverter_Impl2>( smgr)
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir {
370*cdf0e10cSrcweir 	// library unloading support
371*cdf0e10cSrcweir 	globalModuleCount.modCnt.acquire( &globalModuleCount.modCnt);
372*cdf0e10cSrcweir }
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir // The XMultiServiceFactory is later set by XInitialization
375*cdf0e10cSrcweir OleConverter_Impl2::OleConverter_Impl2( const  Reference<XMultiServiceFactory>& smgr, sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass ):
376*cdf0e10cSrcweir 	UnoConversionUtilities<OleConverter_Impl2>( smgr, unoWrapperClass, comWrapperClass  )
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir {
379*cdf0e10cSrcweir 	//library unloading support
380*cdf0e10cSrcweir 	globalModuleCount.modCnt.acquire( &globalModuleCount.modCnt);
381*cdf0e10cSrcweir }
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir OleConverter_Impl2::~OleConverter_Impl2()
384*cdf0e10cSrcweir {
385*cdf0e10cSrcweir 	globalModuleCount.modCnt.release( &globalModuleCount.modCnt);
386*cdf0e10cSrcweir }
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir // XBridgeSupplier --------------------------------------------------------------
389*cdf0e10cSrcweir Any SAL_CALL OleConverter_Impl2::createBridge(const Any& modelDepObject,
390*cdf0e10cSrcweir 									   const Sequence< sal_Int8 >& ProcessId,
391*cdf0e10cSrcweir 									   sal_Int16 sourceModelType,
392*cdf0e10cSrcweir 									   sal_Int16 destModelType)
393*cdf0e10cSrcweir 									   throw (IllegalArgumentException,
394*cdf0e10cSrcweir 									   			RuntimeException )
395*cdf0e10cSrcweir {
396*cdf0e10cSrcweir 	Any ret;
397*cdf0e10cSrcweir 	sal_uInt8 arId[16];
398*cdf0e10cSrcweir 	rtl_getGlobalProcessId( arId );
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir 	Sequence< sal_Int8 > seqProcessId( (sal_Int8*)arId, 16);
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir 	if ( seqProcessId == ProcessId)
403*cdf0e10cSrcweir 	{
404*cdf0e10cSrcweir 		if (sourceModelType == UNO)
405*cdf0e10cSrcweir 		{
406*cdf0e10cSrcweir 			if (destModelType == UNO)
407*cdf0e10cSrcweir 			{
408*cdf0e10cSrcweir 				// same model -> copy value only
409*cdf0e10cSrcweir 				ret = modelDepObject;
410*cdf0e10cSrcweir 			}
411*cdf0e10cSrcweir 			else if (destModelType == OLE)
412*cdf0e10cSrcweir 			{
413*cdf0e10cSrcweir 				// convert UNO any into variant
414*cdf0e10cSrcweir 				VARIANT* pVariant = (VARIANT*) CoTaskMemAlloc(sizeof(VARIANT));
415*cdf0e10cSrcweir 				VariantInit( pVariant);
416*cdf0e10cSrcweir                 try
417*cdf0e10cSrcweir                 {
418*cdf0e10cSrcweir                     anyToVariant( pVariant, modelDepObject);
419*cdf0e10cSrcweir                 }
420*cdf0e10cSrcweir                 catch(...)
421*cdf0e10cSrcweir 				{
422*cdf0e10cSrcweir 					CoTaskMemFree(pVariant);
423*cdf0e10cSrcweir 					throw IllegalArgumentException();
424*cdf0e10cSrcweir 				}
425*cdf0e10cSrcweir                 ret.setValue((void*) &pVariant, getCppuType((sal_uInt32*)0));
426*cdf0e10cSrcweir 			}
427*cdf0e10cSrcweir 			else
428*cdf0e10cSrcweir 				throw IllegalArgumentException();
429*cdf0e10cSrcweir 		}
430*cdf0e10cSrcweir 		else if (sourceModelType == OLE)
431*cdf0e10cSrcweir 		{
432*cdf0e10cSrcweir 			if (modelDepObject.getValueType() != getCppuType((sal_uInt32*)0))
433*cdf0e10cSrcweir 			{
434*cdf0e10cSrcweir 				throw IllegalArgumentException();
435*cdf0e10cSrcweir 			}
436*cdf0e10cSrcweir 			else if (destModelType == OLE)
437*cdf0e10cSrcweir 			{
438*cdf0e10cSrcweir 				// same model -> copy value only
439*cdf0e10cSrcweir 				VARIANT* pVariant = (VARIANT*) CoTaskMemAlloc(sizeof(VARIANT));
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir 				if (NOERROR != VariantCopy(pVariant, *(VARIANT**)modelDepObject.getValue()))
442*cdf0e10cSrcweir 				{
443*cdf0e10cSrcweir 					CoTaskMemFree(pVariant);
444*cdf0e10cSrcweir 					throw(IllegalArgumentException());
445*cdf0e10cSrcweir 				}
446*cdf0e10cSrcweir 				else
447*cdf0e10cSrcweir 				{
448*cdf0e10cSrcweir 					ret.setValue((void*) &pVariant, getCppuType((sal_uInt32*)0));
449*cdf0e10cSrcweir 				}
450*cdf0e10cSrcweir 			}
451*cdf0e10cSrcweir 			else if (destModelType == UNO)
452*cdf0e10cSrcweir 			{
453*cdf0e10cSrcweir 				// convert variant into UNO any
454*cdf0e10cSrcweir 				VARIANT* pVariant = *(VARIANT**)modelDepObject.getValue();
455*cdf0e10cSrcweir 				try
456*cdf0e10cSrcweir 				{
457*cdf0e10cSrcweir 					variantToAny(pVariant, ret);
458*cdf0e10cSrcweir 				}
459*cdf0e10cSrcweir 				catch (CannotConvertException & e)
460*cdf0e10cSrcweir 				{
461*cdf0e10cSrcweir 					throw IllegalArgumentException(
462*cdf0e10cSrcweir 						e.Message, 0, -1);
463*cdf0e10cSrcweir 				}
464*cdf0e10cSrcweir 			}
465*cdf0e10cSrcweir 			else
466*cdf0e10cSrcweir 				throw IllegalArgumentException();
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir 		}
469*cdf0e10cSrcweir 		else
470*cdf0e10cSrcweir 			throw IllegalArgumentException();
471*cdf0e10cSrcweir 	}
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir 	return ret;
474*cdf0e10cSrcweir }
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir // XInitialize ------------------------------------------------------------------------------
478*cdf0e10cSrcweir // the first argument is an XMultiServiceFactory if at all
479*cdf0e10cSrcweir void SAL_CALL OleConverter_Impl2::initialize( const Sequence< Any >& aArguments )
480*cdf0e10cSrcweir 				throw(Exception, RuntimeException)
481*cdf0e10cSrcweir {
482*cdf0e10cSrcweir 	if( aArguments.getLength() == 1 && aArguments[0].getValueTypeClass() == TypeClass_INTERFACE)
483*cdf0e10cSrcweir 	{
484*cdf0e10cSrcweir 		Reference < XInterface > xInt;
485*cdf0e10cSrcweir 		aArguments[0] >>= xInt;
486*cdf0e10cSrcweir 		Reference <XMultiServiceFactory> xMulti( xInt, UNO_QUERY);
487*cdf0e10cSrcweir 		m_smgrRemote= xMulti;
488*cdf0e10cSrcweir 	}
489*cdf0e10cSrcweir }
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir // UnoConversionUtilities -------------------------------------------------------------------
492*cdf0e10cSrcweir Reference< XInterface > OleConverter_Impl2::createUnoWrapperInstance()
493*cdf0e10cSrcweir {
494*cdf0e10cSrcweir 	if( m_nUnoWrapperClass == INTERFACE_OLE_WRAPPER_IMPL)
495*cdf0e10cSrcweir 	{
496*cdf0e10cSrcweir 		Reference<XWeak> xWeak= static_cast<XWeak*>( new InterfaceOleWrapper_Impl(
497*cdf0e10cSrcweir 								m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
498*cdf0e10cSrcweir 		return Reference<XInterface>( xWeak, UNO_QUERY);
499*cdf0e10cSrcweir 	}
500*cdf0e10cSrcweir 	else if( m_nUnoWrapperClass == UNO_OBJECT_WRAPPER_REMOTE_OPT)
501*cdf0e10cSrcweir 	{
502*cdf0e10cSrcweir 		Reference<XWeak> xWeak= static_cast<XWeak*>( new UnoObjectWrapperRemoteOpt(
503*cdf0e10cSrcweir 								m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
504*cdf0e10cSrcweir 		return Reference<XInterface>( xWeak, UNO_QUERY);
505*cdf0e10cSrcweir 	}
506*cdf0e10cSrcweir 	else
507*cdf0e10cSrcweir 		return Reference<XInterface>();
508*cdf0e10cSrcweir }
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir Reference< XInterface > OleConverter_Impl2::createComWrapperInstance()
511*cdf0e10cSrcweir {
512*cdf0e10cSrcweir 	Reference<XWeak> xWeak= static_cast<XWeak*>( new IUnknownWrapper_Impl(
513*cdf0e10cSrcweir 							m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
514*cdf0e10cSrcweir 	return Reference<XInterface>( xWeak, UNO_QUERY);
515*cdf0e10cSrcweir }
516*cdf0e10cSrcweir 
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir /*****************************************************************************
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir 	class implementation OleClient_Impl
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir *****************************************************************************/
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir OleClient_Impl::OleClient_Impl( const Reference<XMultiServiceFactory>& smgr):
526*cdf0e10cSrcweir 	UnoConversionUtilities<OleClient_Impl>( smgr)
527*cdf0e10cSrcweir {
528*cdf0e10cSrcweir 	// library unloading support
529*cdf0e10cSrcweir 	globalModuleCount.modCnt.acquire( &globalModuleCount.modCnt);
530*cdf0e10cSrcweir 	Reference<XInterface> xInt;// = m_smgr->createInstance(L"com.sun.star.bridge.OleBridgeSupplier2");
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir 	if (xInt.is())
533*cdf0e10cSrcweir 	{
534*cdf0e10cSrcweir 		Any a= xInt->queryInterface(getCppuType(
535*cdf0e10cSrcweir 			reinterpret_cast<Reference<XBridgeSupplier2>*>(0)));
536*cdf0e10cSrcweir 		a >>= m_bridgeSupplier;
537*cdf0e10cSrcweir 	}
538*cdf0e10cSrcweir }
539*cdf0e10cSrcweir 
540*cdf0e10cSrcweir OleClient_Impl::~OleClient_Impl()
541*cdf0e10cSrcweir {
542*cdf0e10cSrcweir 	// library unloading support
543*cdf0e10cSrcweir 	globalModuleCount.modCnt.release( &globalModuleCount.modCnt);
544*cdf0e10cSrcweir }
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir Sequence< OUString >	SAL_CALL OleClient_Impl::getAvailableServiceNames() throw( RuntimeException )
547*cdf0e10cSrcweir {
548*cdf0e10cSrcweir 	Sequence< OUString > ret;
549*cdf0e10cSrcweir 
550*cdf0e10cSrcweir 	return ret;
551*cdf0e10cSrcweir }
552*cdf0e10cSrcweir 
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir OUString OleClient_Impl::getImplementationName()
555*cdf0e10cSrcweir {
556*cdf0e10cSrcweir 	return OUString(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleClient"));
557*cdf0e10cSrcweir }
558*cdf0e10cSrcweir 
559*cdf0e10cSrcweir Reference<XInterface> SAL_CALL OleClient_Impl::createInstance(const OUString& ServiceSpecifier) throw (Exception, RuntimeException )
560*cdf0e10cSrcweir {
561*cdf0e10cSrcweir 	Reference<XInterface> 	ret;
562*cdf0e10cSrcweir 	HRESULT 		result;
563*cdf0e10cSrcweir 	IUnknown* 		pUnknown = NULL;
564*cdf0e10cSrcweir 	CLSID			classId;
565*cdf0e10cSrcweir 
566*cdf0e10cSrcweir 	o2u_attachCurrentThread();
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir 	result = CLSIDFromProgID(
569*cdf0e10cSrcweir   				reinterpret_cast<LPCWSTR>(ServiceSpecifier.getStr()),  	//Pointer to the ProgID
570*cdf0e10cSrcweir   				&classId);         				//Pointer to the CLSID
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir 
573*cdf0e10cSrcweir 	if (result == NOERROR)
574*cdf0e10cSrcweir 	{
575*cdf0e10cSrcweir 		result = CoCreateInstance(
576*cdf0e10cSrcweir 					  classId,     			//Class identifier (CLSID) of the object
577*cdf0e10cSrcweir 					  NULL, 			   	//Pointer to whether object is or isn't part of an aggregate
578*cdf0e10cSrcweir 					  CLSCTX_SERVER,  //Context for running executable code
579*cdf0e10cSrcweir 					  IID_IUnknown,         //Reference to the identifier of the interface
580*cdf0e10cSrcweir 					  (void**)&pUnknown);   //Address of output variable that receives
581*cdf0e10cSrcweir 	                       				   	// the interface pointer requested in riid
582*cdf0e10cSrcweir 	}
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir 	if (pUnknown != NULL)
585*cdf0e10cSrcweir 	{
586*cdf0e10cSrcweir 		Any	any;
587*cdf0e10cSrcweir 		CComVariant variant;
588*cdf0e10cSrcweir 
589*cdf0e10cSrcweir 		V_VT(&variant) = VT_UNKNOWN;
590*cdf0e10cSrcweir 		V_UNKNOWN(&variant)	= pUnknown;
591*cdf0e10cSrcweir 		// AddRef for Variant
592*cdf0e10cSrcweir 		pUnknown->AddRef();
593*cdf0e10cSrcweir 
594*cdf0e10cSrcweir 		// When the object is wrapped, then its refcount is increased
595*cdf0e10cSrcweir 		variantToAny(&variant, any);
596*cdf0e10cSrcweir         if (any.getValueTypeClass() == TypeClass_INTERFACE)
597*cdf0e10cSrcweir         {
598*cdf0e10cSrcweir             any >>= ret;
599*cdf0e10cSrcweir         }
600*cdf0e10cSrcweir 		pUnknown->Release(); // CoCreateInstance
601*cdf0e10cSrcweir 	}
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir 	return ret;
604*cdf0e10cSrcweir }
605*cdf0e10cSrcweir 
606*cdf0e10cSrcweir Reference<XInterface> SAL_CALL OleClient_Impl::createInstanceWithArguments(const OUString& ServiceSpecifier, const Sequence< Any >& /*Arguments*/) throw (Exception, RuntimeException)
607*cdf0e10cSrcweir {
608*cdf0e10cSrcweir 	return createInstance( ServiceSpecifier);
609*cdf0e10cSrcweir }
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir // UnoConversionUtilities -----------------------------------------------------------------------------
612*cdf0e10cSrcweir Reference< XInterface > OleClient_Impl::createUnoWrapperInstance()
613*cdf0e10cSrcweir {
614*cdf0e10cSrcweir 	if( m_nUnoWrapperClass == INTERFACE_OLE_WRAPPER_IMPL)
615*cdf0e10cSrcweir 	{
616*cdf0e10cSrcweir 		Reference<XWeak> xWeak= static_cast<XWeak*>( new InterfaceOleWrapper_Impl(
617*cdf0e10cSrcweir 								m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
618*cdf0e10cSrcweir 		return Reference<XInterface>( xWeak, UNO_QUERY);
619*cdf0e10cSrcweir 	}
620*cdf0e10cSrcweir 	else if( m_nUnoWrapperClass == UNO_OBJECT_WRAPPER_REMOTE_OPT)
621*cdf0e10cSrcweir 	{
622*cdf0e10cSrcweir 		Reference<XWeak> xWeak= static_cast<XWeak*>( new UnoObjectWrapperRemoteOpt(
623*cdf0e10cSrcweir 								m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
624*cdf0e10cSrcweir 		return Reference<XInterface>( xWeak, UNO_QUERY);
625*cdf0e10cSrcweir 	}
626*cdf0e10cSrcweir 	else
627*cdf0e10cSrcweir 		return Reference< XInterface>();
628*cdf0e10cSrcweir }
629*cdf0e10cSrcweir // UnoConversionUtilities -----------------------------------------------------------------------------
630*cdf0e10cSrcweir Reference< XInterface > OleClient_Impl::createComWrapperInstance( )
631*cdf0e10cSrcweir {
632*cdf0e10cSrcweir 	Reference<XWeak> xWeak= static_cast<XWeak*>( new IUnknownWrapper_Impl(
633*cdf0e10cSrcweir 							m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
634*cdf0e10cSrcweir 	return Reference<XInterface>( xWeak, UNO_QUERY);
635*cdf0e10cSrcweir }
636*cdf0e10cSrcweir 
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir 
639*cdf0e10cSrcweir /*****************************************************************************
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir 	class implementation OleServer_Impl
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir *****************************************************************************/
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir OleServer_Impl::OleServer_Impl( const Reference<XMultiServiceFactory>& smgr):
646*cdf0e10cSrcweir 	m_smgr( smgr)
647*cdf0e10cSrcweir {
648*cdf0e10cSrcweir 	//library unloading support
649*cdf0e10cSrcweir 	globalModuleCount.modCnt.acquire( &globalModuleCount.modCnt);
650*cdf0e10cSrcweir 	Reference<XInterface> xInt = m_smgr->createInstance(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.oleautomation.BridgeSupplier"));
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir 	if (xInt.is())
653*cdf0e10cSrcweir 	{
654*cdf0e10cSrcweir 		Any a= xInt->queryInterface( getCppuType(
655*cdf0e10cSrcweir 			reinterpret_cast< Reference<XBridgeSupplier2>*>(0)));
656*cdf0e10cSrcweir 		a >>= m_bridgeSupplier;
657*cdf0e10cSrcweir 	}
658*cdf0e10cSrcweir 
659*cdf0e10cSrcweir #ifndef OWNGUID
660*cdf0e10cSrcweir 	sal_Bool bOLERegister = sal_False;
661*cdf0e10cSrcweir #else
662*cdf0e10cSrcweir 	sal_Bool bOLERegister = sal_True;
663*cdf0e10cSrcweir #endif
664*cdf0e10cSrcweir 	sal_Bool ret = provideInstance( m_smgr, (GUID*)&OID_ServiceManager, bOLERegister );
665*cdf0e10cSrcweir     (void)ret;
666*cdf0e10cSrcweir }
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir OleServer_Impl::~OleServer_Impl()
669*cdf0e10cSrcweir {
670*cdf0e10cSrcweir 	while (!m_wrapperList.empty())
671*cdf0e10cSrcweir 	{
672*cdf0e10cSrcweir 		(*m_wrapperList.begin())->deregisterClass();
673*cdf0e10cSrcweir 		(*m_wrapperList.begin())->Release();
674*cdf0e10cSrcweir 		m_wrapperList.pop_front();
675*cdf0e10cSrcweir 	}
676*cdf0e10cSrcweir 	//library unloading support
677*cdf0e10cSrcweir 	globalModuleCount.modCnt.release( &globalModuleCount.modCnt);
678*cdf0e10cSrcweir }
679*cdf0e10cSrcweir // XInterface --------------------------------------------------
680*cdf0e10cSrcweir Any SAL_CALL OleServer_Impl::queryInterface( const Type& aType ) throw(RuntimeException)
681*cdf0e10cSrcweir {
682*cdf0e10cSrcweir 	Any a= ::cppu::queryInterface( aType, static_cast<XTypeProvider*>(this));
683*cdf0e10cSrcweir 	if( a == Any())
684*cdf0e10cSrcweir 		return OWeakObject::queryInterface( aType);
685*cdf0e10cSrcweir 	else
686*cdf0e10cSrcweir 		return a;
687*cdf0e10cSrcweir }
688*cdf0e10cSrcweir void SAL_CALL OleServer_Impl::acquire(  ) throw()
689*cdf0e10cSrcweir {
690*cdf0e10cSrcweir 	OWeakObject::acquire();
691*cdf0e10cSrcweir }
692*cdf0e10cSrcweir void SAL_CALL OleServer_Impl::release(  ) throw ()
693*cdf0e10cSrcweir {
694*cdf0e10cSrcweir 	OWeakObject::release();
695*cdf0e10cSrcweir }
696*cdf0e10cSrcweir 
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir // XTypeProvider --------------------------------------------------
699*cdf0e10cSrcweir Sequence< Type > SAL_CALL OleServer_Impl::getTypes( ) throw(RuntimeException)
700*cdf0e10cSrcweir {
701*cdf0e10cSrcweir 	static OTypeCollection *pCollection = 0;
702*cdf0e10cSrcweir 	if( ! pCollection )
703*cdf0e10cSrcweir 	{
704*cdf0e10cSrcweir 		MutexGuard guard( Mutex::getGlobalMutex() );
705*cdf0e10cSrcweir 		if( ! pCollection )
706*cdf0e10cSrcweir 		{
707*cdf0e10cSrcweir 			static OTypeCollection collection(
708*cdf0e10cSrcweir 				getCppuType(reinterpret_cast< Reference< XWeak>*>(0)),
709*cdf0e10cSrcweir 				getCppuType(reinterpret_cast< Reference< XTypeProvider>*>(0)) );
710*cdf0e10cSrcweir 			pCollection = &collection;
711*cdf0e10cSrcweir 		}
712*cdf0e10cSrcweir 	}
713*cdf0e10cSrcweir 	return (*pCollection).getTypes();
714*cdf0e10cSrcweir }
715*cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL OleServer_Impl::getImplementationId() throw(RuntimeException)
716*cdf0e10cSrcweir {
717*cdf0e10cSrcweir 	static OImplementationId *pId = 0;
718*cdf0e10cSrcweir 	if( ! pId )
719*cdf0e10cSrcweir 	{
720*cdf0e10cSrcweir 		MutexGuard guard( Mutex::getGlobalMutex() );
721*cdf0e10cSrcweir 		if( ! pId )
722*cdf0e10cSrcweir 		{
723*cdf0e10cSrcweir 			static OImplementationId id( sal_False );
724*cdf0e10cSrcweir 			pId = &id;
725*cdf0e10cSrcweir 		}
726*cdf0e10cSrcweir 	}
727*cdf0e10cSrcweir 	return (*pId).getImplementationId();
728*cdf0e10cSrcweir }
729*cdf0e10cSrcweir 
730*cdf0e10cSrcweir 
731*cdf0e10cSrcweir sal_Bool OleServer_Impl::provideService(const Reference<XSingleServiceFactory>& xSFact, GUID* guid)
732*cdf0e10cSrcweir {
733*cdf0e10cSrcweir 	IClassFactoryWrapper* pFac = new ProviderOleWrapper_Impl( m_smgr, xSFact, guid);
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir 	pFac->AddRef();
736*cdf0e10cSrcweir 
737*cdf0e10cSrcweir 	m_wrapperList.push_back(pFac);
738*cdf0e10cSrcweir 
739*cdf0e10cSrcweir 	return pFac->registerClass();
740*cdf0e10cSrcweir }
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir sal_Bool OleServer_Impl::provideInstance(const Reference<XInterface>& xInst, GUID* guid, sal_Bool bAsApplication )
743*cdf0e10cSrcweir {
744*cdf0e10cSrcweir 	IClassFactoryWrapper* pFac = new OneInstanceOleWrapper_Impl( m_smgr, xInst, guid, bAsApplication );
745*cdf0e10cSrcweir 
746*cdf0e10cSrcweir 	pFac->AddRef();
747*cdf0e10cSrcweir 	m_wrapperList.push_back(pFac);
748*cdf0e10cSrcweir 
749*cdf0e10cSrcweir 	return pFac->registerClass();
750*cdf0e10cSrcweir }
751*cdf0e10cSrcweir 
752*cdf0e10cSrcweir 
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir } // end namespace
755