LCOV - code coverage report
Current view: top level - accessibility/source/extended - AccessibleGridControl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 135 0.0 %
Date: 2012-08-25 Functions: 0 25 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 262 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/AccessibleGridControl.hxx"
      30                 :            : #include "accessibility/extended/AccessibleGridControlTable.hxx"
      31                 :            : #include "accessibility/extended/AccessibleGridControlHeader.hxx"
      32                 :            : #include <svtools/accessibletable.hxx>
      33                 :            : #include <comphelper/types.hxx>
      34                 :            : #include <toolkit/helper/vclunohelper.hxx>
      35                 :            : 
      36                 :            : // ============================================================================
      37                 :            : 
      38                 :            : namespace accessibility
      39                 :            : {
      40                 :            : 
      41                 :            : // ============================================================================
      42                 :            : 
      43                 :            : using ::rtl::OUString;
      44                 :            : 
      45                 :            : using namespace ::com::sun::star::uno;
      46                 :            : using namespace ::com::sun::star;
      47                 :            : using namespace ::com::sun::star::lang;
      48                 :            : using namespace ::com::sun::star::accessibility;
      49                 :            : using namespace ::svt;
      50                 :            : using namespace ::svt::table;
      51                 :            : 
      52                 :            : // ============================================================================
      53                 :          0 : class AccessibleGridControl_Impl
      54                 :            : {
      55                 :            : public:
      56                 :            :     /// the XAccessible which created the AccessibleGridControl
      57                 :            :     WeakReference< XAccessible >                                m_aCreator;
      58                 :            : 
      59                 :            :     /** The data table child. */
      60                 :            :     Reference<
      61                 :            :         ::com::sun::star::accessibility::XAccessible >          m_xTable;
      62                 :            :     AccessibleGridControlTable*             m_pTable;
      63                 :            : 
      64                 :            :     /** The header bar for rows. */
      65                 :            :     Reference<
      66                 :            :         ::com::sun::star::accessibility::XAccessible >          m_xRowHeaderBar;
      67                 :            :     AccessibleGridControlHeader*                m_pRowHeaderBar;
      68                 :            : 
      69                 :            :     /** The header bar for columns (first row of the table). */
      70                 :            :     Reference<
      71                 :            :         ::com::sun::star::accessibility::XAccessible >          m_xColumnHeaderBar;
      72                 :            :     AccessibleGridControlHeader*                m_pColumnHeaderBar;
      73                 :            : };
      74                 :            : 
      75                 :          0 : AccessibleGridControl::AccessibleGridControl(
      76                 :            :             const Reference< XAccessible >& _rxParent, const Reference< XAccessible >& _rxCreator,
      77                 :            :             IAccessibleTable& _rTable )
      78                 :          0 :     : AccessibleGridControlBase( _rxParent, _rTable, TCTYPE_GRIDCONTROL )
      79                 :            : {
      80 [ #  # ][ #  # ]:          0 :     m_pImpl.reset( new AccessibleGridControl_Impl() );
      81         [ #  # ]:          0 :     m_pImpl->m_aCreator = _rxCreator;
      82                 :          0 : }
      83                 :            : 
      84                 :            : // -----------------------------------------------------------------------------
      85         [ #  # ]:          0 : AccessibleGridControl::~AccessibleGridControl()
      86                 :            : {
      87         [ #  # ]:          0 : }
      88                 :            : // -----------------------------------------------------------------------------
      89                 :            : 
      90                 :          0 : void SAL_CALL AccessibleGridControl::disposing()
      91                 :            : {
      92         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
      93                 :            : 
      94                 :          0 :     m_pImpl->m_pTable       = NULL;
      95                 :          0 :     m_pImpl->m_pColumnHeaderBar = NULL;
      96                 :          0 :     m_pImpl->m_pRowHeaderBar    = NULL;
      97         [ #  # ]:          0 :     m_pImpl->m_aCreator         = Reference< XAccessible >();
      98                 :            : 
      99                 :          0 :     Reference< XAccessible >  xTable = m_pImpl->m_xTable;
     100                 :            : 
     101         [ #  # ]:          0 :     Reference< XComponent > xComp( m_pImpl->m_xTable, UNO_QUERY );
     102         [ #  # ]:          0 :     if ( xComp.is() )
     103                 :            :     {
     104 [ #  # ][ #  # ]:          0 :         xComp->dispose();
     105                 :            :     }
     106                 :            : 
     107 [ #  # ][ #  # ]:          0 :     AccessibleGridControlBase::disposing();
     108                 :          0 : }
     109                 :            : // -----------------------------------------------------------------------------
     110                 :            : 
     111                 :            : // XAccessibleContext ---------------------------------------------------------
     112                 :            : 
     113                 :          0 : sal_Int32 SAL_CALL AccessibleGridControl::getAccessibleChildCount()
     114                 :            :     throw ( uno::RuntimeException )
     115                 :            : {
     116         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     117         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     118         [ #  # ]:          0 :     ensureIsAlive();
     119 [ #  # ][ #  # ]:          0 :     return m_aTable.GetAccessibleControlCount();
                 [ #  # ]
     120                 :            : }
     121                 :            : // -----------------------------------------------------------------------------
     122                 :            : 
     123                 :            : Reference< XAccessible > SAL_CALL
     124                 :          0 : AccessibleGridControl::getAccessibleChild( sal_Int32 nChildIndex )
     125                 :            :     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
     126                 :            : {
     127         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     128         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     129                 :            : 
     130 [ #  # ][ #  # ]:          0 :     if (nChildIndex<0 || nChildIndex>=getAccessibleChildCount())
         [ #  # ][ #  # ]
     131         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     132                 :            : 
     133                 :          0 :     Reference< XAccessible > xChild;
     134 [ #  # ][ #  # ]:          0 :     if (isAlive())
     135                 :            :     {
     136 [ #  # ][ #  # ]:          0 :         if(nChildIndex == 0 && m_aTable.HasColHeader())
         [ #  # ][ #  # ]
     137                 :            :         {
     138         [ #  # ]:          0 :             if(!m_pImpl->m_xColumnHeaderBar.is())
     139                 :            :             {
     140 [ #  # ][ #  # ]:          0 :                 AccessibleGridControlHeader* pColHeaderBar = new AccessibleGridControlHeader(m_pImpl->m_aCreator, m_aTable, svt::table::TCTYPE_COLUMNHEADERBAR);
     141 [ #  # ][ #  # ]:          0 :                 m_pImpl->m_xColumnHeaderBar = pColHeaderBar;
     142                 :            :             }
     143         [ #  # ]:          0 :             xChild = m_pImpl->m_xColumnHeaderBar;
     144                 :            :         }
     145 [ #  # ][ #  # ]:          0 :         else if(m_aTable.HasRowHeader() && (nChildIndex == 1 || nChildIndex == 0))
         [ #  # ][ #  # ]
                 [ #  # ]
     146                 :            :         {
     147         [ #  # ]:          0 :             if(!m_pImpl->m_xRowHeaderBar.is())
     148                 :            :             {
     149 [ #  # ][ #  # ]:          0 :                 AccessibleGridControlHeader* pRowHeaderBar = new AccessibleGridControlHeader(m_pImpl->m_aCreator, m_aTable, svt::table::TCTYPE_ROWHEADERBAR);
     150 [ #  # ][ #  # ]:          0 :                 m_pImpl->m_xRowHeaderBar = pRowHeaderBar;
     151                 :            :             }
     152         [ #  # ]:          0 :             xChild = m_pImpl->m_xRowHeaderBar;
     153                 :            :         }
     154                 :            :         else
     155                 :            :         {
     156 [ #  # ][ #  # ]:          0 :             AccessibleGridControlTable* pTable = new AccessibleGridControlTable(m_pImpl->m_aCreator, m_aTable, svt::table::TCTYPE_TABLE);
     157 [ #  # ][ #  # ]:          0 :             m_pImpl->m_xTable = pTable;
     158         [ #  # ]:          0 :             xChild = m_pImpl->m_xTable;
     159                 :            :         }
     160                 :            :     }
     161 [ #  # ][ #  # ]:          0 :     return xChild;
     162                 :            : }
     163                 :            : // -----------------------------------------------------------------------------
     164                 :            : 
     165                 :          0 : sal_Int16 SAL_CALL AccessibleGridControl::getAccessibleRole()
     166                 :            :     throw ( uno::RuntimeException )
     167                 :            : {
     168                 :          0 :     ensureIsAlive();
     169                 :          0 :     return AccessibleRole::PANEL;
     170                 :            : }
     171                 :            : // -----------------------------------------------------------------------------
     172                 :            : 
     173                 :            : // XAccessibleComponent -------------------------------------------------------
     174                 :            : 
     175                 :            : Reference< XAccessible > SAL_CALL
     176                 :          0 : AccessibleGridControl::getAccessibleAtPoint( const awt::Point& rPoint )
     177                 :            :     throw ( uno::RuntimeException )
     178                 :            : {
     179         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     180         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     181         [ #  # ]:          0 :     ensureIsAlive();
     182                 :            : 
     183                 :          0 :     Reference< XAccessible > xChild;
     184                 :          0 :     sal_Int32 nIndex = 0;
     185 [ #  # ][ #  # ]:          0 :     if( m_aTable.ConvertPointToControlIndex( nIndex, VCLPoint( rPoint ) ) )
     186 [ #  # ][ #  # ]:          0 :         xChild = m_aTable.CreateAccessibleControl( nIndex );
     187                 :            :     else
     188                 :            :     {
     189                 :            :         // try whether point is in one of the fixed children
     190                 :            :         // (table, header bars, corner control)
     191                 :          0 :         Point aPoint( VCLPoint( rPoint ) );
     192 [ #  # ][ #  # ]:          0 :         for( nIndex = 0; (nIndex < 3) && !xChild.is(); ++nIndex )
                 [ #  # ]
     193                 :            :         {
     194         [ #  # ]:          0 :             Reference< XAccessible > xCurrChild( implGetFixedChild( nIndex ) );
     195                 :            :             Reference< XAccessibleComponent >
     196         [ #  # ]:          0 :             xCurrChildComp( xCurrChild, uno::UNO_QUERY );
     197                 :            : 
     198 [ #  # ][ #  # ]:          0 :             if( xCurrChildComp.is() &&
                 [ #  # ]
     199 [ #  # ][ #  # ]:          0 :                 VCLRectangle( xCurrChildComp->getBounds() ).IsInside( aPoint ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     200         [ #  # ]:          0 :             xChild = xCurrChild;
     201                 :          0 :         }
     202                 :            :     }
     203 [ #  # ][ #  # ]:          0 :     return xChild;
     204                 :            : }
     205                 :            : // -----------------------------------------------------------------------------
     206                 :            : 
     207                 :          0 : void SAL_CALL AccessibleGridControl::grabFocus()
     208                 :            :     throw ( uno::RuntimeException )
     209                 :            : {
     210         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     211         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( getOslMutex() );
     212         [ #  # ]:          0 :     ensureIsAlive();
     213 [ #  # ][ #  # ]:          0 :         m_aTable.GrabFocus();
                 [ #  # ]
     214                 :          0 : }
     215                 :            : // -----------------------------------------------------------------------------
     216                 :            : 
     217                 :          0 : Any SAL_CALL AccessibleGridControl::getAccessibleKeyBinding()
     218                 :            :     throw ( uno::RuntimeException )
     219                 :            : {
     220                 :          0 :     ensureIsAlive();
     221                 :          0 :     return Any();
     222                 :            : }
     223                 :            : // -----------------------------------------------------------------------------
     224                 :            : 
     225                 :            : // XServiceInfo ---------------------------------------------------------------
     226                 :            : 
     227                 :          0 : OUString SAL_CALL AccessibleGridControl::getImplementationName()
     228                 :            :     throw ( uno::RuntimeException )
     229                 :            : {
     230                 :          0 :     return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleGridControl" ) );
     231                 :            : }
     232                 :            : // -----------------------------------------------------------------------------
     233                 :            : 
     234                 :            : // internal virtual methods ---------------------------------------------------
     235                 :            : 
     236                 :          0 : Rectangle AccessibleGridControl::implGetBoundingBox()
     237                 :            : {
     238                 :          0 :     Window* pParent = m_aTable.GetAccessibleParentWindow();
     239                 :            :     OSL_ENSURE( pParent, "implGetBoundingBox - missing parent window" );
     240                 :          0 :     return m_aTable.GetWindowExtentsRelative( pParent );
     241                 :            : }
     242                 :            : // -----------------------------------------------------------------------------
     243                 :            : 
     244                 :          0 : Rectangle AccessibleGridControl::implGetBoundingBoxOnScreen()
     245                 :            : {
     246                 :          0 :     return m_aTable.GetWindowExtentsRelative( NULL );
     247                 :            : }
     248                 :            : // internal helper methods ----------------------------------------------------
     249                 :            : 
     250                 :          0 : Reference< XAccessible > AccessibleGridControl::implGetTable()
     251                 :            : {
     252         [ #  # ]:          0 :     if( !m_pImpl->m_xTable.is() )
     253                 :            :     {
     254                 :          0 :         m_pImpl->m_pTable = createAccessibleTable();
     255         [ #  # ]:          0 :         m_pImpl->m_xTable  = m_pImpl->m_pTable;
     256                 :            :     }
     257                 :          0 :     return m_pImpl->m_xTable;
     258                 :            : }
     259                 :            : // -----------------------------------------------------------------------------
     260                 :            : 
     261                 :            : Reference< XAccessible >
     262                 :          0 : AccessibleGridControl::implGetHeaderBar( AccessibleTableControlObjType eObjType )
     263                 :            : {
     264                 :          0 :     Reference< XAccessible > xRet;
     265                 :          0 :     Reference< XAccessible >* pxMember = NULL;
     266                 :            : 
     267         [ #  # ]:          0 :     if( eObjType == TCTYPE_ROWHEADERBAR )
     268                 :          0 :         pxMember = &m_pImpl->m_xRowHeaderBar;
     269         [ #  # ]:          0 :     else if( eObjType ==  TCTYPE_COLUMNHEADERBAR )
     270                 :          0 :         pxMember = &m_pImpl->m_xColumnHeaderBar;
     271                 :            : 
     272         [ #  # ]:          0 :     if( pxMember )
     273                 :            :     {
     274         [ #  # ]:          0 :         if( !pxMember->is() )
     275                 :            :         {
     276                 :            :             AccessibleGridControlHeader* pHeaderBar = new AccessibleGridControlHeader(
     277 [ #  # ][ #  # ]:          0 :                 (Reference< XAccessible >)m_pImpl->m_aCreator, m_aTable, eObjType );
     278                 :            : 
     279         [ #  # ]:          0 :             if ( TCTYPE_COLUMNHEADERBAR == eObjType)
     280                 :          0 :                 m_pImpl->m_pColumnHeaderBar = pHeaderBar;
     281                 :            :             else
     282                 :          0 :                 m_pImpl->m_pRowHeaderBar    = pHeaderBar;
     283                 :            : 
     284 [ #  # ][ #  # ]:          0 :             *pxMember = pHeaderBar;
     285                 :            :         }
     286         [ #  # ]:          0 :         xRet = *pxMember;
     287                 :            :     }
     288                 :          0 :     return xRet;
     289                 :            : }
     290                 :            : // -----------------------------------------------------------------------------
     291                 :            : Reference< XAccessible >
     292                 :          0 : AccessibleGridControl::implGetFixedChild( sal_Int32 nChildIndex )
     293                 :            : {
     294                 :          0 :     Reference< XAccessible > xRet;
     295   [ #  #  #  # ]:          0 :     switch( nChildIndex )
     296                 :            :     {
     297                 :            :           case TCINDEX_COLUMNHEADERBAR:
     298 [ #  # ][ #  # ]:          0 :             xRet = implGetHeaderBar( TCTYPE_COLUMNHEADERBAR );
     299                 :          0 :         break;
     300                 :            :         case TCINDEX_ROWHEADERBAR:
     301 [ #  # ][ #  # ]:          0 :             xRet = implGetHeaderBar( TCTYPE_ROWHEADERBAR );
     302                 :          0 :         break;
     303                 :            :         case TCINDEX_TABLE:
     304 [ #  # ][ #  # ]:          0 :             xRet = implGetTable();
     305                 :          0 :         break;
     306                 :            :     }
     307                 :          0 :     return xRet;
     308                 :            : }
     309                 :            : // -----------------------------------------------------------------------------
     310                 :          0 : AccessibleGridControlTable* AccessibleGridControl::createAccessibleTable()
     311                 :            : {
     312         [ #  # ]:          0 :     Reference< XAccessible > xCreator = (Reference< XAccessible >)m_pImpl->m_aCreator;
     313                 :            :         OSL_ENSURE( xCreator.is(), "accessibility/extended/AccessibleGirdControl::createAccessibleTable: my creator died - how this?" );
     314         [ #  # ]:          0 :     return new AccessibleGridControlTable( xCreator, m_aTable, TCTYPE_TABLE );
     315                 :            : }
     316                 :            : // ============================================================================
     317                 :            : // = AccessibleGridControlAccess
     318                 :            : // ============================================================================
     319                 :            : 
     320                 :            : // -----------------------------------------------------------------------------
     321                 :          0 : AccessibleGridControlAccess::AccessibleGridControlAccess( const Reference< XAccessible >& _rxParent, IAccessibleTable& _rTable )
     322                 :            :         :m_xParent( _rxParent )
     323                 :            :         ,m_rTable( _rTable )
     324         [ #  # ]:          0 :         ,m_pContext( NULL )
     325                 :            : {
     326                 :          0 : }
     327                 :            : 
     328                 :            : // -----------------------------------------------------------------------------
     329         [ #  # ]:          0 : AccessibleGridControlAccess::~AccessibleGridControlAccess()
     330                 :            : {
     331         [ #  # ]:          0 : }
     332                 :            : 
     333                 :            : // -----------------------------------------------------------------------------
     334                 :          0 : void AccessibleGridControlAccess::dispose()
     335                 :            : {
     336         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
     337                 :            : 
     338                 :          0 :     m_pContext = NULL;
     339 [ #  # ][ #  # ]:          0 :     ::comphelper::disposeComponent( m_xContext );
     340                 :          0 : }
     341                 :            : 
     342                 :            : // -----------------------------------------------------------------------------
     343                 :          0 : Reference< XAccessibleContext > SAL_CALL AccessibleGridControlAccess::getAccessibleContext() throw ( RuntimeException )
     344                 :            : {
     345         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
     346                 :            : 
     347                 :            :     OSL_ENSURE( ( m_pContext && m_xContext.is() ) || ( !m_pContext && !m_xContext.is() ),
     348                 :            :         "accessibility/extended/AccessibleGridControlAccess::getAccessibleContext: inconsistency!" );
     349                 :            : 
     350                 :            :     // if the context died meanwhile (we're no listener, so it won't tell us explicitily when this happens),
     351                 :            :     // then reset an re-create.
     352 [ #  # ][ #  # ]:          0 :     if ( m_pContext && !m_pContext->isAlive() )
         [ #  # ][ #  # ]
     353 [ #  # ][ #  # ]:          0 :         m_xContext = m_pContext = NULL;
     354                 :            : 
     355         [ #  # ]:          0 :     if ( !m_xContext.is() )
     356 [ #  # ][ #  # ]:          0 :         m_xContext = m_pContext = new AccessibleGridControl( m_xParent, this, m_rTable );
         [ #  # ][ #  # ]
     357                 :            : 
     358         [ #  # ]:          0 :     return m_xContext;
     359                 :            : }
     360                 :            : 
     361                 :            : // -----------------------------------------------------------------------------
     362                 :          0 : bool AccessibleGridControlAccess::isContextAlive() const
     363                 :            : {
     364 [ #  # ][ #  # ]:          0 :     return  ( NULL != m_pContext ) && m_pContext->isAlive();
     365                 :            : }
     366                 :            : 
     367                 :            : // ============================================================================
     368                 :            : 
     369                 :            : }   // namespace accessibility
     370                 :            : 
     371                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10