1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_stoc.hxx"
30*cdf0e10cSrcweir #include <rtl/strbuf.hxx>
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <com/sun/star/reflection/XIdlField.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/reflection/XIdlField2.hpp>
34*cdf0e10cSrcweir #include "com/sun/star/uno/TypeClass.hpp"
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include "base.hxx"
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir namespace stoc_corefl
40*cdf0e10cSrcweir {
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir //==================================================================================================
43*cdf0e10cSrcweir class IdlCompFieldImpl
44*cdf0e10cSrcweir 	: public IdlMemberImpl
45*cdf0e10cSrcweir 	, public XIdlField
46*cdf0e10cSrcweir 	, public XIdlField2
47*cdf0e10cSrcweir {
48*cdf0e10cSrcweir 	sal_Int32					_nOffset;
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir public:
51*cdf0e10cSrcweir 	IdlCompFieldImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
52*cdf0e10cSrcweir 					  typelib_TypeDescription * pTypeDescr, typelib_TypeDescription * pDeclTypeDescr,
53*cdf0e10cSrcweir 					  sal_Int32 nOffset )
54*cdf0e10cSrcweir 		: IdlMemberImpl( pReflection, rName, pTypeDescr, pDeclTypeDescr )
55*cdf0e10cSrcweir 		, _nOffset( nOffset )
56*cdf0e10cSrcweir 		{}
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir 	// XInterface
59*cdf0e10cSrcweir 	virtual Any SAL_CALL queryInterface( const Type & rType ) throw (::com::sun::star::uno::RuntimeException);
60*cdf0e10cSrcweir 	virtual void SAL_CALL acquire() throw ();
61*cdf0e10cSrcweir 	virtual void SAL_CALL release() throw ();
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 	// XTypeProvider
64*cdf0e10cSrcweir 	virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
65*cdf0e10cSrcweir 	virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir 	// XIdlMember
68*cdf0e10cSrcweir     virtual Reference< XIdlClass > SAL_CALL getDeclaringClass() throw(::com::sun::star::uno::RuntimeException);
69*cdf0e10cSrcweir     virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
70*cdf0e10cSrcweir 	// XIdlField
71*cdf0e10cSrcweir     virtual Reference< XIdlClass > SAL_CALL getType() throw(::com::sun::star::uno::RuntimeException);
72*cdf0e10cSrcweir     virtual FieldAccessMode SAL_CALL getAccessMode() throw(::com::sun::star::uno::RuntimeException);
73*cdf0e10cSrcweir     virtual Any SAL_CALL get( const Any & rObj ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
74*cdf0e10cSrcweir     virtual void SAL_CALL set( const Any & rObj, const Any & rValue ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
75*cdf0e10cSrcweir 	// XIdlField2: getType, getAccessMode and get are equal to XIdlField
76*cdf0e10cSrcweir     virtual void SAL_CALL set( Any & rObj, const Any & rValue ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
77*cdf0e10cSrcweir };
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir // XInterface
80*cdf0e10cSrcweir //__________________________________________________________________________________________________
81*cdf0e10cSrcweir Any IdlCompFieldImpl::queryInterface( const Type & rType )
82*cdf0e10cSrcweir 	throw(::com::sun::star::uno::RuntimeException)
83*cdf0e10cSrcweir {
84*cdf0e10cSrcweir 	Any aRet( ::cppu::queryInterface( rType,
85*cdf0e10cSrcweir     								  static_cast< XIdlField * >( this ),
86*cdf0e10cSrcweir     								  static_cast< XIdlField2 * >( this ) ) );
87*cdf0e10cSrcweir 	return (aRet.hasValue() ? aRet : IdlMemberImpl::queryInterface( rType ));
88*cdf0e10cSrcweir }
89*cdf0e10cSrcweir //__________________________________________________________________________________________________
90*cdf0e10cSrcweir void IdlCompFieldImpl::acquire() throw()
91*cdf0e10cSrcweir {
92*cdf0e10cSrcweir 	IdlMemberImpl::acquire();
93*cdf0e10cSrcweir }
94*cdf0e10cSrcweir //__________________________________________________________________________________________________
95*cdf0e10cSrcweir void IdlCompFieldImpl::release() throw()
96*cdf0e10cSrcweir {
97*cdf0e10cSrcweir 	IdlMemberImpl::release();
98*cdf0e10cSrcweir }
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir // XTypeProvider
101*cdf0e10cSrcweir //__________________________________________________________________________________________________
102*cdf0e10cSrcweir Sequence< Type > IdlCompFieldImpl::getTypes()
103*cdf0e10cSrcweir 	throw (::com::sun::star::uno::RuntimeException)
104*cdf0e10cSrcweir {
105*cdf0e10cSrcweir 	static OTypeCollection * s_pTypes = 0;
106*cdf0e10cSrcweir 	if (! s_pTypes)
107*cdf0e10cSrcweir 	{
108*cdf0e10cSrcweir 		MutexGuard aGuard( getMutexAccess() );
109*cdf0e10cSrcweir 		if (! s_pTypes)
110*cdf0e10cSrcweir 		{
111*cdf0e10cSrcweir 			static OTypeCollection s_aTypes(
112*cdf0e10cSrcweir 				::getCppuType( (const Reference< XIdlField2 > *)0 ),
113*cdf0e10cSrcweir 				::getCppuType( (const Reference< XIdlField > *)0 ),
114*cdf0e10cSrcweir 				IdlMemberImpl::getTypes() );
115*cdf0e10cSrcweir 			s_pTypes = &s_aTypes;
116*cdf0e10cSrcweir 		}
117*cdf0e10cSrcweir 	}
118*cdf0e10cSrcweir 	return s_pTypes->getTypes();
119*cdf0e10cSrcweir }
120*cdf0e10cSrcweir //__________________________________________________________________________________________________
121*cdf0e10cSrcweir Sequence< sal_Int8 > IdlCompFieldImpl::getImplementationId()
122*cdf0e10cSrcweir 	throw (::com::sun::star::uno::RuntimeException)
123*cdf0e10cSrcweir {
124*cdf0e10cSrcweir 	static OImplementationId * s_pId = 0;
125*cdf0e10cSrcweir 	if (! s_pId)
126*cdf0e10cSrcweir 	{
127*cdf0e10cSrcweir 		MutexGuard aGuard( getMutexAccess() );
128*cdf0e10cSrcweir 		if (! s_pId)
129*cdf0e10cSrcweir 		{
130*cdf0e10cSrcweir 			static OImplementationId s_aId;
131*cdf0e10cSrcweir 			s_pId = &s_aId;
132*cdf0e10cSrcweir 		}
133*cdf0e10cSrcweir 	}
134*cdf0e10cSrcweir 	return s_pId->getImplementationId();
135*cdf0e10cSrcweir }
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir // XIdlMember
138*cdf0e10cSrcweir //__________________________________________________________________________________________________
139*cdf0e10cSrcweir Reference< XIdlClass > IdlCompFieldImpl::getDeclaringClass()
140*cdf0e10cSrcweir 	throw(::com::sun::star::uno::RuntimeException)
141*cdf0e10cSrcweir {
142*cdf0e10cSrcweir 	if (! _xDeclClass.is())
143*cdf0e10cSrcweir 	{
144*cdf0e10cSrcweir 		MutexGuard aGuard( getMutexAccess() );
145*cdf0e10cSrcweir 		if (! _xDeclClass.is())
146*cdf0e10cSrcweir 		{
147*cdf0e10cSrcweir 			typelib_CompoundTypeDescription * pTD =
148*cdf0e10cSrcweir 				(typelib_CompoundTypeDescription *)getDeclTypeDescr();
149*cdf0e10cSrcweir 			while (pTD)
150*cdf0e10cSrcweir 			{
151*cdf0e10cSrcweir 				typelib_TypeDescriptionReference ** ppTypeRefs = pTD->ppTypeRefs;
152*cdf0e10cSrcweir 				for ( sal_Int32 nPos = pTD->nMembers; nPos--; )
153*cdf0e10cSrcweir 				{
154*cdf0e10cSrcweir 					if (td_equals( (typelib_TypeDescription *)getTypeDescr(), ppTypeRefs[nPos] ))
155*cdf0e10cSrcweir 					{
156*cdf0e10cSrcweir 						_xDeclClass = getReflection()->forType( (typelib_TypeDescription *)pTD );
157*cdf0e10cSrcweir 						return _xDeclClass;
158*cdf0e10cSrcweir 					}
159*cdf0e10cSrcweir 				}
160*cdf0e10cSrcweir 				pTD = pTD->pBaseTypeDescription;
161*cdf0e10cSrcweir 			}
162*cdf0e10cSrcweir 		}
163*cdf0e10cSrcweir 	}
164*cdf0e10cSrcweir 	return _xDeclClass;
165*cdf0e10cSrcweir }
166*cdf0e10cSrcweir //__________________________________________________________________________________________________
167*cdf0e10cSrcweir OUString IdlCompFieldImpl::getName()
168*cdf0e10cSrcweir 	throw(::com::sun::star::uno::RuntimeException)
169*cdf0e10cSrcweir {
170*cdf0e10cSrcweir 	return IdlMemberImpl::getName();
171*cdf0e10cSrcweir }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir // XIdlField
174*cdf0e10cSrcweir //__________________________________________________________________________________________________
175*cdf0e10cSrcweir Reference< XIdlClass > IdlCompFieldImpl::getType()
176*cdf0e10cSrcweir 	throw(::com::sun::star::uno::RuntimeException)
177*cdf0e10cSrcweir {
178*cdf0e10cSrcweir 	return getReflection()->forType( getTypeDescr() );
179*cdf0e10cSrcweir }
180*cdf0e10cSrcweir //__________________________________________________________________________________________________
181*cdf0e10cSrcweir FieldAccessMode IdlCompFieldImpl::getAccessMode()
182*cdf0e10cSrcweir 	throw(::com::sun::star::uno::RuntimeException)
183*cdf0e10cSrcweir {
184*cdf0e10cSrcweir     return FieldAccessMode_READWRITE;
185*cdf0e10cSrcweir }
186*cdf0e10cSrcweir //__________________________________________________________________________________________________
187*cdf0e10cSrcweir Any IdlCompFieldImpl::get( const Any & rObj )
188*cdf0e10cSrcweir 	throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
189*cdf0e10cSrcweir {
190*cdf0e10cSrcweir 	if (rObj.getValueTypeClass() == com::sun::star::uno::TypeClass_STRUCT ||
191*cdf0e10cSrcweir 		rObj.getValueTypeClass() == com::sun::star::uno::TypeClass_EXCEPTION)
192*cdf0e10cSrcweir 	{
193*cdf0e10cSrcweir 		typelib_TypeDescription * pObjTD = 0;
194*cdf0e10cSrcweir 		TYPELIB_DANGER_GET( &pObjTD, rObj.getValueTypeRef() );
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 		typelib_TypeDescription * pTD = pObjTD;
197*cdf0e10cSrcweir 		typelib_TypeDescription * pDeclTD = getDeclTypeDescr();
198*cdf0e10cSrcweir 		while (pTD && !typelib_typedescription_equals( pTD, pDeclTD ))
199*cdf0e10cSrcweir 			pTD = (typelib_TypeDescription *)((typelib_CompoundTypeDescription *)pTD)->pBaseTypeDescription;
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 		OSL_ENSURE( pTD, "### illegal object type!" );
202*cdf0e10cSrcweir 		if (pTD)
203*cdf0e10cSrcweir 		{
204*cdf0e10cSrcweir 			TYPELIB_DANGER_RELEASE( pObjTD );
205*cdf0e10cSrcweir 			Any aRet;
206*cdf0e10cSrcweir 			uno_any_destruct(
207*cdf0e10cSrcweir                 &aRet, reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
208*cdf0e10cSrcweir 			uno_any_construct(
209*cdf0e10cSrcweir                 &aRet, (char *)rObj.getValue() + _nOffset, getTypeDescr(),
210*cdf0e10cSrcweir                 reinterpret_cast< uno_AcquireFunc >(cpp_acquire) );
211*cdf0e10cSrcweir 			return aRet;
212*cdf0e10cSrcweir 		}
213*cdf0e10cSrcweir 		TYPELIB_DANGER_RELEASE( pObjTD );
214*cdf0e10cSrcweir 	}
215*cdf0e10cSrcweir 	throw IllegalArgumentException(
216*cdf0e10cSrcweir 		OUString( RTL_CONSTASCII_USTRINGPARAM("illegal object given!") ),
217*cdf0e10cSrcweir 		(XWeak *)(OWeakObject *)this, 0 );
218*cdf0e10cSrcweir }
219*cdf0e10cSrcweir //__________________________________________________________________________________________________
220*cdf0e10cSrcweir void IdlCompFieldImpl::set( const Any & rObj, const Any & rValue )
221*cdf0e10cSrcweir 	throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException)
222*cdf0e10cSrcweir {
223*cdf0e10cSrcweir 	if (rObj.getValueTypeClass() == com::sun::star::uno::TypeClass_STRUCT ||
224*cdf0e10cSrcweir 		rObj.getValueTypeClass() == com::sun::star::uno::TypeClass_EXCEPTION)
225*cdf0e10cSrcweir 	{
226*cdf0e10cSrcweir 		typelib_TypeDescription * pObjTD = 0;
227*cdf0e10cSrcweir 		TYPELIB_DANGER_GET( &pObjTD, rObj.getValueTypeRef() );
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir 		typelib_TypeDescription * pTD = pObjTD;
230*cdf0e10cSrcweir 		typelib_TypeDescription * pDeclTD = getDeclTypeDescr();
231*cdf0e10cSrcweir 		while (pTD && !typelib_typedescription_equals( pTD, pDeclTD ))
232*cdf0e10cSrcweir 			pTD = (typelib_TypeDescription *)((typelib_CompoundTypeDescription *)pTD)->pBaseTypeDescription;
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir 		OSL_ENSURE( pTD, "### illegal object type!" );
235*cdf0e10cSrcweir 		if (pTD)
236*cdf0e10cSrcweir 		{
237*cdf0e10cSrcweir 			TYPELIB_DANGER_RELEASE( pObjTD );
238*cdf0e10cSrcweir 			if (coerce_assign( (char *)rObj.getValue() + _nOffset, getTypeDescr(), rValue, getReflection() ))
239*cdf0e10cSrcweir 			{
240*cdf0e10cSrcweir 				return;
241*cdf0e10cSrcweir 			}
242*cdf0e10cSrcweir 			else
243*cdf0e10cSrcweir 			{
244*cdf0e10cSrcweir 				throw IllegalArgumentException(
245*cdf0e10cSrcweir 					OUString( RTL_CONSTASCII_USTRINGPARAM("illegal value given!") ),
246*cdf0e10cSrcweir 					(XWeak *)(OWeakObject *)this, 1 );
247*cdf0e10cSrcweir 			}
248*cdf0e10cSrcweir 		}
249*cdf0e10cSrcweir 		TYPELIB_DANGER_RELEASE( pObjTD );
250*cdf0e10cSrcweir 	}
251*cdf0e10cSrcweir 	throw IllegalArgumentException(
252*cdf0e10cSrcweir 		OUString( RTL_CONSTASCII_USTRINGPARAM("illegal object given!") ),
253*cdf0e10cSrcweir 		(XWeak *)(OWeakObject *)this, 0 );
254*cdf0e10cSrcweir }
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir //__________________________________________________________________________________________________
257*cdf0e10cSrcweir void IdlCompFieldImpl::set( Any & rObj, const Any & rValue )
258*cdf0e10cSrcweir 	throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException)
259*cdf0e10cSrcweir {
260*cdf0e10cSrcweir 	if (rObj.getValueTypeClass() == com::sun::star::uno::TypeClass_STRUCT ||
261*cdf0e10cSrcweir 		rObj.getValueTypeClass() == com::sun::star::uno::TypeClass_EXCEPTION)
262*cdf0e10cSrcweir 	{
263*cdf0e10cSrcweir 		typelib_TypeDescription * pObjTD = 0;
264*cdf0e10cSrcweir 		TYPELIB_DANGER_GET( &pObjTD, rObj.getValueTypeRef() );
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir 		typelib_TypeDescription * pTD = pObjTD;
267*cdf0e10cSrcweir 		typelib_TypeDescription * pDeclTD = getDeclTypeDescr();
268*cdf0e10cSrcweir 		while (pTD && !typelib_typedescription_equals( pTD, pDeclTD ))
269*cdf0e10cSrcweir 			pTD = (typelib_TypeDescription *)((typelib_CompoundTypeDescription *)pTD)->pBaseTypeDescription;
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir 		OSL_ENSURE( pTD, "### illegal object type!" );
272*cdf0e10cSrcweir 		if (pTD)
273*cdf0e10cSrcweir 		{
274*cdf0e10cSrcweir 			TYPELIB_DANGER_RELEASE( pObjTD );
275*cdf0e10cSrcweir 			if (coerce_assign( (char *)rObj.getValue() + _nOffset, getTypeDescr(), rValue, getReflection() ))
276*cdf0e10cSrcweir 			{
277*cdf0e10cSrcweir 				return;
278*cdf0e10cSrcweir 			}
279*cdf0e10cSrcweir 			else
280*cdf0e10cSrcweir 			{
281*cdf0e10cSrcweir 				throw IllegalArgumentException(
282*cdf0e10cSrcweir 					OUString( RTL_CONSTASCII_USTRINGPARAM("illegal value given!") ),
283*cdf0e10cSrcweir 					(XWeak *)(OWeakObject *)this, 1 );
284*cdf0e10cSrcweir 			}
285*cdf0e10cSrcweir 		}
286*cdf0e10cSrcweir 		TYPELIB_DANGER_RELEASE( pObjTD );
287*cdf0e10cSrcweir 	}
288*cdf0e10cSrcweir 	throw IllegalArgumentException(
289*cdf0e10cSrcweir 		OUString( RTL_CONSTASCII_USTRINGPARAM("illegal object given!") ),
290*cdf0e10cSrcweir 		(XWeak *)(OWeakObject *)this, 0 );
291*cdf0e10cSrcweir }
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir //##################################################################################################
294*cdf0e10cSrcweir //##################################################################################################
295*cdf0e10cSrcweir //##################################################################################################
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir //__________________________________________________________________________________________________
299*cdf0e10cSrcweir CompoundIdlClassImpl::~CompoundIdlClassImpl()
300*cdf0e10cSrcweir {
301*cdf0e10cSrcweir 	delete _pFields;
302*cdf0e10cSrcweir }
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir //__________________________________________________________________________________________________
305*cdf0e10cSrcweir sal_Bool CompoundIdlClassImpl::isAssignableFrom( const Reference< XIdlClass > & xType )
306*cdf0e10cSrcweir 	throw(::com::sun::star::uno::RuntimeException)
307*cdf0e10cSrcweir {
308*cdf0e10cSrcweir 	if (xType.is())
309*cdf0e10cSrcweir 	{
310*cdf0e10cSrcweir 		TypeClass eTC = xType->getTypeClass();
311*cdf0e10cSrcweir 		if (eTC == TypeClass_STRUCT || eTC == TypeClass_EXCEPTION)
312*cdf0e10cSrcweir 		{
313*cdf0e10cSrcweir 			if (equals( xType ))
314*cdf0e10cSrcweir 				return sal_True;
315*cdf0e10cSrcweir 			else
316*cdf0e10cSrcweir 			{
317*cdf0e10cSrcweir 				const Sequence< Reference< XIdlClass > > & rSeq = xType->getSuperclasses();
318*cdf0e10cSrcweir 				if (rSeq.getLength())
319*cdf0e10cSrcweir 				{
320*cdf0e10cSrcweir 					OSL_ENSURE( rSeq.getLength() == 1, "### unexpected len of super classes!" );
321*cdf0e10cSrcweir 					return isAssignableFrom( rSeq[0] );
322*cdf0e10cSrcweir 				}
323*cdf0e10cSrcweir 			}
324*cdf0e10cSrcweir 		}
325*cdf0e10cSrcweir 	}
326*cdf0e10cSrcweir 	return sal_False;
327*cdf0e10cSrcweir }
328*cdf0e10cSrcweir //__________________________________________________________________________________________________
329*cdf0e10cSrcweir Sequence< Reference< XIdlClass > > CompoundIdlClassImpl::getSuperclasses()
330*cdf0e10cSrcweir 	throw(::com::sun::star::uno::RuntimeException)
331*cdf0e10cSrcweir {
332*cdf0e10cSrcweir 	if (! _xSuperClass.is())
333*cdf0e10cSrcweir 	{
334*cdf0e10cSrcweir 		MutexGuard aGuard( getMutexAccess() );
335*cdf0e10cSrcweir 		if (! _xSuperClass.is())
336*cdf0e10cSrcweir 		{
337*cdf0e10cSrcweir 			typelib_CompoundTypeDescription * pCompTypeDescr = getTypeDescr()->pBaseTypeDescription;
338*cdf0e10cSrcweir 			if (pCompTypeDescr)
339*cdf0e10cSrcweir 				_xSuperClass = getReflection()->forType( (typelib_TypeDescription *)pCompTypeDescr );
340*cdf0e10cSrcweir 		}
341*cdf0e10cSrcweir 	}
342*cdf0e10cSrcweir 	if (_xSuperClass.is())
343*cdf0e10cSrcweir 		return Sequence< Reference< XIdlClass > >( &_xSuperClass, 1 );
344*cdf0e10cSrcweir 	else
345*cdf0e10cSrcweir 		return Sequence< Reference< XIdlClass > >();
346*cdf0e10cSrcweir }
347*cdf0e10cSrcweir //__________________________________________________________________________________________________
348*cdf0e10cSrcweir Reference< XIdlField > CompoundIdlClassImpl::getField( const OUString & rName )
349*cdf0e10cSrcweir 	throw(::com::sun::star::uno::RuntimeException)
350*cdf0e10cSrcweir {
351*cdf0e10cSrcweir 	if (! _pFields)
352*cdf0e10cSrcweir 		getFields(); // init fields
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir 	const OUString2Field::const_iterator iFind( _aName2Field.find( rName ) );
355*cdf0e10cSrcweir 	if (iFind != _aName2Field.end())
356*cdf0e10cSrcweir 		return Reference< XIdlField >( (*iFind).second );
357*cdf0e10cSrcweir 	else
358*cdf0e10cSrcweir 		return Reference< XIdlField >();
359*cdf0e10cSrcweir }
360*cdf0e10cSrcweir //__________________________________________________________________________________________________
361*cdf0e10cSrcweir Sequence< Reference< XIdlField > > CompoundIdlClassImpl::getFields()
362*cdf0e10cSrcweir 	throw(::com::sun::star::uno::RuntimeException)
363*cdf0e10cSrcweir {
364*cdf0e10cSrcweir 	MutexGuard aGuard( getMutexAccess() );
365*cdf0e10cSrcweir 	if (! _pFields)
366*cdf0e10cSrcweir 	{
367*cdf0e10cSrcweir 		sal_Int32 nAll = 0;
368*cdf0e10cSrcweir 		typelib_CompoundTypeDescription * pCompTypeDescr = getTypeDescr();
369*cdf0e10cSrcweir 		for ( ; pCompTypeDescr; pCompTypeDescr = pCompTypeDescr->pBaseTypeDescription )
370*cdf0e10cSrcweir 			nAll += pCompTypeDescr->nMembers;
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir 		Sequence< Reference< XIdlField > > * pFields =
373*cdf0e10cSrcweir 			new Sequence< Reference< XIdlField > >( nAll );
374*cdf0e10cSrcweir 		Reference< XIdlField > * pSeq = pFields->getArray();
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir 		for ( pCompTypeDescr = getTypeDescr(); pCompTypeDescr;
377*cdf0e10cSrcweir 			  pCompTypeDescr = pCompTypeDescr->pBaseTypeDescription )
378*cdf0e10cSrcweir 		{
379*cdf0e10cSrcweir 			typelib_TypeDescriptionReference ** ppTypeRefs = pCompTypeDescr->ppTypeRefs;
380*cdf0e10cSrcweir 			rtl_uString ** ppNames						   = pCompTypeDescr->ppMemberNames;
381*cdf0e10cSrcweir 			sal_Int32 * pMemberOffsets					   = pCompTypeDescr->pMemberOffsets;
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir 			for ( sal_Int32 nPos = pCompTypeDescr->nMembers; nPos--; )
384*cdf0e10cSrcweir 			{
385*cdf0e10cSrcweir 				typelib_TypeDescription * pTD = 0;
386*cdf0e10cSrcweir 				TYPELIB_DANGER_GET( &pTD, ppTypeRefs[nPos] );
387*cdf0e10cSrcweir 				OSL_ENSURE( pTD, "### cannot get field in struct!" );
388*cdf0e10cSrcweir 				if (pTD)
389*cdf0e10cSrcweir 				{
390*cdf0e10cSrcweir 					OUString aName( ppNames[nPos] );
391*cdf0e10cSrcweir 					_aName2Field[aName] = pSeq[--nAll] = new IdlCompFieldImpl(
392*cdf0e10cSrcweir 						getReflection(), aName, pTD, IdlClassImpl::getTypeDescr(), pMemberOffsets[nPos] );
393*cdf0e10cSrcweir 					TYPELIB_DANGER_RELEASE( pTD );
394*cdf0e10cSrcweir 				}
395*cdf0e10cSrcweir 			}
396*cdf0e10cSrcweir 		}
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir 		_pFields = pFields;
399*cdf0e10cSrcweir 	}
400*cdf0e10cSrcweir 	return *_pFields;
401*cdf0e10cSrcweir }
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir }
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir 
406