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 <extended/accessibleiconchoicectrlentry.hxx> 21 #include <vcl/toolkit/ivctrl.hxx> 22 #include <com/sun/star/awt/Rectangle.hpp> 23 #include <com/sun/star/accessibility/AccessibleRole.hpp> 24 #include <com/sun/star/accessibility/AccessibleStateType.hpp> 25 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> 26 #include <vcl/svapp.hxx> 27 #include <vcl/toolkit/controllayout.hxx> 28 #include <vcl/settings.hxx> 29 #include <toolkit/helper/convert.hxx> 30 #include <unotools/accessiblestatesethelper.hxx> 31 #include <unotools/accessiblerelationsethelper.hxx> 32 #include <cppuhelper/supportsservice.hxx> 33 #include <svtools/stringtransfer.hxx> 34 #include <comphelper/accessibleeventnotifier.hxx> 35 #include <i18nlangtag/languagetag.hxx> 36 37 #define ACCESSIBLE_ACTION_COUNT 1 38 39 namespace 40 { 41 /// @throws css::lang::IndexOutOfBoundsException checkActionIndex_Impl(sal_Int32 _nIndex)42 void checkActionIndex_Impl( sal_Int32 _nIndex ) 43 { 44 if ( _nIndex < 0 || _nIndex >= ACCESSIBLE_ACTION_COUNT ) 45 // only three actions 46 throw css::lang::IndexOutOfBoundsException(); 47 } 48 } 49 50 51 namespace accessibility 52 { 53 54 55 using namespace ::com::sun::star::accessibility; 56 using namespace ::com::sun::star::uno; 57 using namespace ::com::sun::star::lang; 58 using namespace ::com::sun::star; 59 60 61 // Ctor() and Dtor() 62 AccessibleIconChoiceCtrlEntry(SvtIconChoiceCtrl & _rIconCtrl,sal_Int32 _nPos,const Reference<XAccessible> & _xParent)63 AccessibleIconChoiceCtrlEntry::AccessibleIconChoiceCtrlEntry( SvtIconChoiceCtrl& _rIconCtrl, 64 sal_Int32 _nPos, 65 const Reference< XAccessible >& _xParent ) : 66 67 AccessibleIconChoiceCtrlEntry_BASE ( m_aMutex ), 68 69 m_pIconCtrl ( &_rIconCtrl ), 70 m_nIndex ( _nPos ), 71 m_nClientId ( 0 ), 72 m_xParent ( _xParent ) 73 74 { 75 osl_atomic_increment( &m_refCount ); 76 { 77 Reference< XComponent > xComp( m_xParent, UNO_QUERY ); 78 if ( xComp.is() ) 79 xComp->addEventListener( this ); 80 } 81 osl_atomic_decrement( &m_refCount ); 82 } 83 disposing(const css::lang::EventObject & _rSource)84 void AccessibleIconChoiceCtrlEntry::disposing( const css::lang::EventObject& _rSource ) 85 { 86 if ( _rSource.Source == m_xParent ) 87 { 88 dispose(); 89 OSL_ENSURE( !m_xParent.is() && ( m_pIconCtrl == nullptr ), "" ); 90 } 91 } 92 ~AccessibleIconChoiceCtrlEntry()93 AccessibleIconChoiceCtrlEntry::~AccessibleIconChoiceCtrlEntry() 94 { 95 if ( IsAlive_Impl() ) 96 { 97 // increment ref count to prevent double call of Dtor 98 osl_atomic_increment( &m_refCount ); 99 dispose(); 100 } 101 } 102 GetBoundingBox_Impl() const103 tools::Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBox_Impl() const 104 { 105 tools::Rectangle aRect; 106 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex ); 107 if ( pEntry ) 108 aRect = m_pIconCtrl->GetBoundingBox( pEntry ); 109 110 return aRect; 111 } 112 GetBoundingBoxOnScreen_Impl() const113 tools::Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBoxOnScreen_Impl() const 114 { 115 tools::Rectangle aRect; 116 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex ); 117 if ( pEntry ) 118 { 119 aRect = m_pIconCtrl->GetBoundingBox( pEntry ); 120 Point aTopLeft = aRect.TopLeft(); 121 aTopLeft += m_pIconCtrl->GetWindowExtentsRelative( nullptr ).TopLeft(); 122 aRect = tools::Rectangle( aTopLeft, aRect.GetSize() ); 123 } 124 125 return aRect; 126 } 127 IsAlive_Impl() const128 bool AccessibleIconChoiceCtrlEntry::IsAlive_Impl() const 129 { 130 return ( !rBHelper.bDisposed && !rBHelper.bInDispose && m_pIconCtrl ); 131 } 132 IsShowing_Impl() const133 bool AccessibleIconChoiceCtrlEntry::IsShowing_Impl() const 134 { 135 bool bShowing = false; 136 Reference< XAccessibleContext > xParentContext = 137 m_xParent.is() ? m_xParent->getAccessibleContext() : Reference< XAccessibleContext >(); 138 if( xParentContext.is() ) 139 { 140 Reference< XAccessibleComponent > xParentComp( xParentContext, uno::UNO_QUERY ); 141 if( xParentComp.is() ) 142 bShowing = GetBoundingBox_Impl().IsOver( VCLRectangle( xParentComp->getBounds() ) ); 143 } 144 145 return bShowing; 146 } 147 GetBoundingBox()148 tools::Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBox() 149 { 150 SolarMutexGuard aSolarGuard; 151 ::osl::MutexGuard aGuard( m_aMutex ); 152 153 EnsureIsAlive(); 154 return GetBoundingBox_Impl(); 155 } 156 GetBoundingBoxOnScreen()157 tools::Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBoxOnScreen() 158 { 159 SolarMutexGuard aSolarGuard; 160 ::osl::MutexGuard aGuard( m_aMutex ); 161 162 EnsureIsAlive(); 163 return GetBoundingBoxOnScreen_Impl(); 164 } 165 EnsureIsAlive() const166 void AccessibleIconChoiceCtrlEntry::EnsureIsAlive() const 167 { 168 if ( !IsAlive_Impl() ) 169 throw lang::DisposedException(); 170 } 171 implGetText()172 OUString AccessibleIconChoiceCtrlEntry::implGetText() 173 { 174 OUString sRet; 175 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex ); 176 if ( pEntry ) 177 sRet = pEntry->GetDisplayText(); 178 return sRet; 179 } 180 implGetLocale()181 Locale AccessibleIconChoiceCtrlEntry::implGetLocale() 182 { 183 return Application::GetSettings().GetUILanguageTag().getLocale(); 184 } implGetSelection(sal_Int32 & nStartIndex,sal_Int32 & nEndIndex)185 void AccessibleIconChoiceCtrlEntry::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) 186 { 187 nStartIndex = 0; 188 nEndIndex = 0; 189 } 190 191 // XTypeProvider 192 193 getImplementationId()194 Sequence< sal_Int8 > AccessibleIconChoiceCtrlEntry::getImplementationId() 195 { 196 return css::uno::Sequence<sal_Int8>(); 197 } 198 199 // XComponent 200 disposing()201 void SAL_CALL AccessibleIconChoiceCtrlEntry::disposing() 202 { 203 ::osl::MutexGuard aGuard( m_aMutex ); 204 205 // Send a disposing to all listeners. 206 if ( m_nClientId ) 207 { 208 sal_uInt32 nId = m_nClientId; 209 m_nClientId = 0; 210 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this ); 211 } 212 213 Reference< XComponent > xComp( m_xParent, UNO_QUERY ); 214 if ( xComp.is() ) 215 xComp->removeEventListener( this ); 216 217 m_pIconCtrl = nullptr; 218 m_xParent = nullptr; 219 } 220 221 // XServiceInfo 222 getImplementationName()223 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getImplementationName() 224 { 225 return "com.sun.star.comp.svtools.AccessibleIconChoiceControlEntry"; 226 } 227 getSupportedServiceNames()228 Sequence< OUString > SAL_CALL AccessibleIconChoiceCtrlEntry::getSupportedServiceNames() 229 { 230 return {"com.sun.star.accessibility.AccessibleContext", 231 "com.sun.star.accessibility.AccessibleComponent", 232 "com.sun.star.awt.AccessibleIconChoiceControlEntry"}; 233 } 234 supportsService(const OUString & _rServiceName)235 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::supportsService( const OUString& _rServiceName ) 236 { 237 return cppu::supportsService(this, _rServiceName); 238 } 239 240 // XAccessible 241 getAccessibleContext()242 Reference< XAccessibleContext > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleContext( ) 243 { 244 EnsureIsAlive(); 245 return this; 246 } 247 248 // XAccessibleContext 249 getAccessibleChildCount()250 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleChildCount( ) 251 { 252 return 0; // no children 253 } 254 getAccessibleChild(sal_Int32)255 Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleChild( sal_Int32 ) 256 { 257 throw IndexOutOfBoundsException(); 258 } 259 getAccessibleParent()260 Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleParent( ) 261 { 262 ::osl::MutexGuard aGuard( m_aMutex ); 263 264 EnsureIsAlive(); 265 return m_xParent; 266 } 267 getAccessibleIndexInParent()268 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleIndexInParent( ) 269 { 270 ::osl::MutexGuard aGuard( m_aMutex ); 271 272 return m_nIndex; 273 } 274 getAccessibleRole()275 sal_Int16 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleRole( ) 276 { 277 //return AccessibleRole::LABEL; 278 return AccessibleRole::LIST_ITEM; 279 } 280 getAccessibleDescription()281 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleDescription( ) 282 { 283 // no description for every item 284 return OUString(); 285 } 286 getAccessibleName()287 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleName( ) 288 { 289 ::osl::MutexGuard aGuard( m_aMutex ); 290 291 EnsureIsAlive(); 292 return implGetText(); 293 } 294 getAccessibleRelationSet()295 Reference< XAccessibleRelationSet > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleRelationSet( ) 296 { 297 return new utl::AccessibleRelationSetHelper; 298 } 299 getAccessibleStateSet()300 Reference< XAccessibleStateSet > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleStateSet( ) 301 { 302 SolarMutexGuard aSolarGuard; 303 ::osl::MutexGuard aGuard( m_aMutex ); 304 305 rtl::Reference<utl::AccessibleStateSetHelper> pStateSetHelper = new utl::AccessibleStateSetHelper; 306 307 if ( IsAlive_Impl() ) 308 { 309 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT ); 310 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE ); 311 pStateSetHelper->AddState( AccessibleStateType::ENABLED ); 312 pStateSetHelper->AddState( AccessibleStateType::SENSITIVE ); 313 if ( IsShowing_Impl() ) 314 { 315 pStateSetHelper->AddState( AccessibleStateType::SHOWING ); 316 pStateSetHelper->AddState( AccessibleStateType::VISIBLE ); 317 } 318 319 if ( m_pIconCtrl && m_pIconCtrl->GetCursor() == m_pIconCtrl->GetEntry( m_nIndex ) ) 320 pStateSetHelper->AddState( AccessibleStateType::SELECTED ); 321 } 322 else 323 pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); 324 325 return pStateSetHelper; 326 } 327 getLocale()328 Locale SAL_CALL AccessibleIconChoiceCtrlEntry::getLocale( ) 329 { 330 SolarMutexGuard aSolarGuard; 331 ::osl::MutexGuard aGuard( m_aMutex ); 332 333 return implGetLocale(); 334 } 335 336 // XAccessibleComponent 337 containsPoint(const awt::Point & rPoint)338 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::containsPoint( const awt::Point& rPoint ) 339 { 340 return tools::Rectangle( Point(), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) ); 341 } 342 getAccessibleAtPoint(const awt::Point &)343 Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleAtPoint( const awt::Point& ) 344 { 345 return Reference< XAccessible >(); 346 } 347 getBounds()348 awt::Rectangle SAL_CALL AccessibleIconChoiceCtrlEntry::getBounds( ) 349 { 350 return AWTRectangle( GetBoundingBox() ); 351 } 352 getLocation()353 awt::Point SAL_CALL AccessibleIconChoiceCtrlEntry::getLocation( ) 354 { 355 return AWTPoint( GetBoundingBox().TopLeft() ); 356 } 357 getLocationOnScreen()358 awt::Point SAL_CALL AccessibleIconChoiceCtrlEntry::getLocationOnScreen( ) 359 { 360 return AWTPoint( GetBoundingBoxOnScreen().TopLeft() ); 361 } 362 getSize()363 awt::Size SAL_CALL AccessibleIconChoiceCtrlEntry::getSize( ) 364 { 365 return AWTSize( GetBoundingBox().GetSize() ); 366 } 367 grabFocus()368 void SAL_CALL AccessibleIconChoiceCtrlEntry::grabFocus( ) 369 { 370 // do nothing, because no focus for each item 371 } 372 getForeground()373 sal_Int32 AccessibleIconChoiceCtrlEntry::getForeground( ) 374 { 375 SolarMutexGuard aSolarGuard; 376 ::osl::MutexGuard aGuard( m_aMutex ); 377 378 sal_Int32 nColor = 0; 379 Reference< XAccessible > xParent = getAccessibleParent(); 380 if ( xParent.is() ) 381 { 382 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY ); 383 if ( xParentComp.is() ) 384 nColor = xParentComp->getForeground(); 385 } 386 387 return nColor; 388 } 389 getBackground()390 sal_Int32 AccessibleIconChoiceCtrlEntry::getBackground( ) 391 { 392 SolarMutexGuard aSolarGuard; 393 ::osl::MutexGuard aGuard( m_aMutex ); 394 395 sal_Int32 nColor = 0; 396 Reference< XAccessible > xParent = getAccessibleParent(); 397 if ( xParent.is() ) 398 { 399 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY ); 400 if ( xParentComp.is() ) 401 nColor = xParentComp->getBackground(); 402 } 403 404 return nColor; 405 } 406 407 // XAccessibleText 408 409 getCharacterBounds(sal_Int32 _nIndex)410 awt::Rectangle SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterBounds( sal_Int32 _nIndex ) 411 { 412 SolarMutexGuard aSolarGuard; 413 ::osl::MutexGuard aGuard( m_aMutex ); 414 415 if ( ( 0 > _nIndex ) || ( implGetText().getLength() <= _nIndex ) ) 416 throw IndexOutOfBoundsException(); 417 418 awt::Rectangle aBounds( 0, 0, 0, 0 ); 419 if ( m_pIconCtrl ) 420 { 421 tools::Rectangle aItemRect = GetBoundingBox_Impl(); 422 tools::Rectangle aCharRect = m_pIconCtrl->GetEntryCharacterBounds( m_nIndex, _nIndex ); 423 aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() ); 424 aBounds = AWTRectangle( aCharRect ); 425 } 426 427 return aBounds; 428 } 429 getIndexAtPoint(const awt::Point & aPoint)430 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getIndexAtPoint( const awt::Point& aPoint ) 431 { 432 SolarMutexGuard aSolarGuard; 433 ::osl::MutexGuard aGuard( m_aMutex ); 434 435 sal_Int32 nIndex = -1; 436 if ( m_pIconCtrl ) 437 { 438 vcl::ControlLayoutData aLayoutData; 439 tools::Rectangle aItemRect = GetBoundingBox_Impl(); 440 m_pIconCtrl->RecordLayoutData( &aLayoutData, aItemRect ); 441 Point aPnt( VCLPoint( aPoint ) ); 442 aPnt += aItemRect.TopLeft(); 443 nIndex = aLayoutData.GetIndexForPoint( aPnt ); 444 445 tools::Long nLen = aLayoutData.m_aUnicodeBoundRects.size(); 446 for ( tools::Long i = 0; i < nLen; ++i ) 447 { 448 tools::Rectangle aRect = aLayoutData.GetCharacterBounds(i); 449 bool bInside = aRect.IsInside( aPnt ); 450 451 if ( bInside ) 452 break; 453 } 454 } 455 456 return nIndex; 457 } 458 copyText(sal_Int32 nStartIndex,sal_Int32 nEndIndex)459 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) 460 { 461 SolarMutexGuard aSolarGuard; 462 ::osl::MutexGuard aGuard( m_aMutex ); 463 EnsureIsAlive(); 464 465 OUString sText = implGetText(); 466 if ( ( 0 > nStartIndex ) || ( sText.getLength() <= nStartIndex ) 467 || ( 0 > nEndIndex ) || ( sText.getLength() <= nEndIndex ) ) 468 throw IndexOutOfBoundsException(); 469 470 sal_Int32 nLen = nEndIndex - nStartIndex + 1; 471 ::svt::OStringTransfer::CopyString( sText.copy( nStartIndex, nLen ), m_pIconCtrl ); 472 473 return true; 474 } 475 scrollSubstringTo(sal_Int32,sal_Int32,AccessibleScrollType)476 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::scrollSubstringTo( sal_Int32, sal_Int32, AccessibleScrollType ) 477 { 478 return false; 479 } 480 481 // XAccessibleEventBroadcaster 482 addAccessibleEventListener(const Reference<XAccessibleEventListener> & xListener)483 void SAL_CALL AccessibleIconChoiceCtrlEntry::addAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) 484 { 485 if (xListener.is()) 486 { 487 ::osl::MutexGuard aGuard( m_aMutex ); 488 if (!m_nClientId) 489 m_nClientId = comphelper::AccessibleEventNotifier::registerClient( ); 490 comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener ); 491 } 492 } 493 removeAccessibleEventListener(const Reference<XAccessibleEventListener> & xListener)494 void SAL_CALL AccessibleIconChoiceCtrlEntry::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) 495 { 496 if (!xListener.is()) 497 return; 498 499 ::osl::MutexGuard aGuard( m_aMutex ); 500 501 sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener ); 502 if ( !nListenerCount ) 503 { 504 // no listeners anymore 505 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), 506 // and at least to us not firing any events anymore, in case somebody calls 507 // NotifyAccessibleEvent, again 508 sal_Int32 nId = m_nClientId; 509 m_nClientId = 0; 510 comphelper::AccessibleEventNotifier::revokeClient( nId ); 511 } 512 } 513 getCaretPosition()514 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getCaretPosition( ) 515 { 516 return -1; 517 } setCaretPosition(sal_Int32 nIndex)518 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::setCaretPosition ( sal_Int32 nIndex ) 519 { 520 SolarMutexGuard aSolarGuard; 521 ::osl::MutexGuard aGuard( m_aMutex ); 522 EnsureIsAlive(); 523 524 if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) ) 525 throw IndexOutOfBoundsException(); 526 527 return false; 528 } getCharacter(sal_Int32 nIndex)529 sal_Unicode SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacter( sal_Int32 nIndex ) 530 { 531 SolarMutexGuard aSolarGuard; 532 ::osl::MutexGuard aGuard( m_aMutex ); 533 EnsureIsAlive(); 534 return OCommonAccessibleText::implGetCharacter( implGetText(), nIndex ); 535 } getCharacterAttributes(sal_Int32 nIndex,const css::uno::Sequence<OUString> &)536 css::uno::Sequence< css::beans::PropertyValue > SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& ) 537 { 538 SolarMutexGuard aSolarGuard; 539 ::osl::MutexGuard aGuard( m_aMutex ); 540 EnsureIsAlive(); 541 542 OUString sText( implGetText() ); 543 544 if ( !implIsValidIndex( nIndex, sText.getLength() ) ) 545 throw IndexOutOfBoundsException(); 546 547 return css::uno::Sequence< css::beans::PropertyValue >(); 548 } getCharacterCount()549 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterCount( ) 550 { 551 SolarMutexGuard aSolarGuard; 552 ::osl::MutexGuard aGuard( m_aMutex ); 553 EnsureIsAlive(); 554 return implGetText().getLength(); 555 } 556 getSelectedText()557 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectedText( ) 558 { 559 SolarMutexGuard aSolarGuard; 560 ::osl::MutexGuard aGuard( m_aMutex ); 561 EnsureIsAlive(); 562 return OUString(); 563 } getSelectionStart()564 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectionStart( ) 565 { 566 SolarMutexGuard aSolarGuard; 567 ::osl::MutexGuard aGuard( m_aMutex ); 568 EnsureIsAlive(); 569 return 0; 570 } getSelectionEnd()571 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectionEnd( ) 572 { 573 SolarMutexGuard aSolarGuard; 574 ::osl::MutexGuard aGuard( m_aMutex ); 575 EnsureIsAlive(); 576 return 0; 577 } setSelection(sal_Int32 nStartIndex,sal_Int32 nEndIndex)578 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) 579 { 580 SolarMutexGuard aSolarGuard; 581 ::osl::MutexGuard aGuard( m_aMutex ); 582 EnsureIsAlive(); 583 584 if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) ) 585 throw IndexOutOfBoundsException(); 586 587 return false; 588 } getText()589 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getText( ) 590 { 591 SolarMutexGuard aSolarGuard; 592 ::osl::MutexGuard aGuard( m_aMutex ); 593 EnsureIsAlive(); 594 return implGetText( ); 595 } getTextRange(sal_Int32 nStartIndex,sal_Int32 nEndIndex)596 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) 597 { 598 SolarMutexGuard aSolarGuard; 599 ::osl::MutexGuard aGuard( m_aMutex ); 600 EnsureIsAlive(); 601 return OCommonAccessibleText::implGetTextRange( implGetText(), nStartIndex, nEndIndex ); 602 } getTextAtIndex(sal_Int32 nIndex,sal_Int16 aTextType)603 css::accessibility::TextSegment SAL_CALL AccessibleIconChoiceCtrlEntry::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) 604 { 605 SolarMutexGuard aSolarGuard; 606 ::osl::MutexGuard aGuard( m_aMutex ); 607 EnsureIsAlive(); 608 return OCommonAccessibleText::getTextAtIndex( nIndex ,aTextType); 609 } getTextBeforeIndex(sal_Int32 nIndex,sal_Int16 aTextType)610 css::accessibility::TextSegment SAL_CALL AccessibleIconChoiceCtrlEntry::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) 611 { 612 SolarMutexGuard aSolarGuard; 613 ::osl::MutexGuard aGuard( m_aMutex ); 614 EnsureIsAlive(); 615 return OCommonAccessibleText::getTextBeforeIndex( nIndex ,aTextType); 616 } getTextBehindIndex(sal_Int32 nIndex,sal_Int16 aTextType)617 css::accessibility::TextSegment SAL_CALL AccessibleIconChoiceCtrlEntry::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) 618 { 619 SolarMutexGuard aSolarGuard; 620 ::osl::MutexGuard aGuard( m_aMutex ); 621 EnsureIsAlive(); 622 623 return OCommonAccessibleText::getTextBehindIndex( nIndex ,aTextType); 624 } 625 626 627 // XAccessibleAction 628 getAccessibleActionCount()629 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleActionCount( ) 630 { 631 ::osl::MutexGuard aGuard( m_aMutex ); 632 633 // three actions supported 634 return ACCESSIBLE_ACTION_COUNT; 635 } 636 doAccessibleAction(sal_Int32 nIndex)637 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::doAccessibleAction( sal_Int32 nIndex ) 638 { 639 SolarMutexGuard aSolarGuard; 640 ::osl::MutexGuard aGuard( m_aMutex ); 641 642 bool bRet = false; 643 checkActionIndex_Impl( nIndex ); 644 EnsureIsAlive(); 645 646 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex ); 647 if ( pEntry && !pEntry->IsSelected() ) 648 { 649 m_pIconCtrl->SetNoSelection(); 650 m_pIconCtrl->SetCursor( pEntry ); 651 bRet = true; 652 } 653 654 return bRet; 655 } 656 getAccessibleActionDescription(sal_Int32 nIndex)657 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleActionDescription( sal_Int32 nIndex ) 658 { 659 SolarMutexGuard aSolarGuard; 660 ::osl::MutexGuard aGuard( m_aMutex ); 661 662 checkActionIndex_Impl( nIndex ); 663 EnsureIsAlive(); 664 665 return "Select"; 666 } 667 getAccessibleActionKeyBinding(sal_Int32 nIndex)668 Reference< XAccessibleKeyBinding > AccessibleIconChoiceCtrlEntry::getAccessibleActionKeyBinding( sal_Int32 nIndex ) 669 { 670 ::osl::MutexGuard aGuard( m_aMutex ); 671 672 Reference< XAccessibleKeyBinding > xRet; 673 checkActionIndex_Impl( nIndex ); 674 // ... which key? 675 return xRet; 676 } 677 678 }// namespace accessibility 679 680 681 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 682