xref: /AOO41X/main/svx/source/accessibility/svxrectctaccessiblecontext.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 
31 
32 #include "svxrectctaccessiblecontext.hxx"
33 #include <com/sun/star/accessibility/AccessibleRole.hpp>
34 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
35 #include <unotools/accessiblestatesethelper.hxx>
36 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
37 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
38 #include <com/sun/star/awt/XWindow.hpp>
39 #include <cppuhelper/typeprovider.hxx>
40 #include <toolkit/helper/vclunohelper.hxx>
41 #include <toolkit/helper/convert.hxx>
42 #include <vcl/svapp.hxx>
43 #include <osl/mutex.hxx>
44 #include <rtl/uuid.h>
45 #include <tools/debug.hxx>
46 #include <tools/gen.hxx>
47 
48 #include <svx/dialogs.hrc>
49 #include "accessibility.hrc"
50 #include <svx/dlgctrl.hxx>
51 #include <svx/dialmgr.hxx>
52 #include <comphelper/accessibleeventnotifier.hxx>
53 
54 
55 using namespace ::cppu;
56 using namespace ::osl;
57 using namespace	::com::sun::star;
58 using namespace	::com::sun::star::uno;
59 using namespace	::com::sun::star::accessibility;
60 
61 
62 #define MAX_NUM_OF_CHILDS	9
63 #define NOCHILDSELECTED		-1
64 
65 
66 DBG_NAME( SvxRectCtlAccessibleContext )
67 
68 
69 //=====  internal  ============================================================
70 
71 namespace
72 {
73 	struct ChildIndexToPointData
74 	{
75 		short		nResIdName;
76 		short		nResIdDescr;
77 		RECT_POINT	ePoint;
78 	};
79 }
80 
81 
82 static const ChildIndexToPointData* IndexToPoint( long nIndex, sal_Bool bAngleControl )
83 {
84 	DBG_ASSERT( nIndex < ( bAngleControl? 8 : 9 ) && nIndex >= 0, "-IndexToPoint(): invalid child index! You have been warned..." );
85 
86 	// angles are counted reverse counter clock wise
87 	static const ChildIndexToPointData	pAngleData[] =
88 	{													// index
89 		{	RID_SVXSTR_RECTCTL_ACC_CHLD_A000,	RID_SVXSTR_RECTCTL_ACC_CHLD_A000,	RP_RM },	//	0
90 		{	RID_SVXSTR_RECTCTL_ACC_CHLD_A045,	RID_SVXSTR_RECTCTL_ACC_CHLD_A045,	RP_RT },	//	1
91 		{	RID_SVXSTR_RECTCTL_ACC_CHLD_A090,	RID_SVXSTR_RECTCTL_ACC_CHLD_A090,	RP_MT },	//	2
92 		{	RID_SVXSTR_RECTCTL_ACC_CHLD_A135,	RID_SVXSTR_RECTCTL_ACC_CHLD_A135,	RP_LT },	//	3
93 		{	RID_SVXSTR_RECTCTL_ACC_CHLD_A180,	RID_SVXSTR_RECTCTL_ACC_CHLD_A180,	RP_LM },	//	4
94 		{	RID_SVXSTR_RECTCTL_ACC_CHLD_A225,	RID_SVXSTR_RECTCTL_ACC_CHLD_A225,	RP_LB },	//	5
95 		{	RID_SVXSTR_RECTCTL_ACC_CHLD_A270,	RID_SVXSTR_RECTCTL_ACC_CHLD_A270,	RP_MB },	//	6
96 		{	RID_SVXSTR_RECTCTL_ACC_CHLD_A315,	RID_SVXSTR_RECTCTL_ACC_CHLD_A315,	RP_RB }		//	7
97 	};
98 
99 	// corners are counted from left to right and top to bottom
100 	static const ChildIndexToPointData	pCornerData[] =
101 	{																	// index
102 		{	RID_SVXSTR_RECTCTL_ACC_CHLD_LT,	RID_SVXSTR_RECTCTL_ACC_CHLD_LT,	RP_LT },	//	0
103 		{	RID_SVXSTR_RECTCTL_ACC_CHLD_MT,	RID_SVXSTR_RECTCTL_ACC_CHLD_MT,	RP_MT },	//	1
104 		{	RID_SVXSTR_RECTCTL_ACC_CHLD_RT,	RID_SVXSTR_RECTCTL_ACC_CHLD_RT,	RP_RT },	//	2
105 		{	RID_SVXSTR_RECTCTL_ACC_CHLD_LM,	RID_SVXSTR_RECTCTL_ACC_CHLD_LM,	RP_LM },	//	3
106 		{	RID_SVXSTR_RECTCTL_ACC_CHLD_MM,	RID_SVXSTR_RECTCTL_ACC_CHLD_MM,	RP_MM },	//	4
107 		{	RID_SVXSTR_RECTCTL_ACC_CHLD_RM,	RID_SVXSTR_RECTCTL_ACC_CHLD_RM,	RP_RM },	//	5
108 		{	RID_SVXSTR_RECTCTL_ACC_CHLD_LB,	RID_SVXSTR_RECTCTL_ACC_CHLD_LB,	RP_LB },	//	6
109 		{	RID_SVXSTR_RECTCTL_ACC_CHLD_MB,	RID_SVXSTR_RECTCTL_ACC_CHLD_MB,	RP_MB },	//	7
110 		{	RID_SVXSTR_RECTCTL_ACC_CHLD_RB,	RID_SVXSTR_RECTCTL_ACC_CHLD_RB,	RP_RB }		//	8
111 	};
112 
113 	return ( bAngleControl? pAngleData : pCornerData ) + nIndex;
114 }
115 
116 
117 static long PointToIndex( RECT_POINT ePoint, sal_Bool bAngleControl )
118 {
119 	long	nRet( (long) ePoint );
120 	if( bAngleControl )
121 	{	// angle control
122 		// angles are counted reverse counter clock wise
123 		switch( ePoint )
124 		{
125 			case RP_LT:	nRet = 3;				break;
126 			case RP_MT:	nRet = 2;				break;
127 			case RP_RT:	nRet = 1;				break;
128 			case RP_LM:	nRet = 4;				break;
129 			case RP_MM:	nRet = NOCHILDSELECTED;	break;
130 			case RP_RM:	nRet = 0;				break;
131 			case RP_LB:	nRet = 5;				break;
132 			case RP_MB:	nRet = 6;				break;
133 			case RP_RB:	nRet = 7;				break;
134 		}
135 	}
136 	else
137 	{	// corner control
138 		// corners are counted from left to right and top to bottom
139 		DBG_ASSERT( RP_LT == 0 && RP_MT == 1 && RP_RT == 2 && RP_LM == 3 && RP_MM == 4 && RP_RM == 5 &&
140 					RP_LB == 6 && RP_MB == 7 && RP_RB == 8, "*PointToIndex(): unexpected enum value!" );
141 
142 		nRet = ( long ) ePoint;
143 	}
144 
145 	return nRet;
146 }
147 
148 
149 SvxRectCtlAccessibleContext::SvxRectCtlAccessibleContext(
150 	const Reference< XAccessible >&		rxParent,
151 	SvxRectCtl&							rRepr,
152 	const ::rtl::OUString*						pName,
153 	const ::rtl::OUString*						pDesc ) :
154 
155 	SvxRectCtlAccessibleContext_Base( m_aMutex ),
156 	mxParent( rxParent ),
157 	mpRepr( &rRepr ),
158     mpChilds( NULL ),
159     mnClientId( 0 ),
160 	mnSelectedChild( NOCHILDSELECTED ),
161 	mbAngleMode( rRepr.GetNumOfChilds() == 8 )
162 {
163 	DBG_CTOR( SvxRectCtlAccessibleContext, NULL );
164 
165 	if( pName )
166 		msName = *pName;
167 	else
168 	{
169 		::vos::OGuard	aSolarGuard( Application::GetSolarMutex() );
170 		msName = SVX_RESSTR( mbAngleMode? RID_SVXSTR_RECTCTL_ACC_ANGL_NAME : RID_SVXSTR_RECTCTL_ACC_CORN_NAME );
171 	}
172 
173 	if( pDesc )
174 		msDescription = *pDesc;
175 	else
176 	{
177 		::vos::OGuard	aSolarGuard( Application::GetSolarMutex() );
178 		msDescription = SVX_RESSTR( mbAngleMode? RID_SVXSTR_RECTCTL_ACC_ANGL_DESCR : RID_SVXSTR_RECTCTL_ACC_CORN_DESCR );
179 	}
180 
181 	mpChilds = new SvxRectCtlChildAccessibleContext*[ MAX_NUM_OF_CHILDS ];
182 
183 	SvxRectCtlChildAccessibleContext**	p = mpChilds;
184 	for( int i = MAX_NUM_OF_CHILDS ; i ; --i, ++p )
185 		*p = NULL;
186 }
187 
188 
189 SvxRectCtlAccessibleContext::~SvxRectCtlAccessibleContext()
190 {
191 	DBG_DTOR( SvxRectCtlAccessibleContext, NULL );
192 
193 	if( IsAlive() )
194 	{
195 		osl_incrementInterlockedCount( &m_refCount );
196 		dispose();		// set mpRepr = NULL & release all childs
197 	}
198 }
199 
200 //=====  XAccessible  =========================================================
201 
202 Reference< XAccessibleContext > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleContext( void ) throw( RuntimeException )
203 {
204 	return this;
205 }
206 
207 //=====  XAccessibleComponent  ================================================
208 
209 sal_Bool SAL_CALL SvxRectCtlAccessibleContext::containsPoint( const awt::Point& rPoint ) throw( RuntimeException )
210 {
211 	// no guard -> done in getBounds()
212 //	return GetBoundingBox().IsInside( VCLPoint( rPoint ) );
213 	return Rectangle( Point( 0, 0 ), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) );
214 }
215 
216 Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleAtPoint( const awt::Point& rPoint ) throw( RuntimeException )
217 {
218 	::osl::MutexGuard			aGuard( m_aMutex );
219 
220 	ThrowExceptionIfNotAlive();
221 
222 	Reference< XAccessible >	xRet;
223 
224 	long						nChild = PointToIndex( mpRepr->GetApproxRPFromPixPt( rPoint ), mbAngleMode );
225 
226 	if( nChild != NOCHILDSELECTED )
227 		xRet = getAccessibleChild( nChild );
228 
229 	return xRet;
230 }
231 
232 awt::Rectangle SAL_CALL SvxRectCtlAccessibleContext::getBounds() throw( RuntimeException )
233 {
234 	// no guard -> done in GetBoundingBox()
235 	return AWTRectangle( GetBoundingBox() );
236 }
237 
238 awt::Point SAL_CALL SvxRectCtlAccessibleContext::getLocation() throw( RuntimeException )
239 {
240 	// no guard -> done in GetBoundingBox()
241 	return AWTPoint( GetBoundingBox().TopLeft() );
242 }
243 
244 awt::Point SAL_CALL SvxRectCtlAccessibleContext::getLocationOnScreen() throw( RuntimeException )
245 {
246 	// no guard -> done in GetBoundingBoxOnScreen()
247 	return AWTPoint( GetBoundingBoxOnScreen().TopLeft() );
248 }
249 
250 awt::Size SAL_CALL SvxRectCtlAccessibleContext::getSize() throw( RuntimeException )
251 {
252 	// no guard -> done in GetBoundingBox()
253 	return AWTSize( GetBoundingBox().GetSize() );
254 }
255 
256 sal_Bool SAL_CALL SvxRectCtlAccessibleContext::isShowing() throw( RuntimeException )
257 {
258 	return sal_True;
259 }
260 
261 sal_Bool SAL_CALL SvxRectCtlAccessibleContext::isVisible() throw( RuntimeException )
262 {
263 	::osl::MutexGuard			aGuard( m_aMutex );
264 
265 	ThrowExceptionIfNotAlive();
266 
267 	return mpRepr->IsVisible();
268 }
269 
270 sal_Bool SAL_CALL SvxRectCtlAccessibleContext::isFocusTraversable() throw( RuntimeException )
271 {
272 	return sal_True;
273 }
274 
275 //=====  XAccessibleContext  ==================================================
276 
277 sal_Int32 SAL_CALL SvxRectCtlAccessibleContext::getAccessibleChildCount( void ) throw( RuntimeException )
278 {
279 	::osl::MutexGuard	aGuard( m_aMutex );
280 
281 	ThrowExceptionIfNotAlive();
282 
283 	return mpRepr->GetNumOfChilds();
284 }
285 
286 Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleChild( sal_Int32 nIndex )
287 	throw( RuntimeException, lang::IndexOutOfBoundsException )
288 {
289 	checkChildIndex( nIndex );
290 
291 	Reference< XAccessible >	xChild = mpChilds[ nIndex ];
292 	if( !xChild.is() )
293 	{
294 		::vos::OGuard		aSolarGuard( Application::GetSolarMutex() );
295 
296 		::osl::MutexGuard	aGuard( m_aMutex );
297 
298 		ThrowExceptionIfNotAlive();
299 
300 		xChild = mpChilds[ nIndex ];
301 
302 		if( !xChild.is() )
303 		{
304 			const ChildIndexToPointData*	p = IndexToPoint( nIndex, mbAngleMode );
305 			UniString		tmp = SVX_RESSTR( p->nResIdName );
306 			::rtl::OUString		aName( tmp );
307 						tmp = SVX_RESSTR( p->nResIdDescr );
308 			::rtl::OUString		aDescr( tmp );
309 
310 			Rectangle		aFocusRect( mpRepr->CalculateFocusRectangle( p->ePoint ) );
311 
312 			Rectangle		aBoundingBoxOnScreen( mpRepr->OutputToScreenPixel( aFocusRect.TopLeft() ), aFocusRect.GetSize() );
313 
314 			SvxRectCtlChildAccessibleContext*	pChild = new SvxRectCtlChildAccessibleContext(
315 													this, *mpRepr, aName, aDescr, aFocusRect, nIndex );
316 			xChild = mpChilds[ nIndex ] = pChild;
317 			pChild->acquire();
318 
319 			// set actual state
320 			if( mnSelectedChild == nIndex )
321 				pChild->setStateChecked( sal_True );
322 		}
323 	}
324 
325 	return xChild;
326 }
327 
328 Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleParent( void ) throw( RuntimeException )
329 {
330 	return mxParent;
331 }
332 
333 sal_Int32 SAL_CALL SvxRectCtlAccessibleContext::getAccessibleIndexInParent( void ) throw( RuntimeException )
334 {
335 	::osl::MutexGuard	aGuard( m_aMutex );
336 	//	Use a simple but slow solution for now.  Optimize later.
337 
338     //	Iterate over all the parent's children and search for this object.
339     if( mxParent.is() )
340     {
341     	Reference< XAccessibleContext >		xParentContext( mxParent->getAccessibleContext() );
342         if( xParentContext.is() )
343         {
344         	sal_Int32						nChildCount = xParentContext->getAccessibleChildCount();
345             for( sal_Int32 i = 0 ; i < nChildCount ; ++i )
346             {
347             	Reference< XAccessible >	xChild( xParentContext->getAccessibleChild( i ) );
348 				if( xChild.get() == ( XAccessible* ) this )
349                     return i;
350             }
351         }
352    }
353 
354    //	Return -1 to indicate that this object's parent does not know about the
355    //	object.
356    return -1;
357 }
358 
359 sal_Int16 SAL_CALL SvxRectCtlAccessibleContext::getAccessibleRole( void ) throw( RuntimeException )
360 {
361 	return AccessibleRole::PANEL;
362 }
363 
364 ::rtl::OUString SAL_CALL SvxRectCtlAccessibleContext::getAccessibleDescription( void ) throw( RuntimeException )
365 {
366 	::osl::MutexGuard	aGuard( m_aMutex );
367 	return msDescription;
368 }
369 
370 ::rtl::OUString SAL_CALL SvxRectCtlAccessibleContext::getAccessibleName( void ) throw( RuntimeException )
371 {
372 	::osl::MutexGuard	aGuard( m_aMutex );
373 	return msName;
374 }
375 
376 /**	Return empty reference to indicate that the relation set is not
377 	supported.
378 */
379 Reference< XAccessibleRelationSet > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleRelationSet( void ) throw( RuntimeException )
380 {
381 	return Reference< XAccessibleRelationSet >();
382 }
383 
384 Reference< XAccessibleStateSet > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleStateSet( void ) throw( RuntimeException )
385 {
386 	::osl::MutexGuard						aGuard( m_aMutex );
387 	utl::AccessibleStateSetHelper*			pStateSetHelper = new utl::AccessibleStateSetHelper;
388 
389 	if( IsAlive() )
390 	{
391 		// pStateSetHelper->AddState( AccessibleStateType::ENABLED );
392         // pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
393 		pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
394 		if( mpRepr->HasFocus() )
395 			pStateSetHelper->AddState( AccessibleStateType::FOCUSED );
396 		pStateSetHelper->AddState( AccessibleStateType::OPAQUE );
397 
398 		if( isShowing() )
399 			pStateSetHelper->AddState( AccessibleStateType::SHOWING );
400 
401 		if( isVisible() )
402 			pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
403 	}
404 	else
405 		pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
406 
407 	return pStateSetHelper;
408 }
409 
410 lang::Locale SAL_CALL SvxRectCtlAccessibleContext::getLocale( void ) throw( IllegalAccessibleComponentStateException, RuntimeException )
411 {
412 	::osl::MutexGuard							aGuard( m_aMutex );
413 	if( mxParent.is() )
414     {
415     	Reference< XAccessibleContext >	xParentContext( mxParent->getAccessibleContext() );
416         if( xParentContext.is() )
417 	    	return xParentContext->getLocale();
418     }
419 
420     //	No parent.  Therefore throw exception to indicate this cluelessness.
421     throw IllegalAccessibleComponentStateException();
422 }
423 
424 void SAL_CALL SvxRectCtlAccessibleContext::addEventListener( const Reference< XAccessibleEventListener >& xListener )
425     throw( RuntimeException )
426 {
427 	if (xListener.is())
428     {
429 		::osl::MutexGuard	aGuard( m_aMutex );
430 		if (!mnClientId)
431             mnClientId = comphelper::AccessibleEventNotifier::registerClient( );
432 		comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener );
433     }
434 }
435 
436 void SAL_CALL SvxRectCtlAccessibleContext::removeEventListener( const Reference< XAccessibleEventListener >& xListener )
437     throw( RuntimeException )
438 {
439 	if (xListener.is())
440 	{
441     	::osl::MutexGuard	aGuard( m_aMutex );
442 
443         sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener );
444 		if ( !nListenerCount )
445 		{
446 			// no listeners anymore
447 			// -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
448 			// and at least to us not firing any events anymore, in case somebody calls
449 			// NotifyAccessibleEvent, again
450 			comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
451 			mnClientId = 0;
452 		}
453 	}
454 }
455 
456 void SAL_CALL SvxRectCtlAccessibleContext::addFocusListener( const Reference< awt::XFocusListener >& xListener )
457 	throw( RuntimeException )
458 {
459 	if( xListener.is() )
460     {
461 		::osl::MutexGuard	aGuard( m_aMutex );
462 
463 		ThrowExceptionIfNotAlive();
464 
465 		Reference< awt::XWindow >	xWindow = VCLUnoHelper::GetInterface( mpRepr );
466 		if( xWindow.is() )
467 			xWindow->addFocusListener( xListener );
468     }
469 }
470 
471 void SAL_CALL SvxRectCtlAccessibleContext::removeFocusListener( const Reference< awt::XFocusListener >& xListener )
472 	throw (RuntimeException)
473 {
474 	if( xListener.is() )
475     {
476 		::osl::MutexGuard	aGuard( m_aMutex );
477 
478 		ThrowExceptionIfNotAlive();
479 
480 		Reference< awt::XWindow >	xWindow = VCLUnoHelper::GetInterface( mpRepr );
481 		if( xWindow.is() )
482 			xWindow->removeFocusListener( xListener );
483     }
484 }
485 
486 void SAL_CALL SvxRectCtlAccessibleContext::grabFocus() throw( RuntimeException )
487 {
488 	::vos::OGuard		aSolarGuard( Application::GetSolarMutex() );
489 	::osl::MutexGuard	aGuard( m_aMutex );
490 
491 	ThrowExceptionIfNotAlive();
492 
493 	mpRepr->GrabFocus();
494 }
495 
496 Any SAL_CALL SvxRectCtlAccessibleContext::getAccessibleKeyBinding() throw( RuntimeException )
497 {
498 	// here is no implementation, because here are no KeyBindings for every object
499 	return Any();
500 }
501 
502 sal_Int32 SvxRectCtlAccessibleContext::getForeground(  )
503         throw (::com::sun::star::uno::RuntimeException)
504 {
505     ::vos::OGuard       aSolarGuard( Application::GetSolarMutex() );
506     ::osl::MutexGuard   aGuard( m_aMutex );
507     ThrowExceptionIfNotAlive();
508 
509     return mpRepr->GetControlForeground().GetColor();
510 }
511 sal_Int32 SvxRectCtlAccessibleContext::getBackground(  )
512         throw (::com::sun::star::uno::RuntimeException)
513 {
514     ::vos::OGuard       aSolarGuard( Application::GetSolarMutex() );
515     ::osl::MutexGuard   aGuard( m_aMutex );
516     ThrowExceptionIfNotAlive();
517 
518     return mpRepr->GetControlBackground().GetColor();
519 }
520 
521 //=====  XServiceInfo  ========================================================
522 
523 ::rtl::OUString SAL_CALL SvxRectCtlAccessibleContext::getImplementationName( void ) throw( RuntimeException )
524 {
525 	return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.ui.SvxRectCtlAccessibleContext" ) );
526 }
527 
528 sal_Bool SAL_CALL SvxRectCtlAccessibleContext::supportsService( const ::rtl::OUString& sServiceName ) throw( RuntimeException )
529 {
530 	::osl::MutexGuard	aGuard( m_aMutex );
531     //  Iterate over all supported service names and return true if on of them
532     //  matches the given name.
533     Sequence< ::rtl::OUString >	aSupportedServices( getSupportedServiceNames() );
534 	int						nLength = aSupportedServices.getLength();
535 	const ::rtl::OUString*			pStr = aSupportedServices.getConstArray();
536 
537     for( int i = nLength ; i ; --i, ++pStr )
538 	{
539         if( sServiceName == *pStr )
540             return sal_True;
541 	}
542 
543     return sal_False;
544 }
545 
546 Sequence< ::rtl::OUString > SAL_CALL SvxRectCtlAccessibleContext::getSupportedServiceNames( void ) throw( RuntimeException )
547 {
548 	const ::rtl::OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" ) );
549 	return Sequence< ::rtl::OUString >( &sServiceName, 1 );
550 }
551 
552 //=====  XTypeProvider  =======================================================
553 
554 Sequence< sal_Int8 > SAL_CALL SvxRectCtlAccessibleContext::getImplementationId( void ) throw( RuntimeException )
555 {
556 	return getUniqueId();
557 }
558 
559 //=====  XAccessibleSelection =============================================
560 
561 void SAL_CALL SvxRectCtlAccessibleContext::selectAccessibleChild( sal_Int32 nIndex ) throw( lang::IndexOutOfBoundsException, RuntimeException )
562 {
563 	::vos::OGuard		aSolarGuard( Application::GetSolarMutex() );
564 
565 	::osl::MutexGuard	aGuard( m_aMutex );
566 
567 	checkChildIndex( nIndex );
568 
569 	ThrowExceptionIfNotAlive();
570 
571 	const ChildIndexToPointData*	pData = IndexToPoint( nIndex, mbAngleMode );
572 
573 	DBG_ASSERT( pData,
574 		"SvxRectCtlAccessibleContext::selectAccessibleChild(): this is an impossible state! Or at least should be..." );
575 
576 	// this does all wich is needed, including the change of the child's state!
577 	mpRepr->SetActualRP( pData->ePoint );
578 }
579 
580 sal_Bool SAL_CALL SvxRectCtlAccessibleContext::isAccessibleChildSelected( sal_Int32 nIndex ) throw( lang::IndexOutOfBoundsException, RuntimeException )
581 {
582 	::osl::MutexGuard	aGuard( m_aMutex );
583 
584 	checkChildIndex( nIndex );
585 
586 	return nIndex == mnSelectedChild;
587 }
588 
589 void SAL_CALL SvxRectCtlAccessibleContext::clearAccessibleSelection() throw( RuntimeException )
590 {
591 	DBG_ASSERT( sal_False, "SvxRectCtlAccessibleContext::clearAccessibleSelection() is not possible!" );
592 }
593 
594 void SAL_CALL SvxRectCtlAccessibleContext::selectAllAccessibleChildren() throw( RuntimeException )
595 {
596 	// guard in selectAccessibleChild()!
597 
598 	selectAccessibleChild( 0 );		// default per definition
599 }
600 
601 sal_Int32 SAL_CALL SvxRectCtlAccessibleContext::getSelectedAccessibleChildCount() throw( RuntimeException )
602 {
603 	::osl::MutexGuard	aGuard( m_aMutex );
604 
605 	return mnSelectedChild == NOCHILDSELECTED? 0 : 1;
606 }
607 
608 Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getSelectedAccessibleChild( sal_Int32 nIndex )
609 	throw( lang::IndexOutOfBoundsException, RuntimeException )
610 {
611 	::osl::MutexGuard	aGuard( m_aMutex );
612 
613 	checkChildIndexOnSelection( nIndex );
614 
615 	return getAccessibleChild( mnSelectedChild );
616 }
617 
618 void SAL_CALL SvxRectCtlAccessibleContext::deselectAccessibleChild( sal_Int32 /*nIndex*/ ) throw( lang::IndexOutOfBoundsException, RuntimeException )
619 {
620 	::rtl::OUString	aMessage( RTL_CONSTASCII_USTRINGPARAM( "deselectAccessibleChild is not possible in this context" ) );
621 
622 	DBG_ASSERT( sal_False, "SvxRectCtlAccessibleContext::deselectAccessibleChild() is not possible!" );
623 
624 	throw lang::IndexOutOfBoundsException( aMessage, *this );	// never possible
625 }
626 
627 //=====  internals ========================================================
628 
629 void SvxRectCtlAccessibleContext::checkChildIndex( long nIndex ) throw( lang::IndexOutOfBoundsException )
630 {
631 	if( nIndex < 0 || nIndex >= getAccessibleChildCount() )
632 		throw lang::IndexOutOfBoundsException();
633 }
634 
635 void SvxRectCtlAccessibleContext::checkChildIndexOnSelection( long nIndex ) throw( lang::IndexOutOfBoundsException )
636 {
637 	if( nIndex || mnSelectedChild == NOCHILDSELECTED )
638 		// in our case only for the first (0) _selected_ child this is a valid request
639 		throw lang::IndexOutOfBoundsException();
640 }
641 
642 void SvxRectCtlAccessibleContext::selectChild( long nNew )
643 {
644 	::osl::MutexGuard	aGuard( m_aMutex );
645 	if( nNew != mnSelectedChild )
646 	{
647 		long	nNumOfChilds = getAccessibleChildCount();
648 		if( nNew < nNumOfChilds )
649 		{	// valid index
650 			SvxRectCtlChildAccessibleContext*	pChild;
651 			if( mnSelectedChild != NOCHILDSELECTED )
652 			{	// deselect old selected child if one is selected
653 				pChild = mpChilds[ mnSelectedChild ];
654 				if( pChild )
655 					pChild->setStateChecked( sal_False );
656 			}
657 
658 			// select new child
659 			mnSelectedChild = nNew;
660 
661 			if( nNew != NOCHILDSELECTED )
662 			{
663 				pChild = mpChilds[ nNew ];
664 				if( pChild )
665 					pChild->setStateChecked( sal_True );
666 			}
667 		}
668 		else
669 			mnSelectedChild = NOCHILDSELECTED;
670 	}
671 }
672 
673 void SvxRectCtlAccessibleContext::selectChild( RECT_POINT eButton )
674 {
675 	// no guard -> is done in next selectChild
676 	selectChild( PointToIndex( eButton, mbAngleMode ) );
677 }
678 
679 void SvxRectCtlAccessibleContext::setName( const ::rtl::OUString& rName )
680 {
681 	Any						aPreVal, aPostVal;
682 	{
683 		::osl::MutexGuard	aGuard( m_aMutex );
684 
685 		aPreVal <<= msName;
686 		aPostVal <<= rName;
687 
688 		msName = rName;
689 	}
690 
691 	const Reference< XInterface >	xSource( *this );
692 	CommitChange( AccessibleEventObject( xSource, AccessibleEventId::NAME_CHANGED, aPreVal, aPostVal ) );
693 }
694 
695 void SvxRectCtlAccessibleContext::setDescription( const ::rtl::OUString& rDescr )
696 {
697 	Any						aPreVal, aPostVal;
698 	{
699 		::osl::MutexGuard	aGuard( m_aMutex );
700 
701 		aPreVal <<= msDescription;
702 		aPostVal <<= rDescr;
703 
704 		msDescription = rDescr;
705 	}
706 
707 	const Reference< XInterface >	xSource( *this );
708 	CommitChange( AccessibleEventObject( xSource, AccessibleEventId::DESCRIPTION_CHANGED, aPreVal, aPostVal ) );
709 }
710 
711 void SvxRectCtlAccessibleContext::CommitChange( const AccessibleEventObject& rEvent )
712 {
713 	if (mnClientId)
714 		comphelper::AccessibleEventNotifier::addEvent( mnClientId, rEvent );
715 }
716 
717 void SAL_CALL SvxRectCtlAccessibleContext::disposing()
718 {
719 	if( !rBHelper.bDisposed )
720 	{
721 		{
722 			::osl::MutexGuard	aGuard( m_aMutex );
723 			mpRepr = NULL;		// object dies with representation
724 
725 			SvxRectCtlChildAccessibleContext**	p = mpChilds;
726 			for( int i = MAX_NUM_OF_CHILDS ; i ; --i, ++p )
727 			{
728 				SvxRectCtlChildAccessibleContext*	pChild = *p;
729 				if( pChild )
730 				{
731 					pChild->dispose();
732 					pChild->release();
733 					*p = NULL;
734 				}
735 			}
736 
737 			delete[] mpChilds;
738 			mpChilds = NULL;
739 		}
740 
741 		{
742 			::osl::MutexGuard	aGuard( m_aMutex );
743 
744             // Send a disposing to all listeners.
745 	        if ( mnClientId )
746 	        {
747                 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this );
748 		        mnClientId =  0;
749 	        }
750 
751 			mxParent = Reference< XAccessible >();
752 		}
753 	}
754 }
755 
756 Rectangle SvxRectCtlAccessibleContext::GetBoundingBoxOnScreen( void ) throw( RuntimeException )
757 {
758 	::vos::OGuard		aSolarGuard( Application::GetSolarMutex() );
759 	::osl::MutexGuard	aGuard( m_aMutex );
760 
761 	ThrowExceptionIfNotAlive();
762 
763 	return Rectangle( mpRepr->GetParent()->OutputToScreenPixel( mpRepr->GetPosPixel() ), mpRepr->GetSizePixel() );
764 }
765 
766 Rectangle SvxRectCtlAccessibleContext::GetBoundingBox( void ) throw( RuntimeException )
767 {
768 	::vos::OGuard		aSolarGuard( Application::GetSolarMutex() );
769 	::osl::MutexGuard	aGuard( m_aMutex );
770 
771 	ThrowExceptionIfNotAlive();
772 
773 	return Rectangle( mpRepr->GetPosPixel(), mpRepr->GetSizePixel() );
774 }
775 
776 Sequence< sal_Int8 > SvxRectCtlAccessibleContext::getUniqueId( void )
777 {
778 	static OImplementationId*	pId = 0;
779 	if( !pId )
780 	{
781 		MutexGuard						aGuard( Mutex::getGlobalMutex() );
782 		if( !pId)
783 		{
784 			static OImplementationId	aId;
785 			pId = &aId;
786 		}
787 	}
788 	return pId->getImplementationId();
789 }
790 
791 void SvxRectCtlAccessibleContext::ThrowExceptionIfNotAlive( void ) throw( lang::DisposedException )
792 {
793 	if( IsNotAlive() )
794 		throw lang::DisposedException();
795 }
796 
797 // -------------------------------------------------------------------------------------------------
798 
799 
800 DBG_NAME( SvxRectCtlChildAccessibleContext )
801 
802 
803 SvxRectCtlChildAccessibleContext::SvxRectCtlChildAccessibleContext(
804 	const Reference<XAccessible>&	rxParent,
805 	const Window&						rParentWindow,
806 	const ::rtl::OUString&				rName,
807 	const ::rtl::OUString&				rDescription,
808 	const Rectangle&					rBoundingBox,
809 	long								nIndexInParent ) :
810 
811 	SvxRectCtlChildAccessibleContext_Base( maMutex ),
812     msDescription( rDescription ),
813 	msName( rName ),
814     mxParent(rxParent),
815     mpBoundingBox( new Rectangle( rBoundingBox ) ),
816     mrParentWindow( rParentWindow ),
817     mnClientId( 0 ),
818     mnIndexInParent( nIndexInParent ),
819     mbIsChecked( sal_False )
820 {
821 	DBG_CTOR( SvxRectCtlChildAccessibleContext, NULL );
822 }
823 
824 
825 SvxRectCtlChildAccessibleContext::~SvxRectCtlChildAccessibleContext()
826 {
827 	DBG_DTOR( SvxRectCtlChildAccessibleContext, NULL );
828 
829 	if( IsAlive() )
830 	{
831 		osl_incrementInterlockedCount( &m_refCount );
832 		dispose();		// set mpRepr = NULL & release all childs
833 	}
834 }
835 
836 //=====  XAccessible  =========================================================
837 
838 Reference< XAccessibleContext> SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleContext( void ) throw( RuntimeException )
839 {
840 	return this;
841 }
842 
843 //=====  XAccessibleComponent  ================================================
844 
845 sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::containsPoint( const awt::Point& rPoint ) throw( RuntimeException )
846 {
847 	// no guard -> done in getBounds()
848 //	return GetBoundingBox().IsInside( VCLPoint( rPoint ) );
849 	return Rectangle( Point( 0, 0 ), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) );
850 }
851 
852 Reference< XAccessible > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleAtPoint( const awt::Point& /*rPoint*/ ) throw( RuntimeException )
853 {
854 	return Reference< XAccessible >();
855 }
856 
857 awt::Rectangle SAL_CALL SvxRectCtlChildAccessibleContext::getBounds() throw( RuntimeException )
858 {
859 	// no guard -> done in getBoundingBox()
860 	return AWTRectangle( GetBoundingBox() );
861 }
862 
863 awt::Point SAL_CALL SvxRectCtlChildAccessibleContext::getLocation() throw( RuntimeException )
864 {
865 	// no guard -> done in getBoundingBox()
866 	return AWTPoint( GetBoundingBox().TopLeft() );
867 }
868 
869 awt::Point SAL_CALL SvxRectCtlChildAccessibleContext::getLocationOnScreen() throw( RuntimeException )
870 {
871 	// no guard -> done in getBoundingBoxOnScreen()
872 	return AWTPoint( GetBoundingBoxOnScreen().TopLeft() );
873 }
874 
875 awt::Size SAL_CALL SvxRectCtlChildAccessibleContext::getSize() throw( RuntimeException )
876 {
877 	// no guard -> done in getBoundingBox()
878 	return AWTSize( GetBoundingBox().GetSize() );
879 }
880 
881 sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::isShowing() throw( RuntimeException )
882 {
883 	return sal_True;
884 }
885 
886 sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::isVisible() throw( RuntimeException )
887 {
888 	::osl::MutexGuard					aGuard( maMutex );
889 
890 	ThrowExceptionIfNotAlive();
891 
892 	return mxParent.is()? ( static_cast< SvxRectCtlAccessibleContext* >( mxParent.get() ) )->isVisible() : sal_False;
893 }
894 
895 sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::isFocusTraversable() throw( RuntimeException )
896 {
897 	return sal_False;
898 }
899 
900 void SAL_CALL SvxRectCtlChildAccessibleContext::addFocusListener( const Reference< awt::XFocusListener >& /*xListener*/ )
901 	throw( RuntimeException )
902 {
903     OSL_ENSURE( false, "SvxRectCtlChildAccessibleContext::addFocusListener: not implemented" );
904 }
905 
906 void SAL_CALL SvxRectCtlChildAccessibleContext::removeFocusListener( const Reference< awt::XFocusListener >& /*xListener*/ )
907 	throw (RuntimeException)
908 {
909     OSL_ENSURE( false, "SvxRectCtlChildAccessibleContext::removeFocusListener: not implemented" );
910 }
911 
912 void SAL_CALL SvxRectCtlChildAccessibleContext::grabFocus() throw( RuntimeException )
913 {
914 }
915 
916 Any SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleKeyBinding() throw( RuntimeException )
917 {
918 	// here is no implementation, because here are no KeyBindings for every object
919 	return Any();
920 }
921 sal_Int32 SvxRectCtlChildAccessibleContext::getForeground(  )
922         throw (::com::sun::star::uno::RuntimeException)
923 {
924     ::vos::OGuard       aSolarGuard( Application::GetSolarMutex() );
925     ::osl::MutexGuard   aGuard( maMutex );
926     ThrowExceptionIfNotAlive();
927     return mrParentWindow.GetControlForeground().GetColor();
928 }
929 sal_Int32 SvxRectCtlChildAccessibleContext::getBackground(  )
930         throw (::com::sun::star::uno::RuntimeException)
931 {
932     ::vos::OGuard       aSolarGuard( Application::GetSolarMutex() );
933     ::osl::MutexGuard   aGuard( maMutex );
934 
935     ThrowExceptionIfNotAlive();
936     return mrParentWindow.GetControlBackground().GetColor();
937 }
938 
939 //=====  XAccessibleContext  ==================================================
940 
941 sal_Int32 SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleChildCount( void ) throw( RuntimeException )
942 {
943 	return 0;
944 }
945 
946 Reference< XAccessible > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleChild( sal_Int32 /*nIndex*/ ) throw ( RuntimeException, lang::IndexOutOfBoundsException )
947 {
948 	throw lang::IndexOutOfBoundsException();
949 }
950 
951 Reference< XAccessible > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleParent( void ) throw( RuntimeException )
952 {
953 	return mxParent;
954 }
955 
956 sal_Int32 SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleIndexInParent( void ) throw( RuntimeException )
957 {
958    return mnIndexInParent;
959 }
960 
961 sal_Int16 SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleRole( void ) throw( RuntimeException )
962 {
963 	return AccessibleRole::RADIO_BUTTON;
964 }
965 
966 ::rtl::OUString SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleDescription( void ) throw( RuntimeException )
967 {
968 	::osl::MutexGuard	aGuard( maMutex );
969 	return msDescription;
970 }
971 
972 ::rtl::OUString SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleName( void ) throw( RuntimeException )
973 {
974 	::osl::MutexGuard	aGuard( maMutex );
975 	return msName;
976 }
977 
978 /**	Return empty reference to indicate that the relation set is not
979 	supported.
980 */
981 Reference<XAccessibleRelationSet> SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleRelationSet( void ) throw( RuntimeException )
982 {
983 	return Reference< XAccessibleRelationSet >();
984 }
985 
986 Reference< XAccessibleStateSet > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleStateSet( void ) throw( RuntimeException )
987 {
988 	::osl::MutexGuard						aGuard( maMutex );
989 	utl::AccessibleStateSetHelper*			pStateSetHelper = new utl::AccessibleStateSetHelper;
990 
991 	if( IsAlive() )
992 	{
993 		if( mbIsChecked )
994 		{
995 			pStateSetHelper->AddState( AccessibleStateType::CHECKED );
996 //			pStateSetHelper->AddState( AccessibleStateType::SELECTED );
997 		}
998 
999 		pStateSetHelper->AddState( AccessibleStateType::ENABLED );
1000         pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
1001 		pStateSetHelper->AddState( AccessibleStateType::OPAQUE );
1002 		pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
1003 		pStateSetHelper->AddState( AccessibleStateType::SHOWING );
1004 		pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
1005 	}
1006 	else
1007 		pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
1008 
1009 	return pStateSetHelper;
1010 }
1011 
1012 lang::Locale SAL_CALL SvxRectCtlChildAccessibleContext::getLocale( void ) throw( IllegalAccessibleComponentStateException, RuntimeException )
1013 {
1014 	::osl::MutexGuard						aGuard( maMutex );
1015 	if( mxParent.is() )
1016     {
1017     	Reference< XAccessibleContext >		xParentContext( mxParent->getAccessibleContext() );
1018         if( xParentContext.is() )
1019 	    	return xParentContext->getLocale();
1020     }
1021 
1022     //	No locale and no parent.  Therefore throw exception to indicate this
1023     //	cluelessness.
1024     throw IllegalAccessibleComponentStateException();
1025 }
1026 
1027 void SAL_CALL SvxRectCtlChildAccessibleContext::addEventListener( const Reference< XAccessibleEventListener >& xListener )
1028     throw( RuntimeException )
1029 {
1030 	if (xListener.is())
1031     {
1032     	::osl::MutexGuard	aGuard( maMutex );
1033 		if (!mnClientId)
1034             mnClientId = comphelper::AccessibleEventNotifier::registerClient( );
1035 		comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener );
1036     }
1037 }
1038 
1039 
1040 
1041 
1042 void SAL_CALL SvxRectCtlChildAccessibleContext::removeEventListener( const Reference< XAccessibleEventListener >& xListener )
1043     throw( RuntimeException )
1044 {
1045 	if (xListener.is())
1046 	{
1047     	::osl::MutexGuard	aGuard( maMutex );
1048 
1049         sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener );
1050 		if ( !nListenerCount )
1051 		{
1052 			// no listeners anymore
1053 			// -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
1054 			// and at least to us not firing any events anymore, in case somebody calls
1055 			// NotifyAccessibleEvent, again
1056 			comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
1057 			mnClientId = 0;
1058 		}
1059 	}
1060 }
1061 
1062 //=====  XAccessibleValue  ================================================
1063 
1064 Any SAL_CALL SvxRectCtlChildAccessibleContext::getCurrentValue() throw( RuntimeException )
1065 {
1066 	ThrowExceptionIfNotAlive();
1067 
1068 	Any	aRet;
1069 	aRet <<= ( mbIsChecked? 1.0 : 0.0 );
1070 	return aRet;
1071 }
1072 
1073 sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::setCurrentValue( const Any& /*aNumber*/ ) throw( RuntimeException )
1074 {
1075 	return sal_False;
1076 }
1077 
1078 Any SAL_CALL SvxRectCtlChildAccessibleContext::getMaximumValue() throw( RuntimeException )
1079 {
1080 	Any	aRet;
1081 	aRet <<= 1.0;
1082 	return aRet;
1083 }
1084 
1085 Any SAL_CALL SvxRectCtlChildAccessibleContext::getMinimumValue() throw( RuntimeException )
1086 {
1087 	Any	aRet;
1088 	aRet <<= 0.0;
1089 	return aRet;
1090 }
1091 
1092 //=====  XServiceInfo  ========================================================
1093 
1094 ::rtl::OUString SAL_CALL SvxRectCtlChildAccessibleContext::getImplementationName( void ) throw( RuntimeException )
1095 {
1096 	return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.ui.SvxRectCtlChildAccessibleContext" ) );
1097 }
1098 
1099 sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::supportsService( const ::rtl::OUString& sServiceName ) throw( RuntimeException )
1100 {
1101     //  Iterate over all supported service names and return true if on of them
1102     //  matches the given name.
1103 	::osl::MutexGuard	aGuard( maMutex );
1104     Sequence< ::rtl::OUString >	aSupportedServices ( getSupportedServiceNames() );
1105 	int						nLength = aSupportedServices.getLength();
1106     for( int i = 0 ; i < nLength; ++i )
1107 	{
1108         if( sServiceName == aSupportedServices[ i ] )
1109             return sal_True;
1110 	}
1111 
1112     return sal_False;
1113 }
1114 
1115 Sequence< ::rtl::OUString > SAL_CALL SvxRectCtlChildAccessibleContext::getSupportedServiceNames( void ) throw( RuntimeException )
1116 {
1117 	const ::rtl::OUString sServiceName (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.accessibility.AccessibleContext"));
1118 	return Sequence< ::rtl::OUString >( &sServiceName, 1 );
1119 }
1120 
1121 //=====  XTypeProvider  =======================================================
1122 
1123 Sequence< sal_Int8 > SAL_CALL SvxRectCtlChildAccessibleContext::getImplementationId( void ) throw( RuntimeException )
1124 {
1125 	static OImplementationId*	pId = 0;
1126 	if( !pId )
1127 	{
1128 		MutexGuard						aGuard( Mutex::getGlobalMutex() );
1129 		if( !pId)
1130 		{
1131 			static OImplementationId	aId;
1132 			pId = &aId;
1133 		}
1134 	}
1135 	return pId->getImplementationId();
1136 }
1137 
1138 //=====  internal  ============================================================
1139 
1140 void SvxRectCtlChildAccessibleContext::CommitChange( const AccessibleEventObject& rEvent )
1141 {
1142 	if (mnClientId)
1143 		comphelper::AccessibleEventNotifier::addEvent( mnClientId, rEvent );
1144 }
1145 
1146 void SAL_CALL SvxRectCtlChildAccessibleContext::disposing()
1147 {
1148 	if( !rBHelper.bDisposed )
1149 	{
1150 		::osl::MutexGuard	aGuard( maMutex );
1151 
1152         // Send a disposing to all listeners.
1153 	    if ( mnClientId )
1154 	    {
1155             comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this );
1156 		    mnClientId =  0;
1157 	    }
1158 
1159 		mxParent = Reference< XAccessible >();
1160 
1161 	    delete mpBoundingBox;
1162 	}
1163 }
1164 
1165 void SvxRectCtlChildAccessibleContext::ThrowExceptionIfNotAlive( void ) throw( lang::DisposedException )
1166 {
1167 	if( IsNotAlive() )
1168 		throw lang::DisposedException();
1169 }
1170 
1171 Rectangle SvxRectCtlChildAccessibleContext::GetBoundingBoxOnScreen( void ) throw( RuntimeException )
1172 {
1173 	::osl::MutexGuard	aGuard( maMutex );
1174 
1175 	// no ThrowExceptionIfNotAlive() because its done in GetBoundingBox()
1176 	Rectangle			aRect( GetBoundingBox() );
1177 
1178 	return Rectangle( mrParentWindow.OutputToScreenPixel( aRect.TopLeft() ), aRect.GetSize() );
1179 }
1180 
1181 Rectangle SvxRectCtlChildAccessibleContext::GetBoundingBox( void ) throw( RuntimeException )
1182 {
1183 	// no guard neccessary, because no one changes mpBoundingBox after creating it
1184 	ThrowExceptionIfNotAlive();
1185 
1186 	return *mpBoundingBox;
1187 }
1188 
1189 void SvxRectCtlChildAccessibleContext::setStateChecked( sal_Bool bChecked )
1190 {
1191 	if( mbIsChecked != bChecked )
1192 	{
1193 		mbIsChecked = bChecked;
1194 
1195 		const Reference< XInterface >	xSource( *this );
1196 
1197 		Any								aOld;
1198 		Any								aNew;
1199 		Any&							rMod = bChecked? aNew : aOld;
1200 
1201 		rMod <<= AccessibleStateType::CHECKED;
1202 
1203 		CommitChange( AccessibleEventObject( xSource, AccessibleEventId::STATE_CHANGED, aNew, aOld ) );
1204 	}
1205 }
1206 
1207