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

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

Generated by: LCOV version 1.10