LCOV - code coverage report
Current view: top level - accessibility/source/extended - accessibletabbar.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 215 0.0 %
Date: 2014-04-11 Functions: 0 33 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/extended/accessibletabbar.hxx>
      21             : #include <svtools/tabbar.hxx>
      22             : #include <accessibility/extended/accessibletabbarpagelist.hxx>
      23             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      24             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      25             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      26             : #include <cppuhelper/supportsservice.hxx>
      27             : #include <unotools/accessiblestatesethelper.hxx>
      28             : #include <unotools/accessiblerelationsethelper.hxx>
      29             : #include <vcl/svapp.hxx>
      30             : #include <vcl/settings.hxx>
      31             : #include <toolkit/awt/vclxfont.hxx>
      32             : #include <toolkit/helper/convert.hxx>
      33             : 
      34             : #include <vector>
      35             : 
      36             : 
      37             : 
      38             : namespace accessibility
      39             : {
      40             : 
      41             : 
      42             :     using namespace ::com::sun::star;
      43             :     using namespace ::com::sun::star::uno;
      44             :     using namespace ::com::sun::star::lang;
      45             :     using namespace ::com::sun::star::accessibility;
      46             :     using namespace ::comphelper;
      47             : 
      48             : 
      49             :     //  class AccessibleTabBar
      50             : 
      51             : 
      52           0 :     AccessibleTabBar::AccessibleTabBar( TabBar* pTabBar )
      53           0 :         :AccessibleTabBarBase( pTabBar )
      54             :     {
      55           0 :         if ( m_pTabBar )
      56           0 :             m_aAccessibleChildren.assign( m_pTabBar->GetAccessibleChildWindowCount() + 1, Reference< XAccessible >() );
      57           0 :     }
      58             : 
      59             : 
      60             : 
      61           0 :     AccessibleTabBar::~AccessibleTabBar()
      62             :     {
      63           0 :     }
      64             : 
      65             : 
      66             : 
      67           0 :     void AccessibleTabBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
      68             :     {
      69           0 :         Any aOldValue, aNewValue;
      70             : 
      71           0 :         switch ( rVclWindowEvent.GetId() )
      72             :         {
      73             :             case VCLEVENT_WINDOW_ENABLED:
      74             :             {
      75           0 :                 aNewValue <<= AccessibleStateType::SENSITIVE;
      76           0 :                 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
      77           0 :                 aNewValue <<= AccessibleStateType::ENABLED;
      78           0 :                 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
      79             :             }
      80           0 :             break;
      81             :             case VCLEVENT_WINDOW_DISABLED:
      82             :             {
      83           0 :                 aOldValue <<= AccessibleStateType::ENABLED;
      84           0 :                 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
      85           0 :                 aOldValue <<= AccessibleStateType::SENSITIVE;
      86           0 :                 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
      87             :             }
      88           0 :             break;
      89             :             case VCLEVENT_WINDOW_GETFOCUS:
      90             :             {
      91           0 :                 aNewValue <<= AccessibleStateType::FOCUSED;
      92           0 :                 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
      93             :             }
      94           0 :             break;
      95             :             case VCLEVENT_WINDOW_LOSEFOCUS:
      96             :             {
      97           0 :                 aOldValue <<= AccessibleStateType::FOCUSED;
      98           0 :                 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
      99             :             }
     100           0 :             break;
     101             :             case VCLEVENT_WINDOW_SHOW:
     102             :             {
     103           0 :                 aNewValue <<= AccessibleStateType::SHOWING;
     104           0 :                 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     105             :             }
     106           0 :             break;
     107             :             case VCLEVENT_WINDOW_HIDE:
     108             :             {
     109           0 :                 aOldValue <<= AccessibleStateType::SHOWING;
     110           0 :                 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     111             :             }
     112           0 :             break;
     113             :             default:
     114             :             {
     115           0 :                 AccessibleTabBarBase::ProcessWindowEvent( rVclWindowEvent );
     116             :             }
     117           0 :             break;
     118           0 :         }
     119           0 :     }
     120             : 
     121             : 
     122             : 
     123           0 :     void AccessibleTabBar::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
     124             :     {
     125           0 :         if ( m_pTabBar )
     126             :         {
     127           0 :             if ( m_pTabBar->IsEnabled() )
     128             :             {
     129           0 :                 rStateSet.AddState( AccessibleStateType::ENABLED );
     130           0 :                 rStateSet.AddState( AccessibleStateType::SENSITIVE );
     131             :             }
     132             : 
     133           0 :             rStateSet.AddState( AccessibleStateType::FOCUSABLE );
     134             : 
     135           0 :             if ( m_pTabBar->HasFocus() )
     136           0 :                 rStateSet.AddState( AccessibleStateType::FOCUSED );
     137             : 
     138           0 :             rStateSet.AddState( AccessibleStateType::VISIBLE );
     139             : 
     140           0 :             if ( m_pTabBar->IsVisible() )
     141           0 :                 rStateSet.AddState( AccessibleStateType::SHOWING );
     142             : 
     143           0 :             if ( m_pTabBar->GetStyle() & WB_SIZEABLE )
     144           0 :                 rStateSet.AddState( AccessibleStateType::RESIZABLE );
     145             :         }
     146           0 :     }
     147             : 
     148             : 
     149             :     // OCommonAccessibleComponent
     150             : 
     151             : 
     152           0 :     awt::Rectangle AccessibleTabBar::implGetBounds() throw (RuntimeException)
     153             :     {
     154           0 :         awt::Rectangle aBounds;
     155           0 :         if ( m_pTabBar )
     156           0 :             aBounds = AWTRectangle( Rectangle( m_pTabBar->GetPosPixel(), m_pTabBar->GetSizePixel() ) );
     157             : 
     158           0 :         return aBounds;
     159             :     }
     160             : 
     161             : 
     162             :     // XInterface
     163             : 
     164             : 
     165           0 :     IMPLEMENT_FORWARD_XINTERFACE2( AccessibleTabBar, AccessibleExtendedComponentHelper_BASE, AccessibleTabBar_BASE )
     166             : 
     167             : 
     168             :     // XTypeProvider
     169             : 
     170             : 
     171           0 :     IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleTabBar, AccessibleExtendedComponentHelper_BASE, AccessibleTabBar_BASE )
     172             : 
     173             : 
     174             :     // XComponent
     175             : 
     176             : 
     177           0 :     void AccessibleTabBar::disposing()
     178             :     {
     179           0 :         AccessibleTabBarBase::disposing();
     180             : 
     181             :         // dispose all children
     182           0 :         for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
     183             :         {
     184           0 :             Reference< XComponent > xComponent( m_aAccessibleChildren[i], UNO_QUERY );
     185           0 :             if ( xComponent.is() )
     186           0 :                 xComponent->dispose();
     187           0 :         }
     188           0 :         m_aAccessibleChildren.clear();
     189           0 :     }
     190             : 
     191             : 
     192             :     // XServiceInfo
     193             : 
     194             : 
     195           0 :     OUString AccessibleTabBar::getImplementationName() throw (RuntimeException, std::exception)
     196             :     {
     197           0 :         return OUString( "com.sun.star.comp.svtools.AccessibleTabBar" );
     198             :     }
     199             : 
     200             : 
     201             : 
     202           0 :     sal_Bool AccessibleTabBar::supportsService( const OUString& rServiceName ) throw (RuntimeException, std::exception)
     203             :     {
     204           0 :         return cppu::supportsService(this, rServiceName);
     205             :     }
     206             : 
     207             : 
     208             : 
     209           0 :     Sequence< OUString > AccessibleTabBar::getSupportedServiceNames() throw (RuntimeException, std::exception)
     210             :     {
     211           0 :         Sequence< OUString > aNames(1);
     212           0 :         aNames[0] = "com.sun.star.awt.AccessibleTabBar";
     213           0 :         return aNames;
     214             :     }
     215             : 
     216             : 
     217             :     // XAccessible
     218             : 
     219             : 
     220           0 :     Reference< XAccessibleContext > AccessibleTabBar::getAccessibleContext(  ) throw (RuntimeException, std::exception)
     221             :     {
     222           0 :         OExternalLockGuard aGuard( this );
     223             : 
     224           0 :         return this;
     225             :     }
     226             : 
     227             : 
     228             :     // XAccessibleContext
     229             : 
     230             : 
     231           0 :     sal_Int32 AccessibleTabBar::getAccessibleChildCount() throw (RuntimeException, std::exception)
     232             :     {
     233           0 :         OExternalLockGuard aGuard( this );
     234             : 
     235           0 :         return m_aAccessibleChildren.size();
     236             :     }
     237             : 
     238             : 
     239             : 
     240           0 :     Reference< XAccessible > AccessibleTabBar::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     241             :     {
     242           0 :         OExternalLockGuard aGuard( this );
     243             : 
     244           0 :         if ( i < 0 || i >= getAccessibleChildCount() )
     245           0 :             throw IndexOutOfBoundsException();
     246             : 
     247           0 :         Reference< XAccessible > xChild = m_aAccessibleChildren[i];
     248           0 :         if ( !xChild.is() )
     249             :         {
     250           0 :             if ( m_pTabBar )
     251             :             {
     252           0 :                 sal_Int32 nCount = m_pTabBar->GetAccessibleChildWindowCount();
     253             : 
     254           0 :                 if ( i < nCount )
     255             :                 {
     256           0 :                     Window* pChild = m_pTabBar->GetAccessibleChildWindow( (sal_uInt16)i );
     257           0 :                     if ( pChild )
     258           0 :                         xChild = pChild->GetAccessible();
     259             :                 }
     260           0 :                 else if ( i == nCount )
     261             :                 {
     262           0 :                     xChild = new AccessibleTabBarPageList( m_pTabBar, i );
     263             :                 }
     264             : 
     265             :                 // insert into child list
     266           0 :                 m_aAccessibleChildren[i] = xChild;
     267             :             }
     268             :         }
     269             : 
     270           0 :         return xChild;
     271             :     }
     272             : 
     273             : 
     274             : 
     275           0 :     Reference< XAccessible > AccessibleTabBar::getAccessibleParent(  ) throw (RuntimeException, std::exception)
     276             :     {
     277           0 :         OExternalLockGuard aGuard( this );
     278             : 
     279           0 :         Reference< XAccessible > xParent;
     280           0 :         if ( m_pTabBar )
     281             :         {
     282           0 :             Window* pParent = m_pTabBar->GetAccessibleParentWindow();
     283           0 :             if ( pParent )
     284           0 :                 xParent = pParent->GetAccessible();
     285             :         }
     286             : 
     287           0 :         return xParent;
     288             :     }
     289             : 
     290             : 
     291             : 
     292           0 :     sal_Int32 AccessibleTabBar::getAccessibleIndexInParent(  ) throw (RuntimeException, std::exception)
     293             :     {
     294           0 :         OExternalLockGuard aGuard( this );
     295             : 
     296           0 :         sal_Int32 nIndexInParent = -1;
     297           0 :         if ( m_pTabBar )
     298             :         {
     299           0 :             Window* pParent = m_pTabBar->GetAccessibleParentWindow();
     300           0 :             if ( pParent )
     301             :             {
     302           0 :                 for ( sal_uInt16 i = 0, nCount = pParent->GetAccessibleChildWindowCount(); i < nCount; ++i )
     303             :                 {
     304           0 :                     Window* pChild = pParent->GetAccessibleChildWindow( i );
     305           0 :                     if ( pChild == static_cast< Window* >( m_pTabBar ) )
     306             :                     {
     307           0 :                         nIndexInParent = i;
     308           0 :                         break;
     309             :                     }
     310             :                 }
     311             :             }
     312             :         }
     313             : 
     314           0 :         return nIndexInParent;
     315             :     }
     316             : 
     317             : 
     318             : 
     319           0 :     sal_Int16 AccessibleTabBar::getAccessibleRole(  ) throw (RuntimeException, std::exception)
     320             :     {
     321           0 :         OExternalLockGuard aGuard( this );
     322             : 
     323           0 :         return AccessibleRole::PANEL;
     324             :     }
     325             : 
     326             : 
     327             : 
     328           0 :     OUString AccessibleTabBar::getAccessibleDescription( ) throw (RuntimeException, std::exception)
     329             :     {
     330           0 :         OExternalLockGuard aGuard( this );
     331             : 
     332           0 :         OUString sDescription;
     333           0 :         if ( m_pTabBar )
     334           0 :             sDescription = m_pTabBar->GetAccessibleDescription();
     335             : 
     336           0 :         return sDescription;
     337             :     }
     338             : 
     339             : 
     340             : 
     341           0 :     OUString AccessibleTabBar::getAccessibleName(  ) throw (RuntimeException, std::exception)
     342             :     {
     343           0 :         OExternalLockGuard aGuard( this );
     344             : 
     345           0 :         OUString sName;
     346           0 :         if ( m_pTabBar )
     347           0 :             sName = m_pTabBar->GetAccessibleName();
     348             : 
     349           0 :         return sName;
     350             :     }
     351             : 
     352             : 
     353             : 
     354           0 :     Reference< XAccessibleRelationSet > AccessibleTabBar::getAccessibleRelationSet(  ) throw (RuntimeException, std::exception)
     355             :     {
     356           0 :         OExternalLockGuard aGuard( this );
     357             : 
     358           0 :         utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
     359           0 :         Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
     360           0 :         return xSet;
     361             :     }
     362             : 
     363             : 
     364             : 
     365           0 :     Reference< XAccessibleStateSet > AccessibleTabBar::getAccessibleStateSet(  ) throw (RuntimeException, std::exception)
     366             :     {
     367           0 :         OExternalLockGuard aGuard( this );
     368             : 
     369           0 :         utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
     370           0 :         Reference< XAccessibleStateSet > xSet = pStateSetHelper;
     371             : 
     372           0 :         if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
     373             :         {
     374           0 :             FillAccessibleStateSet( *pStateSetHelper );
     375             :         }
     376             :         else
     377             :         {
     378           0 :             pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
     379             :         }
     380             : 
     381           0 :         return xSet;
     382             :     }
     383             : 
     384             : 
     385             : 
     386           0 :     Locale AccessibleTabBar::getLocale(  ) throw (IllegalAccessibleComponentStateException, RuntimeException, std::exception)
     387             :     {
     388           0 :         OExternalLockGuard aGuard( this );
     389             : 
     390           0 :         return Application::GetSettings().GetLanguageTag().getLocale();
     391             :     }
     392             : 
     393             : 
     394             :     // XAccessibleComponent
     395             : 
     396             : 
     397           0 :     Reference< XAccessible > AccessibleTabBar::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException, std::exception)
     398             :     {
     399           0 :         OExternalLockGuard aGuard( this );
     400             : 
     401           0 :         Reference< XAccessible > xChild;
     402           0 :         for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
     403             :         {
     404           0 :             Reference< XAccessible > xAcc = getAccessibleChild( i );
     405           0 :             if ( xAcc.is() )
     406             :             {
     407           0 :                 Reference< XAccessibleComponent > xComp( xAcc->getAccessibleContext(), UNO_QUERY );
     408           0 :                 if ( xComp.is() )
     409             :                 {
     410           0 :                     Rectangle aRect = VCLRectangle( xComp->getBounds() );
     411           0 :                     Point aPos = VCLPoint( rPoint );
     412           0 :                     if ( aRect.IsInside( aPos ) )
     413             :                     {
     414           0 :                         xChild = xAcc;
     415           0 :                         break;
     416             :                     }
     417           0 :                 }
     418             :             }
     419           0 :         }
     420             : 
     421           0 :         return xChild;
     422             :     }
     423             : 
     424             : 
     425             : 
     426           0 :     void AccessibleTabBar::grabFocus(  ) throw (RuntimeException, std::exception)
     427             :     {
     428           0 :         OExternalLockGuard aGuard( this );
     429             : 
     430           0 :         if ( m_pTabBar )
     431           0 :             m_pTabBar->GrabFocus();
     432           0 :     }
     433             : 
     434             : 
     435             : 
     436           0 :     sal_Int32 AccessibleTabBar::getForeground(  ) throw (RuntimeException, std::exception)
     437             :     {
     438           0 :         OExternalLockGuard aGuard( this );
     439             : 
     440           0 :         sal_Int32 nColor = 0;
     441           0 :         if ( m_pTabBar )
     442             :         {
     443           0 :             if ( m_pTabBar->IsControlForeground() )
     444           0 :                 nColor = m_pTabBar->GetControlForeground().GetColor();
     445             :             else
     446             :             {
     447           0 :                 Font aFont;
     448           0 :                 if ( m_pTabBar->IsControlFont() )
     449           0 :                     aFont = m_pTabBar->GetControlFont();
     450             :                 else
     451           0 :                     aFont = m_pTabBar->GetFont();
     452           0 :                 nColor = aFont.GetColor().GetColor();
     453             :             }
     454             :         }
     455             : 
     456           0 :         return nColor;
     457             :     }
     458             : 
     459             : 
     460             : 
     461           0 :     sal_Int32 AccessibleTabBar::getBackground(  ) throw (RuntimeException, std::exception)
     462             :     {
     463           0 :         OExternalLockGuard aGuard( this );
     464             : 
     465           0 :         sal_Int32 nColor = 0;
     466           0 :         if ( m_pTabBar )
     467             :         {
     468           0 :             if ( m_pTabBar->IsControlBackground() )
     469           0 :                 nColor = m_pTabBar->GetControlBackground().GetColor();
     470             :             else
     471           0 :                 nColor = m_pTabBar->GetBackground().GetColor().GetColor();
     472             :         }
     473             : 
     474           0 :         return nColor;
     475             :     }
     476             : 
     477             : 
     478             :     // XAccessibleExtendedComponent
     479             : 
     480             : 
     481           0 :     Reference< awt::XFont > AccessibleTabBar::getFont(  ) throw (RuntimeException, std::exception)
     482             :     {
     483           0 :         OExternalLockGuard aGuard( this );
     484             : 
     485           0 :         Reference< awt::XFont > xFont;
     486           0 :         if ( m_pTabBar )
     487             :         {
     488           0 :             Reference< awt::XDevice > xDev( m_pTabBar->GetComponentInterface(), UNO_QUERY );
     489           0 :             if ( xDev.is() )
     490             :             {
     491           0 :                 Font aFont;
     492           0 :                 if ( m_pTabBar->IsControlFont() )
     493           0 :                     aFont = m_pTabBar->GetControlFont();
     494             :                 else
     495           0 :                     aFont = m_pTabBar->GetFont();
     496           0 :                 VCLXFont* pVCLXFont = new VCLXFont;
     497           0 :                 pVCLXFont->Init( *xDev.get(), aFont );
     498           0 :                 xFont = pVCLXFont;
     499           0 :             }
     500             :         }
     501             : 
     502           0 :         return xFont;
     503             :     }
     504             : 
     505             : 
     506             : 
     507           0 :     OUString AccessibleTabBar::getTitledBorderText(  ) throw (RuntimeException, std::exception)
     508             :     {
     509           0 :         OExternalLockGuard aGuard( this );
     510             : 
     511           0 :         OUString sText;
     512           0 :         if ( m_pTabBar )
     513           0 :             sText = m_pTabBar->GetText();
     514             : 
     515           0 :         return sText;
     516             :     }
     517             : 
     518             : 
     519             : 
     520           0 :     OUString AccessibleTabBar::getToolTipText(  ) throw (RuntimeException, std::exception)
     521             :     {
     522           0 :         OExternalLockGuard aGuard( this );
     523             : 
     524           0 :         OUString sText;
     525           0 :         if ( m_pTabBar )
     526           0 :             sText = m_pTabBar->GetQuickHelpText();
     527             : 
     528           0 :         return sText;
     529             :     }
     530             : 
     531             : 
     532             : 
     533             : 
     534             : }   // namespace accessibility
     535             : 
     536             : 
     537             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10