1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "thumbnailviewacc.hxx"
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>
28 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
29 #include <com/sun/star/accessibility/AccessibleRole.hpp>
30 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
32 using namespace ::com::sun::star
;
34 ThumbnailViewAcc::ThumbnailViewAcc( ThumbnailView
* pParent
, bool bIsTransientChildrenDisabled
) :
35 ValueSetAccComponentBase (m_aMutex
),
37 mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled
),
42 ThumbnailViewAcc::~ThumbnailViewAcc()
46 void ThumbnailViewAcc::FireAccessibleEvent( short nEventId
, const uno::Any
& rOldValue
, const uno::Any
& rNewValue
)
50 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> > aTmpListeners( mxEventListeners
);
51 accessibility::AccessibleEventObject aEvtObject
;
53 aEvtObject
.EventId
= nEventId
;
54 aEvtObject
.Source
= static_cast<uno::XWeak
*>(this);
55 aEvtObject
.NewValue
= rNewValue
;
56 aEvtObject
.OldValue
= rOldValue
;
58 for (::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator
aIter( aTmpListeners
.begin() ), aEnd( aTmpListeners
.end() );
59 aIter
!= aEnd
; ++aIter
)
63 (*aIter
)->notifyEvent( aEvtObject
);
65 catch(const uno::Exception
&)
74 class theValueSetAccUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theValueSetAccUnoTunnelId
> {};
77 const uno::Sequence
< sal_Int8
>& ThumbnailViewAcc::getUnoTunnelId()
79 return theValueSetAccUnoTunnelId::get().getSeq();
82 ThumbnailViewAcc
* ThumbnailViewAcc::getImplementation( const uno::Reference
< uno::XInterface
>& rxData
)
87 uno::Reference
< lang::XUnoTunnel
> xUnoTunnel( rxData
, uno::UNO_QUERY
);
88 return( xUnoTunnel
.is() ? reinterpret_cast<ThumbnailViewAcc
*>(sal::static_int_cast
<sal_IntPtr
>(xUnoTunnel
->getSomething( ThumbnailViewAcc::getUnoTunnelId() ))) : NULL
);
90 catch(const ::com::sun::star::uno::Exception
&)
96 void ThumbnailViewAcc::GetFocus (void)
100 // Boradcast the state change.
101 ::com::sun::star::uno::Any aOldState
, aNewState
;
102 aNewState
<<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED
;
104 ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED
,
105 aOldState
, aNewState
);
108 void ThumbnailViewAcc::LoseFocus (void)
112 // Boradcast the state change.
113 ::com::sun::star::uno::Any aOldState
, aNewState
;
114 aOldState
<<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED
;
116 ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED
,
117 aOldState
, aNewState
);
120 uno::Reference
< accessibility::XAccessibleContext
> SAL_CALL
ThumbnailViewAcc::getAccessibleContext()
121 throw (uno::RuntimeException
)
127 sal_Int32 SAL_CALL
ThumbnailViewAcc::getAccessibleChildCount()
128 throw (uno::RuntimeException
)
130 const SolarMutexGuard aSolarGuard
;
133 sal_Int32 nCount
= mpParent
->ImplGetVisibleItemCount();
137 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ThumbnailViewAcc::getAccessibleChild( sal_Int32 i
)
138 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
141 const SolarMutexGuard aSolarGuard
;
142 uno::Reference
< accessibility::XAccessible
> xRet
;
143 ThumbnailViewItem
* pItem
= getItem (sal::static_int_cast
< sal_uInt16
>(i
));
146 xRet
= pItem
->GetAccessible( mbIsTransientChildrenDisabled
);
148 throw lang::IndexOutOfBoundsException();
153 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ThumbnailViewAcc::getAccessibleParent()
154 throw (uno::RuntimeException
)
157 const SolarMutexGuard aSolarGuard
;
158 Window
* pParent
= mpParent
->GetParent();
159 uno::Reference
< accessibility::XAccessible
> xRet
;
162 xRet
= pParent
->GetAccessible();
167 sal_Int32 SAL_CALL
ThumbnailViewAcc::getAccessibleIndexInParent()
168 throw (uno::RuntimeException
)
171 const SolarMutexGuard aSolarGuard
;
172 Window
* pParent
= mpParent
->GetParent();
177 sal_Bool bFound
= sal_False
;
179 for( sal_uInt16 i
= 0, nCount
= pParent
->GetChildCount(); ( i
< nCount
) && !bFound
; i
++ )
181 if( pParent
->GetChild( i
) == mpParent
)
192 sal_Int16 SAL_CALL
ThumbnailViewAcc::getAccessibleRole()
193 throw (uno::RuntimeException
)
196 // #i73746# As the Java Access Bridge (v 2.0.1) uses "managesDescendants"
197 // always if the role is LIST, we need a different role in this case
198 return (mbIsTransientChildrenDisabled
199 ? accessibility::AccessibleRole::PANEL
200 : accessibility::AccessibleRole::LIST
);
203 OUString SAL_CALL
ThumbnailViewAcc::getAccessibleDescription()
204 throw (uno::RuntimeException
)
207 const SolarMutexGuard aSolarGuard
;
208 return OUString("ThumbnailView");
211 OUString SAL_CALL
ThumbnailViewAcc::getAccessibleName()
212 throw (uno::RuntimeException
)
215 const SolarMutexGuard aSolarGuard
;
219 aRet
= mpParent
->GetAccessibleName();
221 if ( aRet
.isEmpty() )
223 Window
* pLabel
= mpParent
->GetAccessibleRelationLabeledBy();
224 if ( pLabel
&& pLabel
!= mpParent
)
225 aRet
= OutputDevice::GetNonMnemonicString( pLabel
->GetText() );
231 uno::Reference
< accessibility::XAccessibleRelationSet
> SAL_CALL
ThumbnailViewAcc::getAccessibleRelationSet()
232 throw (uno::RuntimeException
)
235 return uno::Reference
< accessibility::XAccessibleRelationSet
>();
238 uno::Reference
< accessibility::XAccessibleStateSet
> SAL_CALL
ThumbnailViewAcc::getAccessibleStateSet()
239 throw (uno::RuntimeException
)
242 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper();
245 pStateSet
->AddState (accessibility::AccessibleStateType::ENABLED
);
246 pStateSet
->AddState (accessibility::AccessibleStateType::SENSITIVE
);
247 pStateSet
->AddState (accessibility::AccessibleStateType::SHOWING
);
248 pStateSet
->AddState (accessibility::AccessibleStateType::VISIBLE
);
249 if ( !mbIsTransientChildrenDisabled
)
250 pStateSet
->AddState (accessibility::AccessibleStateType::MANAGES_DESCENDANTS
);
251 pStateSet
->AddState (accessibility::AccessibleStateType::FOCUSABLE
);
253 pStateSet
->AddState (accessibility::AccessibleStateType::FOCUSED
);
258 lang::Locale SAL_CALL
ThumbnailViewAcc::getLocale()
259 throw (accessibility::IllegalAccessibleComponentStateException
, uno::RuntimeException
)
262 const SolarMutexGuard aSolarGuard
;
263 const OUString aEmptyStr
;
264 uno::Reference
< accessibility::XAccessible
> xParent( getAccessibleParent() );
265 lang::Locale
aRet( aEmptyStr
, aEmptyStr
, aEmptyStr
);
269 uno::Reference
< accessibility::XAccessibleContext
> xParentContext( xParent
->getAccessibleContext() );
271 if( xParentContext
.is() )
272 aRet
= xParentContext
->getLocale ();
278 void SAL_CALL
ThumbnailViewAcc::addAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
279 throw (uno::RuntimeException
)
282 ::osl::MutexGuard
aGuard (m_aMutex
);
284 if( rxListener
.is() )
286 std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator aIter
= mxEventListeners
.begin();
289 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
291 if( *aIter
== rxListener
)
298 mxEventListeners
.push_back( rxListener
);
302 void SAL_CALL
ThumbnailViewAcc::removeAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
303 throw (uno::RuntimeException
)
306 ::osl::MutexGuard
aGuard (m_aMutex
);
308 if( rxListener
.is() )
310 std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::iterator aIter
= mxEventListeners
.begin();
313 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
315 if( *aIter
== rxListener
)
317 mxEventListeners
.erase( aIter
);
326 sal_Bool SAL_CALL
ThumbnailViewAcc::containsPoint( const awt::Point
& aPoint
)
327 throw (uno::RuntimeException
)
330 const awt::Rectangle
aRect( getBounds() );
331 const Point
aSize( aRect
.Width
, aRect
.Height
);
332 const Point aNullPoint
, aTestPoint( aPoint
.X
, aPoint
.Y
);
334 return Rectangle( aNullPoint
, aSize
).IsInside( aTestPoint
);
337 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ThumbnailViewAcc::getAccessibleAtPoint( const awt::Point
& aPoint
)
338 throw (uno::RuntimeException
)
341 const SolarMutexGuard aSolarGuard
;
342 const sal_uInt16 nItemId
= mpParent
->GetItemId( Point( aPoint
.X
, aPoint
.Y
) );
343 uno::Reference
< accessibility::XAccessible
> xRet
;
347 const size_t nItemPos
= mpParent
->GetItemPos( nItemId
);
349 if( THUMBNAILVIEW_ITEM_NONEITEM
!= nItemPos
)
351 ThumbnailViewItem
*const pItem
= mpParent
->mFilteredItemList
[nItemPos
];
352 xRet
= pItem
->GetAccessible( mbIsTransientChildrenDisabled
);
359 awt::Rectangle SAL_CALL
ThumbnailViewAcc::getBounds()
360 throw (uno::RuntimeException
)
363 const SolarMutexGuard aSolarGuard
;
364 const Point
aOutPos( mpParent
->GetPosPixel() );
365 const Size
aOutSize( mpParent
->GetOutputSizePixel() );
368 aRet
.X
= aOutPos
.X();
369 aRet
.Y
= aOutPos
.Y();
370 aRet
.Width
= aOutSize
.Width();
371 aRet
.Height
= aOutSize
.Height();
376 awt::Point SAL_CALL
ThumbnailViewAcc::getLocation()
377 throw (uno::RuntimeException
)
380 const awt::Rectangle
aRect( getBounds() );
389 awt::Point SAL_CALL
ThumbnailViewAcc::getLocationOnScreen()
390 throw (uno::RuntimeException
)
393 const SolarMutexGuard aSolarGuard
;
394 const Point
aScreenPos( mpParent
->OutputToAbsoluteScreenPixel( Point() ) );
397 aRet
.X
= aScreenPos
.X();
398 aRet
.Y
= aScreenPos
.Y();
403 awt::Size SAL_CALL
ThumbnailViewAcc::getSize()
404 throw (uno::RuntimeException
)
407 const awt::Rectangle
aRect( getBounds() );
410 aRet
.Width
= aRect
.Width
;
411 aRet
.Height
= aRect
.Height
;
416 void SAL_CALL
ThumbnailViewAcc::grabFocus()
417 throw (uno::RuntimeException
)
420 const SolarMutexGuard aSolarGuard
;
421 mpParent
->GrabFocus();
424 uno::Any SAL_CALL
ThumbnailViewAcc::getAccessibleKeyBinding()
425 throw (uno::RuntimeException
)
431 sal_Int32 SAL_CALL
ThumbnailViewAcc::getForeground( )
432 throw (uno::RuntimeException
)
435 sal_uInt32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
436 return static_cast<sal_Int32
>(nColor
);
439 sal_Int32 SAL_CALL
ThumbnailViewAcc::getBackground( )
440 throw (uno::RuntimeException
)
443 sal_uInt32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
444 return static_cast<sal_Int32
>(nColor
);
447 void SAL_CALL
ThumbnailViewAcc::selectAccessibleChild( sal_Int32 nChildIndex
)
448 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
451 const SolarMutexGuard aSolarGuard
;
452 ThumbnailViewItem
* pItem
= getItem (sal::static_int_cast
< sal_uInt16
>(nChildIndex
));
456 mpParent
->SelectItem( pItem
->mnId
);
459 throw lang::IndexOutOfBoundsException();
462 sal_Bool SAL_CALL
ThumbnailViewAcc::isAccessibleChildSelected( sal_Int32 nChildIndex
)
463 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
466 const SolarMutexGuard aSolarGuard
;
467 ThumbnailViewItem
* pItem
= getItem (sal::static_int_cast
< sal_uInt16
>(nChildIndex
));
468 sal_Bool bRet
= sal_False
;
471 bRet
= mpParent
->IsItemSelected( pItem
->mnId
);
473 throw lang::IndexOutOfBoundsException();
478 void SAL_CALL
ThumbnailViewAcc::clearAccessibleSelection()
479 throw (uno::RuntimeException
)
482 const SolarMutexGuard aSolarGuard
;
485 void SAL_CALL
ThumbnailViewAcc::selectAllAccessibleChildren()
486 throw (uno::RuntimeException
)
489 // unsupported due to single selection only
492 sal_Int32 SAL_CALL
ThumbnailViewAcc::getSelectedAccessibleChildCount()
493 throw (uno::RuntimeException
)
496 const SolarMutexGuard aSolarGuard
;
499 for( sal_uInt16 i
= 0, nCount
= getItemCount(); i
< nCount
; i
++ )
501 ThumbnailViewItem
* pItem
= getItem (i
);
503 if( pItem
&& mpParent
->IsItemSelected( pItem
->mnId
) )
510 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ThumbnailViewAcc::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
)
511 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
514 const SolarMutexGuard aSolarGuard
;
515 uno::Reference
< accessibility::XAccessible
> xRet
;
517 for( sal_uInt16 i
= 0, nCount
= getItemCount(), nSel
= 0; ( i
< nCount
) && !xRet
.is(); i
++ )
519 ThumbnailViewItem
* pItem
= getItem(i
);
521 if( pItem
&& mpParent
->IsItemSelected( pItem
->mnId
) && ( nSelectedChildIndex
== static_cast< sal_Int32
>( nSel
++ ) ) )
522 xRet
= pItem
->GetAccessible( mbIsTransientChildrenDisabled
);
528 void SAL_CALL
ThumbnailViewAcc::deselectAccessibleChild( sal_Int32 nChildIndex
)
529 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
532 const SolarMutexGuard aSolarGuard
;
533 // Because of the single selection we can reset the whole selection when
534 // the specified child is currently selected.
535 //FIXME TODO if (isAccessibleChildSelected(nChildIndex))
540 sal_Int64 SAL_CALL
ThumbnailViewAcc::getSomething( const uno::Sequence
< sal_Int8
>& rId
) throw( uno::RuntimeException
)
544 if( ( rId
.getLength() == 16 ) && ( 0 == memcmp( ThumbnailViewAcc::getUnoTunnelId().getConstArray(), rId
.getConstArray(), 16 ) ) )
545 nRet
= reinterpret_cast< sal_Int64
>( this );
552 void SAL_CALL
ThumbnailViewAcc::disposing (void)
554 ::std::vector
<uno::Reference
<accessibility::XAccessibleEventListener
> > aListenerListCopy
;
557 // Make a copy of the list and clear the original.
558 const SolarMutexGuard aSolarGuard
;
559 ::osl::MutexGuard
aGuard (m_aMutex
);
560 aListenerListCopy
= mxEventListeners
;
561 mxEventListeners
.clear();
563 // Reset the pointer to the parent. It has to be the one who has
564 // disposed us because he is dying.
568 // Inform all listeners that this objects is disposing.
569 ::std::vector
<uno::Reference
<accessibility::XAccessibleEventListener
> >::const_iterator
570 aListenerIterator (aListenerListCopy
.begin());
571 lang::EventObject
aEvent (static_cast<accessibility::XAccessible
*>(this));
572 while (aListenerIterator
!= aListenerListCopy
.end())
576 (*aListenerIterator
)->disposing (aEvent
);
578 catch(const uno::Exception
&)
580 // Ignore exceptions.
587 sal_uInt16
ThumbnailViewAcc::getItemCount (void) const
589 return mpParent
->ImplGetVisibleItemCount();
592 ThumbnailViewItem
* ThumbnailViewAcc::getItem (sal_uInt16 nIndex
) const
594 return mpParent
->ImplGetVisibleItem (static_cast<sal_uInt16
>(nIndex
));
597 void ThumbnailViewAcc::ThrowIfDisposed (void)
598 throw (::com::sun::star::lang::DisposedException
)
600 if (rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
602 OSL_TRACE ("Calling disposed object. Throwing exception:");
603 throw lang::DisposedException (
604 OUString("object has been already disposed"),
605 static_cast<uno::XWeak
*>(this));
609 DBG_ASSERT (mpParent
!=NULL
, "ValueSetAcc not disposed but mpParent == NULL");
613 ThumbnailViewItemAcc::ThumbnailViewItemAcc( ThumbnailViewItem
* pParent
, bool bIsTransientChildrenDisabled
) :
615 mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled
)
619 ThumbnailViewItemAcc::~ThumbnailViewItemAcc()
623 void ThumbnailViewItemAcc::ParentDestroyed()
625 const ::osl::MutexGuard
aGuard( maMutex
);
631 class theValueItemAccUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theValueItemAccUnoTunnelId
> {};
634 const uno::Sequence
< sal_Int8
>& ThumbnailViewItemAcc::getUnoTunnelId()
636 return theValueItemAccUnoTunnelId::get().getSeq();
639 uno::Reference
< accessibility::XAccessibleContext
> SAL_CALL
ThumbnailViewItemAcc::getAccessibleContext()
640 throw (uno::RuntimeException
)
645 sal_Int32 SAL_CALL
ThumbnailViewItemAcc::getAccessibleChildCount()
646 throw (uno::RuntimeException
)
651 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ThumbnailViewItemAcc::getAccessibleChild( sal_Int32
)
652 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
654 throw lang::IndexOutOfBoundsException();
657 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ThumbnailViewItemAcc::getAccessibleParent()
658 throw (uno::RuntimeException
)
660 const SolarMutexGuard aSolarGuard
;
661 uno::Reference
< accessibility::XAccessible
> xRet
;
664 xRet
= mpParent
->mrParent
.GetAccessible();
669 sal_Int32 SAL_CALL
ThumbnailViewItemAcc::getAccessibleIndexInParent()
670 throw (uno::RuntimeException
)
672 const SolarMutexGuard aSolarGuard
;
673 // The index defaults to -1 to indicate the child does not belong to its
675 sal_Int32 nIndexInParent
= -1;
681 sal_uInt16 nCount
= mpParent
->mrParent
.ImplGetVisibleItemCount();
682 ThumbnailViewItem
* pItem
;
683 for (sal_uInt16 i
=0; i
<nCount
&& !bDone
; i
++)
685 // Guard the retrieval of the i-th child with a try/catch block
686 // just in case the number of children changes in the mean time.
689 pItem
= mpParent
->mrParent
.ImplGetVisibleItem (i
);
691 catch (const lang::IndexOutOfBoundsException
&)
696 // Do not create an accessible object for the test.
697 if (pItem
!= NULL
&& pItem
->mpxAcc
!= NULL
)
698 if (pItem
->GetAccessible( mbIsTransientChildrenDisabled
).get() == this )
706 return nIndexInParent
;
709 sal_Int16 SAL_CALL
ThumbnailViewItemAcc::getAccessibleRole()
710 throw (uno::RuntimeException
)
712 return accessibility::AccessibleRole::LIST_ITEM
;
715 OUString SAL_CALL
ThumbnailViewItemAcc::getAccessibleDescription()
716 throw (uno::RuntimeException
)
721 OUString SAL_CALL
ThumbnailViewItemAcc::getAccessibleName()
722 throw (uno::RuntimeException
)
724 const SolarMutexGuard aSolarGuard
;
729 aRet
= mpParent
->maTitle
;
733 OUStringBuffer
aBuffer("Item ");
734 aBuffer
.append(static_cast<sal_Int32
>(mpParent
->mnId
));
735 aRet
= aBuffer
.makeStringAndClear();
742 uno::Reference
< accessibility::XAccessibleRelationSet
> SAL_CALL
ThumbnailViewItemAcc::getAccessibleRelationSet()
743 throw (uno::RuntimeException
)
745 return uno::Reference
< accessibility::XAccessibleRelationSet
>();
748 uno::Reference
< accessibility::XAccessibleStateSet
> SAL_CALL
ThumbnailViewItemAcc::getAccessibleStateSet()
749 throw (uno::RuntimeException
)
751 const SolarMutexGuard aSolarGuard
;
752 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper
;
756 pStateSet
->AddState (accessibility::AccessibleStateType::ENABLED
);
757 pStateSet
->AddState (accessibility::AccessibleStateType::SENSITIVE
);
758 pStateSet
->AddState (accessibility::AccessibleStateType::SHOWING
);
759 pStateSet
->AddState (accessibility::AccessibleStateType::VISIBLE
);
760 if ( !mbIsTransientChildrenDisabled
)
761 pStateSet
->AddState (accessibility::AccessibleStateType::TRANSIENT
);
764 pStateSet
->AddState( accessibility::AccessibleStateType::SELECTABLE
);
765 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE );
768 if( mpParent
->isSelected() )
770 pStateSet
->AddState( accessibility::AccessibleStateType::SELECTED
);
771 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSED );
778 lang::Locale SAL_CALL
ThumbnailViewItemAcc::getLocale()
779 throw (accessibility::IllegalAccessibleComponentStateException
, uno::RuntimeException
)
781 const SolarMutexGuard aSolarGuard
;
782 const OUString aEmptyStr
;
783 uno::Reference
< accessibility::XAccessible
> xParent( getAccessibleParent() );
784 lang::Locale
aRet( aEmptyStr
, aEmptyStr
, aEmptyStr
);
788 uno::Reference
< accessibility::XAccessibleContext
> xParentContext( xParent
->getAccessibleContext() );
790 if( xParentContext
.is() )
791 aRet
= xParentContext
->getLocale();
797 void SAL_CALL
ThumbnailViewItemAcc::addAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
798 throw (uno::RuntimeException
)
800 const ::osl::MutexGuard
aGuard( maMutex
);
802 if( rxListener
.is() )
804 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator aIter
= mxEventListeners
.begin();
805 sal_Bool bFound
= sal_False
;
807 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
809 if( *aIter
== rxListener
)
816 mxEventListeners
.push_back( rxListener
);
820 void SAL_CALL
ThumbnailViewItemAcc::removeAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
821 throw (uno::RuntimeException
)
823 const ::osl::MutexGuard
aGuard( maMutex
);
825 if( rxListener
.is() )
827 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::iterator aIter
= mxEventListeners
.begin();
828 sal_Bool bFound
= sal_False
;
830 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
832 if( *aIter
== rxListener
)
834 mxEventListeners
.erase( aIter
);
843 sal_Bool SAL_CALL
ThumbnailViewItemAcc::containsPoint( const awt::Point
& aPoint
)
844 throw (uno::RuntimeException
)
846 const awt::Rectangle
aRect( getBounds() );
847 const Point
aSize( aRect
.Width
, aRect
.Height
);
848 const Point aNullPoint
, aTestPoint( aPoint
.X
, aPoint
.Y
);
850 return Rectangle( aNullPoint
, aSize
).IsInside( aTestPoint
);
853 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ThumbnailViewItemAcc::getAccessibleAtPoint( const awt::Point
& )
854 throw (uno::RuntimeException
)
856 uno::Reference
< accessibility::XAccessible
> xRet
;
860 awt::Rectangle SAL_CALL
ThumbnailViewItemAcc::getBounds()
861 throw (uno::RuntimeException
)
863 const SolarMutexGuard aSolarGuard
;
868 Rectangle
aRect( mpParent
->getDrawArea() );
870 Rectangle
aParentRect( aOrigin
, mpParent
->mrParent
.GetOutputSizePixel() );
872 aRect
.Intersection( aParentRect
);
874 aRet
.X
= aRect
.Left();
875 aRet
.Y
= aRect
.Top();
876 aRet
.Width
= aRect
.GetWidth();
877 aRet
.Height
= aRect
.GetHeight();
883 awt::Point SAL_CALL
ThumbnailViewItemAcc::getLocation()
884 throw (uno::RuntimeException
)
886 const awt::Rectangle
aRect( getBounds() );
895 awt::Point SAL_CALL
ThumbnailViewItemAcc::getLocationOnScreen()
896 throw (uno::RuntimeException
)
898 const SolarMutexGuard aSolarGuard
;
903 const Point aPos
= mpParent
->getDrawArea().TopLeft();
904 const Point
aScreenPos( mpParent
->mrParent
.OutputToAbsoluteScreenPixel( aPos
) );
906 aRet
.X
= aScreenPos
.X();
907 aRet
.Y
= aScreenPos
.Y();
913 awt::Size SAL_CALL
ThumbnailViewItemAcc::getSize()
914 throw (uno::RuntimeException
)
916 const awt::Rectangle
aRect( getBounds() );
919 aRet
.Width
= aRect
.Width
;
920 aRet
.Height
= aRect
.Height
;
925 void SAL_CALL
ThumbnailViewItemAcc::grabFocus()
926 throw (uno::RuntimeException
)
931 uno::Any SAL_CALL
ThumbnailViewItemAcc::getAccessibleKeyBinding()
932 throw (uno::RuntimeException
)
937 sal_Int32 SAL_CALL
ThumbnailViewItemAcc::getForeground( )
938 throw (uno::RuntimeException
)
940 sal_uInt32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
941 return static_cast<sal_Int32
>(nColor
);
944 sal_Int32 SAL_CALL
ThumbnailViewItemAcc::getBackground( )
945 throw (uno::RuntimeException
)
947 return static_cast<sal_Int32
>(Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor());
950 sal_Int64 SAL_CALL
ThumbnailViewItemAcc::getSomething( const uno::Sequence
< sal_Int8
>& rId
) throw( uno::RuntimeException
)
954 if( ( rId
.getLength() == 16 ) && ( 0 == memcmp( ThumbnailViewItemAcc::getUnoTunnelId().getConstArray(), rId
.getConstArray(), 16 ) ) )
955 nRet
= reinterpret_cast< sal_Int64
>( this );
962 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */