Update ooo320-m1
[ooovba.git] / basctl / source / basicide / register.cxx
blob2eb6e8dbee1294309b1f43c5998558020386ef3c
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_basctl.hxx"
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/registry/XRegistryKey.hpp>
35 #include <com/sun/star/uno/Sequence.h>
36 #include <rtl/ustring.hxx>
38 #include <cppuhelper/factory.hxx>
40 #include "unomodel.hxx"
42 using ::rtl::OUString;
43 using namespace ::com::sun::star;
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::lang;
48 extern "C" {
50 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
51 const sal_Char** ppEnvironmentTypeName,
52 uno_Environment** ppEnvironment )
54 (void)ppEnvironment;
55 *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
58 SAL_DLLPUBLIC_EXPORT
59 sal_Bool SAL_CALL component_writeInfo( void* pServiceManager ,
60 void* pRegistryKey )
62 (void)pServiceManager;
64 Reference< ::registry::XRegistryKey >
65 xKey( reinterpret_cast< ::registry::XRegistryKey* >( pRegistryKey ) ) ;
67 OUString aDelimiter( RTL_CONSTASCII_USTRINGPARAM("/") );
68 OUString aUnoServices( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") );
70 sal_Int32 i;
71 Reference< ::registry::XRegistryKey > xNewKey;
72 xNewKey = xKey->createKey( aDelimiter + SIDEModel::getImplementationName_Static() + aUnoServices );
73 Sequence< OUString > aServices = SIDEModel::getSupportedServiceNames_Static();
74 for(i = 0; i < aServices.getLength(); i++ )
75 xNewKey->createKey( aServices.getConstArray()[i] );
77 return sal_True;
80 SAL_DLLPUBLIC_EXPORT
81 void* SAL_CALL component_getFactory( const sal_Char* pImplementationName,
82 void* pServiceManager,
83 void* pRegistryKey )
85 (void)pRegistryKey;
87 // Set default return value for this operation - if it failed.
88 void* pReturn = NULL ;
90 if (
91 ( pImplementationName != NULL ) &&
92 ( pServiceManager != NULL )
95 // Define variables which are used in following macros.
96 Reference< XSingleServiceFactory > xFactory ;
97 Reference< XMultiServiceFactory > xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
99 if( SIDEModel::getImplementationName_Static().equalsAscii( pImplementationName ) )
101 xFactory = ::cppu::createSingleFactory( xServiceManager,
102 SIDEModel::getImplementationName_Static(),
103 SIDEModel_createInstance,
104 SIDEModel::getSupportedServiceNames_Static() );
107 // Factory is valid - service was found.
108 if ( xFactory.is() )
110 xFactory->acquire();
111 pReturn = xFactory.get();
115 // Return with result of this operation.
116 return pReturn ;
118 } // extern "C"