LCOV - code coverage report
Current view: top level - accessibility/source/standard - vclxaccessiblelistitem.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 84 301 27.9 %
Date: 2015-06-13 12:38:46 Functions: 17 60 28.3 %
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/standard/vclxaccessiblelistitem.hxx>
      21             : #include <toolkit/helper/convert.hxx>
      22             : #include <accessibility/helper/listboxhelper.hxx>
      23             : #include <com/sun/star/awt/Point.hpp>
      24             : #include <com/sun/star/awt/Rectangle.hpp>
      25             : #include <com/sun/star/awt/Size.hpp>
      26             : 
      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 <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
      31             : #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
      32             : #include <cppuhelper/supportsservice.hxx>
      33             : #include <vcl/svapp.hxx>
      34             : #include <vcl/controllayout.hxx>
      35             : #include <vcl/unohelp2.hxx>
      36             : #include <vcl/settings.hxx>
      37             : #include <toolkit/awt/vclxwindow.hxx>
      38             : #include <unotools/accessiblestatesethelper.hxx>
      39             : #include <unotools/accessiblerelationsethelper.hxx>
      40             : #include <cppuhelper/typeprovider.hxx>
      41             : #include <comphelper/sequence.hxx>
      42             : #include <comphelper/accessibleeventnotifier.hxx>
      43             : 
      44             : namespace
      45             : {
      46           0 :     void checkIndex_Impl( sal_Int32 _nIndex, const OUString& _sText ) throw (::com::sun::star::lang::IndexOutOfBoundsException)
      47             :     {
      48           0 :         if ( _nIndex < 0 || _nIndex > _sText.getLength() )
      49           0 :             throw ::com::sun::star::lang::IndexOutOfBoundsException();
      50           0 :     }
      51             : }
      52             : 
      53             : // class VCLXAccessibleListItem ------------------------------------------
      54             : 
      55             : using namespace ::com::sun::star::accessibility;
      56             : using namespace ::com::sun::star::uno;
      57             : using namespace ::com::sun::star::beans;
      58             : using namespace ::com::sun::star::lang;
      59             : using namespace ::com::sun::star;
      60             : 
      61             : 
      62             : // Ctor() and Dtor()
      63             : 
      64         150 : VCLXAccessibleListItem::VCLXAccessibleListItem( ::accessibility::IComboListBoxHelper* _pListBoxHelper, sal_Int32 _nIndexInParent, const Reference< XAccessible >& _xParent ) :
      65             : 
      66             :     VCLXAccessibleListItem_BASE ( m_aMutex ),
      67             : 
      68             :     m_nIndexInParent( _nIndexInParent ),
      69             :     m_bSelected     ( false ),
      70             :     m_bVisible      ( false ),
      71             :     m_nClientId     ( 0 ),
      72             :     m_pListBoxHelper( _pListBoxHelper ),
      73         150 :     m_xParent       ( _xParent )
      74             : 
      75             : {
      76         150 :     if ( m_xParent.is() )
      77         150 :         m_xParentContext = m_xParent->getAccessibleContext();
      78             : 
      79         150 :     if ( m_pListBoxHelper )
      80         150 :         m_sEntryText = m_pListBoxHelper->GetEntry( (sal_uInt16)_nIndexInParent );
      81         150 : }
      82             : 
      83          48 : VCLXAccessibleListItem::~VCLXAccessibleListItem()
      84             : {
      85          48 : }
      86             : 
      87         150 : void VCLXAccessibleListItem::SetSelected( bool _bSelected )
      88             : {
      89         150 :     if ( m_bSelected != _bSelected )
      90             :     {
      91           7 :         Any aOldValue;
      92          14 :         Any aNewValue;
      93           7 :         if ( m_bSelected )
      94           0 :             aOldValue <<= AccessibleStateType::SELECTED;
      95             :         else
      96           7 :             aNewValue <<= AccessibleStateType::SELECTED;
      97           7 :         m_bSelected = _bSelected;
      98          14 :         NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
      99             :     }
     100         150 : }
     101             : 
     102         150 : void VCLXAccessibleListItem::SetVisible( bool _bVisible )
     103             : {
     104         150 :     if ( m_bVisible != _bVisible )
     105             :     {
     106           4 :         Any aOldValue, aNewValue;
     107           2 :         m_bVisible = _bVisible;
     108           2 :         (_bVisible ? aNewValue : aOldValue ) <<= AccessibleStateType::VISIBLE;
     109           2 :         NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     110           2 :         (_bVisible ? aNewValue : aOldValue ) <<= AccessibleStateType::SHOWING;
     111           4 :         NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     112             :     }
     113         150 : }
     114             : 
     115          11 : void VCLXAccessibleListItem::NotifyAccessibleEvent( sal_Int16 _nEventId,
     116             :                                                     const ::com::sun::star::uno::Any& _aOldValue,
     117             :                                                     const ::com::sun::star::uno::Any& _aNewValue )
     118             : {
     119          11 :     AccessibleEventObject aEvt;
     120          11 :     aEvt.Source = *this;
     121          11 :     aEvt.EventId = _nEventId;
     122          11 :     aEvt.OldValue = _aOldValue;
     123          11 :     aEvt.NewValue = _aNewValue;
     124             : 
     125          11 :     if (m_nClientId)
     126           0 :         comphelper::AccessibleEventNotifier::addEvent( m_nClientId, aEvt );
     127          11 : }
     128             : 
     129             : // OCommonAccessibleText
     130             : 
     131           0 : OUString VCLXAccessibleListItem::implGetText()
     132             : {
     133           0 :     return m_sEntryText;
     134             : }
     135             : 
     136           0 : Locale VCLXAccessibleListItem::implGetLocale()
     137             : {
     138           0 :     return Application::GetSettings().GetLanguageTag().getLocale();
     139             : }
     140             : 
     141           0 : void VCLXAccessibleListItem::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
     142             : {
     143           0 :     nStartIndex = 0;
     144           0 :     nEndIndex = 0;
     145           0 : }
     146             : 
     147             : // XInterface
     148             : 
     149         950 : Any SAL_CALL VCLXAccessibleListItem::queryInterface( Type const & rType ) throw (RuntimeException, std::exception)
     150             : {
     151         950 :     return VCLXAccessibleListItem_BASE::queryInterface( rType );
     152             : }
     153             : 
     154        2818 : void SAL_CALL VCLXAccessibleListItem::acquire() throw ()
     155             : {
     156        2818 :     VCLXAccessibleListItem_BASE::acquire();
     157        2818 : }
     158             : 
     159        1810 : void SAL_CALL VCLXAccessibleListItem::release() throw ()
     160             : {
     161        1810 :     VCLXAccessibleListItem_BASE::release();
     162        1810 : }
     163             : 
     164             : // XTypeProvider
     165             : 
     166           0 : Sequence< Type > SAL_CALL VCLXAccessibleListItem::getTypes(  ) throw (RuntimeException, std::exception)
     167             : {
     168           0 :     return VCLXAccessibleListItem_BASE::getTypes();
     169             : }
     170             : 
     171           0 : Sequence< sal_Int8 > VCLXAccessibleListItem::getImplementationId() throw (RuntimeException, std::exception)
     172             : {
     173           0 :     return css::uno::Sequence<sal_Int8>();
     174             : }
     175             : 
     176             : // XComponent
     177             : 
     178          24 : void SAL_CALL VCLXAccessibleListItem::disposing()
     179             : {
     180          24 :     comphelper::AccessibleEventNotifier::TClientId nId( 0 );
     181          24 :     Reference< XInterface > xEventSource;
     182             :     {
     183          24 :         ::osl::MutexGuard aGuard( m_aMutex );
     184             : 
     185          24 :         VCLXAccessibleListItem_BASE::disposing();
     186          24 :         m_sEntryText.clear();
     187          24 :         m_pListBoxHelper    = NULL;
     188          24 :         m_xParent           = NULL;
     189          24 :         m_xParentContext    = NULL;
     190             : 
     191          24 :         nId = m_nClientId;
     192          24 :         m_nClientId =  0;
     193          24 :         if ( nId )
     194           0 :             xEventSource = *this;
     195             :     }
     196             : 
     197             :     // Send a disposing to all listeners.
     198          24 :     if ( nId )
     199           0 :             comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this );
     200          24 : }
     201             : 
     202             : // XServiceInfo
     203             : 
     204           0 : OUString VCLXAccessibleListItem::getImplementationName() throw (RuntimeException, std::exception)
     205             : {
     206           0 :     return OUString( "com.sun.star.comp.toolkit.AccessibleListItem" );
     207             : }
     208             : 
     209           0 : sal_Bool VCLXAccessibleListItem::supportsService( const OUString& rServiceName ) throw (RuntimeException, std::exception)
     210             : {
     211           0 :     return cppu::supportsService(this, rServiceName);
     212             : }
     213             : 
     214           0 : Sequence< OUString > VCLXAccessibleListItem::getSupportedServiceNames() throw (RuntimeException, std::exception)
     215             : {
     216           0 :     Sequence< OUString > aNames(3);
     217           0 :     aNames[0] = "com.sun.star.accessibility.AccessibleContext";
     218           0 :     aNames[1] = "com.sun.star.accessibility.AccessibleComponent";
     219           0 :     aNames[2] = "com.sun.star.accessibility.AccessibleListItem";
     220           0 :     return aNames;
     221             : }
     222             : 
     223             : // XAccessible
     224             : 
     225         148 : Reference< XAccessibleContext > SAL_CALL VCLXAccessibleListItem::getAccessibleContext(  ) throw (RuntimeException, std::exception)
     226             : {
     227         148 :     return this;
     228             : }
     229             : 
     230             : // XAccessibleContext
     231             : 
     232         296 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getAccessibleChildCount(  ) throw (RuntimeException, std::exception)
     233             : {
     234         296 :     return 0;
     235             : }
     236             : 
     237           0 : Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleChild( sal_Int32 ) throw (RuntimeException, std::exception)
     238             : {
     239           0 :     return Reference< XAccessible >();
     240             : }
     241             : 
     242           0 : Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleParent(  ) throw (RuntimeException, std::exception)
     243             : {
     244           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     245             : 
     246           0 :     return m_xParent;
     247             : }
     248             : 
     249           0 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getAccessibleIndexInParent(  ) throw (RuntimeException, std::exception)
     250             : {
     251           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     252           0 :     return m_nIndexInParent;
     253             : }
     254             : 
     255         148 : sal_Int16 SAL_CALL VCLXAccessibleListItem::getAccessibleRole(  ) throw (RuntimeException, std::exception)
     256             : {
     257         148 :     return AccessibleRole::LIST_ITEM;
     258             :     //  return AccessibleRole::LABEL;
     259             : }
     260             : 
     261           0 : OUString SAL_CALL VCLXAccessibleListItem::getAccessibleDescription(  ) throw (RuntimeException, std::exception)
     262             : {
     263             :     // no description for every item
     264           0 :     return OUString();
     265             : }
     266             : 
     267           0 : OUString SAL_CALL VCLXAccessibleListItem::getAccessibleName(  ) throw (RuntimeException, std::exception)
     268             : {
     269           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     270             : 
     271             :     // entry text == accessible name
     272           0 :     return implGetText();
     273             : }
     274             : 
     275           0 : Reference< XAccessibleRelationSet > SAL_CALL VCLXAccessibleListItem::getAccessibleRelationSet(  ) throw (RuntimeException, std::exception)
     276             : {
     277           0 :     utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
     278           0 :     Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
     279           0 :     return xSet;
     280             : }
     281             : 
     282         274 : Reference< XAccessibleStateSet > SAL_CALL VCLXAccessibleListItem::getAccessibleStateSet(  ) throw (RuntimeException, std::exception)
     283             : {
     284         274 :     ::osl::MutexGuard aGuard( m_aMutex );
     285             : 
     286         274 :     utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
     287         274 :     Reference< XAccessibleStateSet > xStateSet = pStateSetHelper;
     288             : 
     289         274 :     if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
     290             :     {
     291         274 :         pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
     292             : 
     293         274 :         if(m_pListBoxHelper->IsEnabled())
     294             :         {
     295         274 :             pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
     296         274 :             pStateSetHelper->AddState( AccessibleStateType::ENABLED );
     297         274 :             pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
     298             :         }
     299             : 
     300         274 :         if ( m_bSelected )
     301           7 :             pStateSetHelper->AddState( AccessibleStateType::SELECTED );
     302         548 :         if ( m_bVisible )
     303             :         {
     304           0 :             pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
     305           0 :             pStateSetHelper->AddState( AccessibleStateType::SHOWING );
     306             :         }
     307             :     }
     308             :     else
     309           0 :         pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
     310             : 
     311         274 :     return xStateSet;
     312             : }
     313             : 
     314           0 : Locale SAL_CALL VCLXAccessibleListItem::getLocale(  ) throw (IllegalAccessibleComponentStateException, RuntimeException, std::exception)
     315             : {
     316           0 :     SolarMutexGuard aSolarGuard;
     317           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     318             : 
     319           0 :     return implGetLocale();
     320             : }
     321             : 
     322             : // XAccessibleComponent
     323             : 
     324           0 : sal_Bool SAL_CALL VCLXAccessibleListItem::containsPoint( const awt::Point& _aPoint ) throw (RuntimeException, std::exception)
     325             : {
     326           0 :     SolarMutexGuard aSolarGuard;
     327           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     328             : 
     329           0 :     bool bInside = false;
     330           0 :     if ( m_pListBoxHelper )
     331             :     {
     332           0 :         Rectangle aRect( m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ) );
     333           0 :         aRect.Move(-aRect.TopLeft().X(),-aRect.TopLeft().Y());
     334           0 :         bInside = aRect.IsInside( VCLPoint( _aPoint ) );
     335             :     }
     336           0 :     return bInside;
     337             : }
     338             : 
     339           0 : Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException, std::exception)
     340             : {
     341           0 :     return Reference< XAccessible >();
     342             : }
     343             : 
     344           0 : awt::Rectangle SAL_CALL VCLXAccessibleListItem::getBounds(  ) throw (RuntimeException, std::exception)
     345             : {
     346           0 :     SolarMutexGuard aSolarGuard;
     347           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     348             : 
     349           0 :     awt::Rectangle aRect;
     350           0 :     if ( m_pListBoxHelper )
     351           0 :         aRect = AWTRectangle( m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ) );
     352             : 
     353           0 :     return aRect;
     354             : }
     355             : 
     356           0 : awt::Point SAL_CALL VCLXAccessibleListItem::getLocation(  ) throw (RuntimeException, std::exception)
     357             : {
     358           0 :     SolarMutexGuard aSolarGuard;
     359           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     360             : 
     361           0 :     Point aPoint(0,0);
     362           0 :     if ( m_pListBoxHelper )
     363             :     {
     364           0 :         Rectangle aRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent );
     365           0 :         aPoint = aRect.TopLeft();
     366             :     }
     367           0 :     return AWTPoint( aPoint );
     368             : }
     369             : 
     370           0 : awt::Point SAL_CALL VCLXAccessibleListItem::getLocationOnScreen(  ) throw (RuntimeException, std::exception)
     371             : {
     372           0 :     SolarMutexGuard aSolarGuard;
     373           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     374             : 
     375           0 :     Point aPoint(0,0);
     376           0 :     if ( m_pListBoxHelper )
     377             :     {
     378           0 :         Rectangle aRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent );
     379           0 :         aPoint = aRect.TopLeft();
     380           0 :         aPoint += m_pListBoxHelper->GetWindowExtentsRelative( NULL ).TopLeft();
     381             :     }
     382           0 :     return AWTPoint( aPoint );
     383             : }
     384             : 
     385           0 : awt::Size SAL_CALL VCLXAccessibleListItem::getSize(  ) throw (RuntimeException, std::exception)
     386             : {
     387           0 :     SolarMutexGuard aSolarGuard;
     388           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     389             : 
     390           0 :     Size aSize;
     391           0 :     if ( m_pListBoxHelper )
     392           0 :         aSize = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ).GetSize();
     393             : 
     394           0 :     return AWTSize( aSize );
     395             : }
     396             : 
     397           0 : void SAL_CALL VCLXAccessibleListItem::grabFocus(  ) throw (RuntimeException, std::exception)
     398             : {
     399             :     // no focus for each item
     400           0 : }
     401             : 
     402             : // XAccessibleText
     403             : 
     404           0 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getCaretPosition() throw (RuntimeException, std::exception)
     405             : {
     406           0 :     return -1;
     407             : }
     408             : 
     409           0 : sal_Bool SAL_CALL VCLXAccessibleListItem::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     410             : {
     411           0 :     SolarMutexGuard aSolarGuard;
     412           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     413             : 
     414           0 :     if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
     415           0 :         throw IndexOutOfBoundsException();
     416             : 
     417           0 :     return false;
     418             : }
     419             : 
     420           0 : sal_Unicode SAL_CALL VCLXAccessibleListItem::getCharacter( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     421             : {
     422           0 :     SolarMutexGuard aSolarGuard;
     423           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     424             : 
     425           0 :     return OCommonAccessibleText::getCharacter( nIndex );
     426             : }
     427             : 
     428           0 : Sequence< PropertyValue > SAL_CALL VCLXAccessibleListItem::getCharacterAttributes( sal_Int32 nIndex, const Sequence< OUString >& ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     429             : {
     430           0 :     SolarMutexGuard aSolarGuard;
     431           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     432             : 
     433           0 :     OUString sText( implGetText() );
     434           0 :     if ( !implIsValidIndex( nIndex, sText.getLength() ) )
     435           0 :         throw IndexOutOfBoundsException();
     436             : 
     437           0 :     return Sequence< PropertyValue >();
     438             : }
     439             : 
     440           0 : awt::Rectangle SAL_CALL VCLXAccessibleListItem::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     441             : {
     442           0 :     SolarMutexGuard aSolarGuard;
     443           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     444             : 
     445           0 :     OUString sText( implGetText() );
     446           0 :     if ( !implIsValidIndex( nIndex, sText.getLength() ) )
     447           0 :         throw IndexOutOfBoundsException();
     448             : 
     449           0 :     awt::Rectangle aBounds( 0, 0, 0, 0 );
     450           0 :     if ( m_pListBoxHelper )
     451             :     {
     452           0 :         Rectangle aCharRect = m_pListBoxHelper->GetEntryCharacterBounds( m_nIndexInParent, nIndex );
     453           0 :         Rectangle aItemRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent );
     454           0 :         aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
     455           0 :         aBounds = AWTRectangle( aCharRect );
     456             :     }
     457             : 
     458           0 :     return aBounds;
     459             : }
     460             : 
     461           0 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getCharacterCount() throw (RuntimeException, std::exception)
     462             : {
     463           0 :     SolarMutexGuard aSolarGuard;
     464           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     465             : 
     466           0 :     return OCommonAccessibleText::getCharacterCount();
     467             : }
     468             : 
     469           0 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException, std::exception)
     470             : {
     471           0 :     SolarMutexGuard aSolarGuard;
     472           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     473             : 
     474           0 :     sal_Int32 nIndex = -1;
     475           0 :     if ( m_pListBoxHelper )
     476             :     {
     477           0 :         sal_Int32 nPos = LISTBOX_ENTRY_NOTFOUND;
     478           0 :         Rectangle aItemRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent );
     479           0 :         Point aPnt( VCLPoint( aPoint ) );
     480           0 :         aPnt += aItemRect.TopLeft();
     481           0 :         sal_Int32 nI = m_pListBoxHelper->GetIndexForPoint( aPnt, nPos );
     482           0 :         if ( nI != -1 && m_nIndexInParent == nPos )
     483           0 :             nIndex = nI;
     484             :     }
     485           0 :     return nIndex;
     486             : }
     487             : 
     488           0 : OUString SAL_CALL VCLXAccessibleListItem::getSelectedText() throw (RuntimeException, std::exception)
     489             : {
     490           0 :     SolarMutexGuard aSolarGuard;
     491           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     492             : 
     493           0 :     return OCommonAccessibleText::getSelectedText();
     494             : }
     495             : 
     496           0 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getSelectionStart() throw (RuntimeException, std::exception)
     497             : {
     498           0 :     SolarMutexGuard aSolarGuard;
     499           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     500             : 
     501           0 :     return OCommonAccessibleText::getSelectionStart();
     502             : }
     503             : 
     504           0 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getSelectionEnd() throw (RuntimeException, std::exception)
     505             : {
     506           0 :     SolarMutexGuard aSolarGuard;
     507           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     508             : 
     509           0 :     return OCommonAccessibleText::getSelectionEnd();
     510             : }
     511             : 
     512           0 : sal_Bool SAL_CALL VCLXAccessibleListItem::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     513             : {
     514           0 :     SolarMutexGuard aSolarGuard;
     515           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     516             : 
     517           0 :     if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
     518           0 :         throw IndexOutOfBoundsException();
     519             : 
     520           0 :     return false;
     521             : }
     522             : 
     523           0 : OUString SAL_CALL VCLXAccessibleListItem::getText() throw (RuntimeException, std::exception)
     524             : {
     525           0 :     SolarMutexGuard aSolarGuard;
     526           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     527             : 
     528           0 :     return OCommonAccessibleText::getText();
     529             : }
     530             : 
     531           0 : OUString SAL_CALL VCLXAccessibleListItem::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     532             : {
     533           0 :     SolarMutexGuard aSolarGuard;
     534           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     535             : 
     536           0 :     return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
     537             : }
     538             : 
     539           0 : ::com::sun::star::accessibility::TextSegment SAL_CALL VCLXAccessibleListItem::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)
     540             : {
     541           0 :     SolarMutexGuard aSolarGuard;
     542           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     543             : 
     544           0 :     return OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
     545             : }
     546             : 
     547           0 : ::com::sun::star::accessibility::TextSegment SAL_CALL VCLXAccessibleListItem::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)
     548             : {
     549           0 :     SolarMutexGuard aSolarGuard;
     550           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     551             : 
     552           0 :     return OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
     553             : }
     554             : 
     555           0 : ::com::sun::star::accessibility::TextSegment SAL_CALL VCLXAccessibleListItem::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)
     556             : {
     557           0 :     SolarMutexGuard aSolarGuard;
     558           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     559             : 
     560           0 :     return OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
     561             : }
     562             : 
     563           0 : sal_Bool SAL_CALL VCLXAccessibleListItem::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     564             : {
     565           0 :     SolarMutexGuard aSolarGuard;
     566           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     567             : 
     568           0 :     checkIndex_Impl( nStartIndex, m_sEntryText );
     569           0 :     checkIndex_Impl( nEndIndex, m_sEntryText );
     570             : 
     571           0 :     bool bRet = false;
     572           0 :     if ( m_pListBoxHelper )
     573             :     {
     574           0 :         Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pListBoxHelper->GetClipboard();
     575           0 :         if ( xClipboard.is() )
     576             :         {
     577           0 :             OUString sText( getTextRange( nStartIndex, nEndIndex ) );
     578           0 :             vcl::unohelper::TextDataObject* pDataObj = new vcl::unohelper::TextDataObject( sText );
     579             : 
     580           0 :             SolarMutexReleaser aReleaser;
     581           0 :             xClipboard->setContents( pDataObj, NULL );
     582           0 :             Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
     583           0 :             if( xFlushableClipboard.is() )
     584           0 :                 xFlushableClipboard->flushClipboard();
     585             : 
     586           0 :             bRet = true;
     587           0 :         }
     588             :     }
     589             : 
     590           0 :     return bRet;
     591             : }
     592             : 
     593             : // XAccessibleEventBroadcaster
     594             : 
     595         126 : void SAL_CALL VCLXAccessibleListItem::addAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException, std::exception)
     596             : {
     597         126 :     if (xListener.is())
     598             :     {
     599         126 :         if (!m_nClientId)
     600         126 :             m_nClientId = comphelper::AccessibleEventNotifier::registerClient( );
     601         126 :         comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener );
     602             :     }
     603         126 : }
     604             : 
     605           0 : void SAL_CALL VCLXAccessibleListItem::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException, std::exception)
     606             : {
     607           0 :     if ( xListener.is() && m_nClientId )
     608             :     {
     609           0 :         sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener );
     610           0 :         if ( !nListenerCount )
     611             :         {
     612             :             // no listeners anymore
     613             :             // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
     614             :             // and at least to us not firing any events anymore, in case somebody calls
     615             :             // NotifyAccessibleEvent, again
     616           0 :             if ( m_nClientId )
     617             :             {
     618           0 :                 comphelper::AccessibleEventNotifier::TClientId nId( m_nClientId );
     619           0 :                 m_nClientId = 0;
     620           0 :                 comphelper::AccessibleEventNotifier::revokeClient( nId );
     621             :             }
     622             :         }
     623             :     }
     624           0 : }
     625             : 
     626             : 
     627             : 
     628             : 
     629             : // AF (Oct. 29 2002): Return black as constant foreground color.  This is an
     630             : // initial implementation and has to be substituted by code that determines
     631             : // the color that is actually used.
     632           0 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getForeground()
     633             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     634             : {
     635           0 :     return COL_BLACK;
     636             : }
     637             : 
     638             : // AF (Oct. 29 2002): Return white as constant background color.  This is an
     639             : // initial implementation and has to be substituted by code that determines
     640             : // the color that is actually used.
     641           0 : sal_Int32 SAL_CALL VCLXAccessibleListItem::getBackground()
     642             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     643             : {
     644           0 :     return COL_WHITE;
     645          36 : }
     646             : 
     647             : 
     648             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11