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

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

Generated by: LCOV version 1.10