LCOV - code coverage report
Current view: top level - accessibility/source/extended - accessiblelistbox.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 76 276 27.5 %
Date: 2015-06-13 12:38:46 Functions: 18 37 48.6 %
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/accessiblelistbox.hxx>
      21             : #include <accessibility/extended/accessiblelistboxentry.hxx>
      22             : #include <svtools/treelistbox.hxx>
      23             : #include <svtools/treelistentry.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/AccessibleRole.hpp>
      29             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      30             : #include <cppuhelper/supportsservice.hxx>
      31             : #include <vcl/svapp.hxx>
      32             : #include <toolkit/awt/vclxwindow.hxx>
      33             : #include <toolkit/helper/convert.hxx>
      34             : #include <unotools/accessiblestatesethelper.hxx>
      35             : 
      36             : 
      37             : namespace accessibility
      38             : {
      39             : 
      40             : 
      41             :     // class AccessibleListBox -----------------------------------------------------
      42             : 
      43             :     using namespace ::com::sun::star::accessibility;
      44             :     using namespace ::com::sun::star::uno;
      45             :     using namespace ::com::sun::star::lang;
      46             :     using namespace ::com::sun::star;
      47             : 
      48             : 
      49             :     // Ctor() and Dtor()
      50             : 
      51           3 :     AccessibleListBox::AccessibleListBox( SvTreeListBox& _rListBox, const Reference< XAccessible >& _xParent ) :
      52             : 
      53             :         VCLXAccessibleComponent( _rListBox.GetWindowPeer() ),
      54           3 :         m_xParent( _xParent )
      55             :     {
      56           3 :     }
      57             : 
      58           9 :     AccessibleListBox::~AccessibleListBox()
      59             :     {
      60           3 :         if ( isAlive() )
      61             :         {
      62             :             // increment ref count to prevent double call of Dtor
      63           0 :             osl_atomic_increment( &m_refCount );
      64           0 :             dispose();
      65             :         }
      66           6 :     }
      67         186 :     IMPLEMENT_FORWARD_XINTERFACE2(AccessibleListBox, VCLXAccessibleComponent, AccessibleListBox_BASE)
      68           0 :     IMPLEMENT_FORWARD_XTYPEPROVIDER2(AccessibleListBox, VCLXAccessibleComponent, AccessibleListBox_BASE)
      69             : 
      70          24 :     void AccessibleListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
      71             :     {
      72          24 :         if ( isAlive() )
      73             :         {
      74          24 :             switch ( rVclWindowEvent.GetId() )
      75             :             {
      76             :             case  VCLEVENT_CHECKBOX_TOGGLE :
      77             :                 {
      78           0 :                     if ( !getListBox() || !getListBox()->HasFocus() )
      79             :                     {
      80           0 :                         return;
      81             :                     }
      82           0 :                     AccessibleListBoxEntry* pCurOpEntry = GetCurEventEntry(rVclWindowEvent);
      83           0 :                     if(!pCurOpEntry)
      84             :                     {
      85           0 :                         return ;
      86             :                     }
      87           0 :                     uno::Any aValue;
      88           0 :                     aValue <<= AccessibleStateType::CHECKED;
      89             : 
      90           0 :                     if ( getListBox()->GetCheckButtonState( pCurOpEntry->GetSvLBoxEntry() ) == SV_BUTTON_CHECKED )
      91             :                     {
      92           0 :                         pCurOpEntry->NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, uno::Any(), aValue );
      93             :                     }
      94             :                     else
      95             :                     {
      96           0 :                         pCurOpEntry->NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aValue,uno::Any() );
      97             :                     }
      98           0 :                     break;
      99             :                 }
     100             : 
     101             :             case VCLEVENT_LISTBOX_SELECT :
     102             :                 {
     103             :                     OSL_FAIL("Debug: Treelist shouldn't use VCLEVENT_LISTBOX_SELECT");
     104           0 :                     break;
     105             :                 }
     106             : 
     107             :             case VCLEVENT_LISTBOX_TREESELECT:
     108             :                 {
     109           0 :                     if ( getListBox() && getListBox()->HasFocus() )
     110             :                     {
     111           0 :                         AccessibleListBoxEntry* pEntry =static_cast< AccessibleListBoxEntry* >(m_xFocusedChild.get());
     112           0 :                         if (pEntry)
     113             :                         {
     114           0 :                             pEntry->NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
     115             :                         }
     116             :                     }
     117             :                 }
     118           0 :                 break;
     119             :             case VCLEVENT_LISTBOX_TREEFOCUS:
     120             :                 {
     121           0 :                     SvTreeListBox* pBox = getListBox();
     122           0 :                     bool bNeedFocus = false;
     123           0 :                     if (pBox)
     124             :                     {
     125           0 :                         vcl::Window* pParent = static_cast<vcl::Window*>(pBox)->GetParent();
     126           0 :                         if (pParent && pParent->GetType() == WINDOW_FLOATINGWINDOW)
     127             :                         {
     128             :                             // MT: ImplGetAppSVData shouldn't be exported from VCL.
     129             :                             // In which scenario is this needed?
     130             :                             // If needed, we need to find an other solution
     131             :                             /*
     132             :                               ImplSVData* pSVData = ImplGetAppSVData();
     133             :                               if (pSVData && pSVData->maWinData.mpFirstFloat == (FloatingWindow*)pParent)
     134             :                               bNeedFocus = true;
     135             :                             */
     136             :                         }
     137             :                     }
     138           0 :                     if( pBox && (pBox->HasFocus() || bNeedFocus) )
     139             :                     {
     140           0 :                         uno::Any aOldValue, aNewValue;
     141           0 :                         SvTreeListEntry* pEntry = static_cast< SvTreeListEntry* >( rVclWindowEvent.GetData() );
     142           0 :                         if ( pEntry )
     143             :                         {
     144           0 :                             AccessibleListBoxEntry* pEntryFocus =static_cast< AccessibleListBoxEntry* >(m_xFocusedChild.get());
     145           0 :                             if (pEntryFocus && pEntryFocus->GetSvLBoxEntry() == pEntry)
     146             :                             {
     147           0 :                                 aOldValue <<= uno::Any();
     148           0 :                                 aNewValue <<= m_xFocusedChild;
     149           0 :                                 NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldValue, aNewValue );
     150           0 :                                 return ;
     151             :                             }
     152             : 
     153           0 :                             aOldValue <<= m_xFocusedChild;
     154             : 
     155           0 :                             MAP_ENTRY::iterator mi = m_mapEntry.find(pEntry);
     156           0 :                             if(mi != m_mapEntry.end())
     157             :                             {
     158             :                                 OSL_ASSERT(mi->second.get() != NULL);
     159           0 :                                 m_xFocusedChild = mi->second;
     160             :                             }
     161             :                             else
     162             :                             {
     163           0 :                                 AccessibleListBoxEntry *pEntNew = new AccessibleListBoxEntry( *getListBox(), pEntry, NULL );
     164           0 :                                 m_xFocusedChild = pEntNew;
     165           0 :                                 m_mapEntry.insert(MAP_ENTRY::value_type(pEntry,pEntNew));
     166             :                             }
     167             : 
     168           0 :                             aNewValue <<= m_xFocusedChild;
     169           0 :                             NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldValue, aNewValue );
     170             :                         }
     171             :                         else
     172             :                         {
     173           0 :                             aOldValue <<= uno::Any();
     174           0 :                             aNewValue <<= AccessibleStateType::FOCUSED;
     175           0 :                             NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     176           0 :                         }
     177             :                     }
     178             :                 }
     179           0 :                 break;
     180             :             case VCLEVENT_LISTBOX_ITEMREMOVED:
     181             :                 {
     182           9 :                     SvTreeListEntry* pEntry = static_cast< SvTreeListEntry* >( rVclWindowEvent.GetData() );
     183           9 :                     if ( pEntry )
     184             :                     {
     185           0 :                         RemoveChildEntries(pEntry);
     186             :                     }
     187             :                     else
     188             :                     {
     189             :                         // NULL means Clear()
     190           9 :                         MAP_ENTRY::iterator mi = m_mapEntry.begin();
     191           9 :                         for ( ; mi != m_mapEntry.end() ; ++mi)
     192             :                         {
     193           0 :                             uno::Any aNewValue;
     194           0 :                             uno::Any aOldValue;
     195           0 :                             aOldValue <<= mi->second;
     196           0 :                             NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
     197           0 :                         }
     198           9 :                         m_mapEntry.clear();
     199             :                     }
     200             :                 }
     201           9 :                 break;
     202             : 
     203             :                 // #i92103#
     204             :             case VCLEVENT_ITEM_EXPANDED :
     205             :             case VCLEVENT_ITEM_COLLAPSED :
     206             :                 {
     207           0 :                     SvTreeListEntry* pEntry = static_cast< SvTreeListEntry* >( rVclWindowEvent.GetData() );
     208           0 :                     if ( pEntry )
     209             :                     {
     210             :                         AccessibleListBoxEntry* pAccListBoxEntry =
     211           0 :                             new AccessibleListBoxEntry( *getListBox(), pEntry, this );
     212           0 :                         Reference< XAccessible > xChild = pAccListBoxEntry;
     213             :                         const short nAccEvent =
     214           0 :                                 ( rVclWindowEvent.GetId() == VCLEVENT_ITEM_EXPANDED )
     215             :                                 ? AccessibleEventId::LISTBOX_ENTRY_EXPANDED
     216           0 :                                 : AccessibleEventId::LISTBOX_ENTRY_COLLAPSED;
     217           0 :                         uno::Any aListBoxEntry;
     218           0 :                         aListBoxEntry <<= xChild;
     219           0 :                         NotifyAccessibleEvent( nAccEvent, Any(), aListBoxEntry );
     220           0 :                         if ( getListBox() && getListBox()->HasFocus() )
     221             :                         {
     222           0 :                             NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, Any(), aListBoxEntry );
     223           0 :                         }
     224             :                     }
     225             :                 }
     226           0 :                 break;
     227             :             default:
     228          15 :                 VCLXAccessibleComponent::ProcessWindowEvent (rVclWindowEvent);
     229             :             }
     230             :         }
     231             :     }
     232             : 
     233           0 :     AccessibleListBoxEntry* AccessibleListBox::GetCurEventEntry( const VclWindowEvent& rVclWindowEvent )
     234             :     {
     235           0 :         SvTreeListEntry* pEntry = static_cast< SvTreeListEntry* >( rVclWindowEvent.GetData() );
     236           0 :         if ( !pEntry )
     237           0 :             pEntry = getListBox()->GetCurEntry();
     238             : 
     239           0 :         AccessibleListBoxEntry* pEntryFocus =static_cast< AccessibleListBoxEntry* >(m_xFocusedChild.get());
     240           0 :         if (pEntryFocus && pEntry && pEntry != pEntryFocus->GetSvLBoxEntry())
     241             :         {
     242           0 :             AccessibleListBoxEntry *pAccCurOptionEntry =NULL;
     243           0 :             MAP_ENTRY::iterator mi = m_mapEntry.find(pEntry);
     244           0 :             if (mi != m_mapEntry.end())
     245             :             {
     246           0 :                 pAccCurOptionEntry= static_cast< AccessibleListBoxEntry* >(mi->second.get());
     247             :             }
     248             :             else
     249             :             {
     250           0 :                 pAccCurOptionEntry =new AccessibleListBoxEntry( *getListBox(), pEntry, NULL );
     251           0 :                 std::pair<MAP_ENTRY::iterator, bool> pairMi =  m_mapEntry.insert(MAP_ENTRY::value_type(pAccCurOptionEntry->GetSvLBoxEntry(),pAccCurOptionEntry));
     252           0 :                 mi = pairMi.first;
     253             :             }
     254             : 
     255           0 :             uno::Any aNewValue;
     256           0 :             aNewValue <<= mi->second;//xAcc
     257           0 :             NotifyAccessibleEvent( AccessibleEventId::CHILD, uno::Any(), aNewValue );//Add
     258             : 
     259           0 :             return pAccCurOptionEntry;
     260             :         }
     261             :         else
     262             :         {
     263           0 :             return pEntryFocus;
     264             :         }
     265             :     }
     266             : 
     267           0 :     void AccessibleListBox::RemoveChildEntries(SvTreeListEntry* pEntry)
     268             :     {
     269           0 :         MAP_ENTRY::iterator mi = m_mapEntry.find(pEntry);
     270           0 :         if ( mi != m_mapEntry.end() )
     271             :         {
     272           0 :             uno::Any aNewValue;
     273           0 :             uno::Any aOldValue;
     274           0 :             aOldValue <<= mi->second;
     275           0 :             NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
     276             : 
     277           0 :             m_mapEntry.erase(mi);
     278             :         }
     279             : 
     280           0 :         SvTreeListBox* pBox = getListBox();
     281           0 :         SvTreeListEntry* pEntryChild = pBox->FirstChild(pEntry);
     282           0 :         while (pEntryChild)
     283             :         {
     284           0 :             RemoveChildEntries(pEntryChild);
     285           0 :             pEntryChild = SvTreeListBox::NextSibling(pEntryChild);
     286             :         }
     287           0 :     }
     288             : 
     289             : 
     290          21 :     void AccessibleListBox::ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent )
     291             :     {
     292          21 :         switch ( rVclWindowEvent.GetId() )
     293             :         {
     294             :             case VCLEVENT_WINDOW_SHOW:
     295             :             case VCLEVENT_WINDOW_HIDE:
     296             :             {
     297             :             }
     298           3 :             break;
     299             :             default:
     300             :             {
     301          18 :                 VCLXAccessibleComponent::ProcessWindowChildEvent( rVclWindowEvent );
     302             :             }
     303          18 :             break;
     304             :         }
     305          21 :     }
     306             : 
     307             : 
     308             :     // XComponent
     309             : 
     310           3 :     void SAL_CALL AccessibleListBox::disposing()
     311             :     {
     312           3 :         ::osl::MutexGuard aGuard( m_aMutex );
     313             : 
     314           3 :         m_mapEntry.clear();
     315           3 :         VCLXAccessibleComponent::disposing();
     316           3 :         m_xParent = NULL;
     317           3 :     }
     318             : 
     319             :     // XServiceInfo
     320             : 
     321           0 :     OUString SAL_CALL AccessibleListBox::getImplementationName() throw(RuntimeException, std::exception)
     322             :     {
     323           0 :         return getImplementationName_Static();
     324             :     }
     325             : 
     326           0 :     Sequence< OUString > SAL_CALL AccessibleListBox::getSupportedServiceNames() throw(RuntimeException, std::exception)
     327             :     {
     328           0 :         return getSupportedServiceNames_Static();
     329             :     }
     330             : 
     331           0 :     sal_Bool SAL_CALL AccessibleListBox::supportsService( const OUString& _rServiceName ) throw (RuntimeException, std::exception)
     332             :     {
     333           0 :         return cppu::supportsService(this, _rServiceName);
     334             :     }
     335             : 
     336             :     // XServiceInfo - static methods
     337             : 
     338           0 :     Sequence< OUString > AccessibleListBox::getSupportedServiceNames_Static() throw( RuntimeException )
     339             :     {
     340           0 :         Sequence< OUString > aSupported(3);
     341           0 :         aSupported[0] = "com.sun.star.accessibility.AccessibleContext";
     342           0 :         aSupported[1] = "com.sun.star.accessibility.AccessibleComponent";
     343           0 :         aSupported[2] = "com.sun.star.awt.AccessibleTreeListBox";
     344           0 :         return aSupported;
     345             :     }
     346             : 
     347           0 :     OUString AccessibleListBox::getImplementationName_Static() throw( RuntimeException )
     348             :     {
     349           0 :         return OUString( "com.sun.star.comp.svtools.AccessibleTreeListBox" );
     350             :     }
     351             : 
     352             :     // XAccessible
     353             : 
     354           6 :     Reference< XAccessibleContext > SAL_CALL AccessibleListBox::getAccessibleContext(  ) throw (RuntimeException, std::exception)
     355             :     {
     356           6 :         ensureAlive();
     357           6 :         return this;
     358             :     }
     359             : 
     360             :     // XAccessibleContext
     361             : 
     362           6 :     sal_Int32 SAL_CALL AccessibleListBox::getAccessibleChildCount(  ) throw (RuntimeException, std::exception)
     363             :     {
     364           6 :         ::comphelper::OExternalLockGuard aGuard( this );
     365             : 
     366           6 :         ensureAlive();
     367             : 
     368           6 :         sal_Int32 nCount = 0;
     369           6 :         SvTreeListBox* pSvTreeListBox = getListBox();
     370           6 :         if ( pSvTreeListBox )
     371           6 :             nCount = pSvTreeListBox->GetLevelChildCount( NULL );
     372             : 
     373           6 :         return nCount;
     374             :     }
     375             : 
     376          36 :     Reference< XAccessible > SAL_CALL AccessibleListBox::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException,RuntimeException, std::exception)
     377             :     {
     378          36 :         ::comphelper::OExternalLockGuard aGuard( this );
     379             : 
     380          36 :         ensureAlive();
     381          36 :         SvTreeListEntry* pEntry = getListBox()->GetEntry(i);
     382          36 :         if ( !pEntry )
     383           0 :             throw IndexOutOfBoundsException();
     384             : 
     385             :         // Solution: Set the parameter of the parent to null to let entry determine the parent by itself
     386             :         //return new AccessibleListBoxEntry( *getListBox(), pEntry, this );
     387          36 :         return new AccessibleListBoxEntry( *getListBox(), pEntry, NULL );
     388             :     }
     389             : 
     390           0 :     Reference< XAccessible > SAL_CALL AccessibleListBox::getAccessibleParent(  ) throw (RuntimeException, std::exception)
     391             :     {
     392           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     393             : 
     394           0 :         ensureAlive();
     395           0 :         return m_xParent;
     396             :     }
     397             : 
     398          21 :     sal_Int32 AccessibleListBox::GetRoleType()
     399             :     {
     400          21 :         sal_Int32 nCase = 0;
     401          21 :         SvTreeListEntry* pEntry = getListBox()->GetEntry(0);
     402          21 :         if ( pEntry )
     403             :         {
     404          21 :             if( pEntry->HasChildrenOnDemand() || getListBox()->GetChildCount(pEntry) > 0  )
     405             :             {
     406           0 :                 nCase = 1;
     407           0 :                 return nCase;
     408             :             }
     409             :         }
     410             : 
     411          21 :         bool bHasButtons = (getListBox()->GetStyle() & WB_HASBUTTONS)!=0;
     412          21 :         if( !(getListBox()->GetTreeFlags() & SvTreeFlags::CHKBTN) )
     413             :         {
     414          21 :             if( bHasButtons )
     415          21 :                 nCase = 1;
     416             :         }
     417             :         else
     418             :         {
     419           0 :             if( bHasButtons )
     420           0 :                 nCase = 2;
     421             :              else
     422           0 :                 nCase = 3;
     423             :         }
     424          21 :         return nCase;
     425             :     }
     426             : 
     427          21 :     sal_Int16 SAL_CALL AccessibleListBox::getAccessibleRole()
     428             :         throw (RuntimeException, std::exception)
     429             :     {
     430          21 :         ::comphelper::OExternalLockGuard aGuard( this );
     431             : 
     432          21 :         if(getListBox())
     433             :         {
     434          21 :             SvTreeAccRoleType nType = getListBox()->GetAllEntriesAccessibleRoleType();
     435          21 :             if( nType == SvTreeAccRoleType::TREE)
     436           0 :                     return AccessibleRole::TREE;
     437          21 :             else if( nType == SvTreeAccRoleType::LIST)
     438           0 :                     return AccessibleRole::LIST;
     439             :         }
     440             : 
     441             :         //o is: return AccessibleRole::TREE;
     442          21 :         bool bHasButtons = (getListBox()->GetStyle() & WB_HASBUTTONS)!=0;
     443          21 :         if(!bHasButtons && (getListBox()->GetTreeFlags() & SvTreeFlags::CHKBTN))
     444           0 :             return AccessibleRole::LIST;
     445             :         else
     446          21 :             if (GetRoleType() == 0)
     447           0 :                 return AccessibleRole::LIST;
     448             :             else
     449          21 :             return AccessibleRole::TREE;
     450             :     }
     451             : 
     452           0 :     OUString SAL_CALL AccessibleListBox::getAccessibleDescription(  ) throw (RuntimeException, std::exception)
     453             :     {
     454           0 :         ::comphelper::OExternalLockGuard aGuard( this );
     455             : 
     456           0 :         ensureAlive();
     457           0 :         return getListBox()->GetAccessibleDescription();
     458             :     }
     459             : 
     460           0 :     OUString SAL_CALL AccessibleListBox::getAccessibleName(  ) throw (RuntimeException, std::exception)
     461             :     {
     462           0 :         ::comphelper::OExternalLockGuard aGuard( this );
     463             : 
     464           0 :         ensureAlive();
     465           0 :         return getListBox()->GetAccessibleName();
     466             :     }
     467             : 
     468             :     // XAccessibleSelection
     469             : 
     470           0 :     void SAL_CALL AccessibleListBox::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     471             :     {
     472           0 :         ::comphelper::OExternalLockGuard aGuard( this );
     473             : 
     474           0 :         ensureAlive();
     475             : 
     476           0 :         SvTreeListEntry* pEntry = getListBox()->GetEntry( nChildIndex );
     477           0 :         if ( !pEntry )
     478           0 :             throw IndexOutOfBoundsException();
     479             : 
     480           0 :         getListBox()->Select( pEntry, true );
     481           0 :     }
     482             : 
     483           0 :     sal_Bool SAL_CALL AccessibleListBox::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     484             :     {
     485           0 :         ::comphelper::OExternalLockGuard aGuard( this );
     486             : 
     487           0 :         ensureAlive();
     488             : 
     489           0 :         SvTreeListEntry* pEntry = getListBox()->GetEntry( nChildIndex );
     490           0 :         if ( !pEntry )
     491           0 :             throw IndexOutOfBoundsException();
     492             : 
     493           0 :         return getListBox()->IsSelected( pEntry );
     494             :     }
     495             : 
     496           0 :     void SAL_CALL AccessibleListBox::clearAccessibleSelection(  ) throw (RuntimeException, std::exception)
     497             :     {
     498           0 :         ::comphelper::OExternalLockGuard aGuard( this );
     499             : 
     500           0 :         ensureAlive();
     501             : 
     502           0 :         sal_Int32 nCount = getListBox()->GetLevelChildCount( NULL );
     503           0 :         for ( sal_Int32 i = 0; i < nCount; ++i )
     504             :         {
     505           0 :             SvTreeListEntry* pEntry = getListBox()->GetEntry( i );
     506           0 :             if ( getListBox()->IsSelected( pEntry ) )
     507           0 :                 getListBox()->Select( pEntry, false );
     508           0 :         }
     509           0 :     }
     510             : 
     511           0 :     void SAL_CALL AccessibleListBox::selectAllAccessibleChildren(  ) throw (RuntimeException, std::exception)
     512             :     {
     513           0 :         ::comphelper::OExternalLockGuard aGuard( this );
     514             : 
     515           0 :         ensureAlive();
     516             : 
     517           0 :         sal_Int32 nCount = getListBox()->GetLevelChildCount( NULL );
     518           0 :         for ( sal_Int32 i = 0; i < nCount; ++i )
     519             :         {
     520           0 :             SvTreeListEntry* pEntry = getListBox()->GetEntry( i );
     521           0 :             if ( !getListBox()->IsSelected( pEntry ) )
     522           0 :                 getListBox()->Select( pEntry, true );
     523           0 :         }
     524           0 :     }
     525             : 
     526           0 :     sal_Int32 SAL_CALL AccessibleListBox::getSelectedAccessibleChildCount(  ) throw (RuntimeException, std::exception)
     527             :     {
     528           0 :         ::comphelper::OExternalLockGuard aGuard( this );
     529             : 
     530           0 :         ensureAlive();
     531             : 
     532           0 :         return getListBox()->GetSelectionCount();
     533             :     }
     534             : 
     535           0 :     Reference< XAccessible > SAL_CALL AccessibleListBox::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     536             :     {
     537           0 :         ::comphelper::OExternalLockGuard aGuard( this );
     538             : 
     539           0 :         ensureAlive();
     540             : 
     541           0 :         if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
     542           0 :             throw IndexOutOfBoundsException();
     543             : 
     544           0 :         Reference< XAccessible > xChild;
     545           0 :         sal_Int32 nSelCount= 0;
     546           0 :         sal_Int32 nCount = getListBox()->GetLevelChildCount( NULL );
     547           0 :         for ( sal_Int32 i = 0; i < nCount; ++i )
     548             :         {
     549           0 :             SvTreeListEntry* pEntry = getListBox()->GetEntry( i );
     550           0 :             if ( getListBox()->IsSelected( pEntry ) )
     551           0 :                 ++nSelCount;
     552             : 
     553           0 :             if ( nSelCount == ( nSelectedChildIndex + 1 ) )
     554             :             {
     555             :                 // Solution: Set the parameter of the parent to null to let entry determine the parent by itself
     556             :                 //xChild = new AccessibleListBoxEntry( *getListBox(), pEntry, this );
     557           0 :                 xChild = new AccessibleListBoxEntry( *getListBox(), pEntry, NULL );
     558           0 :                 break;
     559             :             }
     560             :         }
     561             : 
     562           0 :         return xChild;
     563             :     }
     564             : 
     565           0 :     void SAL_CALL AccessibleListBox::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     566             :     {
     567           0 :         ::comphelper::OExternalLockGuard aGuard( this );
     568             : 
     569           0 :         ensureAlive();
     570             : 
     571           0 :         SvTreeListEntry* pEntry = getListBox()->GetEntry( nSelectedChildIndex );
     572           0 :         if ( !pEntry )
     573           0 :             throw IndexOutOfBoundsException();
     574             : 
     575           0 :         getListBox()->Select( pEntry, false );
     576           0 :     }
     577             : 
     578           3 :     void AccessibleListBox::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
     579             :     {
     580           3 :         VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet );
     581           3 :         if ( getListBox() && isAlive() )
     582             :         {
     583           3 :             rStateSet.AddState( AccessibleStateType::FOCUSABLE );
     584           3 :             rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS );
     585           3 :             if ( getListBox()->GetSelectionMode() == MULTIPLE_SELECTION )
     586           0 :                 rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE );
     587             :         }
     588           3 :     }
     589             : 
     590         231 :     VclPtr< SvTreeListBox > AccessibleListBox::getListBox() const
     591             :     {
     592         231 :         return GetAs< SvTreeListBox >();
     593             :     }
     594             : 
     595          36 : }// namespace accessibility
     596             : 
     597             : 
     598             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11