LCOV - code coverage report
Current view: top level - libreoffice/accessibility/source/standard - vclxaccessiblescrollbar.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 100 0.0 %
Date: 2012-12-27 Functions: 0 20 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <accessibility/standard/vclxaccessiblescrollbar.hxx>
      21             : 
      22             : #include <toolkit/awt/vclxwindows.hxx>
      23             : #include <accessibility/helper/accresmgr.hxx>
      24             : #include <accessibility/helper/accessiblestrings.hrc>
      25             : 
      26             : #include <unotools/accessiblestatesethelper.hxx>
      27             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      28             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      29             : #include <com/sun/star/awt/ScrollBarOrientation.hpp>
      30             : #include <cppuhelper/typeprovider.hxx>
      31             : #include <comphelper/sequence.hxx>
      32             : #include <vcl/scrbar.hxx>
      33             : 
      34             : using namespace ::com::sun::star;
      35             : using namespace ::com::sun::star::uno;
      36             : using namespace ::com::sun::star::awt;
      37             : using namespace ::com::sun::star::lang;
      38             : using namespace ::com::sun::star::beans;
      39             : using namespace ::com::sun::star::accessibility;
      40             : using namespace ::comphelper;
      41             : 
      42             : // -----------------------------------------------------------------------------
      43             : // VCLXAccessibleScrollBar
      44             : // -----------------------------------------------------------------------------
      45             : 
      46           0 : VCLXAccessibleScrollBar::VCLXAccessibleScrollBar( VCLXWindow* pVCLWindow )
      47           0 :     :VCLXAccessibleComponent( pVCLWindow )
      48             : {
      49           0 : }
      50             : 
      51             : // -----------------------------------------------------------------------------
      52             : 
      53           0 : VCLXAccessibleScrollBar::~VCLXAccessibleScrollBar()
      54             : {
      55           0 : }
      56             : 
      57             : // -----------------------------------------------------------------------------
      58             : 
      59           0 : void VCLXAccessibleScrollBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
      60             : {
      61           0 :     switch ( rVclWindowEvent.GetId() )
      62             :     {
      63             :         case VCLEVENT_SCROLLBAR_SCROLL:
      64             :         {
      65           0 :             NotifyAccessibleEvent( AccessibleEventId::VALUE_CHANGED, Any(), Any() );
      66             :         }
      67           0 :         break;
      68             :         default:
      69           0 :             VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
      70             :    }
      71           0 : }
      72             : 
      73             : // -----------------------------------------------------------------------------
      74             : 
      75           0 : void VCLXAccessibleScrollBar::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
      76             : {
      77           0 :     VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet );
      78             : 
      79           0 :     VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() );
      80           0 :     if ( pVCLXScrollBar )
      81             :     {
      82           0 :         rStateSet.AddState( AccessibleStateType::FOCUSABLE );
      83           0 :         if ( pVCLXScrollBar->getOrientation() == ScrollBarOrientation::HORIZONTAL )
      84           0 :             rStateSet.AddState( AccessibleStateType::HORIZONTAL );
      85           0 :         else if ( pVCLXScrollBar->getOrientation() == ScrollBarOrientation::VERTICAL )
      86           0 :             rStateSet.AddState( AccessibleStateType::VERTICAL );
      87             :     }
      88           0 : }
      89             : 
      90             : // -----------------------------------------------------------------------------
      91             : // XInterface
      92             : // -----------------------------------------------------------------------------
      93             : 
      94           0 : IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleScrollBar, VCLXAccessibleComponent, VCLXAccessibleScrollBar_BASE )
      95             : 
      96             : // -----------------------------------------------------------------------------
      97             : // XTypeProvider
      98             : // -----------------------------------------------------------------------------
      99             : 
     100           0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleScrollBar, VCLXAccessibleComponent, VCLXAccessibleScrollBar_BASE )
     101             : 
     102             : // -----------------------------------------------------------------------------
     103             : // XServiceInfo
     104             : // -----------------------------------------------------------------------------
     105             : 
     106           0 : OUString VCLXAccessibleScrollBar::getImplementationName() throw (RuntimeException)
     107             : {
     108           0 :     return OUString( "com.sun.star.comp.toolkit.AccessibleScrollBar" );
     109             : }
     110             : 
     111             : // -----------------------------------------------------------------------------
     112             : 
     113           0 : Sequence< OUString > VCLXAccessibleScrollBar::getSupportedServiceNames() throw (RuntimeException)
     114             : {
     115           0 :     Sequence< OUString > aNames(1);
     116           0 :     aNames[0] = "com.sun.star.awt.AccessibleScrollBar";
     117           0 :     return aNames;
     118             : }
     119             : 
     120             : // -----------------------------------------------------------------------------
     121             : // XAccessibleAction
     122             : // -----------------------------------------------------------------------------
     123             : 
     124           0 : sal_Int32 VCLXAccessibleScrollBar::getAccessibleActionCount( ) throw (RuntimeException)
     125             : {
     126           0 :     OExternalLockGuard aGuard( this );
     127             : 
     128           0 :     return 4;
     129             : }
     130             : 
     131             : // -----------------------------------------------------------------------------
     132             : 
     133           0 : sal_Bool VCLXAccessibleScrollBar::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     134             : {
     135           0 :     OExternalLockGuard aGuard( this );
     136             : 
     137           0 :     if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
     138           0 :         throw IndexOutOfBoundsException();
     139             : 
     140           0 :     sal_Bool bReturn = sal_False;
     141           0 :     ScrollBar* pScrollBar = static_cast< ScrollBar* >( GetWindow() );
     142           0 :     if ( pScrollBar )
     143             :     {
     144             :         ScrollType eScrollType;
     145           0 :         switch ( nIndex )
     146             :         {
     147           0 :             case 0:     eScrollType = SCROLL_LINEUP;    break;
     148           0 :             case 1:     eScrollType = SCROLL_LINEDOWN;  break;
     149           0 :             case 2:     eScrollType = SCROLL_PAGEUP;    break;
     150           0 :             case 3:     eScrollType = SCROLL_PAGEDOWN;  break;
     151           0 :             default:    eScrollType = SCROLL_DONTKNOW;  break;
     152             :         }
     153           0 :         if ( pScrollBar->DoScrollAction( eScrollType ) )
     154           0 :             bReturn = sal_True;
     155             :     }
     156             : 
     157           0 :     return bReturn;
     158             : }
     159             : 
     160             : // -----------------------------------------------------------------------------
     161             : 
     162           0 : OUString VCLXAccessibleScrollBar::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     163             : {
     164           0 :     OExternalLockGuard aGuard( this );
     165             : 
     166           0 :     if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
     167           0 :         throw IndexOutOfBoundsException();
     168             : 
     169           0 :     OUString sDescription;
     170             : 
     171           0 :     switch ( nIndex )
     172             :     {
     173           0 :         case 0:     sDescription = OUString( TK_RES_STRING( RID_STR_ACC_ACTION_DECLINE ) );      break;
     174           0 :         case 1:     sDescription = OUString( TK_RES_STRING( RID_STR_ACC_ACTION_INCLINE ) );      break;
     175           0 :         case 2:     sDescription = OUString( TK_RES_STRING( RID_STR_ACC_ACTION_DECBLOCK ) );     break;
     176           0 :         case 3:     sDescription = OUString( TK_RES_STRING( RID_STR_ACC_ACTION_INCBLOCK ) );     break;
     177           0 :         default:                                                                                        break;
     178             :     }
     179             : 
     180           0 :     return sDescription;
     181             : }
     182             : 
     183             : // -----------------------------------------------------------------------------
     184             : 
     185           0 : Reference< XAccessibleKeyBinding > VCLXAccessibleScrollBar::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     186             : {
     187           0 :     OExternalLockGuard aGuard( this );
     188             : 
     189           0 :     if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
     190           0 :         throw IndexOutOfBoundsException();
     191             : 
     192           0 :     return Reference< XAccessibleKeyBinding >();
     193             : }
     194             : 
     195             : // -----------------------------------------------------------------------------
     196             : // XAccessibleValue
     197             : // -----------------------------------------------------------------------------
     198             : 
     199           0 : Any VCLXAccessibleScrollBar::getCurrentValue(  ) throw (RuntimeException)
     200             : {
     201           0 :     OExternalLockGuard aGuard( this );
     202             : 
     203           0 :     Any aValue;
     204             : 
     205           0 :     VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() );
     206           0 :     if ( pVCLXScrollBar )
     207           0 :         aValue <<= (sal_Int32) pVCLXScrollBar->getValue();
     208             : 
     209           0 :     return aValue;
     210             : }
     211             : 
     212             : // -----------------------------------------------------------------------------
     213             : 
     214           0 : sal_Bool VCLXAccessibleScrollBar::setCurrentValue( const Any& aNumber ) throw (RuntimeException)
     215             : {
     216           0 :     OExternalLockGuard aGuard( this );
     217             : 
     218           0 :     sal_Bool bReturn = sal_False;
     219             : 
     220           0 :     VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() );
     221           0 :     if ( pVCLXScrollBar )
     222             :     {
     223           0 :         sal_Int32 nValue = 0, nValueMin = 0, nValueMax = 0;
     224           0 :         OSL_VERIFY( aNumber >>= nValue );
     225           0 :         OSL_VERIFY( getMinimumValue() >>= nValueMin );
     226           0 :         OSL_VERIFY( getMaximumValue() >>= nValueMax );
     227             : 
     228           0 :         if ( nValue < nValueMin )
     229           0 :             nValue = nValueMin;
     230           0 :         else if ( nValue > nValueMax )
     231           0 :             nValue = nValueMax;
     232             : 
     233           0 :         pVCLXScrollBar->setValue( nValue );
     234           0 :         bReturn = sal_True;
     235             :     }
     236             : 
     237           0 :     return bReturn;
     238             : }
     239             : 
     240             : // -----------------------------------------------------------------------------
     241             : 
     242           0 : Any VCLXAccessibleScrollBar::getMaximumValue(  ) throw (RuntimeException)
     243             : {
     244           0 :     OExternalLockGuard aGuard( this );
     245             : 
     246           0 :     Any aValue;
     247             : 
     248           0 :     VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() );
     249           0 :     if ( pVCLXScrollBar )
     250           0 :         aValue <<= (sal_Int32) pVCLXScrollBar->getMaximum();
     251             : 
     252           0 :     return aValue;
     253             : }
     254             : 
     255             : // -----------------------------------------------------------------------------
     256             : 
     257           0 : Any VCLXAccessibleScrollBar::getMinimumValue(  ) throw (RuntimeException)
     258             : {
     259           0 :     OExternalLockGuard aGuard( this );
     260             : 
     261           0 :     Any aValue;
     262           0 :     aValue <<= (sal_Int32) 0;
     263             : 
     264           0 :     return aValue;
     265             : }
     266             : 
     267             : // -----------------------------------------------------------------------------
     268             : 
     269             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10