LCOV - code coverage report
Current view: top level - accessibility/source/standard - vclxaccessiblescrollbar.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 38 100 38.0 %
Date: 2012-08-25 Functions: 11 20 55.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 25 148 16.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/vclxaccessiblescrollbar.hxx>
      30                 :            : 
      31                 :            : #include <toolkit/awt/vclxwindows.hxx>
      32                 :            : #include <accessibility/helper/accresmgr.hxx>
      33                 :            : #include <accessibility/helper/accessiblestrings.hrc>
      34                 :            : 
      35                 :            : #include <unotools/accessiblestatesethelper.hxx>
      36                 :            : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      37                 :            : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      38                 :            : #include <com/sun/star/awt/ScrollBarOrientation.hpp>
      39                 :            : #include <cppuhelper/typeprovider.hxx>
      40                 :            : #include <comphelper/sequence.hxx>
      41                 :            : #include <vcl/scrbar.hxx>
      42                 :            : 
      43                 :            : using namespace ::com::sun::star;
      44                 :            : using namespace ::com::sun::star::uno;
      45                 :            : using namespace ::com::sun::star::awt;
      46                 :            : using namespace ::com::sun::star::lang;
      47                 :            : using namespace ::com::sun::star::beans;
      48                 :            : using namespace ::com::sun::star::accessibility;
      49                 :            : using namespace ::comphelper;
      50                 :            : 
      51                 :            : // -----------------------------------------------------------------------------
      52                 :            : // VCLXAccessibleScrollBar
      53                 :            : // -----------------------------------------------------------------------------
      54                 :            : 
      55                 :         32 : VCLXAccessibleScrollBar::VCLXAccessibleScrollBar( VCLXWindow* pVCLWindow )
      56                 :         32 :     :VCLXAccessibleComponent( pVCLWindow )
      57                 :            : {
      58                 :         32 : }
      59                 :            : 
      60                 :            : // -----------------------------------------------------------------------------
      61                 :            : 
      62                 :         32 : VCLXAccessibleScrollBar::~VCLXAccessibleScrollBar()
      63                 :            : {
      64         [ -  + ]:         64 : }
      65                 :            : 
      66                 :            : // -----------------------------------------------------------------------------
      67                 :            : 
      68                 :         40 : void VCLXAccessibleScrollBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
      69                 :            : {
      70         [ +  + ]:         40 :     switch ( rVclWindowEvent.GetId() )
      71                 :            :     {
      72                 :            :         case VCLEVENT_SCROLLBAR_SCROLL:
      73                 :            :         {
      74         [ +  - ]:          4 :             NotifyAccessibleEvent( AccessibleEventId::VALUE_CHANGED, Any(), Any() );
      75                 :            :         }
      76                 :          4 :         break;
      77                 :            :         default:
      78                 :         36 :             VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
      79                 :            :    }
      80                 :         40 : }
      81                 :            : 
      82                 :            : // -----------------------------------------------------------------------------
      83                 :            : 
      84                 :         34 : void VCLXAccessibleScrollBar::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
      85                 :            : {
      86                 :         34 :     VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet );
      87                 :            : 
      88         [ +  - ]:         34 :     VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() );
      89         [ +  - ]:         34 :     if ( pVCLXScrollBar )
      90                 :            :     {
      91                 :         34 :         rStateSet.AddState( AccessibleStateType::FOCUSABLE );
      92         [ +  + ]:         34 :         if ( pVCLXScrollBar->getOrientation() == ScrollBarOrientation::HORIZONTAL )
      93                 :         19 :             rStateSet.AddState( AccessibleStateType::HORIZONTAL );
      94         [ +  - ]:         15 :         else if ( pVCLXScrollBar->getOrientation() == ScrollBarOrientation::VERTICAL )
      95                 :         15 :             rStateSet.AddState( AccessibleStateType::VERTICAL );
      96                 :            :     }
      97                 :         34 : }
      98                 :            : 
      99                 :            : // -----------------------------------------------------------------------------
     100                 :            : // XInterface
     101                 :            : // -----------------------------------------------------------------------------
     102                 :            : 
     103 [ +  + ][ +  - ]:       1050 : IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleScrollBar, VCLXAccessibleComponent, VCLXAccessibleScrollBar_BASE )
     104                 :            : 
     105                 :            : // -----------------------------------------------------------------------------
     106                 :            : // XTypeProvider
     107                 :            : // -----------------------------------------------------------------------------
     108                 :            : 
     109 [ #  # ][ #  # ]:          0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleScrollBar, VCLXAccessibleComponent, VCLXAccessibleScrollBar_BASE )
                 [ #  # ]
     110                 :            : 
     111                 :            : // -----------------------------------------------------------------------------
     112                 :            : // XServiceInfo
     113                 :            : // -----------------------------------------------------------------------------
     114                 :            : 
     115                 :          2 : ::rtl::OUString VCLXAccessibleScrollBar::getImplementationName() throw (RuntimeException)
     116                 :            : {
     117                 :          2 :     return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.toolkit.AccessibleScrollBar") );
     118                 :            : }
     119                 :            : 
     120                 :            : // -----------------------------------------------------------------------------
     121                 :            : 
     122                 :          0 : Sequence< ::rtl::OUString > VCLXAccessibleScrollBar::getSupportedServiceNames() throw (RuntimeException)
     123                 :            : {
     124                 :          0 :     Sequence< ::rtl::OUString > aNames(1);
     125 [ #  # ][ #  # ]:          0 :     aNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.AccessibleScrollBar") );
     126                 :          0 :     return aNames;
     127                 :            : }
     128                 :            : 
     129                 :            : // -----------------------------------------------------------------------------
     130                 :            : // XAccessibleAction
     131                 :            : // -----------------------------------------------------------------------------
     132                 :            : 
     133                 :          4 : sal_Int32 VCLXAccessibleScrollBar::getAccessibleActionCount( ) throw (RuntimeException)
     134                 :            : {
     135         [ +  - ]:          4 :     OExternalLockGuard aGuard( this );
     136                 :            : 
     137         [ +  - ]:          4 :     return 4;
     138                 :            : }
     139                 :            : 
     140                 :            : // -----------------------------------------------------------------------------
     141                 :            : 
     142                 :          4 : sal_Bool VCLXAccessibleScrollBar::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     143                 :            : {
     144         [ +  - ]:          4 :     OExternalLockGuard aGuard( this );
     145                 :            : 
     146 [ +  - ][ +  - ]:          4 :     if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
         [ -  + ][ -  + ]
     147         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     148                 :            : 
     149                 :          4 :     sal_Bool bReturn = sal_False;
     150         [ +  - ]:          4 :     ScrollBar* pScrollBar = static_cast< ScrollBar* >( GetWindow() );
     151         [ +  - ]:          4 :     if ( pScrollBar )
     152                 :            :     {
     153                 :            :         ScrollType eScrollType;
     154   [ -  +  -  -  :          4 :         switch ( nIndex )
                      - ]
     155                 :            :         {
     156                 :          0 :             case 0:     eScrollType = SCROLL_LINEUP;    break;
     157                 :          4 :             case 1:     eScrollType = SCROLL_LINEDOWN;  break;
     158                 :          0 :             case 2:     eScrollType = SCROLL_PAGEUP;    break;
     159                 :          0 :             case 3:     eScrollType = SCROLL_PAGEDOWN;  break;
     160                 :          0 :             default:    eScrollType = SCROLL_DONTKNOW;  break;
     161                 :            :         }
     162 [ +  - ][ +  - ]:          4 :         if ( pScrollBar->DoScrollAction( eScrollType ) )
     163                 :          4 :             bReturn = sal_True;
     164                 :            :     }
     165                 :            : 
     166         [ +  - ]:          4 :     return bReturn;
     167                 :            : }
     168                 :            : 
     169                 :            : // -----------------------------------------------------------------------------
     170                 :            : 
     171                 :          0 : ::rtl::OUString VCLXAccessibleScrollBar::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     172                 :            : {
     173         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     174                 :            : 
     175 [ #  # ][ #  # ]:          0 :     if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
         [ #  # ][ #  # ]
     176         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     177                 :            : 
     178                 :          0 :     ::rtl::OUString sDescription;
     179                 :            : 
     180   [ #  #  #  #  :          0 :     switch ( nIndex )
                      # ]
     181                 :            :     {
     182         [ #  # ]:          0 :         case 0:     sDescription = ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_DECLINE ) );      break;
     183         [ #  # ]:          0 :         case 1:     sDescription = ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_INCLINE ) );      break;
     184         [ #  # ]:          0 :         case 2:     sDescription = ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_DECBLOCK ) );     break;
     185         [ #  # ]:          0 :         case 3:     sDescription = ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_INCBLOCK ) );     break;
     186                 :          0 :         default:                                                                                        break;
     187                 :            :     }
     188                 :            : 
     189         [ #  # ]:          0 :     return sDescription;
     190                 :            : }
     191                 :            : 
     192                 :            : // -----------------------------------------------------------------------------
     193                 :            : 
     194                 :          0 : Reference< XAccessibleKeyBinding > VCLXAccessibleScrollBar::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     195                 :            : {
     196         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     197                 :            : 
     198 [ #  # ][ #  # ]:          0 :     if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
         [ #  # ][ #  # ]
     199         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     200                 :            : 
     201         [ #  # ]:          0 :     return Reference< XAccessibleKeyBinding >();
     202                 :            : }
     203                 :            : 
     204                 :            : // -----------------------------------------------------------------------------
     205                 :            : // XAccessibleValue
     206                 :            : // -----------------------------------------------------------------------------
     207                 :            : 
     208                 :          0 : Any VCLXAccessibleScrollBar::getCurrentValue(  ) throw (RuntimeException)
     209                 :            : {
     210         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     211                 :            : 
     212                 :          0 :     Any aValue;
     213                 :            : 
     214         [ #  # ]:          0 :     VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() );
     215         [ #  # ]:          0 :     if ( pVCLXScrollBar )
     216 [ #  # ][ #  # ]:          0 :         aValue <<= (sal_Int32) pVCLXScrollBar->getValue();
     217                 :            : 
     218         [ #  # ]:          0 :     return aValue;
     219                 :            : }
     220                 :            : 
     221                 :            : // -----------------------------------------------------------------------------
     222                 :            : 
     223                 :          0 : sal_Bool VCLXAccessibleScrollBar::setCurrentValue( const Any& aNumber ) throw (RuntimeException)
     224                 :            : {
     225         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     226                 :            : 
     227                 :          0 :     sal_Bool bReturn = sal_False;
     228                 :            : 
     229         [ #  # ]:          0 :     VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() );
     230         [ #  # ]:          0 :     if ( pVCLXScrollBar )
     231                 :            :     {
     232                 :          0 :         sal_Int32 nValue = 0, nValueMin = 0, nValueMax = 0;
     233                 :          0 :         OSL_VERIFY( aNumber >>= nValue );
     234         [ #  # ]:          0 :         OSL_VERIFY( getMinimumValue() >>= nValueMin );
     235         [ #  # ]:          0 :         OSL_VERIFY( getMaximumValue() >>= nValueMax );
     236                 :            : 
     237         [ #  # ]:          0 :         if ( nValue < nValueMin )
     238                 :          0 :             nValue = nValueMin;
     239         [ #  # ]:          0 :         else if ( nValue > nValueMax )
     240                 :          0 :             nValue = nValueMax;
     241                 :            : 
     242         [ #  # ]:          0 :         pVCLXScrollBar->setValue( nValue );
     243                 :          0 :         bReturn = sal_True;
     244                 :            :     }
     245                 :            : 
     246         [ #  # ]:          0 :     return bReturn;
     247                 :            : }
     248                 :            : 
     249                 :            : // -----------------------------------------------------------------------------
     250                 :            : 
     251                 :          0 : Any VCLXAccessibleScrollBar::getMaximumValue(  ) throw (RuntimeException)
     252                 :            : {
     253         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     254                 :            : 
     255                 :          0 :     Any aValue;
     256                 :            : 
     257         [ #  # ]:          0 :     VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() );
     258         [ #  # ]:          0 :     if ( pVCLXScrollBar )
     259 [ #  # ][ #  # ]:          0 :         aValue <<= (sal_Int32) pVCLXScrollBar->getMaximum();
     260                 :            : 
     261         [ #  # ]:          0 :     return aValue;
     262                 :            : }
     263                 :            : 
     264                 :            : // -----------------------------------------------------------------------------
     265                 :            : 
     266                 :          0 : Any VCLXAccessibleScrollBar::getMinimumValue(  ) throw (RuntimeException)
     267                 :            : {
     268         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     269                 :            : 
     270                 :          0 :     Any aValue;
     271         [ #  # ]:          0 :     aValue <<= (sal_Int32) 0;
     272                 :            : 
     273         [ #  # ]:          0 :     return aValue;
     274                 :            : }
     275                 :            : 
     276                 :            : // -----------------------------------------------------------------------------
     277                 :            : 
     278                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10