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