LCOV - code coverage report
Current view: top level - accessibility/source/extended - AccessibleBrowseBoxHeaderBar.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 171 0.0 %
Date: 2014-04-11 Functions: 0 36 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/AccessibleBrowseBoxHeaderBar.hxx"
      21             : #include <svtools/accessibletableprovider.hxx>
      22             : #include <comphelper/servicehelper.hxx>
      23             : 
      24             : 
      25             : 
      26             : using ::com::sun::star::uno::Reference;
      27             : using ::com::sun::star::uno::Sequence;
      28             : using ::com::sun::star::uno::Any;
      29             : 
      30             : using namespace ::com::sun::star;
      31             : using namespace ::com::sun::star::accessibility;
      32             : using namespace ::svt;
      33             : 
      34             : 
      35             : 
      36             : namespace accessibility {
      37             : 
      38             : 
      39             : 
      40             : // Ctor/Dtor/disposing --------------------------------------------------------
      41             : 
      42           0 : AccessibleBrowseBoxHeaderBar::AccessibleBrowseBoxHeaderBar(
      43             :         const Reference< XAccessible >& rxParent,
      44             :         IAccessibleTableProvider&                      rBrowseBox,
      45             :         AccessibleBrowseBoxObjType      eObjType ) :
      46           0 :     AccessibleBrowseBoxTableBase( rxParent, rBrowseBox,eObjType )
      47             : {
      48             :     OSL_ENSURE( isRowBar() || isColumnBar(),
      49             :         "accessibility/extended/AccessibleBrowseBoxHeaderBar - invalid object type" );
      50           0 : }
      51             : 
      52           0 : AccessibleBrowseBoxHeaderBar::~AccessibleBrowseBoxHeaderBar()
      53             : {
      54           0 : }
      55             : 
      56             : // XAccessibleContext ---------------------------------------------------------
      57             : 
      58             : Reference< XAccessible > SAL_CALL
      59           0 : AccessibleBrowseBoxHeaderBar::getAccessibleChild( sal_Int32 nChildIndex )
      60             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
      61             : {
      62           0 :     SolarMutexGuard aSolarGuard;
      63           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
      64           0 :     ensureIsAlive();
      65           0 :     ensureIsValidHeaderIndex( nChildIndex );
      66           0 :     return implGetChild( nChildIndex, implToVCLColumnPos( nChildIndex ) );
      67             : }
      68             : 
      69           0 : sal_Int32 SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleIndexInParent()
      70             :     throw ( uno::RuntimeException, std::exception )
      71             : {
      72           0 :     return isRowBar() ? BBINDEX_ROWHEADERBAR : BBINDEX_COLUMNHEADERBAR;
      73             : }
      74             : 
      75             : // XAccessibleComponent -------------------------------------------------------
      76             : 
      77             : Reference< XAccessible > SAL_CALL
      78           0 : AccessibleBrowseBoxHeaderBar::getAccessibleAtPoint( const awt::Point& rPoint )
      79             :     throw ( uno::RuntimeException, std::exception )
      80             : {
      81           0 :     SolarMutexGuard aSolarGuard;
      82           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
      83           0 :     ensureIsAlive();
      84             : 
      85           0 :     sal_Int32 nRow = 0;
      86           0 :     sal_uInt16 nColumnPos = 0;
      87           0 :     sal_Bool bConverted = isRowBar() ?
      88           0 :         mpBrowseBox->ConvertPointToRowHeader( nRow, VCLPoint( rPoint ) ) :
      89           0 :         mpBrowseBox->ConvertPointToColumnHeader( nColumnPos, VCLPoint( rPoint ) );
      90             : 
      91           0 :     return bConverted ? implGetChild( nRow, nColumnPos ) : Reference< XAccessible >();
      92             : }
      93             : 
      94           0 : void SAL_CALL AccessibleBrowseBoxHeaderBar::grabFocus()
      95             :     throw ( uno::RuntimeException, std::exception )
      96             : {
      97           0 :     ensureIsAlive();
      98             :     // focus on header not supported
      99           0 : }
     100             : 
     101             : // XAccessibleTable -----------------------------------------------------------
     102             : 
     103           0 : OUString SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleRowDescription( sal_Int32 nRow )
     104             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     105             : {
     106           0 :     SolarMutexGuard aSolarGuard;
     107           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     108           0 :     ensureIsAlive();
     109           0 :     ensureIsValidRow( nRow );
     110           0 :     return OUString();  // no headers in headers
     111             : }
     112             : 
     113           0 : OUString SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleColumnDescription( sal_Int32 nColumn )
     114             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     115             : {
     116           0 :     SolarMutexGuard aSolarGuard;
     117           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     118           0 :     ensureIsAlive();
     119           0 :     ensureIsValidColumn( nColumn );
     120           0 :     return OUString();  // no headers in headers
     121             : }
     122             : 
     123           0 : Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleRowHeaders()
     124             :     throw ( uno::RuntimeException, std::exception )
     125             : {
     126           0 :     ensureIsAlive();
     127           0 :     return NULL;        // no headers in headers
     128             : }
     129             : 
     130           0 : Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleColumnHeaders()
     131             :     throw ( uno::RuntimeException, std::exception )
     132             : {
     133           0 :     ensureIsAlive();
     134           0 :     return NULL;        // no headers in headers
     135             : }
     136             : 
     137           0 : Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxHeaderBar::getSelectedAccessibleRows()
     138             :     throw ( uno::RuntimeException, std::exception )
     139             : {
     140           0 :     SolarMutexGuard aSolarGuard;
     141           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     142           0 :     ensureIsAlive();
     143             : 
     144           0 :     Sequence< sal_Int32 > aSelSeq;
     145             :     // row of column header bar not selectable
     146           0 :     if( isRowBar() )
     147           0 :         implGetSelectedRows( aSelSeq );
     148           0 :     return aSelSeq;
     149             : }
     150             : 
     151           0 : Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxHeaderBar::getSelectedAccessibleColumns()
     152             :     throw ( uno::RuntimeException, std::exception )
     153             : {
     154           0 :     SolarMutexGuard aSolarGuard;
     155           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     156           0 :     ensureIsAlive();
     157             : 
     158           0 :     Sequence< sal_Int32 > aSelSeq;
     159             :     // column of row header bar ("handle column") not selectable
     160           0 :     if( isColumnBar() )
     161           0 :         implGetSelectedColumns( aSelSeq );
     162           0 :     return aSelSeq;
     163             : }
     164             : 
     165           0 : sal_Bool SAL_CALL AccessibleBrowseBoxHeaderBar::isAccessibleRowSelected( sal_Int32 nRow )
     166             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     167             : {
     168           0 :     SolarMutexGuard aSolarGuard;
     169           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     170           0 :     ensureIsAlive();
     171           0 :     ensureIsValidRow( nRow );
     172           0 :     return isRowBar() ? implIsRowSelected( nRow ) : sal_False;
     173             : }
     174             : 
     175           0 : sal_Bool SAL_CALL AccessibleBrowseBoxHeaderBar::isAccessibleColumnSelected( sal_Int32 nColumn )
     176             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     177             : {
     178           0 :     SolarMutexGuard aSolarGuard;
     179           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     180           0 :     ensureIsAlive();
     181           0 :     ensureIsValidColumn( nColumn );
     182           0 :     return isColumnBar() ? implIsColumnSelected( nColumn ) : sal_False;
     183             : }
     184             : 
     185           0 : Reference< XAccessible > SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleCellAt(
     186             :         sal_Int32 nRow, sal_Int32 nColumn )
     187             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     188             : {
     189           0 :     SolarMutexGuard aSolarGuard;
     190           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     191           0 :     ensureIsAlive();
     192           0 :     ensureIsValidAddress( nRow, nColumn );
     193           0 :     return implGetChild( nRow, implToVCLColumnPos( nColumn ) );
     194             : }
     195             : 
     196           0 : sal_Bool SAL_CALL AccessibleBrowseBoxHeaderBar::isAccessibleSelected(
     197             :         sal_Int32 nRow, sal_Int32 nColumn )
     198             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     199             : {
     200           0 :     SolarMutexGuard aSolarGuard;
     201           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     202           0 :     ensureIsAlive();
     203           0 :     ensureIsValidAddress( nRow, nColumn );
     204           0 :     return isRowBar() ? implIsRowSelected( nRow ) : implIsColumnSelected( nColumn );
     205             : }
     206             : 
     207             : // XAccessibleSelection -------------------------------------------------------
     208             : 
     209           0 : void SAL_CALL AccessibleBrowseBoxHeaderBar::selectAccessibleChild( sal_Int32 nChildIndex )
     210             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     211             : {
     212           0 :     SolarMutexGuard aSolarGuard;
     213           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     214           0 :     ensureIsAlive();
     215           0 :     ensureIsValidHeaderIndex( nChildIndex );
     216           0 :     if( isRowBar() )
     217           0 :         implSelectRow( nChildIndex, sal_True );
     218             :     else
     219           0 :         implSelectColumn( implToVCLColumnPos( nChildIndex ), sal_True );
     220           0 : }
     221             : 
     222           0 : sal_Bool SAL_CALL AccessibleBrowseBoxHeaderBar::isAccessibleChildSelected( sal_Int32 nChildIndex )
     223             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     224             : {
     225             :     // using interface methods - no mutex
     226           0 :     return isRowBar() ?
     227           0 :         isAccessibleRowSelected( nChildIndex ) :
     228           0 :         isAccessibleColumnSelected( nChildIndex );
     229             : }
     230             : 
     231           0 : void SAL_CALL AccessibleBrowseBoxHeaderBar::clearAccessibleSelection()
     232             :     throw ( uno::RuntimeException, std::exception )
     233             : {
     234           0 :     SolarMutexGuard aSolarGuard;
     235           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     236           0 :     ensureIsAlive();
     237           0 :     mpBrowseBox->SetNoSelection();
     238           0 : }
     239             : 
     240           0 : void SAL_CALL AccessibleBrowseBoxHeaderBar::selectAllAccessibleChildren()
     241             :     throw ( uno::RuntimeException, std::exception )
     242             : {
     243           0 :     SolarMutexGuard aSolarGuard;
     244           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     245           0 :     ensureIsAlive();
     246             :     // no multiselection of columns possible
     247           0 :     if( isRowBar() )
     248           0 :         mpBrowseBox->SelectAll();
     249             :     else
     250           0 :         implSelectColumn( implToVCLColumnPos( 0 ), sal_True );
     251           0 : }
     252             : 
     253           0 : sal_Int32 SAL_CALL AccessibleBrowseBoxHeaderBar::getSelectedAccessibleChildCount()
     254             :     throw ( uno::RuntimeException, std::exception )
     255             : {
     256           0 :     SolarMutexGuard aSolarGuard;
     257           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     258           0 :     ensureIsAlive();
     259           0 :     return isRowBar() ? implGetSelectedRowCount() : implGetSelectedColumnCount();
     260             : }
     261             : 
     262             : Reference< XAccessible > SAL_CALL
     263           0 : AccessibleBrowseBoxHeaderBar::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
     264             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     265             : {
     266           0 :     SolarMutexGuard aSolarGuard;
     267           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     268           0 :     ensureIsAlive();
     269             : 
     270             :     // method may throw lang::IndexOutOfBoundsException
     271           0 :     sal_Int32 nIndex = implGetChildIndexFromSelectedIndex( nSelectedChildIndex );
     272           0 :     return implGetChild( nIndex, implToVCLColumnPos( nIndex ) );
     273             : }
     274             : 
     275           0 : void SAL_CALL AccessibleBrowseBoxHeaderBar::deselectAccessibleChild(
     276             :         sal_Int32 nSelectedChildIndex )
     277             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     278             : {
     279           0 :     SolarMutexGuard aSolarGuard;
     280           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     281           0 :     ensureIsAlive();
     282             : 
     283             :     // method may throw lang::IndexOutOfBoundsException
     284           0 :     if ( isAccessibleChildSelected(nSelectedChildIndex) )
     285             :     {
     286           0 :         if( isRowBar() )
     287           0 :             implSelectRow( nSelectedChildIndex, sal_False );
     288             :         else
     289           0 :             implSelectColumn( implToVCLColumnPos( nSelectedChildIndex ), sal_False );
     290           0 :     }
     291           0 : }
     292             : 
     293             : // XInterface -----------------------------------------------------------------
     294             : 
     295           0 : Any SAL_CALL AccessibleBrowseBoxHeaderBar::queryInterface( const uno::Type& rType )
     296             :     throw ( uno::RuntimeException, std::exception )
     297             : {
     298           0 :     Any aAny( AccessibleBrowseBoxTableBase::queryInterface( rType ) );
     299           0 :     return aAny.hasValue() ?
     300           0 :         aAny : AccessibleBrowseBoxHeaderBarImplHelper::queryInterface( rType );
     301             : }
     302             : 
     303           0 : void SAL_CALL AccessibleBrowseBoxHeaderBar::acquire() throw ()
     304             : {
     305           0 :     AccessibleBrowseBoxTableBase::acquire();
     306           0 : }
     307             : 
     308           0 : void SAL_CALL AccessibleBrowseBoxHeaderBar::release() throw ()
     309             : {
     310           0 :     AccessibleBrowseBoxTableBase::release();
     311           0 : }
     312             : 
     313             : // XServiceInfo ---------------------------------------------------------------
     314             : 
     315           0 : OUString SAL_CALL AccessibleBrowseBoxHeaderBar::getImplementationName()
     316             :     throw ( uno::RuntimeException, std::exception )
     317             : {
     318           0 :     return OUString( "com.sun.star.comp.svtools.AccessibleBrowseBoxHeaderBar" );
     319             : }
     320             : 
     321           0 : Sequence< sal_Int8 > SAL_CALL AccessibleBrowseBoxHeaderBar::getImplementationId()
     322             :     throw ( uno::RuntimeException, std::exception )
     323             : {
     324           0 :     return css::uno::Sequence<sal_Int8>();
     325             : }
     326             : 
     327             : // internal virtual methods ---------------------------------------------------
     328             : 
     329           0 : Rectangle AccessibleBrowseBoxHeaderBar::implGetBoundingBox()
     330             : {
     331           0 :     return mpBrowseBox->calcHeaderRect(isColumnBar(), false);
     332             : }
     333             : 
     334           0 : Rectangle AccessibleBrowseBoxHeaderBar::implGetBoundingBoxOnScreen()
     335             : {
     336           0 :     return mpBrowseBox->calcHeaderRect(isColumnBar(), true);
     337             : }
     338             : 
     339           0 : sal_Int32 AccessibleBrowseBoxHeaderBar::implGetRowCount() const
     340             : {
     341             :     // column header bar: only 1 row
     342           0 :     return isRowBar() ? AccessibleBrowseBoxTableBase::implGetRowCount() : 1;
     343             : }
     344             : 
     345           0 : sal_Int32 AccessibleBrowseBoxHeaderBar::implGetColumnCount() const
     346             : {
     347             :     // row header bar ("handle column"): only 1 column
     348           0 :     return isColumnBar() ? AccessibleBrowseBoxTableBase::implGetColumnCount() : 1;
     349             : }
     350             : 
     351             : // internal helper methods ----------------------------------------------------
     352             : 
     353           0 : Reference< XAccessible > AccessibleBrowseBoxHeaderBar::implGetChild(
     354             :         sal_Int32 nRow, sal_uInt16 nColumnPos )
     355             : {
     356           0 :     return isRowBar() ?
     357           0 :         mpBrowseBox->CreateAccessibleRowHeader( nRow ) :
     358           0 :         mpBrowseBox->CreateAccessibleColumnHeader( nColumnPos );
     359             : }
     360             : 
     361           0 : sal_Int32 AccessibleBrowseBoxHeaderBar::implGetChildIndexFromSelectedIndex(
     362             :         sal_Int32 nSelectedChildIndex )
     363             :     throw ( lang::IndexOutOfBoundsException )
     364             : {
     365           0 :     Sequence< sal_Int32 > aSelSeq;
     366           0 :     if( isRowBar() )
     367           0 :         implGetSelectedRows( aSelSeq );
     368             :     else
     369           0 :         implGetSelectedColumns( aSelSeq );
     370             : 
     371           0 :     if( (nSelectedChildIndex < 0) || (nSelectedChildIndex >= aSelSeq.getLength()) )
     372           0 :         throw lang::IndexOutOfBoundsException();
     373             : 
     374           0 :     return aSelSeq[ nSelectedChildIndex ];
     375             : }
     376             : 
     377           0 : void AccessibleBrowseBoxHeaderBar::ensureIsValidHeaderIndex( sal_Int32 nIndex )
     378             :     throw ( lang::IndexOutOfBoundsException )
     379             : {
     380           0 :     if( isRowBar() )
     381           0 :         ensureIsValidRow( nIndex );
     382             :     else
     383           0 :         ensureIsValidColumn( nIndex );
     384           0 : }
     385             : 
     386             : 
     387             : 
     388             : } // namespace accessibility
     389             : 
     390             : 
     391             : 
     392             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10