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 : using css::uno::Reference;
29 : using css::uno::Sequence;
30 :
31 : // -------------------------------------------------------------------------------------
32 :
33 : #define DECLARE_CREATEINSTANCE( ImplName ) \
34 : Reference< css::uno::XInterface > SAL_CALL ImplName##_CreateInstance( const Reference< css::lang::XMultiServiceFactory >& );
35 :
36 : DECLARE_CREATEINSTANCE( SvNumberFormatterServiceObj )
37 : DECLARE_CREATEINSTANCE( SvNumberFormatsSupplierServiceObject )
38 : DECLARE_CREATEINSTANCE( PathService )
39 :
40 : // -------------------------------------------------------------------------------------
41 :
42 : extern "C"
43 : {
44 :
45 23 : SVL_DLLPUBLIC void* SAL_CALL svl_component_getFactory (
46 : const sal_Char * pImplementationName, void * _pServiceManager,
47 : SAL_UNUSED_PARAMETER void * /* _pRegistryKey*/)
48 : {
49 23 : void * pResult = 0;
50 23 : if ( _pServiceManager )
51 : {
52 23 : Reference< css::lang::XSingleServiceFactory > xFactory;
53 23 : if (rtl_str_compare(
54 : pImplementationName,
55 23 : "com.sun.star.uno.util.numbers.SvNumberFormatsSupplierServiceObject") == 0)
56 : {
57 9 : Sequence< OUString > aServiceNames(1);
58 18 : aServiceNames.getArray()[0] =
59 9 : OUString("com.sun.star.util.NumberFormatsSupplier");
60 :
61 18 : xFactory = ::cppu::createSingleFactory(
62 : reinterpret_cast< css::lang::XMultiServiceFactory* >(_pServiceManager),
63 : OUString::createFromAscii( pImplementationName ),
64 : SvNumberFormatsSupplierServiceObject_CreateInstance,
65 18 : aServiceNames);
66 : }
67 14 : else if (rtl_str_compare(
68 : pImplementationName,
69 14 : "com.sun.star.uno.util.numbers.SvNumberFormatterServiceObject") == 0)
70 : {
71 13 : Sequence< OUString > aServiceNames(1);
72 26 : aServiceNames.getArray()[0] =
73 13 : OUString("com.sun.star.util.NumberFormatter");
74 :
75 26 : xFactory = ::cppu::createSingleFactory(
76 : reinterpret_cast< css::lang::XMultiServiceFactory* >(_pServiceManager),
77 : OUString::createFromAscii( pImplementationName ),
78 : SvNumberFormatterServiceObj_CreateInstance,
79 26 : aServiceNames);
80 : }
81 1 : else if (rtl_str_compare (
82 1 : pImplementationName, "com.sun.star.comp.svl.PathService") == 0)
83 : {
84 1 : Sequence< OUString > aServiceNames(1);
85 2 : aServiceNames.getArray()[0] =
86 1 : OUString("com.sun.star.config.SpecialConfigManager");
87 2 : xFactory = ::cppu::createSingleFactory (
88 : reinterpret_cast< css::lang::XMultiServiceFactory* >( _pServiceManager ),
89 : OUString::createFromAscii( pImplementationName ),
90 : PathService_CreateInstance,
91 2 : aServiceNames);
92 : }
93 23 : if ( xFactory.is() )
94 : {
95 23 : xFactory->acquire();
96 23 : pResult = xFactory.get();
97 23 : }
98 : }
99 23 : return pResult;
100 : }
101 :
102 : } // "C"
103 :
104 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|