1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_accessibility.hxx" 26 #include <accessibility/standard/vclxaccessiblelistitem.hxx> 27 #include <toolkit/helper/convert.hxx> 28 #include <accessibility/helper/listboxhelper.hxx> 29 #include <com/sun/star/awt/Point.hpp> 30 #include <com/sun/star/awt/Rectangle.hpp> 31 #include <com/sun/star/awt/Size.hpp> 32 33 #include <com/sun/star/accessibility/AccessibleEventId.hpp> 34 #include <com/sun/star/accessibility/AccessibleRole.hpp> 35 #include <com/sun/star/accessibility/AccessibleStateType.hpp> 36 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> 37 #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp> 38 #include <tools/debug.hxx> 39 #include <vcl/svapp.hxx> 40 #include <vcl/controllayout.hxx> 41 #include <vcl/unohelp2.hxx> 42 #include <toolkit/awt/vclxwindow.hxx> 43 #include <unotools/accessiblestatesethelper.hxx> 44 #include <unotools/accessiblerelationsethelper.hxx> 45 #include <cppuhelper/typeprovider.hxx> 46 #include <comphelper/sequence.hxx> 47 #include <comphelper/accessibleeventnotifier.hxx> 48 49 namespace 50 { 51 void checkIndex_Impl( sal_Int32 _nIndex, const ::rtl::OUString& _sText ) throw (::com::sun::star::lang::IndexOutOfBoundsException) 52 { 53 if ( _nIndex < 0 || _nIndex > _sText.getLength() ) 54 throw ::com::sun::star::lang::IndexOutOfBoundsException(); 55 } 56 } 57 58 // class VCLXAccessibleListItem ------------------------------------------ 59 60 using namespace ::com::sun::star::accessibility; 61 using namespace ::com::sun::star::uno; 62 using namespace ::com::sun::star::beans; 63 using namespace ::com::sun::star::lang; 64 using namespace ::com::sun::star; 65 66 DBG_NAME(VCLXAccessibleListItem) 67 68 // ----------------------------------------------------------------------------- 69 // Ctor() and Dtor() 70 // ----------------------------------------------------------------------------- 71 VCLXAccessibleListItem::VCLXAccessibleListItem( ::accessibility::IComboListBoxHelper* _pListBoxHelper, sal_Int32 _nIndexInParent, const Reference< XAccessible >& _xParent ) : 72 73 VCLXAccessibleListItem_BASE ( m_aMutex ), 74 75 m_nIndexInParent( _nIndexInParent ), 76 m_bSelected ( sal_False ), 77 m_bVisible ( sal_False ), 78 m_nClientId ( 0 ), 79 m_pListBoxHelper( _pListBoxHelper ), 80 m_xParent ( _xParent ) 81 82 { 83 DBG_CTOR( VCLXAccessibleListItem, NULL ); 84 85 if ( m_xParent.is() ) 86 m_xParentContext = m_xParent->getAccessibleContext(); 87 88 if ( m_pListBoxHelper ) 89 m_sEntryText = m_pListBoxHelper->GetEntry( (sal_uInt16)_nIndexInParent ); 90 } 91 // ----------------------------------------------------------------------------- 92 VCLXAccessibleListItem::~VCLXAccessibleListItem() 93 { 94 DBG_DTOR( VCLXAccessibleListItem, NULL ); 95 } 96 // ----------------------------------------------------------------------------- 97 void VCLXAccessibleListItem::SetSelected( sal_Bool _bSelected ) 98 { 99 if ( m_bSelected != _bSelected ) 100 { 101 Any aOldValue; 102 Any aNewValue; 103 if ( m_bSelected ) 104 aOldValue <<= AccessibleStateType::SELECTED; 105 else 106 aNewValue <<= AccessibleStateType::SELECTED; 107 m_bSelected = _bSelected; 108 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); 109 } 110 } 111 // ----------------------------------------------------------------------------- 112 void VCLXAccessibleListItem::SetVisible( sal_Bool _bVisible ) 113 { 114 if ( m_bVisible != _bVisible ) 115 { 116 Any aOldValue, aNewValue; 117 m_bVisible = _bVisible; 118 (_bVisible ? aNewValue : aOldValue ) <<= AccessibleStateType::VISIBLE; 119 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); 120 (_bVisible ? aNewValue : aOldValue ) <<= AccessibleStateType::SHOWING; 121 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); 122 } 123 } 124 // ----------------------------------------------------------------------------- 125 void VCLXAccessibleListItem::NotifyAccessibleEvent( sal_Int16 _nEventId, 126 const ::com::sun::star::uno::Any& _aOldValue, 127 const ::com::sun::star::uno::Any& _aNewValue ) 128 { 129 AccessibleEventObject aEvt; 130 aEvt.Source = *this; 131 aEvt.EventId = _nEventId; 132 aEvt.OldValue = _aOldValue; 133 aEvt.NewValue = _aNewValue; 134 135 if (m_nClientId) 136 comphelper::AccessibleEventNotifier::addEvent( m_nClientId, aEvt ); 137 } 138 // ----------------------------------------------------------------------------- 139 // OCommonAccessibleText 140 // ----------------------------------------------------------------------------- 141 ::rtl::OUString VCLXAccessibleListItem::implGetText() 142 { 143 return m_sEntryText; 144 } 145 // ----------------------------------------------------------------------------- 146 Locale VCLXAccessibleListItem::implGetLocale() 147 { 148 return Application::GetSettings().GetLocale(); 149 } 150 // ----------------------------------------------------------------------------- 151 void VCLXAccessibleListItem::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) 152 { 153 nStartIndex = 0; 154 nEndIndex = 0; 155 } 156 // ----------------------------------------------------------------------------- 157 // XInterface 158 // ----------------------------------------------------------------------------- 159 Any SAL_CALL VCLXAccessibleListItem::queryInterface( Type const & rType ) throw (RuntimeException) 160 { 161 return VCLXAccessibleListItem_BASE::queryInterface( rType ); 162 } 163 // ----------------------------------------------------------------------------- 164 void SAL_CALL VCLXAccessibleListItem::acquire() throw () 165 { 166 VCLXAccessibleListItem_BASE::acquire(); 167 } 168 // ----------------------------------------------------------------------------- 169 void SAL_CALL VCLXAccessibleListItem::release() throw () 170 { 171 VCLXAccessibleListItem_BASE::release(); 172 } 173 // ----------------------------------------------------------------------------- 174 // XTypeProvider 175 // ----------------------------------------------------------------------------- 176 Sequence< Type > SAL_CALL VCLXAccessibleListItem::getTypes( ) throw (RuntimeException) 177 { 178 return VCLXAccessibleListItem_BASE::getTypes(); 179 } 180 // ----------------------------------------------------------------------------- 181 Sequence< sal_Int8 > VCLXAccessibleListItem::getImplementationId() throw (RuntimeException) 182 { 183 static ::cppu::OImplementationId* pId = NULL; 184 185 if ( !pId ) 186 { 187 ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); 188 189 if ( !pId ) 190 { 191 static ::cppu::OImplementationId aId; 192 pId = &aId; 193 } 194 } 195 return pId->getImplementationId(); 196 } 197 // ----------------------------------------------------------------------------- 198 // XComponent 199 // ----------------------------------------------------------------------------- 200 void SAL_CALL VCLXAccessibleListItem::disposing() 201 { 202 comphelper::AccessibleEventNotifier::TClientId nId( 0 ); 203 Reference< XInterface > xEventSource; 204 { 205 ::osl::MutexGuard aGuard( m_aMutex ); 206 207 VCLXAccessibleListItem_BASE::disposing(); 208 m_sEntryText = ::rtl::OUString(); 209 m_pListBoxHelper = NULL; 210 m_xParent = NULL; 211 m_xParentContext = NULL; 212 213 nId = m_nClientId; 214 m_nClientId = 0; 215 if ( nId ) 216 xEventSource = *this; 217 } 218 219 // Send a disposing to all listeners. 220 if ( nId ) 221 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this ); 222 } 223 // ----------------------------------------------------------------------------- 224 // XServiceInfo 225 // ----------------------------------------------------------------------------- 226 ::rtl::OUString VCLXAccessibleListItem::getImplementationName() throw (RuntimeException) 227 { 228 return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleListItem" ); 229 } 230 // ----------------------------------------------------------------------------- 231 sal_Bool VCLXAccessibleListItem::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException) 232 { 233 Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() ); 234 const ::rtl::OUString* pNames = aNames.getConstArray(); 235 const ::rtl::OUString* pEnd = pNames + aNames.getLength(); 236 for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames ) 237 ; 238 239 return pNames != pEnd; 240 } 241 // ----------------------------------------------------------------------------- 242 Sequence< ::rtl::OUString > VCLXAccessibleListItem::getSupportedServiceNames() throw (RuntimeException) 243 { 244 Sequence< ::rtl::OUString > aNames(3); 245 aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleContext" ); 246 aNames[1] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleComponent" ); 247 aNames[2] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleListItem" ); 248 return aNames; 249 } 250 // ----------------------------------------------------------------------------- 251 // XAccessible 252 // ----------------------------------------------------------------------------- 253 Reference< XAccessibleContext > SAL_CALL VCLXAccessibleListItem::getAccessibleContext( ) throw (RuntimeException) 254 { 255 return this; 256 } 257 // ----------------------------------------------------------------------------- 258 // XAccessibleContext 259 // ----------------------------------------------------------------------------- 260 sal_Int32 SAL_CALL VCLXAccessibleListItem::getAccessibleChildCount( ) throw (RuntimeException) 261 { 262 return 0; 263 } 264 // ----------------------------------------------------------------------------- 265 Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleChild( sal_Int32 ) throw (RuntimeException) 266 { 267 return Reference< XAccessible >(); 268 } 269 // ----------------------------------------------------------------------------- 270 Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleParent( ) throw (RuntimeException) 271 { 272 ::osl::MutexGuard aGuard( m_aMutex ); 273 274 return m_xParent; 275 } 276 // ----------------------------------------------------------------------------- 277 sal_Int32 SAL_CALL VCLXAccessibleListItem::getAccessibleIndexInParent( ) throw (RuntimeException) 278 { 279 ::osl::MutexGuard aGuard( m_aMutex ); 280 return m_nIndexInParent; 281 } 282 // ----------------------------------------------------------------------------- 283 sal_Int16 SAL_CALL VCLXAccessibleListItem::getAccessibleRole( ) throw (RuntimeException) 284 { 285 return AccessibleRole::LIST_ITEM; 286 // return AccessibleRole::LABEL; 287 } 288 // ----------------------------------------------------------------------------- 289 ::rtl::OUString SAL_CALL VCLXAccessibleListItem::getAccessibleDescription( ) throw (RuntimeException) 290 { 291 // no description for every item 292 return ::rtl::OUString(); 293 } 294 // ----------------------------------------------------------------------------- 295 ::rtl::OUString SAL_CALL VCLXAccessibleListItem::getAccessibleName( ) throw (RuntimeException) 296 { 297 ::osl::MutexGuard aGuard( m_aMutex ); 298 299 // entry text == accessible name 300 return implGetText(); 301 } 302 // ----------------------------------------------------------------------------- 303 Reference< XAccessibleRelationSet > SAL_CALL VCLXAccessibleListItem::getAccessibleRelationSet( ) throw (RuntimeException) 304 { 305 utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; 306 Reference< XAccessibleRelationSet > xSet = pRelationSetHelper; 307 return xSet; 308 } 309 // ----------------------------------------------------------------------------- 310 Reference< XAccessibleStateSet > SAL_CALL VCLXAccessibleListItem::getAccessibleStateSet( ) throw (RuntimeException) 311 { 312 ::osl::MutexGuard aGuard( m_aMutex ); 313 314 utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; 315 Reference< XAccessibleStateSet > xStateSet = pStateSetHelper; 316 317 if ( !rBHelper.bDisposed && !rBHelper.bInDispose ) 318 { 319 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT ); 320 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE ); 321 pStateSetHelper->AddState( AccessibleStateType::ENABLED ); 322 pStateSetHelper->AddState( AccessibleStateType::SENSITIVE ); 323 if ( m_bSelected ) 324 pStateSetHelper->AddState( AccessibleStateType::SELECTED ); 325 if ( m_bVisible ) 326 { 327 pStateSetHelper->AddState( AccessibleStateType::VISIBLE ); 328 pStateSetHelper->AddState( AccessibleStateType::SHOWING ); 329 } 330 } 331 else 332 pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); 333 334 return xStateSet; 335 } 336 // ----------------------------------------------------------------------------- 337 Locale SAL_CALL VCLXAccessibleListItem::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException) 338 { 339 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 340 ::osl::MutexGuard aGuard( m_aMutex ); 341 342 return implGetLocale(); 343 } 344 // ----------------------------------------------------------------------------- 345 // XAccessibleComponent 346 // ----------------------------------------------------------------------------- 347 sal_Bool SAL_CALL VCLXAccessibleListItem::containsPoint( const awt::Point& _aPoint ) throw (RuntimeException) 348 { 349 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 350 ::osl::MutexGuard aGuard( m_aMutex ); 351 352 sal_Bool bInside = sal_False; 353 if ( m_pListBoxHelper ) 354 { 355 Rectangle aRect( m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ) ); 356 aRect.Move(-aRect.TopLeft().X(),-aRect.TopLeft().Y()); 357 bInside = aRect.IsInside( VCLPoint( _aPoint ) ); 358 } 359 return bInside; 360 } 361 // ----------------------------------------------------------------------------- 362 Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException) 363 { 364 return Reference< XAccessible >(); 365 } 366 // ----------------------------------------------------------------------------- 367 awt::Rectangle SAL_CALL VCLXAccessibleListItem::getBounds( ) throw (RuntimeException) 368 { 369 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 370 ::osl::MutexGuard aGuard( m_aMutex ); 371 372 awt::Rectangle aRect; 373 if ( m_pListBoxHelper ) 374 aRect = AWTRectangle( m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ) ); 375 376 return aRect; 377 } 378 // ----------------------------------------------------------------------------- 379 awt::Point SAL_CALL VCLXAccessibleListItem::getLocation( ) throw (RuntimeException) 380 { 381 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 382 ::osl::MutexGuard aGuard( m_aMutex ); 383 384 Point aPoint(0,0); 385 if ( m_pListBoxHelper ) 386 { 387 Rectangle aRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ); 388 aPoint = aRect.TopLeft(); 389 } 390 return AWTPoint( aPoint ); 391 } 392 // ----------------------------------------------------------------------------- 393 awt::Point SAL_CALL VCLXAccessibleListItem::getLocationOnScreen( ) throw (RuntimeException) 394 { 395 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 396 ::osl::MutexGuard aGuard( m_aMutex ); 397 398 Point aPoint(0,0); 399 if ( m_pListBoxHelper ) 400 { 401 Rectangle aRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ); 402 aPoint = aRect.TopLeft(); 403 aPoint += m_pListBoxHelper->GetWindowExtentsRelative( NULL ).TopLeft(); 404 } 405 return AWTPoint( aPoint ); 406 } 407 // ----------------------------------------------------------------------------- 408 awt::Size SAL_CALL VCLXAccessibleListItem::getSize( ) throw (RuntimeException) 409 { 410 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 411 ::osl::MutexGuard aGuard( m_aMutex ); 412 413 Size aSize; 414 if ( m_pListBoxHelper ) 415 aSize = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ).GetSize(); 416 417 return AWTSize( aSize ); 418 } 419 // ----------------------------------------------------------------------------- 420 void SAL_CALL VCLXAccessibleListItem::grabFocus( ) throw (RuntimeException) 421 { 422 // no focus for each item 423 } 424 // ----------------------------------------------------------------------------- 425 // XAccessibleText 426 // ----------------------------------------------------------------------------- 427 sal_Int32 SAL_CALL VCLXAccessibleListItem::getCaretPosition() throw (RuntimeException) 428 { 429 return -1; 430 } 431 // ----------------------------------------------------------------------------- 432 sal_Bool SAL_CALL VCLXAccessibleListItem::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 433 { 434 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 435 ::osl::MutexGuard aGuard( m_aMutex ); 436 437 if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) ) 438 throw IndexOutOfBoundsException(); 439 440 return sal_False; 441 } 442 // ----------------------------------------------------------------------------- 443 sal_Unicode SAL_CALL VCLXAccessibleListItem::getCharacter( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 444 { 445 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 446 ::osl::MutexGuard aGuard( m_aMutex ); 447 448 return OCommonAccessibleText::getCharacter( nIndex ); 449 } 450 // ----------------------------------------------------------------------------- 451 Sequence< PropertyValue > SAL_CALL VCLXAccessibleListItem::getCharacterAttributes( sal_Int32 nIndex, const Sequence< ::rtl::OUString >& ) throw (IndexOutOfBoundsException, RuntimeException) 452 { 453 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 454 ::osl::MutexGuard aGuard( m_aMutex ); 455 456 ::rtl::OUString sText( implGetText() ); 457 if ( !implIsValidIndex( nIndex, sText.getLength() ) ) 458 throw IndexOutOfBoundsException(); 459 460 return Sequence< PropertyValue >(); 461 } 462 // ----------------------------------------------------------------------------- 463 awt::Rectangle SAL_CALL VCLXAccessibleListItem::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 464 { 465 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 466 ::osl::MutexGuard aGuard( m_aMutex ); 467 468 ::rtl::OUString sText( implGetText() ); 469 if ( !implIsValidIndex( nIndex, sText.getLength() ) ) 470 throw IndexOutOfBoundsException(); 471 472 awt::Rectangle aBounds( 0, 0, 0, 0 ); 473 if ( m_pListBoxHelper ) 474 { 475 Rectangle aCharRect = m_pListBoxHelper->GetEntryCharacterBounds( m_nIndexInParent, nIndex ); 476 Rectangle aItemRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ); 477 aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() ); 478 aBounds = AWTRectangle( aCharRect ); 479 } 480 481 return aBounds; 482 } 483 // ----------------------------------------------------------------------------- 484 sal_Int32 SAL_CALL VCLXAccessibleListItem::getCharacterCount() throw (RuntimeException) 485 { 486 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 487 ::osl::MutexGuard aGuard( m_aMutex ); 488 489 return OCommonAccessibleText::getCharacterCount(); 490 } 491 // ----------------------------------------------------------------------------- 492 sal_Int32 SAL_CALL VCLXAccessibleListItem::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException) 493 { 494 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 495 ::osl::MutexGuard aGuard( m_aMutex ); 496 497 sal_Int32 nIndex = -1; 498 if ( m_pListBoxHelper ) 499 { 500 sal_uInt16 nPos = LISTBOX_ENTRY_NOTFOUND; 501 Rectangle aItemRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ); 502 Point aPnt( VCLPoint( aPoint ) ); 503 aPnt += aItemRect.TopLeft(); 504 sal_Int32 nI = m_pListBoxHelper->GetIndexForPoint( aPnt, nPos ); 505 if ( nI != -1 && (sal_uInt16)m_nIndexInParent == nPos ) 506 nIndex = nI; 507 } 508 return nIndex; 509 } 510 // ----------------------------------------------------------------------------- 511 ::rtl::OUString SAL_CALL VCLXAccessibleListItem::getSelectedText() throw (RuntimeException) 512 { 513 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 514 ::osl::MutexGuard aGuard( m_aMutex ); 515 516 return OCommonAccessibleText::getSelectedText(); 517 } 518 // ----------------------------------------------------------------------------- 519 sal_Int32 SAL_CALL VCLXAccessibleListItem::getSelectionStart() throw (RuntimeException) 520 { 521 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 522 ::osl::MutexGuard aGuard( m_aMutex ); 523 524 return OCommonAccessibleText::getSelectionStart(); 525 } 526 // ----------------------------------------------------------------------------- 527 sal_Int32 SAL_CALL VCLXAccessibleListItem::getSelectionEnd() throw (RuntimeException) 528 { 529 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 530 ::osl::MutexGuard aGuard( m_aMutex ); 531 532 return OCommonAccessibleText::getSelectionEnd(); 533 } 534 // ----------------------------------------------------------------------------- 535 sal_Bool SAL_CALL VCLXAccessibleListItem::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException) 536 { 537 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 538 ::osl::MutexGuard aGuard( m_aMutex ); 539 540 if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) ) 541 throw IndexOutOfBoundsException(); 542 543 return sal_False; 544 } 545 // ----------------------------------------------------------------------------- 546 ::rtl::OUString SAL_CALL VCLXAccessibleListItem::getText() throw (RuntimeException) 547 { 548 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 549 ::osl::MutexGuard aGuard( m_aMutex ); 550 551 return OCommonAccessibleText::getText(); 552 } 553 // ----------------------------------------------------------------------------- 554 ::rtl::OUString SAL_CALL VCLXAccessibleListItem::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException) 555 { 556 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 557 ::osl::MutexGuard aGuard( m_aMutex ); 558 559 return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex ); 560 } 561 // ----------------------------------------------------------------------------- 562 ::com::sun::star::accessibility::TextSegment SAL_CALL VCLXAccessibleListItem::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 563 { 564 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 565 ::osl::MutexGuard aGuard( m_aMutex ); 566 567 return OCommonAccessibleText::getTextAtIndex( nIndex, aTextType ); 568 } 569 // ----------------------------------------------------------------------------- 570 ::com::sun::star::accessibility::TextSegment SAL_CALL VCLXAccessibleListItem::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 571 { 572 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 573 ::osl::MutexGuard aGuard( m_aMutex ); 574 575 return OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType ); 576 } 577 // ----------------------------------------------------------------------------- 578 ::com::sun::star::accessibility::TextSegment SAL_CALL VCLXAccessibleListItem::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 579 { 580 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 581 ::osl::MutexGuard aGuard( m_aMutex ); 582 583 return OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType ); 584 } 585 // ----------------------------------------------------------------------------- 586 sal_Bool SAL_CALL VCLXAccessibleListItem::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException) 587 { 588 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 589 ::osl::MutexGuard aGuard( m_aMutex ); 590 591 checkIndex_Impl( nStartIndex, m_sEntryText ); 592 checkIndex_Impl( nEndIndex, m_sEntryText ); 593 594 sal_Bool bRet = sal_False; 595 if ( m_pListBoxHelper ) 596 { 597 Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pListBoxHelper->GetClipboard(); 598 if ( xClipboard.is() ) 599 { 600 ::rtl::OUString sText( getTextRange( nStartIndex, nEndIndex ) ); 601 ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText ); 602 603 const sal_uInt32 nRef = Application::ReleaseSolarMutex(); 604 xClipboard->setContents( pDataObj, NULL ); 605 Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY ); 606 if( xFlushableClipboard.is() ) 607 xFlushableClipboard->flushClipboard(); 608 Application::AcquireSolarMutex( nRef ); 609 610 bRet = sal_True; 611 } 612 } 613 614 return bRet; 615 } 616 // ----------------------------------------------------------------------------- 617 // XAccessibleEventBroadcaster 618 // ----------------------------------------------------------------------------- 619 void SAL_CALL VCLXAccessibleListItem::addEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException) 620 { 621 if (xListener.is()) 622 { 623 if (!m_nClientId) 624 m_nClientId = comphelper::AccessibleEventNotifier::registerClient( ); 625 comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener ); 626 } 627 } 628 // ----------------------------------------------------------------------------- 629 void SAL_CALL VCLXAccessibleListItem::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException) 630 { 631 if ( xListener.is() && m_nClientId ) 632 { 633 sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener ); 634 if ( !nListenerCount ) 635 { 636 // no listeners anymore 637 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), 638 // and at least to us not firing any events anymore, in case somebody calls 639 // NotifyAccessibleEvent, again 640 if ( m_nClientId ) 641 { 642 comphelper::AccessibleEventNotifier::TClientId nId( m_nClientId ); 643 m_nClientId = 0; 644 comphelper::AccessibleEventNotifier::revokeClient( nId ); 645 } 646 } 647 } 648 } 649 // ----------------------------------------------------------------------------- 650 651 652 653 // AF (Oct. 29 2002): Return black as constant foreground color. This is an 654 // initial implementation and has to be substituted by code that determines 655 // the color that is actually used. 656 sal_Int32 SAL_CALL VCLXAccessibleListItem::getForeground (void) 657 throw (::com::sun::star::uno::RuntimeException) 658 { 659 return COL_BLACK; 660 } 661 662 // AF (Oct. 29 2002): Return white as constant background color. This is an 663 // initial implementation and has to be substituted by code that determines 664 // the color that is actually used. 665 sal_Int32 SAL_CALL VCLXAccessibleListItem::getBackground (void) 666 throw (::com::sun::star::uno::RuntimeException) 667 { 668 return COL_WHITE; 669 } 670 // ----------------------------------------------------------------------------- 671