/src/libreoffice/cppuhelper/source/implementationentry.cxx
Line | Count | Source |
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 <cppuhelper/implementationentry.hxx> |
21 | | #include <com/sun/star/lang/XSingleComponentFactory.hpp> |
22 | | #include <com/sun/star/registry/XRegistryKey.hpp> |
23 | | |
24 | | #include <osl/diagnose.h> |
25 | | |
26 | | using namespace ::com::sun::star::uno; |
27 | | using namespace ::com::sun::star::lang; |
28 | | using namespace ::com::sun::star::registry; |
29 | | |
30 | | namespace cppu { |
31 | | |
32 | | sal_Bool component_writeInfoHelper( |
33 | | SAL_UNUSED_PARAMETER void *, void * pRegistryKey, |
34 | | const struct ImplementationEntry entries[]) |
35 | 0 | { |
36 | 0 | bool bRet = false; |
37 | 0 | try |
38 | 0 | { |
39 | 0 | if( pRegistryKey ) |
40 | 0 | { |
41 | 0 | for( sal_Int32 i = 0; entries[i].create ; i ++ ) |
42 | 0 | { |
43 | 0 | OUString sKey = "/" + entries[i].getImplementationName() + "/UNO/SERVICES"; |
44 | 0 | Reference< XRegistryKey > xNewKey( |
45 | 0 | static_cast< XRegistryKey * >( pRegistryKey )->createKey( sKey ) ); |
46 | |
|
47 | 0 | for (auto& serviceName : entries[i].getSupportedServiceNames()) |
48 | 0 | xNewKey->createKey(serviceName); |
49 | 0 | } |
50 | 0 | bRet = true; |
51 | 0 | } |
52 | 0 | } |
53 | 0 | catch ( InvalidRegistryException & ) |
54 | 0 | { |
55 | 0 | OSL_FAIL( "### InvalidRegistryException!" ); |
56 | 0 | } |
57 | 0 | return bRet; |
58 | 0 | } |
59 | | |
60 | | |
61 | | void * component_getFactoryHelper( |
62 | | char const * pImplName, SAL_UNUSED_PARAMETER void *, |
63 | | SAL_UNUSED_PARAMETER void *, const struct ImplementationEntry entries[]) |
64 | 0 | { |
65 | |
|
66 | 0 | void * pRet = nullptr; |
67 | 0 | Reference< XSingleComponentFactory > xFactory; |
68 | |
|
69 | 0 | for( sal_Int32 i = 0 ; entries[i].create ; i ++ ) |
70 | 0 | { |
71 | 0 | OUString implName = entries[i].getImplementationName(); |
72 | 0 | if( implName.equalsAscii( pImplName ) ) |
73 | 0 | { |
74 | 0 | xFactory = entries[i].createFactory( |
75 | 0 | entries[i].create, |
76 | 0 | implName, |
77 | 0 | entries[i].getSupportedServiceNames(), |
78 | 0 | entries[i].moduleCounter ); |
79 | 0 | } |
80 | 0 | } |
81 | |
|
82 | 0 | if( xFactory.is() ) |
83 | 0 | { |
84 | 0 | xFactory->acquire(); |
85 | 0 | pRet = xFactory.get(); |
86 | 0 | } |
87 | 0 | return pRet; |
88 | 0 | } |
89 | | |
90 | | } |
91 | | |
92 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |