LCOV - code coverage report
Current view: top level - accessibility/source/extended - AccessibleGridControlTableCell.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 148 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 37 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             : 
      21             : #include "accessibility/extended/AccessibleGridControlTableCell.hxx"
      22             : #include <svtools/accessibletable.hxx>
      23             : #include "accessibility/extended/AccessibleGridControl.hxx"
      24             : #include <tools/gen.hxx>
      25             : #include <toolkit/helper/vclunohelper.hxx>
      26             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      27             : 
      28             : namespace accessibility
      29             : {
      30             :     namespace
      31             :     {
      32             :         // FIXME this is a copy'n'paste from
      33             :         // source/extended/AccessibleBrowseBoxTableCell.cxx, get rid of that...
      34           0 :         static void checkIndex_Impl( sal_Int32 _nIndex, const OUString& _sText ) throw (::com::sun::star::lang::IndexOutOfBoundsException)
      35             :         {
      36           0 :             if ( _nIndex >= _sText.getLength() )
      37           0 :                 throw ::com::sun::star::lang::IndexOutOfBoundsException();
      38           0 :         }
      39             :     }
      40             :     using namespace ::com::sun::star::lang;
      41             :     using namespace utl;
      42             :     using namespace comphelper;
      43             :     using ::accessibility::AccessibleGridControl;
      44             :     using namespace ::com::sun::star::uno;
      45             :     using ::com::sun::star::accessibility::XAccessible;
      46             :     using namespace ::com::sun::star::accessibility;
      47             :     using namespace ::svt;
      48             :     using namespace ::svt::table;
      49             : 
      50             : 
      51             : 
      52             :     // = AccessibleGridControlCell
      53             : 
      54             : 
      55           0 :     AccessibleGridControlCell::AccessibleGridControlCell(
      56             :             const Reference< XAccessible >& _rxParent, IAccessibleTable& _rTable,
      57             :             sal_Int32 _nRowPos, sal_uInt16 _nColPos, AccessibleTableControlObjType _eType )
      58             :         :AccessibleGridControlBase( _rxParent, _rTable, _eType )
      59             :         ,m_nRowPos( _nRowPos )
      60           0 :         ,m_nColPos( _nColPos )
      61             :     {
      62             :         // set accessible name here, because for that we need the position of the cell
      63             :         // and so the base class isn't capable of doing this
      64           0 :         OUString aAccName;
      65           0 :         if(_eType == TCTYPE_TABLECELL)
      66           0 :             aAccName = _rTable.GetAccessibleObjectName( TCTYPE_TABLECELL, _nRowPos, _nColPos );
      67           0 :         else if(_eType == TCTYPE_ROWHEADERCELL)
      68           0 :             aAccName = _rTable.GetAccessibleObjectName( TCTYPE_ROWHEADERCELL, _nRowPos, 0 );
      69           0 :         else if(_eType == TCTYPE_COLUMNHEADERCELL)
      70           0 :             aAccName = _rTable.GetAccessibleObjectName( TCTYPE_COLUMNHEADERCELL, 0, _nRowPos );
      71           0 :         implSetName( aAccName );
      72           0 :     }
      73             : 
      74             : 
      75           0 :     AccessibleGridControlCell::~AccessibleGridControlCell()
      76             :     {
      77           0 :     }
      78             : 
      79             : 
      80           0 :     void SAL_CALL AccessibleGridControlCell::grabFocus() throw ( RuntimeException, std::exception )
      81             :     {
      82           0 :         SolarMutexGuard aSolarGuard;
      83             : 
      84           0 :         m_aTable.GoToCell( m_nColPos, m_nRowPos );
      85           0 :     }
      86             : 
      87             :     // implementation of a table cell
      88           0 :     OUString AccessibleGridControlTableCell::implGetText()
      89             :     {
      90           0 :         ensureIsAlive();
      91           0 :         return m_aTable.GetAccessibleCellText( getRowPos(),  getColumnPos() );
      92             :     }
      93             : 
      94           0 :     ::com::sun::star::lang::Locale AccessibleGridControlTableCell::implGetLocale()
      95             :     {
      96           0 :         ensureIsAlive();
      97           0 :         return m_aTable.GetAccessible()->getAccessibleContext()->getLocale();
      98             :     }
      99             : 
     100           0 :     void AccessibleGridControlTableCell::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
     101             :     {
     102           0 :         nStartIndex = 0;
     103           0 :         nEndIndex = 0;
     104           0 :     }
     105             : 
     106           0 :     AccessibleGridControlTableCell::AccessibleGridControlTableCell(const Reference<XAccessible >& _rxParent,
     107             :                                 IAccessibleTable& _rTable,
     108             :                                 sal_Int32 _nRowPos,
     109             :                                 sal_uInt16 _nColPos,
     110             :                                 AccessibleTableControlObjType  eObjType)
     111           0 :         :AccessibleGridControlCell( _rxParent, _rTable, _nRowPos, _nColPos, eObjType )
     112             :     {
     113           0 :     }
     114             : 
     115             :     // XInterface -------------------------------------------------------------
     116             : 
     117             :     /** Queries for a new interface. */
     118           0 :     ::com::sun::star::uno::Any SAL_CALL AccessibleGridControlTableCell::queryInterface(
     119             :             const ::com::sun::star::uno::Type& rType )
     120             :         throw ( ::com::sun::star::uno::RuntimeException, std::exception )
     121             :     {
     122           0 :         Any aRet = AccessibleGridControlCell::queryInterface(rType);
     123           0 :         if ( !aRet.hasValue() )
     124           0 :             aRet = AccessibleTextHelper_BASE::queryInterface(rType);
     125           0 :         return aRet;
     126             :     }
     127             : 
     128             :     /** Aquires the object (calls acquire() on base class). */
     129           0 :     void SAL_CALL AccessibleGridControlTableCell::acquire() throw ()
     130             :     {
     131           0 :         AccessibleGridControlCell::acquire();
     132           0 :     }
     133             : 
     134             :     /** Releases the object (calls release() on base class). */
     135           0 :     void SAL_CALL AccessibleGridControlTableCell::release() throw ()
     136             :     {
     137           0 :         AccessibleGridControlCell::release();
     138           0 :     }
     139             : 
     140           0 :     ::com::sun::star::awt::Rectangle SAL_CALL AccessibleGridControlTableCell::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     141             :     {
     142           0 :         SolarMutexGuard aSolarGuard;
     143             : 
     144           0 :         ensureIsAlive();
     145           0 :         if ( !implIsValidIndex( nIndex, implGetText().getLength() ) )
     146           0 :             throw IndexOutOfBoundsException();
     147             : 
     148           0 :         return AWTRectangle( m_aTable.GetFieldCharacterBounds( getRowPos(), getColumnPos(), nIndex ) );
     149             :     }
     150             : 
     151           0 :     sal_Int32 SAL_CALL AccessibleGridControlTableCell::getIndexAtPoint( const ::com::sun::star::awt::Point& _aPoint ) throw (RuntimeException, std::exception)
     152             :     {
     153           0 :         SolarMutexGuard aSolarGuard;
     154             : 
     155           0 :         ensureIsAlive();
     156             : 
     157           0 :         return m_aTable.GetFieldIndexAtPoint( getRowPos(), getColumnPos(), VCLPoint( _aPoint ) );
     158             :     }
     159             : 
     160             :     /** @return
     161             :             The name of this class.
     162             :     */
     163           0 :     OUString SAL_CALL AccessibleGridControlTableCell::getImplementationName()
     164             :         throw ( ::com::sun::star::uno::RuntimeException, std::exception )
     165             :     {
     166           0 :         return OUString( "com.sun.star.accessibility.AccessibleGridControlTableCell" );
     167             :     }
     168             : 
     169             :     /** @return  The count of visible children. */
     170           0 :     sal_Int32 SAL_CALL AccessibleGridControlTableCell::getAccessibleChildCount()
     171             :         throw ( ::com::sun::star::uno::RuntimeException, std::exception )
     172             :     {
     173           0 :         return 0;
     174             :     }
     175             : 
     176             :     /** @return  The XAccessible interface of the specified child. */
     177             :     ::com::sun::star::uno::Reference<
     178             :         ::com::sun::star::accessibility::XAccessible > SAL_CALL
     179           0 :         AccessibleGridControlTableCell::getAccessibleChild( sal_Int32 )
     180             :             throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
     181             :                     ::com::sun::star::uno::RuntimeException, std::exception )
     182             :     {
     183           0 :         throw ::com::sun::star::lang::IndexOutOfBoundsException();
     184             :     }
     185             : 
     186             :     /** Creates a new AccessibleStateSetHelper and fills it with states of the
     187             :         current object.
     188             :         @return
     189             :             A filled AccessibleStateSetHelper.
     190             :     */
     191           0 :     ::utl::AccessibleStateSetHelper* AccessibleGridControlTableCell::implCreateStateSetHelper()
     192             :     {
     193           0 :         ::utl::AccessibleStateSetHelper* pStateSetHelper = new ::utl::AccessibleStateSetHelper;
     194             : 
     195           0 :         if( isAlive() )
     196             :         {
     197             :             // SHOWING done with mxParent
     198           0 :             if( implIsShowing() )
     199           0 :                 pStateSetHelper->AddState( AccessibleStateType::SHOWING );
     200             : 
     201           0 :             m_aTable.FillAccessibleStateSetForCell( *pStateSetHelper, getRowPos(), static_cast< sal_uInt16 >( getColumnPos() ) );
     202             :         }
     203             :         else
     204           0 :             pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
     205             : 
     206           0 :         return pStateSetHelper;
     207             :     }
     208             : 
     209             : 
     210             :     // XAccessible ------------------------------------------------------------
     211             : 
     212             :     /** @return  The XAccessibleContext interface of this object. */
     213           0 :     Reference< XAccessibleContext > SAL_CALL AccessibleGridControlTableCell::getAccessibleContext() throw ( RuntimeException, std::exception )
     214             :     {
     215           0 :         SolarMutexGuard g;
     216             : 
     217           0 :         ensureIsAlive();
     218           0 :         return this;
     219             :     }
     220             : 
     221             :     // XAccessibleContext -----------------------------------------------------
     222             : 
     223           0 :     sal_Int32 SAL_CALL AccessibleGridControlTableCell::getAccessibleIndexInParent()
     224             :             throw ( ::com::sun::star::uno::RuntimeException, std::exception )
     225             :     {
     226           0 :         SolarMutexGuard aSolarGuard;
     227             : 
     228           0 :         ensureIsAlive();
     229             : 
     230           0 :         return ( getRowPos() * m_aTable.GetColumnCount() ) + getColumnPos();
     231             :     }
     232             : 
     233           0 :     sal_Int32 SAL_CALL AccessibleGridControlTableCell::getCaretPosition(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     234             :     {
     235           0 :         return -1;
     236             :     }
     237           0 :     sal_Bool SAL_CALL AccessibleGridControlTableCell::setCaretPosition ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
     238             :     {
     239           0 :         SolarMutexGuard aSolarGuard;
     240             : 
     241           0 :         if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
     242           0 :             throw IndexOutOfBoundsException();
     243             : 
     244           0 :         return false;
     245             :     }
     246           0 :     sal_Unicode SAL_CALL AccessibleGridControlTableCell::getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
     247             :     {
     248           0 :         SolarMutexGuard aSolarGuard;
     249             : 
     250           0 :         return OCommonAccessibleText::getCharacter( nIndex );
     251             :     }
     252           0 :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL AccessibleGridControlTableCell::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< OUString >& ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
     253             :     {
     254           0 :         SolarMutexGuard aSolarGuard;
     255             : 
     256           0 :         OUString sText( implGetText() );
     257             : 
     258           0 :         if ( !implIsValidIndex( nIndex, sText.getLength() ) )
     259           0 :             throw IndexOutOfBoundsException();
     260             : 
     261           0 :         return ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >();
     262             :     }
     263           0 :     sal_Int32 SAL_CALL AccessibleGridControlTableCell::getCharacterCount(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     264             :     {
     265           0 :         SolarMutexGuard aSolarGuard;
     266             : 
     267           0 :         return OCommonAccessibleText::getCharacterCount(  );
     268             :     }
     269             : 
     270           0 :     OUString SAL_CALL AccessibleGridControlTableCell::getSelectedText(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     271             :     {
     272           0 :         SolarMutexGuard aSolarGuard;
     273             : 
     274           0 :         return OCommonAccessibleText::getSelectedText(  );
     275             :     }
     276           0 :     sal_Int32 SAL_CALL AccessibleGridControlTableCell::getSelectionStart(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     277             :     {
     278           0 :         SolarMutexGuard aSolarGuard;
     279             : 
     280           0 :         return OCommonAccessibleText::getSelectionStart(  );
     281             :     }
     282           0 :     sal_Int32 SAL_CALL AccessibleGridControlTableCell::getSelectionEnd(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     283             :     {
     284           0 :         SolarMutexGuard aSolarGuard;
     285             : 
     286           0 :         return OCommonAccessibleText::getSelectionEnd(  );
     287             :     }
     288           0 :     sal_Bool SAL_CALL AccessibleGridControlTableCell::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
     289             :     {
     290           0 :         SolarMutexGuard aSolarGuard;
     291             : 
     292           0 :         if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
     293           0 :             throw IndexOutOfBoundsException();
     294             : 
     295           0 :         return false;
     296             :     }
     297           0 :     OUString SAL_CALL AccessibleGridControlTableCell::getText(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     298             :     {
     299           0 :         SolarMutexGuard aSolarGuard;
     300             : 
     301           0 :         return OCommonAccessibleText::getText(  );
     302             :     }
     303           0 :     OUString SAL_CALL AccessibleGridControlTableCell::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
     304             :     {
     305           0 :         SolarMutexGuard aSolarGuard;
     306             : 
     307           0 :         return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
     308             :     }
     309           0 :     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleGridControlTableCell::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
     310             :     {
     311           0 :         SolarMutexGuard aSolarGuard;
     312             : 
     313           0 :         return OCommonAccessibleText::getTextAtIndex( nIndex ,aTextType);
     314             :     }
     315           0 :     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleGridControlTableCell::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
     316             :     {
     317           0 :         SolarMutexGuard aSolarGuard;
     318             : 
     319           0 :         return OCommonAccessibleText::getTextBeforeIndex( nIndex ,aTextType);
     320             :     }
     321           0 :     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleGridControlTableCell::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
     322             :     {
     323           0 :         SolarMutexGuard aSolarGuard;
     324             : 
     325           0 :         return OCommonAccessibleText::getTextBehindIndex( nIndex ,aTextType);
     326             :     }
     327           0 :     sal_Bool SAL_CALL AccessibleGridControlTableCell::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
     328             :     {
     329           0 :         SolarMutexGuard aSolarGuard;
     330             : 
     331           0 :         OUString sText = implGetText();
     332           0 :         checkIndex_Impl( nStartIndex, sText );
     333           0 :         checkIndex_Impl( nEndIndex, sText );
     334             : 
     335             :         //!!! don't know how to put a string into the clipboard
     336           0 :         return false;
     337             :     }
     338             : 
     339           0 :     Rectangle AccessibleGridControlTableCell::implGetBoundingBox()
     340             :     {
     341           0 :         vcl::Window* pParent = m_aTable.GetAccessibleParentWindow();
     342             :         DBG_ASSERT( pParent, "implGetBoundingBox - missing parent window" );
     343           0 :         Rectangle aGridRect = m_aTable.GetWindowExtentsRelative( pParent );
     344           0 :         sal_Int32 nIndex = getAccessibleIndexInParent();
     345           0 :         Rectangle aCellRect = m_aTable.calcCellRect(nIndex%m_aTable.GetColumnCount(), nIndex/m_aTable.GetColumnCount());
     346           0 :         long nX = aGridRect.Left() + aCellRect.Left();
     347           0 :         long nY = aGridRect.Top() + aCellRect.Top();
     348           0 :         Rectangle aCell( Point( nX, nY ), aCellRect.GetSize());
     349           0 :         return aCell;
     350             :     }
     351             : 
     352           0 :     Rectangle AccessibleGridControlTableCell::implGetBoundingBoxOnScreen()
     353             :     {
     354           0 :         Rectangle aGridRect = m_aTable.GetWindowExtentsRelative( NULL );
     355           0 :         sal_Int32 nIndex = getAccessibleIndexInParent();
     356           0 :         Rectangle aCellRect = m_aTable.calcCellRect(nIndex%m_aTable.GetColumnCount(), nIndex/m_aTable.GetColumnCount());
     357           0 :         long nX = aGridRect.Left() + aCellRect.Left();
     358           0 :         long nY = aGridRect.Top() + aCellRect.Top();
     359           0 :         Rectangle aCell( Point( nX, nY ), aCellRect.GetSize());
     360           0 :         return aCell;
     361             :     }
     362             : }
     363             : 
     364             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11