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