update dev300-m58
[ooovba.git] / sot / source / unoolestorage / register.cxx
blob7673d838f9d6479a9c80ff32be5618ff53f181f5
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.7 $
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_sot.hxx"
35 #include <com/sun/star/registry/XRegistryKey.hpp>
36 #include <com/sun/star/registry/InvalidRegistryException.hpp>
37 #include <cppuhelper/factory.hxx>
39 #include "xolesimplestorage.hxx"
41 using namespace ::com::sun::star;
44 extern "C" {
46 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
48 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
51 SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
53 void * pRet = 0;
55 ::rtl::OUString aImplName( ::rtl::OUString::createFromAscii( pImplName ) );
56 uno::Reference< lang::XSingleServiceFactory > xFactory;
58 if ( pServiceManager && aImplName.equals( OLESimpleStorage::impl_staticGetImplementationName() ) )
60 xFactory= ::cppu::createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory*>( pServiceManager ),
61 OLESimpleStorage::impl_staticGetImplementationName(),
62 OLESimpleStorage::impl_staticCreateSelfInstance,
63 OLESimpleStorage::impl_staticGetSupportedServiceNames() );
66 if ( xFactory.is() )
68 xFactory->acquire();
69 pRet = xFactory.get();
72 return pRet;
75 SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( void * /*pServiceManager*/, void * pRegistryKey )
77 if (pRegistryKey)
79 try
81 uno::Reference< registry::XRegistryKey > xKey( reinterpret_cast< registry::XRegistryKey* >( pRegistryKey ) );
83 uno::Reference< registry::XRegistryKey > xNewKey;
85 xNewKey = xKey->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
86 OLESimpleStorage::impl_staticGetImplementationName() +
87 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) );
89 const uno::Sequence< ::rtl::OUString > &rServices = OLESimpleStorage::impl_staticGetSupportedServiceNames();
90 for( sal_Int32 ind = 0; ind < rServices.getLength(); ind++ )
91 xNewKey->createKey( rServices.getConstArray()[ind] );
93 return sal_True;
95 catch (registry::InvalidRegistryException &)
97 OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
100 return sal_False;
103 } // extern "C"