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() 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::isVisible() throw( RuntimeException )
238 : {
239 0 : ::osl::MutexGuard aGuard( m_aMutex );
240 :
241 0 : ThrowExceptionIfNotAlive();
242 :
243 0 : return mpRepr->IsVisible();
244 : }
245 :
246 : // XAccessibleContext
247 0 : sal_Int32 SAL_CALL SvxRectCtlAccessibleContext::getAccessibleChildCount() throw( RuntimeException, std::exception )
248 : {
249 0 : ::osl::MutexGuard aGuard( m_aMutex );
250 :
251 0 : ThrowExceptionIfNotAlive();
252 :
253 0 : return mpRepr->GetNumOfChildren();
254 : }
255 :
256 0 : Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleChild( sal_Int32 nIndex )
257 : throw( RuntimeException, lang::IndexOutOfBoundsException, std::exception )
258 : {
259 0 : checkChildIndex( nIndex );
260 :
261 0 : Reference< XAccessible > xChild = mpChildren[ nIndex ];
262 0 : if( !xChild.is() )
263 : {
264 0 : ::SolarMutexGuard aSolarGuard;
265 :
266 0 : ::osl::MutexGuard aGuard( m_aMutex );
267 :
268 0 : ThrowExceptionIfNotAlive();
269 :
270 0 : xChild = mpChildren[ nIndex ];
271 :
272 0 : if( !xChild.is() )
273 : {
274 0 : const ChildIndexToPointData* p = IndexToPoint( nIndex, mbAngleMode );
275 0 : OUString aName(SVX_RESSTR(p->nResIdName));
276 0 : OUString aDescr(SVX_RESSTR(p->nResIdDescr));
277 :
278 0 : Rectangle aFocusRect( mpRepr->CalculateFocusRectangle( p->ePoint ) );
279 :
280 : SvxRectCtlChildAccessibleContext* pChild = new SvxRectCtlChildAccessibleContext(
281 0 : this, *mpRepr, aName, aDescr, aFocusRect, nIndex );
282 0 : xChild = mpChildren[ nIndex ] = pChild;
283 0 : pChild->acquire();
284 :
285 : // set actual state
286 0 : if( mnSelectedChild == nIndex )
287 0 : pChild->setStateChecked( true );
288 0 : }
289 : }
290 :
291 0 : return xChild;
292 : }
293 :
294 0 : Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleParent() throw( RuntimeException, std::exception )
295 : {
296 0 : return mxParent;
297 : }
298 :
299 0 : sal_Int32 SAL_CALL SvxRectCtlAccessibleContext::getAccessibleIndexInParent() throw( RuntimeException, std::exception )
300 : {
301 0 : ::osl::MutexGuard aGuard( m_aMutex );
302 : // Use a simple but slow solution for now. Optimize later.
303 :
304 : // Iterate over all the parent's children and search for this object.
305 0 : if( mxParent.is() )
306 : {
307 0 : Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() );
308 0 : if( xParentContext.is() )
309 : {
310 0 : sal_Int32 nChildCount = xParentContext->getAccessibleChildCount();
311 0 : for( sal_Int32 i = 0 ; i < nChildCount ; ++i )
312 : {
313 0 : Reference< XAccessible > xChild( xParentContext->getAccessibleChild( i ) );
314 0 : if( xChild.get() == static_cast<XAccessible*>(this) )
315 0 : return i;
316 0 : }
317 0 : }
318 : }
319 :
320 : // Return -1 to indicate that this object's parent does not know about the
321 : // object.
322 0 : return -1;
323 : }
324 :
325 0 : sal_Int16 SAL_CALL SvxRectCtlAccessibleContext::getAccessibleRole() throw( RuntimeException, std::exception )
326 : {
327 0 : return AccessibleRole::PANEL;
328 : }
329 :
330 0 : OUString SAL_CALL SvxRectCtlAccessibleContext::getAccessibleDescription() throw( RuntimeException, std::exception )
331 : {
332 0 : ::osl::MutexGuard aGuard( m_aMutex );
333 0 : return msDescription + " Please use arrow key to selection.";
334 : }
335 :
336 0 : OUString SAL_CALL SvxRectCtlAccessibleContext::getAccessibleName() throw( RuntimeException, std::exception )
337 : {
338 0 : ::osl::MutexGuard aGuard( m_aMutex );
339 0 : return msName;
340 : }
341 :
342 : /** Return empty reference to indicate that the relation set is not
343 : supported.
344 : */
345 0 : Reference< XAccessibleRelationSet > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleRelationSet() throw( RuntimeException, std::exception )
346 : {
347 : //return Reference< XAccessibleRelationSet >();
348 0 : utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
349 0 : uno::Reference< css::accessibility::XAccessibleRelationSet > xSet = pRelationSetHelper;
350 0 : vcl::Window* pWindow = mpRepr;
351 0 : if ( pWindow )
352 : {
353 : // vcl::Window *pLabeledBy = pWindow->GetAccRelationLabeledBy();
354 0 : vcl::Window *pLabeledBy = pWindow->GetAccessibleRelationLabeledBy();
355 0 : if ( pLabeledBy && pLabeledBy != pWindow )
356 : {
357 0 : uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1);
358 0 : aSequence[0] = pLabeledBy->GetAccessible();
359 0 : pRelationSetHelper->AddRelation( css::accessibility::AccessibleRelation( css::accessibility::AccessibleRelationType::LABELED_BY, aSequence ) );
360 : }
361 0 : vcl::Window* pMemberOf = pWindow->GetAccessibleRelationMemberOf();
362 0 : if ( pMemberOf && pMemberOf != pWindow )
363 : {
364 0 : uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1);
365 0 : aSequence[0] = pMemberOf->GetAccessible();
366 0 : pRelationSetHelper->AddRelation( css::accessibility::AccessibleRelation( css::accessibility::AccessibleRelationType::MEMBER_OF, aSequence ) );
367 : }
368 : }
369 0 : return xSet;
370 : }
371 :
372 0 : Reference< XAccessibleStateSet > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleStateSet() throw( RuntimeException, std::exception )
373 : {
374 0 : ::osl::MutexGuard aGuard( m_aMutex );
375 0 : utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
376 :
377 0 : if( IsAlive() )
378 : {
379 0 : pStateSetHelper->AddState( AccessibleStateType::ENABLED );
380 0 : pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
381 0 : if( mpRepr->HasFocus() )
382 0 : pStateSetHelper->AddState( AccessibleStateType::FOCUSED );
383 0 : pStateSetHelper->AddState( AccessibleStateType::OPAQUE );
384 :
385 0 : pStateSetHelper->AddState( AccessibleStateType::SHOWING );
386 :
387 0 : if( isVisible() )
388 0 : pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
389 : }
390 : else
391 0 : pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
392 :
393 0 : return pStateSetHelper;
394 : }
395 :
396 0 : lang::Locale SAL_CALL SvxRectCtlAccessibleContext::getLocale() throw( IllegalAccessibleComponentStateException, RuntimeException, std::exception )
397 : {
398 0 : ::osl::MutexGuard aGuard( m_aMutex );
399 0 : if( mxParent.is() )
400 : {
401 0 : Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() );
402 0 : if( xParentContext.is() )
403 0 : return xParentContext->getLocale();
404 : }
405 :
406 : // No parent. Therefore throw exception to indicate this cluelessness.
407 0 : throw IllegalAccessibleComponentStateException();
408 : }
409 :
410 0 : void SAL_CALL SvxRectCtlAccessibleContext::addAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener )
411 : throw( RuntimeException, std::exception )
412 : {
413 0 : if (xListener.is())
414 : {
415 0 : ::osl::MutexGuard aGuard( m_aMutex );
416 0 : if (!mnClientId)
417 0 : mnClientId = comphelper::AccessibleEventNotifier::registerClient( );
418 0 : comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener );
419 : }
420 0 : }
421 :
422 0 : void SAL_CALL SvxRectCtlAccessibleContext::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener )
423 : throw( RuntimeException, std::exception )
424 : {
425 0 : if (xListener.is())
426 : {
427 0 : ::osl::MutexGuard aGuard( m_aMutex );
428 :
429 0 : sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener );
430 0 : if ( !nListenerCount )
431 : {
432 : // no listeners anymore
433 : // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
434 : // and at least to us not firing any events anymore, in case somebody calls
435 : // NotifyAccessibleEvent, again
436 0 : comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
437 0 : mnClientId = 0;
438 0 : }
439 : }
440 0 : }
441 :
442 0 : void SAL_CALL SvxRectCtlAccessibleContext::grabFocus() throw( RuntimeException, std::exception )
443 : {
444 0 : ::SolarMutexGuard aSolarGuard;
445 0 : ::osl::MutexGuard aGuard( m_aMutex );
446 :
447 0 : ThrowExceptionIfNotAlive();
448 :
449 0 : mpRepr->GrabFocus();
450 0 : }
451 :
452 0 : sal_Int32 SvxRectCtlAccessibleContext::getForeground( )
453 : throw (::com::sun::star::uno::RuntimeException, std::exception)
454 : {
455 0 : ::SolarMutexGuard aSolarGuard;
456 0 : ::osl::MutexGuard aGuard( m_aMutex );
457 0 : ThrowExceptionIfNotAlive();
458 :
459 0 : return mpRepr->GetControlForeground().GetColor();
460 : }
461 0 : sal_Int32 SvxRectCtlAccessibleContext::getBackground( )
462 : throw (::com::sun::star::uno::RuntimeException, std::exception)
463 : {
464 0 : ::SolarMutexGuard aSolarGuard;
465 0 : ::osl::MutexGuard aGuard( m_aMutex );
466 0 : ThrowExceptionIfNotAlive();
467 :
468 0 : return mpRepr->GetControlBackground().GetColor();
469 : }
470 :
471 : // XServiceInfo
472 0 : OUString SAL_CALL SvxRectCtlAccessibleContext::getImplementationName() throw( RuntimeException, std::exception )
473 : {
474 0 : return OUString( "com.sun.star.comp.ui.SvxRectCtlAccessibleContext" );
475 : }
476 :
477 0 : sal_Bool SAL_CALL SvxRectCtlAccessibleContext::supportsService( const OUString& sServiceName ) throw( RuntimeException, std::exception )
478 : {
479 0 : return cppu::supportsService(this, sServiceName);
480 : }
481 :
482 0 : Sequence< OUString > SAL_CALL SvxRectCtlAccessibleContext::getSupportedServiceNames() throw( RuntimeException, std::exception )
483 : {
484 0 : const OUString sServiceName( "com.sun.star.accessibility.AccessibleContext" );
485 0 : return Sequence< OUString >( &sServiceName, 1 );
486 : }
487 :
488 : // XTypeProvider
489 0 : Sequence< sal_Int8 > SAL_CALL SvxRectCtlAccessibleContext::getImplementationId() throw( RuntimeException, std::exception )
490 : {
491 0 : return css::uno::Sequence<sal_Int8>();
492 : }
493 :
494 : // XAccessibleSelection
495 0 : void SAL_CALL SvxRectCtlAccessibleContext::selectAccessibleChild( sal_Int32 nIndex ) throw( lang::IndexOutOfBoundsException, RuntimeException, std::exception )
496 : {
497 0 : ::SolarMutexGuard aSolarGuard;
498 :
499 0 : ::osl::MutexGuard aGuard( m_aMutex );
500 :
501 0 : checkChildIndex( nIndex );
502 :
503 0 : ThrowExceptionIfNotAlive();
504 :
505 0 : const ChildIndexToPointData* pData = IndexToPoint( nIndex, mbAngleMode );
506 :
507 : DBG_ASSERT( pData,
508 : "SvxRectCtlAccessibleContext::selectAccessibleChild(): this is an impossible state! Or at least should be..." );
509 :
510 : // this does all what is needed, including the change of the child's state!
511 0 : mpRepr->SetActualRP( pData->ePoint );
512 0 : }
513 :
514 0 : sal_Bool SAL_CALL SvxRectCtlAccessibleContext::isAccessibleChildSelected( sal_Int32 nIndex ) throw( lang::IndexOutOfBoundsException, RuntimeException, std::exception )
515 : {
516 0 : ::osl::MutexGuard aGuard( m_aMutex );
517 :
518 0 : checkChildIndex( nIndex );
519 :
520 0 : return nIndex == mnSelectedChild;
521 : }
522 :
523 0 : void SAL_CALL SvxRectCtlAccessibleContext::clearAccessibleSelection() throw( RuntimeException, std::exception )
524 : {
525 : DBG_ASSERT( false, "SvxRectCtlAccessibleContext::clearAccessibleSelection() is not possible!" );
526 0 : }
527 :
528 0 : void SAL_CALL SvxRectCtlAccessibleContext::selectAllAccessibleChildren() throw( RuntimeException, std::exception )
529 : {
530 : // guard in selectAccessibleChild()!
531 :
532 0 : selectAccessibleChild( 0 ); // default per definition
533 0 : }
534 :
535 0 : sal_Int32 SAL_CALL SvxRectCtlAccessibleContext::getSelectedAccessibleChildCount() throw( RuntimeException, std::exception )
536 : {
537 0 : ::osl::MutexGuard aGuard( m_aMutex );
538 :
539 0 : return mnSelectedChild == NOCHILDSELECTED? 0 : 1;
540 : }
541 :
542 0 : Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getSelectedAccessibleChild( sal_Int32 nIndex )
543 : throw( lang::IndexOutOfBoundsException, RuntimeException, std::exception )
544 : {
545 0 : ::osl::MutexGuard aGuard( m_aMutex );
546 :
547 0 : checkChildIndexOnSelection( nIndex );
548 :
549 0 : return getAccessibleChild( mnSelectedChild );
550 : }
551 :
552 0 : void SAL_CALL SvxRectCtlAccessibleContext::deselectAccessibleChild( sal_Int32 /*nIndex*/ ) throw( lang::IndexOutOfBoundsException, RuntimeException, std::exception )
553 : {
554 0 : OUString aMessage( "deselectAccessibleChild is not possible in this context" );
555 :
556 : DBG_ASSERT( false, "SvxRectCtlAccessibleContext::deselectAccessibleChild() is not possible!" );
557 :
558 0 : throw lang::IndexOutOfBoundsException( aMessage, *this ); // never possible
559 : }
560 :
561 : // internals
562 0 : void SvxRectCtlAccessibleContext::checkChildIndex( long nIndex ) throw( lang::IndexOutOfBoundsException )
563 : {
564 0 : if( nIndex < 0 || nIndex >= getAccessibleChildCount() )
565 0 : throw lang::IndexOutOfBoundsException();
566 0 : }
567 :
568 0 : void SvxRectCtlAccessibleContext::checkChildIndexOnSelection( long nIndex ) throw( lang::IndexOutOfBoundsException )
569 : {
570 0 : if( nIndex || mnSelectedChild == NOCHILDSELECTED )
571 : // in our case only for the first (0) _selected_ child this is a valid request
572 0 : throw lang::IndexOutOfBoundsException();
573 0 : }
574 :
575 0 : void SvxRectCtlAccessibleContext::FireChildFocus( RECT_POINT eButton )
576 : {
577 0 : ::osl::MutexGuard aGuard( m_aMutex );
578 0 : long nNew = PointToIndex( eButton, mbAngleMode );
579 0 : long nNumOfChildren = getAccessibleChildCount();
580 0 : if( nNew < nNumOfChildren )
581 : {
582 : // select new child
583 0 : mnSelectedChild = nNew;
584 0 : if( nNew != NOCHILDSELECTED )
585 : {
586 0 : SvxRectCtlChildAccessibleContext* pChild = mpChildren[ nNew ];
587 0 : if( pChild )
588 : {
589 0 : pChild->FireFocusEvent();
590 : }
591 : }
592 : else
593 : {
594 0 : const Reference< XInterface > xSource( *this );
595 0 : Any aOld;
596 0 : Any aNew;
597 0 : aNew <<= AccessibleStateType::FOCUSED;
598 0 : CommitChange( AccessibleEventObject( xSource, AccessibleEventId::STATE_CHANGED, aNew, aOld ) );
599 : }
600 : }
601 : else
602 0 : mnSelectedChild = NOCHILDSELECTED;
603 0 : }
604 0 : void SvxRectCtlAccessibleContext::selectChild( long nNew, bool bFireFocus )
605 : {
606 0 : ::osl::MutexGuard aGuard( m_aMutex );
607 0 : if( nNew != mnSelectedChild )
608 : {
609 0 : long nNumOfChildren = getAccessibleChildCount();
610 0 : if( nNew < nNumOfChildren )
611 : { // valid index
612 : SvxRectCtlChildAccessibleContext* pChild;
613 0 : if( mnSelectedChild != NOCHILDSELECTED )
614 : { // deselect old selected child if one is selected
615 0 : pChild = mpChildren[ mnSelectedChild ];
616 0 : if( pChild )
617 0 : pChild->setStateChecked( false, bFireFocus );
618 : }
619 :
620 : // select new child
621 0 : mnSelectedChild = nNew;
622 :
623 0 : if( nNew != NOCHILDSELECTED )
624 : {
625 0 : pChild = mpChildren[ nNew ];
626 0 : if( pChild )
627 0 : pChild->setStateChecked( true, bFireFocus );
628 : }
629 : }
630 : else
631 0 : mnSelectedChild = NOCHILDSELECTED;
632 0 : }
633 0 : }
634 :
635 0 : void SvxRectCtlAccessibleContext::selectChild(RECT_POINT eButton, bool bFireFocus )
636 : {
637 : // no guard -> is done in next selectChild
638 0 : selectChild(PointToIndex( eButton, mbAngleMode ), bFireFocus);
639 0 : }
640 :
641 0 : void SvxRectCtlAccessibleContext::CommitChange( const AccessibleEventObject& rEvent )
642 : {
643 0 : if (mnClientId)
644 0 : comphelper::AccessibleEventNotifier::addEvent( mnClientId, rEvent );
645 0 : }
646 :
647 0 : void SAL_CALL SvxRectCtlAccessibleContext::disposing()
648 : {
649 0 : if( !rBHelper.bDisposed )
650 : {
651 : {
652 0 : ::osl::MutexGuard aGuard( m_aMutex );
653 0 : mpRepr = NULL; // object dies with representation
654 :
655 0 : SvxRectCtlChildAccessibleContext** p = mpChildren;
656 0 : for( int i = MAX_NUM_OF_CHILDREN ; i ; --i, ++p )
657 : {
658 0 : SvxRectCtlChildAccessibleContext* pChild = *p;
659 0 : if( pChild )
660 : {
661 0 : pChild->dispose();
662 0 : pChild->release();
663 0 : *p = NULL;
664 : }
665 : }
666 :
667 0 : delete[] mpChildren;
668 0 : mpChildren = NULL;
669 : }
670 :
671 : {
672 0 : ::osl::MutexGuard aGuard( m_aMutex );
673 :
674 : // Send a disposing to all listeners.
675 0 : if ( mnClientId )
676 : {
677 0 : comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this );
678 0 : mnClientId = 0;
679 : }
680 :
681 0 : mxParent.clear();
682 : }
683 : }
684 0 : }
685 :
686 0 : Rectangle SvxRectCtlAccessibleContext::GetBoundingBoxOnScreen() throw( RuntimeException )
687 : {
688 0 : ::SolarMutexGuard aSolarGuard;
689 0 : ::osl::MutexGuard aGuard( m_aMutex );
690 :
691 0 : ThrowExceptionIfNotAlive();
692 :
693 0 : return Rectangle( mpRepr->GetParent()->OutputToScreenPixel( mpRepr->GetPosPixel() ), mpRepr->GetSizePixel() );
694 : }
695 :
696 0 : Rectangle SvxRectCtlAccessibleContext::GetBoundingBox() throw( RuntimeException )
697 : {
698 0 : ::SolarMutexGuard aSolarGuard;
699 0 : ::osl::MutexGuard aGuard( m_aMutex );
700 :
701 0 : ThrowExceptionIfNotAlive();
702 :
703 0 : return Rectangle( mpRepr->GetPosPixel(), mpRepr->GetSizePixel() );
704 : }
705 :
706 0 : void SvxRectCtlAccessibleContext::ThrowExceptionIfNotAlive() throw( lang::DisposedException )
707 : {
708 0 : if( IsNotAlive() )
709 0 : throw lang::DisposedException();
710 0 : }
711 :
712 :
713 :
714 :
715 :
716 :
717 0 : SvxRectCtlChildAccessibleContext::SvxRectCtlChildAccessibleContext(
718 : const Reference<XAccessible>& rxParent,
719 : const vcl::Window& rParentWindow,
720 : const OUString& rName,
721 : const OUString& rDescription,
722 : const Rectangle& rBoundingBox,
723 : long nIndexInParent ) :
724 :
725 : SvxRectCtlChildAccessibleContext_Base( maMutex ),
726 : msDescription( rDescription ),
727 : msName( rName ),
728 : mxParent(rxParent),
729 : mpBoundingBox( new Rectangle( rBoundingBox ) ),
730 : mrParentWindow( rParentWindow ),
731 : mnClientId( 0 ),
732 : mnIndexInParent( nIndexInParent ),
733 0 : mbIsChecked( false )
734 : {
735 0 : }
736 :
737 :
738 0 : SvxRectCtlChildAccessibleContext::~SvxRectCtlChildAccessibleContext()
739 : {
740 :
741 0 : if( IsAlive() )
742 : {
743 0 : osl_atomic_increment( &m_refCount );
744 0 : dispose(); // set mpRepr = NULL & release all children
745 : }
746 0 : }
747 :
748 : // XAccessible
749 0 : Reference< XAccessibleContext> SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleContext() throw( RuntimeException, std::exception )
750 : {
751 0 : return this;
752 : }
753 :
754 : // XAccessibleComponent
755 0 : sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::containsPoint( const awt::Point& rPoint ) throw( RuntimeException, std::exception )
756 : {
757 : // no guard -> done in getBounds()
758 0 : return Rectangle( Point( 0, 0 ), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) );
759 : }
760 :
761 0 : Reference< XAccessible > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleAtPoint( const awt::Point& /*rPoint*/ ) throw( RuntimeException, std::exception )
762 : {
763 0 : return Reference< XAccessible >();
764 : }
765 :
766 0 : awt::Rectangle SAL_CALL SvxRectCtlChildAccessibleContext::getBounds() throw( RuntimeException, std::exception )
767 : {
768 : // no guard -> done in getBoundingBox()
769 0 : return AWTRectangle( GetBoundingBox() );
770 : }
771 :
772 0 : awt::Point SAL_CALL SvxRectCtlChildAccessibleContext::getLocation() throw( RuntimeException, std::exception )
773 : {
774 : // no guard -> done in getBoundingBox()
775 0 : return AWTPoint( GetBoundingBox().TopLeft() );
776 : }
777 :
778 0 : awt::Point SAL_CALL SvxRectCtlChildAccessibleContext::getLocationOnScreen() throw( RuntimeException, std::exception )
779 : {
780 : // no guard -> done in getBoundingBoxOnScreen()
781 0 : return AWTPoint( GetBoundingBoxOnScreen().TopLeft() );
782 : }
783 :
784 0 : awt::Size SAL_CALL SvxRectCtlChildAccessibleContext::getSize() throw( RuntimeException, std::exception )
785 : {
786 : // no guard -> done in getBoundingBox()
787 0 : return AWTSize( GetBoundingBox().GetSize() );
788 : }
789 :
790 0 : void SAL_CALL SvxRectCtlChildAccessibleContext::grabFocus() throw( RuntimeException, std::exception )
791 : {
792 0 : }
793 :
794 0 : sal_Int32 SvxRectCtlChildAccessibleContext::getForeground( )
795 : throw (::com::sun::star::uno::RuntimeException, std::exception)
796 : {
797 0 : ::SolarMutexGuard aSolarGuard;
798 0 : ::osl::MutexGuard aGuard( maMutex );
799 0 : ThrowExceptionIfNotAlive();
800 0 : return mrParentWindow.GetControlForeground().GetColor();
801 : }
802 0 : sal_Int32 SvxRectCtlChildAccessibleContext::getBackground( )
803 : throw (::com::sun::star::uno::RuntimeException, std::exception)
804 : {
805 0 : ::SolarMutexGuard aSolarGuard;
806 0 : ::osl::MutexGuard aGuard( maMutex );
807 :
808 0 : ThrowExceptionIfNotAlive();
809 0 : return mrParentWindow.GetControlBackground().GetColor();
810 : }
811 :
812 : // XAccessibleContext
813 0 : sal_Int32 SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleChildCount() throw( RuntimeException, std::exception )
814 : {
815 0 : return 0;
816 : }
817 :
818 0 : Reference< XAccessible > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleChild( sal_Int32 /*nIndex*/ ) throw ( RuntimeException, lang::IndexOutOfBoundsException, std::exception )
819 : {
820 0 : throw lang::IndexOutOfBoundsException();
821 : }
822 :
823 0 : Reference< XAccessible > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleParent() throw( RuntimeException, std::exception )
824 : {
825 0 : return mxParent;
826 : }
827 :
828 0 : sal_Int32 SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleIndexInParent() throw( RuntimeException, std::exception )
829 : {
830 0 : return mnIndexInParent;
831 : }
832 :
833 0 : sal_Int16 SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleRole() throw( RuntimeException, std::exception )
834 : {
835 0 : return AccessibleRole::RADIO_BUTTON;
836 : }
837 :
838 0 : OUString SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleDescription() throw( RuntimeException, std::exception )
839 : {
840 0 : ::osl::MutexGuard aGuard( maMutex );
841 0 : return msDescription;
842 : }
843 :
844 0 : OUString SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleName() throw( RuntimeException, std::exception )
845 : {
846 0 : ::osl::MutexGuard aGuard( maMutex );
847 0 : return msName;
848 : }
849 :
850 : /** Return empty reference to indicate that the relation set is not
851 : supported.
852 : */
853 0 : Reference<XAccessibleRelationSet> SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleRelationSet() throw( RuntimeException, std::exception )
854 : {
855 0 : utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
856 0 : uno::Reference< css::accessibility::XAccessibleRelationSet > xSet = pRelationSetHelper;
857 0 : if( mxParent.is() )
858 : {
859 0 : uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1);
860 0 : aSequence[0] = mxParent;
861 0 : pRelationSetHelper->AddRelation( css::accessibility::AccessibleRelation( css::accessibility::AccessibleRelationType::MEMBER_OF, aSequence ) );
862 :
863 : }
864 :
865 0 : return xSet;
866 : }
867 :
868 0 : Reference< XAccessibleStateSet > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleStateSet() throw( RuntimeException, std::exception )
869 : {
870 0 : ::osl::MutexGuard aGuard( maMutex );
871 0 : utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
872 :
873 0 : if( IsAlive() )
874 : {
875 0 : if( mbIsChecked )
876 : {
877 0 : pStateSetHelper->AddState( AccessibleStateType::CHECKED );
878 : // pStateSetHelper->AddState( AccessibleStateType::SELECTED );
879 : }
880 :
881 0 : pStateSetHelper->AddState( AccessibleStateType::ENABLED );
882 0 : pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
883 0 : pStateSetHelper->AddState( AccessibleStateType::OPAQUE );
884 0 : pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
885 0 : pStateSetHelper->AddState( AccessibleStateType::SHOWING );
886 0 : pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
887 : }
888 : else
889 0 : pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
890 :
891 0 : return pStateSetHelper;
892 : }
893 :
894 0 : lang::Locale SAL_CALL SvxRectCtlChildAccessibleContext::getLocale() throw( IllegalAccessibleComponentStateException, RuntimeException, std::exception )
895 : {
896 0 : ::osl::MutexGuard aGuard( maMutex );
897 0 : if( mxParent.is() )
898 : {
899 0 : Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() );
900 0 : if( xParentContext.is() )
901 0 : return xParentContext->getLocale();
902 : }
903 :
904 : // No locale and no parent. Therefore throw exception to indicate this
905 : // cluelessness.
906 0 : throw IllegalAccessibleComponentStateException();
907 : }
908 :
909 0 : void SAL_CALL SvxRectCtlChildAccessibleContext::addAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener )
910 : throw( RuntimeException, std::exception )
911 : {
912 0 : if (xListener.is())
913 : {
914 0 : ::osl::MutexGuard aGuard( maMutex );
915 0 : if (!mnClientId)
916 0 : mnClientId = comphelper::AccessibleEventNotifier::registerClient( );
917 0 : comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener );
918 : }
919 0 : }
920 :
921 :
922 :
923 :
924 0 : void SAL_CALL SvxRectCtlChildAccessibleContext::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener )
925 : throw( RuntimeException, std::exception )
926 : {
927 0 : if (xListener.is())
928 : {
929 0 : ::osl::MutexGuard aGuard( maMutex );
930 :
931 0 : sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener );
932 0 : if ( !nListenerCount )
933 : {
934 : // no listeners anymore
935 : // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
936 : // and at least to us not firing any events anymore, in case somebody calls
937 : // NotifyAccessibleEvent, again
938 0 : comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
939 0 : mnClientId = 0;
940 0 : }
941 : }
942 0 : }
943 :
944 : // XAccessibleValue
945 0 : Any SAL_CALL SvxRectCtlChildAccessibleContext::getCurrentValue() throw( RuntimeException, std::exception )
946 : {
947 0 : ThrowExceptionIfNotAlive();
948 :
949 0 : Any aRet;
950 0 : aRet <<= ( mbIsChecked? 1.0 : 0.0 );
951 0 : return aRet;
952 : }
953 :
954 0 : sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::setCurrentValue( const Any& /*aNumber*/ ) throw( RuntimeException, std::exception )
955 : {
956 0 : return sal_False;
957 : }
958 :
959 0 : Any SAL_CALL SvxRectCtlChildAccessibleContext::getMaximumValue() throw( RuntimeException, std::exception )
960 : {
961 0 : Any aRet;
962 0 : aRet <<= 1.0;
963 0 : return aRet;
964 : }
965 :
966 0 : Any SAL_CALL SvxRectCtlChildAccessibleContext::getMinimumValue() throw( RuntimeException, std::exception )
967 : {
968 0 : Any aRet;
969 0 : aRet <<= 0.0;
970 0 : return aRet;
971 : }
972 :
973 :
974 : // XAccessibleAction
975 :
976 :
977 0 : sal_Int32 SvxRectCtlChildAccessibleContext::getAccessibleActionCount( ) throw (RuntimeException, std::exception)
978 : {
979 0 : ::osl::MutexGuard aGuard( maMutex );
980 :
981 0 : return 1;
982 : }
983 :
984 :
985 :
986 0 : sal_Bool SvxRectCtlChildAccessibleContext::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
987 : {
988 0 : ::osl::MutexGuard aGuard( maMutex );
989 :
990 0 : if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
991 0 : throw IndexOutOfBoundsException();
992 :
993 0 : Reference<XAccessibleSelection> xSelection( mxParent, UNO_QUERY);
994 :
995 0 : xSelection->selectAccessibleChild(mnIndexInParent);
996 :
997 0 : return sal_True;
998 : }
999 :
1000 :
1001 :
1002 0 : OUString SvxRectCtlChildAccessibleContext::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
1003 : {
1004 0 : ::osl::MutexGuard aGuard( maMutex );
1005 :
1006 0 : if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
1007 0 : throw IndexOutOfBoundsException();
1008 :
1009 0 : return OUString("select");
1010 : }
1011 :
1012 :
1013 :
1014 0 : Reference< XAccessibleKeyBinding > SvxRectCtlChildAccessibleContext::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
1015 : {
1016 0 : ::osl::MutexGuard aGuard( maMutex );
1017 :
1018 0 : if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
1019 0 : throw IndexOutOfBoundsException();
1020 :
1021 0 : return Reference< XAccessibleKeyBinding >();
1022 : }
1023 :
1024 : // XServiceInfo
1025 0 : OUString SAL_CALL SvxRectCtlChildAccessibleContext::getImplementationName() throw( RuntimeException, std::exception )
1026 : {
1027 0 : return OUString( "com.sun.star.comp.ui.SvxRectCtlChildAccessibleContext" );
1028 : }
1029 :
1030 0 : sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::supportsService( const OUString& sServiceName ) throw( RuntimeException, std::exception )
1031 : {
1032 0 : return cppu::supportsService(this, sServiceName);
1033 : }
1034 :
1035 0 : Sequence< OUString > SAL_CALL SvxRectCtlChildAccessibleContext::getSupportedServiceNames() throw( RuntimeException, std::exception )
1036 : {
1037 0 : const OUString sServiceName ("com.sun.star.accessibility.AccessibleContext");
1038 0 : return Sequence< OUString >( &sServiceName, 1 );
1039 : }
1040 :
1041 : // XTypeProvider
1042 0 : Sequence< sal_Int8 > SAL_CALL SvxRectCtlChildAccessibleContext::getImplementationId() throw( RuntimeException, std::exception )
1043 : {
1044 0 : return css::uno::Sequence<sal_Int8>();
1045 : }
1046 :
1047 0 : void SvxRectCtlChildAccessibleContext::CommitChange( const AccessibleEventObject& rEvent )
1048 : {
1049 0 : if (mnClientId)
1050 0 : comphelper::AccessibleEventNotifier::addEvent( mnClientId, rEvent );
1051 0 : }
1052 :
1053 0 : void SAL_CALL SvxRectCtlChildAccessibleContext::disposing()
1054 : {
1055 0 : if( !rBHelper.bDisposed )
1056 : {
1057 0 : ::osl::MutexGuard aGuard( maMutex );
1058 :
1059 : // Send a disposing to all listeners.
1060 0 : if ( mnClientId )
1061 : {
1062 0 : comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this );
1063 0 : mnClientId = 0;
1064 : }
1065 :
1066 0 : mxParent.clear();
1067 :
1068 0 : delete mpBoundingBox;
1069 : }
1070 0 : }
1071 :
1072 0 : void SvxRectCtlChildAccessibleContext::ThrowExceptionIfNotAlive() throw( lang::DisposedException )
1073 : {
1074 0 : if( IsNotAlive() )
1075 0 : throw lang::DisposedException();
1076 0 : }
1077 :
1078 0 : Rectangle SvxRectCtlChildAccessibleContext::GetBoundingBoxOnScreen() throw( RuntimeException )
1079 : {
1080 0 : ::osl::MutexGuard aGuard( maMutex );
1081 :
1082 : // no ThrowExceptionIfNotAlive() because its done in GetBoundingBox()
1083 0 : Rectangle aRect( GetBoundingBox() );
1084 :
1085 0 : return Rectangle( mrParentWindow.OutputToScreenPixel( aRect.TopLeft() ), aRect.GetSize() );
1086 : }
1087 :
1088 0 : Rectangle SvxRectCtlChildAccessibleContext::GetBoundingBox() throw( RuntimeException )
1089 : {
1090 : // no guard necessary, because no one changes mpBoundingBox after creating it
1091 0 : ThrowExceptionIfNotAlive();
1092 :
1093 0 : return *mpBoundingBox;
1094 : }
1095 :
1096 0 : void SvxRectCtlChildAccessibleContext::setStateChecked( bool bChecked, bool bFireFocus )
1097 : {
1098 0 : if( mbIsChecked != bChecked )
1099 : {
1100 0 : mbIsChecked = bChecked;
1101 :
1102 0 : const Reference< XInterface > xSource( *this );
1103 :
1104 0 : Any aOld;
1105 0 : Any aNew;
1106 0 : Any& rMod = bChecked? aNew : aOld;
1107 :
1108 0 : if( bFireFocus )
1109 : {
1110 : //Send the STATE_CHANGED(Focused) event to accessible
1111 0 : rMod <<= AccessibleStateType::FOCUSED;
1112 0 : CommitChange( AccessibleEventObject( xSource, AccessibleEventId::STATE_CHANGED, aNew, aOld ) );
1113 : }
1114 0 : rMod <<= AccessibleStateType::CHECKED;
1115 :
1116 0 : CommitChange( AccessibleEventObject( xSource, AccessibleEventId::STATE_CHANGED, aNew, aOld ) );
1117 : }
1118 0 : }
1119 :
1120 0 : void SvxRectCtlChildAccessibleContext::FireFocusEvent()
1121 : {
1122 0 : const Reference< XInterface > xSource( *this );
1123 0 : Any aOld;
1124 0 : Any aNew;
1125 0 : aNew <<= AccessibleStateType::FOCUSED;
1126 0 : CommitChange( AccessibleEventObject( xSource, AccessibleEventId::STATE_CHANGED, aNew, aOld ) );
1127 390 : }
1128 :
1129 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|