LCOV - code coverage report
Current view: top level - accessibility/source/extended - AccessibleGridControlTableBase.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 107 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 28 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/AccessibleGridControlTableBase.hxx"
      21             : #include <svtools/accessibletable.hxx>
      22             : #include <tools/multisel.hxx>
      23             : #include <comphelper/sequence.hxx>
      24             : #include <comphelper/servicehelper.hxx>
      25             : 
      26             : 
      27             : 
      28             : using ::com::sun::star::uno::Reference;
      29             : using ::com::sun::star::uno::Sequence;
      30             : using ::com::sun::star::uno::Any;
      31             : 
      32             : using namespace ::com::sun::star;
      33             : using namespace ::com::sun::star::accessibility;
      34             : using namespace ::svt;
      35             : using namespace ::svt::table;
      36             : 
      37             : 
      38             : 
      39             : namespace accessibility {
      40             : 
      41             : 
      42             : 
      43           0 : AccessibleGridControlTableBase::AccessibleGridControlTableBase(
      44             :         const Reference< XAccessible >& rxParent,
      45             :         IAccessibleTable& rTable,
      46             :         AccessibleTableControlObjType eObjType ) :
      47           0 :     GridControlAccessibleElement( rxParent, rTable, eObjType )
      48             : {
      49           0 : }
      50             : 
      51           0 : AccessibleGridControlTableBase::~AccessibleGridControlTableBase()
      52             : {
      53           0 : }
      54             : 
      55             : // XAccessibleContext ---------------------------------------------------------
      56             : 
      57           0 : sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleChildCount()
      58             :     throw ( uno::RuntimeException, std::exception )
      59             : {
      60           0 :     SolarMutexGuard aSolarGuard;
      61             : 
      62           0 :     ensureIsAlive();
      63           0 :     sal_Int32 nChildren = 0;
      64           0 :     if(m_eObjType == TCTYPE_ROWHEADERBAR)
      65           0 :         nChildren = m_aTable.GetRowCount();
      66           0 :     else if(m_eObjType == TCTYPE_TABLE)
      67           0 :         nChildren = m_aTable.GetRowCount()*m_aTable.GetColumnCount();
      68           0 :     else if(m_eObjType == TCTYPE_COLUMNHEADERBAR)
      69           0 :         nChildren = m_aTable.GetColumnCount();
      70           0 :     return nChildren;
      71             : }
      72             : 
      73           0 : sal_Int16 SAL_CALL AccessibleGridControlTableBase::getAccessibleRole()
      74             :     throw ( uno::RuntimeException, std::exception )
      75             : {
      76           0 :     SolarMutexGuard g;
      77             : 
      78           0 :     ensureIsAlive();
      79           0 :     return AccessibleRole::TABLE;
      80             : }
      81             : 
      82             : // XAccessibleTable -----------------------------------------------------------
      83             : 
      84           0 : sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleRowCount()
      85             :     throw ( uno::RuntimeException, std::exception )
      86             : {
      87           0 :     SolarMutexGuard aSolarGuard;
      88             : 
      89           0 :     ensureIsAlive();
      90           0 :     return  m_aTable.GetRowCount();
      91             : }
      92             : 
      93           0 : sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleColumnCount()
      94             :     throw ( uno::RuntimeException, std::exception )
      95             : {
      96           0 :     SolarMutexGuard aSolarGuard;
      97             : 
      98           0 :     ensureIsAlive();
      99           0 :     return m_aTable.GetColumnCount();
     100             : }
     101             : 
     102           0 : sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleRowExtentAt(
     103             :         sal_Int32 nRow, sal_Int32 nColumn )
     104             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     105             : {
     106           0 :     SolarMutexGuard aSolarGuard;
     107             : 
     108           0 :     ensureIsAlive();
     109           0 :     ensureIsValidAddress( nRow, nColumn );
     110           0 :     return 1;   // merged cells not supported
     111             : }
     112             : 
     113           0 : sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleColumnExtentAt(
     114             :         sal_Int32 nRow, sal_Int32 nColumn )
     115             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     116             : {
     117           0 :     SolarMutexGuard aSolarGuard;
     118             : 
     119           0 :     ensureIsAlive();
     120           0 :     ensureIsValidAddress( nRow, nColumn );
     121           0 :     return 1;   // merged cells not supported
     122             : }
     123             : 
     124           0 : Reference< XAccessible > SAL_CALL AccessibleGridControlTableBase::getAccessibleCaption()
     125             :     throw ( uno::RuntimeException, std::exception )
     126             : {
     127           0 :     SolarMutexGuard g;
     128             : 
     129           0 :     ensureIsAlive();
     130           0 :     return NULL;    // not supported
     131             : }
     132             : 
     133           0 : Reference< XAccessible > SAL_CALL AccessibleGridControlTableBase::getAccessibleSummary()
     134             :     throw ( uno::RuntimeException, std::exception )
     135             : {
     136           0 :     SolarMutexGuard g;
     137             : 
     138           0 :     ensureIsAlive();
     139           0 :     return NULL;    // not supported
     140             : }
     141             : 
     142           0 : sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleIndex(
     143             :         sal_Int32 nRow, sal_Int32 nColumn )
     144             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     145             : {
     146           0 :     SolarMutexGuard aSolarGuard;
     147             : 
     148           0 :     ensureIsAlive();
     149           0 :     ensureIsValidAddress( nRow, nColumn );
     150           0 :     return implGetChildIndex( nRow, nColumn );
     151             : }
     152             : 
     153           0 : sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleRow( sal_Int32 nChildIndex )
     154             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     155             : {
     156           0 :     SolarMutexGuard aSolarGuard;
     157             : 
     158           0 :     ensureIsAlive();
     159           0 :     ensureIsValidIndex( nChildIndex );
     160           0 :     return implGetRow( nChildIndex );
     161             : }
     162             : 
     163           0 : sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleColumn( sal_Int32 nChildIndex )
     164             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     165             : {
     166           0 :     SolarMutexGuard aSolarGuard;
     167             : 
     168           0 :     ensureIsAlive();
     169           0 :     ensureIsValidIndex( nChildIndex );
     170           0 :     return implGetColumn( nChildIndex );
     171             : }
     172             : 
     173             : // XInterface -----------------------------------------------------------------
     174             : 
     175           0 : Any SAL_CALL AccessibleGridControlTableBase::queryInterface( const uno::Type& rType )
     176             :     throw ( uno::RuntimeException, std::exception )
     177             : {
     178           0 :     Any aAny( GridControlAccessibleElement::queryInterface( rType ) );
     179           0 :     return aAny.hasValue() ?
     180           0 :         aAny : AccessibleGridControlTableImplHelper::queryInterface( rType );
     181             : }
     182             : 
     183           0 : void SAL_CALL AccessibleGridControlTableBase::acquire() throw ()
     184             : {
     185           0 :     GridControlAccessibleElement::acquire();
     186           0 : }
     187             : 
     188           0 : void SAL_CALL AccessibleGridControlTableBase::release() throw ()
     189             : {
     190           0 :     GridControlAccessibleElement::release();
     191           0 : }
     192             : 
     193             : // XTypeProvider --------------------------------------------------------------
     194             : 
     195           0 : Sequence< uno::Type > SAL_CALL AccessibleGridControlTableBase::getTypes()
     196             :     throw ( uno::RuntimeException, std::exception )
     197             : {
     198             :     return ::comphelper::concatSequences(
     199             :         GridControlAccessibleElement::getTypes(),
     200           0 :         AccessibleGridControlTableImplHelper::getTypes() );
     201             : }
     202             : 
     203           0 : Sequence< sal_Int8 > SAL_CALL AccessibleGridControlTableBase::getImplementationId()
     204             :     throw ( uno::RuntimeException, std::exception )
     205             : {
     206           0 :     return css::uno::Sequence<sal_Int8>();
     207             : }
     208             : 
     209             : // internal helper methods ----------------------------------------------------
     210             : 
     211           0 : sal_Int32 AccessibleGridControlTableBase::implGetChildCount() const
     212             : {
     213           0 :     return m_aTable.GetRowCount()*m_aTable.GetColumnCount();
     214             : }
     215             : 
     216           0 : sal_Int32 AccessibleGridControlTableBase::implGetRow( sal_Int32 nChildIndex ) const
     217             : {
     218           0 :     sal_Int32 nColumns = m_aTable.GetColumnCount();
     219           0 :     return nColumns ? (nChildIndex / nColumns) : 0;
     220             : }
     221             : 
     222           0 : sal_Int32 AccessibleGridControlTableBase::implGetColumn( sal_Int32 nChildIndex ) const
     223             : {
     224           0 :     sal_Int32 nColumns = m_aTable.GetColumnCount();
     225           0 :     return nColumns ? (nChildIndex % nColumns) : 0;
     226             : }
     227             : 
     228           0 : sal_Int32 AccessibleGridControlTableBase::implGetChildIndex(
     229             :         sal_Int32 nRow, sal_Int32 nColumn ) const
     230             : {
     231           0 :     return nRow * m_aTable.GetColumnCount() + nColumn;
     232             : }
     233             : 
     234           0 : void AccessibleGridControlTableBase::implGetSelectedRows( Sequence< sal_Int32 >& rSeq )
     235             : {
     236           0 :     sal_Int32 const selectionCount( m_aTable.GetSelectedRowCount() );
     237           0 :     rSeq.realloc( selectionCount );
     238           0 :     for ( sal_Int32 i=0; i<selectionCount; ++i )
     239           0 :         rSeq[i] = m_aTable.GetSelectedRowIndex(i);
     240           0 : }
     241             : 
     242           0 : void AccessibleGridControlTableBase::ensureIsValidRow( sal_Int32 nRow )
     243             :     throw ( lang::IndexOutOfBoundsException )
     244             : {
     245           0 :     if( nRow >= m_aTable.GetRowCount() )
     246             :         throw lang::IndexOutOfBoundsException(
     247           0 :             OUString( "row index is invalid" ), *this );
     248           0 : }
     249             : 
     250           0 : void AccessibleGridControlTableBase::ensureIsValidColumn( sal_Int32 nColumn )
     251             :     throw ( lang::IndexOutOfBoundsException )
     252             : {
     253           0 :     if( nColumn >= m_aTable.GetColumnCount() )
     254             :         throw lang::IndexOutOfBoundsException(
     255           0 :             OUString( "column index is invalid" ), *this );
     256           0 : }
     257             : 
     258           0 : void AccessibleGridControlTableBase::ensureIsValidAddress(
     259             :         sal_Int32 nRow, sal_Int32 nColumn )
     260             :     throw ( lang::IndexOutOfBoundsException )
     261             : {
     262           0 :     ensureIsValidRow( nRow );
     263           0 :     ensureIsValidColumn( nColumn );
     264           0 : }
     265             : 
     266           0 : void AccessibleGridControlTableBase::ensureIsValidIndex( sal_Int32 nChildIndex )
     267             :     throw ( lang::IndexOutOfBoundsException )
     268             : {
     269           0 :     if( nChildIndex >= implGetChildCount() )
     270             :         throw lang::IndexOutOfBoundsException(
     271           0 :             OUString( "child index is invalid" ), *this );
     272           0 : }
     273             : 
     274             : 
     275             : 
     276             : } // namespace accessibility
     277             : 
     278             : 
     279             : 
     280             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11