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

Generated by: LCOV version 1.10