LCOV - code coverage report
Current view: top level - accessibility/source/standard - vclxaccessibletoolbox.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 169 405 41.7 %
Date: 2012-08-25 Functions: 28 57 49.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 150 716 20.9 %

           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/standard/vclxaccessibletoolbox.hxx>
      30                 :            : #include <accessibility/standard/vclxaccessibletoolboxitem.hxx>
      31                 :            : #include <toolkit/helper/convert.hxx>
      32                 :            : 
      33                 :            : #include <unotools/accessiblestatesethelper.hxx>
      34                 :            : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      35                 :            : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      36                 :            : #include <com/sun/star/lang/XUnoTunnel.hpp>
      37                 :            : #include <vcl/toolbox.hxx>
      38                 :            : #include <comphelper/accessiblewrapper.hxx>
      39                 :            : #include <comphelper/processfactory.hxx>
      40                 :            : 
      41                 :            : using namespace ::comphelper;
      42                 :            : using namespace ::com::sun::star;
      43                 :            : using namespace ::com::sun::star::uno;
      44                 :            : using namespace ::com::sun::star::lang;
      45                 :            : using namespace ::com::sun::star::accessibility;
      46                 :            : 
      47                 :            : namespace
      48                 :            : {
      49                 :            :     // =========================================================================
      50                 :            :     // = OToolBoxWindowItemContext
      51                 :            :     // =========================================================================
      52                 :            :     /** XAccessibleContext implementation for a toolbox item which is represented by a VCL Window
      53                 :            :     */
      54         [ -  + ]:         20 :     class OToolBoxWindowItemContext : public OAccessibleContextWrapper
      55                 :            :     {
      56                 :            :         sal_Int32 m_nIndexInParent;
      57                 :            :     public:
      58                 :         10 :         OToolBoxWindowItemContext(sal_Int32 _nIndexInParent,
      59                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
      60                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >& _rxInnerAccessibleContext,
      61                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxOwningAccessible,
      62                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParentAccessible
      63                 :            :             ) : OAccessibleContextWrapper(
      64                 :            :             _rxORB,
      65                 :            :             _rxInnerAccessibleContext,
      66                 :            :             _rxOwningAccessible,
      67                 :            :             _rxParentAccessible     )
      68                 :         10 :             ,m_nIndexInParent(_nIndexInParent)
      69                 :            :         {
      70                 :         10 :         }
      71                 :            :         virtual sal_Int32 SAL_CALL getAccessibleIndexInParent(  ) throw (::com::sun::star::uno::RuntimeException);
      72                 :            :     };
      73                 :            : 
      74                 :            :     // -------------------------------------------------------------------------
      75                 :          2 :     sal_Int32 SAL_CALL OToolBoxWindowItemContext::getAccessibleIndexInParent(  ) throw (::com::sun::star::uno::RuntimeException)
      76                 :            :     {
      77         [ +  - ]:          2 :         ::osl::MutexGuard aGuard( m_aMutex );
      78         [ +  - ]:          2 :         return m_nIndexInParent;
      79                 :            :     }
      80                 :            : 
      81                 :            :     // =========================================================================
      82                 :            :     // = OToolBoxWindowItem
      83                 :            :     // =========================================================================
      84                 :            :     typedef ::cppu::ImplHelper1 <   XUnoTunnel
      85                 :            :                                 >   OToolBoxWindowItem_Base;
      86                 :            : 
      87                 :            :     /** XAccessible implementation for a toolbox item which is represented by a VCL Window
      88                 :            :     */
      89         [ #  # ]:          0 :     class OToolBoxWindowItem
      90                 :            :             :public OAccessibleWrapper
      91                 :            :             ,public OToolBoxWindowItem_Base
      92                 :            :     {
      93                 :            :     private:
      94                 :            :         sal_Int32 m_nIndexInParent;
      95                 :            : 
      96                 :            :     public:
      97                 :          0 :         inline sal_Int32    getIndexInParent() const                    { return m_nIndexInParent; }
      98                 :          0 :         inline void         setIndexInParent( sal_Int32 _nNewIndex )    { m_nIndexInParent = _nNewIndex; }
      99                 :            : 
     100                 :            :         static  sal_Bool    isWindowItem( const Reference< XAccessible >& _rxAcc, OToolBoxWindowItem** /* [out] */ _ppImplementation = NULL );
     101                 :            : 
     102                 :            :     public:
     103                 :         18 :         OToolBoxWindowItem(sal_Int32 _nIndexInParent,
     104                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
     105                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxInnerAccessible,
     106                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParentAccessible
     107                 :            :             ) : OAccessibleWrapper(
     108                 :            :             _rxORB,
     109                 :            :             _rxInnerAccessible,
     110                 :            :             _rxParentAccessible)
     111                 :         18 :             ,m_nIndexInParent(_nIndexInParent)
     112                 :            :         {
     113                 :         18 :         }
     114                 :            : 
     115                 :            :     protected:
     116                 :            :         // XInterface
     117                 :            :         DECLARE_XINTERFACE( )
     118                 :            :         DECLARE_XTYPEPROVIDER( )
     119                 :            : 
     120                 :            :         // OAccessibleWrapper
     121                 :            :         virtual OAccessibleContextWrapper* createAccessibleContext(
     122                 :            :                 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >& _rxInnerContext
     123                 :            :             );
     124                 :            : 
     125                 :            :         // XUnoTunnel
     126                 :            :         virtual sal_Int64 SAL_CALL getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw (RuntimeException);
     127                 :            :         static Sequence< sal_Int8 > getUnoTunnelImplementationId();
     128                 :            :     };
     129                 :            : 
     130                 :            :     // -------------------------------------------------------------------------
     131 [ -  + ][ #  # ]:       1048 :     IMPLEMENT_FORWARD_XINTERFACE2( OToolBoxWindowItem, OAccessibleWrapper, OToolBoxWindowItem_Base )
     132 [ #  # ][ #  # ]:          0 :     IMPLEMENT_FORWARD_XTYPEPROVIDER2( OToolBoxWindowItem, OAccessibleWrapper, OToolBoxWindowItem_Base )
                 [ #  # ]
     133                 :            : 
     134                 :            :     // -------------------------------------------------------------------------
     135                 :         10 :     OAccessibleContextWrapper* OToolBoxWindowItem::createAccessibleContext(
     136                 :            :             const Reference< XAccessibleContext >& _rxInnerContext )
     137                 :            :     {
     138 [ +  - ][ +  - ]:         10 :         return new OToolBoxWindowItemContext( m_nIndexInParent,getORB(), _rxInnerContext, this, getParent() );
     139                 :            :     }
     140                 :            : 
     141                 :            :     //--------------------------------------------------------------------
     142                 :        982 :     sal_Bool OToolBoxWindowItem::isWindowItem( const Reference< XAccessible >& _rxAcc, OToolBoxWindowItem** /* [out] */ _ppImplementation )
     143                 :            :     {
     144                 :        982 :         OToolBoxWindowItem* pImplementation = NULL;
     145                 :            : 
     146         [ +  - ]:        982 :         Reference< XUnoTunnel > xTunnel( _rxAcc, UNO_QUERY );
     147         [ -  + ]:        982 :         if ( xTunnel.is() )
     148 [ #  # ][ #  # ]:          0 :             pImplementation = reinterpret_cast< OToolBoxWindowItem* >( xTunnel->getSomething( getUnoTunnelImplementationId() ) );
         [ #  # ][ #  # ]
     149                 :            : 
     150         [ +  - ]:        982 :         if ( _ppImplementation )
     151                 :        982 :             *_ppImplementation = pImplementation;
     152                 :            : 
     153                 :        982 :         return NULL != pImplementation;
     154                 :            :     }
     155                 :            : 
     156                 :            :     //--------------------------------------------------------------------
     157                 :          0 :     Sequence< sal_Int8 > OToolBoxWindowItem::getUnoTunnelImplementationId()
     158                 :            :     {
     159                 :            :         static ::cppu::OImplementationId * pId = 0;
     160         [ #  # ]:          0 :         if (! pId)
     161                 :            :         {
     162 [ #  # ][ #  # ]:          0 :             ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     163         [ #  # ]:          0 :             if (! pId)
     164                 :            :             {
     165 [ #  # ][ #  # ]:          0 :                 static ::cppu::OImplementationId aId;
     166                 :          0 :                 pId = &aId;
     167         [ #  # ]:          0 :             }
     168                 :            :         }
     169                 :          0 :         return pId->getImplementationId();
     170                 :            :     }
     171                 :            : 
     172                 :            :     //--------------------------------------------------------------------
     173                 :          0 :     sal_Int64 SAL_CALL OToolBoxWindowItem::getSomething( const Sequence< sal_Int8 >& _rId ) throw (RuntimeException)
     174                 :            :     {
     175 [ #  # ][ #  # ]:          0 :         if  (   ( 16 == _rId.getLength() )
                 [ #  # ]
     176 [ #  # ][ #  # ]:          0 :             &&  ( 0 == rtl_compareMemory( getUnoTunnelImplementationId().getConstArray(),  _rId.getConstArray(), 16 ) )
         [ #  # ][ #  # ]
     177                 :            :             )
     178                 :          0 :             return reinterpret_cast< sal_Int64>( this );
     179                 :            : 
     180                 :          0 :         return 0;
     181                 :            :     }
     182                 :            : }
     183                 :            : 
     184                 :            : // -----------------------------------------------------------------------------
     185                 :            : // VCLXAccessibleToolBox
     186                 :            : // -----------------------------------------------------------------------------
     187                 :         30 : VCLXAccessibleToolBox::VCLXAccessibleToolBox( VCLXWindow* pVCLXWindow ) :
     188                 :            : 
     189         [ +  - ]:         30 :     VCLXAccessibleComponent( pVCLXWindow )
     190                 :            : 
     191                 :            : {
     192                 :         30 : }
     193                 :            : // -----------------------------------------------------------------------------
     194                 :         30 : VCLXAccessibleToolBox::~VCLXAccessibleToolBox()
     195                 :            : {
     196         [ -  + ]:         60 : }
     197                 :            : // -----------------------------------------------------------------------------
     198                 :          0 : VCLXAccessibleToolBoxItem* VCLXAccessibleToolBox::GetItem_Impl( sal_Int32 _nPos, bool _bMustHaveFocus )
     199                 :            : {
     200                 :          0 :     VCLXAccessibleToolBoxItem* pItem = NULL;
     201                 :          0 :     ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
     202 [ #  # ][ #  # ]:          0 :     if ( pToolBox && ( !_bMustHaveFocus || pToolBox->HasFocus() ) )
         [ #  # ][ #  # ]
     203                 :            :     {
     204         [ #  # ]:          0 :         ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find( _nPos );
     205                 :            :         // returns only toolbox buttons, not windows
     206 [ #  # ][ #  # ]:          0 :         if ( aIter != m_aAccessibleChildren.end()  && !aIter->second.is())
         [ #  # ][ #  # ]
     207 [ #  # ][ #  # ]:          0 :             pItem = static_cast< VCLXAccessibleToolBoxItem* >( aIter->second.get() );
     208                 :            :     }
     209                 :            : 
     210                 :          0 :     return pItem;
     211                 :            : }
     212                 :            : // -----------------------------------------------------------------------------
     213                 :            : 
     214                 :          2 : void VCLXAccessibleToolBox::UpdateFocus_Impl()
     215                 :            : {
     216                 :          2 :     ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
     217         [ -  + ]:          2 :     if( !pToolBox )
     218                 :          2 :         return;
     219                 :            : 
     220                 :            :     // submit events only if toolbox has the focus to avoid sending events due to mouse move
     221                 :          2 :     sal_Bool bHasFocus = sal_False;
     222         [ +  - ]:          2 :     if ( pToolBox->HasFocus() )
     223                 :          2 :         bHasFocus = sal_True;
     224                 :            :     else
     225                 :            :     {
     226                 :            :         // check for subtoolbar, i.e. check if our parent is a toolbar
     227         [ #  # ]:          0 :         ToolBox* pToolBoxParent = dynamic_cast< ToolBox* >( pToolBox->GetParent() );
     228                 :            :         // subtoolbars never get the focus as key input is just forwarded, so check if the parent toolbar has it
     229 [ #  # ][ #  # ]:          0 :         if ( pToolBoxParent && pToolBoxParent->HasFocus() )
                 [ #  # ]
     230                 :          0 :             bHasFocus = sal_True;
     231                 :            :     }
     232                 :            : 
     233         [ +  - ]:          2 :     if ( bHasFocus )
     234                 :            :     {
     235                 :          2 :         sal_uInt16 nHighlightItemId = pToolBox->GetHighlightItemId();
     236                 :          2 :         sal_uInt16 nFocusCount = 0;
     237         [ +  - ]:         14 :         for ( ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.begin();
     238                 :          6 :               aIter != m_aAccessibleChildren.end(); ++aIter )
     239                 :            :         {
     240         [ +  - ]:          6 :             sal_uInt16 nItemId = pToolBox->GetItemId( (sal_uInt16)aIter->first );
     241                 :            : 
     242         [ +  - ]:          6 :             if ( aIter->second.is() )
     243                 :            :             {
     244                 :            :                 VCLXAccessibleToolBoxItem* pItem =
     245 [ +  - ][ +  - ]:          6 :                     static_cast< VCLXAccessibleToolBoxItem* >( aIter->second.get() );
     246 [ +  + ][ +  - ]:          6 :                 if ( pItem->HasFocus() && nItemId != nHighlightItemId )
                 [ +  + ]
     247                 :            :                 {
     248                 :            :                     // reset the old focused item
     249         [ +  - ]:          2 :                     pItem->SetFocus( sal_False );
     250                 :          2 :                     nFocusCount++;
     251                 :            :                 }
     252         [ +  + ]:          6 :                 if ( nItemId == nHighlightItemId )
     253                 :            :                 {
     254                 :            :                     // set the new focused item
     255         [ +  - ]:          2 :                     pItem->SetFocus( sal_True );
     256                 :          2 :                     nFocusCount++;
     257                 :            :                 }
     258                 :            :             }
     259                 :            :         // both items changed?
     260         [ +  + ]:          6 :         if ( nFocusCount > 1 )
     261                 :          2 :             break;
     262                 :            :         }
     263                 :            :     }
     264                 :            : }
     265                 :            : // -----------------------------------------------------------------------------
     266                 :          0 : void VCLXAccessibleToolBox::ReleaseFocus_Impl( sal_Int32 _nPos )
     267                 :            : {
     268                 :          0 :     ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
     269         [ #  # ]:          0 :     if ( pToolBox ) // #107124#, do not check for focus because this message is also handled in losefocus
     270                 :            :     {
     271         [ #  # ]:          0 :         ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find( _nPos );
     272 [ #  # ][ #  # ]:          0 :         if ( aIter != m_aAccessibleChildren.end() && aIter->second.is() )
         [ #  # ][ #  # ]
     273                 :            :         {
     274                 :            :             VCLXAccessibleToolBoxItem* pItem =
     275 [ #  # ][ #  # ]:          0 :                 static_cast< VCLXAccessibleToolBoxItem* >( aIter->second.get() );
     276         [ #  # ]:          0 :             if ( pItem->HasFocus() )
     277         [ #  # ]:          0 :                 pItem->SetFocus( sal_False );
     278                 :            :         }
     279                 :            :     }
     280                 :          0 : }
     281                 :            : // -----------------------------------------------------------------------------
     282                 :          0 : void VCLXAccessibleToolBox::UpdateChecked_Impl( sal_Int32  )
     283                 :            : {
     284                 :          0 :     ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
     285         [ #  # ]:          0 :     if ( pToolBox )
     286                 :            :     {
     287         [ #  # ]:          0 :         for ( ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.begin();
     288                 :          0 :               aIter != m_aAccessibleChildren.end(); ++aIter )
     289                 :            :         {
     290         [ #  # ]:          0 :                 sal_uInt16 nItemId = pToolBox->GetItemId( (sal_uInt16)aIter->first );
     291                 :            : 
     292                 :            :                 VCLXAccessibleToolBoxItem* pItem =
     293 [ #  # ][ #  # ]:          0 :                     static_cast< VCLXAccessibleToolBoxItem* >( aIter->second.get() );
     294 [ #  # ][ #  # ]:          0 :                 pItem->SetChecked( pToolBox->IsItemChecked( nItemId ) );
     295                 :            :         }
     296                 :            :     }
     297                 :          0 : }
     298                 :            : // -----------------------------------------------------------------------------
     299                 :          0 : void VCLXAccessibleToolBox::UpdateIndeterminate_Impl( sal_Int32 _nPos )
     300                 :            : {
     301                 :          0 :     ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
     302         [ #  # ]:          0 :     if ( pToolBox )
     303                 :            :     {
     304         [ #  # ]:          0 :         sal_uInt16 nItemId = pToolBox->GetItemId( (sal_uInt16)_nPos );
     305                 :            : 
     306         [ #  # ]:          0 :         ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find( _nPos );
     307 [ #  # ][ #  # ]:          0 :         if ( aIter != m_aAccessibleChildren.end() && aIter->second.is() )
         [ #  # ][ #  # ]
     308                 :            :         {
     309                 :            :             VCLXAccessibleToolBoxItem* pItem =
     310 [ #  # ][ #  # ]:          0 :                 static_cast< VCLXAccessibleToolBoxItem* >( aIter->second.get() );
     311         [ #  # ]:          0 :             if ( pItem )
     312 [ #  # ][ #  # ]:          0 :                 pItem->SetIndeterminate( pToolBox->GetItemState( nItemId ) == STATE_DONTKNOW );
     313                 :            :         }
     314                 :            :     }
     315                 :          0 : }
     316                 :            : // -----------------------------------------------------------------------------
     317                 :        982 : void VCLXAccessibleToolBox::implReleaseToolboxItem( ToolBoxItemsMap::iterator& _rMapPos,
     318                 :            :         bool _bNotifyRemoval, bool _bDispose )
     319                 :            : {
     320                 :        982 :     Reference< XAccessible > xItemAcc( _rMapPos->second );
     321         [ -  + ]:        982 :     if ( !xItemAcc.is() )
     322                 :        982 :         return;
     323                 :            : 
     324         [ -  + ]:        982 :     if ( _bNotifyRemoval )
     325                 :            :     {
     326 [ #  # ][ #  # ]:          0 :         NotifyAccessibleEvent( AccessibleEventId::CHILD, makeAny( xItemAcc ), Any() );
     327                 :            :     }
     328                 :            : 
     329                 :        982 :     OToolBoxWindowItem* pWindowItem = NULL;
     330 [ +  - ][ +  - ]:        982 :     if ( !OToolBoxWindowItem::isWindowItem( xItemAcc, &pWindowItem ) )
     331                 :            :     {
     332 [ +  - ][ +  - ]:        982 :         static_cast< VCLXAccessibleToolBoxItem* >( xItemAcc.get() )->ReleaseToolBox();
     333         [ +  - ]:        982 :         if ( _bDispose )
     334         [ +  - ]:        982 :             ::comphelper::disposeComponent( xItemAcc );
     335                 :            :     }
     336                 :            :     else
     337                 :            :     {
     338         [ #  # ]:          0 :         if ( _bDispose )
     339                 :            :         {
     340         [ #  # ]:          0 :             if ( pWindowItem )
     341                 :            :             {
     342         [ #  # ]:          0 :                 Reference< XAccessibleContext > xContext( pWindowItem->getContextNoCreate() );
     343         [ #  # ]:        982 :                 ::comphelper::disposeComponent( xContext );
     344                 :            :             }
     345                 :            :         }
     346         [ +  - ]:        982 :     }
     347                 :            : }
     348                 :            : 
     349                 :            : // -----------------------------------------------------------------------------
     350                 :          0 : void VCLXAccessibleToolBox::UpdateItem_Impl( sal_Int32 _nPos, sal_Bool _bItemAdded )
     351                 :            : {
     352         [ #  # ]:          0 :     if ( _nPos < sal_Int32( m_aAccessibleChildren.size() ) )
     353                 :            :     {
     354                 :          0 :         UpdateAllItems_Impl();
     355                 :          0 :         return;
     356                 :            :     }
     357                 :            : 
     358                 :          0 :     ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
     359         [ #  # ]:          0 :     if ( pToolBox )
     360                 :            :     {
     361         [ #  # ]:          0 :         if ( !_bItemAdded )
     362                 :            :         {   // the item was removed
     363                 :            :             // -> destroy the old item
     364         [ #  # ]:          0 :             ToolBoxItemsMap::iterator aItemPos = m_aAccessibleChildren.find( _nPos );
     365         [ #  # ]:          0 :             if ( m_aAccessibleChildren.end() != aItemPos )
     366                 :            :             {
     367         [ #  # ]:          0 :                 implReleaseToolboxItem( aItemPos, true, true );
     368         [ #  # ]:          0 :                 m_aAccessibleChildren.erase( aItemPos );
     369                 :            :             }
     370                 :            :         }
     371                 :            : 
     372                 :            :         // adjust the "index-in-parent"s
     373         [ #  # ]:          0 :         ToolBoxItemsMap::iterator aIndexAdjust = m_aAccessibleChildren.upper_bound( _nPos );
     374         [ #  # ]:          0 :         while ( m_aAccessibleChildren.end() != aIndexAdjust )
     375                 :            :         {
     376                 :          0 :             Reference< XAccessible > xItemAcc( aIndexAdjust->second );
     377                 :            : 
     378                 :          0 :             OToolBoxWindowItem* pWindowItem = NULL;
     379 [ #  # ][ #  # ]:          0 :             if ( !OToolBoxWindowItem::isWindowItem( xItemAcc, &pWindowItem ) )
     380                 :            :             {
     381 [ #  # ][ #  # ]:          0 :                 VCLXAccessibleToolBoxItem* pItem = static_cast< VCLXAccessibleToolBoxItem* >( xItemAcc.get() );
     382         [ #  # ]:          0 :                 if ( pItem )
     383                 :            :                 {
     384                 :          0 :                     sal_Int32 nIndex = pItem->getIndexInParent( );
     385         [ #  # ]:          0 :                     nIndex += (_bItemAdded ? +1 : -1);
     386                 :          0 :                     pItem->setIndexInParent( nIndex );
     387                 :            :                 }
     388                 :            :             }
     389                 :            :             else
     390                 :            :             {
     391         [ #  # ]:          0 :                 if ( pWindowItem )
     392                 :            :                 {
     393                 :          0 :                     sal_Int32 nIndex = pWindowItem->getIndexInParent( );
     394         [ #  # ]:          0 :                     nIndex += (_bItemAdded ? +1 : -1);
     395                 :          0 :                     pWindowItem->setIndexInParent( nIndex );
     396                 :            :                 }
     397                 :            :             }
     398                 :            : 
     399                 :          0 :             ++aIndexAdjust;
     400                 :          0 :         }
     401                 :            : 
     402         [ #  # ]:          0 :         if ( _bItemAdded )
     403                 :            :         {
     404                 :            :             // TODO: we should make this dependent on the existence of event listeners
     405                 :            :             // with the current implementation, we always create accessible object
     406 [ #  # ][ #  # ]:          0 :             Any aNewChild = makeAny( getAccessibleChild( (sal_Int32)_nPos ) );
     407         [ #  # ]:          0 :             NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), aNewChild );
     408                 :            :         }
     409                 :            :     }
     410                 :            : }
     411                 :            : // -----------------------------------------------------------------------------
     412                 :          0 : void VCLXAccessibleToolBox::UpdateAllItems_Impl()
     413                 :            : {
     414                 :          0 :     ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
     415         [ #  # ]:          0 :     if ( pToolBox )
     416                 :            :     {
     417                 :            :         // deregister the old items
     418         [ #  # ]:          0 :         for ( ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.begin();
     419                 :          0 :                 aIter != m_aAccessibleChildren.end(); ++aIter )
     420                 :            :         {
     421         [ #  # ]:          0 :             implReleaseToolboxItem( aIter, true, true );
     422                 :            :         }
     423                 :          0 :         m_aAccessibleChildren.clear();
     424                 :            : 
     425                 :            :         // register the new items
     426                 :          0 :         sal_uInt16 i, nCount = pToolBox->GetItemCount();
     427         [ #  # ]:          0 :         for ( i = 0; i < nCount; ++i )
     428                 :            :         {
     429                 :          0 :             Any aNewValue;
     430 [ #  # ][ #  # ]:          0 :             aNewValue <<= getAccessibleChild( (sal_Int32)i );;
     431         [ #  # ]:          0 :             NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), aNewValue );
     432                 :          0 :         }
     433                 :            :     }
     434                 :          0 : }
     435                 :            : 
     436                 :            : // -----------------------------------------------------------------------------
     437                 :            : 
     438                 :          0 : void VCLXAccessibleToolBox::UpdateCustomPopupItemp_Impl( Window* pWindow, bool bOpen )
     439                 :            : {
     440                 :          0 :     ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
     441 [ #  # ][ #  # ]:          0 :     if( pWindow && pToolBox )
     442                 :            :     {
     443         [ #  # ]:          0 :         Reference< XAccessible > xChild( pWindow->GetAccessible() );
     444         [ #  # ]:          0 :         if( xChild.is() )
     445                 :            :         {
     446 [ #  # ][ #  # ]:          0 :             Reference< XAccessible > xChildItem( getAccessibleChild( static_cast< sal_Int32 >( pToolBox->GetItemPos( pToolBox->GetDownItemId() ) ) ) );
     447 [ #  # ][ #  # ]:          0 :             VCLXAccessibleToolBoxItem* pItem = static_cast< VCLXAccessibleToolBoxItem* >( xChildItem.get() );
     448                 :            : 
     449         [ #  # ]:          0 :             pItem->SetChild( xChild );
     450         [ #  # ]:          0 :             pItem->NotifyChildEvent( xChild, bOpen );
     451                 :          0 :         }
     452                 :            :     }
     453                 :          0 : }
     454                 :            : 
     455                 :            : // -----------------------------------------------------------------------------
     456                 :          0 : void VCLXAccessibleToolBox::UpdateItemName_Impl( sal_Int32 _nPos )
     457                 :            : {
     458                 :          0 :     VCLXAccessibleToolBoxItem* pItem = GetItem_Impl( _nPos, false );
     459         [ #  # ]:          0 :     if ( pItem )
     460                 :          0 :         pItem->NameChanged();
     461                 :          0 : }
     462                 :            : // -----------------------------------------------------------------------------
     463                 :          0 : void VCLXAccessibleToolBox::UpdateItemEnabled_Impl( sal_Int32 _nPos )
     464                 :            : {
     465                 :          0 :     VCLXAccessibleToolBoxItem* pItem = GetItem_Impl( _nPos, false );
     466         [ #  # ]:          0 :     if ( pItem )
     467                 :          0 :         pItem->ToggleEnableState();
     468                 :          0 : }
     469                 :            : // -----------------------------------------------------------------------------
     470                 :         10 : void VCLXAccessibleToolBox::HandleSubToolBarEvent( const VclWindowEvent& rVclWindowEvent, bool _bShow )
     471                 :            : {
     472                 :         10 :     Window* pChildWindow = (Window *) rVclWindowEvent.GetData();
     473                 :         10 :     ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
     474   [ +  -  -  +  :         16 :     if ( pChildWindow
           #  # ][ -  + ]
                 [ +  + ]
     475                 :            :         && pToolBox
     476                 :          6 :         && pToolBox == pChildWindow->GetParent()
     477                 :          0 :         && pChildWindow->GetType() == WINDOW_TOOLBOX )
     478                 :            :     {
     479         [ #  # ]:          0 :         sal_Int32 nIndex = pToolBox->GetItemPos( pToolBox->GetCurItemId() );
     480         [ #  # ]:          0 :         Reference< XAccessible > xItem = getAccessibleChild( nIndex );
     481         [ #  # ]:          0 :         if ( xItem.is() )
     482                 :            :         {
     483         [ #  # ]:          0 :             Reference< XAccessible > xChild = pChildWindow->GetAccessible();
     484                 :            :             VCLXAccessibleToolBoxItem* pItem =
     485 [ #  # ][ #  # ]:          0 :                 static_cast< VCLXAccessibleToolBoxItem* >( xItem.get() );
     486         [ #  # ]:          0 :             pItem->SetChild( xChild );
     487         [ #  # ]:          0 :             pItem->NotifyChildEvent( xChild, _bShow );
     488                 :          0 :         }
     489                 :            :     }
     490                 :         10 : }
     491                 :            : // -----------------------------------------------------------------------------
     492                 :          0 : void VCLXAccessibleToolBox::ReleaseSubToolBox( ToolBox* _pSubToolBox )
     493                 :            : {
     494                 :          0 :     ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
     495         [ #  # ]:          0 :     if ( pToolBox )
     496                 :            :     {
     497         [ #  # ]:          0 :         sal_Int32 nIndex = pToolBox->GetItemPos( pToolBox->GetCurItemId() );
     498         [ #  # ]:          0 :         Reference< XAccessible > xItem = getAccessibleChild( nIndex );
     499         [ #  # ]:          0 :         if ( xItem.is() )
     500                 :            :         {
     501         [ #  # ]:          0 :             Reference< XAccessible > xChild = _pSubToolBox->GetAccessible();
     502                 :            :             VCLXAccessibleToolBoxItem* pItem =
     503 [ #  # ][ #  # ]:          0 :                 static_cast< VCLXAccessibleToolBoxItem* >( xItem.get() );
     504 [ #  # ][ #  # ]:          0 :             if ( pItem->GetChild() == xChild )
                 [ #  # ]
     505                 :            :             {
     506         [ #  # ]:          0 :                 pItem->SetChild( Reference< XAccessible >() );
     507         [ #  # ]:          0 :                 pItem->NotifyChildEvent( xChild, false );
     508                 :          0 :             }
     509                 :          0 :         }
     510                 :            :     }
     511                 :          0 : }
     512                 :            : // -----------------------------------------------------------------------------
     513                 :         20 : void VCLXAccessibleToolBox::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
     514                 :            : {
     515                 :         20 :     VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet );
     516                 :            : 
     517                 :         20 :     ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
     518         [ +  - ]:         20 :     if ( pToolBox )
     519                 :            :     {
     520                 :         20 :         rStateSet.AddState( AccessibleStateType::FOCUSABLE );
     521         [ +  - ]:         20 :         if ( pToolBox->IsHorizontal() )
     522                 :         20 :             rStateSet.AddState( AccessibleStateType::HORIZONTAL );
     523                 :            :         else
     524                 :          0 :             rStateSet.AddState( AccessibleStateType::VERTICAL );
     525                 :            :     }
     526                 :         20 : }
     527                 :            : // -----------------------------------------------------------------------------
     528                 :       1184 : void VCLXAccessibleToolBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
     529                 :            : {
     530                 :            :     // to prevent an early release of the toolbox (VCLEVENT_OBJECT_DYING)
     531         [ +  - ]:       1184 :     Reference< XAccessibleContext > xTemp = this;
     532                 :            : 
     533   [ +  +  +  -  :       1184 :     switch ( rVclWindowEvent.GetId() )
          -  -  +  -  -  
                -  +  + ]
     534                 :            :     {
     535                 :            :         case VCLEVENT_TOOLBOX_CLICK:
     536                 :            :         {
     537         [ -  + ]:          2 :             if ( rVclWindowEvent.GetData() )
     538                 :            :             {
     539         [ #  # ]:          0 :                 UpdateChecked_Impl( (sal_Int32)(sal_IntPtr)rVclWindowEvent.GetData() );
     540         [ #  # ]:          0 :                 UpdateIndeterminate_Impl( (sal_Int32)(sal_IntPtr)rVclWindowEvent.GetData() );
     541                 :            :             }
     542                 :          2 :             break;
     543                 :            :         }
     544                 :            :         case VCLEVENT_TOOLBOX_DOUBLECLICK:
     545                 :            :         case VCLEVENT_TOOLBOX_ACTIVATE:
     546                 :            :         case VCLEVENT_TOOLBOX_DEACTIVATE:
     547                 :            :         case VCLEVENT_TOOLBOX_SELECT:
     548                 :          6 :             break;
     549                 :            : 
     550                 :            :         case VCLEVENT_TOOLBOX_HIGHLIGHT:
     551         [ +  - ]:          2 :             UpdateFocus_Impl();
     552                 :          2 :             break;
     553                 :            : 
     554                 :            :         case VCLEVENT_TOOLBOX_HIGHLIGHTOFF:
     555         [ #  # ]:          0 :             ReleaseFocus_Impl( (sal_Int32)(sal_IntPtr)rVclWindowEvent.GetData() );
     556                 :          0 :             break;
     557                 :            : 
     558                 :            :         case VCLEVENT_TOOLBOX_ITEMADDED :
     559                 :            : //            UpdateItem_Impl( (sal_Int32)(sal_IntPtr)rVclWindowEvent.GetData(), VCLEVENT_TOOLBOX_ITEMADDED == rVclWindowEvent.GetId() );
     560         [ #  # ]:          0 :             UpdateItem_Impl( (sal_Int32)(sal_IntPtr)rVclWindowEvent.GetData(), sal_True );
     561                 :          0 :             break;
     562                 :            : 
     563                 :            :         case VCLEVENT_TOOLBOX_ITEMREMOVED :
     564                 :            :         case VCLEVENT_TOOLBOX_ALLITEMSCHANGED :
     565                 :            :         {
     566         [ #  # ]:          0 :             UpdateAllItems_Impl();
     567                 :          0 :             break;
     568                 :            :         }
     569                 :            : 
     570                 :            :         case VCLEVENT_TOOLBOX_ITEMWINDOWCHANGED:
     571                 :            :         {
     572                 :        544 :             sal_Int32 nPos = (sal_Int32)(sal_IntPtr)rVclWindowEvent.GetData();
     573         [ +  - ]:        544 :             ToolBoxItemsMap::iterator aAccessiblePos( m_aAccessibleChildren.find( nPos ) );
     574         [ +  + ]:        544 :             if ( m_aAccessibleChildren.end() != aAccessiblePos )
     575                 :            :             {
     576         [ +  - ]:        422 :                 implReleaseToolboxItem( aAccessiblePos, false, true );
     577         [ +  - ]:        422 :                 m_aAccessibleChildren.erase (aAccessiblePos);
     578                 :            :             }
     579                 :            : 
     580                 :        544 :             Any aNewValue;
     581 [ +  - ][ +  - ]:        544 :             aNewValue <<= getAccessibleChild(nPos);
     582         [ +  - ]:        544 :             NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), aNewValue );
     583                 :        544 :             break;
     584                 :            :         }
     585                 :            :         case VCLEVENT_TOOLBOX_ITEMTEXTCHANGED :
     586         [ #  # ]:          0 :             UpdateItemName_Impl( (sal_Int32)(sal_IntPtr)rVclWindowEvent.GetData() );
     587                 :          0 :             break;
     588                 :            : 
     589                 :            :         case VCLEVENT_TOOLBOX_ITEMENABLED :
     590                 :            :         case VCLEVENT_TOOLBOX_ITEMDISABLED :
     591                 :            :         {
     592         [ #  # ]:          0 :             UpdateItemEnabled_Impl( (sal_Int32)(sal_IntPtr)rVclWindowEvent.GetData() );
     593                 :          0 :             break;
     594                 :            :         }
     595                 :            : 
     596                 :            :         case VCLEVENT_DROPDOWN_OPEN:
     597                 :            :         case VCLEVENT_DROPDOWN_CLOSE:
     598                 :            :         {
     599         [ #  # ]:          0 :             UpdateCustomPopupItemp_Impl( static_cast< Window* >( rVclWindowEvent.GetData() ), rVclWindowEvent.GetId() == VCLEVENT_DROPDOWN_OPEN );
     600                 :          0 :             break;
     601                 :            :         }
     602                 :            : 
     603                 :            :         case VCLEVENT_OBJECT_DYING :
     604                 :            :         {
     605                 :            :             // if this toolbox is a subtoolbox, we have to relese it from its parent
     606         [ +  - ]:         30 :             ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
     607 [ +  - ][ +  - ]:         60 :             if ( pToolBox && pToolBox->GetParent() &&
         [ +  - ][ -  + ]
                 [ -  + ]
     608 [ +  - ][ +  - ]:         30 :                  pToolBox->GetParent()->GetType() == WINDOW_TOOLBOX )
     609                 :            :             {
     610                 :            :                 VCLXAccessibleToolBox* pParent = static_cast< VCLXAccessibleToolBox* >(
     611 [ #  # ][ #  # ]:          0 :                     pToolBox->GetParent()->GetAccessible()->getAccessibleContext().get() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     612         [ #  # ]:          0 :                 if ( pParent )
     613         [ #  # ]:          0 :                     pParent->ReleaseSubToolBox( pToolBox );
     614                 :            :             }
     615                 :            : 
     616                 :            :             // dispose all items
     617         [ +  + ]:       1180 :             for ( ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.begin();
     618                 :        590 :                   aIter != m_aAccessibleChildren.end(); ++aIter )
     619                 :            :             {
     620         [ +  - ]:        560 :                 implReleaseToolboxItem( aIter, false, true );
     621                 :            :             }
     622                 :         30 :             m_aAccessibleChildren.clear();
     623                 :            : 
     624                 :            :             //!!! no break to call base class
     625                 :            :         }
     626                 :            : 
     627                 :            :         default:
     628         [ +  - ]:        630 :             VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
     629                 :       1184 :     }
     630                 :       1184 : }
     631                 :            : // -----------------------------------------------------------------------------
     632                 :       1762 : void VCLXAccessibleToolBox::ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent )
     633                 :            : {
     634         [ +  + ]:       1762 :     switch ( rVclWindowEvent.GetId() )
     635                 :            :     {
     636                 :            :         case VCLEVENT_WINDOW_SHOW:  // send create on show for direct accessible children
     637                 :            :         {
     638         [ +  - ]:         10 :             Reference< XAccessible > xReturn = GetItemWindowAccessible(rVclWindowEvent);
     639         [ -  + ]:         10 :             if ( xReturn.is() )
     640 [ #  # ][ #  # ]:          0 :                 NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), makeAny(xReturn) );
     641                 :            :             else
     642         [ +  - ]:         10 :                 HandleSubToolBarEvent( rVclWindowEvent, true );
     643                 :            :         }
     644                 :         10 :         break;
     645                 :            : 
     646                 :            :         default:
     647                 :       1752 :            VCLXAccessibleComponent::ProcessWindowChildEvent( rVclWindowEvent );
     648                 :            : 
     649                 :            :     }
     650                 :       1762 : }
     651                 :            : // -----------------------------------------------------------------------------
     652                 :            : // XInterface
     653                 :            : // -----------------------------------------------------------------------------
     654 [ -  + ][ #  # ]:       6816 : IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleToolBox, VCLXAccessibleComponent, VCLXAccessibleToolBox_BASE )
     655                 :            : // -----------------------------------------------------------------------------
     656                 :            : // XTypeProvider
     657                 :            : // -----------------------------------------------------------------------------
     658 [ #  # ][ #  # ]:          0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleToolBox, VCLXAccessibleComponent, VCLXAccessibleToolBox_BASE )
                 [ #  # ]
     659                 :            : // -----------------------------------------------------------------------------
     660                 :            : // XComponent
     661                 :            : // -----------------------------------------------------------------------------
     662                 :         30 : void SAL_CALL VCLXAccessibleToolBox::disposing()
     663                 :            : {
     664                 :         30 :     VCLXAccessibleComponent::disposing();
     665                 :            : 
     666                 :            :     // release the items
     667         [ -  + ]:         60 :     for ( ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.begin();
     668                 :         30 :           aIter != m_aAccessibleChildren.end(); ++aIter )
     669                 :            :     {
     670         [ #  # ]:          0 :         implReleaseToolboxItem( aIter, false, true );
     671                 :            :     }
     672                 :         30 :     m_aAccessibleChildren.clear();
     673                 :         30 : }
     674                 :            : // -----------------------------------------------------------------------------
     675                 :            : // XServiceInfo
     676                 :            : // -----------------------------------------------------------------------------
     677                 :          2 : ::rtl::OUString VCLXAccessibleToolBox::getImplementationName() throw (RuntimeException)
     678                 :            : {
     679                 :          2 :     return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.toolkit.AccessibleToolBox" ));
     680                 :            : }
     681                 :            : // -----------------------------------------------------------------------------
     682                 :          0 : Sequence< ::rtl::OUString > VCLXAccessibleToolBox::getSupportedServiceNames() throw (RuntimeException)
     683                 :            : {
     684                 :          0 :     Sequence< ::rtl::OUString > aNames = VCLXAccessibleComponent::getSupportedServiceNames();
     685                 :          0 :     sal_Int32 nLength = aNames.getLength();
     686         [ #  # ]:          0 :     aNames.realloc( nLength + 1 );
     687 [ #  # ][ #  # ]:          0 :     aNames[nLength] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleToolBox" ));
     688                 :          0 :     return aNames;
     689                 :            : }
     690                 :            : // -----------------------------------------------------------------------------
     691                 :            : // XAccessibleContext
     692                 :            : // -----------------------------------------------------------------------------
     693                 :       1036 : sal_Int32 SAL_CALL VCLXAccessibleToolBox::getAccessibleChildCount(  ) throw (RuntimeException)
     694                 :            : {
     695         [ +  - ]:       1036 :     comphelper::OExternalLockGuard aGuard( this );
     696                 :            : 
     697                 :       1036 :     sal_Int32 nCount = 0;
     698         [ +  - ]:       1036 :     ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
     699         [ +  - ]:       1036 :     if ( pToolBox )
     700         [ +  - ]:       1036 :         nCount = pToolBox->GetItemCount();
     701                 :            : 
     702         [ +  - ]:       1036 :     return nCount;
     703                 :            : }
     704                 :            : // -----------------------------------------------------------------------------
     705                 :        984 : Reference< XAccessible > SAL_CALL VCLXAccessibleToolBox::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
     706                 :            : {
     707 [ +  - ][ +  - ]:        984 :     if ( i < 0 || i >= getAccessibleChildCount() )
         [ -  + ][ -  + ]
     708         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     709                 :            : 
     710         [ +  - ]:        984 :     comphelper::OExternalLockGuard aGuard( this );
     711                 :            : 
     712         [ +  - ]:        984 :     ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
     713         [ +  - ]:        984 :     if ( pToolBox )
     714                 :            :     {
     715                 :        984 :         Reference< XAccessible > xChild;
     716                 :            :         // search for the child
     717         [ +  - ]:        984 :         ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find(i);
     718         [ +  + ]:        984 :         if ( m_aAccessibleChildren.end() == aIter )
     719                 :            :         {
     720         [ +  - ]:        982 :             sal_uInt16 nItemId = pToolBox->GetItemId( (sal_uInt16)i );
     721                 :        982 :             sal_uInt16 nHighlightItemId = pToolBox->GetHighlightItemId();
     722         [ +  - ]:        982 :             Window* pItemWindow = pToolBox->GetItemWindow( nItemId );
     723                 :            :             // not found -> create a new child
     724         [ +  - ]:        982 :             VCLXAccessibleToolBoxItem* pChild = new VCLXAccessibleToolBoxItem( pToolBox, i );
     725 [ +  - ][ +  - ]:        982 :             Reference< XAccessible> xParent = pChild;
     726         [ +  + ]:        982 :             if ( pItemWindow )
     727                 :            :             {
     728 [ +  - ][ +  - ]:         18 :                 xChild = new OToolBoxWindowItem(0,::comphelper::getProcessServiceFactory(),pItemWindow->GetAccessible(),xParent);
         [ +  - ][ +  - ]
                 [ +  - ]
     729         [ +  - ]:         18 :                 pItemWindow->SetAccessible(xChild);
     730         [ +  - ]:         18 :                 pChild->SetChild( xChild );
     731                 :            :             }
     732 [ +  - ][ +  - ]:        982 :             xChild = pChild;
     733 [ +  + ][ +  + ]:        982 :             if ( nHighlightItemId > 0 && nItemId == nHighlightItemId )
     734         [ +  - ]:          3 :                 pChild->SetFocus( sal_True );
     735 [ +  - ][ +  + ]:        982 :             if ( pToolBox->IsItemChecked( nItemId ) )
     736         [ +  - ]:         56 :                 pChild->SetChecked( sal_True );
     737 [ +  - ][ -  + ]:        982 :             if ( pToolBox->GetItemState( nItemId ) == STATE_DONTKNOW )
     738         [ #  # ]:          0 :                 pChild->SetIndeterminate( true );
     739 [ +  - ][ +  - ]:        982 :             m_aAccessibleChildren.insert( ToolBoxItemsMap::value_type( i, xChild ) );
                 [ +  - ]
     740                 :            :         }
     741                 :            :         else
     742                 :            :         {
     743                 :            :             // found it
     744         [ +  - ]:          2 :             xChild = aIter->second;
     745                 :            :         }
     746                 :        984 :         return xChild;
     747                 :            :     }
     748                 :            : 
     749 [ #  # ][ +  - ]:        984 :     return NULL;
     750                 :            : }
     751                 :            : // -----------------------------------------------------------------------------
     752                 :          0 : Reference< XAccessible > SAL_CALL VCLXAccessibleToolBox::getAccessibleAtPoint( const awt::Point& _rPoint ) throw (RuntimeException)
     753                 :            : {
     754         [ #  # ]:          0 :     comphelper::OExternalLockGuard aGuard( this );
     755                 :            : 
     756                 :          0 :     Reference< XAccessible > xAccessible;
     757         [ #  # ]:          0 :     ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
     758         [ #  # ]:          0 :     if ( pToolBox )
     759                 :            :     {
     760         [ #  # ]:          0 :         sal_uInt16 nItemPos = pToolBox->GetItemPos( VCLPoint( _rPoint ) );
     761         [ #  # ]:          0 :         if ( nItemPos != TOOLBOX_ITEM_NOTFOUND )
     762 [ #  # ][ #  # ]:          0 :             xAccessible = getAccessibleChild( nItemPos );
     763                 :            :     }
     764                 :            : 
     765         [ #  # ]:          0 :     return xAccessible;
     766                 :            : }
     767                 :            : // -----------------------------------------------------------------------------
     768                 :        182 : Reference< XAccessible > VCLXAccessibleToolBox::GetItemWindowAccessible( const VclWindowEvent& rVclWindowEvent )
     769                 :            : {
     770                 :        182 :     Reference< XAccessible > xReturn;
     771                 :        182 :     Window* pChildWindow = (Window *) rVclWindowEvent.GetData();
     772         [ +  - ]:        182 :     ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
     773 [ +  + ][ +  - ]:        182 :     if ( pChildWindow && pToolBox )
     774                 :            :     {
     775         [ +  - ]:        108 :         sal_uInt16 nCount = pToolBox->GetItemCount();
     776 [ +  + ][ +  + ]:       3224 :         for (sal_uInt16 i = 0 ; i < nCount && !xReturn.is() ; ++i)
                 [ +  + ]
     777                 :            :         {
     778         [ +  - ]:       3116 :             sal_uInt16 nItemId = pToolBox->GetItemId( i );
     779         [ +  - ]:       3116 :             Window* pItemWindow = pToolBox->GetItemWindow( nItemId );
     780         [ +  + ]:       3116 :             if ( pItemWindow == pChildWindow )
     781 [ +  - ][ +  - ]:         10 :                 xReturn = getAccessibleChild(i);
     782                 :            :         }
     783                 :            :     }
     784                 :        182 :     return xReturn;
     785                 :            : }
     786                 :            : // -----------------------------------------------------------------------------
     787                 :        172 : Reference< XAccessible > VCLXAccessibleToolBox::GetChildAccessible( const VclWindowEvent& rVclWindowEvent )
     788                 :            : {
     789                 :        172 :     Reference< XAccessible > xReturn = GetItemWindowAccessible(rVclWindowEvent);
     790                 :            : 
     791         [ +  + ]:        172 :     if ( !xReturn.is() )
     792 [ +  - ][ +  - ]:        162 :         xReturn = VCLXAccessibleComponent::GetChildAccessible(rVclWindowEvent);
     793                 :        172 :     return xReturn;
     794                 :            : }
     795                 :            : // -----------------------------------------------------------------------------
     796                 :            : // XAccessibleSelection
     797                 :            : // -----------------------------------------------------------------------------
     798                 :          0 : void VCLXAccessibleToolBox::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     799                 :            : {
     800         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     801 [ #  # ][ #  # ]:          0 :     if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
         [ #  # ][ #  # ]
     802         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     803         [ #  # ]:          0 :     ToolBox * pToolBox = static_cast < ToolBox * > ( GetWindow() );
     804                 :          0 :     sal_uInt16 nPos = static_cast < sal_uInt16 > (nChildIndex);
     805 [ #  # ][ #  # ]:          0 :     pToolBox->ChangeHighlight( nPos );
     806                 :          0 : }
     807                 :            : // -----------------------------------------------------------------------------
     808                 :          0 : sal_Bool VCLXAccessibleToolBox::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     809                 :            : {
     810         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     811 [ #  # ][ #  # ]:          0 :     if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
         [ #  # ][ #  # ]
     812         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     813         [ #  # ]:          0 :     ToolBox * pToolBox = static_cast < ToolBox * > ( GetWindow() );
     814                 :          0 :     sal_uInt16 nPos = static_cast < sal_uInt16 > (nChildIndex);
     815 [ #  # ][ #  # ]:          0 :     if ( pToolBox != NULL && pToolBox->GetHighlightItemId() == pToolBox->GetItemId( nPos ) )
         [ #  # ][ #  # ]
     816                 :          0 :         return sal_True;
     817                 :            :     else
     818         [ #  # ]:          0 :         return sal_False;
     819                 :            : }
     820                 :            : // -----------------------------------------------------------------------------
     821                 :          0 : void VCLXAccessibleToolBox::clearAccessibleSelection(  ) throw (RuntimeException)
     822                 :            : {
     823         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     824         [ #  # ]:          0 :     ToolBox * pToolBox = static_cast < ToolBox * > ( GetWindow() );
     825 [ #  # ][ #  # ]:          0 :     pToolBox -> LoseFocus();
     826                 :          0 : }
     827                 :            : // -----------------------------------------------------------------------------
     828                 :          0 : void VCLXAccessibleToolBox::selectAllAccessibleChildren(  ) throw (RuntimeException)
     829                 :            : {
     830 [ #  # ][ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     831                 :            :     // intentionally empty. makes no sense for a toolbox
     832                 :          0 : }
     833                 :            : // -----------------------------------------------------------------------------
     834                 :          0 : sal_Int32 VCLXAccessibleToolBox::getSelectedAccessibleChildCount(  ) throw (RuntimeException)
     835                 :            : {
     836         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     837                 :          0 :     sal_Int32 nRet = 0;
     838 [ #  # ][ #  # ]:          0 :     for ( sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; i++ )
     839                 :            :     {
     840 [ #  # ][ #  # ]:          0 :         if ( isAccessibleChildSelected( i ) )
     841                 :            :         {
     842                 :          0 :             nRet = 1;
     843                 :          0 :             break; // a toolbox can only have (n)one selected child
     844                 :            :         }
     845                 :            :     }
     846         [ #  # ]:          0 :     return nRet;
     847                 :            : }
     848                 :            : // -----------------------------------------------------------------------------
     849                 :          0 : Reference< XAccessible > VCLXAccessibleToolBox::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     850                 :            : {
     851         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     852 [ #  # ][ #  # ]:          0 :     if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
         [ #  # ][ #  # ]
     853         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     854                 :          0 :     Reference< XAccessible > xChild;
     855 [ #  # ][ #  # ]:          0 :     for ( sal_Int32 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; i++ )
     856                 :            :     {
     857 [ #  # ][ #  # ]:          0 :         if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
         [ #  # ][ #  # ]
     858                 :            :         {
     859 [ #  # ][ #  # ]:          0 :             xChild = getAccessibleChild( i );
     860                 :          0 :             break;
     861                 :            :         }
     862                 :            :     }
     863         [ #  # ]:          0 :     return xChild;
     864                 :            : }
     865                 :            : // -----------------------------------------------------------------------------
     866                 :          0 : void VCLXAccessibleToolBox::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     867                 :            : {
     868         [ #  # ]:          0 :     OExternalLockGuard aGuard( this );
     869 [ #  # ][ #  # ]:          0 :     if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
         [ #  # ][ #  # ]
     870         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     871 [ #  # ][ #  # ]:          0 :     clearAccessibleSelection(); // a toolbox can only have (n)one selected child
     872                 :          0 : }
     873                 :            : // -----------------------------------------------------------------------------
     874                 :            : 
     875                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10