LCOV - code coverage report
Current view: top level - accessibility/source/extended - accessibleiconchoicectrlentry.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 340 0.0 %
Date: 2014-04-11 Functions: 0 65 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/accessibleiconchoicectrlentry.hxx>
      21             : #include <svtools/ivctrl.hxx>
      22             : #include <com/sun/star/awt/Point.hpp>
      23             : #include <com/sun/star/awt/Rectangle.hpp>
      24             : #include <com/sun/star/awt/Size.hpp>
      25             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      26             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      27             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      28             : #include <vcl/svapp.hxx>
      29             : #include <vcl/controllayout.hxx>
      30             : #include <vcl/settings.hxx>
      31             : #include <toolkit/awt/vclxwindow.hxx>
      32             : #include <toolkit/helper/convert.hxx>
      33             : #include <unotools/accessiblestatesethelper.hxx>
      34             : #include <unotools/accessiblerelationsethelper.hxx>
      35             : #include <cppuhelper/supportsservice.hxx>
      36             : #include <cppuhelper/typeprovider.hxx>
      37             : #include <comphelper/sequence.hxx>
      38             : #include <svtools/stringtransfer.hxx>
      39             : #include <comphelper/accessibleeventnotifier.hxx>
      40             : 
      41             : #define ACCESSIBLE_ACTION_COUNT     1
      42             : 
      43             : namespace
      44             : {
      45           0 :     void checkActionIndex_Impl( sal_Int32 _nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException)
      46             :     {
      47           0 :         if ( _nIndex < 0 || _nIndex >= ACCESSIBLE_ACTION_COUNT )
      48             :             // only three actions
      49           0 :             throw ::com::sun::star::lang::IndexOutOfBoundsException();
      50           0 :     }
      51             : }
      52             : 
      53             : 
      54             : namespace accessibility
      55             : {
      56             : 
      57             :     // class AccessibleIconChoiceCtrlEntry
      58             : 
      59             :     using namespace ::com::sun::star::accessibility;
      60             :     using namespace ::com::sun::star::uno;
      61             :     using namespace ::com::sun::star::lang;
      62             :     using namespace ::com::sun::star;
      63             : 
      64             : 
      65             :     // Ctor() and Dtor()
      66             : 
      67           0 :     AccessibleIconChoiceCtrlEntry::AccessibleIconChoiceCtrlEntry( SvtIconChoiceCtrl& _rIconCtrl,
      68             :                                                                   sal_Int32 _nPos,
      69             :                                                                   const Reference< XAccessible >& _xParent ) :
      70             : 
      71             :         AccessibleIconChoiceCtrlEntry_BASE  ( m_aMutex ),
      72             : 
      73             :         m_pIconCtrl     ( &_rIconCtrl ),
      74             :         m_nIndex        ( _nPos ),
      75             :         m_nClientId     ( 0 ),
      76           0 :         m_xParent       ( _xParent )
      77             : 
      78             :     {
      79           0 :         osl_atomic_increment( &m_refCount );
      80             :         {
      81           0 :             Reference< XComponent > xComp( m_xParent, UNO_QUERY );
      82           0 :             if ( xComp.is() )
      83           0 :                 xComp->addEventListener( this );
      84             :         }
      85           0 :         osl_atomic_decrement( &m_refCount );
      86           0 :     }
      87             : 
      88           0 :     void AccessibleIconChoiceCtrlEntry::disposing( const EventObject& _rSource )
      89             : throw(RuntimeException, std::exception)
      90             :     {
      91           0 :         if ( _rSource.Source == m_xParent )
      92             :         {
      93           0 :             dispose();
      94             :             OSL_ENSURE( !m_xParent.is() && ( NULL == m_pIconCtrl ), "" );
      95             :         }
      96           0 :     }
      97             : 
      98           0 :     AccessibleIconChoiceCtrlEntry::~AccessibleIconChoiceCtrlEntry()
      99             :     {
     100           0 :         if ( IsAlive_Impl() )
     101             :         {
     102             :             // increment ref count to prevent double call of Dtor
     103           0 :             osl_atomic_increment( &m_refCount );
     104           0 :             dispose();
     105             :         }
     106           0 :     }
     107             : 
     108           0 :     Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBox_Impl() const
     109             :     {
     110           0 :         Rectangle aRect;
     111           0 :         SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
     112           0 :         if ( pEntry )
     113           0 :             aRect = m_pIconCtrl->GetBoundingBox( pEntry );
     114             : 
     115           0 :         return aRect;
     116             :     }
     117             : 
     118           0 :     Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBoxOnScreen_Impl() const
     119             :     {
     120           0 :         Rectangle aRect;
     121           0 :         SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
     122           0 :         if ( pEntry )
     123             :         {
     124           0 :             aRect = m_pIconCtrl->GetBoundingBox( pEntry );
     125           0 :             Point aTopLeft = aRect.TopLeft();
     126           0 :             aTopLeft += m_pIconCtrl->GetWindowExtentsRelative( NULL ).TopLeft();
     127           0 :             aRect = Rectangle( aTopLeft, aRect.GetSize() );
     128             :         }
     129             : 
     130           0 :         return aRect;
     131             :     }
     132             : 
     133           0 :     sal_Bool AccessibleIconChoiceCtrlEntry::IsAlive_Impl() const
     134             :     {
     135           0 :         return ( !rBHelper.bDisposed && !rBHelper.bInDispose && m_pIconCtrl );
     136             :     }
     137             : 
     138           0 :     sal_Bool AccessibleIconChoiceCtrlEntry::IsShowing_Impl() const
     139             :     {
     140           0 :         sal_Bool bShowing = sal_False;
     141             :         Reference< XAccessibleContext > m_xParentContext =
     142           0 :             m_xParent.is() ? m_xParent->getAccessibleContext() : Reference< XAccessibleContext >();
     143           0 :         if( m_xParentContext.is() )
     144             :         {
     145           0 :             Reference< XAccessibleComponent > xParentComp( m_xParentContext, uno::UNO_QUERY );
     146           0 :             if( xParentComp.is() )
     147           0 :                 bShowing = GetBoundingBox_Impl().IsOver( VCLRectangle( xParentComp->getBounds() ) );
     148             :         }
     149             : 
     150           0 :         return bShowing;
     151             :     }
     152             : 
     153           0 :     Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBox()
     154             :         throw (lang::DisposedException, uno::RuntimeException)
     155             :     {
     156           0 :         SolarMutexGuard aSolarGuard;
     157           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     158             : 
     159           0 :         EnsureIsAlive();
     160           0 :         return GetBoundingBox_Impl();
     161             :     }
     162             : 
     163           0 :     Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBoxOnScreen()
     164             :         throw (lang::DisposedException, uno::RuntimeException)
     165             :     {
     166           0 :         SolarMutexGuard aSolarGuard;
     167           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     168             : 
     169           0 :         EnsureIsAlive();
     170           0 :         return GetBoundingBoxOnScreen_Impl();
     171             :     }
     172             : 
     173           0 :     void AccessibleIconChoiceCtrlEntry::EnsureIsAlive() const throw ( lang::DisposedException )
     174             :     {
     175           0 :         if ( !IsAlive_Impl() )
     176           0 :             throw lang::DisposedException();
     177           0 :     }
     178             : 
     179           0 :     OUString AccessibleIconChoiceCtrlEntry::implGetText()
     180             :     {
     181           0 :         OUString sRet;
     182           0 :         SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
     183           0 :         if ( pEntry )
     184           0 :             sRet = pEntry->GetDisplayText();
     185           0 :         return sRet;
     186             :     }
     187             : 
     188           0 :     Locale AccessibleIconChoiceCtrlEntry::implGetLocale()
     189             :     {
     190           0 :         Locale aLocale;
     191           0 :         aLocale = Application::GetSettings().GetUILanguageTag().getLocale();
     192             : 
     193           0 :         return aLocale;
     194             :     }
     195           0 :     void AccessibleIconChoiceCtrlEntry::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
     196             :     {
     197           0 :         nStartIndex = 0;
     198           0 :         nEndIndex = 0;
     199           0 :     }
     200             : 
     201             :     // XTypeProvider
     202             : 
     203             : 
     204           0 :     Sequence< sal_Int8 > AccessibleIconChoiceCtrlEntry::getImplementationId() throw (RuntimeException, std::exception)
     205             :     {
     206           0 :         return css::uno::Sequence<sal_Int8>();
     207             :     }
     208             : 
     209             :     // XComponent
     210             : 
     211           0 :     void SAL_CALL AccessibleIconChoiceCtrlEntry::disposing()
     212             :     {
     213           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     214             : 
     215             :         // Send a disposing to all listeners.
     216           0 :         if ( m_nClientId )
     217             :         {
     218           0 :             sal_uInt32 nId = m_nClientId;
     219           0 :             m_nClientId =  0;
     220           0 :             comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this );
     221             :         }
     222             : 
     223           0 :         Reference< XComponent > xComp( m_xParent, UNO_QUERY );
     224           0 :         if ( xComp.is() )
     225           0 :             xComp->removeEventListener( this );
     226             : 
     227           0 :         m_pIconCtrl = NULL;
     228           0 :         m_xParent = NULL;
     229           0 :     }
     230             : 
     231             :     // XServiceInfo
     232             : 
     233           0 :     OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getImplementationName() throw(RuntimeException, std::exception)
     234             :     {
     235           0 :         return getImplementationName_Static();
     236             :     }
     237             : 
     238           0 :     Sequence< OUString > SAL_CALL AccessibleIconChoiceCtrlEntry::getSupportedServiceNames() throw(RuntimeException, std::exception)
     239             :     {
     240           0 :         return getSupportedServiceNames_Static();
     241             :     }
     242             : 
     243           0 :     sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::supportsService( const OUString& _rServiceName ) throw (RuntimeException, std::exception)
     244             :     {
     245           0 :         return cppu::supportsService(this, _rServiceName);
     246             :     }
     247             : 
     248             :     // XServiceInfo - static methods
     249             : 
     250           0 :     Sequence< OUString > AccessibleIconChoiceCtrlEntry::getSupportedServiceNames_Static(void) throw( RuntimeException )
     251             :     {
     252           0 :         Sequence< OUString > aSupported(3);
     253           0 :         aSupported[0] = "com.sun.star.accessibility.AccessibleContext";
     254           0 :         aSupported[1] = "com.sun.star.accessibility.AccessibleComponent";
     255           0 :         aSupported[2] = "com.sun.star.awt.AccessibleIconChoiceControlEntry";
     256           0 :         return aSupported;
     257             :     }
     258             : 
     259           0 :     OUString AccessibleIconChoiceCtrlEntry::getImplementationName_Static(void) throw( RuntimeException )
     260             :     {
     261           0 :         return OUString( "com.sun.star.comp.svtools.AccessibleIconChoiceControlEntry" );
     262             :     }
     263             : 
     264             :     // XAccessible
     265             : 
     266           0 :     Reference< XAccessibleContext > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleContext(  ) throw (RuntimeException, std::exception)
     267             :     {
     268           0 :         EnsureIsAlive();
     269           0 :         return this;
     270             :     }
     271             : 
     272             :     // XAccessibleContext
     273             : 
     274           0 :     sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleChildCount(  ) throw (RuntimeException, std::exception)
     275             :     {
     276           0 :         return 0; // no children
     277             :     }
     278             : 
     279           0 :     Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleChild( sal_Int32 ) throw (IndexOutOfBoundsException,RuntimeException, std::exception)
     280             :     {
     281           0 :         throw IndexOutOfBoundsException();
     282             :     }
     283             : 
     284           0 :     Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleParent(  ) throw (RuntimeException, std::exception)
     285             :     {
     286           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     287             : 
     288           0 :         EnsureIsAlive();
     289           0 :         return m_xParent;
     290             :     }
     291             : 
     292           0 :     sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleIndexInParent(  ) throw (RuntimeException, std::exception)
     293             :     {
     294           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     295             : 
     296           0 :         return m_nIndex;
     297             :     }
     298             : 
     299           0 :     sal_Int16 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleRole(  ) throw (RuntimeException, std::exception)
     300             :     {
     301             :         //return AccessibleRole::LABEL;
     302           0 :         return AccessibleRole::LIST_ITEM;
     303             :     }
     304             : 
     305           0 :     OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleDescription(  ) throw (RuntimeException, std::exception)
     306             :     {
     307             :         // no description for every item
     308           0 :         return OUString();
     309             :     }
     310             : 
     311           0 :     OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleName(  ) throw (RuntimeException, std::exception)
     312             :     {
     313           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     314             : 
     315           0 :         EnsureIsAlive();
     316           0 :         return implGetText();
     317             :     }
     318             : 
     319           0 :     Reference< XAccessibleRelationSet > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleRelationSet(  ) throw (RuntimeException, std::exception)
     320             :     {
     321           0 :         return new utl::AccessibleRelationSetHelper;
     322             :     }
     323             : 
     324           0 :     Reference< XAccessibleStateSet > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleStateSet(  ) throw (RuntimeException, std::exception)
     325             :     {
     326           0 :         SolarMutexGuard aSolarGuard;
     327           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     328             : 
     329           0 :         utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
     330           0 :         Reference< XAccessibleStateSet > xStateSet = pStateSetHelper;
     331             : 
     332           0 :         if ( IsAlive_Impl() )
     333             :         {
     334           0 :                pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
     335           0 :                pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
     336           0 :                pStateSetHelper->AddState( AccessibleStateType::ENABLED );
     337           0 :             pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
     338           0 :             if ( IsShowing_Impl() )
     339             :             {
     340           0 :                 pStateSetHelper->AddState( AccessibleStateType::SHOWING );
     341           0 :                 pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
     342             :             }
     343             : 
     344           0 :             if ( m_pIconCtrl && m_pIconCtrl->GetCursor() == m_pIconCtrl->GetEntry( m_nIndex ) )
     345           0 :                 pStateSetHelper->AddState( AccessibleStateType::SELECTED );
     346             :         }
     347             :         else
     348           0 :             pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
     349             : 
     350           0 :         return xStateSet;
     351             :     }
     352             : 
     353           0 :     Locale SAL_CALL AccessibleIconChoiceCtrlEntry::getLocale(  ) throw (IllegalAccessibleComponentStateException, RuntimeException, std::exception)
     354             :     {
     355           0 :         SolarMutexGuard aSolarGuard;
     356           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     357             : 
     358           0 :         return implGetLocale();
     359             :     }
     360             : 
     361             :     // XAccessibleComponent
     362             : 
     363           0 :     sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::containsPoint( const awt::Point& rPoint ) throw (RuntimeException, std::exception)
     364             :     {
     365           0 :         return Rectangle( Point(), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) );
     366             :     }
     367             : 
     368           0 :     Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException, std::exception)
     369             :     {
     370           0 :         return Reference< XAccessible >();
     371             :     }
     372             : 
     373           0 :     awt::Rectangle SAL_CALL AccessibleIconChoiceCtrlEntry::getBounds(  ) throw (RuntimeException, std::exception)
     374             :     {
     375           0 :         return AWTRectangle( GetBoundingBox() );
     376             :     }
     377             : 
     378           0 :     awt::Point SAL_CALL AccessibleIconChoiceCtrlEntry::getLocation(  ) throw (RuntimeException, std::exception)
     379             :     {
     380           0 :         return AWTPoint( GetBoundingBox().TopLeft() );
     381             :     }
     382             : 
     383           0 :     awt::Point SAL_CALL AccessibleIconChoiceCtrlEntry::getLocationOnScreen(  ) throw (RuntimeException, std::exception)
     384             :     {
     385           0 :         return AWTPoint( GetBoundingBoxOnScreen().TopLeft() );
     386             :     }
     387             : 
     388           0 :     awt::Size SAL_CALL AccessibleIconChoiceCtrlEntry::getSize(  ) throw (RuntimeException, std::exception)
     389             :     {
     390           0 :         return AWTSize( GetBoundingBox().GetSize() );
     391             :     }
     392             : 
     393           0 :     void SAL_CALL AccessibleIconChoiceCtrlEntry::grabFocus(  ) throw (RuntimeException, std::exception)
     394             :     {
     395             :         // do nothing, because no focus for each item
     396           0 :     }
     397             : 
     398           0 :     sal_Int32 AccessibleIconChoiceCtrlEntry::getForeground( ) throw (RuntimeException, std::exception)
     399             :     {
     400           0 :         SolarMutexGuard aSolarGuard;
     401           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     402             : 
     403           0 :         sal_Int32 nColor = 0;
     404           0 :         Reference< XAccessible > xParent = getAccessibleParent();
     405           0 :         if ( xParent.is() )
     406             :         {
     407           0 :             Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
     408           0 :             if ( xParentComp.is() )
     409           0 :                 nColor = xParentComp->getForeground();
     410             :         }
     411             : 
     412           0 :         return nColor;
     413             :     }
     414             : 
     415           0 :     sal_Int32 AccessibleIconChoiceCtrlEntry::getBackground(  ) throw (RuntimeException, std::exception)
     416             :     {
     417           0 :         SolarMutexGuard aSolarGuard;
     418           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     419             : 
     420           0 :         sal_Int32 nColor = 0;
     421           0 :         Reference< XAccessible > xParent = getAccessibleParent();
     422           0 :         if ( xParent.is() )
     423             :         {
     424           0 :             Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
     425           0 :             if ( xParentComp.is() )
     426           0 :                 nColor = xParentComp->getBackground();
     427             :         }
     428             : 
     429           0 :         return nColor;
     430             :     }
     431             : 
     432             :     // XAccessibleText
     433             : 
     434             : 
     435           0 :     awt::Rectangle SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterBounds( sal_Int32 _nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     436             :     {
     437           0 :         SolarMutexGuard aSolarGuard;
     438           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     439             : 
     440           0 :         if ( ( 0 > _nIndex ) || ( getCharacterCount() <= _nIndex ) )
     441           0 :             throw IndexOutOfBoundsException();
     442             : 
     443           0 :         awt::Rectangle aBounds( 0, 0, 0, 0 );
     444           0 :         if ( m_pIconCtrl )
     445             :         {
     446           0 :             Rectangle aItemRect = GetBoundingBox_Impl();
     447           0 :             Rectangle aCharRect = m_pIconCtrl->GetEntryCharacterBounds( m_nIndex, _nIndex );
     448           0 :             aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
     449           0 :             aBounds = AWTRectangle( aCharRect );
     450             :         }
     451             : 
     452           0 :         return aBounds;
     453             :     }
     454             : 
     455           0 :     sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException, std::exception)
     456             :     {
     457           0 :         SolarMutexGuard aSolarGuard;
     458           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     459             : 
     460           0 :         sal_Int32 nIndex = -1;
     461           0 :         if ( m_pIconCtrl )
     462             :         {
     463           0 :             ::vcl::ControlLayoutData aLayoutData;
     464           0 :             Rectangle aItemRect = GetBoundingBox_Impl();
     465           0 :             m_pIconCtrl->RecordLayoutData( &aLayoutData, aItemRect );
     466           0 :             Point aPnt( VCLPoint( aPoint ) );
     467           0 :             aPnt += aItemRect.TopLeft();
     468           0 :             nIndex = aLayoutData.GetIndexForPoint( aPnt );
     469             : 
     470           0 :             long nLen = aLayoutData.m_aUnicodeBoundRects.size();
     471           0 :             for ( long i = 0; i < nLen; ++i )
     472             :             {
     473           0 :                 Rectangle aRect = aLayoutData.GetCharacterBounds(i);
     474           0 :                 sal_Bool bInside = aRect.IsInside( aPnt );
     475             : 
     476           0 :                 if ( bInside )
     477           0 :                     break;
     478           0 :             }
     479             :         }
     480             : 
     481           0 :         return nIndex;
     482             :     }
     483             : 
     484           0 :     sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     485             :     {
     486           0 :         SolarMutexGuard aSolarGuard;
     487           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     488             : 
     489           0 :         OUString sText = getText();
     490           0 :         if  ( ( 0 > nStartIndex ) || ( sText.getLength() <= nStartIndex )
     491           0 :             || ( 0 > nEndIndex ) || ( sText.getLength() <= nEndIndex ) )
     492           0 :             throw IndexOutOfBoundsException();
     493             : 
     494           0 :         sal_Int32 nLen = nEndIndex - nStartIndex + 1;
     495           0 :         ::svt::OStringTransfer::CopyString( sText.copy( nStartIndex, nLen ), m_pIconCtrl );
     496             : 
     497           0 :         return sal_True;
     498             :     }
     499             : 
     500             :     // XAccessibleEventBroadcaster
     501             : 
     502           0 :     void SAL_CALL AccessibleIconChoiceCtrlEntry::addAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException, std::exception)
     503             :     {
     504           0 :         if (xListener.is())
     505             :         {
     506           0 :             ::osl::MutexGuard aGuard( m_aMutex );
     507           0 :             if (!m_nClientId)
     508           0 :                 m_nClientId = comphelper::AccessibleEventNotifier::registerClient( );
     509           0 :             comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener );
     510             :         }
     511           0 :     }
     512             : 
     513           0 :     void SAL_CALL AccessibleIconChoiceCtrlEntry::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException, std::exception)
     514             :     {
     515           0 :         if (xListener.is())
     516             :         {
     517           0 :             ::osl::MutexGuard aGuard( m_aMutex );
     518             : 
     519           0 :             sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener );
     520           0 :             if ( !nListenerCount )
     521             :             {
     522             :                 // no listeners anymore
     523             :                 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
     524             :                 // and at least to us not firing any events anymore, in case somebody calls
     525             :                 // NotifyAccessibleEvent, again
     526           0 :                 sal_Int32 nId = m_nClientId;
     527           0 :                 m_nClientId = 0;
     528           0 :                 comphelper::AccessibleEventNotifier::revokeClient( nId );
     529           0 :             }
     530             :         }
     531           0 :     }
     532             : 
     533           0 :     sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getCaretPosition(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     534             :     {
     535           0 :         return -1;
     536             :     }
     537           0 :     sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::setCaretPosition ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
     538             :     {
     539           0 :         SolarMutexGuard aSolarGuard;
     540           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     541           0 :         EnsureIsAlive();
     542             : 
     543           0 :         if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
     544           0 :             throw IndexOutOfBoundsException();
     545             : 
     546           0 :         return sal_False;
     547             :     }
     548           0 :     sal_Unicode SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
     549             :     {
     550           0 :         SolarMutexGuard aSolarGuard;
     551           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     552           0 :         EnsureIsAlive();
     553           0 :         return OCommonAccessibleText::getCharacter( nIndex );
     554             :     }
     555           0 :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< OUString >& ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
     556             :     {
     557           0 :         SolarMutexGuard aSolarGuard;
     558           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     559           0 :         EnsureIsAlive();
     560             : 
     561           0 :         OUString sText( implGetText() );
     562             : 
     563           0 :         if ( !implIsValidIndex( nIndex, sText.getLength() ) )
     564           0 :             throw IndexOutOfBoundsException();
     565             : 
     566           0 :         return ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >();
     567             :     }
     568           0 :     sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterCount(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     569             :     {
     570           0 :         SolarMutexGuard aSolarGuard;
     571           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     572           0 :         EnsureIsAlive();
     573           0 :         return OCommonAccessibleText::getCharacterCount(  );
     574             :     }
     575             : 
     576           0 :     OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectedText(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     577             :     {
     578           0 :         SolarMutexGuard aSolarGuard;
     579           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     580           0 :         EnsureIsAlive();
     581           0 :         return OCommonAccessibleText::getSelectedText(  );
     582             :     }
     583           0 :     sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectionStart(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     584             :     {
     585           0 :         SolarMutexGuard aSolarGuard;
     586           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     587           0 :         EnsureIsAlive();
     588           0 :         return OCommonAccessibleText::getSelectionStart(  );
     589             :     }
     590           0 :     sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectionEnd(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     591             :     {
     592           0 :         SolarMutexGuard aSolarGuard;
     593           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     594           0 :         EnsureIsAlive();
     595           0 :         return OCommonAccessibleText::getSelectionEnd(  );
     596             :     }
     597           0 :     sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
     598             :     {
     599           0 :         SolarMutexGuard aSolarGuard;
     600           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     601           0 :         EnsureIsAlive();
     602             : 
     603           0 :         if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
     604           0 :             throw IndexOutOfBoundsException();
     605             : 
     606           0 :         return sal_False;
     607             :     }
     608           0 :     OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getText(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     609             :     {
     610           0 :         SolarMutexGuard aSolarGuard;
     611           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     612           0 :         EnsureIsAlive();
     613           0 :         return OCommonAccessibleText::getText(  );
     614             :     }
     615           0 :     OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
     616             :     {
     617           0 :         SolarMutexGuard aSolarGuard;
     618           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     619           0 :         EnsureIsAlive();
     620           0 :         return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
     621             :     }
     622           0 :     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleIconChoiceCtrlEntry::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)
     623             :     {
     624           0 :         SolarMutexGuard aSolarGuard;
     625           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     626           0 :         EnsureIsAlive();
     627           0 :         return OCommonAccessibleText::getTextAtIndex( nIndex ,aTextType);
     628             :     }
     629           0 :     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleIconChoiceCtrlEntry::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)
     630             :     {
     631           0 :         SolarMutexGuard aSolarGuard;
     632           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     633           0 :         EnsureIsAlive();
     634           0 :         return OCommonAccessibleText::getTextBeforeIndex( nIndex ,aTextType);
     635             :     }
     636           0 :     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleIconChoiceCtrlEntry::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)
     637             :     {
     638           0 :         SolarMutexGuard aSolarGuard;
     639           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     640           0 :         EnsureIsAlive();
     641             : 
     642           0 :         return OCommonAccessibleText::getTextBehindIndex( nIndex ,aTextType);
     643             :     }
     644             : 
     645             : 
     646             :     // XAccessibleAction
     647             : 
     648           0 :     sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleActionCount(  ) throw (RuntimeException, std::exception)
     649             :     {
     650           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     651             : 
     652             :         // three actions supported
     653           0 :         return ACCESSIBLE_ACTION_COUNT;
     654             :     }
     655             : 
     656           0 :     sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::doAccessibleAction( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     657             :     {
     658           0 :         SolarMutexGuard aSolarGuard;
     659           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     660             : 
     661           0 :         sal_Bool bRet = sal_False;
     662           0 :         checkActionIndex_Impl( nIndex );
     663           0 :         EnsureIsAlive();
     664             : 
     665           0 :         SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
     666           0 :         if ( pEntry && !pEntry->IsSelected() )
     667             :         {
     668           0 :             m_pIconCtrl->SetNoSelection();
     669           0 :             m_pIconCtrl->SetCursor( pEntry );
     670           0 :             bRet = sal_True;
     671             :         }
     672             : 
     673           0 :         return bRet;
     674             :     }
     675             : 
     676           0 :     OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleActionDescription( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     677             :     {
     678           0 :         SolarMutexGuard aSolarGuard;
     679           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     680             : 
     681           0 :         checkActionIndex_Impl( nIndex );
     682           0 :         EnsureIsAlive();
     683             : 
     684           0 :         static const OUString sActionDesc( "Select" );
     685           0 :         return sActionDesc;
     686             :     }
     687             : 
     688           0 :     Reference< XAccessibleKeyBinding > AccessibleIconChoiceCtrlEntry::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     689             :     {
     690           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     691             : 
     692           0 :         Reference< XAccessibleKeyBinding > xRet;
     693           0 :         checkActionIndex_Impl( nIndex );
     694             :         // ... which key?
     695           0 :         return xRet;
     696             :     }
     697             : 
     698             : }// namespace accessibility
     699             : 
     700             : 
     701             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10