20 #include <osl/diagnose.h>
25 #include <com/sun/star/uno/RuntimeException.hpp>
27 using namespace ::
cppu;
28 using namespace ::
osl;
34 class theImplHelperInitMutex :
public rtl::Static<Mutex, theImplHelperInitMutex>{};
45 return theImplHelperInitMutex::get();
51 if (TypeClass_INTERFACE != rType.getTypeClass())
53 OUString msg(
"querying for interface \"" + rType.getTypeName() +
"\": no interface type!" );
61 return OUString::unacquired(&pStr) ==
"com.sun.star.uno.XInterface";
66 return (static_cast<char *>(that) + nOffset);
70 typelib_TypeDescriptionReference
const * pTDR1,
71 typelib_TypeDescriptionReference
const * pTDR2 )
73 return ((pTDR1 == pTDR2) ||
74 OUString::unacquired(&pTDR1->pTypeName) == OUString::unacquired(&pTDR2->pTypeName));
79 type_entry * pEntries = cd->m_typeEntries;
80 if (! cd->m_storedTypeRefs)
83 if (! cd->m_storedTypeRefs)
86 for ( sal_Int32
n = cd->m_nTypes;
n--; )
88 type_entry * pEntry = &pEntries[
n ];
89 Type const & rType = (*pEntry->m_type.getCppuType)(
nullptr );
90 OSL_ENSURE( rType.getTypeClass() == TypeClass_INTERFACE,
"### wrong helper init: expected interface!" );
91 OSL_ENSURE( !
isXInterface( rType.getTypeLibType()->pTypeName ),
"### want to implement XInterface: template argument is XInterface?!?!?!" );
92 if (rType.getTypeClass() != TypeClass_INTERFACE)
94 OUString msg(
"type \"" + rType.getTypeName() +
"\" is no interface type!" );
99 pEntry->m_type.typeRef = rType.getTypeLibType();
101 OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
102 cd->m_storedTypeRefs =
true;
107 OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
115 for ( sal_Int32
n = cd->m_nTypes;
n--; )
117 types[
n ] = pEntries[
n ].m_type.typeRef;
123 bool recursivelyFindType(
124 typelib_TypeDescriptionReference
const * demandedType,
125 typelib_InterfaceTypeDescription
const * type, sal_IntPtr * offset)
133 for (sal_Int32 i = 0;
i < type->nBaseTypes; ++
i) {
135 *offset +=
sizeof (
void *);
137 typelib_InterfaceTypeDescription
const *
base = type->ppBaseTypes[
i];
139 if (base->nBaseTypes > 0) {
142 typelib_TypeDescriptionReference
const *
>(base),
149 if (type->nBaseTypes == 1) {
153 if (recursivelyFindType(demandedType, base, offset)) {
164 typelib_TypeDescriptionReference
const * pDemandedTDR, class_data * cd,
void * that )
167 sal_Int32 nTypes = cd->m_nTypes;
171 for ( n = 0; n < nTypes; ++n )
179 for ( n = 0; n < nTypes; ++n )
182 TYPELIB_DANGER_GET( &pTD, pEntries[ n ].
m_type.typeRef );
187 reinterpret_cast< typelib_InterfaceTypeDescription * >(pTD)->
189 "### want to implement XInterface:"
190 " template argument is XInterface?!?!?!" );
191 sal_IntPtr offset = pEntries[n].m_offset;
192 bool found = recursivelyFindType(
194 reinterpret_cast< typelib_InterfaceTypeDescription * >(pTD),
196 TYPELIB_DANGER_RELEASE( pTD );
203 OUString msg(
"cannot get type description for type \"" + OUString::unacquired(&pEntries[ n ].
m_type.typeRef->pTypeName) +
"\"!" );
214 Type const & rType, class_data * cd,
void * that )
217 typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
234 return Any( &p, pTDR );
238 Type const & rType, class_data * cd,
void * that )
241 typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
246 return Any( &p, pTDR );
252 SAL_UNUSED_PARAMETER class_data *)
254 return css::uno::Sequence<sal_Int8>();
260 Sequence< Type > types( cd->m_nTypes );
261 Type * pTypes = types.getArray();
267 class_data * cd, Sequence< Type >
const & rAddTypes )
269 sal_Int32 nImplTypes = cd->m_nTypes;
270 sal_Int32 nAddTypes = rAddTypes.getLength();
271 Sequence< Type > types( nImplTypes + nAddTypes );
272 Type * pTypes = types.getArray();
275 Type const * pAddTypes = rAddTypes.getConstArray();
278 pTypes[ nImplTypes + nAddTypes ] = pAddTypes[ nAddTypes ];
286 Type const & rType, class_data * cd,
void * that,
OWeakObject * pBase )
289 typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
297 return Any( &p, pTDR );
300 return pBase->OWeakObject::queryInterface( rType );
306 sal_Int32 nTypes = cd->m_nTypes;
307 Sequence< Type > types( nTypes +1 );
308 Type * pTypes = types.getArray();
320 typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
328 return Any( &p, pTDR );
331 return pBase->OWeakAggObject::queryAggregation( rType );
337 sal_Int32 nTypes = cd->m_nTypes;
338 Sequence< Type > types( nTypes +2 );
339 Type * pTypes = types.getArray();
349 Type const & rType, class_data * cd,
void * that, WeakComponentImplHelperBase * pBase )
352 typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
360 return Any( &p, pTDR );
363 return pBase->WeakComponentImplHelperBase::queryInterface( rType );
369 sal_Int32 nTypes = cd->m_nTypes;
370 Sequence< Type > types( nTypes +2 );
371 Type * pTypes = types.getArray();
381 Type const & rType, class_data * cd,
void * that, WeakAggComponentImplHelperBase * pBase )
384 typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
392 return Any( &p, pTDR );
395 return pBase->WeakAggComponentImplHelperBase::queryAggregation( rType );
401 sal_Int32 nTypes = cd->m_nTypes;
402 Sequence< Type > types( nTypes +3 );
403 Type * pTypes = types.getArray();
static void * makeInterface(sal_IntPtr nOffset, void *that)
static bool isXInterface(rtl_uString *pStr)
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)
Any SAL_CALL WeakAggComponentImplHelper_queryAgg(Type const &rType, class_data *cd, void *that, WeakAggComponentImplHelperBase *pBase)
static bool td_equals(typelib_TypeDescriptionReference const *pTDR1, typelib_TypeDescriptionReference const *pTDR2)
Any SAL_CALL WeakImplHelper_query(Type const &rType, class_data *cd, void *that, OWeakObject *pBase)
static void * queryDeepNoXInterface(typelib_TypeDescriptionReference const *pDemandedTDR, class_data *cd, void *that)
Sequence< Type > SAL_CALL WeakImplHelper_getTypes(class_data *cd)
Sequence< Type > SAL_CALL WeakAggComponentImplHelper_getTypes(class_data *cd)
Base class to implement a UNO object supporting weak references, i.e.
Any SAL_CALL ImplHelper_queryNoXInterface(Type const &rType, class_data *cd, void *that)
css::uno::Sequence< sal_Int8 > ImplHelper_getImplementationId(SAL_UNUSED_PARAMETER class_data *)
Sequence< Type > SAL_CALL WeakComponentImplHelper_getTypes(class_data *cd)
Sequence< Type > SAL_CALL WeakAggImplHelper_getTypes(class_data *cd)
css::uno::Type const & get()
static void checkInterface(Type const &rType)
struct _typelib_TypeDescription typelib_TypeDescription
Base class to implement a UNO object supporting weak references, i.e.
static void fillTypes(Type *types, class_data *cd)
static type_entry * getTypeEntries(class_data *cd)
Any SAL_CALL WeakAggImplHelper_queryAgg(Type const &rType, class_data *cd, void *that, OWeakAggObject *pBase)
Any SAL_CALL ImplHelper_query(Type const &rType, class_data *cd, void *that)
#define SAL_WARN(area, stream)
Sequence< Type > SAL_CALL ImplHelper_getTypes(class_data *cd)
::osl::Mutex & getImplHelperInitMutex()
Shared mutex for implementation helper initialization.