Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include "sal/types.h"
21 : : #include "rtl/ustring.hxx"
22 : : #include <cppuhelper/factory.hxx>
23 : : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
24 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 : : #include <com/sun/star/registry/XRegistryKey.hpp>
26 : : #include <svl/svldllapi.h>
27 : :
28 : : namespace css = com::sun::star;
29 : : using css::uno::Reference;
30 : : using css::uno::Sequence;
31 : : using rtl::OUString;
32 : :
33 : : // -------------------------------------------------------------------------------------
34 : :
35 : : #define DECLARE_CREATEINSTANCE( ImplName ) \
36 : : Reference< css::uno::XInterface > SAL_CALL ImplName##_CreateInstance( const Reference< css::lang::XMultiServiceFactory >& );
37 : :
38 : : DECLARE_CREATEINSTANCE( SvNumberFormatterServiceObj )
39 : : DECLARE_CREATEINSTANCE( SvNumberFormatsSupplierServiceObject )
40 : : DECLARE_CREATEINSTANCE( PathService )
41 : :
42 : : // -------------------------------------------------------------------------------------
43 : :
44 : : extern "C"
45 : : {
46 : :
47 : 40 : SVL_DLLPUBLIC void* SAL_CALL svl_component_getFactory (
48 : : const sal_Char * pImplementationName, void * _pServiceManager,
49 : : SAL_UNUSED_PARAMETER void * /* _pRegistryKey*/)
50 : : {
51 : 40 : void * pResult = 0;
52 [ + - ]: 40 : if ( _pServiceManager )
53 : : {
54 : 40 : Reference< css::lang::XSingleServiceFactory > xFactory;
55 [ + + ]: 40 : if (rtl_str_compare(
56 : : pImplementationName,
57 : 40 : "com.sun.star.uno.util.numbers.SvNumberFormatsSupplierServiceObject") == 0)
58 : : {
59 [ + - ]: 13 : Sequence< OUString > aServiceNames(1);
60 : : aServiceNames.getArray()[0] =
61 [ + - ]: 13 : OUString("com.sun.star.util.NumberFormatsSupplier");
62 : :
63 : : xFactory = ::cppu::createSingleFactory(
64 : : reinterpret_cast< css::lang::XMultiServiceFactory* >(_pServiceManager),
65 : : OUString::createFromAscii( pImplementationName ),
66 : : SvNumberFormatsSupplierServiceObject_CreateInstance,
67 [ + - ][ + - ]: 13 : aServiceNames);
[ + - ][ + - ]
68 : : }
69 [ + + ]: 27 : else if (rtl_str_compare(
70 : : pImplementationName,
71 : 27 : "com.sun.star.uno.util.numbers.SvNumberFormatterServiceObject") == 0)
72 : : {
73 [ + - ]: 19 : Sequence< OUString > aServiceNames(1);
74 : : aServiceNames.getArray()[0] =
75 [ + - ]: 19 : OUString("com.sun.star.util.NumberFormatter");
76 : :
77 : : xFactory = ::cppu::createSingleFactory(
78 : : reinterpret_cast< css::lang::XMultiServiceFactory* >(_pServiceManager),
79 : : OUString::createFromAscii( pImplementationName ),
80 : : SvNumberFormatterServiceObj_CreateInstance,
81 [ + - ][ + - ]: 19 : aServiceNames);
[ + - ][ + - ]
82 : : }
83 [ + - ]: 8 : else if (rtl_str_compare (
84 : 8 : pImplementationName, "com.sun.star.comp.svl.PathService") == 0)
85 : : {
86 [ + - ]: 8 : Sequence< OUString > aServiceNames(1);
87 : : aServiceNames.getArray()[0] =
88 [ + - ]: 8 : OUString("com.sun.star.config.SpecialConfigManager");
89 : : xFactory = ::cppu::createSingleFactory (
90 : : reinterpret_cast< css::lang::XMultiServiceFactory* >( _pServiceManager ),
91 : : OUString::createFromAscii( pImplementationName ),
92 : : PathService_CreateInstance,
93 [ + - ][ + - ]: 8 : aServiceNames);
[ + - ][ + - ]
94 : : }
95 [ + - ]: 40 : if ( xFactory.is() )
96 : : {
97 [ + - ]: 40 : xFactory->acquire();
98 [ + - ]: 40 : pResult = xFactory.get();
99 : 40 : }
100 : : }
101 : 40 : return pResult;
102 : : }
103 : :
104 : : } // "C"
105 : :
106 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|