21#ifndef INCLUDED_STOC_SOURCE_COREREFLECTION_BASE_HXX
22#define INCLUDED_STOC_SOURCE_COREREFLECTION_BASE_HXX
27#include <osl/mutex.hxx>
28#include <uno/mapping.hxx>
29#include <uno/dispatcher.h>
32#include <rtl/ustring.hxx>
37#ifdef TEST_LIST_CLASSES
41#include <unordered_map>
44#include <com/sun/star/lang/XServiceInfo.hpp>
45#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
47#include <com/sun/star/reflection/XIdlReflection.hpp>
57#ifdef TEST_LIST_CLASSES
58extern std::vector<OUString> g_aClassNames;
67 return (pTD->pWeakRef == pType ||
68 (pTD->pTypeName->length == pType->pTypeName->length &&
69 rtl_ustr_compare( pTD->pTypeName->buffer, pType->pTypeName->buffer ) == 0));
72typedef std::unordered_map< OUString, css::uno::WeakReference< css::reflection::XIdlField > >
OUString2Field;
73typedef std::unordered_map< OUString, css::uno::WeakReference< css::reflection::XIdlMethod > >
OUString2Method;
77 :
public ::cppu::WeakComponentImplHelper<
78 css::reflection::XIdlReflection,
79 css::container::XHierarchicalNameAccess,
80 css::lang::XServiceInfo>
83 css::uno::Reference< css::container::XHierarchicalNameAccess >
_xTDMgr;
99 uno_Interface *
mapToUno(
const css::uno::Any & rObj, typelib_InterfaceTypeDescription * pTo );
106 virtual void SAL_CALL
disposing()
override;
114 virtual css::uno::Reference< css::reflection::XIdlClass > SAL_CALL
forName(
const OUString & rTypeName )
override;
115 virtual css::uno::Reference< css::reflection::XIdlClass > SAL_CALL
getType(
const css::uno::Any & rObj )
override;
124 css::uno::Reference< css::reflection::XIdlClass >
forType( typelib_TypeDescriptionReference * pRef );
129 :
public ::cppu::WeakImplHelper< css::reflection::XIdlClass >
147 OUString
aName, typelib_TypeClass eTypeClass,
152 virtual css::uno::TypeClass SAL_CALL
getTypeClass()
override;
153 virtual OUString SAL_CALL
getName()
override;
154 virtual sal_Bool SAL_CALL
equals(
const css::uno::Reference< css::reflection::XIdlClass >& xType )
override;
156 virtual sal_Bool SAL_CALL
isAssignableFrom(
const css::uno::Reference< css::reflection::XIdlClass > & xType )
override;
157 virtual void SAL_CALL
createObject( css::uno::Any & rObj )
override;
160 virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass > > SAL_CALL
getClasses()
override;
161 virtual css::uno::Reference< css::reflection::XIdlClass > SAL_CALL
getClass(
const OUString & rName )
override;
162 virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass > > SAL_CALL
getInterfaces()
override;
165 virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass > > SAL_CALL
getSuperclasses()
override;
167 virtual css::uno::Reference< css::reflection::XIdlField > SAL_CALL
getField(
const OUString & rName )
override;
168 virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > SAL_CALL
getFields()
override;
170 virtual css::uno::Uik SAL_CALL
getUik()
override;
171 virtual css::uno::Reference< css::reflection::XIdlMethod > SAL_CALL
getMethod(
const OUString & rName )
override;
172 virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlMethod > > SAL_CALL
getMethods()
override;
174 virtual css::uno::Reference< css::reflection::XIdlClass > SAL_CALL
getComponentType()
override;
175 virtual css::uno::Reference< css::reflection::XIdlArray > SAL_CALL
getArray()
override;
182 typedef std::pair< OUString, typelib_TypeDescription * >
MemberInit;
184 css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass > >
_xSuperClasses;
200 const OUString & rName, typelib_TypeClass eTypeClass,
202 :
IdlClassImpl( pReflection, rName, eTypeClass, pTypeDescr )
209 virtual sal_Bool SAL_CALL
isAssignableFrom(
const css::uno::Reference< css::reflection::XIdlClass > & xType )
override;
210 virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass > > SAL_CALL
getSuperclasses()
override;
211 virtual css::uno::Uik SAL_CALL
getUik()
override;
212 virtual css::uno::Reference< css::reflection::XIdlMethod > SAL_CALL
getMethod(
const OUString & rName )
override;
213 virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlMethod > > SAL_CALL
getMethods()
override;
214 virtual css::uno::Reference< css::reflection::XIdlField > SAL_CALL
getField(
const OUString & rName )
override;
215 virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > SAL_CALL
getFields()
override;
216 virtual void SAL_CALL
createObject( css::uno::Any & rObj )
override;
223 css::uno::Reference< css::reflection::XIdlClass >
225 std::optional< css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > >
235 const OUString & rName, typelib_TypeClass eTypeClass,
237 :
IdlClassImpl( pReflection, rName, eTypeClass, pTypeDescr )
242 virtual sal_Bool SAL_CALL
isAssignableFrom(
const css::uno::Reference< css::reflection::XIdlClass > & xType )
override;
243 virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass > > SAL_CALL
getSuperclasses()
override;
244 virtual css::uno::Reference< css::reflection::XIdlField > SAL_CALL
getField(
const OUString & rName )
override;
245 virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > SAL_CALL
getFields()
override;
258 const OUString & rName, typelib_TypeClass eTypeClass,
264 virtual sal_Bool SAL_CALL
isAssignableFrom(
const css::uno::Reference< css::reflection::XIdlClass > & xType )
override;
265 virtual css::uno::Reference< css::reflection::XIdlClass > SAL_CALL
getComponentType()
override;
266 virtual css::uno::Reference< css::reflection::XIdlArray > SAL_CALL
getArray()
override;
269 virtual void SAL_CALL
realloc( css::uno::Any & rArray, sal_Int32 nLen )
override;
270 virtual sal_Int32 SAL_CALL
getLen(
const css::uno::Any & rArray )
override;
271 virtual css::uno::Any SAL_CALL
get(
const css::uno::Any & rArray, sal_Int32
nIndex )
override;
272 virtual void SAL_CALL
set( css::uno::Any & rArray, sal_Int32
nIndex,
const css::uno::Any & rNewValue )
override;
279 std::optional< css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > >
m_xFields;
288 const OUString & rName, typelib_TypeClass eTypeClass,
290 :
IdlClassImpl( pReflection, rName, eTypeClass, pTypeDescr )
295 virtual css::uno::Reference< css::reflection::XIdlField > SAL_CALL
getField(
const OUString & rName )
override;
296 virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > SAL_CALL
getFields()
override;
297 virtual void SAL_CALL
createObject( css::uno::Any & rObj )
override;
302 :
public ::cppu::WeakImplHelper< css::reflection::XIdlMember >
328 virtual css::uno::Reference< css::reflection::XIdlClass > SAL_CALL
getDeclaringClass()
override;
329 virtual OUString SAL_CALL
getName()
override;
336 const css::uno::Any & rObj, typelib_InterfaceTypeDescription * pTo,
337 css::uno::Reference< css::uno::XInterface > & rDest,
343 if (! rObj.hasValue())
345 if (rObj.getValueTypeClass() == css::uno::TypeClass_INTERFACE)
347 return ::uno_type_assignData(
348 &rDest, pTo->aBase.pWeakRef,
349 const_cast< void *
>( rObj.getValue() ), rObj.getValueTypeRef(),
350 reinterpret_cast< uno_QueryInterfaceFunc
>(css::uno::cpp_queryInterface),
351 reinterpret_cast< uno_AcquireFunc
>(css::uno::cpp_acquire),
352 reinterpret_cast< uno_ReleaseFunc
>(css::uno::cpp_release) );
354 else if (
auto t = o3tl::tryAccess<css::uno::Type>(rObj))
356 rDest = pRefl->
forType(
t->getTypeLibType() );
367 if (pTD->eTypeClass == typelib_TypeClass_INTERFACE)
369 css::uno::Reference< css::uno::XInterface > xVal;
370 if (
extract( rSource,
reinterpret_cast<typelib_InterfaceTypeDescription *
>(pTD), xVal, pRefl ))
372 if (*
static_cast<css::uno::XInterface **
>(pDest))
373 (*
static_cast<css::uno::XInterface **
>(pDest))->release();
374 *
static_cast<css::uno::XInterface **
>(pDest) = xVal.get();
375 if (*
static_cast<css::uno::XInterface **
>(pDest))
376 (*
static_cast<css::uno::XInterface **
>(pDest))->acquire();
381 else if (pTD->eTypeClass == typelib_TypeClass_ANY)
385 const_cast<css::uno::Any *
>(&rSource), pTD,
386 reinterpret_cast< uno_QueryInterfaceFunc
>(css::uno::cpp_queryInterface),
387 reinterpret_cast< uno_AcquireFunc
>(css::uno::cpp_acquire),
388 reinterpret_cast< uno_ReleaseFunc
>(css::uno::cpp_release) );
393 pDest, pTD->pWeakRef,
394 const_cast<void *
>(rSource.getValue()), rSource.getValueTypeRef(),
395 reinterpret_cast< uno_QueryInterfaceFunc
>(css::uno::cpp_queryInterface),
396 reinterpret_cast< uno_AcquireFunc
>(css::uno::cpp_acquire),
397 reinterpret_cast< uno_ReleaseFunc
>(css::uno::cpp_release) );
virtual css::uno::Any SAL_CALL get(const css::uno::Any &rArray, sal_Int32 nIndex) override
virtual void SAL_CALL set(css::uno::Any &rArray, sal_Int32 nIndex, const css::uno::Any &rNewValue) override
typelib_IndirectTypeDescription * getTypeDescr() const
virtual sal_Int32 SAL_CALL getLen(const css::uno::Any &rArray) override
virtual void SAL_CALL realloc(css::uno::Any &rArray, sal_Int32 nLen) override
virtual sal_Bool SAL_CALL isAssignableFrom(const css::uno::Reference< css::reflection::XIdlClass > &xType) override
virtual css::uno::Reference< css::reflection::XIdlClass > SAL_CALL getComponentType() override
ArrayIdlClassImpl(IdlReflectionServiceImpl *pReflection, const OUString &rName, typelib_TypeClass eTypeClass, typelib_TypeDescription *pTypeDescr)
virtual css::uno::Reference< css::reflection::XIdlArray > SAL_CALL getArray() override
virtual ~CompoundIdlClassImpl() override
typelib_CompoundTypeDescription * getTypeDescr() const
CompoundIdlClassImpl(IdlReflectionServiceImpl *pReflection, const OUString &rName, typelib_TypeClass eTypeClass, typelib_TypeDescription *pTypeDescr)
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
OUString2Field _aName2Field
virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > SAL_CALL getFields() override
EnumIdlClassImpl(IdlReflectionServiceImpl *pReflection, const OUString &rName, typelib_TypeClass eTypeClass, typelib_TypeDescription *pTypeDescr)
typelib_EnumTypeDescription * 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
virtual void SAL_CALL createObject(css::uno::Any &rObj) override
virtual ~EnumIdlClassImpl() override
virtual sal_Bool SAL_CALL isAssignableFrom(const css::uno::Reference< css::reflection::XIdlClass > &xType) override
virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > SAL_CALL getFields() override
IdlReflectionServiceImpl * getReflection() const
css::uno::TypeClass _eTypeClass
virtual css::uno::Reference< css::reflection::XIdlArray > SAL_CALL getArray() override
virtual css::uno::Reference< css::reflection::XIdlMethod > SAL_CALL getMethod(const OUString &rName) override
virtual css::uno::Reference< css::reflection::XIdlClass > SAL_CALL getComponentType() override
virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass > > SAL_CALL getInterfaces() override
rtl::Reference< IdlReflectionServiceImpl > m_xReflection
virtual void SAL_CALL createObject(css::uno::Any &rObj) override
virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlMethod > > SAL_CALL getMethods() override
virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass > > SAL_CALL getClasses() override
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
virtual ~IdlClassImpl() override
virtual css::uno::Reference< css::reflection::XIdlField > SAL_CALL getField(const OUString &rName) override
virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass > > SAL_CALL getSuperclasses() override
typelib_TypeDescription * _pTypeDescr
virtual css::uno::TypeClass SAL_CALL getTypeClass() override
IdlClassImpl(IdlReflectionServiceImpl *pReflection, OUString aName, typelib_TypeClass eTypeClass, typelib_TypeDescription *pTypeDescr)
virtual css::uno::Reference< css::reflection::XIdlClass > SAL_CALL getClass(const OUString &rName) override
virtual css::uno::Uik SAL_CALL getUik() override
virtual css::uno::Reference< css::reflection::XIdlClass > SAL_CALL getDeclaringClass() override
virtual ~IdlMemberImpl() override
css::uno::Reference< css::reflection::XIdlClass > _xDeclClass
IdlMemberImpl(IdlReflectionServiceImpl *pReflection, OUString aName, typelib_TypeDescription *pTypeDescr, typelib_TypeDescription *pDeclTypeDescr)
rtl::Reference< IdlReflectionServiceImpl > m_xReflection
virtual OUString SAL_CALL getName() override
typelib_TypeDescription * _pDeclTypeDescr
typelib_TypeDescription * _pTypeDescr
IdlReflectionServiceImpl * getReflection() const
typelib_TypeDescription * getTypeDescr() const
typelib_TypeDescription * getDeclTypeDescr() const
LRU_CacheAnyByOUString _aElements
virtual sal_Bool SAL_CALL hasByHierarchicalName(const OUString &rName) override
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
virtual ~IdlReflectionServiceImpl() override
uno_Interface * mapToUno(const css::uno::Any &rObj, typelib_InterfaceTypeDescription *pTo)
virtual css::uno::Any SAL_CALL getByHierarchicalName(const OUString &rName) override
virtual css::uno::Reference< css::reflection::XIdlClass > SAL_CALL getType(const css::uno::Any &rObj) override
css::uno::Mapping _aUno2Cpp
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
IdlReflectionServiceImpl(const css::uno::Reference< css::uno::XComponentContext > &xContext)
virtual css::uno::Reference< css::reflection::XIdlClass > SAL_CALL forName(const OUString &rTypeName) override
css::uno::Reference< css::reflection::XIdlClass > constructClass(typelib_TypeDescription *pTypeDescr)
const css::uno::Mapping & getCpp2Uno()
css::uno::Reference< css::reflection::XIdlClass > forType(typelib_TypeDescription *pTypeDescr)
css::uno::Reference< css::container::XHierarchicalNameAccess > _xTDMgr
virtual OUString SAL_CALL getImplementationName() override
const css::uno::Mapping & getUno2Cpp()
::osl::Mutex _aComponentMutex
css::uno::Mapping _aCpp2Uno
virtual void SAL_CALL disposing() override
virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlMethod > > SAL_CALL getMethods() override
std::unique_ptr< MemberInit[]> _pSortedMemberInit
typelib_InterfaceTypeDescription * getTypeDescr() const
OUString2Method _aName2Method
css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass > > _xSuperClasses
virtual css::uno::Reference< css::reflection::XIdlMethod > SAL_CALL getMethod(const OUString &rName) override
std::pair< OUString, typelib_TypeDescription * > MemberInit
virtual sal_Bool SAL_CALL isAssignableFrom(const css::uno::Reference< css::reflection::XIdlClass > &xType) override
virtual void SAL_CALL createObject(css::uno::Any &rObj) override
InterfaceIdlClassImpl(IdlReflectionServiceImpl *pReflection, const OUString &rName, typelib_TypeClass eTypeClass, typelib_TypeDescription *pTypeDescr)
virtual css::uno::Reference< css::reflection::XIdlField > SAL_CALL getField(const OUString &rName) override
virtual ~InterfaceIdlClassImpl() override
virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > SAL_CALL getFields() override
virtual css::uno::Uik SAL_CALL getUik() override
OUString2Field _aName2Field
virtual css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass > > SAL_CALL getSuperclasses() override
sal_Bool SAL_CALL uno_assignData(void *pDest, typelib_TypeDescription *pDestTD, void *pSource, typelib_TypeDescription *pSourceTD, uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
sal_Bool SAL_CALL uno_type_assignData(void *pDest, typelib_TypeDescriptionReference *pDestType, void *pSource, typelib_TypeDescriptionReference *pSourceType, uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
struct _typelib_TypeDescription typelib_TypeDescription
std::unordered_map< OUString, css::uno::WeakReference< css::reflection::XIdlField > > OUString2Field
cppu::ImplInheritanceHelper< IdlClassImpl, css::reflection::XIdlArray > ArrayIdlClassImpl_Base
::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)
bool extract(const css::uno::Any &rObj, typelib_InterfaceTypeDescription *pTo, css::uno::Reference< css::uno::XInterface > &rDest, IdlReflectionServiceImpl *pRefl)
std::unordered_map< OUString, css::uno::WeakReference< css::reflection::XIdlMethod > > OUString2Method