LCOV - code coverage report
Current view: top level - accessibility/source/extended - AccessibleBrowseBoxTableBase.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 137 0.0 %
Date: 2015-06-13 12:38:46 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/AccessibleBrowseBoxTableBase.hxx"
      21             : #include <svtools/accessibletableprovider.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             : 
      36             : 
      37             : 
      38             : namespace accessibility {
      39             : 
      40             : 
      41             : 
      42             : // Ctor/Dtor/disposing --------------------------------------------------------
      43             : 
      44           0 : AccessibleBrowseBoxTableBase::AccessibleBrowseBoxTableBase(
      45             :         const Reference< XAccessible >& rxParent,
      46             :         IAccessibleTableProvider&                      rBrowseBox,
      47             :         AccessibleBrowseBoxObjType      eObjType ) :
      48           0 :     BrowseBoxAccessibleElement( rxParent, rBrowseBox,NULL, eObjType )
      49             : {
      50           0 : }
      51             : 
      52           0 : AccessibleBrowseBoxTableBase::~AccessibleBrowseBoxTableBase()
      53             : {
      54           0 : }
      55             : 
      56             : // XAccessibleContext ---------------------------------------------------------
      57             : 
      58           0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleChildCount()
      59             :     throw ( uno::RuntimeException, std::exception )
      60             : {
      61           0 :     SolarMutexGuard aSolarGuard;
      62           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
      63           0 :     ensureIsAlive();
      64           0 :     return implGetChildCount();
      65             : }
      66             : 
      67           0 : sal_Int16 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleRole()
      68             :     throw ( uno::RuntimeException, std::exception )
      69             : {
      70           0 :     ensureIsAlive();
      71           0 :     return AccessibleRole::TABLE;
      72             : }
      73             : 
      74             : // XAccessibleTable -----------------------------------------------------------
      75             : 
      76           0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleRowCount()
      77             :     throw ( uno::RuntimeException, std::exception )
      78             : {
      79           0 :     SolarMutexGuard aSolarGuard;
      80           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
      81           0 :     ensureIsAlive();
      82           0 :     return implGetRowCount();
      83             : }
      84             : 
      85           0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleColumnCount()
      86             :     throw ( uno::RuntimeException, std::exception )
      87             : {
      88           0 :     SolarMutexGuard aSolarGuard;
      89           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
      90           0 :     ensureIsAlive();
      91           0 :     return implGetColumnCount();
      92             : }
      93             : 
      94           0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleRowExtentAt(
      95             :         sal_Int32 nRow, sal_Int32 nColumn )
      96             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
      97             : {
      98           0 :     SolarMutexGuard aSolarGuard;
      99           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     100           0 :     ensureIsAlive();
     101           0 :     ensureIsValidAddress( nRow, nColumn );
     102           0 :     return 1;   // merged cells not supported
     103             : }
     104             : 
     105           0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleColumnExtentAt(
     106             :         sal_Int32 nRow, sal_Int32 nColumn )
     107             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     108             : {
     109           0 :     SolarMutexGuard aSolarGuard;
     110           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     111           0 :     ensureIsAlive();
     112           0 :     ensureIsValidAddress( nRow, nColumn );
     113           0 :     return 1;   // merged cells not supported
     114             : }
     115             : 
     116           0 : Reference< XAccessible > SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleCaption()
     117             :     throw ( uno::RuntimeException, std::exception )
     118             : {
     119           0 :     ensureIsAlive();
     120           0 :     return NULL;    // not supported
     121             : }
     122             : 
     123           0 : Reference< XAccessible > SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleSummary()
     124             :     throw ( uno::RuntimeException, std::exception )
     125             : {
     126           0 :     ensureIsAlive();
     127           0 :     return NULL;    // not supported
     128             : }
     129             : 
     130           0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleIndex(
     131             :         sal_Int32 nRow, sal_Int32 nColumn )
     132             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     133             : {
     134           0 :     SolarMutexGuard aSolarGuard;
     135           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     136           0 :     ensureIsAlive();
     137           0 :     ensureIsValidAddress( nRow, nColumn );
     138           0 :     return implGetChildIndex( nRow, nColumn );
     139             : }
     140             : 
     141           0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleRow( sal_Int32 nChildIndex )
     142             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     143             : {
     144           0 :     SolarMutexGuard aSolarGuard;
     145           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     146           0 :     ensureIsAlive();
     147           0 :     ensureIsValidIndex( nChildIndex );
     148           0 :     return implGetRow( nChildIndex );
     149             : }
     150             : 
     151           0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleColumn( sal_Int32 nChildIndex )
     152             :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
     153             : {
     154           0 :     SolarMutexGuard aSolarGuard;
     155           0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     156           0 :     ensureIsAlive();
     157           0 :     ensureIsValidIndex( nChildIndex );
     158           0 :     return implGetColumn( nChildIndex );
     159             : }
     160             : 
     161             : // XInterface -----------------------------------------------------------------
     162             : 
     163           0 : Any SAL_CALL AccessibleBrowseBoxTableBase::queryInterface( const uno::Type& rType )
     164             :     throw ( uno::RuntimeException, std::exception )
     165             : {
     166           0 :     Any aAny( BrowseBoxAccessibleElement::queryInterface( rType ) );
     167           0 :     return aAny.hasValue() ?
     168           0 :         aAny : AccessibleBrowseBoxTableImplHelper::queryInterface( rType );
     169             : }
     170             : 
     171           0 : void SAL_CALL AccessibleBrowseBoxTableBase::acquire() throw ()
     172             : {
     173           0 :     BrowseBoxAccessibleElement::acquire();
     174           0 : }
     175             : 
     176           0 : void SAL_CALL AccessibleBrowseBoxTableBase::release() throw ()
     177             : {
     178           0 :     BrowseBoxAccessibleElement::release();
     179           0 : }
     180             : 
     181             : // XTypeProvider --------------------------------------------------------------
     182             : 
     183           0 : Sequence< uno::Type > SAL_CALL AccessibleBrowseBoxTableBase::getTypes()
     184             :     throw ( uno::RuntimeException, std::exception )
     185             : {
     186             :     return ::comphelper::concatSequences(
     187             :         BrowseBoxAccessibleElement::getTypes(),
     188           0 :         AccessibleBrowseBoxTableImplHelper::getTypes() );
     189             : }
     190             : 
     191           0 : Sequence< sal_Int8 > SAL_CALL AccessibleBrowseBoxTableBase::getImplementationId()
     192             :     throw ( uno::RuntimeException, std::exception )
     193             : {
     194           0 :     return css::uno::Sequence<sal_Int8>();
     195             : }
     196             : 
     197             : // internal virtual methods ---------------------------------------------------
     198             : 
     199           0 : sal_Int32 AccessibleBrowseBoxTableBase::implGetRowCount() const
     200             : {
     201           0 :     return mpBrowseBox->GetRowCount();
     202             : }
     203             : 
     204           0 : sal_Int32 AccessibleBrowseBoxTableBase::implGetColumnCount() const
     205             : {
     206           0 :     sal_uInt16 nColumns = mpBrowseBox->GetColumnCount();
     207             :     // do not count the "handle column"
     208           0 :     if( nColumns && implHasHandleColumn() )
     209           0 :         --nColumns;
     210           0 :     return nColumns;
     211             : }
     212             : 
     213             : // internal helper methods ----------------------------------------------------
     214             : 
     215           0 : bool AccessibleBrowseBoxTableBase::implHasHandleColumn() const
     216             : {
     217           0 :     return mpBrowseBox->HasRowHeader();
     218             : }
     219             : 
     220           0 : sal_uInt16 AccessibleBrowseBoxTableBase::implToVCLColumnPos( sal_Int32 nColumn ) const
     221             : {
     222           0 :     sal_uInt16 nVCLPos = 0;
     223           0 :     if( (0 <= nColumn) && (nColumn < implGetColumnCount()) )
     224             :     {
     225             :         // regard "handle column"
     226           0 :         if( implHasHandleColumn() )
     227           0 :             ++nColumn;
     228           0 :         nVCLPos = static_cast< sal_uInt16 >( nColumn );
     229             :     }
     230           0 :     return nVCLPos;
     231             : }
     232             : 
     233           0 : sal_Int32 AccessibleBrowseBoxTableBase::implGetChildCount() const
     234             : {
     235           0 :     return implGetRowCount() * implGetColumnCount();
     236             : }
     237             : 
     238           0 : sal_Int32 AccessibleBrowseBoxTableBase::implGetRow( sal_Int32 nChildIndex ) const
     239             : {
     240           0 :     sal_Int32 nColumns = implGetColumnCount();
     241           0 :     return nColumns ? (nChildIndex / nColumns) : 0;
     242             : }
     243             : 
     244           0 : sal_Int32 AccessibleBrowseBoxTableBase::implGetColumn( sal_Int32 nChildIndex ) const
     245             : {
     246           0 :     sal_Int32 nColumns = implGetColumnCount();
     247           0 :     return nColumns ? (nChildIndex % nColumns) : 0;
     248             : }
     249             : 
     250           0 : sal_Int32 AccessibleBrowseBoxTableBase::implGetChildIndex(
     251             :         sal_Int32 nRow, sal_Int32 nColumn ) const
     252             : {
     253           0 :     return nRow * implGetColumnCount() + nColumn;
     254             : }
     255             : 
     256           0 : bool AccessibleBrowseBoxTableBase::implIsRowSelected( sal_Int32 nRow ) const
     257             : {
     258           0 :     return mpBrowseBox->IsRowSelected( nRow );
     259             : }
     260             : 
     261           0 : bool AccessibleBrowseBoxTableBase::implIsColumnSelected( sal_Int32 nColumn ) const
     262             : {
     263           0 :     if( implHasHandleColumn() )
     264           0 :         --nColumn;
     265           0 :     return mpBrowseBox->IsColumnSelected( nColumn );
     266             : }
     267             : 
     268           0 : void AccessibleBrowseBoxTableBase::implSelectRow( sal_Int32 nRow, bool bSelect )
     269             : {
     270           0 :     mpBrowseBox->SelectRow( nRow, bSelect, true );
     271           0 : }
     272             : 
     273           0 : void AccessibleBrowseBoxTableBase::implSelectColumn( sal_Int32 nColumnPos, bool bSelect )
     274             : {
     275           0 :     mpBrowseBox->SelectColumn( (sal_uInt16)nColumnPos, bSelect );
     276           0 : }
     277             : 
     278           0 : sal_Int32 AccessibleBrowseBoxTableBase::implGetSelectedRowCount() const
     279             : {
     280           0 :     return mpBrowseBox->GetSelectedRowCount();
     281             : }
     282             : 
     283           0 : sal_Int32 AccessibleBrowseBoxTableBase::implGetSelectedColumnCount() const
     284             : {
     285           0 :     return mpBrowseBox->GetSelectedColumnCount();
     286             : }
     287             : 
     288           0 : void AccessibleBrowseBoxTableBase::implGetSelectedRows( Sequence< sal_Int32 >& rSeq )
     289             : {
     290           0 :     mpBrowseBox->GetAllSelectedRows( rSeq );
     291           0 : }
     292             : 
     293           0 : void AccessibleBrowseBoxTableBase::implGetSelectedColumns( Sequence< sal_Int32 >& rSeq )
     294             : {
     295           0 :     mpBrowseBox->GetAllSelectedColumns( rSeq );
     296           0 : }
     297             : 
     298           0 : void AccessibleBrowseBoxTableBase::ensureIsValidRow( sal_Int32 nRow )
     299             :     throw ( lang::IndexOutOfBoundsException )
     300             : {
     301           0 :     if( nRow >= implGetRowCount() )
     302             :         throw lang::IndexOutOfBoundsException(
     303           0 :             OUString( "row index is invalid" ), *this );
     304           0 : }
     305             : 
     306           0 : void AccessibleBrowseBoxTableBase::ensureIsValidColumn( sal_Int32 nColumn )
     307             :     throw ( lang::IndexOutOfBoundsException )
     308             : {
     309           0 :     if( nColumn >= implGetColumnCount() )
     310             :         throw lang::IndexOutOfBoundsException(
     311           0 :             OUString( "column index is invalid" ), *this );
     312           0 : }
     313             : 
     314           0 : void AccessibleBrowseBoxTableBase::ensureIsValidAddress(
     315             :         sal_Int32 nRow, sal_Int32 nColumn )
     316             :     throw ( lang::IndexOutOfBoundsException )
     317             : {
     318           0 :     ensureIsValidRow( nRow );
     319           0 :     ensureIsValidColumn( nColumn );
     320           0 : }
     321             : 
     322           0 : void AccessibleBrowseBoxTableBase::ensureIsValidIndex( sal_Int32 nChildIndex )
     323             :     throw ( lang::IndexOutOfBoundsException )
     324             : {
     325           0 :     if( nChildIndex >= implGetChildCount() )
     326             :         throw lang::IndexOutOfBoundsException(
     327           0 :             OUString( "child index is invalid" ), *this );
     328           0 : }
     329             : 
     330             : 
     331             : 
     332             : } // namespace accessibility
     333             : 
     334             : 
     335             : 
     336             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11