LCOV - code coverage report
Current view: top level - accessibility/source/standard - vclxaccessibleradiobutton.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 121 0.0 %
Date: 2012-08-25 Functions: 0 21 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 202 0.0 %

           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/vclxaccessibleradiobutton.hxx>
      30                 :            : 
      31                 :            : #include <toolkit/awt/vclxwindows.hxx>
      32                 :            : #include <accessibility/helper/accresmgr.hxx>
      33                 :            : #include <accessibility/helper/accessiblestrings.hrc>
      34                 :            : 
      35                 :            : #include <unotools/accessiblerelationsethelper.hxx>
      36                 :            : #include <unotools/accessiblestatesethelper.hxx>
      37                 :            : #include <comphelper/accessiblekeybindinghelper.hxx>
      38                 :            : #include <com/sun/star/awt/KeyModifier.hpp>
      39                 :            : #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
      40                 :            : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      41                 :            : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      42                 :            : #include <cppuhelper/typeprovider.hxx>
      43                 :            : #include <comphelper/sequence.hxx>
      44                 :            : #include <vcl/window.hxx>
      45                 :            : #include <vcl/button.hxx>
      46                 :            : 
      47                 :            : 
      48                 :            : using namespace ::com::sun::star;
      49                 :            : using namespace ::com::sun::star::uno;
      50                 :            : using namespace ::com::sun::star::lang;
      51                 :            : using namespace ::com::sun::star::beans;
      52                 :            : using namespace ::com::sun::star::accessibility;
      53                 :            : using namespace ::comphelper;
      54                 :            : 
      55                 :            : 
      56                 :            : // -----------------------------------------------------------------------------
      57                 :            : // VCLXAccessibleRadioButton
      58                 :            : // -----------------------------------------------------------------------------
      59                 :            : 
      60                 :          0 : VCLXAccessibleRadioButton::VCLXAccessibleRadioButton( VCLXWindow* pVCLWindow )
      61                 :          0 :     :VCLXAccessibleTextComponent( pVCLWindow )
      62                 :            : {
      63                 :          0 : }
      64                 :            : 
      65                 :            : // -----------------------------------------------------------------------------
      66                 :            : 
      67                 :          0 : VCLXAccessibleRadioButton::~VCLXAccessibleRadioButton()
      68                 :            : {
      69         [ #  # ]:          0 : }
      70                 :            : 
      71                 :            : // -----------------------------------------------------------------------------
      72                 :            : 
      73                 :          0 : void VCLXAccessibleRadioButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
      74                 :            : {
      75         [ #  # ]:          0 :     switch ( rVclWindowEvent.GetId() )
      76                 :            :     {
      77                 :            :         case VCLEVENT_RADIOBUTTON_TOGGLE:
      78                 :            :         {
      79                 :          0 :             Any aOldValue;
      80                 :          0 :             Any aNewValue;
      81                 :            : 
      82         [ #  # ]:          0 :             VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
      83 [ #  # ][ #  # ]:          0 :             if ( pVCLXRadioButton && pVCLXRadioButton->getState() )
         [ #  # ][ #  # ]
      84         [ #  # ]:          0 :                 aNewValue <<= AccessibleStateType::CHECKED;
      85                 :            :             else
      86         [ #  # ]:          0 :                 aOldValue <<= AccessibleStateType::CHECKED;
      87                 :            : 
      88         [ #  # ]:          0 :             NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
      89                 :            :         }
      90                 :          0 :         break;
      91                 :            :         default:
      92                 :          0 :             VCLXAccessibleTextComponent::ProcessWindowEvent( rVclWindowEvent );
      93                 :            :    }
      94                 :          0 : }
      95                 :            : 
      96                 :            : // -----------------------------------------------------------------------------
      97                 :            : 
      98                 :          0 : void VCLXAccessibleRadioButton::FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet )
      99                 :            : {
     100                 :          0 :     VCLXAccessibleTextComponent::FillAccessibleRelationSet( rRelationSet );
     101                 :            : 
     102         [ #  # ]:          0 :     RadioButton* pRadioButton = dynamic_cast< RadioButton* >( GetWindow() );
     103         [ #  # ]:          0 :     if ( pRadioButton )
     104                 :            :     {
     105         [ #  # ]:          0 :         ::std::vector< RadioButton* > aGroup;
     106         [ #  # ]:          0 :         pRadioButton->GetRadioButtonGroup( aGroup, true );
     107         [ #  # ]:          0 :         if ( !aGroup.empty() )
     108                 :            :         {
     109                 :          0 :             sal_Int32 i = 0;
     110         [ #  # ]:          0 :             Sequence< Reference< XInterface > > aSequence( static_cast< sal_Int32 >( aGroup.size() ) );
     111         [ #  # ]:          0 :             ::std::vector< RadioButton* >::const_iterator aEndItr = aGroup.end();
     112 [ #  # ][ #  # ]:          0 :             for ( ::std::vector< RadioButton* >::const_iterator aItr = aGroup.begin(); aItr < aEndItr; ++aItr )
         [ #  # ][ #  # ]
     113                 :            :             {
     114 [ #  # ][ #  # ]:          0 :                 aSequence[i++] = (*aItr)->GetAccessible();
         [ #  # ][ #  # ]
     115                 :            :             }
     116 [ #  # ][ #  # ]:          0 :             rRelationSet.AddRelation( AccessibleRelation( AccessibleRelationType::MEMBER_OF, aSequence ) );
         [ #  # ][ #  # ]
     117                 :          0 :         }
     118                 :            :     }
     119                 :          0 : }
     120                 :            : 
     121                 :            : // -----------------------------------------------------------------------------
     122                 :            : 
     123                 :          0 : void VCLXAccessibleRadioButton::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
     124                 :            : {
     125                 :          0 :     VCLXAccessibleTextComponent::FillAccessibleStateSet( rStateSet );
     126                 :            : 
     127         [ #  # ]:          0 :     VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
     128         [ #  # ]:          0 :     if ( pVCLXRadioButton )
     129                 :            :     {
     130                 :          0 :         rStateSet.AddState( AccessibleStateType::FOCUSABLE );
     131         [ #  # ]:          0 :         if ( pVCLXRadioButton->getState() )
     132                 :          0 :             rStateSet.AddState( AccessibleStateType::CHECKED );
     133                 :            :     }
     134                 :          0 : }
     135                 :            : 
     136                 :            : // -----------------------------------------------------------------------------
     137                 :            : // XInterface
     138                 :            : // -----------------------------------------------------------------------------
     139                 :            : 
     140 [ #  # ][ #  # ]:          0 : IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleRadioButton, VCLXAccessibleTextComponent, VCLXAccessibleRadioButton_BASE )
     141                 :            : 
     142                 :            : // -----------------------------------------------------------------------------
     143                 :            : // XTypeProvider
     144                 :            : // -----------------------------------------------------------------------------
     145                 :            : 
     146 [ #  # ][ #  # ]:          0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleRadioButton, VCLXAccessibleTextComponent, VCLXAccessibleRadioButton_BASE )
                 [ #  # ]
     147                 :            : 
     148                 :            : // -----------------------------------------------------------------------------
     149                 :            : // XServiceInfo
     150                 :            : // -----------------------------------------------------------------------------
     151                 :            : 
     152                 :          0 : ::rtl::OUString VCLXAccessibleRadioButton::getImplementationName() throw (RuntimeException)
     153                 :            : {
     154                 :          0 :     return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.toolkit.AccessibleRadioButton") );
     155                 :            : }
     156                 :            : 
     157                 :            : // -----------------------------------------------------------------------------
     158                 :            : 
     159                 :          0 : Sequence< ::rtl::OUString > VCLXAccessibleRadioButton::getSupportedServiceNames() throw (RuntimeException)
     160                 :            : {
     161                 :          0 :     Sequence< ::rtl::OUString > aNames(1);
     162 [ #  # ][ #  # ]:          0 :     aNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.AccessibleRadioButton") );
     163                 :          0 :     return aNames;
     164                 :            : }
     165                 :            : 
     166                 :            : // -----------------------------------------------------------------------------
     167                 :            : // XAccessibleAction
     168                 :            : // -----------------------------------------------------------------------------
     169                 :            : 
     170                 :          0 : sal_Int32 VCLXAccessibleRadioButton::getAccessibleActionCount( ) throw (RuntimeException)
     171                 :            : {
     172         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     173                 :            : 
     174         [ #  # ]:          0 :     return 1;
     175                 :            : }
     176                 :            : 
     177                 :            : // -----------------------------------------------------------------------------
     178                 :            : 
     179                 :          0 : sal_Bool VCLXAccessibleRadioButton::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     180                 :            : {
     181         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     182                 :            : 
     183 [ #  # ][ #  # ]:          0 :     if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
         [ #  # ][ #  # ]
     184         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     185                 :            : 
     186         [ #  # ]:          0 :     VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
     187 [ #  # ][ #  # ]:          0 :     if ( pVCLXRadioButton && !pVCLXRadioButton->getState() )
         [ #  # ][ #  # ]
     188         [ #  # ]:          0 :         pVCLXRadioButton->setState( sal_True );
     189                 :            : 
     190         [ #  # ]:          0 :     return sal_True;
     191                 :            : }
     192                 :            : 
     193                 :            : // -----------------------------------------------------------------------------
     194                 :            : 
     195                 :          0 : ::rtl::OUString VCLXAccessibleRadioButton::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     196                 :            : {
     197         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     198                 :            : 
     199 [ #  # ][ #  # ]:          0 :     if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
         [ #  # ][ #  # ]
     200         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     201                 :            : 
     202 [ #  # ][ #  # ]:          0 :     return ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_CLICK ) );
     203                 :            : }
     204                 :            : 
     205                 :            : // -----------------------------------------------------------------------------
     206                 :            : 
     207                 :          0 : Reference< XAccessibleKeyBinding > VCLXAccessibleRadioButton::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     208                 :            : {
     209         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     210                 :            : 
     211 [ #  # ][ #  # ]:          0 :     if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
         [ #  # ][ #  # ]
     212         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     213                 :            : 
     214         [ #  # ]:          0 :     OAccessibleKeyBindingHelper* pKeyBindingHelper = new OAccessibleKeyBindingHelper();
     215 [ #  # ][ #  # ]:          0 :     Reference< XAccessibleKeyBinding > xKeyBinding = pKeyBindingHelper;
     216                 :            : 
     217         [ #  # ]:          0 :     Window* pWindow = GetWindow();
     218         [ #  # ]:          0 :     if ( pWindow )
     219                 :            :     {
     220         [ #  # ]:          0 :         KeyEvent aKeyEvent = pWindow->GetActivationKey();
     221                 :          0 :         KeyCode aKeyCode = aKeyEvent.GetKeyCode();
     222         [ #  # ]:          0 :         if ( aKeyCode.GetCode() != 0 )
     223                 :            :         {
     224                 :          0 :             awt::KeyStroke aKeyStroke;
     225                 :          0 :             aKeyStroke.Modifiers = 0;
     226         [ #  # ]:          0 :             if ( aKeyCode.IsShift() )
     227                 :          0 :                 aKeyStroke.Modifiers |= awt::KeyModifier::SHIFT;
     228         [ #  # ]:          0 :             if ( aKeyCode.IsMod1() )
     229                 :          0 :                 aKeyStroke.Modifiers |= awt::KeyModifier::MOD1;
     230         [ #  # ]:          0 :             if ( aKeyCode.IsMod2() )
     231                 :          0 :                 aKeyStroke.Modifiers |= awt::KeyModifier::MOD2;
     232         [ #  # ]:          0 :             if ( aKeyCode.IsMod3() )
     233                 :          0 :                 aKeyStroke.Modifiers |= awt::KeyModifier::MOD3;
     234                 :          0 :             aKeyStroke.KeyCode = aKeyCode.GetCode();
     235                 :          0 :             aKeyStroke.KeyChar = aKeyEvent.GetCharCode();
     236         [ #  # ]:          0 :             aKeyStroke.KeyFunc = static_cast< sal_Int16 >( aKeyCode.GetFunction() );
     237         [ #  # ]:          0 :             pKeyBindingHelper->AddKeyBinding( aKeyStroke );
     238                 :            :         }
     239                 :            :     }
     240                 :            : 
     241         [ #  # ]:          0 :     return xKeyBinding;
     242                 :            : }
     243                 :            : 
     244                 :            : // -----------------------------------------------------------------------------
     245                 :            : // XAccessibleValue
     246                 :            : // -----------------------------------------------------------------------------
     247                 :            : 
     248                 :          0 : Any VCLXAccessibleRadioButton::getCurrentValue(  ) throw (RuntimeException)
     249                 :            : {
     250         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     251                 :            : 
     252                 :          0 :     Any aValue;
     253                 :            : 
     254         [ #  # ]:          0 :     VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
     255         [ #  # ]:          0 :     if ( pVCLXRadioButton )
     256 [ #  # ][ #  # ]:          0 :         aValue <<= (sal_Int32) pVCLXRadioButton->getState();
     257                 :            : 
     258         [ #  # ]:          0 :     return aValue;
     259                 :            : }
     260                 :            : 
     261                 :            : // -----------------------------------------------------------------------------
     262                 :            : 
     263                 :          0 : sal_Bool VCLXAccessibleRadioButton::setCurrentValue( const Any& aNumber ) throw (RuntimeException)
     264                 :            : {
     265         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     266                 :            : 
     267                 :          0 :     sal_Bool bReturn = sal_False;
     268                 :            : 
     269         [ #  # ]:          0 :     VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
     270         [ #  # ]:          0 :     if ( pVCLXRadioButton )
     271                 :            :     {
     272                 :          0 :         sal_Int32 nValue = 0;
     273                 :          0 :         OSL_VERIFY( aNumber >>= nValue );
     274                 :            : 
     275         [ #  # ]:          0 :         if ( nValue < 0 )
     276                 :          0 :             nValue = 0;
     277         [ #  # ]:          0 :         else if ( nValue > 1 )
     278                 :          0 :             nValue = 1;
     279                 :            : 
     280         [ #  # ]:          0 :         pVCLXRadioButton->setState( (sal_Bool) nValue );
     281                 :          0 :         bReturn = sal_True;
     282                 :            :     }
     283                 :            : 
     284         [ #  # ]:          0 :     return bReturn;
     285                 :            : }
     286                 :            : 
     287                 :            : // -----------------------------------------------------------------------------
     288                 :            : 
     289                 :          0 : Any VCLXAccessibleRadioButton::getMaximumValue(  ) throw (RuntimeException)
     290                 :            : {
     291         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     292                 :            : 
     293                 :          0 :     Any aValue;
     294         [ #  # ]:          0 :     aValue <<= (sal_Int32) 1;
     295                 :            : 
     296         [ #  # ]:          0 :     return aValue;
     297                 :            : }
     298                 :            : 
     299                 :            : // -----------------------------------------------------------------------------
     300                 :            : 
     301                 :          0 : Any VCLXAccessibleRadioButton::getMinimumValue(  ) throw (RuntimeException)
     302                 :            : {
     303         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     304                 :            : 
     305                 :          0 :     Any aValue;
     306         [ #  # ]:          0 :     aValue <<= (sal_Int32) 0;
     307                 :            : 
     308         [ #  # ]:          0 :     return aValue;
     309                 :            : }
     310                 :            : 
     311                 :            : // -----------------------------------------------------------------------------
     312                 :            : 
     313                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10