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