Update ooo320-m1
[ooovba.git] / embeddedobj / source / commonembedding / register.cxx
blobf72de11a0373e72c3636d52e46ff8ea01b4be2c8
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: register.cxx,v $
10 * $Revision: 1.8 $
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 "xfactory.hxx"
40 #include "xcreator.hxx"
42 using namespace ::com::sun::star;
45 extern "C" {
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*/ )
54 void * pRet = 0;
56 ::rtl::OUString aImplName( ::rtl::OUString::createFromAscii( pImplName ) );
57 uno::Reference< lang::XSingleServiceFactory > xFactory;
59 if ( pServiceManager )
61 if ( aImplName.equals( OOoEmbeddedObjectFactory::impl_staticGetImplementationName() ) )
63 xFactory= ::cppu::createOneInstanceFactory( reinterpret_cast< lang::XMultiServiceFactory*>( pServiceManager ),
64 OOoEmbeddedObjectFactory::impl_staticGetImplementationName(),
65 OOoEmbeddedObjectFactory::impl_staticCreateSelfInstance,
66 OOoEmbeddedObjectFactory::impl_staticGetSupportedServiceNames() );
68 else if ( aImplName.equals( OOoSpecialEmbeddedObjectFactory::impl_staticGetImplementationName() ) )
70 xFactory= ::cppu::createOneInstanceFactory( reinterpret_cast< lang::XMultiServiceFactory*>( pServiceManager ),
71 OOoSpecialEmbeddedObjectFactory::impl_staticGetImplementationName(),
72 OOoSpecialEmbeddedObjectFactory::impl_staticCreateSelfInstance,
73 OOoSpecialEmbeddedObjectFactory::impl_staticGetSupportedServiceNames() );
75 else if ( aImplName.equals( UNOEmbeddedObjectCreator::impl_staticGetImplementationName() ) )
77 xFactory= ::cppu::createOneInstanceFactory( reinterpret_cast< lang::XMultiServiceFactory*>( pServiceManager ),
78 UNOEmbeddedObjectCreator::impl_staticGetImplementationName(),
79 UNOEmbeddedObjectCreator::impl_staticCreateSelfInstance,
80 UNOEmbeddedObjectCreator::impl_staticGetSupportedServiceNames() );
84 if ( xFactory.is() )
86 xFactory->acquire();
87 pRet = xFactory.get();
90 return pRet;
93 sal_Bool SAL_CALL component_writeInfo( void * /*pServiceManager*/, void * pRegistryKey )
95 if (pRegistryKey)
97 try
99 sal_Int32 nInd = 0;
100 uno::Reference< registry::XRegistryKey > xKey( reinterpret_cast< registry::XRegistryKey* >( pRegistryKey ) );
102 uno::Reference< registry::XRegistryKey > xNewKey;
104 xNewKey = xKey->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
105 OOoEmbeddedObjectFactory::impl_staticGetImplementationName() +
106 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) );
107 uno::Sequence< ::rtl::OUString > rServices = OOoEmbeddedObjectFactory::impl_staticGetSupportedServiceNames();
108 for( nInd = 0; nInd < rServices.getLength(); nInd++ )
109 xNewKey->createKey( rServices.getConstArray()[nInd] );
111 xNewKey = xKey->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
112 OOoSpecialEmbeddedObjectFactory::impl_staticGetImplementationName() +
113 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) );
114 rServices = OOoSpecialEmbeddedObjectFactory::impl_staticGetSupportedServiceNames();
115 for( nInd = 0; nInd < rServices.getLength(); nInd++ )
116 xNewKey->createKey( rServices.getConstArray()[nInd] );
118 xNewKey = xKey->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
119 UNOEmbeddedObjectCreator::impl_staticGetImplementationName() +
120 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) );
121 rServices = UNOEmbeddedObjectCreator::impl_staticGetSupportedServiceNames();
122 for( nInd = 0; nInd < rServices.getLength(); nInd++ )
123 xNewKey->createKey( rServices.getConstArray()[nInd] );
125 return sal_True;
127 catch (registry::InvalidRegistryException &)
129 OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
132 return sal_False;
135 } // extern "C"