LCOV - code coverage report
Current view: top level - accessibility/source/extended - AccessibleBrowseBoxTableBase.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 137 0.0 %
Date: 2012-08-25 Functions: 0 39 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 162 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "accessibility/extended/AccessibleBrowseBoxTableBase.hxx"
      30                 :            : #include <svtools/accessibletableprovider.hxx>
      31                 :            : #include <tools/multisel.hxx>
      32                 :            : #include <comphelper/sequence.hxx>
      33                 :            : #include <comphelper/servicehelper.hxx>
      34                 :            : 
      35                 :            : // ============================================================================
      36                 :            : 
      37                 :            : using ::rtl::OUString;
      38                 :            : 
      39                 :            : using ::com::sun::star::uno::Reference;
      40                 :            : using ::com::sun::star::uno::Sequence;
      41                 :            : using ::com::sun::star::uno::Any;
      42                 :            : 
      43                 :            : using namespace ::com::sun::star;
      44                 :            : using namespace ::com::sun::star::accessibility;
      45                 :            : using namespace ::svt;
      46                 :            : 
      47                 :            : // ============================================================================
      48                 :            : 
      49                 :            : namespace accessibility {
      50                 :            : 
      51                 :            : // ============================================================================
      52                 :            : 
      53                 :            : // Ctor/Dtor/disposing --------------------------------------------------------
      54                 :            : 
      55                 :          0 : AccessibleBrowseBoxTableBase::AccessibleBrowseBoxTableBase(
      56                 :            :         const Reference< XAccessible >& rxParent,
      57                 :            :         IAccessibleTableProvider&                      rBrowseBox,
      58                 :            :         AccessibleBrowseBoxObjType      eObjType ) :
      59         [ #  # ]:          0 :     BrowseBoxAccessibleElement( rxParent, rBrowseBox,NULL, eObjType )
      60                 :            : {
      61                 :          0 : }
      62                 :            : 
      63                 :          0 : AccessibleBrowseBoxTableBase::~AccessibleBrowseBoxTableBase()
      64                 :            : {
      65         [ #  # ]:          0 : }
      66                 :            : 
      67                 :            : // XAccessibleContext ---------------------------------------------------------
      68                 :            : 
      69                 :          0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleChildCount()
      70                 :            :     throw ( uno::RuntimeException )
      71                 :            : {
      72         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
      73         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
      74         [ #  # ]:          0 :     ensureIsAlive();
      75 [ #  # ][ #  # ]:          0 :     return implGetChildCount();
                 [ #  # ]
      76                 :            : }
      77                 :            : 
      78                 :          0 : sal_Int16 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleRole()
      79                 :            :     throw ( uno::RuntimeException )
      80                 :            : {
      81                 :          0 :     ensureIsAlive();
      82                 :          0 :     return AccessibleRole::TABLE;
      83                 :            : }
      84                 :            : 
      85                 :            : // XAccessibleTable -----------------------------------------------------------
      86                 :            : 
      87                 :          0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleRowCount()
      88                 :            :     throw ( uno::RuntimeException )
      89                 :            : {
      90         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
      91         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
      92         [ #  # ]:          0 :     ensureIsAlive();
      93 [ #  # ][ #  # ]:          0 :     return implGetRowCount();
                 [ #  # ]
      94                 :            : }
      95                 :            : 
      96                 :          0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleColumnCount()
      97                 :            :     throw ( uno::RuntimeException )
      98                 :            : {
      99         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     100         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     101         [ #  # ]:          0 :     ensureIsAlive();
     102 [ #  # ][ #  # ]:          0 :     return implGetColumnCount();
                 [ #  # ]
     103                 :            : }
     104                 :            : 
     105                 :          0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleRowExtentAt(
     106                 :            :         sal_Int32 nRow, sal_Int32 nColumn )
     107                 :            :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
     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 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleColumnExtentAt(
     117                 :            :         sal_Int32 nRow, sal_Int32 nColumn )
     118                 :            :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
     119                 :            : {
     120         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     121         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     122         [ #  # ]:          0 :     ensureIsAlive();
     123         [ #  # ]:          0 :     ensureIsValidAddress( nRow, nColumn );
     124 [ #  # ][ #  # ]:          0 :     return 1;   // merged cells not supported
     125                 :            : }
     126                 :            : 
     127                 :          0 : Reference< XAccessible > SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleCaption()
     128                 :            :     throw ( uno::RuntimeException )
     129                 :            : {
     130                 :          0 :     ensureIsAlive();
     131                 :          0 :     return NULL;    // not supported
     132                 :            : }
     133                 :            : 
     134                 :          0 : Reference< XAccessible > SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleSummary()
     135                 :            :     throw ( uno::RuntimeException )
     136                 :            : {
     137                 :          0 :     ensureIsAlive();
     138                 :          0 :     return NULL;    // not supported
     139                 :            : }
     140                 :            : 
     141                 :          0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleIndex(
     142                 :            :         sal_Int32 nRow, sal_Int32 nColumn )
     143                 :            :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
     144                 :            : {
     145         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     146         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     147         [ #  # ]:          0 :     ensureIsAlive();
     148         [ #  # ]:          0 :     ensureIsValidAddress( nRow, nColumn );
     149 [ #  # ][ #  # ]:          0 :     return implGetChildIndex( nRow, nColumn );
                 [ #  # ]
     150                 :            : }
     151                 :            : 
     152                 :          0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleRow( sal_Int32 nChildIndex )
     153                 :            :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
     154                 :            : {
     155         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     156         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     157         [ #  # ]:          0 :     ensureIsAlive();
     158         [ #  # ]:          0 :     ensureIsValidIndex( nChildIndex );
     159 [ #  # ][ #  # ]:          0 :     return implGetRow( nChildIndex );
                 [ #  # ]
     160                 :            : }
     161                 :            : 
     162                 :          0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleColumn( sal_Int32 nChildIndex )
     163                 :            :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
     164                 :            : {
     165         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     166         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     167         [ #  # ]:          0 :     ensureIsAlive();
     168         [ #  # ]:          0 :     ensureIsValidIndex( nChildIndex );
     169 [ #  # ][ #  # ]:          0 :     return implGetColumn( nChildIndex );
                 [ #  # ]
     170                 :            : }
     171                 :            : 
     172                 :            : // XInterface -----------------------------------------------------------------
     173                 :            : 
     174                 :          0 : Any SAL_CALL AccessibleBrowseBoxTableBase::queryInterface( const uno::Type& rType )
     175                 :            :     throw ( uno::RuntimeException )
     176                 :            : {
     177         [ #  # ]:          0 :     Any aAny( BrowseBoxAccessibleElement::queryInterface( rType ) );
     178                 :          0 :     return aAny.hasValue() ?
     179 [ #  # ][ #  # ]:          0 :         aAny : AccessibleBrowseBoxTableImplHelper::queryInterface( rType );
     180                 :            : }
     181                 :            : 
     182                 :          0 : void SAL_CALL AccessibleBrowseBoxTableBase::acquire() throw ()
     183                 :            : {
     184                 :          0 :     BrowseBoxAccessibleElement::acquire();
     185                 :          0 : }
     186                 :            : 
     187                 :          0 : void SAL_CALL AccessibleBrowseBoxTableBase::release() throw ()
     188                 :            : {
     189                 :          0 :     BrowseBoxAccessibleElement::release();
     190                 :          0 : }
     191                 :            : 
     192                 :            : // XTypeProvider --------------------------------------------------------------
     193                 :            : 
     194                 :          0 : Sequence< uno::Type > SAL_CALL AccessibleBrowseBoxTableBase::getTypes()
     195                 :            :     throw ( uno::RuntimeException )
     196                 :            : {
     197                 :            :     return ::comphelper::concatSequences(
     198                 :            :         BrowseBoxAccessibleElement::getTypes(),
     199 [ #  # ][ #  # ]:          0 :         AccessibleBrowseBoxTableImplHelper::getTypes() );
                 [ #  # ]
     200                 :            : }
     201                 :            : 
     202                 :            : namespace
     203                 :            : {
     204                 :            :     class theAccessibleBrowseBoxTableBaseImplementationId : public rtl::Static< UnoTunnelIdInit, theAccessibleBrowseBoxTableBaseImplementationId > {};
     205                 :            : }
     206                 :            : 
     207                 :          0 : Sequence< sal_Int8 > SAL_CALL AccessibleBrowseBoxTableBase::getImplementationId()
     208                 :            :     throw ( uno::RuntimeException )
     209                 :            : {
     210                 :          0 :     return theAccessibleBrowseBoxTableBaseImplementationId::get().getSeq();
     211                 :            : }
     212                 :            : 
     213                 :            : // internal virtual methods ---------------------------------------------------
     214                 :            : 
     215                 :          0 : sal_Int32 AccessibleBrowseBoxTableBase::implGetRowCount() const
     216                 :            : {
     217                 :          0 :     return mpBrowseBox->GetRowCount();
     218                 :            : }
     219                 :            : 
     220                 :          0 : sal_Int32 AccessibleBrowseBoxTableBase::implGetColumnCount() const
     221                 :            : {
     222                 :          0 :     sal_uInt16 nColumns = mpBrowseBox->GetColumnCount();
     223                 :            :     // do not count the "handle column"
     224 [ #  # ][ #  # ]:          0 :     if( nColumns && implHasHandleColumn() )
                 [ #  # ]
     225                 :          0 :         --nColumns;
     226                 :          0 :     return nColumns;
     227                 :            : }
     228                 :            : 
     229                 :            : // internal helper methods ----------------------------------------------------
     230                 :            : 
     231                 :          0 : sal_Bool AccessibleBrowseBoxTableBase::implHasHandleColumn() const
     232                 :            : {
     233                 :          0 :     return mpBrowseBox->HasRowHeader();
     234                 :            : }
     235                 :            : 
     236                 :          0 : sal_uInt16 AccessibleBrowseBoxTableBase::implToVCLColumnPos( sal_Int32 nColumn ) const
     237                 :            : {
     238                 :          0 :     sal_uInt16 nVCLPos = 0;
     239 [ #  # ][ #  # ]:          0 :     if( (0 <= nColumn) && (nColumn < implGetColumnCount()) )
                 [ #  # ]
     240                 :            :     {
     241                 :            :         // regard "handle column"
     242         [ #  # ]:          0 :         if( implHasHandleColumn() )
     243                 :          0 :             ++nColumn;
     244                 :          0 :         nVCLPos = static_cast< sal_uInt16 >( nColumn );
     245                 :            :     }
     246                 :          0 :     return nVCLPos;
     247                 :            : }
     248                 :            : 
     249                 :          0 : sal_Int32 AccessibleBrowseBoxTableBase::implGetChildCount() const
     250                 :            : {
     251                 :          0 :     return implGetRowCount() * implGetColumnCount();
     252                 :            : }
     253                 :            : 
     254                 :          0 : sal_Int32 AccessibleBrowseBoxTableBase::implGetRow( sal_Int32 nChildIndex ) const
     255                 :            : {
     256                 :          0 :     sal_Int32 nColumns = implGetColumnCount();
     257         [ #  # ]:          0 :     return nColumns ? (nChildIndex / nColumns) : 0;
     258                 :            : }
     259                 :            : 
     260                 :          0 : sal_Int32 AccessibleBrowseBoxTableBase::implGetColumn( sal_Int32 nChildIndex ) const
     261                 :            : {
     262                 :          0 :     sal_Int32 nColumns = implGetColumnCount();
     263         [ #  # ]:          0 :     return nColumns ? (nChildIndex % nColumns) : 0;
     264                 :            : }
     265                 :            : 
     266                 :          0 : sal_Int32 AccessibleBrowseBoxTableBase::implGetChildIndex(
     267                 :            :         sal_Int32 nRow, sal_Int32 nColumn ) const
     268                 :            : {
     269                 :          0 :     return nRow * implGetColumnCount() + nColumn;
     270                 :            : }
     271                 :            : 
     272                 :          0 : sal_Bool AccessibleBrowseBoxTableBase::implIsRowSelected( sal_Int32 nRow ) const
     273                 :            : {
     274                 :          0 :     return mpBrowseBox->IsRowSelected( nRow );
     275                 :            : }
     276                 :            : 
     277                 :          0 : sal_Bool AccessibleBrowseBoxTableBase::implIsColumnSelected( sal_Int32 nColumn ) const
     278                 :            : {
     279         [ #  # ]:          0 :     if( implHasHandleColumn() )
     280                 :          0 :         --nColumn;
     281                 :          0 :     return mpBrowseBox->IsColumnSelected( nColumn );
     282                 :            : }
     283                 :            : 
     284                 :          0 : void AccessibleBrowseBoxTableBase::implSelectRow( sal_Int32 nRow, sal_Bool bSelect )
     285                 :            : {
     286                 :          0 :     mpBrowseBox->SelectRow( nRow, bSelect, sal_True );
     287                 :          0 : }
     288                 :            : 
     289                 :          0 : void AccessibleBrowseBoxTableBase::implSelectColumn( sal_Int32 nColumnPos, sal_Bool bSelect )
     290                 :            : {
     291                 :          0 :     mpBrowseBox->SelectColumn( (sal_uInt16)nColumnPos, bSelect );
     292                 :          0 : }
     293                 :            : 
     294                 :          0 : sal_Int32 AccessibleBrowseBoxTableBase::implGetSelectedRowCount() const
     295                 :            : {
     296                 :          0 :     return mpBrowseBox->GetSelectedRowCount();
     297                 :            : }
     298                 :            : 
     299                 :          0 : sal_Int32 AccessibleBrowseBoxTableBase::implGetSelectedColumnCount() const
     300                 :            : {
     301                 :          0 :     return mpBrowseBox->GetSelectedColumnCount();
     302                 :            : }
     303                 :            : 
     304                 :          0 : void AccessibleBrowseBoxTableBase::implGetSelectedRows( Sequence< sal_Int32 >& rSeq )
     305                 :            : {
     306                 :          0 :     mpBrowseBox->GetAllSelectedRows( rSeq );
     307                 :          0 : }
     308                 :            : 
     309                 :          0 : void AccessibleBrowseBoxTableBase::implGetSelectedColumns( Sequence< sal_Int32 >& rSeq )
     310                 :            : {
     311                 :          0 :     mpBrowseBox->GetAllSelectedColumns( rSeq );
     312                 :          0 : }
     313                 :            : 
     314                 :          0 : void AccessibleBrowseBoxTableBase::ensureIsValidRow( sal_Int32 nRow )
     315                 :            :     throw ( lang::IndexOutOfBoundsException )
     316                 :            : {
     317         [ #  # ]:          0 :     if( nRow >= implGetRowCount() )
     318                 :            :         throw lang::IndexOutOfBoundsException(
     319 [ #  # ][ #  # ]:          0 :             OUString( RTL_CONSTASCII_USTRINGPARAM( "row index is invalid" ) ), *this );
                 [ #  # ]
     320                 :          0 : }
     321                 :            : 
     322                 :          0 : void AccessibleBrowseBoxTableBase::ensureIsValidColumn( sal_Int32 nColumn )
     323                 :            :     throw ( lang::IndexOutOfBoundsException )
     324                 :            : {
     325         [ #  # ]:          0 :     if( nColumn >= implGetColumnCount() )
     326                 :            :         throw lang::IndexOutOfBoundsException(
     327 [ #  # ][ #  # ]:          0 :             OUString( RTL_CONSTASCII_USTRINGPARAM("column index is invalid") ), *this );
                 [ #  # ]
     328                 :          0 : }
     329                 :            : 
     330                 :          0 : void AccessibleBrowseBoxTableBase::ensureIsValidAddress(
     331                 :            :         sal_Int32 nRow, sal_Int32 nColumn )
     332                 :            :     throw ( lang::IndexOutOfBoundsException )
     333                 :            : {
     334                 :          0 :     ensureIsValidRow( nRow );
     335                 :          0 :     ensureIsValidColumn( nColumn );
     336                 :          0 : }
     337                 :            : 
     338                 :          0 : void AccessibleBrowseBoxTableBase::ensureIsValidIndex( sal_Int32 nChildIndex )
     339                 :            :     throw ( lang::IndexOutOfBoundsException )
     340                 :            : {
     341         [ #  # ]:          0 :     if( nChildIndex >= implGetChildCount() )
     342                 :            :         throw lang::IndexOutOfBoundsException(
     343 [ #  # ][ #  # ]:          0 :             OUString( RTL_CONSTASCII_USTRINGPARAM("child index is invalid") ), *this );
                 [ #  # ]
     344                 :          0 : }
     345                 :            : 
     346                 :            : // ============================================================================
     347                 :            : 
     348                 :            : } // namespace accessibility
     349                 :            : 
     350                 :            : // ============================================================================
     351                 :            : 
     352                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10