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 "methoddescription.hxx"
22 : :
23 : : #include "com/sun/star/container/NoSuchElementException.hpp"
24 : : #include "com/sun/star/container/XHierarchicalNameAccess.hpp"
25 : : #include "com/sun/star/reflection/XParameter.hpp"
26 : : #include "com/sun/star/reflection/XTypeDescription.hpp"
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 "cppuhelper/implbase1.hxx"
31 : : #include "cppuhelper/weak.hxx"
32 : : #include "osl/mutex.hxx"
33 : : #include "registry/reader.hxx"
34 : : #include "registry/types.h"
35 : : #include "rtl/ustring.hxx"
36 : : #include "sal/types.h"
37 : :
38 : : namespace css = com::sun::star;
39 : :
40 : : using stoc::registry_tdprovider::MethodDescription;
41 : :
42 : : namespace {
43 : :
44 : : class Parameter: public cppu::WeakImplHelper1< css::reflection::XParameter > {
45 : : public:
46 : 25951 : Parameter(
47 : : css::uno::Reference< css::container::XHierarchicalNameAccess > const &
48 : : manager,
49 : : rtl::OUString const & name, rtl::OUString const & typeName,
50 : : RTParamMode mode, sal_Int32 position):
51 : : m_manager(manager), m_name(name),
52 : : m_typeName(typeName.replace('/', '.')), m_mode(mode),
53 : 25951 : m_position(position) {}
54 : :
55 [ - + ]: 48026 : virtual ~Parameter() {}
56 : :
57 : 26981 : virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException)
58 : 26981 : { return m_name; }
59 : :
60 : : virtual css::uno::Reference< css::reflection::XTypeDescription > SAL_CALL
61 : : getType() throw (css::uno::RuntimeException);
62 : :
63 : 26981 : virtual sal_Bool SAL_CALL isIn() throw (css::uno::RuntimeException)
64 : 26981 : { return (m_mode & RT_PARAM_IN) != 0; }
65 : :
66 : 26981 : virtual sal_Bool SAL_CALL isOut() throw (css::uno::RuntimeException)
67 : 26981 : { return (m_mode & RT_PARAM_OUT) != 0; }
68 : :
69 : 26981 : virtual sal_Int32 SAL_CALL getPosition() throw (css::uno::RuntimeException)
70 : 26981 : { return m_position; }
71 : :
72 : 0 : virtual sal_Bool SAL_CALL isRestParameter()
73 : : throw (css::uno::RuntimeException)
74 : 0 : { return (m_mode & RT_PARAM_REST) != 0; }
75 : :
76 : : private:
77 : : Parameter(Parameter &); // not implemented
78 : : void operator =(Parameter); // not implemented
79 : :
80 : : css::uno::Reference< css::container::XHierarchicalNameAccess > m_manager;
81 : : rtl::OUString m_name;
82 : : rtl::OUString m_typeName;
83 : : RTParamMode m_mode;
84 : : sal_Int32 m_position;
85 : : };
86 : :
87 : 26981 : css::uno::Reference< css::reflection::XTypeDescription > Parameter::getType()
88 : : throw (css::uno::RuntimeException)
89 : : {
90 : : try {
91 : : return css::uno::Reference< css::reflection::XTypeDescription >(
92 [ + - ]: 26981 : m_manager->getByHierarchicalName(m_typeName),
93 [ + - ][ + - ]: 26981 : css::uno::UNO_QUERY_THROW);
94 [ # # ]: 0 : } catch (const css::container::NoSuchElementException & e) {
95 : : throw new css::uno::RuntimeException(
96 : : (rtl::OUString(
97 : : RTL_CONSTASCII_USTRINGPARAM(
98 : : "com.sun.star.container.NoSuchElementException: "))
99 : : + e.Message),
100 [ # # # # : 0 : static_cast< cppu::OWeakObject * >(this));
# # # # ]
101 : : }
102 : : }
103 : :
104 : : }
105 : :
106 : 168353 : MethodDescription::MethodDescription(
107 : : css::uno::Reference< css::container::XHierarchicalNameAccess > const &
108 : : manager,
109 : : rtl::OUString const & name,
110 : : com::sun::star::uno::Sequence< sal_Int8 > const & bytes,
111 : : sal_uInt16 index):
112 : : FunctionDescription(manager, bytes, index), m_name(name),
113 [ + - ]: 168353 : m_parametersInit(false)
114 : 168353 : {}
115 : :
116 [ + - ]: 164908 : MethodDescription::~MethodDescription() {}
117 : :
118 : : css::uno::Sequence< css::uno::Reference< css::reflection::XParameter > >
119 : 30292 : MethodDescription::getParameters() const {
120 [ + - ]: 30292 : osl::MutexGuard guard(m_mutex);
121 [ + + ]: 30292 : if (!m_parametersInit) {
122 [ + - ]: 28895 : typereg::Reader reader(getReader());
123 : 28895 : sal_uInt16 n = reader.getMethodParameterCount(m_index);
124 [ + - ]: 28895 : m_parameters.realloc(n);
125 [ + + ]: 54846 : for (sal_uInt16 i = 0; i < n; ++i) {
126 [ + - ]: 25951 : m_parameters[i] = new Parameter(
127 : : m_manager, reader.getMethodParameterName(m_index, i),
128 : : reader.getMethodParameterTypeName(m_index, i),
129 [ + - ][ + - ]: 51902 : reader.getMethodParameterFlags(m_index, i), i);
[ + - ][ + - ]
[ + - ]
130 : : }
131 : 28895 : m_parametersInit = true;
132 : : }
133 [ + - ][ + - ]: 30292 : return m_parameters;
134 : : }
135 : :
136 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|