12 #include <osl/diagnose.h>
26 if (!aGuard.owns_lock())
28 css::lang::EventObject aEvt(static_cast<OWeakObject*>(
this));
35 css::uno::Reference<css::lang::XEventListener>
const& rxListener)
44 css::uno::Reference<css::lang::XEventListener>
const& rxListener)
52 css::uno::Any aReturn = ::cppu::queryInterface(rType, static_cast<css::uno::XWeak*>(
this),
53 static_cast<css::lang::XComponent*>(
this));
54 if (aReturn.hasValue())
56 return OWeakObject::queryInterface(rType);
61 if (css::uno::TypeClass_INTERFACE != rType.getTypeClass())
63 OUString msg(
"querying for interface \"" + rType.getTypeName() +
"\": no interface type!");
65 throw css::uno::RuntimeException(msg);
71 return OUString::unacquired(&pStr) ==
"com.sun.star.uno.XInterface";
74 static bool td_equals(typelib_TypeDescriptionReference
const* pTDR1,
75 typelib_TypeDescriptionReference
const* pTDR2)
77 return ((pTDR1 == pTDR2)
78 || OUString::unacquired(&pTDR1->pTypeName) == OUString::unacquired(&pTDR2->pTypeName));
83 cppu::type_entry* pEntries = cd->m_typeEntries;
84 if (!cd->m_storedTypeRefs)
87 std::scoped_lock guard(aMutex);
88 if (!cd->m_storedTypeRefs)
91 for (sal_Int32
n = cd->m_nTypes;
n--;)
93 cppu::type_entry* pEntry = &pEntries[
n];
94 css::uno::Type
const& rType = (*pEntry->m_type.getCppuType)(
nullptr);
95 OSL_ENSURE(rType.getTypeClass() == css::uno::TypeClass_INTERFACE,
96 "### wrong helper init: expected interface!");
99 "### want to implement XInterface: template argument is XInterface?!?!?!");
100 if (rType.getTypeClass() != css::uno::TypeClass_INTERFACE)
102 OUString msg(
"type \"" + rType.getTypeName() +
"\" is no interface type!");
104 throw css::uno::RuntimeException(msg);
107 pEntry->m_type.typeRef = rType.getTypeLibType();
109 OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
110 cd->m_storedTypeRefs =
true;
115 OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
122 return (static_cast<char*>(that) + nOffset);
126 typelib_InterfaceTypeDescription
const* type, sal_IntPtr* offset)
134 for (sal_Int32
i = 0;
i < type->nBaseTypes; ++
i)
138 *offset +=
sizeof(
void*);
140 typelib_InterfaceTypeDescription
const*
base = type->ppBaseTypes[
i];
142 if (base->nBaseTypes > 0)
144 if (
td_equals(reinterpret_cast<typelib_TypeDescriptionReference const*>(base),
151 if (type->nBaseTypes == 1)
166 cppu::class_data* cd,
void* that)
169 sal_Int32 nTypes = cd->m_nTypes;
173 for (n = 0; n < nTypes; ++n)
181 for (n = 0; n < nTypes; ++n)
184 TYPELIB_DANGER_GET(&pTD, pEntries[n].
m_type.typeRef);
188 OSL_ENSURE(reinterpret_cast<typelib_InterfaceTypeDescription*>(pTD)->nBaseTypes > 0,
189 "### want to implement XInterface:"
190 " template argument is XInterface?!?!?!");
191 sal_IntPtr offset = pEntries[n].m_offset;
193 pDemandedTDR, reinterpret_cast<typelib_InterfaceTypeDescription*>(pTD), &offset);
194 TYPELIB_DANGER_RELEASE(pTD);
202 OUString msg(
"cannot get type description for type \""
203 + OUString::unacquired(&pEntries[n].
m_type.typeRef->pTypeName) +
"\"!");
205 throw css::uno::RuntimeException(msg);
215 typelib_TypeDescriptionReference* pTDR = rType.getTypeLibType();
223 return css::uno::Any(&p, pTDR);
226 return pBase->comphelper::WeakComponentImplHelperBase::queryInterface(rType);
void disposeAndClear(::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt)
Call disposing on all object in the container that support XEventListener.
Serves two purposes (1) extracts code that doesn't need to be templated (2) helps to handle the custo...
static bool recursivelyFindType(typelib_TypeDescriptionReference const *demandedType, typelib_InterfaceTypeDescription const *type, sal_IntPtr *offset)
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) override
virtual void SAL_CALL removeEventListener(css::uno::Reference< css::lang::XEventListener > const &rxListener) override
sal_Int32 addInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
Inserts an element into the container.
static cppu::type_entry * getTypeEntries(cppu::class_data *cd)
static void checkInterface(css::uno::Type const &rType)
virtual ~WeakComponentImplHelperBase() override
virtual void SAL_CALL addEventListener(css::uno::Reference< css::lang::XEventListener > const &rxListener) override
virtual void disposing(std::unique_lock< std::mutex > &)
Called by dispose for subclasses to do dispose() work.
virtual void SAL_CALL dispose() override
struct _typelib_TypeDescription typelib_TypeDescription
static bool isXInterface(rtl_uString *pStr)
sal_Int32 removeInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
Removes an element from the container.
static bool td_equals(typelib_TypeDescriptionReference const *pTDR1, typelib_TypeDescriptionReference const *pTDR2)
static void * queryDeepNoXInterface(typelib_TypeDescriptionReference const *pDemandedTDR, cppu::class_data *cd, void *that)
#define SAL_WARN(area, stream)
static void * makeInterface(sal_IntPtr nOffset, void *that)
comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > maEventListeners
css::uno::Any WeakComponentImplHelper_query(css::uno::Type const &rType, cppu::class_data *cd, WeakComponentImplHelperBase *pBase)
WeakComponentImplHelper.