LCOV - code coverage report
Current view: top level - accessibility/source/extended - accessiblelistboxentry.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 69 637 10.8 %
Date: 2015-06-13 12:38:46 Functions: 14 82 17.1 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11