Branch libreoffice-5-0-4
[LibreOffice.git] / accessibility / source / extended / accessibleiconchoicectrlentry.cxx
blob92dd30e8faf02ade7b38bfd7294c05012003d2e8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <accessibility/extended/accessibleiconchoicectrlentry.hxx>
21 #include <svtools/ivctrl.hxx>
22 #include <com/sun/star/awt/Point.hpp>
23 #include <com/sun/star/awt/Rectangle.hpp>
24 #include <com/sun/star/awt/Size.hpp>
25 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
26 #include <com/sun/star/accessibility/AccessibleRole.hpp>
27 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
28 #include <vcl/svapp.hxx>
29 #include <vcl/controllayout.hxx>
30 #include <vcl/settings.hxx>
31 #include <toolkit/awt/vclxwindow.hxx>
32 #include <toolkit/helper/convert.hxx>
33 #include <unotools/accessiblestatesethelper.hxx>
34 #include <unotools/accessiblerelationsethelper.hxx>
35 #include <cppuhelper/supportsservice.hxx>
36 #include <cppuhelper/typeprovider.hxx>
37 #include <comphelper/sequence.hxx>
38 #include <svtools/stringtransfer.hxx>
39 #include <comphelper/accessibleeventnotifier.hxx>
41 #define ACCESSIBLE_ACTION_COUNT 1
43 namespace
45 void checkActionIndex_Impl( sal_Int32 _nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException)
47 if ( _nIndex < 0 || _nIndex >= ACCESSIBLE_ACTION_COUNT )
48 // only three actions
49 throw ::com::sun::star::lang::IndexOutOfBoundsException();
54 namespace accessibility
57 // class AccessibleIconChoiceCtrlEntry
59 using namespace ::com::sun::star::accessibility;
60 using namespace ::com::sun::star::uno;
61 using namespace ::com::sun::star::lang;
62 using namespace ::com::sun::star;
65 // Ctor() and Dtor()
67 AccessibleIconChoiceCtrlEntry::AccessibleIconChoiceCtrlEntry( SvtIconChoiceCtrl& _rIconCtrl,
68 sal_Int32 _nPos,
69 const Reference< XAccessible >& _xParent ) :
71 AccessibleIconChoiceCtrlEntry_BASE ( m_aMutex ),
73 m_pIconCtrl ( &_rIconCtrl ),
74 m_nIndex ( _nPos ),
75 m_nClientId ( 0 ),
76 m_xParent ( _xParent )
79 osl_atomic_increment( &m_refCount );
81 Reference< XComponent > xComp( m_xParent, UNO_QUERY );
82 if ( xComp.is() )
83 xComp->addEventListener( this );
85 osl_atomic_decrement( &m_refCount );
88 void AccessibleIconChoiceCtrlEntry::disposing( const EventObject& _rSource )
89 throw(RuntimeException, std::exception)
91 if ( _rSource.Source == m_xParent )
93 dispose();
94 OSL_ENSURE( !m_xParent.is() && ( nullptr == m_pIconCtrl ), "" );
98 AccessibleIconChoiceCtrlEntry::~AccessibleIconChoiceCtrlEntry()
100 if ( IsAlive_Impl() )
102 // increment ref count to prevent double call of Dtor
103 osl_atomic_increment( &m_refCount );
104 dispose();
108 Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBox_Impl() const
110 Rectangle aRect;
111 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
112 if ( pEntry )
113 aRect = m_pIconCtrl->GetBoundingBox( pEntry );
115 return aRect;
118 Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBoxOnScreen_Impl() const
120 Rectangle aRect;
121 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
122 if ( pEntry )
124 aRect = m_pIconCtrl->GetBoundingBox( pEntry );
125 Point aTopLeft = aRect.TopLeft();
126 aTopLeft += m_pIconCtrl->GetWindowExtentsRelative( NULL ).TopLeft();
127 aRect = Rectangle( aTopLeft, aRect.GetSize() );
130 return aRect;
133 bool AccessibleIconChoiceCtrlEntry::IsAlive_Impl() const
135 return ( !rBHelper.bDisposed && !rBHelper.bInDispose && m_pIconCtrl );
138 bool AccessibleIconChoiceCtrlEntry::IsShowing_Impl() const
140 bool bShowing = false;
141 Reference< XAccessibleContext > m_xParentContext =
142 m_xParent.is() ? m_xParent->getAccessibleContext() : Reference< XAccessibleContext >();
143 if( m_xParentContext.is() )
145 Reference< XAccessibleComponent > xParentComp( m_xParentContext, uno::UNO_QUERY );
146 if( xParentComp.is() )
147 bShowing = GetBoundingBox_Impl().IsOver( VCLRectangle( xParentComp->getBounds() ) );
150 return bShowing;
153 Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBox()
154 throw (lang::DisposedException, uno::RuntimeException)
156 SolarMutexGuard aSolarGuard;
157 ::osl::MutexGuard aGuard( m_aMutex );
159 EnsureIsAlive();
160 return GetBoundingBox_Impl();
163 Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBoxOnScreen()
164 throw (lang::DisposedException, uno::RuntimeException)
166 SolarMutexGuard aSolarGuard;
167 ::osl::MutexGuard aGuard( m_aMutex );
169 EnsureIsAlive();
170 return GetBoundingBoxOnScreen_Impl();
173 void AccessibleIconChoiceCtrlEntry::EnsureIsAlive() const throw ( lang::DisposedException )
175 if ( !IsAlive_Impl() )
176 throw lang::DisposedException();
179 OUString AccessibleIconChoiceCtrlEntry::implGetText()
181 OUString sRet;
182 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
183 if ( pEntry )
184 sRet = pEntry->GetDisplayText();
185 return sRet;
188 Locale AccessibleIconChoiceCtrlEntry::implGetLocale()
190 Locale aLocale;
191 aLocale = Application::GetSettings().GetUILanguageTag().getLocale();
193 return aLocale;
195 void AccessibleIconChoiceCtrlEntry::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
197 nStartIndex = 0;
198 nEndIndex = 0;
201 // XTypeProvider
204 Sequence< sal_Int8 > AccessibleIconChoiceCtrlEntry::getImplementationId() throw (RuntimeException, std::exception)
206 return css::uno::Sequence<sal_Int8>();
209 // XComponent
211 void SAL_CALL AccessibleIconChoiceCtrlEntry::disposing()
213 ::osl::MutexGuard aGuard( m_aMutex );
215 // Send a disposing to all listeners.
216 if ( m_nClientId )
218 sal_uInt32 nId = m_nClientId;
219 m_nClientId = 0;
220 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this );
223 Reference< XComponent > xComp( m_xParent, UNO_QUERY );
224 if ( xComp.is() )
225 xComp->removeEventListener( this );
227 m_pIconCtrl = NULL;
228 m_xParent = NULL;
231 // XServiceInfo
233 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getImplementationName() throw(RuntimeException, std::exception)
235 return getImplementationName_Static();
238 Sequence< OUString > SAL_CALL AccessibleIconChoiceCtrlEntry::getSupportedServiceNames() throw(RuntimeException, std::exception)
240 return getSupportedServiceNames_Static();
243 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::supportsService( const OUString& _rServiceName ) throw (RuntimeException, std::exception)
245 return cppu::supportsService(this, _rServiceName);
248 // XServiceInfo - static methods
250 Sequence< OUString > AccessibleIconChoiceCtrlEntry::getSupportedServiceNames_Static() throw( RuntimeException )
252 Sequence< OUString > aSupported(3);
253 aSupported[0] = "com.sun.star.accessibility.AccessibleContext";
254 aSupported[1] = "com.sun.star.accessibility.AccessibleComponent";
255 aSupported[2] = "com.sun.star.awt.AccessibleIconChoiceControlEntry";
256 return aSupported;
259 OUString AccessibleIconChoiceCtrlEntry::getImplementationName_Static() throw( RuntimeException )
261 return OUString( "com.sun.star.comp.svtools.AccessibleIconChoiceControlEntry" );
264 // XAccessible
266 Reference< XAccessibleContext > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleContext( ) throw (RuntimeException, std::exception)
268 EnsureIsAlive();
269 return this;
272 // XAccessibleContext
274 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleChildCount( ) throw (RuntimeException, std::exception)
276 return 0; // no children
279 Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleChild( sal_Int32 ) throw (IndexOutOfBoundsException,RuntimeException, std::exception)
281 throw IndexOutOfBoundsException();
284 Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleParent( ) throw (RuntimeException, std::exception)
286 ::osl::MutexGuard aGuard( m_aMutex );
288 EnsureIsAlive();
289 return m_xParent;
292 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleIndexInParent( ) throw (RuntimeException, std::exception)
294 ::osl::MutexGuard aGuard( m_aMutex );
296 return m_nIndex;
299 sal_Int16 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleRole( ) throw (RuntimeException, std::exception)
301 //return AccessibleRole::LABEL;
302 return AccessibleRole::LIST_ITEM;
305 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleDescription( ) throw (RuntimeException, std::exception)
307 // no description for every item
308 return OUString();
311 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleName( ) throw (RuntimeException, std::exception)
313 ::osl::MutexGuard aGuard( m_aMutex );
315 EnsureIsAlive();
316 return implGetText();
319 Reference< XAccessibleRelationSet > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleRelationSet( ) throw (RuntimeException, std::exception)
321 return new utl::AccessibleRelationSetHelper;
324 Reference< XAccessibleStateSet > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleStateSet( ) throw (RuntimeException, std::exception)
326 SolarMutexGuard aSolarGuard;
327 ::osl::MutexGuard aGuard( m_aMutex );
329 utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
330 Reference< XAccessibleStateSet > xStateSet = pStateSetHelper;
332 if ( IsAlive_Impl() )
334 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
335 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
336 pStateSetHelper->AddState( AccessibleStateType::ENABLED );
337 pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
338 if ( IsShowing_Impl() )
340 pStateSetHelper->AddState( AccessibleStateType::SHOWING );
341 pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
344 if ( m_pIconCtrl && m_pIconCtrl->GetCursor() == m_pIconCtrl->GetEntry( m_nIndex ) )
345 pStateSetHelper->AddState( AccessibleStateType::SELECTED );
347 else
348 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
350 return xStateSet;
353 Locale SAL_CALL AccessibleIconChoiceCtrlEntry::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException, std::exception)
355 SolarMutexGuard aSolarGuard;
356 ::osl::MutexGuard aGuard( m_aMutex );
358 return implGetLocale();
361 // XAccessibleComponent
363 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::containsPoint( const awt::Point& rPoint ) throw (RuntimeException, std::exception)
365 return Rectangle( Point(), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) );
368 Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException, std::exception)
370 return Reference< XAccessible >();
373 awt::Rectangle SAL_CALL AccessibleIconChoiceCtrlEntry::getBounds( ) throw (RuntimeException, std::exception)
375 return AWTRectangle( GetBoundingBox() );
378 awt::Point SAL_CALL AccessibleIconChoiceCtrlEntry::getLocation( ) throw (RuntimeException, std::exception)
380 return AWTPoint( GetBoundingBox().TopLeft() );
383 awt::Point SAL_CALL AccessibleIconChoiceCtrlEntry::getLocationOnScreen( ) throw (RuntimeException, std::exception)
385 return AWTPoint( GetBoundingBoxOnScreen().TopLeft() );
388 awt::Size SAL_CALL AccessibleIconChoiceCtrlEntry::getSize( ) throw (RuntimeException, std::exception)
390 return AWTSize( GetBoundingBox().GetSize() );
393 void SAL_CALL AccessibleIconChoiceCtrlEntry::grabFocus( ) throw (RuntimeException, std::exception)
395 // do nothing, because no focus for each item
398 sal_Int32 AccessibleIconChoiceCtrlEntry::getForeground( ) throw (RuntimeException, std::exception)
400 SolarMutexGuard aSolarGuard;
401 ::osl::MutexGuard aGuard( m_aMutex );
403 sal_Int32 nColor = 0;
404 Reference< XAccessible > xParent = getAccessibleParent();
405 if ( xParent.is() )
407 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
408 if ( xParentComp.is() )
409 nColor = xParentComp->getForeground();
412 return nColor;
415 sal_Int32 AccessibleIconChoiceCtrlEntry::getBackground( ) throw (RuntimeException, std::exception)
417 SolarMutexGuard aSolarGuard;
418 ::osl::MutexGuard aGuard( m_aMutex );
420 sal_Int32 nColor = 0;
421 Reference< XAccessible > xParent = getAccessibleParent();
422 if ( xParent.is() )
424 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
425 if ( xParentComp.is() )
426 nColor = xParentComp->getBackground();
429 return nColor;
432 // XAccessibleText
435 awt::Rectangle SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterBounds( sal_Int32 _nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
437 SolarMutexGuard aSolarGuard;
438 ::osl::MutexGuard aGuard( m_aMutex );
440 if ( ( 0 > _nIndex ) || ( getCharacterCount() <= _nIndex ) )
441 throw IndexOutOfBoundsException();
443 awt::Rectangle aBounds( 0, 0, 0, 0 );
444 if ( m_pIconCtrl )
446 Rectangle aItemRect = GetBoundingBox_Impl();
447 Rectangle aCharRect = m_pIconCtrl->GetEntryCharacterBounds( m_nIndex, _nIndex );
448 aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
449 aBounds = AWTRectangle( aCharRect );
452 return aBounds;
455 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException, std::exception)
457 SolarMutexGuard aSolarGuard;
458 ::osl::MutexGuard aGuard( m_aMutex );
460 sal_Int32 nIndex = -1;
461 if ( m_pIconCtrl )
463 vcl::ControlLayoutData aLayoutData;
464 Rectangle aItemRect = GetBoundingBox_Impl();
465 m_pIconCtrl->RecordLayoutData( &aLayoutData, aItemRect );
466 Point aPnt( VCLPoint( aPoint ) );
467 aPnt += aItemRect.TopLeft();
468 nIndex = aLayoutData.GetIndexForPoint( aPnt );
470 long nLen = aLayoutData.m_aUnicodeBoundRects.size();
471 for ( long i = 0; i < nLen; ++i )
473 Rectangle aRect = aLayoutData.GetCharacterBounds(i);
474 bool bInside = aRect.IsInside( aPnt );
476 if ( bInside )
477 break;
481 return nIndex;
484 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
486 SolarMutexGuard aSolarGuard;
487 ::osl::MutexGuard aGuard( m_aMutex );
489 OUString sText = getText();
490 if ( ( 0 > nStartIndex ) || ( sText.getLength() <= nStartIndex )
491 || ( 0 > nEndIndex ) || ( sText.getLength() <= nEndIndex ) )
492 throw IndexOutOfBoundsException();
494 sal_Int32 nLen = nEndIndex - nStartIndex + 1;
495 ::svt::OStringTransfer::CopyString( sText.copy( nStartIndex, nLen ), m_pIconCtrl );
497 return true;
500 // XAccessibleEventBroadcaster
502 void SAL_CALL AccessibleIconChoiceCtrlEntry::addAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException, std::exception)
504 if (xListener.is())
506 ::osl::MutexGuard aGuard( m_aMutex );
507 if (!m_nClientId)
508 m_nClientId = comphelper::AccessibleEventNotifier::registerClient( );
509 comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener );
513 void SAL_CALL AccessibleIconChoiceCtrlEntry::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException, std::exception)
515 if (xListener.is())
517 ::osl::MutexGuard aGuard( m_aMutex );
519 sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener );
520 if ( !nListenerCount )
522 // no listeners anymore
523 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
524 // and at least to us not firing any events anymore, in case somebody calls
525 // NotifyAccessibleEvent, again
526 sal_Int32 nId = m_nClientId;
527 m_nClientId = 0;
528 comphelper::AccessibleEventNotifier::revokeClient( nId );
533 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getCaretPosition( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
535 return -1;
537 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::setCaretPosition ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
539 SolarMutexGuard aSolarGuard;
540 ::osl::MutexGuard aGuard( m_aMutex );
541 EnsureIsAlive();
543 if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
544 throw IndexOutOfBoundsException();
546 return false;
548 sal_Unicode SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
550 SolarMutexGuard aSolarGuard;
551 ::osl::MutexGuard aGuard( m_aMutex );
552 EnsureIsAlive();
553 return OCommonAccessibleText::getCharacter( nIndex );
555 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< OUString >& ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
557 SolarMutexGuard aSolarGuard;
558 ::osl::MutexGuard aGuard( m_aMutex );
559 EnsureIsAlive();
561 OUString sText( implGetText() );
563 if ( !implIsValidIndex( nIndex, sText.getLength() ) )
564 throw IndexOutOfBoundsException();
566 return ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >();
568 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterCount( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
570 SolarMutexGuard aSolarGuard;
571 ::osl::MutexGuard aGuard( m_aMutex );
572 EnsureIsAlive();
573 return OCommonAccessibleText::getCharacterCount( );
576 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectedText( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
578 SolarMutexGuard aSolarGuard;
579 ::osl::MutexGuard aGuard( m_aMutex );
580 EnsureIsAlive();
581 return OCommonAccessibleText::getSelectedText( );
583 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectionStart( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
585 SolarMutexGuard aSolarGuard;
586 ::osl::MutexGuard aGuard( m_aMutex );
587 EnsureIsAlive();
588 return OCommonAccessibleText::getSelectionStart( );
590 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectionEnd( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
592 SolarMutexGuard aSolarGuard;
593 ::osl::MutexGuard aGuard( m_aMutex );
594 EnsureIsAlive();
595 return OCommonAccessibleText::getSelectionEnd( );
597 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
599 SolarMutexGuard aSolarGuard;
600 ::osl::MutexGuard aGuard( m_aMutex );
601 EnsureIsAlive();
603 if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
604 throw IndexOutOfBoundsException();
606 return false;
608 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getText( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
610 SolarMutexGuard aSolarGuard;
611 ::osl::MutexGuard aGuard( m_aMutex );
612 EnsureIsAlive();
613 return OCommonAccessibleText::getText( );
615 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
617 SolarMutexGuard aSolarGuard;
618 ::osl::MutexGuard aGuard( m_aMutex );
619 EnsureIsAlive();
620 return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
622 ::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, std::exception)
624 SolarMutexGuard aSolarGuard;
625 ::osl::MutexGuard aGuard( m_aMutex );
626 EnsureIsAlive();
627 return OCommonAccessibleText::getTextAtIndex( nIndex ,aTextType);
629 ::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, std::exception)
631 SolarMutexGuard aSolarGuard;
632 ::osl::MutexGuard aGuard( m_aMutex );
633 EnsureIsAlive();
634 return OCommonAccessibleText::getTextBeforeIndex( nIndex ,aTextType);
636 ::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, std::exception)
638 SolarMutexGuard aSolarGuard;
639 ::osl::MutexGuard aGuard( m_aMutex );
640 EnsureIsAlive();
642 return OCommonAccessibleText::getTextBehindIndex( nIndex ,aTextType);
646 // XAccessibleAction
648 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleActionCount( ) throw (RuntimeException, std::exception)
650 ::osl::MutexGuard aGuard( m_aMutex );
652 // three actions supported
653 return ACCESSIBLE_ACTION_COUNT;
656 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::doAccessibleAction( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
658 SolarMutexGuard aSolarGuard;
659 ::osl::MutexGuard aGuard( m_aMutex );
661 bool bRet = false;
662 checkActionIndex_Impl( nIndex );
663 EnsureIsAlive();
665 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
666 if ( pEntry && !pEntry->IsSelected() )
668 m_pIconCtrl->SetNoSelection();
669 m_pIconCtrl->SetCursor( pEntry );
670 bRet = true;
673 return bRet;
676 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleActionDescription( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
678 SolarMutexGuard aSolarGuard;
679 ::osl::MutexGuard aGuard( m_aMutex );
681 checkActionIndex_Impl( nIndex );
682 EnsureIsAlive();
684 return OUString( "Select" );
687 Reference< XAccessibleKeyBinding > AccessibleIconChoiceCtrlEntry::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
689 ::osl::MutexGuard aGuard( m_aMutex );
691 Reference< XAccessibleKeyBinding > xRet;
692 checkActionIndex_Impl( nIndex );
693 // ... which key?
694 return xRet;
697 }// namespace accessibility
700 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */