merged tag ooo/DEV300_m102
[LibreOffice.git] / accessibility / source / extended / accessibleiconchoicectrlentry.cxx
blobe910b503ad1c02f36720d8ac68b84a695fbbd0bf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_accessibility.hxx"
30 #include <accessibility/extended/accessibleiconchoicectrlentry.hxx>
31 #include <svtools/ivctrl.hxx>
32 #include <com/sun/star/awt/Point.hpp>
33 #include <com/sun/star/awt/Rectangle.hpp>
34 #include <com/sun/star/awt/Size.hpp>
35 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
36 #include <com/sun/star/accessibility/AccessibleRole.hpp>
37 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
38 #include <tools/debug.hxx>
39 #include <vcl/svapp.hxx>
40 #include <vcl/controllayout.hxx>
41 #include <toolkit/awt/vclxwindow.hxx>
42 #include <toolkit/helper/convert.hxx>
43 #include <unotools/accessiblestatesethelper.hxx>
44 #include <unotools/accessiblerelationsethelper.hxx>
45 #include <cppuhelper/typeprovider.hxx>
46 #include <comphelper/sequence.hxx>
47 #include <svtools/stringtransfer.hxx>
48 #include <comphelper/accessibleeventnotifier.hxx>
50 #define ACCESSIBLE_ACTION_COUNT 1
51 #define AID_EXPAND 0
52 #define AID_COLLAPSE 1
54 namespace
56 void checkActionIndex_Impl( sal_Int32 _nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException)
58 if ( _nIndex < 0 || _nIndex >= ACCESSIBLE_ACTION_COUNT )
59 // only three actions
60 throw ::com::sun::star::lang::IndexOutOfBoundsException();
64 //........................................................................
65 namespace accessibility
67 //........................................................................
68 // class ALBSolarGuard ---------------------------------------------------------
70 /** Aquire the solar mutex. */
71 class ALBSolarGuard : public ::vos::OGuard
73 public:
74 inline ALBSolarGuard() : ::vos::OGuard( Application::GetSolarMutex() ) {}
77 // class AccessibleIconChoiceCtrlEntry -----------------------------------------------------
79 using namespace ::com::sun::star::accessibility;
80 using namespace ::com::sun::star::uno;
81 using namespace ::com::sun::star::lang;
82 using namespace ::com::sun::star;
84 DBG_NAME(AccessibleIconChoiceCtrlEntry)
86 // -----------------------------------------------------------------------------
87 // Ctor() and Dtor()
88 // -----------------------------------------------------------------------------
89 AccessibleIconChoiceCtrlEntry::AccessibleIconChoiceCtrlEntry( SvtIconChoiceCtrl& _rIconCtrl,
90 sal_uLong _nPos,
91 const Reference< XAccessible >& _xParent ) :
93 AccessibleIconChoiceCtrlEntry_BASE ( m_aMutex ),
95 m_pIconCtrl ( &_rIconCtrl ),
96 m_nIndex ( _nPos ),
97 m_nClientId ( 0 ),
98 m_xParent ( _xParent )
101 osl_incrementInterlockedCount( &m_refCount );
103 Reference< XComponent > xComp( m_xParent, UNO_QUERY );
104 if ( xComp.is() )
105 xComp->addEventListener( this );
107 osl_decrementInterlockedCount( &m_refCount );
109 DBG_CTOR( AccessibleIconChoiceCtrlEntry, NULL );
111 // -----------------------------------------------------------------------------
112 void AccessibleIconChoiceCtrlEntry::disposing( const EventObject& _rSource )
113 throw(RuntimeException)
115 if ( _rSource.Source == m_xParent )
117 dispose();
118 DBG_ASSERT( !m_xParent.is() && ( NULL == m_pIconCtrl ), "" );
121 // -----------------------------------------------------------------------------
122 AccessibleIconChoiceCtrlEntry::~AccessibleIconChoiceCtrlEntry()
124 DBG_DTOR( AccessibleIconChoiceCtrlEntry, NULL );
126 if ( IsAlive_Impl() )
128 // increment ref count to prevent double call of Dtor
129 osl_incrementInterlockedCount( &m_refCount );
130 dispose();
133 #ifdef ACCESSIBLE_EVENT_NOTIFICATION_ENABLED
134 // (the following method is unused currently. If you need it, simply remove the #ifdef thing here and
135 // in the hxx)
136 // -----------------------------------------------------------------------------
137 void AccessibleIconChoiceCtrlEntry::NotifyAccessibleEvent( sal_Int16 _nEventId,
138 const ::com::sun::star::uno::Any& _aOldValue,
139 const ::com::sun::star::uno::Any& _aNewValue )
141 Reference< uno::XInterface > xSource( *this );
142 AccessibleEventObject aEventObj( xSource, _nEventId, _aNewValue, _aOldValue );
144 if (m_nClientId)
145 comphelper::AccessibleEventNotifier::addEvent( m_nClientId, aEventObj );
147 #endif
148 // -----------------------------------------------------------------------------
149 Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBox_Impl() const
151 Rectangle aRect;
152 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
153 if ( pEntry )
154 aRect = m_pIconCtrl->GetBoundingBox( pEntry );
156 return aRect;
158 // -----------------------------------------------------------------------------
159 Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBoxOnScreen_Impl() const
161 Rectangle aRect;
162 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
163 if ( pEntry )
165 aRect = m_pIconCtrl->GetBoundingBox( pEntry );
166 Point aTopLeft = aRect.TopLeft();
167 aTopLeft += m_pIconCtrl->GetWindowExtentsRelative( NULL ).TopLeft();
168 aRect = Rectangle( aTopLeft, aRect.GetSize() );
171 return aRect;
173 // -----------------------------------------------------------------------------
174 sal_Bool AccessibleIconChoiceCtrlEntry::IsAlive_Impl() const
176 return ( !rBHelper.bDisposed && !rBHelper.bInDispose && m_pIconCtrl );
178 // -----------------------------------------------------------------------------
179 sal_Bool AccessibleIconChoiceCtrlEntry::IsShowing_Impl() const
181 sal_Bool bShowing = sal_False;
182 Reference< XAccessibleContext > m_xParentContext =
183 m_xParent.is() ? m_xParent->getAccessibleContext() : Reference< XAccessibleContext >();
184 if( m_xParentContext.is() )
186 Reference< XAccessibleComponent > xParentComp( m_xParentContext, uno::UNO_QUERY );
187 if( xParentComp.is() )
188 bShowing = GetBoundingBox_Impl().IsOver( VCLRectangle( xParentComp->getBounds() ) );
191 return bShowing;
193 // -----------------------------------------------------------------------------
194 Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBox() throw ( lang::DisposedException )
196 ALBSolarGuard aSolarGuard;
197 ::osl::MutexGuard aGuard( m_aMutex );
199 EnsureIsAlive();
200 return GetBoundingBox_Impl();
202 // -----------------------------------------------------------------------------
203 Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBoxOnScreen() throw ( lang::DisposedException )
205 ALBSolarGuard aSolarGuard;
206 ::osl::MutexGuard aGuard( m_aMutex );
208 EnsureIsAlive();
209 return GetBoundingBoxOnScreen_Impl();
211 // -----------------------------------------------------------------------------
212 void AccessibleIconChoiceCtrlEntry::EnsureIsAlive() const throw ( lang::DisposedException )
214 if ( !IsAlive_Impl() )
215 throw lang::DisposedException();
217 // -----------------------------------------------------------------------------
218 ::rtl::OUString AccessibleIconChoiceCtrlEntry::implGetText()
220 ::rtl::OUString sRet;
221 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
222 if ( pEntry )
223 sRet = pEntry->GetDisplayText();
224 return sRet;
226 // -----------------------------------------------------------------------------
227 Locale AccessibleIconChoiceCtrlEntry::implGetLocale()
229 Locale aLocale;
230 aLocale = Application::GetSettings().GetUILocale();
232 return aLocale;
234 void AccessibleIconChoiceCtrlEntry::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
236 nStartIndex = 0;
237 nEndIndex = 0;
239 // -----------------------------------------------------------------------------
240 // XTypeProvider
241 // -----------------------------------------------------------------------------
242 // -----------------------------------------------------------------------------
243 Sequence< sal_Int8 > AccessibleIconChoiceCtrlEntry::getImplementationId() throw (RuntimeException)
245 static ::cppu::OImplementationId* pId = NULL;
247 if ( !pId )
249 ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
251 if ( !pId )
253 static ::cppu::OImplementationId aId;
254 pId = &aId;
257 return pId->getImplementationId();
259 // -----------------------------------------------------------------------------
260 // XComponent
261 // -----------------------------------------------------------------------------
262 void SAL_CALL AccessibleIconChoiceCtrlEntry::disposing()
264 ::osl::MutexGuard aGuard( m_aMutex );
266 // Send a disposing to all listeners.
267 if ( m_nClientId )
269 sal_uInt32 nId = m_nClientId;
270 m_nClientId = 0;
271 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this );
274 Reference< XComponent > xComp( m_xParent, UNO_QUERY );
275 if ( xComp.is() )
276 xComp->removeEventListener( this );
278 m_pIconCtrl = NULL;
279 m_xParent = NULL;
281 // -----------------------------------------------------------------------------
282 // XServiceInfo
283 // -----------------------------------------------------------------------------
284 ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getImplementationName() throw(RuntimeException)
286 return getImplementationName_Static();
288 // -----------------------------------------------------------------------------
289 Sequence< ::rtl::OUString > SAL_CALL AccessibleIconChoiceCtrlEntry::getSupportedServiceNames() throw(RuntimeException)
291 return getSupportedServiceNames_Static();
293 // -----------------------------------------------------------------------------
294 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
296 Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() );
297 const ::rtl::OUString* pSupported = aSupported.getConstArray();
298 const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
299 for ( ; pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported )
302 return pSupported != pEnd;
304 // -----------------------------------------------------------------------------
305 // XServiceInfo - static methods
306 // -----------------------------------------------------------------------------
307 Sequence< ::rtl::OUString > AccessibleIconChoiceCtrlEntry::getSupportedServiceNames_Static(void) throw( RuntimeException )
309 Sequence< ::rtl::OUString > aSupported(3);
310 aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleContext") );
311 aSupported[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleComponent") );
312 aSupported[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.AccessibleIconChoiceControlEntry") );
313 return aSupported;
315 // -----------------------------------------------------------------------------
316 ::rtl::OUString AccessibleIconChoiceCtrlEntry::getImplementationName_Static(void) throw( RuntimeException )
318 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.svtools.AccessibleIconChoiceControlEntry") );
320 // -----------------------------------------------------------------------------
321 // XAccessible
322 // -----------------------------------------------------------------------------
323 Reference< XAccessibleContext > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleContext( ) throw (RuntimeException)
325 EnsureIsAlive();
326 return this;
328 // -----------------------------------------------------------------------------
329 // XAccessibleContext
330 // -----------------------------------------------------------------------------
331 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleChildCount( ) throw (RuntimeException)
333 return 0; // no children
335 // -----------------------------------------------------------------------------
336 Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleChild( sal_Int32 ) throw (IndexOutOfBoundsException,RuntimeException)
338 throw IndexOutOfBoundsException();
340 // -----------------------------------------------------------------------------
341 Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleParent( ) throw (RuntimeException)
343 ::osl::MutexGuard aGuard( m_aMutex );
345 EnsureIsAlive();
346 return m_xParent;
348 // -----------------------------------------------------------------------------
349 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleIndexInParent( ) throw (RuntimeException)
351 ::osl::MutexGuard aGuard( m_aMutex );
353 return m_nIndex;
355 // -----------------------------------------------------------------------------
356 sal_Int16 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleRole( ) throw (RuntimeException)
358 return AccessibleRole::LABEL;
360 // -----------------------------------------------------------------------------
361 ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleDescription( ) throw (RuntimeException)
363 // no description for every item
364 return ::rtl::OUString();
366 // -----------------------------------------------------------------------------
367 ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleName( ) throw (RuntimeException)
369 ::osl::MutexGuard aGuard( m_aMutex );
371 EnsureIsAlive();
372 return implGetText();
374 // -----------------------------------------------------------------------------
375 Reference< XAccessibleRelationSet > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleRelationSet( ) throw (RuntimeException)
377 return new utl::AccessibleRelationSetHelper;
379 // -----------------------------------------------------------------------------
380 Reference< XAccessibleStateSet > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleStateSet( ) throw (RuntimeException)
382 ALBSolarGuard aSolarGuard;
383 ::osl::MutexGuard aGuard( m_aMutex );
385 utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
386 Reference< XAccessibleStateSet > xStateSet = pStateSetHelper;
388 if ( IsAlive_Impl() )
390 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
391 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
392 pStateSetHelper->AddState( AccessibleStateType::ENABLED );
393 pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
394 if ( IsShowing_Impl() )
396 pStateSetHelper->AddState( AccessibleStateType::SHOWING );
397 pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
400 if ( m_pIconCtrl && m_pIconCtrl->GetCursor() == m_pIconCtrl->GetEntry( m_nIndex ) )
401 pStateSetHelper->AddState( AccessibleStateType::SELECTED );
403 else
404 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
406 return xStateSet;
408 // -----------------------------------------------------------------------------
409 Locale SAL_CALL AccessibleIconChoiceCtrlEntry::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
411 ALBSolarGuard aSolarGuard;
412 ::osl::MutexGuard aGuard( m_aMutex );
414 return implGetLocale();
416 // -----------------------------------------------------------------------------
417 // XAccessibleComponent
418 // -----------------------------------------------------------------------------
419 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::containsPoint( const awt::Point& rPoint ) throw (RuntimeException)
421 return Rectangle( Point(), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) );
423 // -----------------------------------------------------------------------------
424 Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
426 return Reference< XAccessible >();
428 // -----------------------------------------------------------------------------
429 awt::Rectangle SAL_CALL AccessibleIconChoiceCtrlEntry::getBounds( ) throw (RuntimeException)
431 return AWTRectangle( GetBoundingBox() );
433 // -----------------------------------------------------------------------------
434 awt::Point SAL_CALL AccessibleIconChoiceCtrlEntry::getLocation( ) throw (RuntimeException)
436 return AWTPoint( GetBoundingBox().TopLeft() );
438 // -----------------------------------------------------------------------------
439 awt::Point SAL_CALL AccessibleIconChoiceCtrlEntry::getLocationOnScreen( ) throw (RuntimeException)
441 return AWTPoint( GetBoundingBoxOnScreen().TopLeft() );
443 // -----------------------------------------------------------------------------
444 awt::Size SAL_CALL AccessibleIconChoiceCtrlEntry::getSize( ) throw (RuntimeException)
446 return AWTSize( GetBoundingBox().GetSize() );
448 // -----------------------------------------------------------------------------
449 void SAL_CALL AccessibleIconChoiceCtrlEntry::grabFocus( ) throw (RuntimeException)
451 // do nothing, because no focus for each item
453 // -----------------------------------------------------------------------------
454 sal_Int32 AccessibleIconChoiceCtrlEntry::getForeground( ) throw (RuntimeException)
456 ALBSolarGuard aSolarGuard;
457 ::osl::MutexGuard aGuard( m_aMutex );
459 sal_Int32 nColor = 0;
460 Reference< XAccessible > xParent = getAccessibleParent();
461 if ( xParent.is() )
463 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
464 if ( xParentComp.is() )
465 nColor = xParentComp->getForeground();
468 return nColor;
470 // -----------------------------------------------------------------------------
471 sal_Int32 AccessibleIconChoiceCtrlEntry::getBackground( ) throw (RuntimeException)
473 ALBSolarGuard aSolarGuard;
474 ::osl::MutexGuard aGuard( m_aMutex );
476 sal_Int32 nColor = 0;
477 Reference< XAccessible > xParent = getAccessibleParent();
478 if ( xParent.is() )
480 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
481 if ( xParentComp.is() )
482 nColor = xParentComp->getBackground();
485 return nColor;
487 // -----------------------------------------------------------------------------
488 // XAccessibleText
489 // -----------------------------------------------------------------------------
490 // -----------------------------------------------------------------------------
491 awt::Rectangle SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterBounds( sal_Int32 _nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
493 ALBSolarGuard aSolarGuard;
494 ::osl::MutexGuard aGuard( m_aMutex );
496 if ( ( 0 > _nIndex ) || ( getCharacterCount() <= _nIndex ) )
497 throw IndexOutOfBoundsException();
499 awt::Rectangle aBounds( 0, 0, 0, 0 );
500 if ( m_pIconCtrl )
502 Rectangle aItemRect = GetBoundingBox_Impl();
503 Rectangle aCharRect = m_pIconCtrl->GetEntryCharacterBounds( m_nIndex, _nIndex );
504 aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
505 aBounds = AWTRectangle( aCharRect );
508 return aBounds;
510 // -----------------------------------------------------------------------------
511 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
513 ALBSolarGuard aSolarGuard;
514 ::osl::MutexGuard aGuard( m_aMutex );
516 sal_Int32 nIndex = -1;
517 if ( m_pIconCtrl )
519 ::vcl::ControlLayoutData aLayoutData;
520 Rectangle aItemRect = GetBoundingBox_Impl();
521 m_pIconCtrl->RecordLayoutData( &aLayoutData, aItemRect );
522 Point aPnt( VCLPoint( aPoint ) );
523 aPnt += aItemRect.TopLeft();
524 nIndex = aLayoutData.GetIndexForPoint( aPnt );
526 long nLen = aLayoutData.m_aUnicodeBoundRects.size();
527 for ( long i = 0; i < nLen; ++i )
529 Rectangle aRect = aLayoutData.GetCharacterBounds(i);
530 sal_Bool bInside = aRect.IsInside( aPnt );
532 if ( bInside )
533 break;
537 return nIndex;
539 // -----------------------------------------------------------------------------
540 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
542 ALBSolarGuard aSolarGuard;
543 ::osl::MutexGuard aGuard( m_aMutex );
545 String sText = getText();
546 if ( ( 0 > nStartIndex ) || ( sText.Len() <= nStartIndex )
547 || ( 0 > nEndIndex ) || ( sText.Len() <= nEndIndex ) )
548 throw IndexOutOfBoundsException();
550 sal_Int32 nLen = nEndIndex - nStartIndex + 1;
551 ::svt::OStringTransfer::CopyString( sText.Copy( (sal_uInt16)nStartIndex, (sal_uInt16)nLen ), m_pIconCtrl );
553 return sal_True;
555 // -----------------------------------------------------------------------------
556 // XAccessibleEventBroadcaster
557 // -----------------------------------------------------------------------------
558 void SAL_CALL AccessibleIconChoiceCtrlEntry::addEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
560 if (xListener.is())
562 ::osl::MutexGuard aGuard( m_aMutex );
563 if (!m_nClientId)
564 m_nClientId = comphelper::AccessibleEventNotifier::registerClient( );
565 comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener );
568 // -----------------------------------------------------------------------------
569 void SAL_CALL AccessibleIconChoiceCtrlEntry::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
571 if (xListener.is())
573 ::osl::MutexGuard aGuard( m_aMutex );
575 sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener );
576 if ( !nListenerCount )
578 // no listeners anymore
579 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
580 // and at least to us not firing any events anymore, in case somebody calls
581 // NotifyAccessibleEvent, again
582 sal_Int32 nId = m_nClientId;
583 m_nClientId = 0;
584 comphelper::AccessibleEventNotifier::revokeClient( nId );
589 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getCaretPosition( ) throw (::com::sun::star::uno::RuntimeException)
591 return -1;
593 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::setCaretPosition ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
595 ALBSolarGuard aSolarGuard;
596 ::osl::MutexGuard aGuard( m_aMutex );
597 EnsureIsAlive();
599 if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
600 throw IndexOutOfBoundsException();
602 return sal_False;
604 sal_Unicode SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
606 ALBSolarGuard aSolarGuard;
607 ::osl::MutexGuard aGuard( m_aMutex );
608 EnsureIsAlive();
609 return OCommonAccessibleText::getCharacter( nIndex );
611 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
613 ALBSolarGuard aSolarGuard;
614 ::osl::MutexGuard aGuard( m_aMutex );
615 EnsureIsAlive();
617 ::rtl::OUString sText( implGetText() );
619 if ( !implIsValidIndex( nIndex, sText.getLength() ) )
620 throw IndexOutOfBoundsException();
622 return ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >();
624 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterCount( ) throw (::com::sun::star::uno::RuntimeException)
626 ALBSolarGuard aSolarGuard;
627 ::osl::MutexGuard aGuard( m_aMutex );
628 EnsureIsAlive();
629 return OCommonAccessibleText::getCharacterCount( );
632 ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectedText( ) throw (::com::sun::star::uno::RuntimeException)
634 ALBSolarGuard aSolarGuard;
635 ::osl::MutexGuard aGuard( m_aMutex );
636 EnsureIsAlive();
637 return OCommonAccessibleText::getSelectedText( );
639 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectionStart( ) throw (::com::sun::star::uno::RuntimeException)
641 ALBSolarGuard aSolarGuard;
642 ::osl::MutexGuard aGuard( m_aMutex );
643 EnsureIsAlive();
644 return OCommonAccessibleText::getSelectionStart( );
646 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectionEnd( ) throw (::com::sun::star::uno::RuntimeException)
648 ALBSolarGuard aSolarGuard;
649 ::osl::MutexGuard aGuard( m_aMutex );
650 EnsureIsAlive();
651 return OCommonAccessibleText::getSelectionEnd( );
653 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
655 ALBSolarGuard aSolarGuard;
656 ::osl::MutexGuard aGuard( m_aMutex );
657 EnsureIsAlive();
659 if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
660 throw IndexOutOfBoundsException();
662 return sal_False;
664 ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getText( ) throw (::com::sun::star::uno::RuntimeException)
666 ALBSolarGuard aSolarGuard;
667 ::osl::MutexGuard aGuard( m_aMutex );
668 EnsureIsAlive();
669 return OCommonAccessibleText::getText( );
671 ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
673 ALBSolarGuard aSolarGuard;
674 ::osl::MutexGuard aGuard( m_aMutex );
675 EnsureIsAlive();
676 return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
678 ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleIconChoiceCtrlEntry::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
680 ALBSolarGuard aSolarGuard;
681 ::osl::MutexGuard aGuard( m_aMutex );
682 EnsureIsAlive();
683 return OCommonAccessibleText::getTextAtIndex( nIndex ,aTextType);
685 ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleIconChoiceCtrlEntry::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
687 ALBSolarGuard aSolarGuard;
688 ::osl::MutexGuard aGuard( m_aMutex );
689 EnsureIsAlive();
690 return OCommonAccessibleText::getTextBeforeIndex( nIndex ,aTextType);
692 ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleIconChoiceCtrlEntry::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
694 ALBSolarGuard aSolarGuard;
695 ::osl::MutexGuard aGuard( m_aMutex );
696 EnsureIsAlive();
698 return OCommonAccessibleText::getTextBehindIndex( nIndex ,aTextType);
701 // -----------------------------------------------------------------------------
702 // XAccessibleAction
703 // -----------------------------------------------------------------------------
704 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleActionCount( ) throw (RuntimeException)
706 ::osl::MutexGuard aGuard( m_aMutex );
708 // three actions supported
709 return ACCESSIBLE_ACTION_COUNT;
711 // -----------------------------------------------------------------------------
712 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::doAccessibleAction( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
714 ALBSolarGuard aSolarGuard;
715 ::osl::MutexGuard aGuard( m_aMutex );
717 sal_Bool bRet = sal_False;
718 checkActionIndex_Impl( nIndex );
719 EnsureIsAlive();
721 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
722 if ( pEntry && !pEntry->IsSelected() )
724 m_pIconCtrl->SetNoSelection();
725 m_pIconCtrl->SetCursor( pEntry );
726 bRet = sal_True;
729 return bRet;
731 // -----------------------------------------------------------------------------
732 ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleActionDescription( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
734 ALBSolarGuard aSolarGuard;
735 ::osl::MutexGuard aGuard( m_aMutex );
737 checkActionIndex_Impl( nIndex );
738 EnsureIsAlive();
740 static const ::rtl::OUString sActionDesc( RTL_CONSTASCII_USTRINGPARAM( "Select" ) );
741 return sActionDesc;
743 // -----------------------------------------------------------------------------
744 Reference< XAccessibleKeyBinding > AccessibleIconChoiceCtrlEntry::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
746 ::osl::MutexGuard aGuard( m_aMutex );
748 Reference< XAccessibleKeyBinding > xRet;
749 checkActionIndex_Impl( nIndex );
750 // ... which key?
751 return xRet;
753 //........................................................................
754 }// namespace accessibility
755 //........................................................................