LCOV - code coverage report
Current view: top level - accessibility/source/standard - vclxaccessiblemenu.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 25 79 31.6 %
Date: 2012-08-25 Functions: 12 23 52.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 19 158 12.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/vclxaccessiblemenu.hxx>
      30                 :            : 
      31                 :            : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      32                 :            : #include <vcl/menu.hxx>
      33                 :            : 
      34                 :            : 
      35                 :            : using namespace ::com::sun::star;
      36                 :            : using namespace ::com::sun::star::lang;
      37                 :            : using namespace ::com::sun::star::uno;
      38                 :            : using namespace ::com::sun::star::accessibility;
      39                 :            : using namespace ::comphelper;
      40                 :            : 
      41                 :            : 
      42                 :            : // -----------------------------------------------------------------------------
      43                 :            : // VCLXAccessibleMenu
      44                 :            : // -----------------------------------------------------------------------------
      45                 :            : 
      46                 :        516 : VCLXAccessibleMenu::VCLXAccessibleMenu( Menu* pParent, sal_uInt16 nItemPos, Menu* pMenu )
      47                 :        516 :     :VCLXAccessibleMenuItem( pParent, nItemPos, pMenu )
      48                 :            : {
      49                 :        516 : }
      50                 :            : 
      51                 :            : // -----------------------------------------------------------------------------
      52                 :            : 
      53                 :        516 : VCLXAccessibleMenu::~VCLXAccessibleMenu()
      54                 :            : {
      55         [ -  + ]:       1032 : }
      56                 :            : 
      57                 :            : // -----------------------------------------------------------------------------
      58                 :            : 
      59                 :       1100 : sal_Bool VCLXAccessibleMenu::IsFocused()
      60                 :            : {
      61                 :       1100 :     sal_Bool bFocused = sal_False;
      62                 :            : 
      63 [ -  + ][ #  # ]:       1100 :     if ( IsHighlighted() && !IsChildHighlighted() )
                 [ -  + ]
      64                 :          0 :         bFocused = sal_True;
      65                 :            : 
      66                 :       1100 :     return bFocused;
      67                 :            : }
      68                 :            : 
      69                 :            : // -----------------------------------------------------------------------------
      70                 :            : 
      71                 :          0 : sal_Bool VCLXAccessibleMenu::IsPopupMenuOpen()
      72                 :            : {
      73                 :          0 :     sal_Bool bPopupMenuOpen = sal_False;
      74                 :            : 
      75         [ #  # ]:          0 :     if ( m_pParent )
      76                 :            :     {
      77                 :          0 :         PopupMenu* pPopupMenu = m_pParent->GetPopupMenu( m_pParent->GetItemId( m_nItemPos ) );
      78 [ #  # ][ #  # ]:          0 :         if ( pPopupMenu && pPopupMenu->IsMenuVisible() )
                 [ #  # ]
      79                 :          0 :             bPopupMenuOpen = sal_True;
      80                 :            :     }
      81                 :            : 
      82                 :          0 :     return bPopupMenuOpen;
      83                 :            : }
      84                 :            : 
      85                 :            : // -----------------------------------------------------------------------------
      86                 :            : // XInterface
      87                 :            : // -----------------------------------------------------------------------------
      88                 :            : 
      89 [ -  + ][ #  # ]:      34612 : IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleMenu, VCLXAccessibleMenuItem, VCLXAccessibleMenu_BASE )
      90                 :            : 
      91                 :            : // -----------------------------------------------------------------------------
      92                 :            : // XTypeProvider
      93                 :            : // -----------------------------------------------------------------------------
      94                 :            : 
      95 [ #  # ][ #  # ]:          0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleMenu, VCLXAccessibleMenuItem, VCLXAccessibleMenu_BASE )
                 [ #  # ]
      96                 :            : 
      97                 :            : // -----------------------------------------------------------------------------
      98                 :            : // XServiceInfo
      99                 :            : // -----------------------------------------------------------------------------
     100                 :            : 
     101                 :         26 : ::rtl::OUString VCLXAccessibleMenu::getImplementationName() throw (RuntimeException)
     102                 :            : {
     103                 :         26 :     return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.toolkit.AccessibleMenu") );
     104                 :            : }
     105                 :            : 
     106                 :            : // -----------------------------------------------------------------------------
     107                 :            : 
     108                 :          0 : Sequence< ::rtl::OUString > VCLXAccessibleMenu::getSupportedServiceNames() throw (RuntimeException)
     109                 :            : {
     110                 :          0 :     Sequence< ::rtl::OUString > aNames(1);
     111 [ #  # ][ #  # ]:          0 :     aNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.AccessibleMenu") );
     112                 :          0 :     return aNames;
     113                 :            : }
     114                 :            : 
     115                 :            : // -----------------------------------------------------------------------------
     116                 :            : // XAccessibleContext
     117                 :            : // -----------------------------------------------------------------------------
     118                 :            : 
     119                 :       1416 : sal_Int32 VCLXAccessibleMenu::getAccessibleChildCount(  ) throw (RuntimeException)
     120                 :            : {
     121         [ +  - ]:       1416 :     OExternalLockGuard aGuard( this );
     122                 :            : 
     123 [ +  - ][ +  - ]:       1416 :     return GetChildCount();
     124                 :            : }
     125                 :            : 
     126                 :            : // -----------------------------------------------------------------------------
     127                 :            : 
     128                 :       5508 : Reference< XAccessible > VCLXAccessibleMenu::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
     129                 :            : {
     130         [ +  - ]:       5508 :     OExternalLockGuard aGuard( this );
     131                 :            : 
     132 [ +  - ][ +  - ]:       5508 :     if ( i < 0 || i >= GetChildCount() )
         [ -  + ][ -  + ]
     133         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     134                 :            : 
     135 [ +  - ][ +  - ]:       5508 :     return GetChild( i );
     136                 :            : }
     137                 :            : 
     138                 :            : // -----------------------------------------------------------------------------
     139                 :            : 
     140                 :        784 : sal_Int16 VCLXAccessibleMenu::getAccessibleRole(  ) throw (RuntimeException)
     141                 :            : {
     142         [ +  - ]:        784 :     OExternalLockGuard aGuard( this );
     143                 :            : 
     144         [ +  - ]:        784 :     return AccessibleRole::MENU;
     145                 :            : }
     146                 :            : 
     147                 :            : // -----------------------------------------------------------------------------
     148                 :            : // XAccessibleComponent
     149                 :            : // -----------------------------------------------------------------------------
     150                 :            : 
     151                 :         80 : Reference< XAccessible > VCLXAccessibleMenu::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException)
     152                 :            : {
     153         [ +  - ]:         80 :     OExternalLockGuard aGuard( this );
     154                 :            : 
     155 [ +  - ][ +  - ]:         80 :     return GetChildAt( rPoint );
     156                 :            : }
     157                 :            : 
     158                 :            : // -----------------------------------------------------------------------------
     159                 :            : // XAccessibleSelection
     160                 :            : // -----------------------------------------------------------------------------
     161                 :            : 
     162                 :          0 : void VCLXAccessibleMenu::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     163                 :            : {
     164         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     165                 :            : 
     166 [ #  # ][ #  # ]:          0 :     if ( nChildIndex < 0 || nChildIndex >= GetChildCount() )
         [ #  # ][ #  # ]
     167         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     168                 :            : 
     169 [ #  # ][ #  # ]:          0 :     SelectChild( nChildIndex );
     170                 :          0 : }
     171                 :            : 
     172                 :            : // -----------------------------------------------------------------------------
     173                 :            : 
     174                 :          0 : sal_Bool VCLXAccessibleMenu::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     175                 :            : {
     176         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     177                 :            : 
     178 [ #  # ][ #  # ]:          0 :     if ( nChildIndex < 0 || nChildIndex >= GetChildCount() )
         [ #  # ][ #  # ]
     179         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     180                 :            : 
     181 [ #  # ][ #  # ]:          0 :     return IsChildSelected( nChildIndex );
     182                 :            : }
     183                 :            : 
     184                 :            : // -----------------------------------------------------------------------------
     185                 :            : 
     186                 :          0 : void VCLXAccessibleMenu::clearAccessibleSelection(  ) throw (RuntimeException)
     187                 :            : {
     188         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     189                 :            : 
     190 [ #  # ][ #  # ]:          0 :     DeSelectAll();
     191                 :          0 : }
     192                 :            : 
     193                 :            : // -----------------------------------------------------------------------------
     194                 :            : 
     195                 :          0 : void VCLXAccessibleMenu::selectAllAccessibleChildren(  ) throw (RuntimeException)
     196                 :            : {
     197                 :            :     // This method makes no sense in a menu, and so does nothing.
     198                 :          0 : }
     199                 :            : 
     200                 :            : // -----------------------------------------------------------------------------
     201                 :            : 
     202                 :          0 : sal_Int32 VCLXAccessibleMenu::getSelectedAccessibleChildCount(  ) throw (RuntimeException)
     203                 :            : {
     204         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     205                 :            : 
     206                 :          0 :     sal_Int32 nRet = 0;
     207                 :            : 
     208 [ #  # ][ #  # ]:          0 :     for ( sal_Int32 i = 0, nCount = GetChildCount(); i < nCount; i++ )
     209                 :            :     {
     210 [ #  # ][ #  # ]:          0 :         if ( IsChildSelected( i ) )
     211                 :          0 :             ++nRet;
     212                 :            :     }
     213                 :            : 
     214         [ #  # ]:          0 :     return nRet;
     215                 :            : }
     216                 :            : 
     217                 :            : // -----------------------------------------------------------------------------
     218                 :            : 
     219                 :          0 : Reference< XAccessible > VCLXAccessibleMenu::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     220                 :            : {
     221         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     222                 :            : 
     223 [ #  # ][ #  # ]:          0 :     if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
         [ #  # ][ #  # ]
     224         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     225                 :            : 
     226                 :          0 :     Reference< XAccessible > xChild;
     227                 :            : 
     228 [ #  # ][ #  # ]:          0 :     for ( sal_Int32 i = 0, j = 0, nCount = GetChildCount(); i < nCount; i++ )
     229                 :            :     {
     230 [ #  # ][ #  # ]:          0 :         if ( IsChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
         [ #  # ][ #  # ]
     231                 :            :         {
     232 [ #  # ][ #  # ]:          0 :             xChild = GetChild( i );
     233                 :          0 :             break;
     234                 :            :         }
     235                 :            :     }
     236                 :            : 
     237         [ #  # ]:          0 :     return xChild;
     238                 :            : }
     239                 :            : 
     240                 :            : // -----------------------------------------------------------------------------
     241                 :            : 
     242                 :          0 : void VCLXAccessibleMenu::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     243                 :            : {
     244         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     245                 :            : 
     246 [ #  # ][ #  # ]:          0 :     if ( nChildIndex < 0 || nChildIndex >= GetChildCount() )
         [ #  # ][ #  # ]
     247         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     248                 :            : 
     249 [ #  # ][ #  # ]:          0 :     DeSelectAll();
     250                 :          0 : }
     251                 :            : 
     252                 :            : // -----------------------------------------------------------------------------
     253                 :            : 
     254                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10