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

Generated by: LCOV version 1.10