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 #include <rtl/unload.h> 27 #include <osl/time.h> 28 #include "ole2uno.hxx" 29 #include "servprov.hxx" 30 #include <rtl/ustring.hxx> 31 #include <cppuhelper/factory.hxx> 32 using namespace rtl; 33 using namespace ole_adapter; 34 using namespace cppu; 35 36 namespace ole_adapter 37 { 38 rtl_StandardModuleCount globalModuleCount= MODULE_COUNT_INIT; 39 40 41 42 Reference<XInterface> SAL_CALL ConverterProvider_CreateInstance2( const Reference<XMultiServiceFactory> & xSMgr) 43 throw(Exception) 44 { 45 Reference<XInterface> xService = *new OleConverter_Impl2( xSMgr); 46 return xService; 47 } 48 49 Reference<XInterface> SAL_CALL ConverterProvider_CreateInstanceVar1( const Reference<XMultiServiceFactory> & xSMgr) 50 throw(Exception) 51 { 52 Reference<XInterface> xService = *new OleConverter_Impl2( xSMgr, UNO_OBJECT_WRAPPER_REMOTE_OPT, IUNKNOWN_WRAPPER_IMPL); 53 return xService; 54 } 55 56 Reference<XInterface> SAL_CALL OleClient_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr) 57 throw(Exception) 58 { 59 Reference<XInterface> xService = *new OleClient_Impl( xSMgr); 60 return xService; 61 } 62 63 Reference<XInterface> SAL_CALL OleServer_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr) 64 throw (Exception) 65 { 66 Reference<XInterface > xService = *new OleServer_Impl(xSMgr); 67 return xService; 68 } 69 } // end namespace 70 71 extern "C" void * SAL_CALL component_getFactory( 72 const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ ) 73 { 74 void * pRet = 0; 75 76 OUString aImplName( OUString::createFromAscii( pImplName ) ); 77 Reference< XSingleServiceFactory > xFactory; 78 Sequence<OUString> seqServiceNames; 79 if (pServiceManager && aImplName.equals( reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleConverter2") )) 80 { 81 xFactory= createSingleFactory( reinterpret_cast< XMultiServiceFactory*>(pServiceManager), 82 OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleConverter2")), 83 ConverterProvider_CreateInstance2, seqServiceNames, 84 &globalModuleCount.modCnt ); 85 } 86 else if (pServiceManager && aImplName.equals( reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleConverterVar1") )) 87 { 88 xFactory= createSingleFactory( reinterpret_cast<XMultiServiceFactory*>(pServiceManager), 89 OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleConverterVar1")), 90 ConverterProvider_CreateInstanceVar1, seqServiceNames, 91 &globalModuleCount.modCnt ); 92 } 93 else if(pServiceManager && aImplName.equals(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleClient"))) 94 { 95 xFactory= createSingleFactory( reinterpret_cast< XMultiServiceFactory*>(pServiceManager), 96 OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleClient")), 97 OleClient_CreateInstance, seqServiceNames, 98 &globalModuleCount.modCnt); 99 } 100 else if(pServiceManager && aImplName.equals(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleServer"))) 101 { 102 xFactory= createOneInstanceFactory( reinterpret_cast< XMultiServiceFactory*>(pServiceManager), 103 OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleServer")), 104 OleServer_CreateInstance, seqServiceNames, 105 &globalModuleCount.modCnt); 106 } 107 108 if (xFactory.is()) 109 { 110 xFactory->acquire(); 111 pRet = xFactory.get(); 112 } 113 114 return pRet; 115 } 116 117 118 extern "C" void SAL_CALL component_getImplementationEnvironment( 119 const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) 120 { 121 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; 122 } 123 124 125 extern "C" sal_Bool component_canUnload( TimeValue* libUnused) 126 { 127 return globalModuleCount.canUnload( &globalModuleCount, libUnused); 128 } 129