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