1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: registerservices.cxx,v $
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_svtools.hxx"
33 #include "sal/types.h"
34 #include "rtl/ustring.hxx"
35 #include <cppuhelper/factory.hxx>
36 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <com/sun/star/registry/XRegistryKey.hpp>
40 namespace css
= com::sun::star
;
41 using css::uno::Reference
;
42 using css::uno::Sequence
;
45 // -------------------------------------------------------------------------------------
47 #define DECLARE_CREATEINSTANCE( ImplName ) \
48 Reference< css::uno::XInterface > SAL_CALL ImplName##_CreateInstance( const Reference< css::lang::XMultiServiceFactory >& );
50 DECLARE_CREATEINSTANCE( SvNumberFormatterServiceObj
)
51 DECLARE_CREATEINSTANCE( SvNumberFormatsSupplierServiceObject
)
53 // -------------------------------------------------------------------------------------
58 SAL_DLLPUBLIC_EXPORT
void SAL_CALL
component_getImplementationEnvironment (
59 const sal_Char
** ppEnvTypeName
, uno_Environment
** /* ppEnv */)
61 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
64 SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL
component_writeInfo (
65 void * /* _pServiceManager */, void * _pRegistryKey
)
69 Reference
< css::registry::XRegistryKey
> xRegistryKey (
70 reinterpret_cast< css::registry::XRegistryKey
* >(_pRegistryKey
));
71 Reference
< css::registry::XRegistryKey
> xNewKey
;
73 xNewKey
= xRegistryKey
->createKey (
74 OUString::createFromAscii(
75 "/com.sun.star.uno.util.numbers.SvNumberFormatsSupplierServiceObject/UNO/SERVICES" ) );
77 OUString::createFromAscii( "com.sun.star.util.NumberFormatsSupplier" ) );
79 xNewKey
= xRegistryKey
->createKey (
80 OUString::createFromAscii(
81 "/com.sun.star.uno.util.numbers.SvNumberFormatterServiceObject/UNO/SERVICES" ) );
83 OUString::createFromAscii( "com.sun.star.util.NumberFormatter" ) );
90 SAL_DLLPUBLIC_EXPORT
void* SAL_CALL
component_getFactory (
91 const sal_Char
* pImplementationName
, void * _pServiceManager
, void * /* _pRegistryKey*/)
94 if ( _pServiceManager
)
96 Reference
< css::lang::XSingleServiceFactory
> xFactory
;
99 "com.sun.star.uno.util.numbers.SvNumberFormatsSupplierServiceObject") == 0)
101 Sequence
< OUString
> aServiceNames(1);
102 aServiceNames
.getArray()[0] =
103 OUString::createFromAscii( "com.sun.star.util.NumberFormatsSupplier" );
105 xFactory
= ::cppu::createSingleFactory(
106 reinterpret_cast< css::lang::XMultiServiceFactory
* >(_pServiceManager
),
107 OUString::createFromAscii( pImplementationName
),
108 SvNumberFormatsSupplierServiceObject_CreateInstance
,
111 else if (rtl_str_compare(
113 "com.sun.star.uno.util.numbers.SvNumberFormatterServiceObject") == 0)
115 Sequence
< OUString
> aServiceNames(1);
116 aServiceNames
.getArray()[0] =
117 OUString::createFromAscii( "com.sun.star.util.NumberFormatter" );
119 xFactory
= ::cppu::createSingleFactory(
120 reinterpret_cast< css::lang::XMultiServiceFactory
* >(_pServiceManager
),
121 OUString::createFromAscii( pImplementationName
),
122 SvNumberFormatterServiceObj_CreateInstance
,
128 pResult
= xFactory
.get();