1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include "res_services.hxx"
32 /** === begin UNO includes === **/
33 #include <com/sun/star/registry/XRegistryKey.hpp>
34 /** === end UNO includes === **/
36 /** === begin UNO using === **/
37 using ::com::sun::star::registry::XRegistryKey
;
38 using ::com::sun::star::uno::Reference
;
39 using ::com::sun::star::uno::Sequence
;
40 using ::com::sun::star::uno::Exception
;
41 using ::com::sun::star::lang::XMultiServiceFactory
;
42 using ::com::sun::star::lang::XSingleServiceFactory
;
43 using ::com::sun::star::uno::UNO_QUERY
;
44 /** === end UNO using === **/
50 ::std::vector
< ComponentInfo
> getComponentInfos()
52 ::std::vector
< ::res::ComponentInfo
> aComponentInfos
;
53 aComponentInfos
.push_back( getComponentInfo_VclStringResourceLoader() );
54 aComponentInfos
.push_back( getComponentInfo_OpenOfficeResourceLoader() );
55 return aComponentInfos
;
61 void SAL_CALL
component_getImplementationEnvironment(
62 const sal_Char
** ppEnvTypeName
, uno_Environment
** /*ppEnv*/ )
64 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
67 sal_Bool SAL_CALL
component_writeInfo( void * /*pServiceManager*/, XRegistryKey
* pRegistryKey
)
71 ::std::vector
< ::res::ComponentInfo
> aComponentInfos( ::res::getComponentInfos() );
72 for ( ::std::vector
< ::res::ComponentInfo
>::const_iterator loop
= aComponentInfos
.begin();
73 loop
!= aComponentInfos
.end();
77 Reference
< XRegistryKey
> xNewKey
=
78 pRegistryKey
->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") )
79 + loop
->sImplementationName
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES" ) ) );
81 for( sal_Int32 i
= 0; i
< loop
->aSupportedServices
.getLength(); ++i
)
82 xNewKey
->createKey( loop
->aSupportedServices
.getConstArray()[i
]);
84 if ( loop
->sSingletonName
.getLength() )
86 OSL_ENSURE( loop
->aSupportedServices
.getLength() == 1, "singletons must support exactly one service!" );
87 xNewKey
= pRegistryKey
->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") )
88 + loop
->sImplementationName
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SINGLETONS/" ) )
89 + loop
->sSingletonName
);
90 xNewKey
->setStringValue( loop
->aSupportedServices
[ 0 ] );
98 // not allowed to throw an exception over the c function.
99 //OSL_ENSURE( sal_False, "Exception cannot register component!" );
104 void * SAL_CALL
component_getFactory(
105 const sal_Char
* pImplName
, XMultiServiceFactory
* /*pServiceManager*/, void * /*pRegistryKey*/ )
108 ::std::vector
< ::res::ComponentInfo
> aComponentInfos( ::res::getComponentInfos() );
109 for ( ::std::vector
< ::res::ComponentInfo
>::const_iterator loop
= aComponentInfos
.begin();
110 loop
!= aComponentInfos
.end();
114 if ( 0 == loop
->sImplementationName
.compareToAscii( pImplName
) )
116 // create the factory
117 Reference
< XSingleServiceFactory
> xFactory( ::cppu::createSingleComponentFactory(
118 loop
->pFactory
, loop
->sImplementationName
, loop
->aSupportedServices
),
120 // acquire, because we return an interface pointer instead of a reference
122 pRet
= xFactory
.get();