10#include <compbase2.hxx>
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)
53 static_cast<css::lang::XComponent*
>(
this));
54 if (aReturn.hasValue())
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";
74static 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->cppuhelper::WeakComponentImplHelperBase2::queryInterface(rType);
sal_Int32 addInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
void disposeAndClear(::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt)
sal_Int32 removeInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
OWeakObject()
Default Constructor.
Serves two purposes (1) extracts code that doesn't need to be templated (2) helps to handle the custo...
OInterfaceContainerHelper4< css::lang::XEventListener > maEventListeners
virtual void SAL_CALL addEventListener(css::uno::Reference< css::lang::XEventListener > const &rxListener) override
virtual void SAL_CALL removeEventListener(css::uno::Reference< css::lang::XEventListener > const &rxListener) override
virtual void SAL_CALL dispose() override
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) override
Basic queryInterface() implementation supporting com::sun::star::uno::XWeak and com::sun::star::uno::...
virtual void disposing(std::unique_lock< std::mutex > &)
Called by dispose for subclasses to do dispose() work.
virtual ~WeakComponentImplHelperBase2() override
#define SAL_WARN(area, stream)
struct _typelib_TypeDescription typelib_TypeDescription
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
Compares demanded type to given template argument types.
This is a straight copy of the include/comphelper/compbase.hxx file, copied here because it is nigh i...
static void * makeInterface(sal_IntPtr nOffset, void *that)
static void checkInterface(css::uno::Type const &rType)
static bool isXInterface(rtl_uString *pStr)
static void * queryDeepNoXInterface(typelib_TypeDescriptionReference const *pDemandedTDR, cppu::class_data *cd, void *that)
static bool td_equals(typelib_TypeDescriptionReference const *pTDR1, typelib_TypeDescriptionReference const *pTDR2)
static cppu::type_entry * getTypeEntries(cppu::class_data *cd)
static bool recursivelyFindType(typelib_TypeDescriptionReference const *demandedType, typelib_InterfaceTypeDescription const *type, sal_IntPtr *offset)
css::uno::Any WeakComponentImplHelper_query(css::uno::Type const &rType, cppu::class_data *cd, WeakComponentImplHelperBase2 *pBase)
WeakComponentImplHelper.