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

Generated by: LCOV version 1.10