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/extended/accessiblelistboxentry.hxx" 27 #include <svtools/svtreebx.hxx> 28 #include <accessibility/helper/accresmgr.hxx> 29 #include <svtools/stringtransfer.hxx> 30 #include <com/sun/star/awt/Point.hpp> 31 #include <com/sun/star/awt/Rectangle.hpp> 32 #include <com/sun/star/awt/Size.hpp> 33 #include <com/sun/star/accessibility/AccessibleEventId.hpp> 34 #include <com/sun/star/accessibility/AccessibleRelationType.hpp> 35 #include <com/sun/star/accessibility/AccessibleRole.hpp> 36 #include <com/sun/star/accessibility/AccessibleStateType.hpp> 37 #include <tools/debug.hxx> 38 #include <vcl/svapp.hxx> 39 #include <vcl/controllayout.hxx> 40 #include <toolkit/awt/vclxwindow.hxx> 41 #include <toolkit/helper/convert.hxx> 42 #include <unotools/accessiblestatesethelper.hxx> 43 #include <unotools/accessiblerelationsethelper.hxx> 44 #include <cppuhelper/typeprovider.hxx> 45 #include <comphelper/sequence.hxx> 46 #include <comphelper/accessibleeventnotifier.hxx> 47 #include <toolkit/helper/vclunohelper.hxx> 48 #include <accessibility/helper/accessiblestrings.hrc> 49 #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLEVALUE_HPP_ 50 #include <com/sun/star/accessibility/XAccessibleValue.hpp> 51 #endif 52 #define ACCESSIBLE_ACTION_COUNT 1 53 54 namespace 55 { 56 void checkActionIndex_Impl( sal_Int32 _nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException) 57 { 58 if ( _nIndex < 0 || _nIndex >= ACCESSIBLE_ACTION_COUNT ) 59 // only three actions 60 throw ::com::sun::star::lang::IndexOutOfBoundsException(); 61 } 62 } 63 64 //........................................................................ 65 namespace accessibility 66 { 67 //........................................................................ 68 // class ALBSolarGuard --------------------------------------------------------- 69 70 /** Aquire the solar mutex. */ 71 class ALBSolarGuard : public ::vos::OGuard 72 { 73 public: 74 inline ALBSolarGuard() : ::vos::OGuard( Application::GetSolarMutex() ) {} 75 }; 76 77 // class AccessibleListBoxEntry ----------------------------------------------------- 78 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; 83 using namespace ::comphelper; 84 DBG_NAME(AccessibleListBoxEntry) 85 86 // ----------------------------------------------------------------------------- 87 // Ctor() and Dtor() 88 // ----------------------------------------------------------------------------- 89 AccessibleListBoxEntry::AccessibleListBoxEntry( SvTreeListBox& _rListBox, 90 SvLBoxEntry* _pEntry, 91 const Reference< XAccessible >& _xParent ) : 92 93 AccessibleListBoxEntry_BASE ( m_aMutex ), 94 ListBoxAccessibleBase( _rListBox ), 95 96 m_pSvLBoxEntry ( _pEntry ), 97 m_nClientId ( 0 ), 98 m_aParent ( _xParent ) 99 100 { 101 DBG_CTOR( AccessibleListBoxEntry, NULL ); 102 103 _rListBox.FillEntryPath( _pEntry, m_aEntryPath ); 104 } 105 // ----------------------------------------------------------------------------- 106 AccessibleListBoxEntry::~AccessibleListBoxEntry() 107 { 108 DBG_DTOR( AccessibleListBoxEntry, NULL ); 109 110 if ( IsAlive_Impl() ) 111 { 112 // increment ref count to prevent double call of Dtor 113 osl_incrementInterlockedCount( &m_refCount ); 114 dispose(); 115 } 116 } 117 118 // IA2 CWS 119 void AccessibleListBoxEntry::NotifyAccessibleEvent( sal_Int16 _nEventId, 120 const ::com::sun::star::uno::Any& _aOldValue, 121 const ::com::sun::star::uno::Any& _aNewValue ) 122 { 123 Reference< uno::XInterface > xSource( *this ); 124 AccessibleEventObject aEventObj( xSource, _nEventId, _aNewValue, _aOldValue ); 125 126 if (m_nClientId) 127 comphelper::AccessibleEventNotifier::addEvent( m_nClientId, aEventObj ); 128 } 129 130 131 // ----------------------------------------------------------------------------- 132 Rectangle AccessibleListBoxEntry::GetBoundingBox_Impl() const 133 { 134 Rectangle aRect; 135 SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 136 if ( pEntry ) 137 { 138 aRect = getListBox()->GetBoundingRect( pEntry ); 139 SvLBoxEntry* pParent = getListBox()->GetParent( pEntry ); 140 if ( pParent ) 141 { 142 // position relative to parent entry 143 Point aTopLeft = aRect.TopLeft(); 144 aTopLeft -= getListBox()->GetBoundingRect( pParent ).TopLeft(); 145 aRect = Rectangle( aTopLeft, aRect.GetSize() ); 146 } 147 } 148 149 return aRect; 150 } 151 // ----------------------------------------------------------------------------- 152 Rectangle AccessibleListBoxEntry::GetBoundingBoxOnScreen_Impl() const 153 { 154 Rectangle aRect; 155 SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 156 if ( pEntry ) 157 { 158 aRect = getListBox()->GetBoundingRect( pEntry ); 159 Point aTopLeft = aRect.TopLeft(); 160 aTopLeft += getListBox()->GetWindowExtentsRelative( NULL ).TopLeft(); 161 aRect = Rectangle( aTopLeft, aRect.GetSize() ); 162 } 163 164 return aRect; 165 } 166 // ----------------------------------------------------------------------------- 167 sal_Bool AccessibleListBoxEntry::IsAlive_Impl() const 168 { 169 return ( !rBHelper.bDisposed && !rBHelper.bInDispose && isAlive() ); 170 } 171 // ----------------------------------------------------------------------------- 172 sal_Bool AccessibleListBoxEntry::IsShowing_Impl() const 173 { 174 Reference< XAccessible > xParent = implGetParentAccessible( ); 175 176 sal_Bool bShowing = sal_False; 177 Reference< XAccessibleContext > m_xParentContext = 178 xParent.is() ? xParent->getAccessibleContext() : Reference< XAccessibleContext >(); 179 if( m_xParentContext.is() ) 180 { 181 Reference< XAccessibleComponent > xParentComp( m_xParentContext, uno::UNO_QUERY ); 182 if( xParentComp.is() ) 183 bShowing = GetBoundingBox_Impl().IsOver( VCLRectangle( xParentComp->getBounds() ) ); 184 } 185 186 return bShowing; 187 } 188 // ----------------------------------------------------------------------------- 189 Rectangle AccessibleListBoxEntry::GetBoundingBox() throw ( lang::DisposedException ) 190 { 191 ALBSolarGuard aSolarGuard; 192 ::osl::MutexGuard aGuard( m_aMutex ); 193 194 EnsureIsAlive(); 195 return GetBoundingBox_Impl(); 196 } 197 // ----------------------------------------------------------------------------- 198 Rectangle AccessibleListBoxEntry::GetBoundingBoxOnScreen() throw ( lang::DisposedException ) 199 { 200 ALBSolarGuard aSolarGuard; 201 ::osl::MutexGuard aGuard( m_aMutex ); 202 203 EnsureIsAlive(); 204 return GetBoundingBoxOnScreen_Impl(); 205 } 206 // ----------------------------------------------------------------------------- 207 void AccessibleListBoxEntry::EnsureIsAlive() const throw ( lang::DisposedException ) 208 { 209 if ( !IsAlive_Impl() ) 210 throw lang::DisposedException(); 211 } 212 // ----------------------------------------------------------------------------- 213 ::rtl::OUString AccessibleListBoxEntry::implGetText() 214 { 215 ::rtl::OUString sRet; 216 SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 217 //IAccessibility2 Implementation 2009----- 218 if ( pEntry ) 219 sRet = getListBox()->SearchEntryTextWithHeadTitle( pEntry ); 220 //-----IAccessibility2 Implementation 2009 221 return sRet; 222 } 223 // ----------------------------------------------------------------------------- 224 Locale AccessibleListBoxEntry::implGetLocale() 225 { 226 Locale aLocale; 227 aLocale = Application::GetSettings().GetUILocale(); 228 229 return aLocale; 230 } 231 void AccessibleListBoxEntry::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) 232 { 233 nStartIndex = 0; 234 nEndIndex = 0; 235 } 236 // ----------------------------------------------------------------------------- 237 // XTypeProvider 238 // ----------------------------------------------------------------------------- 239 // ----------------------------------------------------------------------------- 240 Sequence< sal_Int8 > AccessibleListBoxEntry::getImplementationId() throw (RuntimeException) 241 { 242 static ::cppu::OImplementationId* pId = NULL; 243 244 if ( !pId ) 245 { 246 ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); 247 248 if ( !pId ) 249 { 250 static ::cppu::OImplementationId aId; 251 pId = &aId; 252 } 253 } 254 return pId->getImplementationId(); 255 } 256 257 // ----------------------------------------------------------------------------- 258 // XComponent/ListBoxAccessibleBase 259 // ----------------------------------------------------------------------------- 260 void SAL_CALL AccessibleListBoxEntry::dispose() throw ( uno::RuntimeException ) 261 { 262 AccessibleListBoxEntry_BASE::dispose(); 263 } 264 265 // ----------------------------------------------------------------------------- 266 // XComponent 267 // ----------------------------------------------------------------------------- 268 void SAL_CALL AccessibleListBoxEntry::disposing() 269 { 270 ALBSolarGuard(); 271 ::osl::MutexGuard aGuard( m_aMutex ); 272 273 Reference< XAccessible > xKeepAlive( this ); 274 275 // Send a disposing to all listeners. 276 if ( m_nClientId ) 277 { 278 ::comphelper::AccessibleEventNotifier::TClientId nId = m_nClientId; 279 m_nClientId = 0; 280 ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this ); 281 } 282 283 // clean up 284 { 285 286 ListBoxAccessibleBase::disposing(); 287 } 288 m_aParent = WeakReference< XAccessible >(); 289 } 290 // ----------------------------------------------------------------------------- 291 // XServiceInfo 292 // ----------------------------------------------------------------------------- 293 ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getImplementationName() throw(RuntimeException) 294 { 295 return getImplementationName_Static(); 296 } 297 // ----------------------------------------------------------------------------- 298 Sequence< ::rtl::OUString > SAL_CALL AccessibleListBoxEntry::getSupportedServiceNames() throw(RuntimeException) 299 { 300 return getSupportedServiceNames_Static(); 301 } 302 // ----------------------------------------------------------------------------- 303 sal_Bool SAL_CALL AccessibleListBoxEntry::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException) 304 { 305 Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() ); 306 const ::rtl::OUString* pSupported = aSupported.getConstArray(); 307 const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); 308 for ( ; pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported ) 309 ; 310 311 return pSupported != pEnd; 312 } 313 // ----------------------------------------------------------------------------- 314 // XServiceInfo - static methods 315 // ----------------------------------------------------------------------------- 316 Sequence< ::rtl::OUString > AccessibleListBoxEntry::getSupportedServiceNames_Static(void) throw( RuntimeException ) 317 { 318 Sequence< ::rtl::OUString > aSupported(3); 319 aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleContext") ); 320 aSupported[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleComponent") ); 321 aSupported[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.AccessibleTreeListBoxEntry") ); 322 return aSupported; 323 } 324 // ----------------------------------------------------------------------------- 325 ::rtl::OUString AccessibleListBoxEntry::getImplementationName_Static(void) throw( RuntimeException ) 326 { 327 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.svtools.AccessibleTreeListBoxEntry") ); 328 } 329 // ----------------------------------------------------------------------------- 330 // XAccessible 331 // ----------------------------------------------------------------------------- 332 Reference< XAccessibleContext > SAL_CALL AccessibleListBoxEntry::getAccessibleContext( ) throw (RuntimeException) 333 { 334 EnsureIsAlive(); 335 return this; 336 } 337 // ----------------------------------------------------------------------------- 338 // XAccessibleContext 339 // ----------------------------------------------------------------------------- 340 sal_Int32 SAL_CALL AccessibleListBoxEntry::getAccessibleChildCount( ) throw (RuntimeException) 341 { 342 ALBSolarGuard aSolarGuard; 343 ::osl::MutexGuard aGuard( m_aMutex ); 344 345 EnsureIsAlive(); 346 SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 347 sal_Int32 nCount = 0; 348 if ( pEntry ) 349 nCount = getListBox()->GetLevelChildCount( pEntry ); 350 351 return nCount; 352 } 353 // ----------------------------------------------------------------------------- 354 Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException,RuntimeException) 355 { 356 ALBSolarGuard aSolarGuard; 357 ::osl::MutexGuard aGuard( m_aMutex ); 358 EnsureIsAlive(); 359 360 // SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 361 // SvLBoxEntry* pEntry = pParent ? getListBox()->GetEntry( pParent, i ) : NULL; 362 SvLBoxEntry* pEntry =GetRealChild(i); 363 if ( !pEntry ) 364 throw IndexOutOfBoundsException(); 365 366 return new AccessibleListBoxEntry( *getListBox(), pEntry, this ); 367 } 368 369 // ----------------------------------------------------------------------------- 370 Reference< XAccessible > AccessibleListBoxEntry::implGetParentAccessible( ) const 371 { 372 Reference< XAccessible > xParent = (Reference< XAccessible >)m_aParent; 373 if ( !xParent.is() ) 374 { 375 DBG_ASSERT( m_aEntryPath.size(), "AccessibleListBoxEntry::getAccessibleParent: invalid path!" ); 376 if ( 1 == m_aEntryPath.size() ) 377 { // we're a top level entry 378 // -> our parent is the tree listbox itself 379 if ( getListBox() ) 380 xParent = getListBox()->GetAccessible( ); 381 } 382 else 383 { // we have a entry as parent -> get it's accessible 384 385 // shorten our access path by one 386 ::std::deque< sal_Int32 > aParentPath( m_aEntryPath ); 387 aParentPath.pop_back(); 388 389 // get the entry for this shortened access path 390 SvLBoxEntry* pParentEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 391 DBG_ASSERT( pParentEntry, "AccessibleListBoxEntry::implGetParentAccessible: could not obtain a parent entry!" ); 392 393 //IAccessibility2 Implementation 2009----- 394 if ( pParentEntry ) 395 pParentEntry = getListBox()->GetParent(pParentEntry); 396 //-----IAccessibility2 Implementation 2009 397 if ( pParentEntry ) 398 xParent = new AccessibleListBoxEntry( *getListBox(), pParentEntry, NULL ); 399 // note that we pass NULL here as parent-accessible: 400 // this is allowed, as the AccessibleListBoxEntry class will create it's parent 401 // when needed 402 } 403 } 404 405 return xParent; 406 } 407 408 // ----------------------------------------------------------------------------- 409 Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getAccessibleParent( ) throw (RuntimeException) 410 { 411 ALBSolarGuard aSolarGuard; 412 ::osl::MutexGuard aGuard( m_aMutex ); 413 EnsureIsAlive(); 414 415 return implGetParentAccessible( ); 416 } 417 // ----------------------------------------------------------------------------- 418 sal_Int32 SAL_CALL AccessibleListBoxEntry::getAccessibleIndexInParent( ) throw (RuntimeException) 419 { 420 ::osl::MutexGuard aGuard( m_aMutex ); 421 422 DBG_ASSERT( !m_aEntryPath.empty(), "empty path" ); 423 return m_aEntryPath.empty() ? -1 : m_aEntryPath.back(); 424 } 425 // ----------------------------------------------------------------------------- 426 sal_Int32 SAL_CALL AccessibleListBoxEntry::getRoleType() 427 { 428 sal_Int32 nCase = 0; 429 SvLBoxEntry* pEntry = getListBox()->GetEntry(0); 430 if ( pEntry ) 431 { 432 if( pEntry->HasChildsOnDemand() || getListBox()->GetChildCount(pEntry) > 0 ) 433 { 434 nCase = 1; 435 return nCase; 436 } 437 } 438 439 sal_Bool bHasButtons = (getListBox()->GetStyle() & WB_HASBUTTONS)!=0; 440 if( !(getListBox()->GetTreeFlags() & TREEFLAG_CHKBTN) ) 441 { 442 if( bHasButtons ) 443 nCase = 1; 444 } 445 else 446 { 447 if( bHasButtons ) 448 nCase = 2; 449 else 450 nCase = 3; 451 } 452 return nCase; 453 } 454 sal_Int16 SAL_CALL AccessibleListBoxEntry::getAccessibleRole( ) throw (RuntimeException) 455 { 456 SvTreeListBox* pBox = getListBox(); 457 if(pBox) 458 { 459 short nType = pBox->GetAllEntriesAccessibleRoleType(); 460 if( nType == TREEBOX_ALLITEM_ACCROLE_TYPE_TREE) 461 return AccessibleRole::TREE_ITEM; 462 else if( nType == TREEBOX_ALLITEM_ACCROLE_TYPE_LIST) 463 return AccessibleRole::LIST_ITEM; 464 } 465 466 sal_uInt16 treeFlag = pBox->GetTreeFlags(); 467 if(treeFlag & TREEFLAG_CHKBTN ) 468 { 469 SvLBoxEntry* pEntry = pBox->GetEntryFromPath( m_aEntryPath ); 470 SvButtonState eState = pBox->GetCheckButtonState( pEntry ); 471 switch( eState ) 472 { 473 case SV_BUTTON_CHECKED: 474 case SV_BUTTON_UNCHECKED: 475 return AccessibleRole::CHECK_BOX; 476 case SV_BUTTON_TRISTATE: 477 default: 478 return AccessibleRole::LABEL; 479 } 480 } 481 else 482 { 483 484 if(getRoleType() == 0) 485 return AccessibleRole::LIST_ITEM; 486 else 487 //o is: return AccessibleRole::LABEL; 488 return AccessibleRole::TREE_ITEM; 489 } 490 } 491 // ----------------------------------------------------------------------------- 492 ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getAccessibleDescription( ) throw (RuntimeException) 493 { 494 // no description for every item 495 SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 496 if( getAccessibleRole() == AccessibleRole::TREE_ITEM ) 497 { 498 return getListBox()->GetEntryLongDescription( pEntry ); 499 } 500 //want to cout the real column nubmer in the list box. 501 sal_uInt16 iRealItemCount = 0; 502 sal_uInt16 iCount = 0; 503 sal_uInt16 iTotleItemCount = pEntry->ItemCount(); 504 SvLBoxItem* pItem; 505 while( iCount < iTotleItemCount ) 506 { 507 pItem = pEntry->GetItem( iCount ); 508 if ( pItem->IsA() == SV_ITEM_ID_LBOXSTRING && 509 static_cast<SvLBoxString*>( pItem )->GetText().Len() > 0 ) 510 { 511 iRealItemCount++; 512 } 513 iCount++; 514 } 515 if(iRealItemCount<=1 ) 516 { 517 return ::rtl::OUString(); 518 } 519 else 520 { 521 return getListBox()->SearchEntryTextWithHeadTitle( pEntry ); 522 } 523 524 } 525 // ----------------------------------------------------------------------------- 526 ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getAccessibleName( ) throw (RuntimeException) 527 { 528 ::osl::MutexGuard aGuard( m_aMutex ); 529 530 EnsureIsAlive(); 531 532 ::rtl::OUString sRet; 533 sRet = implGetText(); 534 535 SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 536 537 String altText = getListBox()->GetEntryAltText( pEntry ); 538 if( altText.Len() > 0 ) 539 { 540 sRet += ::rtl::OUString(' '); 541 sRet += altText; 542 } 543 544 // IA2 CWS. Removed for now - only used in Sw/Sd/ScContentLBoxString, they should decide if they need this 545 // if ( pEntry && pEntry->IsMarked()) 546 // sRet = sRet + ::rtl::OUString(TK_RES_STRING(STR_SVT_ACC_LISTENTRY_SELCTED_STATE)); 547 548 return sRet; 549 } 550 // ----------------------------------------------------------------------------- 551 Reference< XAccessibleRelationSet > SAL_CALL AccessibleListBoxEntry::getAccessibleRelationSet( ) throw (RuntimeException) 552 { 553 Reference< XAccessibleRelationSet > xRelSet; 554 Reference< XAccessible > xParent; 555 if ( m_aEntryPath.size() > 1 ) // not a root entry 556 xParent = implGetParentAccessible(); 557 if ( xParent.is() ) 558 { 559 utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; 560 Sequence< Reference< XInterface > > aSequence(1); 561 aSequence[0] = xParent; 562 pRelationSetHelper->AddRelation( 563 AccessibleRelation( AccessibleRelationType::NODE_CHILD_OF, aSequence ) ); 564 xRelSet = pRelationSetHelper; 565 } 566 return xRelSet; 567 } 568 // ----------------------------------------------------------------------------- 569 Reference< XAccessibleStateSet > SAL_CALL AccessibleListBoxEntry::getAccessibleStateSet( ) throw (RuntimeException) 570 { 571 ::osl::MutexGuard aGuard( m_aMutex ); 572 573 utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; 574 Reference< XAccessibleStateSet > xStateSet = pStateSetHelper; 575 576 if ( IsAlive_Impl() ) 577 { 578 switch(getAccessibleRole()) 579 { 580 case AccessibleRole::LABEL: 581 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT ); 582 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE ); 583 pStateSetHelper->AddState( AccessibleStateType::ENABLED ); 584 if ( getListBox()->IsInplaceEditingEnabled() ) 585 pStateSetHelper->AddState( AccessibleStateType::EDITABLE ); 586 if ( IsShowing_Impl() ) 587 pStateSetHelper->AddState( AccessibleStateType::SHOWING ); 588 break; 589 case AccessibleRole::CHECK_BOX: 590 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT ); 591 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE ); 592 pStateSetHelper->AddState( AccessibleStateType::ENABLED ); 593 if ( IsShowing_Impl() ) 594 pStateSetHelper->AddState( AccessibleStateType::SHOWING ); 595 break; 596 } 597 getListBox()->FillAccessibleEntryStateSet( 598 getListBox()->GetEntryFromPath( m_aEntryPath ), *pStateSetHelper ); 599 } 600 else 601 pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); 602 603 return xStateSet; 604 } 605 // ----------------------------------------------------------------------------- 606 Locale SAL_CALL AccessibleListBoxEntry::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException) 607 { 608 ALBSolarGuard aSolarGuard; 609 ::osl::MutexGuard aGuard( m_aMutex ); 610 611 return implGetLocale(); 612 } 613 // ----------------------------------------------------------------------------- 614 // XAccessibleComponent 615 // ----------------------------------------------------------------------------- 616 sal_Bool SAL_CALL AccessibleListBoxEntry::containsPoint( const awt::Point& rPoint ) throw (RuntimeException) 617 { 618 return Rectangle( Point(), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) ); 619 } 620 // ----------------------------------------------------------------------------- 621 Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getAccessibleAtPoint( const awt::Point& _aPoint ) throw (RuntimeException) 622 { 623 ALBSolarGuard aSolarGuard; 624 ::osl::MutexGuard aGuard( m_aMutex ); 625 626 EnsureIsAlive(); 627 SvLBoxEntry* pEntry = getListBox()->GetEntry( VCLPoint( _aPoint ) ); 628 if ( !pEntry ) 629 throw RuntimeException(); 630 631 Reference< XAccessible > xAcc; 632 AccessibleListBoxEntry* pAccEntry = new AccessibleListBoxEntry( *getListBox(), pEntry, this ); 633 Rectangle aRect = pAccEntry->GetBoundingBox_Impl(); 634 if ( aRect.IsInside( VCLPoint( _aPoint ) ) ) 635 xAcc = pAccEntry; 636 return xAcc; 637 } 638 // ----------------------------------------------------------------------------- 639 awt::Rectangle SAL_CALL AccessibleListBoxEntry::getBounds( ) throw (RuntimeException) 640 { 641 return AWTRectangle( GetBoundingBox() ); 642 } 643 // ----------------------------------------------------------------------------- 644 awt::Point SAL_CALL AccessibleListBoxEntry::getLocation( ) throw (RuntimeException) 645 { 646 return AWTPoint( GetBoundingBox().TopLeft() ); 647 } 648 // ----------------------------------------------------------------------------- 649 awt::Point SAL_CALL AccessibleListBoxEntry::getLocationOnScreen( ) throw (RuntimeException) 650 { 651 return AWTPoint( GetBoundingBoxOnScreen().TopLeft() ); 652 } 653 // ----------------------------------------------------------------------------- 654 awt::Size SAL_CALL AccessibleListBoxEntry::getSize( ) throw (RuntimeException) 655 { 656 return AWTSize( GetBoundingBox().GetSize() ); 657 } 658 // ----------------------------------------------------------------------------- 659 void SAL_CALL AccessibleListBoxEntry::grabFocus( ) throw (RuntimeException) 660 { 661 // do nothing, because no focus for each item 662 } 663 // ----------------------------------------------------------------------------- 664 sal_Int32 AccessibleListBoxEntry::getForeground( ) throw (RuntimeException) 665 { 666 ALBSolarGuard aSolarGuard; 667 ::osl::MutexGuard aGuard( m_aMutex ); 668 669 sal_Int32 nColor = 0; 670 Reference< XAccessible > xParent = getAccessibleParent(); 671 if ( xParent.is() ) 672 { 673 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY ); 674 if ( xParentComp.is() ) 675 nColor = xParentComp->getForeground(); 676 } 677 678 return nColor; 679 } 680 // ----------------------------------------------------------------------------- 681 sal_Int32 AccessibleListBoxEntry::getBackground( ) throw (RuntimeException) 682 { 683 ALBSolarGuard aSolarGuard; 684 ::osl::MutexGuard aGuard( m_aMutex ); 685 686 sal_Int32 nColor = 0; 687 Reference< XAccessible > xParent = getAccessibleParent(); 688 if ( xParent.is() ) 689 { 690 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY ); 691 if ( xParentComp.is() ) 692 nColor = xParentComp->getBackground(); 693 } 694 695 return nColor; 696 } 697 // ----------------------------------------------------------------------------- 698 // XAccessibleText 699 // ----------------------------------------------------------------------------- 700 // ----------------------------------------------------------------------------- 701 awt::Rectangle SAL_CALL AccessibleListBoxEntry::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 702 { 703 ALBSolarGuard aSolarGuard; 704 ::osl::MutexGuard aGuard( m_aMutex ); 705 706 EnsureIsAlive(); 707 708 if ( !implIsValidIndex( nIndex, implGetText().getLength() ) ) 709 throw IndexOutOfBoundsException(); 710 711 awt::Rectangle aBounds( 0, 0, 0, 0 ); 712 SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 713 if ( pEntry ) 714 { 715 ::vcl::ControlLayoutData aLayoutData; 716 Rectangle aItemRect = GetBoundingBox(); 717 getListBox()->RecordLayoutData( &aLayoutData, aItemRect ); 718 Rectangle aCharRect = aLayoutData.GetCharacterBounds( nIndex ); 719 aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() ); 720 aBounds = AWTRectangle( aCharRect ); 721 } 722 723 return aBounds; 724 } 725 // ----------------------------------------------------------------------------- 726 sal_Int32 SAL_CALL AccessibleListBoxEntry::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException) 727 { 728 ALBSolarGuard aSolarGuard; 729 ::osl::MutexGuard aGuard( m_aMutex ); 730 EnsureIsAlive(); 731 if(aPoint.X==0 && aPoint.Y==0) return 0; 732 733 sal_Int32 nIndex = -1; 734 SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 735 if ( pEntry ) 736 { 737 ::vcl::ControlLayoutData aLayoutData; 738 Rectangle aItemRect = GetBoundingBox(); 739 getListBox()->RecordLayoutData( &aLayoutData, aItemRect ); 740 Point aPnt( VCLPoint( aPoint ) ); 741 aPnt += aItemRect.TopLeft(); 742 nIndex = aLayoutData.GetIndexForPoint( aPnt ); 743 } 744 745 return nIndex; 746 } 747 // ----------------------------------------------------------------------------- 748 sal_Bool SAL_CALL AccessibleListBoxEntry::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException) 749 { 750 ALBSolarGuard aSolarGuard; 751 ::osl::MutexGuard aGuard( m_aMutex ); 752 EnsureIsAlive(); 753 754 String sText = getText(); 755 if ( ( 0 > nStartIndex ) || ( sText.Len() <= nStartIndex ) 756 || ( 0 > nEndIndex ) || ( sText.Len() <= nEndIndex ) ) 757 throw IndexOutOfBoundsException(); 758 759 sal_Int32 nLen = nEndIndex - nStartIndex + 1; 760 ::svt::OStringTransfer::CopyString( sText.Copy( (sal_uInt16)nStartIndex, (sal_uInt16)nLen ), getListBox() ); 761 762 return sal_True; 763 } 764 // ----------------------------------------------------------------------------- 765 // XAccessibleEventBroadcaster 766 // ----------------------------------------------------------------------------- 767 void SAL_CALL AccessibleListBoxEntry::addEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException) 768 { 769 if (xListener.is()) 770 { 771 ::osl::MutexGuard aGuard( m_aMutex ); 772 if (!m_nClientId) 773 m_nClientId = comphelper::AccessibleEventNotifier::registerClient( ); 774 comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener ); 775 } 776 } 777 // ----------------------------------------------------------------------------- 778 void SAL_CALL AccessibleListBoxEntry::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException) 779 { 780 if (xListener.is()) 781 { 782 ::osl::MutexGuard aGuard( m_aMutex ); 783 784 sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener ); 785 if ( !nListenerCount ) 786 { 787 // no listeners anymore 788 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), 789 // and at least to us not firing any events anymore, in case somebody calls 790 // NotifyAccessibleEvent, again 791 sal_Int32 nId = m_nClientId; 792 m_nClientId = 0; 793 comphelper::AccessibleEventNotifier::revokeClient( nId ); 794 795 } 796 } 797 } 798 // ----------------------------------------------------------------------------- 799 // XAccessibleAction 800 // ----------------------------------------------------------------------------- 801 sal_Int32 SAL_CALL AccessibleListBoxEntry::getAccessibleActionCount( ) throw (RuntimeException) 802 { 803 ::osl::MutexGuard aGuard( m_aMutex ); 804 805 // three actions supported 806 SvTreeListBox* pBox = getListBox(); 807 sal_uInt16 treeFlag = pBox->GetTreeFlags(); 808 sal_Bool bHasButtons = (getListBox()->GetStyle() & WB_HASBUTTONS)!=0; 809 if( (treeFlag & TREEFLAG_CHKBTN) && !bHasButtons) 810 { 811 sal_Int16 role = getAccessibleRole(); 812 if ( role == AccessibleRole::CHECK_BOX ) 813 return 2; 814 else if ( role == AccessibleRole::LABEL ) 815 return 0; 816 } 817 else 818 return ACCESSIBLE_ACTION_COUNT; 819 return 0; 820 } 821 // ----------------------------------------------------------------------------- 822 sal_Bool SAL_CALL AccessibleListBoxEntry::doAccessibleAction( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 823 { 824 ALBSolarGuard aSolarGuard; 825 ::osl::MutexGuard aGuard( m_aMutex ); 826 827 sal_Bool bRet = sal_False; 828 checkActionIndex_Impl( nIndex ); 829 EnsureIsAlive(); 830 sal_uInt16 treeFlag = getListBox()->GetTreeFlags(); 831 if( nIndex == 0 && (treeFlag & TREEFLAG_CHKBTN) ) 832 { 833 if(getAccessibleRole() == AccessibleRole::CHECK_BOX) 834 { 835 SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 836 SvButtonState state = getListBox()->GetCheckButtonState( pEntry ); 837 if ( state == SV_BUTTON_CHECKED ) 838 getListBox()->SetCheckButtonState(pEntry, (SvButtonState)SV_BMP_UNCHECKED); 839 else if (state == SV_BMP_UNCHECKED) 840 getListBox()->SetCheckButtonState(pEntry, (SvButtonState)SV_BUTTON_CHECKED); 841 } 842 }else if( (nIndex == 1 && (treeFlag & TREEFLAG_CHKBTN) ) || (nIndex == 0) ) 843 { 844 SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 845 if ( pEntry ) 846 { 847 if ( getListBox()->IsExpanded( pEntry ) ) 848 getListBox()->Collapse( pEntry ); 849 else 850 getListBox()->Expand( pEntry ); 851 bRet = sal_True; 852 } 853 } 854 return bRet; 855 } 856 // ----------------------------------------------------------------------------- 857 ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getAccessibleActionDescription( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 858 { 859 ALBSolarGuard aSolarGuard; 860 ::osl::MutexGuard aGuard( m_aMutex ); 861 862 checkActionIndex_Impl( nIndex ); 863 EnsureIsAlive(); 864 865 static const ::rtl::OUString sActionDesc( RTL_CONSTASCII_USTRINGPARAM( "toggleExpand" ) ); 866 static const ::rtl::OUString sActionDesc1( RTL_CONSTASCII_USTRINGPARAM( "Check" ) ); 867 static const ::rtl::OUString sActionDesc2( RTL_CONSTASCII_USTRINGPARAM( "UnCheck" ) ); 868 // sal_Bool bHasButtons = (getListBox()->GetStyle() & WB_HASBUTTONS)!=0; 869 SvLBoxEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath ); 870 SvButtonState state = getListBox()->GetCheckButtonState( pEntry ); 871 sal_uInt16 treeFlag = getListBox()->GetTreeFlags(); 872 if(nIndex == 0 && (treeFlag & TREEFLAG_CHKBTN)) 873 { 874 if(getAccessibleRole() == AccessibleRole::CHECK_BOX) 875 { 876 if ( state == SV_BUTTON_CHECKED ) 877 return sActionDesc2; 878 else if (state == SV_BMP_UNCHECKED) 879 return sActionDesc1; 880 } 881 else 882 { 883 //Sometimes, a List or Tree may have both checkbox and label at the same time 884 return ::rtl::OUString(); 885 } 886 }else if( (nIndex == 1 && (treeFlag & TREEFLAG_CHKBTN)) || nIndex == 0 ) 887 { 888 //IAccessibility2 Implementation 2009----- 889 if( pEntry->HasChilds() || pEntry->HasChildsOnDemand() ) 890 //-----IAccessibility2 Implementation 2009 891 return getListBox()->IsExpanded( pEntry ) ? \ 892 ::rtl::OUString(TK_RES_STRING(STR_SVT_ACC_ACTION_COLLAPSE)) : 893 ::rtl::OUString(TK_RES_STRING(STR_SVT_ACC_ACTION_EXPAND)); 894 return ::rtl::OUString(); 895 896 } 897 throw IndexOutOfBoundsException(); 898 } 899 // ----------------------------------------------------------------------------- 900 Reference< XAccessibleKeyBinding > AccessibleListBoxEntry::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 901 { 902 ::osl::MutexGuard aGuard( m_aMutex ); 903 904 Reference< XAccessibleKeyBinding > xRet; 905 checkActionIndex_Impl( nIndex ); 906 // ... which key? 907 return xRet; 908 } 909 // ----------------------------------------------------------------------------- 910 // XAccessibleSelection 911 // ----------------------------------------------------------------------------- 912 void SAL_CALL AccessibleListBoxEntry::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 913 { 914 ALBSolarGuard aSolarGuard; 915 ::osl::MutexGuard aGuard( m_aMutex ); 916 917 EnsureIsAlive(); 918 // IAccessible2 implementation, 2009 919 // SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 920 // SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, nChildIndex ); 921 922 SvLBoxEntry* pEntry =GetRealChild(nChildIndex); 923 if ( !pEntry ) 924 throw IndexOutOfBoundsException(); 925 926 getListBox()->Select( pEntry, sal_True ); 927 } 928 // ----------------------------------------------------------------------------- 929 sal_Bool SAL_CALL AccessibleListBoxEntry::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 930 { 931 ALBSolarGuard aSolarGuard; 932 ::osl::MutexGuard aGuard( m_aMutex ); 933 934 EnsureIsAlive(); 935 936 SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 937 SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, nChildIndex ); 938 if ( !pEntry ) 939 throw IndexOutOfBoundsException(); 940 941 return getListBox()->IsSelected( pEntry ); 942 } 943 // ----------------------------------------------------------------------------- 944 void SAL_CALL AccessibleListBoxEntry::clearAccessibleSelection( ) throw (RuntimeException) 945 { 946 ALBSolarGuard aSolarGuard; 947 ::osl::MutexGuard aGuard( m_aMutex ); 948 949 EnsureIsAlive(); 950 951 SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 952 if ( !pParent ) 953 throw RuntimeException(); 954 sal_Int32 i, nCount = 0; 955 nCount = getListBox()->GetLevelChildCount( pParent ); 956 for ( i = 0; i < nCount; ++i ) 957 { 958 SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, i ); 959 if ( getListBox()->IsSelected( pEntry ) ) 960 getListBox()->Select( pEntry, sal_False ); 961 } 962 } 963 // ----------------------------------------------------------------------------- 964 void SAL_CALL AccessibleListBoxEntry::selectAllAccessibleChildren( ) throw (RuntimeException) 965 { 966 ALBSolarGuard aSolarGuard; 967 ::osl::MutexGuard aGuard( m_aMutex ); 968 969 EnsureIsAlive(); 970 971 SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 972 if ( !pParent ) 973 throw RuntimeException(); 974 sal_Int32 i, nCount = 0; 975 nCount = getListBox()->GetLevelChildCount( pParent ); 976 for ( i = 0; i < nCount; ++i ) 977 { 978 SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, i ); 979 if ( !getListBox()->IsSelected( pEntry ) ) 980 getListBox()->Select( pEntry, sal_True ); 981 } 982 } 983 // ----------------------------------------------------------------------------- 984 sal_Int32 SAL_CALL AccessibleListBoxEntry::getSelectedAccessibleChildCount( ) throw (RuntimeException) 985 { 986 ALBSolarGuard aSolarGuard; 987 ::osl::MutexGuard aGuard( m_aMutex ); 988 989 EnsureIsAlive(); 990 991 sal_Int32 i, nSelCount = 0, nCount = 0; 992 993 SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 994 if ( !pParent ) 995 throw RuntimeException(); 996 nCount = getListBox()->GetLevelChildCount( pParent ); 997 for ( i = 0; i < nCount; ++i ) 998 { 999 SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, i ); 1000 if ( getListBox()->IsSelected( pEntry ) ) 1001 ++nSelCount; 1002 } 1003 1004 return nSelCount; 1005 } 1006 // ----------------------------------------------------------------------------- 1007 Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 1008 { 1009 ALBSolarGuard aSolarGuard; 1010 ::osl::MutexGuard aGuard( m_aMutex ); 1011 1012 EnsureIsAlive(); 1013 1014 if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() ) 1015 throw IndexOutOfBoundsException(); 1016 1017 Reference< XAccessible > xChild; 1018 sal_Int32 i, nSelCount = 0, nCount = 0; 1019 1020 SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 1021 if ( !pParent ) 1022 throw RuntimeException(); 1023 nCount = getListBox()->GetLevelChildCount( pParent ); 1024 for ( i = 0; i < nCount; ++i ) 1025 { 1026 SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, i ); 1027 if ( getListBox()->IsSelected( pEntry ) ) 1028 ++nSelCount; 1029 1030 if ( nSelCount == ( nSelectedChildIndex + 1 ) ) 1031 { 1032 xChild = new AccessibleListBoxEntry( *getListBox(), pEntry, this ); 1033 break; 1034 } 1035 } 1036 1037 return xChild; 1038 } 1039 // ----------------------------------------------------------------------------- 1040 void SAL_CALL AccessibleListBoxEntry::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 1041 { 1042 ALBSolarGuard aSolarGuard; 1043 ::osl::MutexGuard aGuard( m_aMutex ); 1044 1045 EnsureIsAlive(); 1046 1047 SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 1048 SvLBoxEntry* pEntry = getListBox()->GetEntry( pParent, nSelectedChildIndex ); 1049 if ( !pEntry ) 1050 throw IndexOutOfBoundsException(); 1051 1052 getListBox()->Select( pEntry, sal_False ); 1053 } 1054 sal_Int32 SAL_CALL AccessibleListBoxEntry::getCaretPosition( ) throw (::com::sun::star::uno::RuntimeException) 1055 { 1056 return -1; 1057 } 1058 sal_Bool SAL_CALL AccessibleListBoxEntry::setCaretPosition ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 1059 { 1060 ALBSolarGuard aSolarGuard; 1061 ::osl::MutexGuard aGuard( m_aMutex ); 1062 EnsureIsAlive(); 1063 1064 if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) ) 1065 throw IndexOutOfBoundsException(); 1066 1067 return sal_False; 1068 } 1069 sal_Unicode SAL_CALL AccessibleListBoxEntry::getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 1070 { 1071 ALBSolarGuard aSolarGuard; 1072 ::osl::MutexGuard aGuard( m_aMutex ); 1073 EnsureIsAlive(); 1074 return OCommonAccessibleText::getCharacter( nIndex ); 1075 } 1076 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL AccessibleListBoxEntry::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 1077 { 1078 ALBSolarGuard aSolarGuard; 1079 ::osl::MutexGuard aGuard( m_aMutex ); 1080 EnsureIsAlive(); 1081 1082 ::rtl::OUString sText( implGetText() ); 1083 1084 if ( !implIsValidIndex( nIndex, sText.getLength() ) ) 1085 throw IndexOutOfBoundsException(); 1086 1087 return ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >(); 1088 } 1089 sal_Int32 SAL_CALL AccessibleListBoxEntry::getCharacterCount( ) throw (::com::sun::star::uno::RuntimeException) 1090 { 1091 ALBSolarGuard aSolarGuard; 1092 ::osl::MutexGuard aGuard( m_aMutex ); 1093 EnsureIsAlive(); 1094 return OCommonAccessibleText::getCharacterCount( ); 1095 } 1096 1097 ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getSelectedText( ) throw (::com::sun::star::uno::RuntimeException) 1098 { 1099 ALBSolarGuard aSolarGuard; 1100 ::osl::MutexGuard aGuard( m_aMutex ); 1101 EnsureIsAlive(); 1102 return OCommonAccessibleText::getSelectedText( ); 1103 } 1104 sal_Int32 SAL_CALL AccessibleListBoxEntry::getSelectionStart( ) throw (::com::sun::star::uno::RuntimeException) 1105 { 1106 ALBSolarGuard aSolarGuard; 1107 ::osl::MutexGuard aGuard( m_aMutex ); 1108 EnsureIsAlive(); 1109 return OCommonAccessibleText::getSelectionStart( ); 1110 } 1111 sal_Int32 SAL_CALL AccessibleListBoxEntry::getSelectionEnd( ) throw (::com::sun::star::uno::RuntimeException) 1112 { 1113 ALBSolarGuard aSolarGuard; 1114 ::osl::MutexGuard aGuard( m_aMutex ); 1115 EnsureIsAlive(); 1116 return OCommonAccessibleText::getSelectionEnd( ); 1117 } 1118 sal_Bool SAL_CALL AccessibleListBoxEntry::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 1119 { 1120 ALBSolarGuard aSolarGuard; 1121 ::osl::MutexGuard aGuard( m_aMutex ); 1122 EnsureIsAlive(); 1123 1124 if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) ) 1125 throw IndexOutOfBoundsException(); 1126 1127 return sal_False; 1128 } 1129 ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getText( ) throw (::com::sun::star::uno::RuntimeException) 1130 { 1131 ALBSolarGuard aSolarGuard; 1132 ::osl::MutexGuard aGuard( m_aMutex ); 1133 EnsureIsAlive(); 1134 return OCommonAccessibleText::getText( ); 1135 } 1136 ::rtl::OUString SAL_CALL AccessibleListBoxEntry::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 1137 { 1138 ALBSolarGuard aSolarGuard; 1139 ::osl::MutexGuard aGuard( m_aMutex ); 1140 EnsureIsAlive(); 1141 return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex ); 1142 } 1143 ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleListBoxEntry::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 1144 { 1145 ALBSolarGuard aSolarGuard; 1146 ::osl::MutexGuard aGuard( m_aMutex ); 1147 EnsureIsAlive(); 1148 return OCommonAccessibleText::getTextAtIndex( nIndex ,aTextType); 1149 } 1150 ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleListBoxEntry::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 1151 { 1152 ALBSolarGuard aSolarGuard; 1153 ::osl::MutexGuard aGuard( m_aMutex ); 1154 EnsureIsAlive(); 1155 return OCommonAccessibleText::getTextBeforeIndex( nIndex ,aTextType); 1156 } 1157 ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleListBoxEntry::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 1158 { 1159 ALBSolarGuard aSolarGuard; 1160 ::osl::MutexGuard aGuard( m_aMutex ); 1161 EnsureIsAlive(); 1162 1163 return OCommonAccessibleText::getTextBehindIndex( nIndex ,aTextType); 1164 } 1165 // ----------------------------------------------------------------------------- 1166 // XAccessibleValue 1167 // ----------------------------------------------------------------------------- 1168 1169 Any AccessibleListBoxEntry::getCurrentValue( ) throw (RuntimeException) 1170 { 1171 ::osl::MutexGuard aGuard( m_aMutex ); 1172 Any aValue; 1173 sal_Int32 level = ((sal_Int32) m_aEntryPath.size() - 1); 1174 level = level < 0 ? 0: level; 1175 aValue <<= level; 1176 return aValue; 1177 } 1178 1179 // ----------------------------------------------------------------------------- 1180 1181 sal_Bool AccessibleListBoxEntry::setCurrentValue( const Any& aNumber ) throw (RuntimeException) 1182 { 1183 ::osl::MutexGuard aGuard( m_aMutex ); 1184 1185 1186 sal_Bool bReturn = sal_False; 1187 SvTreeListBox* pBox = getListBox(); 1188 if(getAccessibleRole() == AccessibleRole::CHECK_BOX) 1189 { 1190 SvLBoxEntry* pEntry = pBox->GetEntryFromPath( m_aEntryPath ); 1191 if ( pEntry ) 1192 { 1193 sal_Int32 nValue, nValueMin, nValueMax; 1194 aNumber >>= nValue; 1195 getMinimumValue() >>= nValueMin; 1196 getMaximumValue() >>= nValueMax; 1197 1198 if ( nValue < nValueMin ) 1199 nValue = nValueMin; 1200 else if ( nValue > nValueMax ) 1201 nValue = nValueMax; 1202 1203 pBox->SetCheckButtonState(pEntry, (SvButtonState) nValue ); 1204 bReturn = sal_True; 1205 } 1206 } 1207 1208 return bReturn; 1209 } 1210 1211 // ----------------------------------------------------------------------------- 1212 1213 Any AccessibleListBoxEntry::getMaximumValue( ) throw (RuntimeException) 1214 { 1215 ::osl::MutexGuard aGuard( m_aMutex ); 1216 1217 Any aValue; 1218 // SvTreeListBox* pBox = getListBox(); 1219 switch(getAccessibleRole()) 1220 { 1221 case AccessibleRole::CHECK_BOX: 1222 aValue <<= (sal_Int32)1; 1223 break; 1224 case AccessibleRole::LABEL: 1225 default: 1226 break; 1227 } 1228 1229 return aValue; 1230 } 1231 1232 // ----------------------------------------------------------------------------- 1233 1234 Any AccessibleListBoxEntry::getMinimumValue( ) throw (RuntimeException) 1235 { 1236 ::osl::MutexGuard aGuard( m_aMutex ); 1237 1238 Any aValue; 1239 // SvTreeListBox* pBox = getListBox(); 1240 switch(getAccessibleRole()) 1241 { 1242 case AccessibleRole::CHECK_BOX: 1243 aValue <<= (sal_Int32)0; 1244 break; 1245 case AccessibleRole::LABEL: 1246 default: 1247 break; 1248 } 1249 1250 return aValue; 1251 } 1252 1253 // ----------------------------------------------------------------------------- 1254 1255 SvLBoxEntry * AccessibleListBoxEntry::GetRealChild(sal_Int32 nIndex) 1256 { 1257 SvLBoxEntry* pEntry =NULL; 1258 SvLBoxEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath ); 1259 if (pParent) 1260 { 1261 pEntry = getListBox()->GetEntry( pParent, nIndex ); 1262 if ( !pEntry && getAccessibleChildCount() > 0 ) 1263 { 1264 getListBox()->RequestingChilds(pParent); 1265 pEntry = getListBox()->GetEntry( pParent, nIndex ); 1266 } 1267 } 1268 return pEntry; 1269 } 1270 //........................................................................ 1271 }// namespace accessibility 1272 //........................................................................ 1273 1274