update dev300-m58
[ooovba.git] / extensions / source / ole / servreg.cxx
blob6ec921ec51c80cef940535e9e53799c62c6b97b4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: servreg.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
33 #include <rtl/unload.h>
34 #include <osl/time.h>
35 #include "ole2uno.hxx"
36 #include "servprov.hxx"
37 #include <rtl/ustring.hxx>
38 #include <cppuhelper/factory.hxx>
39 using namespace rtl;
40 using namespace ole_adapter;
41 using namespace cppu;
43 namespace ole_adapter
45 rtl_StandardModuleCount globalModuleCount= MODULE_COUNT_INIT;
49 Reference<XInterface> SAL_CALL ConverterProvider_CreateInstance2( const Reference<XMultiServiceFactory> & xSMgr)
50 throw(Exception)
52 Reference<XInterface> xService = *new OleConverter_Impl2( xSMgr);
53 return xService;
56 Reference<XInterface> SAL_CALL ConverterProvider_CreateInstanceVar1( const Reference<XMultiServiceFactory> & xSMgr)
57 throw(Exception)
59 Reference<XInterface> xService = *new OleConverter_Impl2( xSMgr, UNO_OBJECT_WRAPPER_REMOTE_OPT, IUNKNOWN_WRAPPER_IMPL);
60 return xService;
63 Reference<XInterface> SAL_CALL OleClient_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr)
64 throw(Exception)
66 Reference<XInterface> xService = *new OleClient_Impl( xSMgr);
67 return xService;
70 Reference<XInterface> SAL_CALL OleServer_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr)
71 throw (Exception)
73 Reference<XInterface > xService = *new OleServer_Impl(xSMgr);
74 return xService;
76 } // end namespace
78 extern "C" void * SAL_CALL component_getFactory(
79 const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
81 void * pRet = 0;
83 OUString aImplName( OUString::createFromAscii( pImplName ) );
84 Reference< XSingleServiceFactory > xFactory;
85 Sequence<OUString> seqServiceNames;
86 if (pServiceManager && aImplName.equals( reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleConverter2") ))
88 xFactory= createSingleFactory( reinterpret_cast< XMultiServiceFactory*>(pServiceManager),
89 OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleConverter2")),
90 ConverterProvider_CreateInstance2, seqServiceNames,
91 &globalModuleCount.modCnt );
93 else if (pServiceManager && aImplName.equals( reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleConverterVar1") ))
95 xFactory= createSingleFactory( reinterpret_cast<XMultiServiceFactory*>(pServiceManager),
96 OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleConverterVar1")),
97 ConverterProvider_CreateInstanceVar1, seqServiceNames,
98 &globalModuleCount.modCnt );
100 else if(pServiceManager && aImplName.equals(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleClient")))
102 xFactory= createSingleFactory( reinterpret_cast< XMultiServiceFactory*>(pServiceManager),
103 OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleClient")),
104 OleClient_CreateInstance, seqServiceNames,
105 &globalModuleCount.modCnt);
107 else if(pServiceManager && aImplName.equals(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleServer")))
109 xFactory= createOneInstanceFactory( reinterpret_cast< XMultiServiceFactory*>(pServiceManager),
110 OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleServer")),
111 OleServer_CreateInstance, seqServiceNames,
112 &globalModuleCount.modCnt);
115 if (xFactory.is())
117 xFactory->acquire();
118 pRet = xFactory.get();
121 return pRet;
125 extern "C" sal_Bool SAL_CALL component_writeInfo( void * /*pServiceManager*/, void * pRegistryKey )
127 if (pRegistryKey)
131 //deprecated
132 Reference<XRegistryKey> xNewKey =
133 reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(reinterpret_cast<const sal_Unicode*>(L"/com.sun.star.comp.ole.OleConverter2/UNO/SERVICES"));
134 xNewKey->createKey(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.OleBridgeSupplier2"));
136 xNewKey->createKey(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.oleautomation.BridgeSupplier"));
138 //deprecated
139 xNewKey =
140 reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(reinterpret_cast<const sal_Unicode*>(L"/com.sun.star.comp.ole.OleConverterVar1/UNO/SERVICES"));
141 xNewKey->createKey(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.OleBridgeSupplierVar1"));
143 //deprecated
144 xNewKey =
145 reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(reinterpret_cast<const sal_Unicode*>(L"/com.sun.star.comp.ole.OleClient/UNO/SERVICES"));
146 xNewKey->createKey(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.OleObjectFactory"));
148 xNewKey->createKey(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.oleautomation.Factory"));
149 //deprecated
150 xNewKey =
151 reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(reinterpret_cast<const sal_Unicode*>(L"/com.sun.star.comp.ole.OleServer/UNO/SERVICES"));
152 xNewKey->createKey(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.OleApplicationRegistration"));
154 xNewKey->createKey(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.oleautomation.ApplicationRegistration"));
156 return sal_True;
158 catch (InvalidRegistryException &)
160 OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
163 return sal_False;
166 extern "C" void SAL_CALL component_getImplementationEnvironment(
167 const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
169 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
173 extern "C" sal_Bool component_canUnload( TimeValue* libUnused)
175 return globalModuleCount.canUnload( &globalModuleCount, libUnused);