Update ooo320-m1
[ooovba.git] / desktop / unx / splash / services_unxsplash.cxx
blobb762fa56b7b0a5aad9e521bedc649f41cfaf4ff8
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile$
7 * $Revision: 7305 $
9 * last change: $Author: jholesovsky $ $Date: 2006-08-04 16:35:41 +0200 (Pá, 04 srp 2006) $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 * MA 02111-1307 USA
34 ************************************************************************/
36 #ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPP_
37 #include <com/sun/star/beans/NamedValue.hpp>
38 #endif
39 #ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_
40 #include <com/sun/star/registry/XRegistryKey.hpp>
41 #endif
42 #ifndef _COM_SUN_STAR_UTIL_DATE_HPP_
43 #include <com/sun/star/util/Date.hpp>
44 #endif
46 #ifndef _UNO_ENVIRONMENT_H_
47 #include <uno/environment.h>
48 #endif
49 #ifndef _CPPUHELPER_FACTORY_HXX_
50 #include <cppuhelper/factory.hxx>
51 #endif
52 #ifndef _UTL_CONFIGMGR_HXX_
53 #include <unotools/configmgr.hxx>
54 #endif
56 #include <string.h>
58 #include "unxsplash.hxx"
60 using namespace rtl;
61 using namespace ::com::sun::star::uno;
62 using namespace ::com::sun::star::lang;
63 using namespace ::com::sun::star::beans;
64 using namespace ::com::sun::star::registry;
65 using namespace ::desktop;
67 static const char* pServices[] =
69 UnxSplashScreen::serviceName,
70 NULL
73 static const char* pImplementations[] =
75 UnxSplashScreen::implementationName,
76 NULL
79 typedef Reference<XInterface>(* fProvider)( const Reference<XMultiServiceFactory>& );
81 static const fProvider pInstanceProviders[] =
83 UnxSplashScreen::getInstance,
84 NULL
88 static const char** pSupportedServices[] =
90 UnxSplashScreen::interfaces,
91 NULL
94 static Sequence<OUString>
95 getSupportedServiceNames( int p ) {
96 const char **names = pSupportedServices[p];
97 Sequence<OUString> aSeq;
98 for ( int i = 0; names[i] != NULL; i++ )
100 aSeq.realloc( i+1 );
101 aSeq[i] = OUString::createFromAscii( names[i] );
103 return aSeq;
106 extern "C"
108 void SAL_CALL
109 component_getImplementationEnvironment(
110 const sal_Char** ppEnvironmentTypeName,
111 uno_Environment** ppEnvironment )
113 *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
116 sal_Bool SAL_CALL
117 component_writeInfo(
118 void* pServiceManager,
119 void* pRegistryKey )
121 Reference<XMultiServiceFactory> xMan(
122 reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
123 Reference<XRegistryKey> xKey(
124 reinterpret_cast< XRegistryKey* >( pRegistryKey ) ) ;
126 // iterate over service names and register them...
127 OUString aImpl;
128 const char* pServiceName = NULL;
129 const char* pImplName = NULL;
130 for ( int i = 0; ( pServices[i] != NULL ) && ( pImplementations[i] != NULL ); i++ )
132 pServiceName= pServices[i];
133 pImplName = pImplementations[i];
134 aImpl = OUString::createFromAscii( "/" )
135 + OUString::createFromAscii( pImplName )
136 + OUString::createFromAscii( "/UNO/SERVICES" );
137 Reference<XRegistryKey> xNewKey = xKey->createKey( aImpl );
138 xNewKey->createKey( OUString::createFromAscii( pServiceName ) );
140 return sal_True;
143 void* SAL_CALL
144 component_getFactory(
145 const sal_Char* pImplementationName,
146 void* pServiceManager,
147 void* pRegistryKey )
149 // Set default return value for this operation - if it failed.
150 if ( pImplementationName && pServiceManager )
152 Reference< XSingleServiceFactory > xFactory;
153 Reference< XMultiServiceFactory > xServiceManager(
154 reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
156 // search implementation
157 for ( int i = 0; ( pImplementations[i] != NULL ); i++ )
159 if ( strcmp( pImplementations[i], pImplementationName ) == 0 )
161 // found implementation
162 xFactory = Reference<XSingleServiceFactory>( cppu::createSingleFactory(
163 xServiceManager, OUString::createFromAscii( pImplementationName ),
164 pInstanceProviders[i], getSupportedServiceNames( i ) ) );
165 if ( xFactory.is() )
167 // Factory is valid - service was found.
168 xFactory->acquire();
169 return xFactory.get();
175 return NULL;
177 } // extern "C"