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

Generated by: LCOV version 1.10