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