LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/control - toolbarmenuacc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 418 0.0 %
Date: 2012-12-17 Functions: 0 66 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      22             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      23             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      24             : 
      25             : #include <unotools/accessiblestatesethelper.hxx>
      26             : 
      27             : #include <vcl/svapp.hxx>
      28             : 
      29             : #include "svtools/toolbarmenu.hxx"
      30             : 
      31             : #include "toolbarmenuimp.hxx"
      32             : 
      33             : using ::rtl::OUString;
      34             : 
      35             : using namespace ::com::sun::star;
      36             : using namespace ::com::sun::star::uno;
      37             : using namespace ::com::sun::star::lang;
      38             : using namespace ::com::sun::star::accessibility;
      39             : 
      40             : namespace svtools {
      41             : 
      42             : // ------------------
      43             : // - ToolbarMenuAcc -
      44             : // ------------------
      45             : 
      46           0 : ToolbarMenuAcc::ToolbarMenuAcc( ToolbarMenu_Impl& rParent )
      47             : : ToolbarMenuAccComponentBase(m_aMutex)
      48             : , mpParent( &rParent )
      49           0 : , mbIsFocused(false)
      50             : {
      51           0 :     mpParent->mrMenu.AddEventListener( LINK( this, ToolbarMenuAcc, WindowEventListener ) );
      52           0 : }
      53             : 
      54             : // -----------------------------------------------------------------------------
      55             : 
      56           0 : ToolbarMenuAcc::~ToolbarMenuAcc()
      57             : {
      58           0 :     if( mpParent )
      59           0 :         mpParent->mrMenu.RemoveEventListener( LINK( this, ToolbarMenuAcc, WindowEventListener ) );
      60           0 : }
      61             : 
      62             : // -----------------------------------------------------------------------
      63             : 
      64           0 : IMPL_LINK( ToolbarMenuAcc, WindowEventListener, VclSimpleEvent*, pEvent )
      65             : {
      66             :     DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" );
      67             : 
      68             :     /* Ignore VCLEVENT_WINDOW_ENDPOPUPMODE, because the UNO accessibility wrapper
      69             :      * might have been destroyed by the previous VCLEventListener (if no AT tool
      70             :      * is running), e.g. sub-toolbars in impress.
      71             :      */
      72           0 :     if ( mpParent && pEvent && pEvent->ISA( VclWindowEvent ) && (pEvent->GetId() != VCLEVENT_WINDOW_ENDPOPUPMODE) )
      73             :     {
      74             :         DBG_ASSERT( ((VclWindowEvent*)pEvent)->GetWindow(), "Window???" );
      75           0 :         if( !((VclWindowEvent*)pEvent)->GetWindow()->IsAccessibilityEventsSuppressed() || ( pEvent->GetId() == VCLEVENT_OBJECT_DYING ) )
      76             :         {
      77           0 :             ProcessWindowEvent( *(VclWindowEvent*)pEvent );
      78             :         }
      79             :     }
      80           0 :     return 0;
      81             : }
      82             : 
      83             : // -----------------------------------------------------------------------
      84             : 
      85           0 : void ToolbarMenuAcc::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
      86             : {
      87           0 :     Any aOldValue, aNewValue;
      88             : 
      89           0 :     switch ( rVclWindowEvent.GetId() )
      90             :     {
      91             :         case VCLEVENT_OBJECT_DYING:
      92             :         {
      93           0 :             mpParent->mrMenu.RemoveEventListener( LINK( this, ToolbarMenuAcc, WindowEventListener ) );
      94           0 :             mpParent = 0;
      95             :         }
      96           0 :         break;
      97             : 
      98             :         case VCLEVENT_WINDOW_GETFOCUS:
      99             :         {
     100           0 :             if( !mbIsFocused )
     101             :             {
     102           0 :                 mpParent->notifyHighlightedEntry();
     103           0 :                 mbIsFocused = true;
     104             :             }
     105             :         }
     106           0 :         break;
     107             :         case VCLEVENT_WINDOW_LOSEFOCUS:
     108             :         {
     109           0 :             if( mbIsFocused )
     110             :             {
     111           0 :                 mbIsFocused = false;
     112             :             }
     113             :         }
     114           0 :         break;
     115             :         default:
     116             :         {
     117             :         }
     118           0 :         break;
     119           0 :     }
     120           0 : }
     121             : 
     122             : // -----------------------------------------------------------------------
     123             : 
     124           0 : void ToolbarMenuAcc::FireAccessibleEvent( short nEventId, const Any& rOldValue, const Any& rNewValue )
     125             : {
     126           0 :     if( nEventId )
     127             :     {
     128           0 :         EventListenerVector                  aTmpListeners( mxEventListeners );
     129           0 :         EventListenerVector::const_iterator  aIter( aTmpListeners.begin() );
     130           0 :         AccessibleEventObject aEvtObject;
     131             : 
     132           0 :         aEvtObject.EventId = nEventId;
     133           0 :         aEvtObject.Source = static_cast<XWeak*>(this);
     134           0 :         aEvtObject.NewValue = rNewValue;
     135           0 :         aEvtObject.OldValue = rOldValue;
     136             : 
     137           0 :         while( aIter != aTmpListeners.end() )
     138             :         {
     139             :             try
     140             :             {
     141           0 :                 (*aIter)->notifyEvent( aEvtObject );
     142             :             }
     143           0 :             catch( Exception& )
     144             :             {
     145             :             }
     146             : 
     147           0 :             aIter++;
     148           0 :         }
     149             :     }
     150           0 : }
     151             : 
     152             : // -----------------------------------------------------------------------------
     153             : 
     154           0 : Reference< XAccessibleContext > SAL_CALL ToolbarMenuAcc::getAccessibleContext() throw (RuntimeException)
     155             : {
     156           0 :     ThrowIfDisposed();
     157           0 :     return this;
     158             : }
     159             : 
     160             : // -----------------------------------------------------------------------------
     161             : 
     162           0 : sal_Int32 SAL_CALL ToolbarMenuAcc::getAccessibleChildCount() throw (RuntimeException)
     163             : {
     164           0 :     const SolarMutexGuard aSolarGuard;
     165           0 :     ThrowIfDisposed();
     166             : 
     167           0 :     return mpParent->getAccessibleChildCount();
     168             : }
     169             : 
     170             : // -----------------------------------------------------------------------------
     171             : 
     172           0 : Reference< XAccessible > SAL_CALL ToolbarMenuAcc::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
     173             : {
     174           0 :     const SolarMutexGuard aSolarGuard;
     175           0 :     ThrowIfDisposed();
     176             : 
     177           0 :     return mpParent->getAccessibleChild(i);
     178             : }
     179             : 
     180             : // -----------------------------------------------------------------------------
     181             : 
     182           0 : Reference< XAccessible > SAL_CALL ToolbarMenuAcc::getAccessibleParent() throw (RuntimeException)
     183             : {
     184           0 :     ThrowIfDisposed();
     185           0 :     const SolarMutexGuard aSolarGuard;
     186             : 
     187           0 :     Reference< XAccessible > xRet;
     188             : 
     189           0 :     Window* pParent = mpParent->mrMenu.GetParent();
     190           0 :     if( pParent )
     191           0 :         xRet = pParent->GetAccessible();
     192             : 
     193           0 :     return xRet;
     194             : }
     195             : 
     196             : // -----------------------------------------------------------------------------
     197             : 
     198           0 : sal_Int32 SAL_CALL ToolbarMenuAcc::getAccessibleIndexInParent() throw (RuntimeException)
     199             : {
     200           0 :     const SolarMutexGuard aSolarGuard;
     201           0 :     ThrowIfDisposed();
     202             : 
     203           0 :     Window* pParent = mpParent->mrMenu.GetParent();
     204           0 :     if( pParent )
     205             :     {
     206           0 :         for( sal_uInt16 i = 0, nCount = pParent->GetChildCount(); i < nCount ; i++ )
     207             :         {
     208           0 :             if( pParent->GetChild( i ) == &mpParent->mrMenu )
     209           0 :                 return i;
     210             :         }
     211             :     }
     212             : 
     213           0 :     return 0;
     214             : }
     215             : 
     216             : // -----------------------------------------------------------------------------
     217             : 
     218           0 : sal_Int16 SAL_CALL ToolbarMenuAcc::getAccessibleRole() throw (RuntimeException)
     219             : {
     220           0 :     ThrowIfDisposed();
     221           0 :     return AccessibleRole::LIST;
     222             : }
     223             : 
     224             : // -----------------------------------------------------------------------------
     225             : 
     226           0 : OUString SAL_CALL ToolbarMenuAcc::getAccessibleDescription() throw (RuntimeException)
     227             : {
     228           0 :     ThrowIfDisposed();
     229           0 :     return OUString( RTL_CONSTASCII_USTRINGPARAM( "ToolbarMenu" ) );
     230             : }
     231             : 
     232             : // -----------------------------------------------------------------------------
     233             : 
     234           0 : OUString SAL_CALL ToolbarMenuAcc::getAccessibleName() throw (RuntimeException)
     235             : {
     236           0 :     ThrowIfDisposed();
     237           0 :     const SolarMutexGuard aSolarGuard;
     238           0 :     OUString aRet;
     239             : 
     240           0 :     if( mpParent )
     241           0 :         aRet = mpParent->mrMenu.GetAccessibleName();
     242             : 
     243           0 :     if( aRet.isEmpty() )
     244             :     {
     245           0 :         Window* pLabel = mpParent->mrMenu.GetAccessibleRelationLabeledBy();
     246           0 :         if( pLabel && pLabel != &mpParent->mrMenu )
     247           0 :             aRet = OutputDevice::GetNonMnemonicString( pLabel->GetText() );
     248             :     }
     249             : 
     250           0 :     return aRet;
     251             : }
     252             : 
     253             : // -----------------------------------------------------------------------------
     254             : 
     255           0 : Reference< XAccessibleRelationSet > SAL_CALL ToolbarMenuAcc::getAccessibleRelationSet() throw (RuntimeException)
     256             : {
     257           0 :     ThrowIfDisposed();
     258           0 :     return Reference< XAccessibleRelationSet >();
     259             : }
     260             : 
     261             : // -----------------------------------------------------------------------------
     262             : 
     263           0 : Reference< XAccessibleStateSet > SAL_CALL ToolbarMenuAcc::getAccessibleStateSet() throw (RuntimeException)
     264             : {
     265           0 :     ThrowIfDisposed();
     266           0 :     ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper();
     267             : 
     268             :     // Set some states.
     269           0 :     pStateSet->AddState (AccessibleStateType::ENABLED);
     270           0 :     pStateSet->AddState (AccessibleStateType::SENSITIVE);
     271           0 :     pStateSet->AddState (AccessibleStateType::SHOWING);
     272           0 :     pStateSet->AddState (AccessibleStateType::VISIBLE);
     273           0 :     pStateSet->AddState (AccessibleStateType::MANAGES_DESCENDANTS);
     274           0 :     pStateSet->AddState (AccessibleStateType::FOCUSABLE);
     275           0 :     if (mbIsFocused)
     276           0 :         pStateSet->AddState (AccessibleStateType::FOCUSED);
     277             : 
     278           0 :     return pStateSet;
     279             : }
     280             : 
     281             : // -----------------------------------------------------------------------------
     282             : 
     283           0 : Locale SAL_CALL ToolbarMenuAcc::getLocale() throw (IllegalAccessibleComponentStateException, RuntimeException)
     284             : {
     285           0 :     ThrowIfDisposed();
     286           0 :     const SolarMutexGuard aSolarGuard;
     287           0 :     const ::rtl::OUString aEmptyStr;
     288           0 :     Reference< XAccessible > xParent( getAccessibleParent() );
     289           0 :     Locale aRet( aEmptyStr, aEmptyStr, aEmptyStr );
     290             : 
     291           0 :     if( xParent.is() )
     292             :     {
     293           0 :         Reference< XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
     294             : 
     295           0 :         if( xParentContext.is() )
     296           0 :             aRet = xParentContext->getLocale ();
     297             :     }
     298             : 
     299           0 :     return aRet;
     300             : }
     301             : 
     302             : // -----------------------------------------------------------------------------
     303             : 
     304           0 : void SAL_CALL ToolbarMenuAcc::addAccessibleEventListener( const Reference< XAccessibleEventListener >& rxListener ) throw (RuntimeException)
     305             : {
     306           0 :     ThrowIfDisposed();
     307           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     308             : 
     309           0 :     if( rxListener.is() )
     310             :     {
     311           0 :            EventListenerVector::const_iterator aIter = mxEventListeners.begin();
     312           0 :         bool bFound = false;
     313             : 
     314           0 :         while( !bFound && ( aIter != mxEventListeners.end() ) )
     315             :         {
     316           0 :             if( *aIter == rxListener )
     317           0 :                 bFound = true;
     318             :             else
     319           0 :                 ++aIter;
     320             :         }
     321             : 
     322           0 :         if (!bFound)
     323           0 :             mxEventListeners.push_back( rxListener );
     324           0 :     }
     325           0 : }
     326             : 
     327             : // -----------------------------------------------------------------------------
     328             : 
     329           0 : void SAL_CALL ToolbarMenuAcc::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& rxListener ) throw (RuntimeException)
     330             : {
     331           0 :     ThrowIfDisposed();
     332           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     333             : 
     334           0 :     if( rxListener.is() )
     335             :     {
     336           0 :            EventListenerVector::iterator aIter = mxEventListeners.begin();
     337           0 :         bool bFound = false;
     338             : 
     339           0 :         while( !bFound && ( aIter != mxEventListeners.end() ) )
     340             :         {
     341           0 :             if( *aIter == rxListener )
     342             :             {
     343           0 :                 mxEventListeners.erase( aIter );
     344           0 :                 bFound = true;
     345             :             }
     346             :             else
     347           0 :                 ++aIter;
     348             :         }
     349           0 :     }
     350           0 : }
     351             : 
     352             : // -----------------------------------------------------------------------------
     353             : 
     354           0 : sal_Bool SAL_CALL ToolbarMenuAcc::containsPoint( const awt::Point& aPoint ) throw (RuntimeException)
     355             : {
     356           0 :     ThrowIfDisposed();
     357           0 :     const awt::Rectangle aRect( getBounds() );
     358           0 :     const Point aSize( aRect.Width, aRect.Height );
     359           0 :     const Point aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
     360             : 
     361           0 :     return Rectangle( aNullPoint, aSize ).IsInside( aTestPoint );
     362             : }
     363             : 
     364             : // -----------------------------------------------------------------------------
     365             : 
     366           0 : Reference< XAccessible > SAL_CALL ToolbarMenuAcc::getAccessibleAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
     367             : {
     368           0 :     const SolarMutexGuard aSolarGuard;
     369           0 :     ThrowIfDisposed();
     370             : 
     371           0 :     Reference< XAccessible > xRet;
     372             : 
     373           0 :     const Point aVclPoint( aPoint.X, aPoint.Y );
     374             : 
     375           0 :     const int nEntryCount = mpParent->maEntryVector.size();
     376           0 :     for( int nEntry = 0; (nEntry < nEntryCount) && !xRet.is(); nEntry++ )
     377             :     {
     378           0 :         ToolbarMenuEntry* pEntry = mpParent->maEntryVector[nEntry];
     379           0 :         if( pEntry && pEntry->maRect.IsInside( aVclPoint ) )
     380             :         {
     381           0 :             if( pEntry->mpControl )
     382             :             {
     383           0 :                 awt::Point aChildPoint( aPoint.X - pEntry->maRect.Left(), aPoint.Y - pEntry->maRect.Top() );
     384           0 :                 Reference< XAccessibleComponent > xComp( pEntry->GetAccessible(true), UNO_QUERY_THROW );
     385           0 :                 xRet = xComp->getAccessibleAtPoint(aChildPoint);
     386             :             }
     387             :             else
     388             :             {
     389           0 :                 xRet = Reference< XAccessible >( pEntry->GetAccessible(true), UNO_QUERY );
     390             :             }
     391             :         }
     392             :     }
     393           0 :     return xRet;
     394             : }
     395             : 
     396             : // -----------------------------------------------------------------------------
     397             : 
     398           0 : awt::Rectangle SAL_CALL ToolbarMenuAcc::getBounds() throw (RuntimeException)
     399             : {
     400           0 :     ThrowIfDisposed();
     401           0 :     const SolarMutexGuard aSolarGuard;
     402           0 :     const Point         aOutPos( mpParent->mrMenu.GetPosPixel() );
     403           0 :     const Size          aOutSize( mpParent->mrMenu.GetOutputSizePixel() );
     404           0 :     awt::Rectangle      aRet;
     405             : 
     406           0 :     aRet.X = aOutPos.X();
     407           0 :     aRet.Y = aOutPos.Y();
     408           0 :     aRet.Width = aOutSize.Width();
     409           0 :     aRet.Height = aOutSize.Height();
     410             : 
     411           0 :     return aRet;
     412             : }
     413             : 
     414             : // -----------------------------------------------------------------------------
     415             : 
     416           0 : awt::Point SAL_CALL ToolbarMenuAcc::getLocation() throw (RuntimeException)
     417             : {
     418           0 :     ThrowIfDisposed();
     419           0 :     const SolarMutexGuard aSolarGuard;
     420           0 :     const Point aOutPos( mpParent->mrMenu.GetPosPixel() );
     421           0 :     return awt::Point( aOutPos.X(), aOutPos.Y() );
     422             : }
     423             : 
     424             : // -----------------------------------------------------------------------------
     425             : 
     426           0 : awt::Point SAL_CALL ToolbarMenuAcc::getLocationOnScreen()  throw (RuntimeException)
     427             : {
     428           0 :     ThrowIfDisposed();
     429           0 :     const SolarMutexGuard aSolarGuard;
     430           0 :     const Point aScreenPos( mpParent->mrMenu.OutputToAbsoluteScreenPixel( Point() ) );
     431           0 :     return awt::Point( aScreenPos.X(), aScreenPos.Y() );
     432             : }
     433             : 
     434             : // -----------------------------------------------------------------------------
     435             : 
     436           0 : awt::Size SAL_CALL ToolbarMenuAcc::getSize() throw (RuntimeException)
     437             : {
     438           0 :     ThrowIfDisposed();
     439           0 :     const SolarMutexGuard aSolarGuard;
     440           0 :     const Size aOutSize( mpParent->mrMenu.GetOutputSizePixel() );
     441           0 :     return awt::Size( aOutSize.Width(), aOutSize.Height() );
     442             : }
     443             : 
     444             : // -----------------------------------------------------------------------------
     445             : 
     446           0 : void SAL_CALL ToolbarMenuAcc::grabFocus() throw (RuntimeException)
     447             : {
     448           0 :     ThrowIfDisposed();
     449           0 :     const SolarMutexGuard aSolarGuard;
     450           0 :     mpParent->mrMenu.GrabFocus();
     451           0 : }
     452             : 
     453             : // -----------------------------------------------------------------------------
     454             : 
     455           0 : Any SAL_CALL ToolbarMenuAcc::getAccessibleKeyBinding() throw (RuntimeException)
     456             : {
     457           0 :     ThrowIfDisposed();
     458           0 :     return Any();
     459             : }
     460             : 
     461             : // -----------------------------------------------------------------------------
     462             : 
     463           0 : sal_Int32 SAL_CALL ToolbarMenuAcc::getForeground() throw (RuntimeException)
     464             : {
     465           0 :     ThrowIfDisposed();
     466           0 :     sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetMenuTextColor().GetColor();
     467           0 :     return static_cast<sal_Int32>(nColor);
     468             : }
     469             : 
     470             : // -----------------------------------------------------------------------------
     471             : 
     472           0 : sal_Int32 SAL_CALL ToolbarMenuAcc::getBackground() throw (RuntimeException)
     473             : {
     474           0 :     ThrowIfDisposed();
     475           0 :     sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetMenuColor().GetColor();
     476           0 :     return static_cast<sal_Int32>(nColor);
     477             : }
     478             : 
     479             : // -----------------------------------------------------------------------------
     480             : 
     481           0 : void SAL_CALL ToolbarMenuAcc::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     482             : {
     483           0 :     const SolarMutexGuard aSolarGuard;
     484           0 :     ThrowIfDisposed();
     485             : 
     486           0 :     mpParent->selectAccessibleChild( nChildIndex );
     487           0 : }
     488             : 
     489             : // -----------------------------------------------------------------------------
     490             : 
     491           0 : sal_Bool SAL_CALL ToolbarMenuAcc::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     492             : {
     493           0 :     const SolarMutexGuard aSolarGuard;
     494           0 :     ThrowIfDisposed();
     495           0 :     return mpParent->isAccessibleChildSelected( nChildIndex );
     496             : }
     497             : 
     498             : // -----------------------------------------------------------------------------
     499             : 
     500           0 : void SAL_CALL ToolbarMenuAcc::clearAccessibleSelection() throw (RuntimeException)
     501             : {
     502           0 :     const SolarMutexGuard aSolarGuard;
     503           0 :     ThrowIfDisposed();
     504           0 :     mpParent->clearAccessibleSelection();
     505           0 : }
     506             : 
     507             : // -----------------------------------------------------------------------------
     508             : 
     509           0 : void SAL_CALL ToolbarMenuAcc::selectAllAccessibleChildren() throw (RuntimeException)
     510             : {
     511           0 :     ThrowIfDisposed();
     512             :     // unsupported due to single selection only
     513           0 : }
     514             : 
     515             : // -----------------------------------------------------------------------------
     516             : 
     517           0 : sal_Int32 SAL_CALL ToolbarMenuAcc::getSelectedAccessibleChildCount() throw (RuntimeException)
     518             : {
     519           0 :     const SolarMutexGuard aSolarGuard;
     520           0 :     ThrowIfDisposed();
     521             : 
     522           0 :     return mpParent->mnHighlightedEntry != -1 ? 1 : 0;
     523             : }
     524             : 
     525             : // -----------------------------------------------------------------------------
     526             : 
     527           0 : Reference< XAccessible > SAL_CALL ToolbarMenuAcc::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     528             : {
     529           0 :     ThrowIfDisposed();
     530           0 :     const SolarMutexGuard aSolarGuard;
     531             : 
     532           0 :     if( (mpParent->mnHighlightedEntry != -1) && (nSelectedChildIndex == 0) )
     533             :     {
     534           0 :         ToolbarMenuEntry* pEntry = mpParent->maEntryVector[ mpParent->mnHighlightedEntry ];
     535           0 :         if( pEntry )
     536             :         {
     537           0 :             if( pEntry->mpControl )
     538             :             {
     539           0 :                 Reference< XAccessibleSelection > xSel( pEntry->GetAccessible(true), UNO_QUERY_THROW );
     540           0 :                 return xSel->getSelectedAccessibleChild(0);
     541             :             }
     542             :             else
     543           0 :                 return Reference< XAccessible >( pEntry->GetAccessible(true), UNO_QUERY );
     544             :         }
     545             :     }
     546             : 
     547           0 :     throw IndexOutOfBoundsException();
     548             : }
     549             : 
     550             : // -----------------------------------------------------------------------------
     551             : 
     552           0 : void SAL_CALL ToolbarMenuAcc::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     553             : {
     554           0 :     ThrowIfDisposed();
     555           0 :     const SolarMutexGuard aSolarGuard;
     556             :     // Because of the single selection we can reset the whole selection when
     557             :     // the specified child is currently selected.
     558           0 :     if (isAccessibleChildSelected(nChildIndex))
     559           0 :         mpParent->clearAccessibleSelection();
     560           0 : }
     561             : 
     562             : // -----------------------------------------------------------------------------
     563             : 
     564           0 : void SAL_CALL ToolbarMenuAcc::disposing (void)
     565             : {
     566           0 :     EventListenerVector aListenerListCopy;
     567             : 
     568             :     {
     569             :         // Make a copy of the list and clear the original.
     570           0 :         const SolarMutexGuard aSolarGuard;
     571           0 :         ::osl::MutexGuard aGuard (m_aMutex);
     572           0 :         aListenerListCopy = mxEventListeners;
     573           0 :         mxEventListeners.clear();
     574             : 
     575             :         // Reset the pointer to the parent.  It has to be the one who has
     576             :         // disposed us because he is dying.
     577           0 :         mpParent = NULL;
     578             :     }
     579             : 
     580             :     // Inform all listeners that this objects is disposing.
     581           0 :     EventListenerVector::const_iterator aListenerIterator (aListenerListCopy.begin());
     582           0 :     EventObject aEvent (static_cast<XAccessible*>(this));
     583           0 :     while(aListenerIterator != aListenerListCopy.end())
     584             :     {
     585             :         try
     586             :         {
     587           0 :             (*aListenerIterator)->disposing (aEvent);
     588             :         }
     589           0 :         catch( Exception& )
     590             :         {
     591             :             // Ignore exceptions.
     592             :         }
     593             : 
     594           0 :         ++aListenerIterator;
     595           0 :     }
     596           0 : }
     597             : 
     598           0 : void ToolbarMenuAcc::ThrowIfDisposed (void) throw (DisposedException)
     599             : {
     600           0 :     if(rBHelper.bDisposed || rBHelper.bInDispose || !mpParent)
     601             :     {
     602           0 :         throw DisposedException ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("object has been already disposed")), static_cast<XWeak*>(this));
     603             :     }
     604           0 : }
     605             : 
     606             : // -----------------------
     607             : // - ToolbarMenuEntryAcc -
     608             : // -----------------------
     609             : 
     610           0 : ToolbarMenuEntryAcc::ToolbarMenuEntryAcc( ToolbarMenuEntry* pParent )
     611             : : ToolbarMenuEntryAccBase( m_aMutex )
     612           0 : , mpParent( pParent )
     613             : {
     614           0 : }
     615             : 
     616             : // -----------------------------------------------------------------------------
     617             : 
     618           0 : ToolbarMenuEntryAcc::~ToolbarMenuEntryAcc()
     619             : {
     620           0 : }
     621             : 
     622             : // -----------------------------------------------------------------------
     623             : 
     624           0 : void SAL_CALL ToolbarMenuEntryAcc::disposing (void)
     625             : {
     626           0 :     EventListenerVector aListenerListCopy;
     627             : 
     628             :     {
     629             :         // Make a copy of the list and clear the original.
     630           0 :         const SolarMutexGuard aSolarGuard;
     631           0 :         ::osl::MutexGuard aGuard (m_aMutex);
     632           0 :         aListenerListCopy = mxEventListeners;
     633           0 :         mxEventListeners.clear();
     634             : 
     635             :         // Reset the pointer to the parent.  It has to be the one who has
     636             :         // disposed us because he is dying.
     637           0 :         mpParent = NULL;
     638             :     }
     639             : 
     640             :     // Inform all listeners that this objects is disposing.
     641           0 :     EventListenerVector::const_iterator aListenerIterator (aListenerListCopy.begin());
     642           0 :     EventObject aEvent (static_cast<XAccessible*>(this));
     643           0 :     while(aListenerIterator != aListenerListCopy.end())
     644             :     {
     645             :         try
     646             :         {
     647           0 :             (*aListenerIterator)->disposing (aEvent);
     648             :         }
     649           0 :         catch( Exception& )
     650             :         {
     651             :             // Ignore exceptions.
     652             :         }
     653             : 
     654           0 :         ++aListenerIterator;
     655           0 :     }
     656           0 : }
     657             : // -----------------------------------------------------------------------------
     658             : 
     659           0 : Reference< XAccessibleContext > SAL_CALL ToolbarMenuEntryAcc::getAccessibleContext() throw (RuntimeException)
     660             : {
     661           0 :     return this;
     662             : }
     663             : 
     664             : // -----------------------------------------------------------------------------
     665             : 
     666           0 : sal_Int32 SAL_CALL ToolbarMenuEntryAcc::getAccessibleChildCount() throw (RuntimeException)
     667             : {
     668           0 :     return 0;
     669             : }
     670             : 
     671             : // -----------------------------------------------------------------------------
     672             : 
     673           0 : Reference< XAccessible > SAL_CALL ToolbarMenuEntryAcc::getAccessibleChild( sal_Int32 ) throw (IndexOutOfBoundsException, RuntimeException)
     674             : {
     675           0 :     throw IndexOutOfBoundsException();
     676             : }
     677             : 
     678             : // -----------------------------------------------------------------------------
     679             : 
     680           0 : Reference< XAccessible > SAL_CALL ToolbarMenuEntryAcc::getAccessibleParent() throw (RuntimeException)
     681             : {
     682           0 :     const SolarMutexGuard aSolarGuard;
     683           0 :     Reference< XAccessible > xRet;
     684             : 
     685           0 :     if( mpParent )
     686           0 :         xRet = mpParent->mrMenu.GetAccessible();
     687             : 
     688           0 :     return xRet;
     689             : }
     690             : 
     691             : // -----------------------------------------------------------------------------
     692             : 
     693           0 : sal_Int32 SAL_CALL ToolbarMenuEntryAcc::getAccessibleIndexInParent() throw (RuntimeException)
     694             : {
     695           0 :     const SolarMutexGuard aSolarGuard;
     696             :     // The index defaults to -1 to indicate the child does not belong to its
     697             :     // parent.
     698           0 :     sal_Int32 nIndexInParent = -1;
     699             : 
     700           0 :     if( mpParent )
     701             :     {
     702           0 :         Reference< XAccessibleContext > xParent( mpParent->mrMenu.GetAccessible(), UNO_QUERY );
     703             : 
     704           0 :         if( xParent.is() )
     705             :         {
     706           0 :             Reference< XAccessible > xThis( this );
     707             : 
     708           0 :             const sal_Int32 nCount = xParent->getAccessibleChildCount();
     709           0 :             for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
     710             :             {
     711           0 :                 if( xParent->getAccessibleChild(nIndex) == xThis )
     712             :                 {
     713           0 :                     nIndexInParent = nIndex;
     714           0 :                     break;
     715             :                 }
     716           0 :             }
     717           0 :         }
     718             :     }
     719             : 
     720           0 :     return nIndexInParent;
     721             : }
     722             : 
     723             : // -----------------------------------------------------------------------------
     724             : 
     725           0 : sal_Int16 SAL_CALL ToolbarMenuEntryAcc::getAccessibleRole() throw (RuntimeException)
     726             : {
     727           0 :     return AccessibleRole::LIST_ITEM;
     728             : }
     729             : 
     730             : // -----------------------------------------------------------------------------
     731             : 
     732           0 : ::rtl::OUString SAL_CALL ToolbarMenuEntryAcc::getAccessibleDescription() throw (RuntimeException)
     733             : {
     734           0 :     return ::rtl::OUString();
     735             : }
     736             : 
     737             : // -----------------------------------------------------------------------------
     738             : 
     739           0 : ::rtl::OUString SAL_CALL ToolbarMenuEntryAcc::getAccessibleName() throw (RuntimeException)
     740             : {
     741           0 :     const SolarMutexGuard aSolarGuard;
     742           0 :     String              aRet;
     743             : 
     744           0 :     if( mpParent )
     745             :     {
     746           0 :         aRet = mpParent->maText;
     747             : 
     748           0 :         if( !aRet.Len() )
     749             :         {
     750           0 :             aRet = String( RTL_CONSTASCII_USTRINGPARAM( "Item " ) );
     751           0 :             aRet += String::CreateFromInt32( mpParent->mnEntryId );
     752             :         }
     753             :     }
     754             : 
     755           0 :     return aRet;
     756             : }
     757             : 
     758             : // -----------------------------------------------------------------------------
     759             : 
     760           0 : Reference< XAccessibleRelationSet > SAL_CALL ToolbarMenuEntryAcc::getAccessibleRelationSet() throw (RuntimeException)
     761             : {
     762           0 :     return Reference< XAccessibleRelationSet >();
     763             : }
     764             : 
     765             : // -----------------------------------------------------------------------------
     766             : 
     767           0 : Reference< XAccessibleStateSet > SAL_CALL ToolbarMenuEntryAcc::getAccessibleStateSet() throw (RuntimeException)
     768             : {
     769           0 :     const SolarMutexGuard aSolarGuard;
     770           0 :     ::utl::AccessibleStateSetHelper*    pStateSet = new ::utl::AccessibleStateSetHelper;
     771             : 
     772           0 :     if( mpParent )
     773             :     {
     774           0 :         pStateSet->AddState (AccessibleStateType::ENABLED);
     775           0 :         pStateSet->AddState (AccessibleStateType::SENSITIVE);
     776           0 :         pStateSet->AddState (AccessibleStateType::SHOWING);
     777           0 :         pStateSet->AddState (AccessibleStateType::VISIBLE);
     778           0 :         pStateSet->AddState (AccessibleStateType::TRANSIENT);
     779           0 :         if( mpParent->mnEntryId != TITLE_ID )
     780             :         {
     781           0 :             pStateSet->AddState( AccessibleStateType::SELECTABLE );
     782             : 
     783             :             // SELECTED
     784           0 :             if( mpParent->mrMenu.getHighlightedEntryId() == mpParent->mnEntryId )
     785           0 :                 pStateSet->AddState( AccessibleStateType::SELECTED );
     786             :         }
     787             :     }
     788             : 
     789           0 :     return pStateSet;
     790             : }
     791             : 
     792             : // -----------------------------------------------------------------------------
     793             : 
     794           0 : Locale SAL_CALL ToolbarMenuEntryAcc::getLocale() throw (IllegalAccessibleComponentStateException, RuntimeException)
     795             : {
     796           0 :     const ::rtl::OUString aEmptyStr;
     797           0 :     Locale aRet( aEmptyStr, aEmptyStr, aEmptyStr );
     798             : 
     799           0 :     Reference< XAccessible > xParent( getAccessibleParent() );
     800           0 :     if( xParent.is() )
     801             :     {
     802           0 :         Reference< XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
     803             : 
     804           0 :         if( xParentContext.is() )
     805           0 :             aRet = xParentContext->getLocale();
     806             :     }
     807             : 
     808           0 :     return aRet;
     809             : }
     810             : 
     811             : // -----------------------------------------------------------------------------
     812             : 
     813           0 : void SAL_CALL ToolbarMenuEntryAcc::addAccessibleEventListener( const Reference< XAccessibleEventListener >& rxListener ) throw (RuntimeException)
     814             : {
     815           0 :     const ::osl::MutexGuard aGuard( maMutex );
     816             : 
     817           0 :     if( rxListener.is() )
     818             :     {
     819           0 :            EventListenerVector::const_iterator aIter( mxEventListeners.begin() );
     820           0 :         bool bFound = false;
     821             : 
     822           0 :         while( !bFound && ( aIter != mxEventListeners.end() ) )
     823             :         {
     824           0 :             if( *aIter == rxListener )
     825           0 :                 bFound = true;
     826             :             else
     827           0 :                 aIter++;
     828             :         }
     829             : 
     830           0 :         if (!bFound)
     831           0 :             mxEventListeners.push_back( rxListener );
     832           0 :     }
     833           0 : }
     834             : 
     835             : // -----------------------------------------------------------------------------
     836             : 
     837           0 : void SAL_CALL ToolbarMenuEntryAcc::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& rxListener ) throw (RuntimeException)
     838             : {
     839           0 :     const ::osl::MutexGuard aGuard( maMutex );
     840             : 
     841           0 :     if( rxListener.is() )
     842             :     {
     843           0 :            EventListenerVector::iterator aIter = mxEventListeners.begin();
     844           0 :         bool bFound = false;
     845             : 
     846           0 :         while( !bFound && ( aIter != mxEventListeners.end() ) )
     847             :         {
     848           0 :             if( *aIter == rxListener )
     849             :             {
     850           0 :                 mxEventListeners.erase( aIter );
     851           0 :                 bFound = true;
     852             :             }
     853             :             else
     854           0 :                 ++aIter;
     855             :         }
     856           0 :     }
     857           0 : }
     858             : 
     859             : // -----------------------------------------------------------------------------
     860             : 
     861           0 : sal_Bool SAL_CALL ToolbarMenuEntryAcc::containsPoint( const awt::Point& aPoint ) throw (RuntimeException)
     862             : {
     863           0 :     const awt::Rectangle    aRect( getBounds() );
     864           0 :     const Point             aSize( aRect.Width, aRect.Height );
     865           0 :     const Point             aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
     866             : 
     867           0 :     return Rectangle( aNullPoint, aSize ).IsInside( aTestPoint );
     868             : }
     869             : 
     870             : // -----------------------------------------------------------------------------
     871             : 
     872           0 : Reference< XAccessible > SAL_CALL ToolbarMenuEntryAcc::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
     873             : {
     874           0 :     Reference< XAccessible > xRet;
     875           0 :     return xRet;
     876             : }
     877             : 
     878             : // -----------------------------------------------------------------------------
     879             : 
     880           0 : awt::Rectangle SAL_CALL ToolbarMenuEntryAcc::getBounds() throw (RuntimeException)
     881             : {
     882           0 :     const SolarMutexGuard aSolarGuard;
     883           0 :     awt::Rectangle      aRet;
     884             : 
     885           0 :     if( mpParent )
     886             :     {
     887           0 :         Rectangle   aRect( mpParent->maRect );
     888           0 :         Point       aOrigin;
     889           0 :         Rectangle   aParentRect( aOrigin, mpParent->mrMenu.GetOutputSizePixel() );
     890             : 
     891           0 :         aRect.Intersection( aParentRect );
     892             : 
     893           0 :         aRet.X = aRect.Left();
     894           0 :         aRet.Y = aRect.Top();
     895           0 :         aRet.Width = aRect.GetWidth();
     896           0 :         aRet.Height = aRect.GetHeight();
     897             :     }
     898             : 
     899           0 :     return aRet;
     900             : }
     901             : 
     902             : // -----------------------------------------------------------------------------
     903             : 
     904           0 : awt::Point SAL_CALL ToolbarMenuEntryAcc::getLocation() throw (RuntimeException)
     905             : {
     906           0 :     const awt::Rectangle aRect( getBounds() );
     907           0 :     return awt::Point( aRect.X, aRect.Y );
     908             : }
     909             : 
     910             : // -----------------------------------------------------------------------------
     911             : 
     912           0 : awt::Point SAL_CALL ToolbarMenuEntryAcc::getLocationOnScreen() throw (RuntimeException)
     913             : {
     914           0 :     const SolarMutexGuard aSolarGuard;
     915           0 :     awt::Point aRet;
     916             : 
     917           0 :     if( mpParent )
     918             :     {
     919           0 :         const Point aScreenPos( mpParent->mrMenu.OutputToAbsoluteScreenPixel( mpParent->maRect.TopLeft() ) );
     920             : 
     921           0 :         aRet.X = aScreenPos.X();
     922           0 :         aRet.Y = aScreenPos.Y();
     923             :     }
     924             : 
     925           0 :     return aRet;
     926             : }
     927             : 
     928             : // -----------------------------------------------------------------------------
     929             : 
     930           0 : awt::Size SAL_CALL ToolbarMenuEntryAcc::getSize() throw (RuntimeException)
     931             : {
     932           0 :     const awt::Rectangle aRect( getBounds() );
     933           0 :     awt::Size aRet;
     934             : 
     935           0 :     aRet.Width = aRect.Width;
     936           0 :     aRet.Height = aRect.Height;
     937             : 
     938           0 :     return aRet;
     939             : }
     940             : 
     941             : // -----------------------------------------------------------------------------
     942             : 
     943           0 : void SAL_CALL ToolbarMenuEntryAcc::grabFocus() throw (RuntimeException)
     944             : {
     945             :     // nothing to do
     946           0 : }
     947             : 
     948             : // -----------------------------------------------------------------------------
     949             : 
     950           0 : Any SAL_CALL ToolbarMenuEntryAcc::getAccessibleKeyBinding() throw (RuntimeException)
     951             : {
     952           0 :     return Any();
     953             : }
     954             : 
     955             : // -----------------------------------------------------------------------------
     956             : 
     957           0 : sal_Int32 SAL_CALL ToolbarMenuEntryAcc::getForeground(  ) throw (RuntimeException)
     958             : {
     959           0 :     return static_cast<sal_Int32>(Application::GetSettings().GetStyleSettings().GetMenuTextColor().GetColor());
     960             : }
     961             : 
     962             : // -----------------------------------------------------------------------------
     963             : 
     964           0 : sal_Int32 SAL_CALL ToolbarMenuEntryAcc::getBackground(  )  throw (RuntimeException)
     965             : {
     966           0 :     return static_cast<sal_Int32>(Application::GetSettings().GetStyleSettings().GetMenuColor().GetColor());
     967             : }
     968             : 
     969             : }
     970             : 
     971             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10