1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: servreg.cxx,v $
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>
35 #include "ole2uno.hxx"
36 #include "servprov.hxx"
37 #include <rtl/ustring.hxx>
38 #include <cppuhelper/factory.hxx>
40 using namespace ole_adapter
;
45 rtl_StandardModuleCount globalModuleCount
= MODULE_COUNT_INIT
;
49 Reference
<XInterface
> SAL_CALL
ConverterProvider_CreateInstance2( const Reference
<XMultiServiceFactory
> & xSMgr
)
52 Reference
<XInterface
> xService
= *new OleConverter_Impl2( xSMgr
);
56 Reference
<XInterface
> SAL_CALL
ConverterProvider_CreateInstanceVar1( const Reference
<XMultiServiceFactory
> & xSMgr
)
59 Reference
<XInterface
> xService
= *new OleConverter_Impl2( xSMgr
, UNO_OBJECT_WRAPPER_REMOTE_OPT
, IUNKNOWN_WRAPPER_IMPL
);
63 Reference
<XInterface
> SAL_CALL
OleClient_CreateInstance( const Reference
<XMultiServiceFactory
> & xSMgr
)
66 Reference
<XInterface
> xService
= *new OleClient_Impl( xSMgr
);
70 Reference
<XInterface
> SAL_CALL
OleServer_CreateInstance( const Reference
<XMultiServiceFactory
> & xSMgr
)
73 Reference
<XInterface
> xService
= *new OleServer_Impl(xSMgr
);
78 extern "C" void * SAL_CALL
component_getFactory(
79 const sal_Char
* pImplName
, void * pServiceManager
, void * /*pRegistryKey*/ )
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
);
118 pRet
= xFactory
.get();
125 extern "C" sal_Bool SAL_CALL
component_writeInfo( void * /*pServiceManager*/, void * pRegistryKey
)
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"));
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"));
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"));
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"));
158 catch (InvalidRegistryException
&)
160 OSL_ENSURE( sal_False
, "### InvalidRegistryException!" );
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
);