LCOV - code coverage report
Current view: top level - accessibility/source/extended - accessiblelistboxentry.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 639 0.0 %
Date: 2014-04-14 Functions: 0 80 0.0 %
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           0 :     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           0 :         m_aParent       ( _xParent )
      82             : 
      83             :     {
      84           0 :         _rListBox.FillEntryPath( _pEntry, m_aEntryPath );
      85           0 :     }
      86             : 
      87           0 :     AccessibleListBoxEntry::~AccessibleListBoxEntry()
      88             :     {
      89           0 :         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           0 :     }
      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           0 :     sal_Bool AccessibleListBoxEntry::IsAlive_Impl() const
     146             :     {
     147           0 :         return ( !rBHelper.bDisposed && !rBHelper.bInDispose && isAlive() );
     148             :     }
     149             : 
     150           0 :     sal_Bool AccessibleListBoxEntry::IsShowing_Impl() const
     151             :     {
     152           0 :         Reference< XAccessible > xParent = implGetParentAccessible( );
     153             : 
     154           0 :         sal_Bool bShowing = sal_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           0 :     void AccessibleListBoxEntry::EnsureIsAlive() const throw ( lang::DisposedException )
     188             :     {
     189           0 :         if ( !IsAlive_Impl() )
     190           0 :             throw lang::DisposedException();
     191           0 :     }
     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           0 :     void SAL_CALL AccessibleListBoxEntry::dispose() throw ( uno::RuntimeException, std::exception )
     227             :     {
     228           0 :         AccessibleListBoxEntry_BASE::dispose();
     229           0 :     }
     230             : 
     231             : 
     232             :     // XComponent
     233             : 
     234           0 :     void SAL_CALL AccessibleListBoxEntry::disposing()
     235             :     {
     236           0 :         SolarMutexGuard();
     237           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     238             : 
     239           0 :         Reference< XAccessible > xKeepAlive( this );
     240             : 
     241             :         // Send a disposing to all listeners.
     242           0 :         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           0 :             ListBoxAccessibleBase::disposing();
     253             :         }
     254           0 :         m_aParent = WeakReference< XAccessible >();
     255           0 :     }
     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(void) 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(void) throw( RuntimeException )
     286             :     {
     287           0 :         return OUString( "com.sun.star.comp.svtools.AccessibleTreeListBoxEntry" );
     288             :     }
     289             : 
     290             :     // XAccessible
     291             : 
     292           0 :     Reference< XAccessibleContext > SAL_CALL AccessibleListBoxEntry::getAccessibleContext(  ) throw (RuntimeException, std::exception)
     293             :     {
     294           0 :         EnsureIsAlive();
     295           0 :         return this;
     296             :     }
     297             : 
     298             :     // XAccessibleContext
     299             : 
     300           0 :     sal_Int32 SAL_CALL AccessibleListBoxEntry::getAccessibleChildCount(  ) throw (RuntimeException, std::exception)
     301             :     {
     302           0 :         SolarMutexGuard aSolarGuard;
     303           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     304             : 
     305           0 :         EnsureIsAlive();
     306           0 :         SvTreeListEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath );
     307           0 :         sal_Int32 nCount = 0;
     308           0 :         if ( pEntry )
     309           0 :             nCount = getListBox()->GetLevelChildCount( pEntry );
     310             : 
     311           0 :         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 = (Reference< XAccessible >)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           0 :     sal_Int32 AccessibleListBoxEntry::GetRoleType()
     383             :     {
     384           0 :         sal_Int32 nCase = 0;
     385           0 :         SvTreeListEntry* pEntry = getListBox()->GetEntry(0);
     386           0 :         if ( pEntry )
     387             :         {
     388           0 :             if( pEntry->HasChildrenOnDemand() || getListBox()->GetChildCount(pEntry) > 0  )
     389             :             {
     390           0 :                 nCase = 1;
     391           0 :                 return nCase;
     392             :             }
     393             :         }
     394             : 
     395           0 :         sal_Bool bHasButtons = (getListBox()->GetStyle() & WB_HASBUTTONS)!=0;
     396           0 :         if( !(getListBox()->GetTreeFlags() & TREEFLAG_CHKBTN) )
     397             :         {
     398           0 :             if( bHasButtons )
     399           0 :                 nCase = 1;
     400             :         }
     401             :         else
     402             :         {
     403           0 :             if( bHasButtons )
     404           0 :                 nCase = 2;
     405             :              else
     406           0 :                 nCase = 3;
     407             :         }
     408           0 :         return nCase;
     409             :     }
     410             : 
     411           0 :     sal_Int16 SAL_CALL AccessibleListBoxEntry::getAccessibleRole(  ) throw (RuntimeException, std::exception)
     412             :     {
     413           0 :         SolarMutexGuard aSolarGuard;
     414           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     415             : 
     416           0 :         SvTreeListBox* pBox = getListBox();
     417           0 :         if(pBox)
     418             :         {
     419           0 :             short nType = pBox->GetAllEntriesAccessibleRoleType();
     420           0 :             if( nType == TREEBOX_ALLITEM_ACCROLE_TYPE_TREE)
     421           0 :                     return AccessibleRole::TREE_ITEM;
     422           0 :             else if( nType == TREEBOX_ALLITEM_ACCROLE_TYPE_LIST)
     423           0 :                     return AccessibleRole::LIST_ITEM;
     424             : 
     425           0 :             sal_uInt16 treeFlag = pBox->GetTreeFlags();
     426           0 :             if(treeFlag & TREEFLAG_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           0 :             if (GetRoleType() == 0)
     441           0 :                 return AccessibleRole::LIST_ITEM;
     442             :             else
     443             :                 //o is: return AccessibleRole::LABEL;
     444           0 :                 return AccessibleRole::TREE_ITEM;
     445             :         }
     446           0 :         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             :         SvLBoxItem* pItem;
     464           0 :         while( iCount < iTotleItemCount )
     465             :         {
     466           0 :             pItem = pEntry->GetItem( iCount );
     467           0 :             if ( pItem->GetType() == SV_ITEM_ID_LBOXSTRING &&
     468           0 :                  !static_cast<SvLBoxString*>( pItem )->GetText().isEmpty() )
     469             :             {
     470           0 :                 iRealItemCount++;
     471             :             }
     472           0 :             iCount++;
     473             :         }
     474           0 :         if(iRealItemCount<=1  )
     475             :         {
     476           0 :             return OUString();
     477             :         }
     478             :         else
     479             :         {
     480           0 :             return getListBox()->SearchEntryTextWithHeadTitle( pEntry );
     481           0 :         }
     482             :     }
     483             : 
     484           0 :     OUString SAL_CALL AccessibleListBoxEntry::getAccessibleName(  ) throw (RuntimeException, std::exception)
     485             :     {
     486           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     487             : 
     488           0 :         EnsureIsAlive();
     489             : 
     490           0 :         OUString sRet(implGetText());
     491             : 
     492           0 :         SvTreeListEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath );
     493             : 
     494           0 :         OUString altText = getListBox()->GetEntryAltText( pEntry );
     495           0 :         if (!altText.isEmpty())
     496             :         {
     497           0 :             sRet += " ";
     498           0 :             sRet += altText;
     499             :         }
     500             : 
     501           0 :         return sRet;
     502             :     }
     503             : 
     504           0 :     Reference< XAccessibleRelationSet > SAL_CALL AccessibleListBoxEntry::getAccessibleRelationSet(  ) throw (RuntimeException, std::exception)
     505             :     {
     506           0 :         Reference< XAccessibleRelationSet > xRelSet;
     507           0 :         Reference< XAccessible > xParent;
     508           0 :         if ( m_aEntryPath.size() > 1 ) // not a root entry
     509           0 :             xParent = implGetParentAccessible();
     510           0 :         if ( xParent.is() )
     511             :         {
     512           0 :             utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
     513           0 :             Sequence< Reference< XInterface > > aSequence(1);
     514           0 :             aSequence[0] = xParent;
     515             :             pRelationSetHelper->AddRelation(
     516           0 :                 AccessibleRelation( AccessibleRelationType::NODE_CHILD_OF, aSequence ) );
     517           0 :             xRelSet = pRelationSetHelper;
     518             :         }
     519           0 :         return xRelSet;
     520             :     }
     521             : 
     522           0 :     Reference< XAccessibleStateSet > SAL_CALL AccessibleListBoxEntry::getAccessibleStateSet(  ) throw (RuntimeException, std::exception)
     523             :     {
     524           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     525             : 
     526           0 :         utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
     527           0 :         Reference< XAccessibleStateSet > xStateSet = pStateSetHelper;
     528             : 
     529           0 :         if ( IsAlive_Impl() )
     530             :         {
     531           0 :             switch(getAccessibleRole())
     532             :             {
     533             :                 case AccessibleRole::LABEL:
     534           0 :                     pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
     535           0 :                     pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
     536           0 :                     pStateSetHelper->AddState( AccessibleStateType::ENABLED );
     537           0 :                     if (getListBox()->IsInplaceEditingEnabled())
     538           0 :                         pStateSetHelper->AddState( AccessibleStateType::EDITABLE );
     539           0 :                     if (IsShowing_Impl())
     540           0 :                         pStateSetHelper->AddState( AccessibleStateType::SHOWING );
     541           0 :                     break;
     542             :                 case AccessibleRole::CHECK_BOX:
     543           0 :                     pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
     544           0 :                     pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
     545           0 :                     pStateSetHelper->AddState( AccessibleStateType::ENABLED );
     546           0 :                     if (IsShowing_Impl())
     547           0 :                         pStateSetHelper->AddState( AccessibleStateType::SHOWING );
     548           0 :                     break;
     549             :             }
     550           0 :             SvTreeListEntry *pEntry = getListBox()->GetEntryFromPath(m_aEntryPath);
     551           0 :             if (pEntry)
     552           0 :                 getListBox()->FillAccessibleEntryStateSet(pEntry, *pStateSetHelper);
     553             :         }
     554             :         else
     555           0 :             pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
     556             : 
     557           0 :         return xStateSet;
     558             :     }
     559             : 
     560           0 :     Locale SAL_CALL AccessibleListBoxEntry::getLocale(  ) throw (IllegalAccessibleComponentStateException, RuntimeException, std::exception)
     561             :     {
     562           0 :         SolarMutexGuard aSolarGuard;
     563           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     564             : 
     565           0 :         return implGetLocale();
     566             :     }
     567             : 
     568             :     // XAccessibleComponent
     569             : 
     570           0 :     sal_Bool SAL_CALL AccessibleListBoxEntry::containsPoint( const awt::Point& rPoint ) throw (RuntimeException, std::exception)
     571             :     {
     572           0 :         return Rectangle( Point(), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) );
     573             :     }
     574             : 
     575           0 :     Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getAccessibleAtPoint( const awt::Point& _aPoint ) throw (RuntimeException, std::exception)
     576             :     {
     577           0 :         SolarMutexGuard aSolarGuard;
     578           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     579             : 
     580           0 :         EnsureIsAlive();
     581           0 :         SvTreeListEntry* pEntry = getListBox()->GetEntry( VCLPoint( _aPoint ) );
     582           0 :         if ( !pEntry )
     583           0 :             throw RuntimeException();
     584             : 
     585           0 :         Reference< XAccessible > xAcc;
     586           0 :         AccessibleListBoxEntry* pAccEntry = new AccessibleListBoxEntry( *getListBox(), pEntry, this );
     587           0 :         Rectangle aRect = pAccEntry->GetBoundingBox_Impl();
     588           0 :         if ( aRect.IsInside( VCLPoint( _aPoint ) ) )
     589           0 :             xAcc = pAccEntry;
     590           0 :         return xAcc;
     591             :     }
     592             : 
     593           0 :     awt::Rectangle SAL_CALL AccessibleListBoxEntry::getBounds(  ) throw (RuntimeException, std::exception)
     594             :     {
     595           0 :         return AWTRectangle( GetBoundingBox() );
     596             :     }
     597             : 
     598           0 :     awt::Point SAL_CALL AccessibleListBoxEntry::getLocation(  ) throw (RuntimeException, std::exception)
     599             :     {
     600           0 :         return AWTPoint( GetBoundingBox().TopLeft() );
     601             :     }
     602             : 
     603           0 :     awt::Point SAL_CALL AccessibleListBoxEntry::getLocationOnScreen(  ) throw (RuntimeException, std::exception)
     604             :     {
     605           0 :         return AWTPoint( GetBoundingBoxOnScreen().TopLeft() );
     606             :     }
     607             : 
     608           0 :     awt::Size SAL_CALL AccessibleListBoxEntry::getSize(  ) throw (RuntimeException, std::exception)
     609             :     {
     610           0 :         return AWTSize( GetBoundingBox().GetSize() );
     611             :     }
     612             : 
     613           0 :     void SAL_CALL AccessibleListBoxEntry::grabFocus(  ) throw (RuntimeException, std::exception)
     614             :     {
     615             :         // do nothing, because no focus for each item
     616           0 :     }
     617             : 
     618           0 :     sal_Int32 AccessibleListBoxEntry::getForeground(    ) throw (RuntimeException, std::exception)
     619             :     {
     620           0 :         SolarMutexGuard aSolarGuard;
     621           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     622             : 
     623           0 :         sal_Int32 nColor = 0;
     624           0 :         Reference< XAccessible > xParent = getAccessibleParent();
     625           0 :         if ( xParent.is() )
     626             :         {
     627           0 :             Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
     628           0 :             if ( xParentComp.is() )
     629           0 :                 nColor = xParentComp->getForeground();
     630             :         }
     631             : 
     632           0 :         return nColor;
     633             :     }
     634             : 
     635           0 :     sal_Int32 AccessibleListBoxEntry::getBackground(  ) throw (RuntimeException, std::exception)
     636             :     {
     637           0 :         SolarMutexGuard aSolarGuard;
     638           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     639             : 
     640           0 :         sal_Int32 nColor = 0;
     641           0 :         Reference< XAccessible > xParent = getAccessibleParent();
     642           0 :         if ( xParent.is() )
     643             :         {
     644           0 :             Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
     645           0 :             if ( xParentComp.is() )
     646           0 :                 nColor = xParentComp->getBackground();
     647             :         }
     648             : 
     649           0 :         return nColor;
     650             :     }
     651             : 
     652             :     // XAccessibleText
     653             : 
     654             : 
     655           0 :     awt::Rectangle SAL_CALL AccessibleListBoxEntry::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     656             :     {
     657           0 :         SolarMutexGuard aSolarGuard;
     658           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     659             : 
     660           0 :         EnsureIsAlive();
     661             : 
     662           0 :         if ( !implIsValidIndex( nIndex, implGetText().getLength() ) )
     663           0 :             throw IndexOutOfBoundsException();
     664             : 
     665           0 :         awt::Rectangle aBounds( 0, 0, 0, 0 );
     666           0 :         SvTreeListEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath );
     667           0 :         if ( pEntry )
     668             :         {
     669           0 :             ::vcl::ControlLayoutData aLayoutData;
     670           0 :             Rectangle aItemRect = GetBoundingBox();
     671           0 :             getListBox()->RecordLayoutData( &aLayoutData, aItemRect );
     672           0 :             Rectangle aCharRect = aLayoutData.GetCharacterBounds( nIndex );
     673           0 :             aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
     674           0 :             aBounds = AWTRectangle( aCharRect );
     675             :         }
     676             : 
     677           0 :         return aBounds;
     678             :     }
     679             : 
     680           0 :     sal_Int32 SAL_CALL AccessibleListBoxEntry::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException, std::exception)
     681             :     {
     682           0 :         SolarMutexGuard aSolarGuard;
     683           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     684           0 :         EnsureIsAlive();
     685           0 :         if(aPoint.X==0 && aPoint.Y==0) return 0;
     686             : 
     687           0 :         sal_Int32 nIndex = -1;
     688           0 :         SvTreeListEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath );
     689           0 :         if ( pEntry )
     690             :         {
     691           0 :             ::vcl::ControlLayoutData aLayoutData;
     692           0 :             Rectangle aItemRect = GetBoundingBox();
     693           0 :             getListBox()->RecordLayoutData( &aLayoutData, aItemRect );
     694           0 :             Point aPnt( VCLPoint( aPoint ) );
     695           0 :             aPnt += aItemRect.TopLeft();
     696           0 :             nIndex = aLayoutData.GetIndexForPoint( aPnt );
     697             :         }
     698             : 
     699           0 :         return nIndex;
     700             :     }
     701             : 
     702           0 :     sal_Bool SAL_CALL AccessibleListBoxEntry::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     703             :     {
     704           0 :         SolarMutexGuard aSolarGuard;
     705           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     706           0 :         EnsureIsAlive();
     707             : 
     708           0 :         OUString sText = getText();
     709           0 :         if  ( ( 0 > nStartIndex ) || ( sText.getLength() <= nStartIndex )
     710           0 :             || ( 0 > nEndIndex ) || ( sText.getLength() <= nEndIndex ) )
     711           0 :             throw IndexOutOfBoundsException();
     712             : 
     713           0 :         sal_Int32 nLen = nEndIndex - nStartIndex + 1;
     714           0 :         ::svt::OStringTransfer::CopyString( sText.copy( nStartIndex, nLen ), getListBox() );
     715             : 
     716           0 :         return sal_True;
     717             :     }
     718             : 
     719             :     // XAccessibleEventBroadcaster
     720             : 
     721           0 :     void SAL_CALL AccessibleListBoxEntry::addAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException, std::exception)
     722             :     {
     723           0 :         if (xListener.is())
     724             :         {
     725           0 :             ::osl::MutexGuard aGuard( m_aMutex );
     726           0 :             if (!m_nClientId)
     727           0 :                 m_nClientId = comphelper::AccessibleEventNotifier::registerClient( );
     728           0 :             comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener );
     729             :         }
     730           0 :     }
     731             : 
     732           0 :     void SAL_CALL AccessibleListBoxEntry::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException, std::exception)
     733             :     {
     734           0 :         if (xListener.is())
     735             :         {
     736           0 :             ::osl::MutexGuard aGuard( m_aMutex );
     737             : 
     738           0 :             sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener );
     739           0 :             if ( !nListenerCount )
     740             :             {
     741             :                 // no listeners anymore
     742             :                 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
     743             :                 // and at least to us not firing any events anymore, in case somebody calls
     744             :                 // NotifyAccessibleEvent, again
     745           0 :                 sal_Int32 nId = m_nClientId;
     746           0 :                 m_nClientId = 0;
     747           0 :                 comphelper::AccessibleEventNotifier::revokeClient( nId );
     748             : 
     749           0 :             }
     750             :         }
     751           0 :     }
     752             : 
     753             :     // XAccessibleAction
     754             : 
     755           0 :     sal_Int32 SAL_CALL AccessibleListBoxEntry::getAccessibleActionCount(  ) throw (RuntimeException, std::exception)
     756             :     {
     757           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     758             : 
     759             :         // three actions supported
     760           0 :         SvTreeListBox* pBox = getListBox();
     761           0 :         sal_uInt16 treeFlag = pBox->GetTreeFlags();
     762           0 :         sal_Bool bHasButtons = (getListBox()->GetStyle() & WB_HASBUTTONS)!=0;
     763           0 :         if( (treeFlag & TREEFLAG_CHKBTN) && !bHasButtons)
     764             :         {
     765           0 :             sal_Int16 role = getAccessibleRole();
     766           0 :             if ( role == AccessibleRole::CHECK_BOX )
     767           0 :                 return 2;
     768           0 :             else if ( role == AccessibleRole::LABEL )
     769           0 :                 return 0;
     770             :         }
     771             :         else
     772           0 :             return ACCESSIBLE_ACTION_COUNT;
     773           0 :         return 0;
     774             :     }
     775             : 
     776           0 :     sal_Bool SAL_CALL AccessibleListBoxEntry::doAccessibleAction( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     777             :     {
     778           0 :         SolarMutexGuard aSolarGuard;
     779           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     780             : 
     781           0 :         sal_Bool bRet = sal_False;
     782           0 :         checkActionIndex_Impl( nIndex );
     783           0 :         EnsureIsAlive();
     784             : 
     785           0 :         sal_uInt16 treeFlag = getListBox()->GetTreeFlags();
     786           0 :         if( nIndex == 0 && (treeFlag & TREEFLAG_CHKBTN) )
     787             :         {
     788           0 :             if(getAccessibleRole() == AccessibleRole::CHECK_BOX)
     789             :             {
     790           0 :                 SvTreeListEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath );
     791           0 :                 SvButtonState state = getListBox()->GetCheckButtonState( pEntry );
     792           0 :                 if ( state == SV_BUTTON_CHECKED )
     793           0 :                     getListBox()->SetCheckButtonState(pEntry, (SvButtonState)SV_BMP_UNCHECKED);
     794           0 :                 else if (state == SV_BMP_UNCHECKED)
     795           0 :                     getListBox()->SetCheckButtonState(pEntry, (SvButtonState)SV_BUTTON_CHECKED);
     796           0 :             }
     797             :         }
     798           0 :         else if( (nIndex == 1 && (treeFlag & TREEFLAG_CHKBTN) ) || (nIndex == 0) )
     799             :         {
     800           0 :             SvTreeListEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath );
     801           0 :             if ( pEntry )
     802             :             {
     803           0 :                 if ( getListBox()->IsExpanded( pEntry ) )
     804           0 :                     getListBox()->Collapse( pEntry );
     805             :                 else
     806           0 :                     getListBox()->Expand( pEntry );
     807           0 :                 bRet = sal_True;
     808             :             }
     809             :         }
     810             : 
     811           0 :         return bRet;
     812             :     }
     813             : 
     814           0 :     OUString SAL_CALL AccessibleListBoxEntry::getAccessibleActionDescription( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     815             :     {
     816           0 :         SolarMutexGuard aSolarGuard;
     817           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     818             : 
     819           0 :         checkActionIndex_Impl( nIndex );
     820           0 :         EnsureIsAlive();
     821             : 
     822           0 :         static const OUString sActionDesc1( "Check" );
     823           0 :         static const OUString sActionDesc2( "UnCheck" );
     824             :         // sal_Bool bHasButtons = (getListBox()->GetStyle() & WB_HASBUTTONS)!=0;
     825           0 :         SvTreeListEntry* pEntry = getListBox()->GetEntryFromPath( m_aEntryPath );
     826           0 :         SvButtonState state = getListBox()->GetCheckButtonState( pEntry );
     827           0 :         sal_uInt16 treeFlag = getListBox()->GetTreeFlags();
     828           0 :         if(nIndex == 0 && (treeFlag & TREEFLAG_CHKBTN))
     829             :         {
     830           0 :             if(getAccessibleRole() == AccessibleRole::CHECK_BOX)
     831             :             {
     832           0 :                 if ( state == SV_BUTTON_CHECKED )
     833           0 :                     return sActionDesc2;
     834           0 :                 else if (state == SV_BMP_UNCHECKED)
     835           0 :                     return sActionDesc1;
     836             :             }
     837             :             else
     838             :             {
     839             :                 //Sometimes, a List or Tree may have both checkbox and label at the same time
     840           0 :                 return OUString();
     841             :             }
     842           0 :         }else if( (nIndex == 1 && (treeFlag & TREEFLAG_CHKBTN)) || nIndex == 0 )
     843             :         {
     844           0 :             if( pEntry->HasChildren() || pEntry->HasChildrenOnDemand() )
     845           0 :                 return getListBox()->IsExpanded( pEntry ) ? \
     846             :                 OUString(TK_RES_STRING(STR_SVT_ACC_ACTION_COLLAPSE)) :
     847           0 :                 OUString(TK_RES_STRING(STR_SVT_ACC_ACTION_EXPAND));
     848           0 :             return OUString();
     849             : 
     850             :         }
     851           0 :         throw IndexOutOfBoundsException();
     852             :     }
     853             : 
     854           0 :     Reference< XAccessibleKeyBinding > AccessibleListBoxEntry::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     855             :     {
     856           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     857             : 
     858           0 :         Reference< XAccessibleKeyBinding > xRet;
     859           0 :         checkActionIndex_Impl( nIndex );
     860             :         // ... which key?
     861           0 :         return xRet;
     862             :     }
     863             : 
     864             :     // XAccessibleSelection
     865             : 
     866           0 :     void SAL_CALL AccessibleListBoxEntry::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     867             :     {
     868           0 :         SolarMutexGuard aSolarGuard;
     869           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     870             : 
     871           0 :         EnsureIsAlive();
     872             : 
     873           0 :         SvTreeListEntry* pEntry = GetRealChild(nChildIndex);
     874           0 :         if ( !pEntry )
     875           0 :             throw IndexOutOfBoundsException();
     876             : 
     877           0 :         getListBox()->Select( pEntry, true );
     878           0 :     }
     879             : 
     880           0 :     sal_Bool SAL_CALL AccessibleListBoxEntry::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     881             :     {
     882           0 :         SolarMutexGuard aSolarGuard;
     883           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     884             : 
     885           0 :         EnsureIsAlive();
     886             : 
     887           0 :         SvTreeListEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath );
     888           0 :         SvTreeListEntry* pEntry = getListBox()->GetEntry( pParent, nChildIndex );
     889           0 :         if ( !pEntry )
     890           0 :             throw IndexOutOfBoundsException();
     891             : 
     892           0 :         return getListBox()->IsSelected( pEntry );
     893             :     }
     894             : 
     895           0 :     void SAL_CALL AccessibleListBoxEntry::clearAccessibleSelection(  ) throw (RuntimeException, std::exception)
     896             :     {
     897           0 :         SolarMutexGuard aSolarGuard;
     898           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     899             : 
     900           0 :         EnsureIsAlive();
     901             : 
     902           0 :         SvTreeListEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath );
     903           0 :         if ( !pParent )
     904           0 :             throw RuntimeException();
     905           0 :         sal_Int32 nCount = getListBox()->GetLevelChildCount( pParent );
     906           0 :         for ( sal_Int32 i = 0; i < nCount; ++i )
     907             :         {
     908           0 :             SvTreeListEntry* pEntry = getListBox()->GetEntry( pParent, i );
     909           0 :             if ( getListBox()->IsSelected( pEntry ) )
     910           0 :                 getListBox()->Select( pEntry, false );
     911           0 :         }
     912           0 :     }
     913             : 
     914           0 :     void SAL_CALL AccessibleListBoxEntry::selectAllAccessibleChildren(  ) throw (RuntimeException, std::exception)
     915             :     {
     916           0 :         SolarMutexGuard aSolarGuard;
     917           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     918             : 
     919           0 :         EnsureIsAlive();
     920             : 
     921           0 :         SvTreeListEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath );
     922           0 :         if ( !pParent )
     923           0 :             throw RuntimeException();
     924           0 :         sal_Int32 nCount = getListBox()->GetLevelChildCount( pParent );
     925           0 :         for ( sal_Int32 i = 0; i < nCount; ++i )
     926             :         {
     927           0 :             SvTreeListEntry* pEntry = getListBox()->GetEntry( pParent, i );
     928           0 :             if ( !getListBox()->IsSelected( pEntry ) )
     929           0 :                 getListBox()->Select( pEntry, true );
     930           0 :         }
     931           0 :     }
     932             : 
     933           0 :     sal_Int32 SAL_CALL AccessibleListBoxEntry::getSelectedAccessibleChildCount(  ) throw (RuntimeException, std::exception)
     934             :     {
     935           0 :         SolarMutexGuard aSolarGuard;
     936           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     937             : 
     938           0 :         EnsureIsAlive();
     939             : 
     940           0 :         sal_Int32 i, nSelCount = 0, nCount = 0;
     941             : 
     942           0 :         SvTreeListEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath );
     943           0 :         if ( !pParent )
     944           0 :             throw RuntimeException();
     945           0 :         nCount = getListBox()->GetLevelChildCount( pParent );
     946           0 :         for ( i = 0; i < nCount; ++i )
     947             :         {
     948           0 :             SvTreeListEntry* pEntry = getListBox()->GetEntry( pParent, i );
     949           0 :             if ( getListBox()->IsSelected( pEntry ) )
     950           0 :                 ++nSelCount;
     951             :         }
     952             : 
     953           0 :         return nSelCount;
     954             :     }
     955             : 
     956           0 :     Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     957             :     {
     958           0 :         SolarMutexGuard aSolarGuard;
     959           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     960             : 
     961           0 :         EnsureIsAlive();
     962             : 
     963           0 :         if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
     964           0 :             throw IndexOutOfBoundsException();
     965             : 
     966           0 :         Reference< XAccessible > xChild;
     967           0 :         sal_Int32 i, nSelCount = 0, nCount = 0;
     968             : 
     969           0 :         SvTreeListEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath );
     970           0 :         if ( !pParent )
     971           0 :             throw RuntimeException();
     972           0 :         nCount = getListBox()->GetLevelChildCount( pParent );
     973           0 :         for ( i = 0; i < nCount; ++i )
     974             :         {
     975           0 :             SvTreeListEntry* pEntry = getListBox()->GetEntry( pParent, i );
     976           0 :             if ( getListBox()->IsSelected( pEntry ) )
     977           0 :                 ++nSelCount;
     978             : 
     979           0 :             if ( nSelCount == ( nSelectedChildIndex + 1 ) )
     980             :             {
     981           0 :                 xChild = new AccessibleListBoxEntry( *getListBox(), pEntry, this );
     982           0 :                 break;
     983             :             }
     984             :         }
     985             : 
     986           0 :         return xChild;
     987             :     }
     988             : 
     989           0 :     void SAL_CALL AccessibleListBoxEntry::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     990             :     {
     991           0 :         SolarMutexGuard aSolarGuard;
     992           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     993             : 
     994           0 :         EnsureIsAlive();
     995             : 
     996           0 :         SvTreeListEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath );
     997           0 :         SvTreeListEntry* pEntry = getListBox()->GetEntry( pParent, nSelectedChildIndex );
     998           0 :         if ( !pEntry )
     999           0 :             throw IndexOutOfBoundsException();
    1000             : 
    1001           0 :         getListBox()->Select( pEntry, false );
    1002           0 :     }
    1003           0 :     sal_Int32 SAL_CALL AccessibleListBoxEntry::getCaretPosition(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
    1004             :     {
    1005           0 :         return -1;
    1006             :     }
    1007           0 :     sal_Bool SAL_CALL AccessibleListBoxEntry::setCaretPosition ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
    1008             :     {
    1009           0 :         SolarMutexGuard aSolarGuard;
    1010           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    1011           0 :         EnsureIsAlive();
    1012             : 
    1013           0 :         if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
    1014           0 :             throw IndexOutOfBoundsException();
    1015             : 
    1016           0 :         return sal_False;
    1017             :     }
    1018           0 :     sal_Unicode SAL_CALL AccessibleListBoxEntry::getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
    1019             :     {
    1020           0 :         SolarMutexGuard aSolarGuard;
    1021           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    1022           0 :         EnsureIsAlive();
    1023           0 :         return OCommonAccessibleText::getCharacter( nIndex );
    1024             :     }
    1025           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)
    1026             :     {
    1027           0 :         SolarMutexGuard aSolarGuard;
    1028           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    1029           0 :         EnsureIsAlive();
    1030             : 
    1031           0 :         OUString sText( implGetText() );
    1032             : 
    1033           0 :         if ( !implIsValidIndex( nIndex, sText.getLength() ) )
    1034           0 :             throw IndexOutOfBoundsException();
    1035             : 
    1036           0 :         return ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >();
    1037             :     }
    1038           0 :     sal_Int32 SAL_CALL AccessibleListBoxEntry::getCharacterCount(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
    1039             :     {
    1040           0 :         SolarMutexGuard aSolarGuard;
    1041           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    1042           0 :         EnsureIsAlive();
    1043           0 :         return OCommonAccessibleText::getCharacterCount(  );
    1044             :     }
    1045             : 
    1046           0 :     OUString SAL_CALL AccessibleListBoxEntry::getSelectedText(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
    1047             :     {
    1048           0 :         SolarMutexGuard aSolarGuard;
    1049           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    1050           0 :         EnsureIsAlive();
    1051           0 :         return OCommonAccessibleText::getSelectedText(  );
    1052             :     }
    1053           0 :     sal_Int32 SAL_CALL AccessibleListBoxEntry::getSelectionStart(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
    1054             :     {
    1055           0 :         SolarMutexGuard aSolarGuard;
    1056           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    1057           0 :         EnsureIsAlive();
    1058           0 :         return OCommonAccessibleText::getSelectionStart(  );
    1059             :     }
    1060           0 :     sal_Int32 SAL_CALL AccessibleListBoxEntry::getSelectionEnd(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
    1061             :     {
    1062           0 :         SolarMutexGuard aSolarGuard;
    1063           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    1064           0 :         EnsureIsAlive();
    1065           0 :         return OCommonAccessibleText::getSelectionEnd(  );
    1066             :     }
    1067           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)
    1068             :     {
    1069           0 :         SolarMutexGuard aSolarGuard;
    1070           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    1071           0 :         EnsureIsAlive();
    1072             : 
    1073           0 :         if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
    1074           0 :             throw IndexOutOfBoundsException();
    1075             : 
    1076           0 :         return sal_False;
    1077             :     }
    1078           0 :     OUString SAL_CALL AccessibleListBoxEntry::getText(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
    1079             :     {
    1080           0 :         SolarMutexGuard aSolarGuard;
    1081           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    1082           0 :         EnsureIsAlive();
    1083           0 :         return OCommonAccessibleText::getText(  );
    1084             :     }
    1085           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)
    1086             :     {
    1087           0 :         SolarMutexGuard aSolarGuard;
    1088           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    1089           0 :         EnsureIsAlive();
    1090           0 :         return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
    1091             :     }
    1092           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)
    1093             :     {
    1094           0 :         SolarMutexGuard aSolarGuard;
    1095           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    1096           0 :         EnsureIsAlive();
    1097           0 :         return OCommonAccessibleText::getTextAtIndex( nIndex ,aTextType);
    1098             :     }
    1099           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)
    1100             :     {
    1101           0 :         SolarMutexGuard aSolarGuard;
    1102           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    1103           0 :         EnsureIsAlive();
    1104           0 :         return OCommonAccessibleText::getTextBeforeIndex( nIndex ,aTextType);
    1105             :     }
    1106           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)
    1107             :     {
    1108           0 :         SolarMutexGuard aSolarGuard;
    1109           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    1110           0 :         EnsureIsAlive();
    1111             : 
    1112           0 :         return OCommonAccessibleText::getTextBehindIndex( nIndex ,aTextType);
    1113             :     }
    1114             : 
    1115             :     // XAccessibleValue
    1116             : 
    1117             : 
    1118           0 :     Any AccessibleListBoxEntry::getCurrentValue(  ) throw (RuntimeException, std::exception)
    1119             :     {
    1120           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    1121           0 :         Any aValue;
    1122           0 :         sal_Int32 level = ((sal_Int32) m_aEntryPath.size() - 1);
    1123           0 :         level = level < 0 ?  0: level;
    1124           0 :         aValue <<= level;
    1125           0 :         return aValue;
    1126             :     }
    1127             : 
    1128             : 
    1129             : 
    1130           0 :     sal_Bool AccessibleListBoxEntry::setCurrentValue( const Any& aNumber ) throw (RuntimeException, std::exception)
    1131             :     {
    1132           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    1133             : 
    1134             : 
    1135           0 :         sal_Bool bReturn = sal_False;
    1136           0 :         SvTreeListBox* pBox = getListBox();
    1137           0 :         if(getAccessibleRole() == AccessibleRole::CHECK_BOX)
    1138             :         {
    1139           0 :             SvTreeListEntry* pEntry = pBox->GetEntryFromPath( m_aEntryPath );
    1140           0 :             if ( pEntry )
    1141             :             {
    1142           0 :                 sal_Int32 nValue(0), nValueMin(0), nValueMax(0);
    1143           0 :                 aNumber >>= nValue;
    1144           0 :                 getMinimumValue() >>= nValueMin;
    1145           0 :                 getMaximumValue() >>= nValueMax;
    1146             : 
    1147           0 :                 if ( nValue < nValueMin )
    1148           0 :                     nValue = nValueMin;
    1149           0 :                 else if ( nValue > nValueMax )
    1150           0 :                     nValue = nValueMax;
    1151             : 
    1152           0 :                 pBox->SetCheckButtonState(pEntry,  (SvButtonState) nValue );
    1153           0 :                 bReturn = sal_True;
    1154             :             }
    1155             :         }
    1156             : 
    1157           0 :         return bReturn;
    1158             :     }
    1159             : 
    1160             : 
    1161             : 
    1162           0 :     Any AccessibleListBoxEntry::getMaximumValue(  ) throw (RuntimeException, std::exception)
    1163             :     {
    1164           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    1165             : 
    1166           0 :         Any aValue;
    1167             :         // SvTreeListBox* pBox = getListBox();
    1168           0 :         switch(getAccessibleRole())
    1169             :         {
    1170             :             case AccessibleRole::CHECK_BOX:
    1171           0 :                 aValue <<= (sal_Int32)1;
    1172           0 :                 break;
    1173             :             case AccessibleRole::LABEL:
    1174             :             default:
    1175           0 :                 break;
    1176             :         }
    1177             : 
    1178           0 :         return aValue;
    1179             :     }
    1180             : 
    1181             : 
    1182             : 
    1183           0 :     Any AccessibleListBoxEntry::getMinimumValue(  ) throw (RuntimeException, std::exception)
    1184             :     {
    1185           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    1186             : 
    1187           0 :         Any aValue;
    1188             :         // SvTreeListBox* pBox = getListBox();
    1189           0 :         switch(getAccessibleRole())
    1190             :         {
    1191             :             case AccessibleRole::CHECK_BOX:
    1192           0 :                 aValue <<= (sal_Int32)0;
    1193           0 :                 break;
    1194             :             case AccessibleRole::LABEL:
    1195             :             default:
    1196           0 :                 break;
    1197             :         }
    1198             : 
    1199           0 :         return aValue;
    1200             :     }
    1201             : 
    1202             : 
    1203             : 
    1204           0 :     SvTreeListEntry* AccessibleListBoxEntry::GetRealChild(sal_Int32 nIndex)
    1205             :     {
    1206           0 :         SvTreeListEntry* pEntry = NULL;
    1207           0 :         SvTreeListEntry* pParent = getListBox()->GetEntryFromPath( m_aEntryPath );
    1208           0 :         if (pParent)
    1209             :         {
    1210           0 :             pEntry = getListBox()->GetEntry( pParent, nIndex );
    1211           0 :             if ( !pEntry && getAccessibleChildCount() > 0 )
    1212             :             {
    1213           0 :                 getListBox()->RequestingChildren(pParent);
    1214           0 :                 pEntry = getListBox()->GetEntry( pParent, nIndex );
    1215             :             }
    1216             :         }
    1217           0 :         return pEntry;
    1218             :     }
    1219             : 
    1220             : }// namespace accessibility
    1221             : 
    1222             : 
    1223             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10