LCOV - code coverage report
Current view: top level - libreoffice/accessibility/source/standard - vclxaccessibletoolboxitem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 326 0.0 %
Date: 2012-12-27 Functions: 0 57 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/standard/vclxaccessibletoolboxitem.hxx>
      21             : #include <toolkit/helper/convert.hxx>
      22             : #include <accessibility/helper/accresmgr.hxx>
      23             : #include <accessibility/helper/accessiblestrings.hrc>
      24             : #include <com/sun/star/awt/Point.hpp>
      25             : #include <com/sun/star/awt/Rectangle.hpp>
      26             : #include <com/sun/star/awt/Size.hpp>
      27             : 
      28             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      29             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      30             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      31             : #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
      32             : #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
      33             : #include <cppuhelper/supportsservice.hxx>
      34             : #include <vcl/svapp.hxx>
      35             : #include <vcl/toolbox.hxx>
      36             : #include <vcl/unohelp2.hxx>
      37             : #include <vcl/help.hxx>
      38             : #include <toolkit/awt/vclxwindow.hxx>
      39             : #include <toolkit/helper/externallock.hxx>
      40             : #include <unotools/accessiblestatesethelper.hxx>
      41             : #include <unotools/accessiblerelationsethelper.hxx>
      42             : #include <cppuhelper/typeprovider.hxx>
      43             : #include <comphelper/sequence.hxx>
      44             : 
      45             : #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
      46             : 
      47             : // class VCLXAccessibleToolBoxItem ------------------------------------------
      48             : 
      49             : using namespace ::com::sun::star::accessibility;
      50             : using namespace ::com::sun::star::uno;
      51             : using namespace ::com::sun::star::beans;
      52             : using namespace ::com::sun::star::lang;
      53             : using namespace ::com::sun::star;
      54             : using namespace ::comphelper;
      55             : 
      56             : // -----------------------------------------------------------------------------
      57             : // Ctor() and Dtor()
      58             : // -----------------------------------------------------------------------------
      59           0 : VCLXAccessibleToolBoxItem::VCLXAccessibleToolBoxItem( ToolBox* _pToolBox, sal_Int32 _nPos ) :
      60             : 
      61             :     AccessibleTextHelper_BASE( new VCLExternalSolarLock() ),
      62             : 
      63             :     m_pToolBox      ( _pToolBox ),
      64             :     m_nIndexInParent( _nPos ),
      65             :     m_nRole         ( AccessibleRole::PUSH_BUTTON ),
      66             :     m_nItemId       ( 0 ),
      67             :     m_bHasFocus     ( sal_False ),
      68             :     m_bIsChecked    ( sal_False ),
      69           0 :     m_bIndeterminate( false )
      70             : 
      71             : {
      72           0 :     m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock( ) );
      73             : 
      74             :     OSL_ENSURE( m_pToolBox, "invalid toolbox" );
      75           0 :     m_nItemId = m_pToolBox->GetItemId( (sal_uInt16)m_nIndexInParent );
      76           0 :     m_sOldName = GetText( true );
      77           0 :     m_bIsChecked = m_pToolBox->IsItemChecked( m_nItemId );
      78           0 :     m_bIndeterminate = ( m_pToolBox->GetItemState( m_nItemId ) == STATE_DONTKNOW );
      79           0 :     ToolBoxItemType eType = m_pToolBox->GetItemType( (sal_uInt16)m_nIndexInParent );
      80           0 :     switch ( eType )
      81             :     {
      82             :         case TOOLBOXITEM_BUTTON :
      83             :         {
      84           0 :             ToolBoxItemBits nBits = m_pToolBox->GetItemBits( m_nItemId );
      85           0 :             if (( nBits & TIB_DROPDOWN ) == TIB_DROPDOWN)
      86           0 :                 m_nRole = AccessibleRole::BUTTON_DROPDOWN;
      87           0 :             else if (( ( nBits & TIB_CHECKABLE ) == TIB_CHECKABLE ) ||
      88             :                 ( ( nBits & TIB_AUTOCHECK ) == TIB_AUTOCHECK ) )
      89           0 :                 m_nRole = AccessibleRole::TOGGLE_BUTTON;
      90           0 :             else if ( m_pToolBox->GetItemWindow( m_nItemId ) )
      91           0 :                 m_nRole = AccessibleRole::PANEL;
      92           0 :             break;
      93             :         }
      94             : 
      95             :         case TOOLBOXITEM_SPACE :
      96           0 :             m_nRole = AccessibleRole::FILLER;
      97           0 :             break;
      98             : 
      99             :         case TOOLBOXITEM_SEPARATOR :
     100             :         case TOOLBOXITEM_BREAK :
     101           0 :             m_nRole = AccessibleRole::SEPARATOR;
     102           0 :             break;
     103             : 
     104             :         default:
     105             :         {
     106             :             SAL_WARN( "accessibility", "unsupported toolbox itemtype" );
     107             :         }
     108             :     }
     109           0 : }
     110             : // -----------------------------------------------------------------------------
     111           0 : VCLXAccessibleToolBoxItem::~VCLXAccessibleToolBoxItem()
     112             : {
     113           0 :     delete m_pExternalLock;
     114           0 :     m_pExternalLock = NULL;
     115           0 : }
     116             : // -----------------------------------------------------------------------------
     117           0 : OUString VCLXAccessibleToolBoxItem::GetText( bool _bAsName )
     118             : {
     119           0 :     OUString sRet;
     120             :     // no text for separators and spaces
     121           0 :     if ( m_pToolBox && m_nItemId > 0 && ( _bAsName || m_pToolBox->GetButtonType() != BUTTON_SYMBOL ) )
     122             :     {
     123           0 :         sRet = m_pToolBox->GetItemText( m_nItemId );
     124             :     }
     125           0 :     return sRet;
     126             : }
     127             : // -----------------------------------------------------------------------------
     128           0 : void VCLXAccessibleToolBoxItem::SetFocus( sal_Bool _bFocus )
     129             : {
     130           0 :     if ( m_bHasFocus != _bFocus )
     131             :     {
     132           0 :         Any aOldValue;
     133           0 :         Any aNewValue;
     134           0 :         if ( m_bHasFocus )
     135           0 :             aOldValue <<= AccessibleStateType::FOCUSED;
     136             :         else
     137           0 :             aNewValue <<= AccessibleStateType::FOCUSED;
     138           0 :         m_bHasFocus = _bFocus;
     139           0 :          NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     140             :     }
     141           0 : }
     142             : // -----------------------------------------------------------------------------
     143           0 : void VCLXAccessibleToolBoxItem::SetChecked( sal_Bool _bCheck )
     144             : {
     145           0 :     if ( m_bIsChecked != _bCheck )
     146             :     {
     147           0 :         Any aOldValue;
     148           0 :         Any aNewValue;
     149           0 :         if ( m_bIsChecked )
     150           0 :             aOldValue <<= AccessibleStateType::CHECKED;
     151             :         else
     152           0 :             aNewValue <<= AccessibleStateType::CHECKED;
     153           0 :         m_bIsChecked = _bCheck;
     154           0 :         NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     155             :     }
     156           0 : }
     157             : // -----------------------------------------------------------------------------
     158           0 : void VCLXAccessibleToolBoxItem::SetIndeterminate( bool _bIndeterminate )
     159             : {
     160           0 :     if ( m_bIndeterminate != _bIndeterminate )
     161             :     {
     162           0 :         Any aOldValue, aNewValue;
     163           0 :         if ( m_bIndeterminate )
     164           0 :             aOldValue <<= AccessibleStateType::INDETERMINATE;
     165             :         else
     166           0 :             aNewValue <<= AccessibleStateType::INDETERMINATE;
     167           0 :         m_bIndeterminate = _bIndeterminate;
     168           0 :         NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     169             :     }
     170           0 : }
     171             : // -----------------------------------------------------------------------------
     172           0 : void VCLXAccessibleToolBoxItem::NameChanged()
     173             : {
     174           0 :     OUString sNewName = implGetText();
     175           0 :     if ( sNewName != m_sOldName )
     176             :     {
     177           0 :         Any aOldValue, aNewValue;
     178           0 :         aOldValue <<= m_sOldName;
     179             :         // save new name as old name for next change
     180           0 :         m_sOldName = sNewName;
     181           0 :         aNewValue <<= m_sOldName;
     182           0 :         NotifyAccessibleEvent( AccessibleEventId::NAME_CHANGED, aOldValue, aNewValue );
     183           0 :     }
     184           0 : }
     185             : // -----------------------------------------------------------------------------
     186           0 : void VCLXAccessibleToolBoxItem::SetChild( const Reference< XAccessible >& _xChild )
     187             : {
     188           0 :     m_xChild = _xChild;
     189           0 : }
     190             : // -----------------------------------------------------------------------------
     191           0 : void VCLXAccessibleToolBoxItem::NotifyChildEvent( const Reference< XAccessible >& _xChild, bool _bShow )
     192             : {
     193           0 :     Any aOld = _bShow ? Any() : makeAny( _xChild );
     194           0 :     Any aNew = _bShow ? makeAny( _xChild ) : Any();
     195           0 :     NotifyAccessibleEvent( AccessibleEventId::CHILD, aOld, aNew );
     196           0 : }
     197             : // -----------------------------------------------------------------------------
     198           0 : void VCLXAccessibleToolBoxItem::ToggleEnableState()
     199             : {
     200           0 :     Any aOldValue[2], aNewValue[2];
     201           0 :     if ( m_pToolBox->IsItemEnabled( m_nItemId ) )
     202             :     {
     203           0 :         aNewValue[0] <<= AccessibleStateType::SENSITIVE;
     204           0 :         aNewValue[1] <<= AccessibleStateType::ENABLED;
     205             :     }
     206             :     else
     207             :     {
     208           0 :         aOldValue[0] <<= AccessibleStateType::ENABLED;
     209           0 :         aOldValue[1] <<= AccessibleStateType::SENSITIVE;
     210             :     }
     211             : 
     212           0 :     NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[0], aNewValue[0] );
     213           0 :     NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[1], aNewValue[1] );
     214           0 : }
     215             : // -----------------------------------------------------------------------------
     216           0 : awt::Rectangle SAL_CALL VCLXAccessibleToolBoxItem::implGetBounds(  ) throw (RuntimeException)
     217             : {
     218           0 :     awt::Rectangle aRect;
     219           0 :     if ( m_pToolBox )
     220           0 :         aRect = AWTRectangle( m_pToolBox->GetItemPosRect( (sal_uInt16)m_nIndexInParent ) );
     221             : 
     222           0 :     return aRect;
     223             : }
     224             : // -----------------------------------------------------------------------------
     225           0 : OUString VCLXAccessibleToolBoxItem::implGetText()
     226             : {
     227           0 :     return GetText (true);
     228             : }
     229             : // -----------------------------------------------------------------------------
     230           0 : Locale VCLXAccessibleToolBoxItem::implGetLocale()
     231             : {
     232           0 :     return Application::GetSettings().GetUILanguageTag().getLocale();
     233             : }
     234             : // -----------------------------------------------------------------------------
     235           0 : void VCLXAccessibleToolBoxItem::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
     236             : {
     237           0 :     nStartIndex = 0;
     238           0 :     nEndIndex = 0;
     239           0 : }
     240             : // -----------------------------------------------------------------------------
     241             : // XInterface
     242             : // -----------------------------------------------------------------------------
     243           0 : IMPLEMENT_FORWARD_REFCOUNT( VCLXAccessibleToolBoxItem, AccessibleTextHelper_BASE )
     244           0 : Any SAL_CALL VCLXAccessibleToolBoxItem::queryInterface( const Type& _rType ) throw (RuntimeException)
     245             : {
     246             :     // #i33611# - toolbox buttons without text don't support XAccessibleText
     247           0 :     if ( _rType == ::getCppuType( ( const Reference< XAccessibleText >* ) 0 )
     248           0 :         && ( !m_pToolBox || m_pToolBox->GetButtonType() == BUTTON_SYMBOL ) )
     249           0 :         return Any();
     250             : 
     251           0 :     ::com::sun::star::uno::Any aReturn = AccessibleTextHelper_BASE::queryInterface( _rType );
     252           0 :     if ( !aReturn.hasValue() )
     253           0 :         aReturn = VCLXAccessibleToolBoxItem_BASE::queryInterface( _rType );
     254           0 :     return aReturn;
     255             : }
     256             : // -----------------------------------------------------------------------------
     257             : // XTypeProvider
     258             : // -----------------------------------------------------------------------------
     259           0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleToolBoxItem, AccessibleTextHelper_BASE, VCLXAccessibleToolBoxItem_BASE )
     260             : // -----------------------------------------------------------------------------
     261             : // XComponent
     262             : // -----------------------------------------------------------------------------
     263           0 : void SAL_CALL VCLXAccessibleToolBoxItem::disposing()
     264             : {
     265           0 :     AccessibleTextHelper_BASE::disposing();
     266           0 :     m_pToolBox = NULL;
     267           0 : }
     268             : // -----------------------------------------------------------------------------
     269             : // XServiceInfo
     270             : // -----------------------------------------------------------------------------
     271           0 : OUString VCLXAccessibleToolBoxItem::getImplementationName() throw (RuntimeException)
     272             : {
     273           0 :     return OUString( "com.sun.star.comp.toolkit.AccessibleToolBoxItem" );
     274             : }
     275             : // -----------------------------------------------------------------------------
     276           0 : sal_Bool VCLXAccessibleToolBoxItem::supportsService( const OUString& rServiceName ) throw (RuntimeException)
     277             : {
     278           0 :     return cppu::supportsService(this, rServiceName);
     279             : }
     280             : // -----------------------------------------------------------------------------
     281           0 : Sequence< OUString > VCLXAccessibleToolBoxItem::getSupportedServiceNames() throw (RuntimeException)
     282             : {
     283           0 :     Sequence< OUString > aNames(4);
     284           0 :     aNames[0] = "com.sun.star.accessibility.AccessibleContext";
     285           0 :     aNames[1] = "com.sun.star.accessibility.AccessibleComponent";
     286           0 :     aNames[2] = "com.sun.star.accessibility.AccessibleExtendedComponent";
     287           0 :     aNames[3] = "com.sun.star.accessibility.AccessibleToolBoxItem";
     288           0 :     return aNames;
     289             : }
     290             : // -----------------------------------------------------------------------------
     291             : // XAccessible
     292             : // -----------------------------------------------------------------------------
     293           0 : Reference< XAccessibleContext > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleContext(  ) throw (RuntimeException)
     294             : {
     295           0 :     return this;
     296             : }
     297             : // -----------------------------------------------------------------------------
     298             : // XAccessibleContext
     299             : // -----------------------------------------------------------------------------
     300           0 : sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleChildCount(  ) throw (RuntimeException)
     301             : {
     302           0 :     OContextEntryGuard aGuard( this );
     303             : 
     304           0 :     return m_xChild.is() ? 1 : 0;
     305             : }
     306             : // -----------------------------------------------------------------------------
     307           0 : Reference< XAccessible > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleChild( sal_Int32 i ) throw (RuntimeException,  com::sun::star::lang::IndexOutOfBoundsException)
     308             : {
     309           0 :     OContextEntryGuard aGuard( this );
     310             : 
     311             :     // no child -> so index is out of bounds
     312           0 :     if ( !m_xChild.is() || i != 0 )
     313           0 :         throw IndexOutOfBoundsException();
     314             : 
     315           0 :     return m_xChild;
     316             : }
     317             : // -----------------------------------------------------------------------------
     318           0 : Reference< XAccessible > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleParent(  ) throw (RuntimeException)
     319             : {
     320           0 :     OContextEntryGuard aGuard( this );
     321             : 
     322           0 :     return m_pToolBox->GetAccessible();
     323             : }
     324             : // -----------------------------------------------------------------------------
     325           0 : sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleIndexInParent(  ) throw (RuntimeException)
     326             : {
     327           0 :     OContextEntryGuard aGuard( this );
     328             : 
     329           0 :     return m_nIndexInParent;
     330             : }
     331             : // -----------------------------------------------------------------------------
     332           0 : sal_Int16 SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleRole(  ) throw (RuntimeException)
     333             : {
     334           0 :     OContextEntryGuard aGuard( this );
     335             : 
     336           0 :     return m_nRole;
     337             : }
     338             : // -----------------------------------------------------------------------------
     339           0 : OUString SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleDescription(  ) throw (RuntimeException)
     340             : {
     341           0 :     OExternalLockGuard aGuard( this );
     342             : 
     343           0 :     OUString sDescription;
     344           0 :     if ( m_pToolBox )
     345           0 :         sDescription = m_pToolBox->GetHelpText( m_nItemId );
     346             : 
     347           0 :     return sDescription;
     348             : }
     349             : // -----------------------------------------------------------------------------
     350           0 : OUString SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleName(  ) throw (RuntimeException)
     351             : {
     352           0 :     OExternalLockGuard aGuard( this );
     353             : 
     354             :     // entry text == accessible name
     355           0 :     return GetText( true );
     356             : }
     357             : // -----------------------------------------------------------------------------
     358           0 : Reference< XAccessibleRelationSet > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleRelationSet(  ) throw (RuntimeException)
     359             : {
     360           0 :     OContextEntryGuard aGuard( this );
     361             : 
     362           0 :     utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
     363           0 :     Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
     364           0 :     return xSet;
     365             : }
     366             : // -----------------------------------------------------------------------------
     367           0 : Reference< XAccessibleStateSet > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleStateSet(  ) throw (RuntimeException)
     368             : {
     369           0 :     OExternalLockGuard aGuard( this );
     370             : 
     371           0 :     utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
     372           0 :     Reference< XAccessibleStateSet > xStateSet = pStateSetHelper;
     373             : 
     374           0 :     if ( m_pToolBox && !rBHelper.bDisposed && !rBHelper.bInDispose )
     375             :     {
     376           0 :         pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
     377           0 :         if ( m_bIsChecked )
     378           0 :             pStateSetHelper->AddState( AccessibleStateType::CHECKED );
     379           0 :         if ( m_bIndeterminate )
     380           0 :             pStateSetHelper->AddState( AccessibleStateType::INDETERMINATE );
     381           0 :         if ( m_pToolBox->IsItemEnabled( m_nItemId ) )
     382             :         {
     383           0 :             pStateSetHelper->AddState( AccessibleStateType::ENABLED );
     384           0 :             pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
     385             :         }
     386           0 :         if ( m_pToolBox->IsItemVisible( m_nItemId ) )
     387           0 :             pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
     388           0 :         if ( m_pToolBox->IsItemReallyVisible( m_nItemId ) )
     389           0 :             pStateSetHelper->AddState( AccessibleStateType::SHOWING );
     390           0 :         if ( m_bHasFocus )
     391           0 :             pStateSetHelper->AddState( AccessibleStateType::FOCUSED );
     392             :     }
     393             :     else
     394           0 :         pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
     395             : 
     396           0 :     return xStateSet;
     397             : }
     398             : // -----------------------------------------------------------------------------
     399             : // XAccessibleText
     400             : // -----------------------------------------------------------------------------
     401           0 : sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getCaretPosition() throw (RuntimeException)
     402             : {
     403           0 :     return -1;
     404             : }
     405             : // -----------------------------------------------------------------------------
     406           0 : sal_Bool SAL_CALL VCLXAccessibleToolBoxItem::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     407             : {
     408           0 :     OExternalLockGuard aGuard( this );
     409             : 
     410           0 :     if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
     411           0 :         throw IndexOutOfBoundsException();
     412             : 
     413           0 :     return sal_False;
     414             : }
     415             : // -----------------------------------------------------------------------------
     416           0 : Sequence< PropertyValue > SAL_CALL VCLXAccessibleToolBoxItem::getCharacterAttributes( sal_Int32 nIndex, const Sequence< OUString >& ) throw (IndexOutOfBoundsException, RuntimeException)
     417             : {
     418           0 :     OExternalLockGuard aGuard( this );
     419             : 
     420           0 :     OUString sText( implGetText() );
     421             : 
     422           0 :     if ( !implIsValidIndex( nIndex, sText.getLength() ) )
     423           0 :         throw IndexOutOfBoundsException();
     424             : 
     425           0 :     return Sequence< PropertyValue >();
     426             : }
     427             : // -----------------------------------------------------------------------------
     428           0 : awt::Rectangle SAL_CALL VCLXAccessibleToolBoxItem::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     429             : {
     430           0 :     OExternalLockGuard aGuard( this );
     431             : 
     432           0 :     OUString sText( implGetText() );
     433             : 
     434           0 :     if ( !implIsValidIndex( nIndex, sText.getLength() ) )
     435           0 :         throw IndexOutOfBoundsException();
     436             : 
     437           0 :     awt::Rectangle aBounds( 0, 0, 0, 0 );
     438           0 :     if ( m_pToolBox && m_pToolBox->GetButtonType() != BUTTON_SYMBOL ) // symbol buttons have no character bounds
     439             :     {
     440           0 :         Rectangle aCharRect = m_pToolBox->GetCharacterBounds( m_nItemId, nIndex );
     441           0 :         Rectangle aItemRect = m_pToolBox->GetItemRect( m_nItemId );
     442           0 :         aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
     443           0 :         aBounds = AWTRectangle( aCharRect );
     444             :     }
     445             : 
     446           0 :     return aBounds;
     447             : }
     448             : // -----------------------------------------------------------------------------
     449           0 : sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
     450             : {
     451           0 :     OExternalLockGuard aGuard( this );
     452             : 
     453           0 :     sal_Int32 nIndex = -1;
     454           0 :     if ( m_pToolBox && m_pToolBox->GetButtonType() != BUTTON_SYMBOL ) // symbol buttons have no character bounds
     455             :     {
     456           0 :         sal_uInt16 nItemId = 0;
     457           0 :         Rectangle aItemRect = m_pToolBox->GetItemRect( m_nItemId );
     458           0 :         Point aPnt( VCLPoint( aPoint ) );
     459           0 :         aPnt += aItemRect.TopLeft();
     460           0 :         sal_Int32 nIdx = m_pToolBox->GetIndexForPoint( aPnt, nItemId );
     461           0 :         if ( nIdx != -1 && nItemId == m_nItemId )
     462           0 :             nIndex = nIdx;
     463             :     }
     464             : 
     465           0 :     return nIndex;
     466             : }
     467             : // -----------------------------------------------------------------------------
     468           0 : sal_Bool SAL_CALL VCLXAccessibleToolBoxItem::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     469             : {
     470           0 :     OExternalLockGuard aGuard( this );
     471             : 
     472           0 :     if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
     473           0 :         throw IndexOutOfBoundsException();
     474             : 
     475           0 :     return sal_False;
     476             : }
     477             : // -----------------------------------------------------------------------------
     478           0 : sal_Bool SAL_CALL VCLXAccessibleToolBoxItem::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     479             : {
     480           0 :     OExternalLockGuard aGuard( this );
     481             : 
     482           0 :     if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
     483           0 :         throw IndexOutOfBoundsException();
     484             : 
     485           0 :     sal_Bool bReturn = sal_False;
     486             : 
     487           0 :     if ( m_pToolBox )
     488             :     {
     489           0 :         Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pToolBox->GetClipboard();
     490           0 :         if ( xClipboard.is() )
     491             :         {
     492           0 :             OUString sText( getTextRange( nStartIndex, nEndIndex ) );
     493             : 
     494           0 :             ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
     495           0 :             const sal_uInt32 nRef = Application::ReleaseSolarMutex();
     496           0 :             xClipboard->setContents( pDataObj, NULL );
     497             : 
     498           0 :             Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
     499           0 :             if( xFlushableClipboard.is() )
     500           0 :                 xFlushableClipboard->flushClipboard();
     501             : 
     502           0 :             Application::AcquireSolarMutex( nRef );
     503             : 
     504           0 :             bReturn = sal_True;
     505           0 :         }
     506             :     }
     507             : 
     508           0 :     return bReturn;
     509             : }
     510             : // -----------------------------------------------------------------------------
     511             : // XAccessibleComponent
     512             : // -----------------------------------------------------------------------------
     513           0 : Reference< XAccessible > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
     514             : {
     515           0 :     return Reference< XAccessible >();
     516             : }
     517             : // -----------------------------------------------------------------------------
     518           0 : void SAL_CALL VCLXAccessibleToolBoxItem::grabFocus(  ) throw (RuntimeException)
     519             : {
     520           0 :     Reference< XAccessible > xParent(getAccessibleParent());
     521             : 
     522           0 :     if( xParent.is() )
     523             :     {
     524           0 :         Reference< XAccessibleSelection > rxAccessibleSelection(xParent->getAccessibleContext(), UNO_QUERY);
     525             : 
     526           0 :         if ( rxAccessibleSelection.is() )
     527             :         {
     528           0 :             rxAccessibleSelection -> selectAccessibleChild ( getAccessibleIndexInParent() );
     529           0 :         }
     530           0 :     }
     531           0 : }
     532             : // -----------------------------------------------------------------------------
     533           0 : sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getForeground(  ) throw (RuntimeException)
     534             : {
     535           0 :     OExternalLockGuard aGuard( this );
     536             : 
     537           0 :     sal_Int32 nColor = 0;
     538           0 :     if ( m_pToolBox )
     539           0 :        nColor = m_pToolBox->GetControlForeground().GetColor();
     540             : 
     541           0 :     return nColor;
     542             : }
     543             : // -----------------------------------------------------------------------------
     544           0 : sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getBackground(  ) throw (RuntimeException)
     545             : {
     546           0 :     OExternalLockGuard aGuard( this );
     547             : 
     548           0 :     sal_Int32 nColor = 0;
     549           0 :     if ( m_pToolBox )
     550           0 :        nColor = m_pToolBox->GetControlBackground().GetColor();
     551             : 
     552           0 :     return nColor;
     553             : }
     554             : // -----------------------------------------------------------------------------
     555             : // XAccessibleExtendedComponent
     556             : // -----------------------------------------------------------------------------
     557           0 : Reference< awt::XFont > SAL_CALL VCLXAccessibleToolBoxItem::getFont(    ) throw (RuntimeException)
     558             : {
     559           0 :     return uno::Reference< awt::XFont >();
     560             : }
     561             : // -----------------------------------------------------------------------------
     562           0 : awt::FontDescriptor SAL_CALL VCLXAccessibleToolBoxItem::getFontMetrics( const Reference< awt::XFont >& xFont ) throw (RuntimeException)
     563             : {
     564           0 :     return xFont->getFontDescriptor();
     565             : }
     566             : // -----------------------------------------------------------------------------
     567           0 : OUString SAL_CALL VCLXAccessibleToolBoxItem::getTitledBorderText(  ) throw (RuntimeException)
     568             : {
     569           0 :     OExternalLockGuard aGuard( this );
     570             : 
     571           0 :     OUString sRet;
     572           0 :     if ( m_pToolBox )
     573           0 :         sRet = m_pToolBox->GetItemText( m_nItemId );
     574             : 
     575           0 :     return sRet;
     576             : }
     577             : // -----------------------------------------------------------------------------
     578           0 : OUString SAL_CALL VCLXAccessibleToolBoxItem::getToolTipText(  ) throw (RuntimeException)
     579             : {
     580           0 :     OExternalLockGuard aGuard( this );
     581             : 
     582           0 :     OUString sRet;
     583           0 :     if ( m_pToolBox )
     584             :     {
     585           0 :         if ( Help::IsExtHelpEnabled() )
     586           0 :             sRet = m_pToolBox->GetHelpText( m_nItemId );
     587             :         else
     588           0 :             sRet = m_pToolBox->GetQuickHelpText( m_nItemId );
     589           0 :         if ( sRet.isEmpty() )
     590             :             // no help text set, so use item text
     591           0 :             sRet = m_pToolBox->GetItemText( m_nItemId );
     592             :     }
     593           0 :     return sRet;
     594             : }
     595             : // -----------------------------------------------------------------------------
     596             : // XAccessibleAction
     597             : // -----------------------------------------------------------------------------
     598           0 : sal_Int32 VCLXAccessibleToolBoxItem::getAccessibleActionCount( ) throw (RuntimeException)
     599             : {
     600             :     // only one action -> "Click"
     601           0 :     return 1;
     602             : }
     603             : // -----------------------------------------------------------------------------
     604           0 : sal_Bool VCLXAccessibleToolBoxItem::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     605             : {
     606           0 :     OExternalLockGuard aGuard( this );
     607             : 
     608           0 :     if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
     609           0 :         throw IndexOutOfBoundsException();
     610             : 
     611           0 :     if ( m_pToolBox )
     612           0 :         m_pToolBox->TriggerItem( m_nItemId );
     613             : 
     614           0 :     return sal_True;
     615             : }
     616             : // -----------------------------------------------------------------------------
     617           0 : OUString VCLXAccessibleToolBoxItem::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     618             : {
     619           0 :     OExternalLockGuard aGuard( this );
     620             : 
     621           0 :     if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
     622           0 :         throw IndexOutOfBoundsException();
     623             : 
     624           0 :     return OUString( TK_RES_STRING( RID_STR_ACC_ACTION_CLICK ) );
     625             : }
     626             : // -----------------------------------------------------------------------------
     627           0 : Reference< XAccessibleKeyBinding > VCLXAccessibleToolBoxItem::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     628             : {
     629           0 :     OContextEntryGuard aGuard( this );
     630             : 
     631           0 :     if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
     632           0 :         throw IndexOutOfBoundsException();
     633             : 
     634           0 :     return Reference< XAccessibleKeyBinding >();
     635             : }
     636             : // -----------------------------------------------------------------------------
     637             : // XAccessibleValue
     638             : // -----------------------------------------------------------------------------
     639           0 : Any VCLXAccessibleToolBoxItem::getCurrentValue(  ) throw (RuntimeException)
     640             : {
     641           0 :     OExternalLockGuard aGuard( this );
     642             : 
     643           0 :     Any aValue;
     644           0 :     if ( m_pToolBox )
     645           0 :         aValue <<= (sal_Int32)m_pToolBox->IsItemChecked( m_nItemId );
     646             : 
     647           0 :     return aValue;
     648             : }
     649             : // -----------------------------------------------------------------------------
     650           0 : sal_Bool VCLXAccessibleToolBoxItem::setCurrentValue( const Any& aNumber ) throw (RuntimeException)
     651             : {
     652           0 :     OExternalLockGuard aGuard( this );
     653             : 
     654           0 :     sal_Bool bReturn = sal_False;
     655             : 
     656           0 :     if ( m_pToolBox )
     657             :     {
     658           0 :         sal_Int32 nValue = 0;
     659           0 :         OSL_VERIFY( aNumber >>= nValue );
     660             : 
     661           0 :         if ( nValue < 0 )
     662           0 :             nValue = 0;
     663           0 :         else if ( nValue > 1 )
     664           0 :             nValue = 1;
     665             : 
     666           0 :         m_pToolBox->CheckItem( m_nItemId, (sal_Bool) nValue );
     667           0 :         bReturn = sal_True;
     668             :     }
     669             : 
     670           0 :     return bReturn;
     671             : }
     672             : // -----------------------------------------------------------------------------
     673           0 : Any VCLXAccessibleToolBoxItem::getMaximumValue(  ) throw (RuntimeException)
     674             : {
     675           0 :     return makeAny((sal_Int32)1);
     676             : }
     677             : // -----------------------------------------------------------------------------
     678           0 : Any VCLXAccessibleToolBoxItem::getMinimumValue(  ) throw (RuntimeException)
     679             : {
     680           0 :     return makeAny((sal_Int32)0);
     681             : }
     682             : // -----------------------------------------------------------------------------
     683             : 
     684             : 
     685             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10