merge the formfield patch from ooo-build
[ooovba.git] / stoc / source / registry_tdprovider / structtypedescription.cxx
blob4a06f0f8c6c649c18edc65d081b010fb62ea87e2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: structtypedescription.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_stoc.hxx"
34 #include "structtypedescription.hxx"
36 #include "base.hxx"
38 #include "com/sun/star/reflection/XTypeDescription.hpp"
39 #include "com/sun/star/uno/Reference.hxx"
40 #include "com/sun/star/uno/RuntimeException.hpp"
41 #include "com/sun/star/uno/Sequence.hxx"
42 #include "com/sun/star/uno/TypeClass.hpp"
43 #include "cppuhelper/weak.hxx"
44 #include "osl/diagnose.h"
45 #include "registry/reader.hxx"
46 #include "registry/types.h"
47 #include "registry/version.h"
48 #include "rtl/ustring.h"
49 #include "rtl/ustring.hxx"
51 #include <new>
53 namespace css = com::sun::star;
54 using stoc::registry_tdprovider::StructTypeDescription;
56 StructTypeDescription::StructTypeDescription(
57 css::uno::Reference< css::container::XHierarchicalNameAccess > const &
58 manager,
59 rtl::OUString const & name, rtl::OUString const & baseTypeName,
60 css::uno::Sequence< sal_Int8 > const & data, bool published):
61 m_data(data),
62 m_base(
63 new stoc_rdbtdp::CompoundTypeDescriptionImpl(
64 manager, css::uno::TypeClass_STRUCT, name, baseTypeName, data,
65 published))
68 StructTypeDescription::~StructTypeDescription()
71 css::uno::TypeClass StructTypeDescription::getTypeClass()
72 throw (css::uno::RuntimeException)
74 return m_base->getTypeClass();
77 rtl::OUString StructTypeDescription::getName()
78 throw (css::uno::RuntimeException)
80 return m_base->getName();
83 css::uno::Reference< css::reflection::XTypeDescription >
84 StructTypeDescription::getBaseType() throw (css::uno::RuntimeException)
86 return m_base->getBaseType();
89 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
90 StructTypeDescription::getMemberTypes() throw (css::uno::RuntimeException)
92 return m_base->getMemberTypes();
95 css::uno::Sequence< rtl::OUString > StructTypeDescription::getMemberNames()
96 throw (css::uno::RuntimeException)
98 return m_base->getMemberNames();
101 css::uno::Sequence< rtl::OUString > StructTypeDescription::getTypeParameters()
102 throw (css::uno::RuntimeException)
104 try {
105 typereg::Reader reader(
106 m_data.getConstArray(), m_data.getLength(), false,
107 TYPEREG_VERSION_1);
108 OSL_ASSERT(reader.isValid());
109 sal_uInt16 n = reader.getReferenceCount();
110 css::uno::Sequence< rtl::OUString > parameters(n);
111 for (sal_uInt16 i = 0; i < n; ++i) {
112 if (reader.getReferenceFlags(i) != RT_ACCESS_INVALID
113 || reader.getReferenceSort(i) != RT_REF_TYPE_PARAMETER)
115 throw css::uno::RuntimeException(
116 rtl::OUString(
117 RTL_CONSTASCII_USTRINGPARAM(
118 "type parameter of polymorphic struct type template"
119 " not RT_ACCESS_INVALID/RT_REF_TYPE_PARAMETER")),
120 static_cast< cppu::OWeakObject * >(this));
122 parameters[i] = reader.getReferenceTypeName(i);
124 return parameters;
125 } catch (std::bad_alloc &) {
126 throw css::uno::RuntimeException(
127 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("std::bad_alloc")),
128 static_cast< cppu::OWeakObject * >(this));
132 css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > >
133 StructTypeDescription::getTypeArguments() throw (css::uno::RuntimeException)
135 return css::uno::Sequence<
136 css::uno::Reference< css::reflection::XTypeDescription > >();
139 sal_Bool StructTypeDescription::isPublished() throw (css::uno::RuntimeException)
141 return m_base->isPublished();