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

Generated by: LCOV version 1.10