23#include <com/sun/star/reflection/XIdlField.hpp>
24#include <com/sun/star/reflection/XIdlField2.hpp>
25#include <com/sun/star/uno/TypeClass.hpp>
29using namespace css::lang;
30using namespace css::reflection;
31using namespace css::uno;
38typedef cppu::ImplInheritanceHelper<IdlMemberImpl, XIdlField, XIdlField2> IdlCompFieldImpl_Base;
39class IdlCompFieldImpl :
public IdlCompFieldImpl_Base
44 IdlCompFieldImpl( IdlReflectionServiceImpl * pReflection,
const OUString & rName,
47 : IdlCompFieldImpl_Base( pReflection, rName, pTypeDescr, pDeclTypeDescr )
52 virtual Reference< XIdlClass > SAL_CALL getDeclaringClass()
override;
53 virtual OUString SAL_CALL getName()
override;
55 virtual Reference< XIdlClass > SAL_CALL
getType()
override;
56 virtual FieldAccessMode SAL_CALL getAccessMode()
override;
57 virtual Any SAL_CALL
get(
const Any & rObj )
override;
58 virtual void SAL_CALL
set(
const Any & rObj,
const Any & rValue )
override;
60 virtual void SAL_CALL
set( Any & rObj,
const Any & rValue )
override;
67Reference< XIdlClass > IdlCompFieldImpl::getDeclaringClass()
69 if (! _xDeclClass.is())
72 if (! _xDeclClass.is())
74 typelib_CompoundTypeDescription * pTD =
75 reinterpret_cast<typelib_CompoundTypeDescription *
>(getDeclTypeDescr());
78 typelib_TypeDescriptionReference ** ppTypeRefs = pTD->ppTypeRefs;
79 for ( sal_Int32 nPos = pTD->nMembers; nPos--; )
81 if (
td_equals( getTypeDescr(), ppTypeRefs[nPos] ))
83 _xDeclClass = getReflection()->forType( &pTD->aBase );
87 pTD = pTD->pBaseTypeDescription;
94OUString IdlCompFieldImpl::getName()
101Reference< XIdlClass > IdlCompFieldImpl::getType()
103 return getReflection()->forType( getTypeDescr() );
106FieldAccessMode IdlCompFieldImpl::getAccessMode()
108 return FieldAccessMode_READWRITE;
111Any IdlCompFieldImpl::get(
const Any & rObj )
113 if (rObj.getValueTypeClass() == css::uno::TypeClass_STRUCT ||
114 rObj.getValueTypeClass() == css::uno::TypeClass_EXCEPTION)
117 TYPELIB_DANGER_GET( &pObjTD, rObj.getValueTypeRef() );
122 pTD = &
reinterpret_cast<typelib_CompoundTypeDescription *
>(pTD)->pBaseTypeDescription->aBase;
124 OSL_ENSURE( pTD,
"### illegal object type!" );
127 TYPELIB_DANGER_RELEASE( pObjTD );
130 &aRet,
reinterpret_cast< uno_ReleaseFunc
>(cpp_release) );
132 &aRet,
const_cast<char *
>(
static_cast<char const *
>(rObj.getValue()) +
_nOffset), getTypeDescr(),
133 reinterpret_cast< uno_AcquireFunc
>(cpp_acquire) );
136 TYPELIB_DANGER_RELEASE( pObjTD );
138 throw IllegalArgumentException(
139 "expected struct or exception, got " + rObj.getValueType().getTypeName(),
143void IdlCompFieldImpl::set(
const Any & rObj,
const Any & rValue )
145 if (rObj.getValueTypeClass() == css::uno::TypeClass_STRUCT ||
146 rObj.getValueTypeClass() == css::uno::TypeClass_EXCEPTION)
149 TYPELIB_DANGER_GET( &pObjTD, rObj.getValueTypeRef() );
154 pTD = &
reinterpret_cast<typelib_CompoundTypeDescription *
>(pTD)->pBaseTypeDescription->aBase;
156 OSL_ENSURE( pTD,
"### illegal object type!" );
159 TYPELIB_DANGER_RELEASE( pObjTD );
160 if (!
coerce_assign(
const_cast<char *
>(
static_cast<char const *
>(rObj.getValue()) +
_nOffset), getTypeDescr(), rValue, getReflection() ))
162 throw IllegalArgumentException(
163 "cannot assign value to destination",
168 TYPELIB_DANGER_RELEASE( pObjTD );
170 throw IllegalArgumentException(
171 "expected struct or exception, got " + rObj.getValueType().getTypeName(),
176void IdlCompFieldImpl::set( Any & rObj,
const Any & rValue )
178 if (rObj.getValueTypeClass() == css::uno::TypeClass_STRUCT ||
179 rObj.getValueTypeClass() == css::uno::TypeClass_EXCEPTION)
182 TYPELIB_DANGER_GET( &pObjTD, rObj.getValueTypeRef() );
187 pTD = &
reinterpret_cast<typelib_CompoundTypeDescription *
>(pTD)->pBaseTypeDescription->aBase;
189 OSL_ENSURE( pTD,
"### illegal object type!" );
192 TYPELIB_DANGER_RELEASE( pObjTD );
193 if (!
coerce_assign(
const_cast<char *
>(
static_cast<char const *
>(rObj.getValue()) +
_nOffset), getTypeDescr(), rValue, getReflection() ))
195 throw IllegalArgumentException(
196 "cannot assign to destination",
201 TYPELIB_DANGER_RELEASE( pObjTD );
203 throw IllegalArgumentException(
204 "expected struct or exception, got " + rObj.getValueType().getTypeName(),
218 TypeClass
eTC = xType->getTypeClass();
219 if (
eTC == TypeClass_STRUCT ||
eTC == TypeClass_EXCEPTION)
225 const Sequence< Reference< XIdlClass > > & rSeq = xType->getSuperclasses();
226 if (rSeq.hasElements())
228 OSL_ENSURE( rSeq.getLength() == 1,
"### unexpected len of super classes!" );
244 typelib_CompoundTypeDescription * pCompTypeDescr =
getTypeDescr()->pBaseTypeDescription;
250 return Sequence< Reference< XIdlClass > >( &
_xSuperClass, 1 );
252 return Sequence< Reference< XIdlClass > >();
260 const OUString2Field::const_iterator iFind(
_aName2Field.find( rName ) );
262 return Reference< XIdlField >( (*iFind).second );
264 return Reference< XIdlField >();
273 typelib_CompoundTypeDescription * pCompTypeDescr =
getTypeDescr();
274 for ( ; pCompTypeDescr; pCompTypeDescr = pCompTypeDescr->pBaseTypeDescription )
275 nAll += pCompTypeDescr->nMembers;
277 Sequence< Reference< XIdlField > > aFields( nAll );
278 Reference< XIdlField > * pSeq = aFields.getArray();
281 pCompTypeDescr = pCompTypeDescr->pBaseTypeDescription )
283 typelib_TypeDescriptionReference ** ppTypeRefs = pCompTypeDescr->ppTypeRefs;
284 rtl_uString ** ppNames = pCompTypeDescr->ppMemberNames;
285 sal_Int32 * pMemberOffsets = pCompTypeDescr->pMemberOffsets;
287 for ( sal_Int32
nPos = pCompTypeDescr->nMembers;
nPos--; )
290 TYPELIB_DANGER_GET( &pTD, ppTypeRefs[
nPos] );
291 OSL_ENSURE( pTD,
"### cannot get field in struct!" );
297 TYPELIB_DANGER_RELEASE( pTD );
void SAL_CALL uno_any_construct(uno_Any *pDest, void *pSource, typelib_TypeDescription *pTypeDescr, uno_AcquireFunc acquire) SAL_THROW_EXTERN_C()
void SAL_CALL uno_any_destruct(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
virtual ~CompoundIdlClassImpl() override
typelib_CompoundTypeDescription * getTypeDescr() const
virtual css::uno::Reference< css::reflection::XIdlField > SAL_CALL getField(const OUString &rName) override
std::optional< css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > > m_xFields
OUString2Field _aName2Field
virtual sal_Bool SAL_CALL isAssignableFrom(const css::uno::Reference< css::reflection::XIdlClass > &xType) override
css::uno::Reference< css::reflection::XIdlClass > _xSuperClass
virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > SAL_CALL getFields() override
virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass > > SAL_CALL getSuperclasses() override
IdlReflectionServiceImpl * getReflection() const
typelib_TypeDescription * getTypeDescr() const
virtual sal_Bool SAL_CALL equals(const css::uno::Reference< css::reflection::XIdlClass > &xType) override
virtual OUString SAL_CALL getName() override
css::uno::Reference< css::reflection::XIdlClass > forType(typelib_TypeDescription *pTypeDescr)
struct _typelib_TypeDescription typelib_TypeDescription
void set(css::uno::UnoInterfaceReference const &value)
::osl::Mutex & getMutexAccess()
bool coerce_assign(void *pDest, typelib_TypeDescription *pTD, const css::uno::Any &rSource, IdlReflectionServiceImpl *pRefl)
bool td_equals(typelib_TypeDescription *pTD, typelib_TypeDescriptionReference *pType)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
bool getType(BSTR name, Type &type)
sal_Bool SAL_CALL typelib_typedescription_equals(const typelib_TypeDescription *p1, const typelib_TypeDescription *p2) SAL_THROW_EXTERN_C()