LCOV - code coverage report
Current view: top level - accessibility/source/standard - vclxaccessibletoolboxitem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 108 331 32.6 %
Date: 2012-08-25 Functions: 22 57 38.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 100 560 17.9 %

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

Generated by: LCOV version 1.10