LCOV - code coverage report
Current view: top level - accessibility/source/standard - vclxaccessiblemenubar.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 55 63 87.3 %
Date: 2012-08-25 Functions: 12 13 92.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 36 81 44.4 %

           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/vclxaccessiblemenubar.hxx>
      30                 :            : 
      31                 :            : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      32                 :            : #include <vcl/svapp.hxx>
      33                 :            : #include <vcl/window.hxx>
      34                 :            : #include <vcl/menu.hxx>
      35                 :            : 
      36                 :            : 
      37                 :            : using namespace ::com::sun::star::accessibility;
      38                 :            : using namespace ::com::sun::star::uno;
      39                 :            : using namespace ::com::sun::star;
      40                 :            : using namespace ::comphelper;
      41                 :            : 
      42                 :            : 
      43                 :            : // -----------------------------------------------------------------------------
      44                 :            : // class VCLXAccessibleMenuBar
      45                 :            : // -----------------------------------------------------------------------------
      46                 :            : 
      47                 :         49 : VCLXAccessibleMenuBar::VCLXAccessibleMenuBar( Menu* pMenu )
      48                 :         49 :     :OAccessibleMenuComponent( pMenu )
      49                 :            : {
      50         [ +  - ]:         49 :     if ( pMenu )
      51                 :            :     {
      52                 :         49 :         m_pWindow = pMenu->GetWindow();
      53                 :            : 
      54         [ +  - ]:         49 :         if ( m_pWindow )
      55 [ +  - ][ +  - ]:         49 :             m_pWindow->AddEventListener( LINK( this, VCLXAccessibleMenuBar, WindowEventListener ) );
      56                 :            :     }
      57                 :         49 : }
      58                 :            : 
      59                 :            : // -----------------------------------------------------------------------------
      60                 :            : 
      61                 :         49 : VCLXAccessibleMenuBar::~VCLXAccessibleMenuBar()
      62                 :            : {
      63         [ -  + ]:         49 :     if ( m_pWindow )
      64 [ #  # ][ #  # ]:          0 :         m_pWindow->RemoveEventListener( LINK( this, VCLXAccessibleMenuBar, WindowEventListener ) );
      65         [ -  + ]:         98 : }
      66                 :            : 
      67                 :            : // -----------------------------------------------------------------------------
      68                 :            : 
      69                 :         71 : sal_Bool VCLXAccessibleMenuBar::IsFocused()
      70                 :            : {
      71                 :         71 :     sal_Bool bFocused = sal_False;
      72                 :            : 
      73 [ +  - ][ -  + ]:         71 :     if ( m_pWindow && m_pWindow->HasFocus() && !IsChildHighlighted() )
         [ #  # ][ -  + ]
      74                 :          0 :         bFocused = sal_True;
      75                 :            : 
      76                 :         71 :     return bFocused;
      77                 :            : }
      78                 :            : 
      79                 :            : // -----------------------------------------------------------------------------
      80                 :            : 
      81                 :        194 : IMPL_LINK( VCLXAccessibleMenuBar, WindowEventListener, VclSimpleEvent*, pEvent )
      82                 :            : {
      83                 :            :     OSL_ENSURE( pEvent && pEvent->ISA( VclWindowEvent ), "VCLXAccessibleMenuBar::WindowEventListener: unknown window event!" );
      84 [ +  - ][ +  - ]:        194 :     if ( pEvent && pEvent->ISA( VclWindowEvent ) )
                 [ +  - ]
      85                 :            :     {
      86                 :            :         OSL_ENSURE( ((VclWindowEvent*)pEvent)->GetWindow(), "VCLXAccessibleMenuBar::WindowEventListener: no window!" );
      87 [ -  + ][ #  # ]:        194 :         if ( !((VclWindowEvent*)pEvent)->GetWindow()->IsAccessibilityEventsSuppressed() || ( pEvent->GetId() == VCLEVENT_OBJECT_DYING ) )
                 [ +  - ]
      88                 :            :         {
      89                 :        194 :             ProcessWindowEvent( *(VclWindowEvent*)pEvent );
      90                 :            :         }
      91                 :            :     }
      92                 :        194 :     return 0;
      93                 :            : }
      94                 :            : 
      95                 :            : // -----------------------------------------------------------------------------
      96                 :            : 
      97                 :        194 : void VCLXAccessibleMenuBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
      98                 :            : {
      99      [ +  +  + ]:        194 :     switch ( rVclWindowEvent.GetId() )
     100                 :            :     {
     101                 :            :         case VCLEVENT_WINDOW_GETFOCUS:
     102                 :            :         case VCLEVENT_WINDOW_LOSEFOCUS:
     103                 :            :         {
     104                 :         32 :             SetFocused( rVclWindowEvent.GetId() == VCLEVENT_WINDOW_GETFOCUS );
     105                 :            :         }
     106                 :         32 :         break;
     107                 :            :         case VCLEVENT_OBJECT_DYING:
     108                 :            :         {
     109         [ +  - ]:         49 :             if ( m_pWindow )
     110                 :            :             {
     111         [ +  - ]:         49 :                 m_pWindow->RemoveEventListener( LINK( this, VCLXAccessibleMenuBar, WindowEventListener ) );
     112                 :         49 :                 m_pWindow = NULL;
     113                 :            :             }
     114                 :            :         }
     115                 :         49 :         break;
     116                 :            :         default:
     117                 :            :         {
     118                 :            :         }
     119                 :        113 :         break;
     120                 :            :     }
     121                 :        194 : }
     122                 :            : 
     123                 :            : // -----------------------------------------------------------------------------
     124                 :            : // XComponent
     125                 :            : // -----------------------------------------------------------------------------
     126                 :            : 
     127                 :         49 : void VCLXAccessibleMenuBar::disposing()
     128                 :            : {
     129                 :         49 :     OAccessibleMenuComponent::disposing();
     130                 :            : 
     131         [ -  + ]:         49 :     if ( m_pWindow )
     132                 :            :     {
     133         [ #  # ]:          0 :         m_pWindow->RemoveEventListener( LINK( this, VCLXAccessibleMenuBar, WindowEventListener ) );
     134                 :          0 :         m_pWindow = NULL;
     135                 :            :     }
     136                 :         49 : }
     137                 :            : 
     138                 :            : // -----------------------------------------------------------------------------
     139                 :            : // XServiceInfo
     140                 :            : // -----------------------------------------------------------------------------
     141                 :            : 
     142                 :          2 : ::rtl::OUString VCLXAccessibleMenuBar::getImplementationName() throw (RuntimeException)
     143                 :            : {
     144                 :          2 :     return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.toolkit.AccessibleMenuBar") );
     145                 :            : }
     146                 :            : 
     147                 :            : // -----------------------------------------------------------------------------
     148                 :            : 
     149                 :          0 : Sequence< ::rtl::OUString > VCLXAccessibleMenuBar::getSupportedServiceNames() throw (RuntimeException)
     150                 :            : {
     151                 :          0 :     Sequence< ::rtl::OUString > aNames(1);
     152 [ #  # ][ #  # ]:          0 :     aNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.AccessibleMenuBar") );
     153                 :          0 :     return aNames;
     154                 :            : }
     155                 :            : 
     156                 :            : // -----------------------------------------------------------------------------
     157                 :            : // XAccessibleContext
     158                 :            : // -----------------------------------------------------------------------------
     159                 :            : 
     160                 :          2 : sal_Int32 VCLXAccessibleMenuBar::getAccessibleIndexInParent(  ) throw (RuntimeException)
     161                 :            : {
     162         [ +  - ]:          2 :     OExternalLockGuard aGuard( this );
     163                 :            : 
     164                 :          2 :     sal_Int32 nIndexInParent = -1;
     165                 :            : 
     166         [ +  - ]:          2 :     if ( m_pMenu )
     167                 :            :     {
     168                 :          2 :         Window* pWindow = m_pMenu->GetWindow();
     169         [ +  - ]:          2 :         if ( pWindow )
     170                 :            :         {
     171         [ +  - ]:          2 :             Window* pParent = pWindow->GetAccessibleParentWindow();
     172         [ +  - ]:          2 :             if ( pParent )
     173                 :            :             {
     174 [ +  - ][ +  - ]:         16 :                 for ( sal_uInt16 n = pParent->GetAccessibleChildWindowCount(); n; )
     175                 :            :                 {
     176         [ +  - ]:         14 :                     Window* pChild = pParent->GetAccessibleChildWindow( --n );
     177         [ +  + ]:         14 :                     if ( pChild == pWindow )
     178                 :            :                     {
     179                 :          2 :                         nIndexInParent = n;
     180                 :          2 :                         break;
     181                 :            :                     }
     182                 :            :                 }
     183                 :            :             }
     184                 :            :         }
     185                 :            :     }
     186                 :            : 
     187         [ +  - ]:          2 :     return nIndexInParent;
     188                 :            : }
     189                 :            : 
     190                 :            : // -----------------------------------------------------------------------------
     191                 :            : 
     192                 :        254 : sal_Int16 VCLXAccessibleMenuBar::getAccessibleRole(  ) throw (RuntimeException)
     193                 :            : {
     194         [ +  - ]:        254 :     OExternalLockGuard aGuard( this );
     195                 :            : 
     196         [ +  - ]:        254 :     return AccessibleRole::MENU_BAR;
     197                 :            : }
     198                 :            : 
     199                 :            : // -----------------------------------------------------------------------------
     200                 :            : // XAccessibleExtendedComponent
     201                 :            : // -----------------------------------------------------------------------------
     202                 :            : 
     203                 :          2 : sal_Int32 VCLXAccessibleMenuBar::getBackground(  ) throw (RuntimeException)
     204                 :            : {
     205         [ +  - ]:          2 :     OExternalLockGuard aGuard( this );
     206                 :            : 
     207 [ +  - ][ +  - ]:          2 :     return Application::GetSettings().GetStyleSettings().GetMenuBarColor().GetColor();
     208                 :            : }
     209                 :            : 
     210                 :            : // -----------------------------------------------------------------------------
     211                 :            : 
     212                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10