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 "structtypedescription.hxx"
22 :
23 : #include "base.hxx"
24 :
25 : #include "com/sun/star/reflection/XTypeDescription.hpp"
26 : #include "com/sun/star/uno/Reference.hxx"
27 : #include "com/sun/star/uno/RuntimeException.hpp"
28 : #include "com/sun/star/uno/Sequence.hxx"
29 : #include "com/sun/star/uno/TypeClass.hpp"
30 : #include "cppuhelper/weak.hxx"
31 : #include "osl/diagnose.h"
32 : #include "registry/reader.hxx"
33 : #include "registry/types.h"
34 : #include "registry/version.h"
35 : #include "rtl/ustring.h"
36 : #include "rtl/ustring.hxx"
37 :
38 : #include <new>
39 :
40 : using stoc::registry_tdprovider::StructTypeDescription;
41 :
42 2268 : StructTypeDescription::StructTypeDescription(
43 : css::uno::Reference< css::container::XHierarchicalNameAccess > const &
44 : manager,
45 : rtl::OUString const & name, rtl::OUString const & baseTypeName,
46 : css::uno::Sequence< sal_Int8 > const & data, bool published):
47 : m_data(data),
48 : m_base(
49 : new stoc_rdbtdp::CompoundTypeDescriptionImpl(
50 : manager, css::uno::TypeClass_STRUCT, name, baseTypeName, data,
51 2268 : published))
52 2268 : {}
53 :
54 4480 : StructTypeDescription::~StructTypeDescription()
55 4480 : {}
56 :
57 3007 : css::uno::TypeClass StructTypeDescription::getTypeClass()
58 : throw (css::uno::RuntimeException)
59 : {
60 3007 : return m_base->getTypeClass();
61 : }
62 :
63 4821 : rtl::OUString StructTypeDescription::getName()
64 : throw (css::uno::RuntimeException)
65 : {
66 4821 : return m_base->getName();
67 : }
68 :
69 : css::uno::Reference< css::reflection::XTypeDescription >
70 2191 : StructTypeDescription::getBaseType() throw (css::uno::RuntimeException)
71 : {
72 2191 : return m_base->getBaseType();
73 : }
74 :
75 : css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
76 2301 : StructTypeDescription::getMemberTypes() throw (css::uno::RuntimeException)
77 : {
78 2301 : return m_base->getMemberTypes();
79 : }
80 :
81 2191 : css::uno::Sequence< rtl::OUString > StructTypeDescription::getMemberNames()
82 : throw (css::uno::RuntimeException)
83 : {
84 2191 : return m_base->getMemberNames();
85 : }
86 :
87 2331 : css::uno::Sequence< rtl::OUString > StructTypeDescription::getTypeParameters()
88 : throw (css::uno::RuntimeException)
89 : {
90 : try {
91 : typereg::Reader reader(
92 4662 : m_data.getConstArray(), m_data.getLength(), false,
93 4662 : TYPEREG_VERSION_1);
94 : OSL_ASSERT(reader.isValid());
95 2331 : sal_uInt16 n = reader.getReferenceCount();
96 2331 : css::uno::Sequence< rtl::OUString > parameters(n);
97 2671 : for (sal_uInt16 i = 0; i < n; ++i) {
98 680 : if (reader.getReferenceFlags(i) != RT_ACCESS_INVALID
99 340 : || reader.getReferenceSort(i) != RT_REF_TYPE_PARAMETER)
100 : {
101 : throw css::uno::RuntimeException(
102 : rtl::OUString(
103 : RTL_CONSTASCII_USTRINGPARAM(
104 : "type parameter of polymorphic struct type template"
105 : " not RT_ACCESS_INVALID/RT_REF_TYPE_PARAMETER")),
106 0 : static_cast< cppu::OWeakObject * >(this));
107 : }
108 340 : parameters[i] = reader.getReferenceTypeName(i);
109 : }
110 2331 : return parameters;
111 0 : } catch (std::bad_alloc &) {
112 : throw css::uno::RuntimeException(
113 : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("std::bad_alloc")),
114 0 : static_cast< cppu::OWeakObject * >(this));
115 : }
116 : }
117 :
118 : css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
119 0 : StructTypeDescription::getTypeArguments() throw (css::uno::RuntimeException)
120 : {
121 : return css::uno::Sequence<
122 0 : css::uno::Reference< css::reflection::XTypeDescription > >();
123 : }
124 :
125 0 : sal_Bool StructTypeDescription::isPublished() throw (css::uno::RuntimeException)
126 : {
127 0 : return m_base->isPublished();
128 : }
129 :
130 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|