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

Generated by: LCOV version 1.10