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: oleregister.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_embeddedobj.hxx"
35 #include <com/sun/star/registry/XRegistryKey.hpp>
36 #include <com/sun/star/registry/InvalidRegistryException.hpp>
37 #include <cppuhelper/factory.hxx>
39 #include "xolefactory.hxx"
40 #include "xdialogcreator.hxx"
42 using namespace ::com::sun::star
;
47 void SAL_CALL
component_getImplementationEnvironment( const sal_Char
** ppEnvTypeName
, uno_Environment
** /*ppEnv*/ )
49 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
52 void * SAL_CALL
component_getFactory( const sal_Char
* pImplName
, void * pServiceManager
, void * /*pRegistryKey*/ )
56 ::rtl::OUString
aImplName( ::rtl::OUString::createFromAscii( pImplName
) );
57 uno::Reference
< lang::XSingleServiceFactory
> xFactory
;
59 if ( pServiceManager
)
61 if ( aImplName
.equals( OleEmbeddedObjectFactory::impl_staticGetImplementationName() ) )
63 xFactory
= ::cppu::createOneInstanceFactory( reinterpret_cast< lang::XMultiServiceFactory
*>( pServiceManager
),
64 OleEmbeddedObjectFactory::impl_staticGetImplementationName(),
65 OleEmbeddedObjectFactory::impl_staticCreateSelfInstance
,
66 OleEmbeddedObjectFactory::impl_staticGetSupportedServiceNames() );
69 // the following service makes sence only on windows
70 else if ( aImplName
.equals( MSOLEDialogObjectCreator::impl_staticGetImplementationName() ) )
72 xFactory
= ::cppu::createOneInstanceFactory( reinterpret_cast< lang::XMultiServiceFactory
*>( pServiceManager
),
73 MSOLEDialogObjectCreator::impl_staticGetImplementationName(),
74 MSOLEDialogObjectCreator::impl_staticCreateSelfInstance
,
75 MSOLEDialogObjectCreator::impl_staticGetSupportedServiceNames() );
83 pRet
= xFactory
.get();
89 sal_Bool SAL_CALL
component_writeInfo( void * /*pServiceManager*/, void * pRegistryKey
)
95 uno::Reference
< registry::XRegistryKey
> xKey( reinterpret_cast< registry::XRegistryKey
* >( pRegistryKey
) );
96 uno::Reference
< registry::XRegistryKey
> xNewKey
;
98 xNewKey
= xKey
->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
99 OleEmbeddedObjectFactory::impl_staticGetImplementationName() +
100 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) );
101 uno::Sequence
< ::rtl::OUString
> rServices
= OleEmbeddedObjectFactory::impl_staticGetSupportedServiceNames();
102 for( sal_Int32 ind
= 0; ind
< rServices
.getLength(); ind
++ )
103 xNewKey
->createKey( rServices
.getConstArray()[ind
] );
106 // the following service makes sence only on windows
107 xNewKey
= xKey
->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
108 MSOLEDialogObjectCreator::impl_staticGetImplementationName() +
109 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) );
110 rServices
= MSOLEDialogObjectCreator::impl_staticGetSupportedServiceNames();
111 for( sal_Int32 ind
= 0; ind
< rServices
.getLength(); ind
++ )
112 xNewKey
->createKey( rServices
.getConstArray()[ind
] );
117 catch (registry::InvalidRegistryException
&)
119 OSL_ENSURE( sal_False
, "### InvalidRegistryException!" );