LCOV - code coverage report
Current view: top level - accessibility/source/extended - accessibletabbarpage.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 189 0.0 %
Date: 2014-04-11 Functions: 0 39 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/accessibletabbarpage.hxx>
      21             : #include <svtools/tabbar.hxx>
      22             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      23             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      24             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      25             : #include <cppuhelper/supportsservice.hxx>
      26             : #include <unotools/accessiblestatesethelper.hxx>
      27             : #include <unotools/accessiblerelationsethelper.hxx>
      28             : #include <vcl/svapp.hxx>
      29             : #include <vcl/settings.hxx>
      30             : #include <toolkit/helper/convert.hxx>
      31             : 
      32             : 
      33             : 
      34             : namespace accessibility
      35             : {
      36             : 
      37             : 
      38             :     using namespace ::com::sun::star::accessibility;
      39             :     using namespace ::com::sun::star::uno;
      40             :     using namespace ::com::sun::star::lang;
      41             :     using namespace ::com::sun::star;
      42             :     using namespace ::comphelper;
      43             : 
      44             : 
      45             :     // class AccessibleTabBarPage
      46             : 
      47             : 
      48           0 :     AccessibleTabBarPage::AccessibleTabBarPage( TabBar* pTabBar, sal_uInt16 nPageId, const Reference< XAccessible >& rxParent )
      49             :         :AccessibleTabBarBase( pTabBar )
      50             :         ,m_nPageId( nPageId )
      51           0 :         ,m_xParent( rxParent )
      52             :     {
      53           0 :         m_bEnabled  = IsEnabled();
      54           0 :         m_bShowing  = IsShowing();
      55           0 :         m_bSelected = IsSelected();
      56             : 
      57           0 :         if ( m_pTabBar )
      58           0 :             m_sPageText = m_pTabBar->GetPageText( m_nPageId );
      59           0 :     }
      60             : 
      61             : 
      62             : 
      63           0 :     AccessibleTabBarPage::~AccessibleTabBarPage()
      64             :     {
      65           0 :     }
      66             : 
      67             : 
      68             : 
      69           0 :     sal_Bool AccessibleTabBarPage::IsEnabled()
      70             :     {
      71           0 :         OExternalLockGuard aGuard( this );
      72             : 
      73           0 :         sal_Bool bEnabled = sal_False;
      74           0 :         if ( m_pTabBar )
      75           0 :             bEnabled = m_pTabBar->IsPageEnabled( m_nPageId );
      76             : 
      77           0 :         return bEnabled;
      78             :     }
      79             : 
      80             : 
      81             : 
      82           0 :     sal_Bool AccessibleTabBarPage::IsShowing()
      83             :     {
      84           0 :         sal_Bool bShowing = sal_False;
      85             : 
      86           0 :         if ( m_pTabBar && m_pTabBar->IsVisible() )
      87           0 :             bShowing = sal_True;
      88             : 
      89           0 :         return bShowing;
      90             :     }
      91             : 
      92             : 
      93             : 
      94           0 :     sal_Bool AccessibleTabBarPage::IsSelected()
      95             :     {
      96           0 :         sal_Bool bSelected = sal_False;
      97             : 
      98           0 :         if ( m_pTabBar && m_pTabBar->GetCurPageId() == m_nPageId )
      99           0 :             bSelected = sal_True;
     100             : 
     101           0 :         return bSelected;
     102             :     }
     103             : 
     104             : 
     105             : 
     106           0 :     void AccessibleTabBarPage::SetEnabled( sal_Bool bEnabled )
     107             :     {
     108           0 :         if ( m_bEnabled != bEnabled )
     109             :         {
     110           0 :             Any aOldValue[2], aNewValue[2];
     111           0 :             if ( m_bEnabled )
     112             :             {
     113           0 :                 aOldValue[0] <<= AccessibleStateType::SENSITIVE;
     114           0 :                 aOldValue[1] <<= AccessibleStateType::ENABLED;
     115             :             }
     116             :             else
     117             :             {
     118             : 
     119           0 :                 aNewValue[0] <<= AccessibleStateType::ENABLED;
     120           0 :                 aNewValue[1] <<= AccessibleStateType::SENSITIVE;
     121             :             }
     122           0 :             m_bEnabled = bEnabled;
     123           0 :             NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[0], aNewValue[0] );
     124           0 :             NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[1], aNewValue[1] );
     125             :         }
     126           0 :     }
     127             : 
     128             : 
     129             : 
     130           0 :     void AccessibleTabBarPage::SetShowing( sal_Bool bShowing )
     131             :     {
     132           0 :         if ( m_bShowing != bShowing )
     133             :         {
     134           0 :             Any aOldValue, aNewValue;
     135           0 :             if ( m_bShowing )
     136           0 :                 aOldValue <<= AccessibleStateType::SHOWING;
     137             :             else
     138           0 :                 aNewValue <<= AccessibleStateType::SHOWING;
     139           0 :             m_bShowing = bShowing;
     140           0 :             NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     141             :         }
     142           0 :     }
     143             : 
     144             : 
     145             : 
     146           0 :     void AccessibleTabBarPage::SetSelected( sal_Bool bSelected )
     147             :     {
     148           0 :         if ( m_bSelected != bSelected )
     149             :         {
     150           0 :             Any aOldValue, aNewValue;
     151           0 :             if ( m_bSelected )
     152           0 :                 aOldValue <<= AccessibleStateType::SELECTED;
     153             :             else
     154           0 :                 aNewValue <<= AccessibleStateType::SELECTED;
     155           0 :             m_bSelected = bSelected;
     156           0 :             NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     157             :         }
     158           0 :     }
     159             : 
     160             : 
     161             : 
     162           0 :     void AccessibleTabBarPage::SetPageText( const OUString& sPageText )
     163             :     {
     164           0 :         if ( !m_sPageText.equals( sPageText ) )
     165             :         {
     166           0 :             Any aOldValue, aNewValue;
     167           0 :             aOldValue <<= m_sPageText;
     168           0 :             aNewValue <<= sPageText;
     169           0 :             m_sPageText = sPageText;
     170           0 :             NotifyAccessibleEvent( AccessibleEventId::NAME_CHANGED, aOldValue, aNewValue );
     171             :         }
     172           0 :     }
     173             : 
     174             : 
     175             : 
     176           0 :     void AccessibleTabBarPage::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
     177             :     {
     178           0 :         if ( IsEnabled() )
     179             :         {
     180           0 :             rStateSet.AddState( AccessibleStateType::ENABLED );
     181           0 :             rStateSet.AddState( AccessibleStateType::SENSITIVE );
     182             :         }
     183             : 
     184           0 :         rStateSet.AddState( AccessibleStateType::VISIBLE );
     185             : 
     186           0 :         if ( IsShowing() )
     187           0 :             rStateSet.AddState( AccessibleStateType::SHOWING );
     188             : 
     189           0 :         rStateSet.AddState( AccessibleStateType::SELECTABLE );
     190             : 
     191           0 :         if ( IsSelected() )
     192           0 :             rStateSet.AddState( AccessibleStateType::SELECTED );
     193           0 :     }
     194             : 
     195             : 
     196             :     // OCommonAccessibleComponent
     197             : 
     198             : 
     199           0 :     awt::Rectangle AccessibleTabBarPage::implGetBounds() throw (RuntimeException)
     200             :     {
     201           0 :         awt::Rectangle aBounds;
     202           0 :         if ( m_pTabBar )
     203             :         {
     204             :             // get bounding rectangle relative to the AccessibleTabBar
     205           0 :             aBounds = AWTRectangle( m_pTabBar->GetPageRect( m_nPageId ) );
     206             : 
     207             :             // get position of the AccessibleTabBarPageList relative to the AccessibleTabBar
     208           0 :             Reference< XAccessible > xParent = getAccessibleParent();
     209           0 :             if ( xParent.is() )
     210             :             {
     211           0 :                 Reference< XAccessibleComponent > xParentComponent( xParent->getAccessibleContext(), UNO_QUERY );
     212           0 :                 if ( xParentComponent.is() )
     213             :                 {
     214           0 :                     awt::Point aParentLoc = xParentComponent->getLocation();
     215             : 
     216             :                     // calculate bounding rectangle relative to the AccessibleTabBarPageList
     217           0 :                     aBounds.X -= aParentLoc.X;
     218           0 :                     aBounds.Y -= aParentLoc.Y;
     219           0 :                 }
     220           0 :             }
     221             :         }
     222             : 
     223           0 :         return aBounds;
     224             :     }
     225             : 
     226             : 
     227             :     // XInterface
     228             : 
     229             : 
     230           0 :     IMPLEMENT_FORWARD_XINTERFACE2( AccessibleTabBarPage, AccessibleExtendedComponentHelper_BASE, AccessibleTabBarPage_BASE )
     231             : 
     232             : 
     233             :     // XTypeProvider
     234             : 
     235             : 
     236           0 :     IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleTabBarPage, AccessibleExtendedComponentHelper_BASE, AccessibleTabBarPage_BASE )
     237             : 
     238             : 
     239             :     // XComponent
     240             : 
     241             : 
     242           0 :     void AccessibleTabBarPage::disposing()
     243             :     {
     244           0 :         AccessibleTabBarBase::disposing();
     245           0 :         m_sPageText = OUString();
     246           0 :     }
     247             : 
     248             : 
     249             :     // XServiceInfo
     250             : 
     251             : 
     252           0 :     OUString AccessibleTabBarPage::getImplementationName() throw (RuntimeException, std::exception)
     253             :     {
     254           0 :         return OUString( "com.sun.star.comp.svtools.AccessibleTabBarPage" );
     255             :     }
     256             : 
     257             : 
     258             : 
     259           0 :     sal_Bool AccessibleTabBarPage::supportsService( const OUString& rServiceName ) throw (RuntimeException, std::exception)
     260             :     {
     261           0 :         return cppu::supportsService(this, rServiceName);
     262             :     }
     263             : 
     264             : 
     265             : 
     266           0 :     Sequence< OUString > AccessibleTabBarPage::getSupportedServiceNames() throw (RuntimeException, std::exception)
     267             :     {
     268           0 :         Sequence< OUString > aNames(1);
     269           0 :         aNames[0] = "com.sun.star.awt.AccessibleTabBarPage";
     270           0 :         return aNames;
     271             :     }
     272             : 
     273             : 
     274             :     // XAccessible
     275             : 
     276             : 
     277           0 :     Reference< XAccessibleContext > AccessibleTabBarPage::getAccessibleContext(  ) throw (RuntimeException, std::exception)
     278             :     {
     279           0 :         OExternalLockGuard aGuard( this );
     280             : 
     281           0 :         return this;
     282             :     }
     283             : 
     284             : 
     285             :     // XAccessibleContext
     286             : 
     287             : 
     288           0 :     sal_Int32 AccessibleTabBarPage::getAccessibleChildCount() throw (RuntimeException, std::exception)
     289             :     {
     290           0 :         OExternalLockGuard aGuard( this );
     291             : 
     292           0 :         return 0;
     293             :     }
     294             : 
     295             : 
     296             : 
     297           0 :     Reference< XAccessible > AccessibleTabBarPage::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     298             :     {
     299           0 :         OExternalLockGuard aGuard( this );
     300             : 
     301           0 :         if ( i < 0 || i >= getAccessibleChildCount() )
     302           0 :             throw IndexOutOfBoundsException();
     303             : 
     304           0 :         return Reference< XAccessible >();
     305             :     }
     306             : 
     307             : 
     308             : 
     309           0 :     Reference< XAccessible > AccessibleTabBarPage::getAccessibleParent(  ) throw (RuntimeException, std::exception)
     310             :     {
     311           0 :         OExternalLockGuard aGuard( this );
     312             : 
     313           0 :         return m_xParent;
     314             :     }
     315             : 
     316             : 
     317             : 
     318           0 :     sal_Int32 AccessibleTabBarPage::getAccessibleIndexInParent(  ) throw (RuntimeException, std::exception)
     319             :     {
     320           0 :         OExternalLockGuard aGuard( this );
     321             : 
     322           0 :         sal_Int32 nIndexInParent = -1;
     323           0 :         if ( m_pTabBar )
     324           0 :             nIndexInParent = m_pTabBar->GetPagePos( m_nPageId );
     325             : 
     326           0 :         return nIndexInParent;
     327             :     }
     328             : 
     329             : 
     330             : 
     331           0 :     sal_Int16 AccessibleTabBarPage::getAccessibleRole(  ) throw (RuntimeException, std::exception)
     332             :     {
     333           0 :         OExternalLockGuard aGuard( this );
     334             : 
     335           0 :         return AccessibleRole::PAGE_TAB;
     336             :     }
     337             : 
     338             : 
     339             : 
     340           0 :     OUString AccessibleTabBarPage::getAccessibleDescription( ) throw (RuntimeException, std::exception)
     341             :     {
     342           0 :         OExternalLockGuard aGuard( this );
     343             : 
     344           0 :         OUString sDescription;
     345           0 :         if ( m_pTabBar )
     346           0 :             sDescription = m_pTabBar->GetHelpText( m_nPageId );
     347             : 
     348           0 :         return sDescription;
     349             :     }
     350             : 
     351             : 
     352             : 
     353           0 :     OUString AccessibleTabBarPage::getAccessibleName(  ) throw (RuntimeException, std::exception)
     354             :     {
     355           0 :         OExternalLockGuard aGuard( this );
     356             : 
     357           0 :         return m_sPageText;
     358             :     }
     359             : 
     360             : 
     361             : 
     362           0 :     Reference< XAccessibleRelationSet > AccessibleTabBarPage::getAccessibleRelationSet(  ) throw (RuntimeException, std::exception)
     363             :     {
     364           0 :         OExternalLockGuard aGuard( this );
     365             : 
     366           0 :         utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
     367           0 :         Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
     368           0 :         return xSet;
     369             :     }
     370             : 
     371             : 
     372             : 
     373           0 :     Reference< XAccessibleStateSet > AccessibleTabBarPage::getAccessibleStateSet(  ) throw (RuntimeException, std::exception)
     374             :     {
     375           0 :         OExternalLockGuard aGuard( this );
     376             : 
     377           0 :         utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
     378           0 :         Reference< XAccessibleStateSet > xSet = pStateSetHelper;
     379             : 
     380           0 :         if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
     381             :         {
     382           0 :             FillAccessibleStateSet( *pStateSetHelper );
     383             :         }
     384             :         else
     385             :         {
     386           0 :             pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
     387             :         }
     388             : 
     389           0 :         return xSet;
     390             :     }
     391             : 
     392             : 
     393             : 
     394           0 :     Locale AccessibleTabBarPage::getLocale(  ) throw (IllegalAccessibleComponentStateException, RuntimeException, std::exception)
     395             :     {
     396           0 :         OExternalLockGuard aGuard( this );
     397             : 
     398           0 :         return Application::GetSettings().GetLanguageTag().getLocale();
     399             :     }
     400             : 
     401             : 
     402             :     // XAccessibleComponent
     403             : 
     404             : 
     405           0 :     Reference< XAccessible > AccessibleTabBarPage::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException, std::exception)
     406             :     {
     407           0 :         OExternalLockGuard aGuard( this );
     408             : 
     409           0 :         return Reference< XAccessible >();
     410             :     }
     411             : 
     412             : 
     413             : 
     414           0 :     void AccessibleTabBarPage::grabFocus(  ) throw (RuntimeException, std::exception)
     415             :     {
     416             :         // no focus
     417           0 :     }
     418             : 
     419             : 
     420             : 
     421           0 :     sal_Int32 AccessibleTabBarPage::getForeground(  ) throw (RuntimeException, std::exception)
     422             :     {
     423           0 :         OExternalLockGuard aGuard( this );
     424             : 
     425           0 :         sal_Int32 nColor = 0;
     426           0 :         Reference< XAccessible > xParent = getAccessibleParent();
     427           0 :         if ( xParent.is() )
     428             :         {
     429           0 :             Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
     430           0 :             if ( xParentComp.is() )
     431           0 :                 nColor = xParentComp->getForeground();
     432             :         }
     433             : 
     434           0 :         return nColor;
     435             :     }
     436             : 
     437             : 
     438             : 
     439           0 :     sal_Int32 AccessibleTabBarPage::getBackground(  ) throw (RuntimeException, std::exception)
     440             :     {
     441           0 :         OExternalLockGuard aGuard( this );
     442             : 
     443           0 :         sal_Int32 nColor = 0;
     444           0 :         Reference< XAccessible > xParent = getAccessibleParent();
     445           0 :         if ( xParent.is() )
     446             :         {
     447           0 :             Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
     448           0 :             if ( xParentComp.is() )
     449           0 :                 nColor = xParentComp->getBackground();
     450             :         }
     451             : 
     452           0 :         return nColor;
     453             :     }
     454             : 
     455             : 
     456             :     // XAccessibleExtendedComponent
     457             : 
     458             : 
     459           0 :     Reference< awt::XFont > AccessibleTabBarPage::getFont(  ) throw (RuntimeException, std::exception)
     460             :     {
     461           0 :         OExternalLockGuard aGuard( this );
     462             : 
     463           0 :         Reference< awt::XFont > xFont;
     464           0 :         Reference< XAccessible > xParent = getAccessibleParent();
     465           0 :         if ( xParent.is() )
     466             :         {
     467           0 :             Reference< XAccessibleExtendedComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
     468           0 :             if ( xParentComp.is() )
     469           0 :                 xFont = xParentComp->getFont();
     470             :         }
     471             : 
     472           0 :         return xFont;
     473             :     }
     474             : 
     475             : 
     476             : 
     477           0 :     OUString AccessibleTabBarPage::getTitledBorderText(  ) throw (RuntimeException, std::exception)
     478             :     {
     479           0 :         OExternalLockGuard aGuard( this );
     480             : 
     481           0 :         return m_sPageText;
     482             :     }
     483             : 
     484             : 
     485             : 
     486           0 :     OUString AccessibleTabBarPage::getToolTipText(  ) throw (RuntimeException, std::exception)
     487             :     {
     488           0 :         OExternalLockGuard aGuard( this );
     489             : 
     490           0 :         return OUString();
     491             :     }
     492             : 
     493             : 
     494             : 
     495             : 
     496             : }   // namespace accessibility
     497             : 
     498             : 
     499             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10