LCOV - code coverage report
Current view: top level - accessibility/source/extended - AccessibleGridControlTable.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 169 0.0 %
Date: 2012-08-25 Functions: 0 32 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 326 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/AccessibleGridControlTable.hxx"
      30                 :            : #include "accessibility/extended/AccessibleGridControlTableCell.hxx"
      31                 :            : #include <svtools/accessibletable.hxx>
      32                 :            : 
      33                 :            : // ============================================================================
      34                 :            : 
      35                 :            : using ::rtl::OUString;
      36                 :            : 
      37                 :            : using ::com::sun::star::uno::Reference;
      38                 :            : using ::com::sun::star::uno::Sequence;
      39                 :            : using ::com::sun::star::uno::Any;
      40                 :            : 
      41                 :            : using namespace ::com::sun::star;
      42                 :            : using namespace ::com::sun::star::accessibility;
      43                 :            : using namespace ::svt;
      44                 :            : using namespace ::svt::table;
      45                 :            : // ============================================================================
      46                 :            : 
      47                 :            : namespace accessibility {
      48                 :            : 
      49                 :            : // ============================================================================
      50                 :            : 
      51                 :          0 : AccessibleGridControlTable::AccessibleGridControlTable(
      52                 :            :         const Reference< XAccessible >& rxParent,
      53                 :            :         IAccessibleTable& rTable,
      54                 :            :         AccessibleTableControlObjType _eType) :
      55                 :          0 :     AccessibleGridControlTableBase( rxParent, rTable, _eType )
      56                 :            : {
      57                 :          0 : }
      58                 :            : 
      59                 :          0 : AccessibleGridControlTable::~AccessibleGridControlTable()
      60                 :            : {
      61         [ #  # ]:          0 : }
      62                 :            : 
      63                 :            : // XAccessibleContext ---------------------------------------------------------
      64                 :            : 
      65                 :            : Reference< XAccessible > SAL_CALL
      66                 :          0 : AccessibleGridControlTable::getAccessibleChild( sal_Int32 nChildIndex )
      67                 :            :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
      68                 :            : {
      69         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
      70         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
      71         [ #  # ]:          0 :     ensureIsAlive();
      72         [ #  # ]:          0 :     ensureIsValidIndex( nChildIndex );
      73 [ #  # ][ #  # ]:          0 :     return new AccessibleGridControlTableCell(this, m_aTable, nChildIndex/m_aTable.GetColumnCount(), nChildIndex%m_aTable.GetColumnCount(), TCTYPE_TABLECELL);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      74                 :            : }
      75                 :            : 
      76                 :          0 : sal_Int32 SAL_CALL AccessibleGridControlTable::getAccessibleIndexInParent()
      77                 :            :     throw ( uno::RuntimeException )
      78                 :            : {
      79                 :          0 :     ensureIsAlive();
      80 [ #  # ][ #  # ]:          0 :     if(m_aTable.HasRowHeader() && m_aTable.HasColHeader())
                 [ #  # ]
      81                 :          0 :         return 0;
      82 [ #  # ][ #  # ]:          0 :     else if((!m_aTable.HasRowHeader() && m_aTable.HasColHeader()) || (m_aTable.HasRowHeader() && !m_aTable.HasColHeader()) )
         [ #  # ][ #  # ]
                 [ #  # ]
      83                 :          0 :         return 1;
      84                 :            :     else
      85                 :          0 :         return 2;
      86                 :            : }
      87                 :            : 
      88                 :            : // XAccessibleComponent -------------------------------------------------------
      89                 :            : 
      90                 :            : Reference< XAccessible > SAL_CALL
      91                 :          0 : AccessibleGridControlTable::getAccessibleAtPoint( const awt::Point& rPoint )
      92                 :            :     throw ( uno::RuntimeException )
      93                 :            : {
      94         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
      95         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
      96         [ #  # ]:          0 :     ensureIsAlive();
      97                 :            : 
      98                 :          0 :     Reference< XAccessible > xChild;
      99                 :          0 :     sal_Int32 nRow = 0;
     100                 :          0 :     sal_Int32 nColumnPos = 0;
     101 [ #  # ][ #  # ]:          0 :     if( m_aTable.ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) ) )
     102 [ #  # ][ #  # ]:          0 :         xChild = new AccessibleGridControlTableCell(this, m_aTable, nRow, nColumnPos, TCTYPE_TABLECELL);
         [ #  # ][ #  # ]
     103                 :            : 
     104 [ #  # ][ #  # ]:          0 :     return xChild;
     105                 :            : }
     106                 :            : 
     107                 :          0 : void SAL_CALL AccessibleGridControlTable::grabFocus()
     108                 :            :     throw ( uno::RuntimeException )
     109                 :            : {
     110         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     111         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     112         [ #  # ]:          0 :     ensureIsAlive();
     113 [ #  # ][ #  # ]:          0 :     m_aTable.GrabFocus();
                 [ #  # ]
     114                 :          0 : }
     115                 :            : 
     116                 :          0 : Any SAL_CALL AccessibleGridControlTable::getAccessibleKeyBinding()
     117                 :            :     throw ( uno::RuntimeException )
     118                 :            : {
     119                 :          0 :     ensureIsAlive();
     120                 :          0 :     return Any();   // no special key bindings for data table
     121                 :            : }
     122                 :            : 
     123                 :            : // XAccessibleTable -----------------------------------------------------------
     124                 :            : 
     125                 :          0 : OUString SAL_CALL AccessibleGridControlTable::getAccessibleRowDescription( sal_Int32 nRow )
     126                 :            :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
     127                 :            : {
     128         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     129         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     130         [ #  # ]:          0 :     ensureIsAlive();
     131         [ #  # ]:          0 :     ensureIsValidRow( nRow );
     132 [ #  # ][ #  # ]:          0 :     return m_aTable.GetRowDescription( nRow );
                 [ #  # ]
     133                 :            : }
     134                 :            : 
     135                 :          0 : OUString SAL_CALL AccessibleGridControlTable::getAccessibleColumnDescription( sal_Int32 nColumn )
     136                 :            :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
     137                 :            : {
     138         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     139         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     140         [ #  # ]:          0 :     ensureIsAlive();
     141         [ #  # ]:          0 :     ensureIsValidColumn( nColumn );
     142 [ #  # ][ #  # ]:          0 :     return m_aTable.GetColumnDescription( (sal_uInt16)nColumn );
                 [ #  # ]
     143                 :            : }
     144                 :            : 
     145                 :          0 : Reference< XAccessibleTable > SAL_CALL AccessibleGridControlTable::getAccessibleRowHeaders()
     146                 :            :     throw ( uno::RuntimeException )
     147                 :            : {
     148         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     149         [ #  # ]:          0 :     ensureIsAlive();
     150 [ #  # ][ #  # ]:          0 :     if(m_aTable.HasColHeader())
     151         [ #  # ]:          0 :         return implGetHeaderBar( 1 );
     152                 :            :     else
     153 [ #  # ][ #  # ]:          0 :         return implGetHeaderBar( 0 );
     154                 :            : }
     155                 :            : 
     156                 :          0 : Reference< XAccessibleTable > SAL_CALL AccessibleGridControlTable::getAccessibleColumnHeaders()
     157                 :            :     throw ( uno::RuntimeException )
     158                 :            : {
     159         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     160         [ #  # ]:          0 :     ensureIsAlive();
     161 [ #  # ][ #  # ]:          0 :     return implGetHeaderBar( 0 );
     162                 :            : }
     163                 :            : 
     164                 :          0 : Sequence< sal_Int32 > SAL_CALL AccessibleGridControlTable::getSelectedAccessibleRows()
     165                 :            :     throw ( uno::RuntimeException )
     166                 :            : {
     167         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     168         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     169         [ #  # ]:          0 :     ensureIsAlive();
     170         [ #  # ]:          0 :     Sequence< sal_Int32 > aSelSeq;
     171         [ #  # ]:          0 :     implGetSelectedRows( aSelSeq );
     172 [ #  # ][ #  # ]:          0 :     return aSelSeq;
     173                 :            : }
     174                 :            : 
     175                 :            : //columns aren't selectable
     176                 :          0 : Sequence< sal_Int32 > SAL_CALL AccessibleGridControlTable::getSelectedAccessibleColumns()
     177                 :            :     throw ( uno::RuntimeException )
     178                 :            : {
     179                 :          0 :     Sequence< sal_Int32 > aSelSeq(0);
     180                 :          0 :     return aSelSeq;
     181                 :            : }
     182                 :            : 
     183                 :          0 : sal_Bool SAL_CALL AccessibleGridControlTable::isAccessibleRowSelected( sal_Int32 nRow )
     184                 :            :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
     185                 :            : {
     186         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     187         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     188         [ #  # ]:          0 :     ensureIsAlive();
     189         [ #  # ]:          0 :     ensureIsValidRow( nRow );
     190                 :          0 :     sal_Bool bSelected = sal_False;
     191         [ #  # ]:          0 :     Sequence< sal_Int32 > selectedRows = getSelectedAccessibleRows();
     192         [ #  # ]:          0 :     for(int i=0; i<selectedRows.getLength(); i++)
     193                 :            :     {
     194 [ #  # ][ #  # ]:          0 :         if(nRow == selectedRows[i])
     195                 :            :         {
     196                 :          0 :             bSelected = sal_True;
     197                 :          0 :             continue;
     198                 :            :         }
     199                 :            :     }
     200 [ #  # ][ #  # ]:          0 :     return bSelected;
                 [ #  # ]
     201                 :            : }
     202                 :            : 
     203                 :            : //columns aren't selectable
     204                 :          0 : sal_Bool SAL_CALL AccessibleGridControlTable::isAccessibleColumnSelected( sal_Int32 nColumn )
     205                 :            :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
     206                 :            : {
     207                 :            :     (void) nColumn;
     208                 :          0 :     return sal_False;
     209                 :            : }
     210                 :            : 
     211                 :          0 : Reference< XAccessible > SAL_CALL AccessibleGridControlTable::getAccessibleCellAt(
     212                 :            :         sal_Int32 nRow, sal_Int32 nColumn )
     213                 :            :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
     214                 :            : {
     215         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     216         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     217         [ #  # ]:          0 :     ensureIsAlive();
     218         [ #  # ]:          0 :     ensureIsValidAddress( nRow, nColumn );
     219 [ #  # ][ #  # ]:          0 :     return new AccessibleGridControlTableCell(this, m_aTable, nRow, nColumn, TCTYPE_TABLECELL);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     220                 :            : }
     221                 :            : 
     222                 :          0 : sal_Bool SAL_CALL AccessibleGridControlTable::isAccessibleSelected(
     223                 :            :         sal_Int32 nRow, sal_Int32 nColumn )
     224                 :            :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
     225                 :            : {
     226         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     227         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     228         [ #  # ]:          0 :     ensureIsAlive();
     229         [ #  # ]:          0 :     ensureIsValidAddress( nRow, nColumn );
     230                 :            :     (void) nColumn;
     231                 :            :     //selection of single cells not possible, so if row is selected, the cell will be selected too
     232 [ #  # ][ #  # ]:          0 :     return isAccessibleRowSelected(nRow);
                 [ #  # ]
     233                 :            : }
     234                 :          0 : void SAL_CALL AccessibleGridControlTable::selectAccessibleChild( sal_Int32 nChildIndex )
     235                 :            :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
     236                 :            : {
     237         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     238         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     239         [ #  # ]:          0 :     ensureIsAlive();
     240         [ #  # ]:          0 :     ensureIsValidIndex( nChildIndex );
     241         [ #  # ]:          0 :     sal_Int32 nColumns = m_aTable.GetColumnCount();
     242                 :          0 :     sal_Int32 nRow = (nChildIndex / nColumns);
     243 [ #  # ][ #  # ]:          0 :     m_aTable.SelectRow( nRow, sal_True );
                 [ #  # ]
     244                 :          0 : }
     245                 :          0 : sal_Bool SAL_CALL AccessibleGridControlTable::isAccessibleChildSelected( sal_Int32 nChildIndex )
     246                 :            :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
     247                 :            : {
     248         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     249         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     250         [ #  # ]:          0 :     ensureIsAlive();
     251         [ #  # ]:          0 :     ensureIsValidIndex( nChildIndex );
     252         [ #  # ]:          0 :     sal_Int32 nColumns = m_aTable.GetColumnCount();
     253                 :          0 :     sal_Int32 nRow = (nChildIndex / nColumns);
     254 [ #  # ][ #  # ]:          0 :     return isAccessibleRowSelected(nRow);
                 [ #  # ]
     255                 :            : }
     256                 :          0 : void SAL_CALL AccessibleGridControlTable::clearAccessibleSelection()
     257                 :            :     throw ( uno::RuntimeException )
     258                 :            : {
     259         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     260         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     261         [ #  # ]:          0 :     ensureIsAlive();
     262 [ #  # ][ #  # ]:          0 :     m_aTable.SelectAllRows( false );
                 [ #  # ]
     263                 :          0 : }
     264                 :          0 : void SAL_CALL AccessibleGridControlTable::selectAllAccessibleChildren()
     265                 :            :     throw ( uno::RuntimeException )
     266                 :            : {
     267         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     268         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     269         [ #  # ]:          0 :     ensureIsAlive();
     270         [ #  # ]:          0 :     Sequence< sal_Int32 > selectedRows = getSelectedAccessibleRows();
     271 [ #  # ][ #  # ]:          0 :     for(int i=0;i<m_aTable.GetRowCount();i++)
     272 [ #  # ][ #  # ]:          0 :         selectedRows[i]=i;
         [ #  # ][ #  # ]
     273                 :          0 : }
     274                 :          0 : sal_Int32 SAL_CALL AccessibleGridControlTable::getSelectedAccessibleChildCount()
     275                 :            :     throw ( uno::RuntimeException )
     276                 :            : {
     277         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     278         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     279         [ #  # ]:          0 :     ensureIsAlive();
     280         [ #  # ]:          0 :     Sequence< sal_Int32 > selectedRows = getSelectedAccessibleRows();
     281         [ #  # ]:          0 :     sal_Int32 nColumns = m_aTable.GetColumnCount();
     282 [ #  # ][ #  # ]:          0 :     return selectedRows.getLength()*nColumns;
                 [ #  # ]
     283                 :            : }
     284                 :            : Reference< XAccessible > SAL_CALL
     285                 :          0 : AccessibleGridControlTable::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
     286                 :            :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
     287                 :            : {
     288         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     289         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     290         [ #  # ]:          0 :     ensureIsAlive();
     291 [ #  # ][ #  # ]:          0 :     if(isAccessibleChildSelected(nSelectedChildIndex))
     292         [ #  # ]:          0 :         return getAccessibleChild(nSelectedChildIndex);
     293                 :            :     else
     294 [ #  # ][ #  # ]:          0 :         return NULL;
                 [ #  # ]
     295                 :            : }
     296                 :            : //not implemented yet, because only row selection possible
     297                 :          0 : void SAL_CALL AccessibleGridControlTable::deselectAccessibleChild(
     298                 :            :         sal_Int32 nSelectedChildIndex )
     299                 :            :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
     300                 :            : {
     301         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     302         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     303         [ #  # ]:          0 :     ensureIsAlive();
     304 [ #  # ][ #  # ]:          0 :     (void)nSelectedChildIndex;
     305                 :          0 : }
     306                 :            : // XInterface -----------------------------------------------------------------
     307                 :            : 
     308                 :          0 : Any SAL_CALL AccessibleGridControlTable::queryInterface( const uno::Type& rType )
     309                 :            :     throw ( uno::RuntimeException )
     310                 :            : {
     311         [ #  # ]:          0 :     Any aAny( AccessibleGridControlTableBase::queryInterface( rType ) );
     312                 :          0 :     return aAny.hasValue() ?
     313 [ #  # ][ #  # ]:          0 :         aAny : AccessibleGridControlTableImplHelper1::queryInterface( rType );
     314                 :            : }
     315                 :            : 
     316                 :          0 : void SAL_CALL AccessibleGridControlTable::acquire() throw ()
     317                 :            : {
     318                 :          0 :     AccessibleGridControlTableBase::acquire();
     319                 :          0 : }
     320                 :            : 
     321                 :          0 : void SAL_CALL AccessibleGridControlTable::release() throw ()
     322                 :            : {
     323                 :          0 :     AccessibleGridControlTableBase::release();
     324                 :          0 : }
     325                 :            : // XServiceInfo ---------------------------------------------------------------
     326                 :            : 
     327                 :          0 : OUString SAL_CALL AccessibleGridControlTable::getImplementationName()
     328                 :            :     throw ( uno::RuntimeException )
     329                 :            : {
     330                 :          0 :     return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleGridControlTable" ) );
     331                 :            : }
     332                 :            : 
     333                 :            : // internal virtual methods ---------------------------------------------------
     334                 :            : 
     335                 :          0 : Rectangle AccessibleGridControlTable::implGetBoundingBox()
     336                 :            : {
     337                 :          0 :     return m_aTable.calcTableRect();
     338                 :            : }
     339                 :            : 
     340                 :          0 : Rectangle AccessibleGridControlTable::implGetBoundingBoxOnScreen()
     341                 :            : {
     342                 :          0 :     return m_aTable.calcTableRect();
     343                 :            : }
     344                 :            : // internal helper methods ----------------------------------------------------
     345                 :          0 : Reference< XAccessibleTable > AccessibleGridControlTable::implGetHeaderBar(
     346                 :            :         sal_Int32 nChildIndex )
     347                 :            :     throw ( uno::RuntimeException )
     348                 :            : {
     349                 :          0 :     Reference< XAccessible > xRet;
     350         [ #  # ]:          0 :     Reference< XAccessibleContext > xContext( m_xParent, uno::UNO_QUERY );
     351         [ #  # ]:          0 :     if( xContext.is() )
     352                 :            :     {
     353                 :            :         try
     354                 :            :         {
     355 [ #  # ][ #  # ]:          0 :             xRet = xContext->getAccessibleChild( nChildIndex );
         [ #  # ][ #  # ]
     356                 :            :         }
     357         [ #  # ]:          0 :         catch (const lang::IndexOutOfBoundsException&)
     358                 :            :         {
     359                 :            :             OSL_FAIL( "implGetHeaderBar - wrong child index" );
     360                 :            :         }
     361                 :            :         // RuntimeException goes to caller
     362                 :            :     }
     363         [ #  # ]:          0 :     return Reference< XAccessibleTable >( xRet, uno::UNO_QUERY );
     364                 :            : }
     365                 :            : 
     366                 :            : // ============================================================================
     367                 :            : 
     368                 :            : } // namespace accessibility
     369                 :            : 
     370                 :            : // ============================================================================
     371                 :            : 
     372                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10