xref: /AOO41X/main/comphelper/inc/comphelper/accessiblecontexthelper.hxx (revision 9877b273795ec465a3ce9c15d738eb34c0455705)
1*9877b273SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9877b273SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9877b273SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9877b273SAndrew Rist  * distributed with this work for additional information
6*9877b273SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9877b273SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9877b273SAndrew Rist  * "License"); you may not use this file except in compliance
9*9877b273SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*9877b273SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*9877b273SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9877b273SAndrew Rist  * software distributed under the License is distributed on an
15*9877b273SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9877b273SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9877b273SAndrew Rist  * specific language governing permissions and limitations
18*9877b273SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*9877b273SAndrew Rist  *************************************************************/
21*9877b273SAndrew Rist 
22*9877b273SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef COMPHELPER_ACCESSIBLE_CONTEXT_HELPER_HXX
25cdf0e10cSrcweir #define COMPHELPER_ACCESSIBLE_CONTEXT_HELPER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx>
28cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleContext.hpp>
29cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
30cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
31cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
32cdf0e10cSrcweir #include "comphelper/comphelperdllapi.h"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir //.........................................................................
35cdf0e10cSrcweir namespace comphelper
36cdf0e10cSrcweir {
37cdf0e10cSrcweir //.........................................................................
38cdf0e10cSrcweir 
39cdf0e10cSrcweir     class AccessibleEventBuffer;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 	//=====================================================================
42cdf0e10cSrcweir 	//= IMutex
43cdf0e10cSrcweir 	//=====================================================================
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 	// This whole thingie here (own mutex classes and such) is a HACK. I hate the SolarMutex.
46cdf0e10cSrcweir 	// See below for more explanations ....
47cdf0e10cSrcweir 
48cdf0e10cSrcweir 	/** abstract interface for implementing a mutex
49cdf0e10cSrcweir 	*/
50cdf0e10cSrcweir 	class IMutex
51cdf0e10cSrcweir 	{
52cdf0e10cSrcweir 	public:
53cdf0e10cSrcweir 		virtual void acquire() = 0;
54cdf0e10cSrcweir 		virtual void release() = 0;
55cdf0e10cSrcweir 	};
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 	//=====================================================================
58cdf0e10cSrcweir 	//= OMutexGuard
59cdf0e10cSrcweir 	//=====================================================================
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 	class OMutexGuard
62cdf0e10cSrcweir 	{
63cdf0e10cSrcweir 		IMutex*	m_pMutex;
64cdf0e10cSrcweir 	public:
OMutexGuard(IMutex * _pMutex)65cdf0e10cSrcweir 		inline OMutexGuard( IMutex* _pMutex )
66cdf0e10cSrcweir 			:m_pMutex( _pMutex )
67cdf0e10cSrcweir 		{
68cdf0e10cSrcweir 			if ( m_pMutex )
69cdf0e10cSrcweir 				m_pMutex->acquire();
70cdf0e10cSrcweir 		}
71cdf0e10cSrcweir 
~OMutexGuard()72cdf0e10cSrcweir 		inline ~OMutexGuard( )
73cdf0e10cSrcweir 		{
74cdf0e10cSrcweir 			if ( m_pMutex )
75cdf0e10cSrcweir 				m_pMutex->release();
76cdf0e10cSrcweir 		}
77cdf0e10cSrcweir 	};
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	//=====================================================================
80cdf0e10cSrcweir 	//= OAccessibleContextHelper
81cdf0e10cSrcweir 	//=====================================================================
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	class OContextHelper_Impl;
84cdf0e10cSrcweir 	typedef	::cppu::WeakAggComponentImplHelper2	<	::com::sun::star::accessibility::XAccessibleContext,
85cdf0e10cSrcweir 													::com::sun::star::accessibility::XAccessibleEventBroadcaster
86cdf0e10cSrcweir 												>	OAccessibleContextHelper_Base;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	/** helper class for implementing an AccessibleContext
89cdf0e10cSrcweir 	*/
90cdf0e10cSrcweir 	class COMPHELPER_DLLPUBLIC OAccessibleContextHelper
91cdf0e10cSrcweir 				:public ::comphelper::OBaseMutex
92cdf0e10cSrcweir 				,public OAccessibleContextHelper_Base
93cdf0e10cSrcweir 	{
94cdf0e10cSrcweir 	private:
95cdf0e10cSrcweir 		OContextHelper_Impl*	m_pImpl;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	protected:
98cdf0e10cSrcweir 		OAccessibleContextHelper( );
99cdf0e10cSrcweir 		~OAccessibleContextHelper( );
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 		/** ctor
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 			<p>If you need additional object safety for your class, and want to ensure that your own
104cdf0e10cSrcweir 			mutex is locked before the mutex this class provides is, than use this ctor.</p>
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 			<p>Beware that this is a hack. Unfortunately, OpenOffice.org has two different mutex hierarchies,
107cdf0e10cSrcweir 			which are not compatible. In addition, wide parts of the code (especially VCL) is not thread-safe,
108cdf0e10cSrcweir 			but instead relies on a <em>single global mutex</em>. As a consequence, components using
109cdf0e10cSrcweir 			directly or indirectly such code need to care for this global mutex. Yes, this is as ugly as
110cdf0e10cSrcweir 			anything.</p>
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 			<p>Note that the external lock is used as additional lock, not as the only one. The own mutex of the
113cdf0e10cSrcweir 			instance is used for internal actions, and every action which potentially involves external code
114cdf0e10cSrcweir 			(for instance every call to a virtual method overridden by derivees) is <em>additionally</em> and
115cdf0e10cSrcweir 			<em>first</em> guarded by with the external lock.</p>
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 			<p>Beware of the lifetime of the lock - you must ensure that the lock exists at least as long as
118cdf0e10cSrcweir 			the context does. A good approach to implement the lock may be to derive you own context
119cdf0e10cSrcweir 			not only from OAccessibleContextHelper, but also from IMutex.</p>
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 			<p>One more note. This lock is definately not used once the dtor is reached. Means whatever
122cdf0e10cSrcweir 			the dtor implementation does, it does <em>not</em> guard the external lock. See this as a contract.
123cdf0e10cSrcweir 			<br/>You should ensure the same thing for own derivees which do not supply the lock themself,
124cdf0e10cSrcweir 			but get them from yet another derivee.</p>
125cdf0e10cSrcweir 			@see forgetExternalLock
126cdf0e10cSrcweir 		*/
127cdf0e10cSrcweir 		OAccessibleContextHelper( IMutex* _pExternalLock );
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 		/** late construction
130cdf0e10cSrcweir 		@param _rxAccessible
131cdf0e10cSrcweir 			the Accessible object which created this context.
132cdf0e10cSrcweir 			<p>If your derived implementation implements the XAccessible (and does not follow the proposed
133cdf0e10cSrcweir 			separation of XAccessible from XAccessibleContext), you may pass <code>this</code> here.</p>
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 			<p>The object is hold weak, so it's life time is not affected.</p>
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 			<p>The object is needed for performance reasons: for <method>getAccessibleIndexInParent</method>,
138cdf0e10cSrcweir 			all children (which are XAccessible's theirself) of our parent have to be asked. If we know our
139cdf0e10cSrcweir 			XAccessible, we can compare it with all the children, instead of asking all children for their
140cdf0e10cSrcweir 			context and comparing this context with ourself.</p>
141cdf0e10cSrcweir 		*/
142cdf0e10cSrcweir 		void	lateInit( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxAccessible );
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 		/** retrieves the creator previously set with <method>lateInit</method>
145cdf0e10cSrcweir 		*/
146cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
147cdf0e10cSrcweir 				getAccessibleCreator( ) const;
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 		/** forgets the reference to the external lock, if present.
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 			<p>This means any further locking will not be guard the external lock anymore, never.</p>
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 			<p>To be used in derived classes which do not supply the external lock themself, but instead get
154cdf0e10cSrcweir 			them passed from own derivees (or clients).</p>
155cdf0e10cSrcweir 		*/
156cdf0e10cSrcweir 		void	forgetExternalLock();
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 	public:
159cdf0e10cSrcweir 		// XAccessibleEventBroadcaster
160cdf0e10cSrcweir         using WeakAggComponentImplHelperBase::addEventListener;
161cdf0e10cSrcweir 		virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
162cdf0e10cSrcweir         using WeakAggComponentImplHelperBase::removeEventListener;
163cdf0e10cSrcweir 		virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 		// XAccessibleContext - still waiting to be overwritten
166cdf0e10cSrcweir 		virtual sal_Int32 SAL_CALL getAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException) = 0;
167cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) = 0;
168cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent(  ) throw (::com::sun::star::uno::RuntimeException) = 0;
169cdf0e10cSrcweir 		virtual sal_Int16 SAL_CALL getAccessibleRole(  ) throw (::com::sun::star::uno::RuntimeException) = 0;
170cdf0e10cSrcweir 		virtual ::rtl::OUString SAL_CALL getAccessibleDescription(  ) throw (::com::sun::star::uno::RuntimeException) = 0;
171cdf0e10cSrcweir 		virtual ::rtl::OUString SAL_CALL getAccessibleName(  ) throw (::com::sun::star::uno::RuntimeException) = 0;
172cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) throw (::com::sun::star::uno::RuntimeException) = 0;
173cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet(  ) throw (::com::sun::star::uno::RuntimeException) = 0;
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 		// XAccessibleContext - default implementations
176cdf0e10cSrcweir 		/** default implementation for retrieving the index of this object within the parent
177cdf0e10cSrcweir 			<p>This basic implementation here returns the index <code>i</code> of the child for which
178cdf0e10cSrcweir 				<code>&lt;parent&gt;.getAccessibleChild( i )</code> equals our creator.</p>
179cdf0e10cSrcweir 		*/
180cdf0e10cSrcweir 		virtual sal_Int32 SAL_CALL getAccessibleIndexInParent(  ) throw (::com::sun::star::uno::RuntimeException);
181cdf0e10cSrcweir 		/** default implementation for retrieving the locale
182cdf0e10cSrcweir 			<p>This basic implementation returns the locale of the parent context,
183cdf0e10cSrcweir 			as retrieved via getAccessibleParent()->getAccessibleContext.</p>
184cdf0e10cSrcweir 		*/
185cdf0e10cSrcweir 		virtual ::com::sun::star::lang::Locale SAL_CALL getLocale(  ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 	public:
188cdf0e10cSrcweir 		// helper struct for granting selective access rights
189cdf0e10cSrcweir 		struct OAccessControl
190cdf0e10cSrcweir 		{
191cdf0e10cSrcweir 			friend class OContextEntryGuard;
192cdf0e10cSrcweir 			friend class OContextHelper_Impl;
193cdf0e10cSrcweir 			friend class OExternalLockGuard;
194cdf0e10cSrcweir 		private:
OAccessControlcomphelper::OAccessibleContextHelper::OAccessControl195cdf0e10cSrcweir 			OAccessControl() { }
196cdf0e10cSrcweir 		};
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 		// ensures that the object is alive
199cdf0e10cSrcweir 		inline	void			ensureAlive( const OAccessControl& ) const SAL_THROW( ( ::com::sun::star::lang::DisposedException ) );
200cdf0e10cSrcweir 		inline	IMutex*			getExternalLock( const OAccessControl& );
201cdf0e10cSrcweir 		inline	::osl::Mutex&	GetMutex( const OAccessControl& );
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 	protected:
204cdf0e10cSrcweir 		// OComponentHelper
205cdf0e10cSrcweir 		virtual void SAL_CALL disposing();
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 	protected:
208cdf0e10cSrcweir 		// helper
209cdf0e10cSrcweir 		/** notifies all AccessibleEventListeners of a certain event
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 		@precond	not too be called with our mutex locked
212cdf0e10cSrcweir 		@param	_nEventId
213cdf0e10cSrcweir 			the id of the even. See AccessibleEventType
214cdf0e10cSrcweir 		@param	_rOldValue
215cdf0e10cSrcweir 			the old value to be notified
216cdf0e10cSrcweir 		@param	_rNewValue
217cdf0e10cSrcweir 			the new value to be notified
218cdf0e10cSrcweir 		*/
219cdf0e10cSrcweir 		virtual void SAL_CALL	NotifyAccessibleEvent(
220cdf0e10cSrcweir 					const sal_Int16 _nEventId,
221cdf0e10cSrcweir 					const ::com::sun::star::uno::Any& _rOldValue,
222cdf0e10cSrcweir 					const ::com::sun::star::uno::Any& _rNewValue
223cdf0e10cSrcweir 				);
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 		/** records a certain event so that all AccessibleEventListeners can
226cdf0e10cSrcweir             be notified later on.
227cdf0e10cSrcweir 
228cdf0e10cSrcweir             Can even be called with our mutex locked.
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 		@param	_nEventId
231cdf0e10cSrcweir 			the id of the even. See AccessibleEventType
232cdf0e10cSrcweir 		@param	_rOldValue
233cdf0e10cSrcweir 			the old value to be notified
234cdf0e10cSrcweir 		@param	_rNewValue
235cdf0e10cSrcweir 			the new value to be notified
236cdf0e10cSrcweir         @param  _rBuffer
237cdf0e10cSrcweir             the buffer that records the event
238cdf0e10cSrcweir 		*/
239cdf0e10cSrcweir 		virtual void SAL_CALL	BufferAccessibleEvent(
240cdf0e10cSrcweir 					const sal_Int16 _nEventId,
241cdf0e10cSrcweir 					const ::com::sun::star::uno::Any& _rOldValue,
242cdf0e10cSrcweir 					const ::com::sun::star::uno::Any& _rNewValue,
243cdf0e10cSrcweir                     AccessibleEventBuffer & _rBuffer
244cdf0e10cSrcweir 				);
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 		// life time control
247cdf0e10cSrcweir 		/// checks whether the object is alive (returns <TRUE/> then) or disposed
248cdf0e10cSrcweir 		sal_Bool	isAlive() const;
249cdf0e10cSrcweir 		/// checks for beeing alive. If the object is already disposed (i.e. not alive), an exception is thrown.
250cdf0e10cSrcweir 		void		ensureAlive() const SAL_THROW( ( ::com::sun::star::lang::DisposedException ) );
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 		/** ensures that the object is disposed.
253cdf0e10cSrcweir 		@precond
254cdf0e10cSrcweir 			to be called from within the destructor of your derived class only!
255cdf0e10cSrcweir 		*/
256cdf0e10cSrcweir 		void		ensureDisposed( );
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 		/** shortcut for retrieving the context of the parent (returned by getAccessibleParent)
259cdf0e10cSrcweir 		*/
260cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
261cdf0e10cSrcweir 					implGetParentContext() SAL_THROW( ( ::com::sun::star::uno::RuntimeException ) );
262cdf0e10cSrcweir 
263cdf0e10cSrcweir 		// access to the base class' broadcast helper/mutex
GetBroadcastHelper()264cdf0e10cSrcweir 		::cppu::OBroadcastHelper&		GetBroadcastHelper()		{ return rBHelper; }
GetBroadcastHelper() const265cdf0e10cSrcweir 		const ::cppu::OBroadcastHelper&	GetBroadcastHelper() const	{ return rBHelper; }
GetMutex()266cdf0e10cSrcweir 		::osl::Mutex&					GetMutex()					{ return m_aMutex; }
267cdf0e10cSrcweir 		IMutex*							getExternalLock( );
268cdf0e10cSrcweir 	};
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 	//---------------------------------------------------------------------
ensureAlive(const OAccessControl &) const271cdf0e10cSrcweir 	inline	void OAccessibleContextHelper::ensureAlive( const OAccessControl& ) const SAL_THROW( ( ::com::sun::star::lang::DisposedException ) )
272cdf0e10cSrcweir 	{
273cdf0e10cSrcweir 		ensureAlive();
274cdf0e10cSrcweir 	}
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 	//---------------------------------------------------------------------
getExternalLock(const OAccessControl &)277cdf0e10cSrcweir 	inline	IMutex* OAccessibleContextHelper::getExternalLock( const OAccessControl& )
278cdf0e10cSrcweir 	{
279cdf0e10cSrcweir 		return getExternalLock();
280cdf0e10cSrcweir 	}
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 	//---------------------------------------------------------------------
GetMutex(const OAccessControl &)283cdf0e10cSrcweir 	inline	::osl::Mutex& OAccessibleContextHelper::GetMutex( const OAccessControl& )
284cdf0e10cSrcweir 	{
285cdf0e10cSrcweir 		return GetMutex();
286cdf0e10cSrcweir 	}
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 	//=====================================================================
289cdf0e10cSrcweir 	//= OContextEntryGuard
290cdf0e10cSrcweir 	//=====================================================================
291cdf0e10cSrcweir 	typedef ::osl::ClearableMutexGuard	OContextEntryGuard_Base;
292cdf0e10cSrcweir 	/** helper class for guarding the entry into OAccessibleContextHelper methods.
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 		<p>The class has two responsibilities:
295cdf0e10cSrcweir 		<ul><li>it locks the mutex of an OAccessibleContextHelper instance, as long as the guard lives</li>
296cdf0e10cSrcweir 			<li>it checks if an given OAccessibleContextHelper instance is alive, else an exception is thrown
297cdf0e10cSrcweir 				our of the constructor of the guard</li>
298cdf0e10cSrcweir 		</ul>
299cdf0e10cSrcweir 		<br/>
300cdf0e10cSrcweir 		This makes it your first choice (hopefully :) for guarding any interface method implementations of
301cdf0e10cSrcweir 		you derived class.
302cdf0e10cSrcweir 		</p>
303cdf0e10cSrcweir 	*/
304cdf0e10cSrcweir 	class OContextEntryGuard : public OContextEntryGuard_Base
305cdf0e10cSrcweir 	{
306cdf0e10cSrcweir 	public:
307cdf0e10cSrcweir 		/** constructs the guard
308cdf0e10cSrcweir 
309cdf0e10cSrcweir 			<p>The given context (it's mutex, respectively) is locked, and an exception is thrown if the context
310cdf0e10cSrcweir 			is not alive anymore. In the latter case, of course, the mutex is freed, again.</p>
311cdf0e10cSrcweir 
312cdf0e10cSrcweir 		@param _pContext
313cdf0e10cSrcweir 			the context which shall be guarded
314cdf0e10cSrcweir 		@precond <arg>_pContext</arg> != NULL
315cdf0e10cSrcweir 		*/
316cdf0e10cSrcweir 		inline OContextEntryGuard( OAccessibleContextHelper* _pContext );
317cdf0e10cSrcweir 
318cdf0e10cSrcweir 		/** destructs the guard.
319cdf0e10cSrcweir 			<p>The context (it's mutex, respectively) is unlocked.</p>
320cdf0e10cSrcweir 		*/
321cdf0e10cSrcweir 		inline ~OContextEntryGuard();
322cdf0e10cSrcweir 	};
323cdf0e10cSrcweir 
324cdf0e10cSrcweir 	//.....................................................................
OContextEntryGuard(OAccessibleContextHelper * _pContext)325cdf0e10cSrcweir 	inline OContextEntryGuard::OContextEntryGuard( OAccessibleContextHelper* _pContext  )
326cdf0e10cSrcweir 		:OContextEntryGuard_Base( _pContext->GetMutex( OAccessibleContextHelper::OAccessControl() ) )
327cdf0e10cSrcweir 	{
328cdf0e10cSrcweir 		_pContext->ensureAlive( OAccessibleContextHelper::OAccessControl() );
329cdf0e10cSrcweir 	}
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 	//.....................................................................
~OContextEntryGuard()332cdf0e10cSrcweir 	inline OContextEntryGuard::~OContextEntryGuard()
333cdf0e10cSrcweir 	{
334cdf0e10cSrcweir 	}
335cdf0e10cSrcweir 
336cdf0e10cSrcweir 	//=====================================================================
337cdf0e10cSrcweir 	//= OExternalLockGuard
338cdf0e10cSrcweir 	//=====================================================================
339cdf0e10cSrcweir 	class OExternalLockGuard
340cdf0e10cSrcweir 			:public OMutexGuard
341cdf0e10cSrcweir 			,public OContextEntryGuard
342cdf0e10cSrcweir 	{
343cdf0e10cSrcweir 	public:
344cdf0e10cSrcweir 		inline OExternalLockGuard( OAccessibleContextHelper* _pContext );
345cdf0e10cSrcweir 		inline ~OExternalLockGuard( );
346cdf0e10cSrcweir 	};
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 	//.....................................................................
OExternalLockGuard(OAccessibleContextHelper * _pContext)349cdf0e10cSrcweir 	inline OExternalLockGuard::OExternalLockGuard( OAccessibleContextHelper* _pContext )
350cdf0e10cSrcweir 		:OMutexGuard( _pContext->getExternalLock( OAccessibleContextHelper::OAccessControl() ) )
351cdf0e10cSrcweir 		,OContextEntryGuard( _pContext )
352cdf0e10cSrcweir 	{
353cdf0e10cSrcweir 		// #102438#
354cdf0e10cSrcweir 		// Only lock the external mutex,
355cdf0e10cSrcweir 		// release the ::osl::Mutex of the OAccessibleContextHelper instance.
356cdf0e10cSrcweir 		// If you call into another UNO object with locked ::osl::Mutex,
357cdf0e10cSrcweir 		// this may lead to dead locks.
358cdf0e10cSrcweir 		clear();
359cdf0e10cSrcweir 	}
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 	//.....................................................................
~OExternalLockGuard()362cdf0e10cSrcweir 	inline OExternalLockGuard::~OExternalLockGuard( )
363cdf0e10cSrcweir 	{
364cdf0e10cSrcweir 	}
365cdf0e10cSrcweir 
366cdf0e10cSrcweir //.........................................................................
367cdf0e10cSrcweir }	// namespace comphelper
368cdf0e10cSrcweir //.........................................................................
369cdf0e10cSrcweir 
370cdf0e10cSrcweir #endif // COMPHELPER_ACCESSIBLE_CONTEXT_HELPER_HXX
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 
373