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