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 : :
21 : : #include "functiondescription.hxx"
22 : :
23 : : #include "com/sun/star/container/NoSuchElementException.hpp"
24 : : #include "com/sun/star/container/XHierarchicalNameAccess.hpp"
25 : : #include "com/sun/star/reflection/XCompoundTypeDescription.hpp"
26 : : #include "com/sun/star/uno/Any.hxx"
27 : : #include "com/sun/star/uno/Reference.hxx"
28 : : #include "com/sun/star/uno/RuntimeException.hpp"
29 : : #include "com/sun/star/uno/Sequence.hxx"
30 : : #include "com/sun/star/uno/TypeClass.hpp"
31 : : #include "com/sun/star/uno/XInterface.hpp"
32 : : #include "cppuhelper/implbase1.hxx"
33 : : #include "osl/diagnose.h"
34 : : #include "osl/mutex.hxx"
35 : : #include "registry/reader.hxx"
36 : : #include "registry/version.h"
37 : : #include "rtl/ustring.h"
38 : : #include "rtl/ustring.hxx"
39 : : #include "sal/types.h"
40 : :
41 : : namespace css = com::sun::star;
42 : :
43 : : using stoc::registry_tdprovider::FunctionDescription;
44 : :
45 : 169246 : FunctionDescription::FunctionDescription(
46 : : css::uno::Reference< css::container::XHierarchicalNameAccess > const &
47 : : manager,
48 : : com::sun::star::uno::Sequence< sal_Int8 > const & bytes,
49 : : sal_uInt16 index):
50 [ + - ][ + - ]: 169246 : m_manager(manager), m_bytes(bytes), m_index(index), m_exceptionsInit(false)
[ + - ]
51 : 169246 : {}
52 : :
53 [ + - ][ + - ]: 165791 : FunctionDescription::~FunctionDescription() {}
[ + - ]
54 : :
55 : : css::uno::Sequence<
56 : : css::uno::Reference< css::reflection::XCompoundTypeDescription > >
57 : 30863 : FunctionDescription::getExceptions() const {
58 : : {
59 [ + - ]: 30863 : osl::MutexGuard guard(m_mutex);
60 [ + + ]: 30863 : if (m_exceptionsInit) {
61 [ + - ]: 30863 : return m_exceptions;
62 [ + - ][ + + ]: 30863 : }
63 : : }
64 [ + - ]: 30863 : typereg::Reader reader(getReader());
65 : 29454 : sal_uInt16 n = reader.getMethodExceptionCount(m_index);
66 : : css::uno::Sequence<
67 : : css::uno::Reference< css::reflection::XCompoundTypeDescription > >
68 [ + - ]: 29454 : exceptions(n);
69 [ + + ]: 47693 : for (sal_uInt16 i = 0; i < n; ++i) {
70 : : rtl::OUString name(
71 [ + - ]: 18239 : reader.getMethodExceptionTypeName(m_index, i).replace('/', '.'));
72 : 18239 : css::uno::Any any;
73 : : try {
74 [ + - ][ + - ]: 18239 : any = m_manager->getByHierarchicalName(name);
75 [ # # ]: 0 : } catch (const css::container::NoSuchElementException & e) {
76 : : throw new css::uno::RuntimeException(
77 : : (rtl::OUString(
78 : : RTL_CONSTASCII_USTRINGPARAM(
79 : : "com.sun.star.container.NoSuchElementException: "))
80 : : + e.Message),
81 [ # # # # : 0 : css::uno::Reference< css::uno::XInterface >()); //TODO
# # ]
82 : : }
83 [ + - ][ + - ]: 36478 : if (!(any >>= exceptions[i])
[ - + ][ - + ]
[ + - ]
84 [ + - ][ + - ]: 18239 : || exceptions[i]->getTypeClass() != css::uno::TypeClass_EXCEPTION)
[ + - ]
85 : : {
86 : : throw new css::uno::RuntimeException(
87 : : (rtl::OUString(
88 : : RTL_CONSTASCII_USTRINGPARAM("not an exception type: "))
89 : : + name),
90 [ # # ][ # # ]: 0 : css::uno::Reference< css::uno::XInterface >()); //TODO
[ # # ]
91 : : }
92 : : OSL_ASSERT(exceptions[i].is());
93 : 18239 : }
94 [ + - ]: 29454 : osl::MutexGuard guard(m_mutex);
95 [ + - ]: 29454 : if (!m_exceptionsInit) {
96 [ + - ]: 29454 : m_exceptions = exceptions;
97 : 29454 : m_exceptionsInit = true;
98 : : }
99 [ + - ][ + - ]: 30863 : return m_exceptions;
[ + - ]
100 : : }
101 : :
102 : 58349 : typereg::Reader FunctionDescription::getReader() const {
103 : : return typereg::Reader(
104 : 58349 : m_bytes.getConstArray(), m_bytes.getLength(), false, TYPEREG_VERSION_1);
105 : : }
106 : :
107 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|