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>
27 #include <vcl/settings.hxx>
29 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
30 #include <com/sun/star/accessibility/AccessibleRole.hpp>
31 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
33 using namespace ::com::sun::star
;
35 ThumbnailViewAcc::ThumbnailViewAcc( ThumbnailView
* pParent
, bool bIsTransientChildrenDisabled
) :
36 ValueSetAccComponentBase (m_aMutex
),
38 mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled
),
43 ThumbnailViewAcc::~ThumbnailViewAcc()
47 void ThumbnailViewAcc::FireAccessibleEvent( short nEventId
, const uno::Any
& rOldValue
, const uno::Any
& rNewValue
)
51 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> > aTmpListeners( mxEventListeners
);
52 accessibility::AccessibleEventObject aEvtObject
;
54 aEvtObject
.EventId
= nEventId
;
55 aEvtObject
.Source
= static_cast<uno::XWeak
*>(this);
56 aEvtObject
.NewValue
= rNewValue
;
57 aEvtObject
.OldValue
= rOldValue
;
59 for (::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator
aIter( aTmpListeners
.begin() ), aEnd( aTmpListeners
.end() );
60 aIter
!= aEnd
; ++aIter
)
64 (*aIter
)->notifyEvent( aEvtObject
);
66 catch(const uno::Exception
&)
75 class theValueSetAccUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theValueSetAccUnoTunnelId
> {};
78 const uno::Sequence
< sal_Int8
>& ThumbnailViewAcc::getUnoTunnelId()
80 return theValueSetAccUnoTunnelId::get().getSeq();
83 ThumbnailViewAcc
* ThumbnailViewAcc::getImplementation( const uno::Reference
< uno::XInterface
>& rxData
)
88 uno::Reference
< lang::XUnoTunnel
> xUnoTunnel( rxData
, uno::UNO_QUERY
);
89 return( xUnoTunnel
.is() ? reinterpret_cast<ThumbnailViewAcc
*>(sal::static_int_cast
<sal_IntPtr
>(xUnoTunnel
->getSomething( ThumbnailViewAcc::getUnoTunnelId() ))) : NULL
);
91 catch(const ::com::sun::star::uno::Exception
&)
97 void ThumbnailViewAcc::GetFocus()
101 // Broadcast the state change.
102 ::com::sun::star::uno::Any aOldState
, aNewState
;
103 aNewState
<<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED
;
105 ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED
,
106 aOldState
, aNewState
);
109 void ThumbnailViewAcc::LoseFocus()
113 // Broadcast the state change.
114 ::com::sun::star::uno::Any aOldState
, aNewState
;
115 aOldState
<<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED
;
117 ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED
,
118 aOldState
, aNewState
);
121 uno::Reference
< accessibility::XAccessibleContext
> SAL_CALL
ThumbnailViewAcc::getAccessibleContext()
122 throw (uno::RuntimeException
, std::exception
)
128 sal_Int32 SAL_CALL
ThumbnailViewAcc::getAccessibleChildCount()
129 throw (uno::RuntimeException
, std::exception
)
131 const SolarMutexGuard aSolarGuard
;
134 sal_Int32 nCount
= mpParent
->ImplGetVisibleItemCount();
138 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ThumbnailViewAcc::getAccessibleChild( sal_Int32 i
)
139 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
142 const SolarMutexGuard aSolarGuard
;
143 uno::Reference
< accessibility::XAccessible
> xRet
;
144 ThumbnailViewItem
* pItem
= getItem (sal::static_int_cast
< sal_uInt16
>(i
));
147 xRet
= pItem
->GetAccessible( mbIsTransientChildrenDisabled
);
149 throw lang::IndexOutOfBoundsException();
154 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ThumbnailViewAcc::getAccessibleParent()
155 throw (uno::RuntimeException
, std::exception
)
158 const SolarMutexGuard aSolarGuard
;
159 vcl::Window
* pParent
= mpParent
->GetParent();
160 uno::Reference
< accessibility::XAccessible
> xRet
;
163 xRet
= pParent
->GetAccessible();
168 sal_Int32 SAL_CALL
ThumbnailViewAcc::getAccessibleIndexInParent()
169 throw (uno::RuntimeException
, std::exception
)
172 const SolarMutexGuard aSolarGuard
;
173 vcl::Window
* pParent
= mpParent
->GetParent();
180 for( sal_uInt16 i
= 0, nCount
= pParent
->GetChildCount(); ( i
< nCount
) && !bFound
; i
++ )
182 if( pParent
->GetChild( i
) == mpParent
)
193 sal_Int16 SAL_CALL
ThumbnailViewAcc::getAccessibleRole()
194 throw (uno::RuntimeException
, std::exception
)
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 : accessibility::AccessibleRole::LIST
);
204 OUString SAL_CALL
ThumbnailViewAcc::getAccessibleDescription()
205 throw (uno::RuntimeException
, std::exception
)
208 const SolarMutexGuard aSolarGuard
;
209 return OUString("ThumbnailView");
212 OUString SAL_CALL
ThumbnailViewAcc::getAccessibleName()
213 throw (uno::RuntimeException
, std::exception
)
216 const SolarMutexGuard aSolarGuard
;
221 aRet
= mpParent
->GetAccessibleName();
224 vcl::Window
* pLabel
= mpParent
->GetAccessibleRelationLabeledBy();
225 if (pLabel
&& pLabel
!= mpParent
)
226 aRet
= OutputDevice::GetNonMnemonicString( pLabel
->GetText() );
233 uno::Reference
< accessibility::XAccessibleRelationSet
> SAL_CALL
ThumbnailViewAcc::getAccessibleRelationSet()
234 throw (uno::RuntimeException
, std::exception
)
237 return uno::Reference
< accessibility::XAccessibleRelationSet
>();
240 uno::Reference
< accessibility::XAccessibleStateSet
> SAL_CALL
ThumbnailViewAcc::getAccessibleStateSet()
241 throw (uno::RuntimeException
, std::exception
)
244 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper();
247 pStateSet
->AddState (accessibility::AccessibleStateType::ENABLED
);
248 pStateSet
->AddState (accessibility::AccessibleStateType::SENSITIVE
);
249 pStateSet
->AddState (accessibility::AccessibleStateType::SHOWING
);
250 pStateSet
->AddState (accessibility::AccessibleStateType::VISIBLE
);
251 if ( !mbIsTransientChildrenDisabled
)
252 pStateSet
->AddState (accessibility::AccessibleStateType::MANAGES_DESCENDANTS
);
253 pStateSet
->AddState (accessibility::AccessibleStateType::FOCUSABLE
);
255 pStateSet
->AddState (accessibility::AccessibleStateType::FOCUSED
);
260 lang::Locale SAL_CALL
ThumbnailViewAcc::getLocale()
261 throw (accessibility::IllegalAccessibleComponentStateException
, uno::RuntimeException
, std::exception
)
264 const SolarMutexGuard aSolarGuard
;
265 const OUString aEmptyStr
;
266 uno::Reference
< accessibility::XAccessible
> xParent( getAccessibleParent() );
267 lang::Locale
aRet( aEmptyStr
, aEmptyStr
, aEmptyStr
);
271 uno::Reference
< accessibility::XAccessibleContext
> xParentContext( xParent
->getAccessibleContext() );
273 if( xParentContext
.is() )
274 aRet
= xParentContext
->getLocale ();
280 void SAL_CALL
ThumbnailViewAcc::addAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
281 throw (uno::RuntimeException
, std::exception
)
284 ::osl::MutexGuard
aGuard (m_aMutex
);
286 if( rxListener
.is() )
288 std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator aIter
= mxEventListeners
.begin();
291 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
293 if( *aIter
== rxListener
)
300 mxEventListeners
.push_back( rxListener
);
304 void SAL_CALL
ThumbnailViewAcc::removeAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
305 throw (uno::RuntimeException
, std::exception
)
308 ::osl::MutexGuard
aGuard (m_aMutex
);
310 if( rxListener
.is() )
312 std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::iterator aIter
=
313 std::find(mxEventListeners
.begin(), mxEventListeners
.end(), rxListener
);
315 if (aIter
!= mxEventListeners
.end())
316 mxEventListeners
.erase( aIter
);
320 sal_Bool SAL_CALL
ThumbnailViewAcc::containsPoint( const awt::Point
& aPoint
)
321 throw (uno::RuntimeException
, std::exception
)
324 const awt::Rectangle
aRect( getBounds() );
325 const Point
aSize( aRect
.Width
, aRect
.Height
);
326 const Point aNullPoint
, aTestPoint( aPoint
.X
, aPoint
.Y
);
328 return Rectangle( aNullPoint
, aSize
).IsInside( aTestPoint
);
331 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ThumbnailViewAcc::getAccessibleAtPoint( const awt::Point
& aPoint
)
332 throw (uno::RuntimeException
, std::exception
)
335 const SolarMutexGuard aSolarGuard
;
336 const sal_uInt16 nItemId
= mpParent
->GetItemId( Point( aPoint
.X
, aPoint
.Y
) );
337 uno::Reference
< accessibility::XAccessible
> xRet
;
341 const size_t nItemPos
= mpParent
->GetItemPos( nItemId
);
343 if( THUMBNAILVIEW_ITEM_NONEITEM
!= nItemPos
)
345 ThumbnailViewItem
*const pItem
= mpParent
->mFilteredItemList
[nItemPos
];
346 xRet
= pItem
->GetAccessible( mbIsTransientChildrenDisabled
);
353 awt::Rectangle SAL_CALL
ThumbnailViewAcc::getBounds()
354 throw (uno::RuntimeException
, std::exception
)
357 const SolarMutexGuard aSolarGuard
;
358 const Point
aOutPos( mpParent
->GetPosPixel() );
359 const Size
aOutSize( mpParent
->GetOutputSizePixel() );
362 aRet
.X
= aOutPos
.X();
363 aRet
.Y
= aOutPos
.Y();
364 aRet
.Width
= aOutSize
.Width();
365 aRet
.Height
= aOutSize
.Height();
370 awt::Point SAL_CALL
ThumbnailViewAcc::getLocation()
371 throw (uno::RuntimeException
, std::exception
)
374 const awt::Rectangle
aRect( getBounds() );
383 awt::Point SAL_CALL
ThumbnailViewAcc::getLocationOnScreen()
384 throw (uno::RuntimeException
, std::exception
)
387 const SolarMutexGuard aSolarGuard
;
388 const Point
aScreenPos( mpParent
->OutputToAbsoluteScreenPixel( Point() ) );
391 aRet
.X
= aScreenPos
.X();
392 aRet
.Y
= aScreenPos
.Y();
397 awt::Size SAL_CALL
ThumbnailViewAcc::getSize()
398 throw (uno::RuntimeException
, std::exception
)
401 const awt::Rectangle
aRect( getBounds() );
404 aRet
.Width
= aRect
.Width
;
405 aRet
.Height
= aRect
.Height
;
410 void SAL_CALL
ThumbnailViewAcc::grabFocus()
411 throw (uno::RuntimeException
, std::exception
)
414 const SolarMutexGuard aSolarGuard
;
415 mpParent
->GrabFocus();
418 sal_Int32 SAL_CALL
ThumbnailViewAcc::getForeground( )
419 throw (uno::RuntimeException
, std::exception
)
422 sal_uInt32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
423 return static_cast<sal_Int32
>(nColor
);
426 sal_Int32 SAL_CALL
ThumbnailViewAcc::getBackground( )
427 throw (uno::RuntimeException
, std::exception
)
430 sal_uInt32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
431 return static_cast<sal_Int32
>(nColor
);
434 void SAL_CALL
ThumbnailViewAcc::selectAccessibleChild( sal_Int32 nChildIndex
)
435 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
438 const SolarMutexGuard aSolarGuard
;
439 ThumbnailViewItem
* pItem
= getItem (sal::static_int_cast
< sal_uInt16
>(nChildIndex
));
443 mpParent
->SelectItem( pItem
->mnId
);
446 throw lang::IndexOutOfBoundsException();
449 sal_Bool SAL_CALL
ThumbnailViewAcc::isAccessibleChildSelected( sal_Int32 nChildIndex
)
450 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
453 const SolarMutexGuard aSolarGuard
;
454 ThumbnailViewItem
* pItem
= getItem (sal::static_int_cast
< sal_uInt16
>(nChildIndex
));
458 bRet
= mpParent
->IsItemSelected( pItem
->mnId
);
460 throw lang::IndexOutOfBoundsException();
465 void SAL_CALL
ThumbnailViewAcc::clearAccessibleSelection()
466 throw (uno::RuntimeException
, std::exception
)
469 const SolarMutexGuard aSolarGuard
;
472 void SAL_CALL
ThumbnailViewAcc::selectAllAccessibleChildren()
473 throw (uno::RuntimeException
, std::exception
)
476 // unsupported due to single selection only
479 sal_Int32 SAL_CALL
ThumbnailViewAcc::getSelectedAccessibleChildCount()
480 throw (uno::RuntimeException
, std::exception
)
483 const SolarMutexGuard aSolarGuard
;
486 for( sal_uInt16 i
= 0, nCount
= getItemCount(); i
< nCount
; i
++ )
488 ThumbnailViewItem
* pItem
= getItem (i
);
490 if( pItem
&& mpParent
->IsItemSelected( pItem
->mnId
) )
497 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ThumbnailViewAcc::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
)
498 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
501 const SolarMutexGuard aSolarGuard
;
502 uno::Reference
< accessibility::XAccessible
> xRet
;
504 for( sal_uInt16 i
= 0, nCount
= getItemCount(), nSel
= 0; ( i
< nCount
) && !xRet
.is(); i
++ )
506 ThumbnailViewItem
* pItem
= getItem(i
);
508 if( pItem
&& mpParent
->IsItemSelected( pItem
->mnId
) && ( nSelectedChildIndex
== static_cast< sal_Int32
>( nSel
++ ) ) )
509 xRet
= pItem
->GetAccessible( mbIsTransientChildrenDisabled
);
515 void SAL_CALL
ThumbnailViewAcc::deselectAccessibleChild( sal_Int32 nChildIndex
)
516 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
519 const SolarMutexGuard aSolarGuard
;
520 // Because of the single selection we can reset the whole selection when
521 // the specified child is currently selected.
522 //FIXME TODO if (isAccessibleChildSelected(nChildIndex))
527 sal_Int64 SAL_CALL
ThumbnailViewAcc::getSomething( const uno::Sequence
< sal_Int8
>& rId
) throw( uno::RuntimeException
, std::exception
)
531 if( ( rId
.getLength() == 16 ) && ( 0 == memcmp( ThumbnailViewAcc::getUnoTunnelId().getConstArray(), rId
.getConstArray(), 16 ) ) )
532 nRet
= reinterpret_cast< sal_Int64
>( this );
539 void SAL_CALL
ThumbnailViewAcc::disposing()
541 ::std::vector
<uno::Reference
<accessibility::XAccessibleEventListener
> > aListenerListCopy
;
544 // Make a copy of the list and clear the original.
545 const SolarMutexGuard aSolarGuard
;
546 ::osl::MutexGuard
aGuard (m_aMutex
);
547 aListenerListCopy
= mxEventListeners
;
548 mxEventListeners
.clear();
550 // Reset the pointer to the parent. It has to be the one who has
551 // disposed us because he is dying.
555 // Inform all listeners that this objects is disposing.
556 ::std::vector
<uno::Reference
<accessibility::XAccessibleEventListener
> >::const_iterator
557 aListenerIterator (aListenerListCopy
.begin());
558 lang::EventObject
aEvent (static_cast<accessibility::XAccessible
*>(this));
559 while (aListenerIterator
!= aListenerListCopy
.end())
563 (*aListenerIterator
)->disposing (aEvent
);
565 catch(const uno::Exception
&)
567 // Ignore exceptions.
574 sal_uInt16
ThumbnailViewAcc::getItemCount() const
576 return mpParent
->ImplGetVisibleItemCount();
579 ThumbnailViewItem
* ThumbnailViewAcc::getItem (sal_uInt16 nIndex
) const
581 return mpParent
->ImplGetVisibleItem (static_cast<sal_uInt16
>(nIndex
));
584 void ThumbnailViewAcc::ThrowIfDisposed()
585 throw (::com::sun::star::lang::DisposedException
)
587 if (rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
589 OSL_TRACE ("Calling disposed object. Throwing exception:");
590 throw lang::DisposedException (
591 OUString("object has been already disposed"),
592 static_cast<uno::XWeak
*>(this));
596 DBG_ASSERT (mpParent
!=nullptr, "ValueSetAcc not disposed but mpParent == NULL");
600 ThumbnailViewItemAcc::ThumbnailViewItemAcc( ThumbnailViewItem
* pParent
, bool bIsTransientChildrenDisabled
) :
602 mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled
)
606 ThumbnailViewItemAcc::~ThumbnailViewItemAcc()
610 void ThumbnailViewItemAcc::FireAccessibleEvent( short nEventId
, const uno::Any
& rOldValue
, const uno::Any
& rNewValue
)
614 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> > aTmpListeners( mxEventListeners
);
615 accessibility::AccessibleEventObject aEvtObject
;
617 aEvtObject
.EventId
= nEventId
;
618 aEvtObject
.Source
= static_cast<uno::XWeak
*>(this);
619 aEvtObject
.NewValue
= rNewValue
;
620 aEvtObject
.OldValue
= rOldValue
;
622 for (::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator
aIter( aTmpListeners
.begin() ), aEnd( aTmpListeners
.end() );
623 aIter
!= aEnd
; ++aIter
)
627 (*aIter
)->notifyEvent( aEvtObject
);
629 catch(const uno::Exception
&)
636 void ThumbnailViewItemAcc::ParentDestroyed()
638 const ::osl::MutexGuard
aGuard( maMutex
);
644 class theValueItemAccUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theValueItemAccUnoTunnelId
> {};
647 const uno::Sequence
< sal_Int8
>& ThumbnailViewItemAcc::getUnoTunnelId()
649 return theValueItemAccUnoTunnelId::get().getSeq();
652 ThumbnailViewItemAcc
* ThumbnailViewItemAcc::getImplementation( const uno::Reference
< uno::XInterface
>& rxData
)
657 uno::Reference
< lang::XUnoTunnel
> xUnoTunnel( rxData
, uno::UNO_QUERY
);
658 return( xUnoTunnel
.is() ?
659 reinterpret_cast<ThumbnailViewItemAcc
*>(sal::static_int_cast
<sal_IntPtr
>(
660 xUnoTunnel
->getSomething( ThumbnailViewItemAcc::getUnoTunnelId() ))) :
663 catch(const ::com::sun::star::uno::Exception
&)
669 uno::Reference
< accessibility::XAccessibleContext
> SAL_CALL
ThumbnailViewItemAcc::getAccessibleContext()
670 throw (uno::RuntimeException
, std::exception
)
675 sal_Int32 SAL_CALL
ThumbnailViewItemAcc::getAccessibleChildCount()
676 throw (uno::RuntimeException
, std::exception
)
681 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ThumbnailViewItemAcc::getAccessibleChild( sal_Int32
)
682 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
684 throw lang::IndexOutOfBoundsException();
687 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ThumbnailViewItemAcc::getAccessibleParent()
688 throw (uno::RuntimeException
, std::exception
)
690 const SolarMutexGuard aSolarGuard
;
691 uno::Reference
< accessibility::XAccessible
> xRet
;
694 xRet
= mpParent
->mrParent
.GetAccessible();
699 sal_Int32 SAL_CALL
ThumbnailViewItemAcc::getAccessibleIndexInParent()
700 throw (uno::RuntimeException
, std::exception
)
702 const SolarMutexGuard aSolarGuard
;
703 // The index defaults to -1 to indicate the child does not belong to its
705 sal_Int32 nIndexInParent
= -1;
711 sal_uInt16 nCount
= mpParent
->mrParent
.ImplGetVisibleItemCount();
712 ThumbnailViewItem
* pItem
;
713 for (sal_uInt16 i
=0; i
<nCount
&& !bDone
; i
++)
715 // Guard the retrieval of the i-th child with a try/catch block
716 // just in case the number of children changes in the mean time.
719 pItem
= mpParent
->mrParent
.ImplGetVisibleItem (i
);
721 catch (const lang::IndexOutOfBoundsException
&)
726 // Do not create an accessible object for the test.
727 if (pItem
!= NULL
&& pItem
->mpxAcc
!= NULL
)
728 if (pItem
->GetAccessible( mbIsTransientChildrenDisabled
).get() == this )
736 return nIndexInParent
;
739 sal_Int16 SAL_CALL
ThumbnailViewItemAcc::getAccessibleRole()
740 throw (uno::RuntimeException
, std::exception
)
742 return accessibility::AccessibleRole::LIST_ITEM
;
745 OUString SAL_CALL
ThumbnailViewItemAcc::getAccessibleDescription()
746 throw (uno::RuntimeException
, std::exception
)
751 OUString SAL_CALL
ThumbnailViewItemAcc::getAccessibleName()
752 throw (uno::RuntimeException
, std::exception
)
754 const SolarMutexGuard aSolarGuard
;
759 aRet
= mpParent
->maTitle
;
763 OUStringBuffer
aBuffer("Item ");
764 aBuffer
.append(static_cast<sal_Int32
>(mpParent
->mnId
));
765 aRet
= aBuffer
.makeStringAndClear();
772 uno::Reference
< accessibility::XAccessibleRelationSet
> SAL_CALL
ThumbnailViewItemAcc::getAccessibleRelationSet()
773 throw (uno::RuntimeException
, std::exception
)
775 return uno::Reference
< accessibility::XAccessibleRelationSet
>();
778 uno::Reference
< accessibility::XAccessibleStateSet
> SAL_CALL
ThumbnailViewItemAcc::getAccessibleStateSet()
779 throw (uno::RuntimeException
, std::exception
)
781 const SolarMutexGuard aSolarGuard
;
782 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper
;
786 pStateSet
->AddState (accessibility::AccessibleStateType::ENABLED
);
787 pStateSet
->AddState (accessibility::AccessibleStateType::SENSITIVE
);
788 pStateSet
->AddState (accessibility::AccessibleStateType::SHOWING
);
789 pStateSet
->AddState (accessibility::AccessibleStateType::VISIBLE
);
790 if ( !mbIsTransientChildrenDisabled
)
791 pStateSet
->AddState (accessibility::AccessibleStateType::TRANSIENT
);
794 pStateSet
->AddState( accessibility::AccessibleStateType::SELECTABLE
);
795 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE );
798 if( mpParent
->isSelected() )
800 pStateSet
->AddState( accessibility::AccessibleStateType::SELECTED
);
801 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSED );
808 lang::Locale SAL_CALL
ThumbnailViewItemAcc::getLocale()
809 throw (accessibility::IllegalAccessibleComponentStateException
, uno::RuntimeException
, std::exception
)
811 const SolarMutexGuard aSolarGuard
;
812 const OUString aEmptyStr
;
813 uno::Reference
< accessibility::XAccessible
> xParent( getAccessibleParent() );
814 lang::Locale
aRet( aEmptyStr
, aEmptyStr
, aEmptyStr
);
818 uno::Reference
< accessibility::XAccessibleContext
> xParentContext( xParent
->getAccessibleContext() );
820 if( xParentContext
.is() )
821 aRet
= xParentContext
->getLocale();
827 void SAL_CALL
ThumbnailViewItemAcc::addAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
828 throw (uno::RuntimeException
, std::exception
)
830 const ::osl::MutexGuard
aGuard( maMutex
);
832 if( rxListener
.is() )
834 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator aIter
= mxEventListeners
.begin();
837 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
839 if( *aIter
== rxListener
)
846 mxEventListeners
.push_back( rxListener
);
850 void SAL_CALL
ThumbnailViewItemAcc::removeAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
851 throw (uno::RuntimeException
, std::exception
)
853 const ::osl::MutexGuard
aGuard( maMutex
);
855 if( rxListener
.is() )
857 std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::iterator aIter
=
858 std::find(mxEventListeners
.begin(), mxEventListeners
.end(), rxListener
);
860 if (aIter
!= mxEventListeners
.end())
861 mxEventListeners
.erase( aIter
);
865 sal_Bool SAL_CALL
ThumbnailViewItemAcc::containsPoint( const awt::Point
& aPoint
)
866 throw (uno::RuntimeException
, std::exception
)
868 const awt::Rectangle
aRect( getBounds() );
869 const Point
aSize( aRect
.Width
, aRect
.Height
);
870 const Point aNullPoint
, aTestPoint( aPoint
.X
, aPoint
.Y
);
872 return Rectangle( aNullPoint
, aSize
).IsInside( aTestPoint
);
875 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ThumbnailViewItemAcc::getAccessibleAtPoint( const awt::Point
& )
876 throw (uno::RuntimeException
, std::exception
)
878 uno::Reference
< accessibility::XAccessible
> xRet
;
882 awt::Rectangle SAL_CALL
ThumbnailViewItemAcc::getBounds()
883 throw (uno::RuntimeException
, std::exception
)
885 const SolarMutexGuard aSolarGuard
;
890 Rectangle
aRect( mpParent
->getDrawArea() );
892 Rectangle
aParentRect( aOrigin
, mpParent
->mrParent
.GetOutputSizePixel() );
894 aRect
.Intersection( aParentRect
);
896 aRet
.X
= aRect
.Left();
897 aRet
.Y
= aRect
.Top();
898 aRet
.Width
= aRect
.GetWidth();
899 aRet
.Height
= aRect
.GetHeight();
905 awt::Point SAL_CALL
ThumbnailViewItemAcc::getLocation()
906 throw (uno::RuntimeException
, std::exception
)
908 const awt::Rectangle
aRect( getBounds() );
917 awt::Point SAL_CALL
ThumbnailViewItemAcc::getLocationOnScreen()
918 throw (uno::RuntimeException
, std::exception
)
920 const SolarMutexGuard aSolarGuard
;
925 const Point aPos
= mpParent
->getDrawArea().TopLeft();
926 const Point
aScreenPos( mpParent
->mrParent
.OutputToAbsoluteScreenPixel( aPos
) );
928 aRet
.X
= aScreenPos
.X();
929 aRet
.Y
= aScreenPos
.Y();
935 awt::Size SAL_CALL
ThumbnailViewItemAcc::getSize()
936 throw (uno::RuntimeException
, std::exception
)
938 const awt::Rectangle
aRect( getBounds() );
941 aRet
.Width
= aRect
.Width
;
942 aRet
.Height
= aRect
.Height
;
947 void SAL_CALL
ThumbnailViewItemAcc::grabFocus()
948 throw (uno::RuntimeException
, std::exception
)
953 sal_Int32 SAL_CALL
ThumbnailViewItemAcc::getForeground( )
954 throw (uno::RuntimeException
, std::exception
)
956 sal_uInt32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
957 return static_cast<sal_Int32
>(nColor
);
960 sal_Int32 SAL_CALL
ThumbnailViewItemAcc::getBackground( )
961 throw (uno::RuntimeException
, std::exception
)
963 return static_cast<sal_Int32
>(Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor());
966 sal_Int64 SAL_CALL
ThumbnailViewItemAcc::getSomething( const uno::Sequence
< sal_Int8
>& rId
) throw( uno::RuntimeException
, std::exception
)
970 if( ( rId
.getLength() == 16 ) && ( 0 == memcmp( ThumbnailViewItemAcc::getUnoTunnelId().getConstArray(), rId
.getConstArray(), 16 ) ) )
971 nRet
= reinterpret_cast< sal_Int64
>( this );
978 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */