20#include <osl/diagnose.h>
25#include <com/sun/star/uno/RuntimeException.hpp>
29using namespace ::
cppu;
39 if (TypeClass_INTERFACE != rType.getTypeClass())
41 OUString msg(
"querying for interface \"" + rType.getTypeName() +
"\": no interface type!" );
49 return OUString::unacquired(&pStr) ==
"com.sun.star.uno.XInterface";
54 return (
static_cast<char *
>(that) + nOffset);
58 typelib_TypeDescriptionReference
const * pTDR1,
59 typelib_TypeDescriptionReference
const * pTDR2 )
61 return ((pTDR1 == pTDR2) ||
62 OUString::unacquired(&pTDR1->pTypeName) == OUString::unacquired(&pTDR2->pTypeName));
67 type_entry * pEntries = cd->m_typeEntries;
68 if (! cd->m_storedTypeRefs)
71 std::scoped_lock guard(
aMutex );
72 if (! cd->m_storedTypeRefs)
75 for ( sal_Int32
n = cd->m_nTypes;
n--; )
77 type_entry * pEntry = &pEntries[
n ];
78 Type const & rType = (*pEntry->m_type.getCppuType)(
nullptr );
79 OSL_ENSURE( rType.getTypeClass() == TypeClass_INTERFACE,
"### wrong helper init: expected interface!" );
80 OSL_ENSURE( !
isXInterface( rType.getTypeLibType()->pTypeName ),
"### want to implement XInterface: template argument is XInterface?!?!?!" );
81 if (rType.getTypeClass() != TypeClass_INTERFACE)
83 OUString msg(
"type \"" + rType.getTypeName() +
"\" is no interface type!" );
88 pEntry->m_type.typeRef = rType.getTypeLibType();
90 OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
91 cd->m_storedTypeRefs =
true;
96 OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
104 for ( sal_Int32
n = cd->m_nTypes;
n--; )
106 types[
n ] = pEntries[
n ].m_type.typeRef;
112bool recursivelyFindType(
113 typelib_TypeDescriptionReference
const * demandedType,
114 typelib_InterfaceTypeDescription
const * type, sal_IntPtr * offset)
122 for (sal_Int32 i = 0;
i <
type->nBaseTypes; ++
i) {
124 *offset +=
sizeof (
void *);
126 typelib_InterfaceTypeDescription
const *
base =
type->ppBaseTypes[
i];
128 if (
base->nBaseTypes > 0) {
131 typelib_TypeDescriptionReference
const *
>(base),
138 if (
type->nBaseTypes == 1) {
142 if (recursivelyFindType(demandedType, base, offset)) {
153 typelib_TypeDescriptionReference
const * pDemandedTDR, class_data * cd,
void * that )
156 sal_Int32 nTypes = cd->m_nTypes;
160 for (
n = 0;
n < nTypes; ++
n )
168 for (
n = 0;
n < nTypes; ++
n )
171 TYPELIB_DANGER_GET( &pTD, pEntries[
n ].
m_type.typeRef );
176 reinterpret_cast< typelib_InterfaceTypeDescription *
>(pTD)->
178 "### want to implement XInterface:"
179 " template argument is XInterface?!?!?!" );
180 sal_IntPtr offset = pEntries[
n].m_offset;
181 bool found = recursivelyFindType(
183 reinterpret_cast< typelib_InterfaceTypeDescription *
>(pTD),
185 TYPELIB_DANGER_RELEASE( pTD );
192 OUString msg(
"cannot get type description for type \"" + OUString::unacquired(&pEntries[
n ].
m_type.typeRef->pTypeName) +
"\"!" );
203 Type const & rType, class_data * cd,
void * that )
206 typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
223 return Any( &
p, pTDR );
227 Type const & rType, class_data * cd,
void * that )
230 typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
235 return Any( &
p, pTDR );
241 SAL_UNUSED_PARAMETER class_data *)
243 return css::uno::Sequence<sal_Int8>();
249 Sequence< Type > types( cd->m_nTypes );
250 Type * pTypes = types.getArray();
256 class_data * cd, Sequence< Type >
const & rAddTypes )
258 sal_Int32 nImplTypes = cd->m_nTypes;
259 sal_Int32 nAddTypes = rAddTypes.getLength();
260 Sequence< Type > types( nImplTypes + nAddTypes );
261 Type * pTypes = types.getArray();
264 Type const * pAddTypes = rAddTypes.getConstArray();
267 pTypes[ nImplTypes + nAddTypes ] = pAddTypes[ nAddTypes ];
275 Type const & rType, class_data * cd,
void * that,
OWeakObject * pBase )
278 typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
286 return Any( &
p, pTDR );
289 return pBase->OWeakObject::queryInterface( rType );
295 sal_Int32 nTypes = cd->m_nTypes;
296 Sequence< Type > types( nTypes +1 );
297 Type * pTypes = types.getArray();
309 typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
317 return Any( &
p, pTDR );
320 return pBase->OWeakAggObject::queryAggregation( rType );
326 sal_Int32 nTypes = cd->m_nTypes;
327 Sequence< Type > types( nTypes +2 );
328 Type * pTypes = types.getArray();
338 Type const & rType, class_data * cd,
void * that, WeakComponentImplHelperBase * pBase )
341 typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
349 return Any( &
p, pTDR );
352 return pBase->WeakComponentImplHelperBase::queryInterface( rType );
358 sal_Int32 nTypes = cd->m_nTypes;
359 Sequence< Type > types( nTypes +2 );
360 Type * pTypes = types.getArray();
370 Type const & rType, class_data * cd,
void * that, WeakAggComponentImplHelperBase * pBase )
373 typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
381 return Any( &
p, pTDR );
384 return pBase->WeakAggComponentImplHelperBase::queryAggregation( rType );
390 sal_Int32 nTypes = cd->m_nTypes;
391 Sequence< Type > types( nTypes +3 );
392 Type * pTypes = types.getArray();
Base class to implement a UNO object supporting weak references, i.e.
Base class to implement a UNO object supporting weak references, i.e.
css::uno::Type const & get()
#define SAL_WARN(area, stream)
struct _typelib_TypeDescription typelib_TypeDescription
Any SAL_CALL WeakComponentImplHelper_query(Type const &rType, class_data *cd, void *that, WeakComponentImplHelperBase *pBase)
Sequence< Type > SAL_CALL ImplInhHelper_getTypes(class_data *cd, Sequence< Type > const &rAddTypes)
Sequence< Type > SAL_CALL ImplHelper_getTypes(class_data *cd)
static bool isXInterface(rtl_uString *pStr)
static void fillTypes(Type *types, class_data *cd)
Any SAL_CALL WeakImplHelper_query(Type const &rType, class_data *cd, void *that, OWeakObject *pBase)
Sequence< Type > SAL_CALL WeakAggComponentImplHelper_getTypes(class_data *cd)
css::uno::Sequence< sal_Int8 > ImplHelper_getImplementationId(SAL_UNUSED_PARAMETER class_data *)
Any SAL_CALL WeakAggComponentImplHelper_queryAgg(Type const &rType, class_data *cd, void *that, WeakAggComponentImplHelperBase *pBase)
static type_entry * getTypeEntries(class_data *cd)
Sequence< Type > SAL_CALL WeakComponentImplHelper_getTypes(class_data *cd)
Any SAL_CALL WeakAggImplHelper_queryAgg(Type const &rType, class_data *cd, void *that, OWeakAggObject *pBase)
Sequence< Type > SAL_CALL WeakImplHelper_getTypes(class_data *cd)
static bool td_equals(typelib_TypeDescriptionReference const *pTDR1, typelib_TypeDescriptionReference const *pTDR2)
Sequence< Type > SAL_CALL WeakAggImplHelper_getTypes(class_data *cd)
static void * makeInterface(sal_IntPtr nOffset, void *that)
static void * queryDeepNoXInterface(typelib_TypeDescriptionReference const *pDemandedTDR, class_data *cd, void *that)
Any SAL_CALL ImplHelper_query(Type const &rType, class_data *cd, void *that)
static void checkInterface(Type const &rType)
Any SAL_CALL ImplHelper_queryNoXInterface(Type const &rType, class_data *cd, void *that)