1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tdcomp.cxx,v $
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"
35 #include "registry/reader.hxx"
36 #include "registry/version.h"
41 //__________________________________________________________________________________________________
42 CompoundTypeDescriptionImpl::~CompoundTypeDescriptionImpl()
46 g_moduleCount
.modCnt
.release( &g_moduleCount
.modCnt
);
50 //__________________________________________________________________________________________________
51 TypeClass
CompoundTypeDescriptionImpl::getTypeClass()
52 throw(::com::sun::star::uno::RuntimeException
)
56 //__________________________________________________________________________________________________
57 OUString
CompoundTypeDescriptionImpl::getName()
58 throw(::com::sun::star::uno::RuntimeException
)
63 // XCompoundTypeDescription
64 //__________________________________________________________________________________________________
65 Reference
< XTypeDescription
> CompoundTypeDescriptionImpl::getBaseType()
66 throw(::com::sun::star::uno::RuntimeException
)
68 if (!_xBaseTD
.is() && _aBaseType
.getLength())
72 Reference
< XTypeDescription
> xBaseTD
;
73 if (_xTDMgr
->getByHierarchicalName( _aBaseType
) >>= xBaseTD
)
75 MutexGuard
aGuard( getMutex() );
81 catch (NoSuchElementException
&)
84 // never try again, if no base td was found
85 _aBaseType
= OUString();
89 //__________________________________________________________________________________________________
93 class TypeParameter
: public WeakImplHelper1
< XTypeDescription
> {
95 explicit TypeParameter(OUString
const & name
): m_name(name
) {}
97 virtual TypeClass SAL_CALL
getTypeClass() throw (RuntimeException
)
98 { return TypeClass_UNKNOWN
; }
100 virtual OUString SAL_CALL
getName() throw (RuntimeException
)
109 Sequence
< Reference
< XTypeDescription
> > CompoundTypeDescriptionImpl::getMemberTypes()
110 throw(::com::sun::star::uno::RuntimeException
)
114 typereg::Reader
aReader(
115 _aBytes
.getConstArray(), _aBytes
.getLength(), false,
118 sal_uInt16 nFields
= aReader
.getFieldCount();
119 Sequence
< Reference
< XTypeDescription
> > * pTempMembers
=
120 new Sequence
< Reference
< XTypeDescription
> >( nFields
);
121 Reference
< XTypeDescription
> * pMembers
= pTempMembers
->getArray();
125 if ((aReader
.getFieldFlags(nFields
) & RT_ACCESS_PARAMETERIZED_TYPE
)
128 pMembers
[nFields
] = new TypeParameter(
129 aReader
.getFieldTypeName(nFields
));
132 _xTDMgr
->getByHierarchicalName(
133 aReader
.getFieldTypeName(nFields
).replace('/', '.'))
134 >>= pMembers
[nFields
];
135 } catch (NoSuchElementException
&) {}
137 pMembers
[nFields
].is(), "### compound member unknown!");
141 ClearableMutexGuard
aGuard( getMutex() );
149 _pMembers
= pTempMembers
;
155 //__________________________________________________________________________________________________
156 Sequence
< OUString
> CompoundTypeDescriptionImpl::getMemberNames()
157 throw(::com::sun::star::uno::RuntimeException
)
161 typereg::Reader
aReader(
162 _aBytes
.getConstArray(), _aBytes
.getLength(), false,
165 sal_uInt16 nFields
= aReader
.getFieldCount();
166 Sequence
< OUString
> * pTempMemberNames
= new Sequence
< OUString
>( nFields
);
167 OUString
* pMemberNames
= pTempMemberNames
->getArray();
171 pMemberNames
[nFields
] = aReader
.getFieldName( nFields
);
174 ClearableMutexGuard
aGuard( getMutex() );
178 delete pTempMemberNames
;
182 _pMemberNames
= pTempMemberNames
;
185 return *_pMemberNames
;