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

Generated by: LCOV version 1.10