LibreOffice Module cppuhelper (master) 1
implementationentry.cxx
Go to the documentation of this file.
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
21#include <com/sun/star/lang/XSingleComponentFactory.hpp>
22#include <com/sun/star/registry/XRegistryKey.hpp>
23
24#include <osl/diagnose.h>
25
26using namespace ::com::sun::star::uno;
27using namespace ::com::sun::star::lang;
28using namespace ::com::sun::star::registry;
29
30namespace cppu {
31
33 SAL_UNUSED_PARAMETER void *, void * pRegistryKey,
34 const struct ImplementationEntry entries[])
35{
36 bool bRet = false;
37 try
38 {
39 if( pRegistryKey )
40 {
41 for( sal_Int32 i = 0; entries[i].create ; i ++ )
42 {
43 OUString sKey = "/" + entries[i].getImplementationName() + "/UNO/SERVICES";
44 Reference< XRegistryKey > xNewKey(
45 static_cast< XRegistryKey * >( pRegistryKey )->createKey( sKey ) );
46
47 Sequence< OUString > seq = entries[i].getSupportedServiceNames();
48 const OUString *pArray = seq.getConstArray();
49 for ( sal_Int32 nPos = 0 ; nPos < seq.getLength(); nPos ++ )
50 xNewKey->createKey( pArray[nPos] );
51 }
52 bRet = true;
53 }
54 }
55 catch ( InvalidRegistryException & )
56 {
57 OSL_FAIL( "### InvalidRegistryException!" );
58 }
59 return bRet;
60}
61
62
64 char const * pImplName, SAL_UNUSED_PARAMETER void *,
65 SAL_UNUSED_PARAMETER void *, const struct ImplementationEntry entries[])
66{
67
68 void * pRet = nullptr;
69 Reference< XSingleComponentFactory > xFactory;
70
71 for( sal_Int32 i = 0 ; entries[i].create ; i ++ )
72 {
73 OUString implName = entries[i].getImplementationName();
74 if( implName.equalsAscii( pImplName ) )
75 {
76 xFactory = entries[i].createFactory(
77 entries[i].create,
79 entries[i].getSupportedServiceNames(),
80 entries[i].moduleCounter );
81 }
82 }
83
84 if( xFactory.is() )
85 {
86 xFactory->acquire();
87 pRet = xFactory.get();
88 }
89 return pRet;
90}
91
92}
93
94/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XSingleServiceFactory > xFactory
Definition: factory.cxx:715
sal_uInt16 nPos
css::uno::Sequence< OUString > getSupportedServiceNames()
void * component_getFactoryHelper(char const *pImplName, SAL_UNUSED_PARAMETER void *, SAL_UNUSED_PARAMETER void *, const struct ImplementationEntry entries[])
sal_Bool component_writeInfoHelper(SAL_UNUSED_PARAMETER void *, void *pRegistryKey, const struct ImplementationEntry entries[])
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
int i
RegError REGISTRY_CALLTYPE createKey(RegKeyHandle hKey, rtl_uString *keyName, RegKeyHandle *phNewKey)
One struct instance represents all data necessary for registering one service implementation.
ComponentFactoryFunc create
Function that creates an instance of the implementation.
const char * implName
unsigned char sal_Bool