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