22#include <osl/diagnose.h>
25#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
26#include <com/sun/star/uno/RuntimeException.hpp>
38WeakComponentImplHelperBase::WeakComponentImplHelperBase( Mutex & rMutex )
43WeakComponentImplHelperBase::~WeakComponentImplHelperBase()
47void WeakComponentImplHelperBase::disposing()
55 void *
p =
static_cast< lang::XComponent *
>( this );
56 return Any( &p, rType );
61void WeakComponentImplHelperBase::acquire()
64 OWeakObject::acquire();
67void WeakComponentImplHelperBase::release()
70 if (osl_atomic_decrement( &m_refCount ) != 0)
74 disposeWeakConnectionPoint();
76 osl_atomic_increment( &m_refCount );
77 if (! rBHelper.bDisposed) {
84 OSL_ASSERT( rBHelper.bDisposed );
86 OWeakObject::release();
89void WeakComponentImplHelperBase::dispose()
91 ClearableMutexGuard aGuard( rBHelper.rMutex );
92 if (rBHelper.bDisposed || rBHelper.bInDispose)
95 rBHelper.bInDispose =
true;
100 lang::EventObject aEvt(
static_cast< OWeakObject *
>(
this ) );
103 rBHelper.aLC.disposeAndClear( aEvt );
108 MutexGuard aGuard2( rBHelper.rMutex );
110 rBHelper.bDisposed =
true;
111 rBHelper.bInDispose =
false;
114 MutexGuard aGuard2( rBHelper.rMutex );
116 rBHelper.bDisposed =
true;
117 rBHelper.bInDispose =
false;
123 catch (Exception & exc)
126 throw lang::WrappedTargetRuntimeException(
127 "unexpected UNO exception caught: " + exc.Message,
132void WeakComponentImplHelperBase::addEventListener(
133 Reference< lang::XEventListener >
const & xListener )
135 ClearableMutexGuard aGuard( rBHelper.rMutex );
136 if (rBHelper.bDisposed || rBHelper.bInDispose)
139 lang::EventObject aEvt(
static_cast< OWeakObject *
>(
this ) );
140 xListener->disposing( aEvt );
144 rBHelper.addListener(
cppu::UnoType<
decltype(xListener)>::get(), xListener );
148void WeakComponentImplHelperBase::removeEventListener(
149 Reference< lang::XEventListener >
const & xListener )
151 rBHelper.removeListener(
cppu::UnoType<
decltype(xListener)>::get(), xListener );
156WeakAggComponentImplHelperBase::WeakAggComponentImplHelperBase( Mutex & rMutex )
161WeakAggComponentImplHelperBase::~WeakAggComponentImplHelperBase()
165void WeakAggComponentImplHelperBase::disposing()
174Any WeakAggComponentImplHelperBase::queryAggregation(
Type const & rType )
178 void *
p =
static_cast< lang::XComponent *
>( this );
179 return Any( &p, rType );
181 return OWeakAggObject::queryAggregation( rType );
184void WeakAggComponentImplHelperBase::acquire()
187 OWeakAggObject::acquire();
190void WeakAggComponentImplHelperBase::release()
193 Reference<XInterface>
const xDelegator_(xDelegator);
194 if (xDelegator_.is()) {
195 OWeakAggObject::release();
197 else if (osl_atomic_decrement( &m_refCount ) == 0) {
199 disposeWeakConnectionPoint();
201 osl_atomic_increment( &m_refCount );
202 if (! rBHelper.bDisposed) {
209 OSL_ASSERT( rBHelper.bDisposed );
211 OWeakAggObject::release();
215void WeakAggComponentImplHelperBase::dispose()
217 ClearableMutexGuard aGuard( rBHelper.rMutex );
218 if (rBHelper.bDisposed || rBHelper.bInDispose)
221 rBHelper.bInDispose =
true;
226 lang::EventObject aEvt(
static_cast< OWeakObject *
>(
this ) );
229 rBHelper.aLC.disposeAndClear( aEvt );
234 MutexGuard aGuard2( rBHelper.rMutex );
236 rBHelper.bDisposed =
true;
237 rBHelper.bInDispose =
false;
240 MutexGuard aGuard2( rBHelper.rMutex );
242 rBHelper.bDisposed =
true;
243 rBHelper.bInDispose =
false;
249 catch (Exception & exc)
252 throw lang::WrappedTargetRuntimeException(
253 "unexpected UNO exception caught: " + exc.Message,
258void WeakAggComponentImplHelperBase::addEventListener(
259 Reference< lang::XEventListener >
const & xListener )
261 ClearableMutexGuard aGuard( rBHelper.rMutex );
262 if (rBHelper.bDisposed || rBHelper.bInDispose)
265 lang::EventObject aEvt(
static_cast< OWeakObject *
>(
this ) );
266 xListener->disposing( aEvt );
270 rBHelper.addListener(
cppu::UnoType<
decltype(xListener)>::get(), xListener );
274void WeakAggComponentImplHelperBase::removeEventListener(
275 Reference< lang::XEventListener >
const & xListener )
278 MutexGuard aGuard( rBHelper.rMutex );
279 if (!rBHelper.bDisposed)
280 rBHelper.removeListener(
cppu::UnoType<
decltype(xListener)>::get(), xListener );
#define SAL_WARN(area, stream)
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
Compares demanded type to given template argument types.
Any SAL_CALL getCaughtException()
Use this function to get the dynamic type of a caught C++-UNO exception; completes the above function...