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

Generated by: LCOV version 1.10