nss: upgrade to release 3.73
[LibreOffice.git] / sfx2 / source / control / thumbnailviewacc.cxx
blob8c67445f226f4b4de5a4e81b82eb93e877c6485c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
28 #include <sal/log.hxx>
29 #include <tools/debug.hxx>
30 #include <tools/diagnose_ex.h>
32 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
33 #include <com/sun/star/accessibility/AccessibleRole.hpp>
34 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
35 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
37 using namespace ::com::sun::star;
39 ThumbnailViewAcc::ThumbnailViewAcc( ThumbnailView* pParent ) :
40 ValueSetAccComponentBase (m_aMutex),
41 mpParent( pParent )
45 ThumbnailViewAcc::~ThumbnailViewAcc()
49 namespace
51 class theSfxValueSetAccUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSfxValueSetAccUnoTunnelId > {};
54 const uno::Sequence< sal_Int8 >& ThumbnailViewAcc::getUnoTunnelId()
56 return theSfxValueSetAccUnoTunnelId::get().getSeq();
59 ThumbnailViewAcc* ThumbnailViewAcc::getImplementation( const uno::Reference< uno::XInterface >& rxData )
60 throw()
62 try
64 return comphelper::getUnoTunnelImplementation<ThumbnailViewAcc>(rxData);
66 catch(const css::uno::Exception&)
68 return nullptr;
72 uno::Reference< accessibility::XAccessibleContext > SAL_CALL ThumbnailViewAcc::getAccessibleContext()
74 ThrowIfDisposed();
75 return this;
78 sal_Int32 SAL_CALL ThumbnailViewAcc::getAccessibleChildCount()
80 const SolarMutexGuard aSolarGuard;
81 ThrowIfDisposed();
83 sal_Int32 nCount = mpParent->ImplGetVisibleItemCount();
84 return nCount;
87 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewAcc::getAccessibleChild( sal_Int32 i )
89 ThrowIfDisposed();
90 const SolarMutexGuard aSolarGuard;
91 ThumbnailViewItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(i));
93 if( !pItem )
94 throw lang::IndexOutOfBoundsException();
96 uno::Reference< accessibility::XAccessible > xRet = pItem->GetAccessible( /*bIsTransientChildrenDisabled*/false );
97 return xRet;
100 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewAcc::getAccessibleParent()
102 ThrowIfDisposed();
103 const SolarMutexGuard aSolarGuard;
104 return mpParent->GetDrawingArea()->get_accessible_parent();
107 sal_Int32 SAL_CALL ThumbnailViewAcc::getAccessibleIndexInParent()
109 ThrowIfDisposed();
110 const SolarMutexGuard aSolarGuard;
112 // -1 for child not found/no parent (according to specification)
113 sal_Int32 nRet = -1;
115 uno::Reference<accessibility::XAccessible> xParent(getAccessibleParent());
116 if (!xParent)
117 return nRet;
121 uno::Reference<accessibility::XAccessibleContext> xParentContext(xParent->getAccessibleContext());
123 // iterate over parent's children and search for this object
124 if ( xParentContext.is() )
126 sal_Int32 nChildCount = xParentContext->getAccessibleChildCount();
127 for ( sal_Int32 nChild = 0; ( nChild < nChildCount ) && ( -1 == nRet ); ++nChild )
129 uno::Reference<XAccessible> xChild(xParentContext->getAccessibleChild(nChild));
130 if ( xChild.get() == this )
131 nRet = nChild;
135 catch (const uno::Exception&)
137 TOOLS_WARN_EXCEPTION( "sfx", "OAccessibleContextHelper::getAccessibleIndexInParent" );
140 return nRet;
143 sal_Int16 SAL_CALL ThumbnailViewAcc::getAccessibleRole()
145 ThrowIfDisposed();
146 // #i73746# As the Java Access Bridge (v 2.0.1) uses "managesDescendants"
147 // always if the role is LIST, we need a different role in this case
148 return accessibility::AccessibleRole::LIST;
151 OUString SAL_CALL ThumbnailViewAcc::getAccessibleDescription()
153 ThrowIfDisposed();
154 return "ThumbnailView";
157 OUString SAL_CALL ThumbnailViewAcc::getAccessibleName()
159 ThrowIfDisposed();
160 const SolarMutexGuard aSolarGuard;
161 OUString aRet;
163 if (mpParent)
165 aRet = mpParent->GetAccessibleName();
168 return aRet;
171 uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ThumbnailViewAcc::getAccessibleRelationSet()
173 ThrowIfDisposed();
174 return uno::Reference< accessibility::XAccessibleRelationSet >();
177 uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL ThumbnailViewAcc::getAccessibleStateSet()
179 ThrowIfDisposed();
180 ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper();
182 // Set some states.
183 pStateSet->AddState (accessibility::AccessibleStateType::ENABLED);
184 pStateSet->AddState (accessibility::AccessibleStateType::SENSITIVE);
185 pStateSet->AddState (accessibility::AccessibleStateType::SHOWING);
186 pStateSet->AddState (accessibility::AccessibleStateType::VISIBLE);
187 pStateSet->AddState (accessibility::AccessibleStateType::MANAGES_DESCENDANTS);
188 pStateSet->AddState (accessibility::AccessibleStateType::FOCUSABLE);
190 return pStateSet;
193 lang::Locale SAL_CALL ThumbnailViewAcc::getLocale()
195 ThrowIfDisposed();
196 const SolarMutexGuard aSolarGuard;
197 uno::Reference< accessibility::XAccessible > xParent( getAccessibleParent() );
198 lang::Locale aRet( "", "", "" );
200 if( xParent.is() )
202 uno::Reference< accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
204 if( xParentContext.is() )
205 aRet = xParentContext->getLocale ();
208 return aRet;
211 void SAL_CALL ThumbnailViewAcc::addAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
213 ThrowIfDisposed();
214 ::osl::MutexGuard aGuard (m_aMutex);
216 if( !rxListener.is() )
217 return;
219 bool bFound = false;
221 for (auto const& eventListener : mxEventListeners)
223 if( eventListener == rxListener )
225 bFound = true;
226 break;
230 if (!bFound)
231 mxEventListeners.push_back( rxListener );
234 void SAL_CALL ThumbnailViewAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
236 ThrowIfDisposed();
237 ::osl::MutexGuard aGuard (m_aMutex);
239 if( rxListener.is() )
241 std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::iterator aIter =
242 std::find(mxEventListeners.begin(), mxEventListeners.end(), rxListener);
244 if (aIter != mxEventListeners.end())
245 mxEventListeners.erase( aIter );
249 sal_Bool SAL_CALL ThumbnailViewAcc::containsPoint( const awt::Point& aPoint )
251 ThrowIfDisposed();
252 const awt::Rectangle aRect( getBounds() );
253 const Point aSize( aRect.Width, aRect.Height );
254 const Point aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
256 return tools::Rectangle( aNullPoint, aSize ).IsInside( aTestPoint );
259 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewAcc::getAccessibleAtPoint( const awt::Point& aPoint )
261 ThrowIfDisposed();
262 const SolarMutexGuard aSolarGuard;
263 const sal_uInt16 nItemId = mpParent->GetItemId( Point( aPoint.X, aPoint.Y ) );
264 uno::Reference< accessibility::XAccessible > xRet;
266 if ( nItemId )
268 const size_t nItemPos = mpParent->GetItemPos( nItemId );
270 if( THUMBNAILVIEW_ITEM_NONEITEM != nItemPos )
272 ThumbnailViewItem *const pItem = mpParent->mFilteredItemList[nItemPos];
273 xRet = pItem->GetAccessible( /*bIsTransientChildrenDisabled*/false );
277 return xRet;
280 awt::Rectangle SAL_CALL ThumbnailViewAcc::getBounds()
282 ThrowIfDisposed();
283 const SolarMutexGuard aSolarGuard;
284 const Point aOutPos;
285 const Size aOutSize( mpParent->GetOutputSizePixel() );
286 awt::Rectangle aRet;
288 aRet.X = aOutPos.X();
289 aRet.Y = aOutPos.Y();
290 aRet.Width = aOutSize.Width();
291 aRet.Height = aOutSize.Height();
293 return aRet;
296 awt::Point SAL_CALL ThumbnailViewAcc::getLocation()
298 ThrowIfDisposed();
299 const awt::Rectangle aRect( getBounds() );
300 awt::Point aRet;
302 aRet.X = aRect.X;
303 aRet.Y = aRect.Y;
305 return aRet;
308 awt::Point SAL_CALL ThumbnailViewAcc::getLocationOnScreen()
310 ThrowIfDisposed();
311 const SolarMutexGuard aSolarGuard;
312 awt::Point aScreenLoc(0, 0);
314 uno::Reference<accessibility::XAccessible> xParent(getAccessibleParent());
315 if (xParent)
317 uno::Reference<accessibility::XAccessibleContext> xParentContext(xParent->getAccessibleContext());
318 uno::Reference<accessibility::XAccessibleComponent> xParentComponent(xParentContext, css::uno::UNO_QUERY);
319 OSL_ENSURE( xParentComponent.is(), "ThumbnailViewAcc::getLocationOnScreen: no parent component!" );
320 if ( xParentComponent.is() )
322 awt::Point aParentScreenLoc( xParentComponent->getLocationOnScreen() );
323 awt::Point aOwnRelativeLoc( getLocation() );
324 aScreenLoc.X = aParentScreenLoc.X + aOwnRelativeLoc.X;
325 aScreenLoc.Y = aParentScreenLoc.Y + aOwnRelativeLoc.Y;
329 return aScreenLoc;
332 awt::Size SAL_CALL ThumbnailViewAcc::getSize()
334 ThrowIfDisposed();
335 const awt::Rectangle aRect( getBounds() );
336 awt::Size aRet;
338 aRet.Width = aRect.Width;
339 aRet.Height = aRect.Height;
341 return aRet;
344 void SAL_CALL ThumbnailViewAcc::grabFocus()
346 ThrowIfDisposed();
347 const SolarMutexGuard aSolarGuard;
348 mpParent->GrabFocus();
351 sal_Int32 SAL_CALL ThumbnailViewAcc::getForeground( )
353 ThrowIfDisposed();
354 Color nColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor();
355 return static_cast<sal_Int32>(nColor);
358 sal_Int32 SAL_CALL ThumbnailViewAcc::getBackground( )
360 ThrowIfDisposed();
361 Color nColor = Application::GetSettings().GetStyleSettings().GetWindowColor();
362 return static_cast<sal_Int32>(nColor);
365 void SAL_CALL ThumbnailViewAcc::selectAccessibleChild( sal_Int32 nChildIndex )
367 ThrowIfDisposed();
368 const SolarMutexGuard aSolarGuard;
369 ThumbnailViewItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
371 if(pItem == nullptr)
372 throw lang::IndexOutOfBoundsException();
374 mpParent->SelectItem( pItem->mnId );
377 sal_Bool SAL_CALL ThumbnailViewAcc::isAccessibleChildSelected( sal_Int32 nChildIndex )
379 ThrowIfDisposed();
380 const SolarMutexGuard aSolarGuard;
381 ThumbnailViewItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
383 if (pItem == nullptr)
384 throw lang::IndexOutOfBoundsException();
386 return mpParent->IsItemSelected( pItem->mnId );
389 void SAL_CALL ThumbnailViewAcc::clearAccessibleSelection()
391 ThrowIfDisposed();
394 void SAL_CALL ThumbnailViewAcc::selectAllAccessibleChildren()
396 ThrowIfDisposed();
397 // unsupported due to single selection only
400 sal_Int32 SAL_CALL ThumbnailViewAcc::getSelectedAccessibleChildCount()
402 ThrowIfDisposed();
403 const SolarMutexGuard aSolarGuard;
404 sal_Int32 nRet = 0;
406 for( sal_uInt16 i = 0, nCount = getItemCount(); i < nCount; i++ )
408 ThumbnailViewItem* pItem = getItem (i);
410 if( pItem && mpParent->IsItemSelected( pItem->mnId ) )
411 ++nRet;
414 return nRet;
417 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewAcc::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
419 ThrowIfDisposed();
420 const SolarMutexGuard aSolarGuard;
421 uno::Reference< accessibility::XAccessible > xRet;
423 for( sal_uInt16 i = 0, nCount = getItemCount(), nSel = 0; ( i < nCount ) && !xRet.is(); i++ )
425 ThumbnailViewItem* pItem = getItem(i);
427 if( pItem && mpParent->IsItemSelected( pItem->mnId ) && ( nSelectedChildIndex == static_cast< sal_Int32 >( nSel++ ) ) )
428 xRet = pItem->GetAccessible( /*bIsTransientChildrenDisabled*/false );
431 return xRet;
434 void SAL_CALL ThumbnailViewAcc::deselectAccessibleChild( sal_Int32 )
436 ThrowIfDisposed();
437 const SolarMutexGuard aSolarGuard;
438 // Because of the single selection we can reset the whole selection when
439 // the specified child is currently selected.
440 //FIXME TODO if (isAccessibleChildSelected(nChildIndex))
441 //FIXME TODO ;
444 sal_Int64 SAL_CALL ThumbnailViewAcc::getSomething( const uno::Sequence< sal_Int8 >& rId )
446 sal_Int64 nRet;
448 if( isUnoTunnelId<ThumbnailViewAcc>(rId) )
449 nRet = reinterpret_cast< sal_Int64 >( this );
450 else
451 nRet = 0;
453 return nRet;
456 void SAL_CALL ThumbnailViewAcc::disposing()
458 ::std::vector<uno::Reference<accessibility::XAccessibleEventListener> > aListenerListCopy;
461 // Make a copy of the list and clear the original.
462 const SolarMutexGuard aSolarGuard;
463 ::osl::MutexGuard aGuard (m_aMutex);
464 aListenerListCopy = mxEventListeners;
465 mxEventListeners.clear();
467 // Reset the pointer to the parent. It has to be the one who has
468 // disposed us because he is dying.
469 mpParent = nullptr;
472 // Inform all listeners that this objects is disposing.
473 lang::EventObject aEvent (static_cast<accessibility::XAccessible*>(this));
474 for (auto const& listener : aListenerListCopy)
478 listener->disposing (aEvent);
480 catch(const uno::Exception&)
482 // Ignore exceptions.
487 sal_uInt16 ThumbnailViewAcc::getItemCount() const
489 return mpParent->ImplGetVisibleItemCount();
492 ThumbnailViewItem* ThumbnailViewAcc::getItem (sal_uInt16 nIndex) const
494 return mpParent->ImplGetVisibleItem (nIndex);
497 void ThumbnailViewAcc::ThrowIfDisposed()
499 if (rBHelper.bDisposed || rBHelper.bInDispose)
501 SAL_WARN("sfx", "Calling disposed object. Throwing exception:");
502 throw lang::DisposedException (
503 "object has been already disposed",
504 static_cast<uno::XWeak*>(this));
506 else
508 DBG_ASSERT (mpParent!=nullptr, "ValueSetAcc not disposed but mpParent == NULL");
512 ThumbnailViewItemAcc::ThumbnailViewItemAcc( ThumbnailViewItem* pParent, bool bIsTransientChildrenDisabled ) :
513 mpParent( pParent ),
514 mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled )
518 ThumbnailViewItemAcc::~ThumbnailViewItemAcc()
522 void ThumbnailViewItemAcc::ParentDestroyed()
524 const ::osl::MutexGuard aGuard( maMutex );
525 mpParent = nullptr;
528 void ThumbnailViewAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOldValue, const uno::Any& rNewValue )
530 if( !nEventId )
531 return;
533 ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > > aTmpListeners( mxEventListeners );
534 accessibility::AccessibleEventObject aEvtObject;
536 aEvtObject.EventId = nEventId;
537 aEvtObject.Source = static_cast<uno::XWeak*>(this);
538 aEvtObject.NewValue = rNewValue;
539 aEvtObject.OldValue = rOldValue;
541 for (auto const& tmpListener : aTmpListeners)
545 tmpListener->notifyEvent( aEvtObject );
547 catch(const uno::Exception&)
553 namespace
555 class theValueItemAccUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theValueItemAccUnoTunnelId > {};
558 const uno::Sequence< sal_Int8 >& ThumbnailViewItemAcc::getUnoTunnelId()
560 return theValueItemAccUnoTunnelId::get().getSeq();
563 ThumbnailViewItemAcc* ThumbnailViewItemAcc::getImplementation( const uno::Reference< uno::XInterface >& rxData )
564 throw()
568 return comphelper::getUnoTunnelImplementation<ThumbnailViewItemAcc>(rxData);
570 catch(const css::uno::Exception&)
572 return nullptr;
576 void ThumbnailViewAcc::GetFocus()
578 // Broadcast the state change.
579 css::uno::Any aOldState, aNewState;
580 aNewState <<= css::accessibility::AccessibleStateType::FOCUSED;
581 FireAccessibleEvent(
582 css::accessibility::AccessibleEventId::STATE_CHANGED,
583 aOldState, aNewState);
586 void ThumbnailViewAcc::LoseFocus()
588 // Broadcast the state change.
589 css::uno::Any aOldState, aNewState;
590 aOldState <<= css::accessibility::AccessibleStateType::FOCUSED;
591 FireAccessibleEvent(
592 css::accessibility::AccessibleEventId::STATE_CHANGED,
593 aOldState, aNewState);
596 uno::Reference< accessibility::XAccessibleContext > SAL_CALL ThumbnailViewItemAcc::getAccessibleContext()
598 return this;
601 sal_Int32 SAL_CALL ThumbnailViewItemAcc::getAccessibleChildCount()
603 return 0;
606 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewItemAcc::getAccessibleChild( sal_Int32 )
608 throw lang::IndexOutOfBoundsException();
611 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewItemAcc::getAccessibleParent()
613 const SolarMutexGuard aSolarGuard;
614 uno::Reference< accessibility::XAccessible > xRet;
616 if( mpParent )
617 xRet = mpParent->mrParent.getAccessible();
619 return xRet;
622 sal_Int32 SAL_CALL ThumbnailViewItemAcc::getAccessibleIndexInParent()
624 const SolarMutexGuard aSolarGuard;
625 // The index defaults to -1 to indicate the child does not belong to its
626 // parent.
627 sal_Int32 nIndexInParent = -1;
629 if( mpParent )
631 bool bDone = false;
633 sal_uInt16 nCount = mpParent->mrParent.ImplGetVisibleItemCount();
634 ThumbnailViewItem* pItem;
635 for (sal_uInt16 i=0; i<nCount && !bDone; i++)
637 // Guard the retrieval of the i-th child with a try/catch block
638 // just in case the number of children changes in the meantime.
641 pItem = mpParent->mrParent.ImplGetVisibleItem (i);
643 catch (const lang::IndexOutOfBoundsException&)
645 pItem = nullptr;
648 // Do not create an accessible object for the test.
649 if (pItem != nullptr && pItem->mxAcc.is())
650 if (pItem->GetAccessible( mbIsTransientChildrenDisabled ).get() == this )
652 nIndexInParent = i;
653 bDone = true;
658 return nIndexInParent;
661 sal_Int16 SAL_CALL ThumbnailViewItemAcc::getAccessibleRole()
663 return accessibility::AccessibleRole::LIST_ITEM;
666 OUString SAL_CALL ThumbnailViewItemAcc::getAccessibleDescription()
668 return OUString();
671 OUString SAL_CALL ThumbnailViewItemAcc::getAccessibleName()
673 const SolarMutexGuard aSolarGuard;
674 OUString aRet;
676 if( mpParent )
678 aRet = mpParent->maTitle;
680 if( aRet.isEmpty() )
682 aRet = "Item " + OUString::number(static_cast<sal_Int32>(mpParent->mnId));
686 return aRet;
689 uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ThumbnailViewItemAcc::getAccessibleRelationSet()
691 return uno::Reference< accessibility::XAccessibleRelationSet >();
694 uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL ThumbnailViewItemAcc::getAccessibleStateSet()
696 const SolarMutexGuard aSolarGuard;
697 ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper;
699 if( mpParent )
701 pStateSet->AddState (accessibility::AccessibleStateType::ENABLED);
702 pStateSet->AddState (accessibility::AccessibleStateType::SENSITIVE);
703 pStateSet->AddState (accessibility::AccessibleStateType::SHOWING);
704 pStateSet->AddState (accessibility::AccessibleStateType::VISIBLE);
705 if ( !mbIsTransientChildrenDisabled )
706 pStateSet->AddState (accessibility::AccessibleStateType::TRANSIENT);
708 // SELECTABLE
709 pStateSet->AddState( accessibility::AccessibleStateType::SELECTABLE );
710 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE );
712 // SELECTED
713 if( mpParent->isSelected() )
715 pStateSet->AddState( accessibility::AccessibleStateType::SELECTED );
716 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSED );
720 return pStateSet;
723 lang::Locale SAL_CALL ThumbnailViewItemAcc::getLocale()
725 const SolarMutexGuard aSolarGuard;
726 uno::Reference< accessibility::XAccessible > xParent( getAccessibleParent() );
727 lang::Locale aRet( "", "", "" );
729 if( xParent.is() )
731 uno::Reference< accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
733 if( xParentContext.is() )
734 aRet = xParentContext->getLocale();
737 return aRet;
740 void SAL_CALL ThumbnailViewItemAcc::addAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
742 const ::osl::MutexGuard aGuard( maMutex );
744 if( !rxListener.is() )
745 return;
747 bool bFound = false;
749 for (auto const& eventListener : mxEventListeners)
751 if( eventListener == rxListener )
753 bFound = true;
754 break;
758 if (!bFound)
759 mxEventListeners.push_back( rxListener );
762 void SAL_CALL ThumbnailViewItemAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
764 const ::osl::MutexGuard aGuard( maMutex );
766 if( rxListener.is() )
768 std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::iterator aIter =
769 std::find(mxEventListeners.begin(), mxEventListeners.end(), rxListener);
771 if (aIter != mxEventListeners.end())
772 mxEventListeners.erase( aIter );
776 sal_Bool SAL_CALL ThumbnailViewItemAcc::containsPoint( const awt::Point& aPoint )
778 const awt::Rectangle aRect( getBounds() );
779 const Point aSize( aRect.Width, aRect.Height );
780 const Point aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
782 return tools::Rectangle( aNullPoint, aSize ).IsInside( aTestPoint );
785 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewItemAcc::getAccessibleAtPoint( const awt::Point& )
787 uno::Reference< accessibility::XAccessible > xRet;
788 return xRet;
791 awt::Rectangle SAL_CALL ThumbnailViewItemAcc::getBounds()
793 const SolarMutexGuard aSolarGuard;
794 awt::Rectangle aRet;
796 if( mpParent )
798 tools::Rectangle aRect( mpParent->getDrawArea() );
799 tools::Rectangle aParentRect;
801 // get position of the accessible parent in screen coordinates
802 uno::Reference< XAccessible > xParent = getAccessibleParent();
803 if ( xParent.is() )
805 uno::Reference<XAccessibleComponent> xParentComponent(xParent->getAccessibleContext(), uno::UNO_QUERY);
806 if (xParentComponent.is())
808 awt::Size aParentSize = xParentComponent->getSize();
809 aParentRect = tools::Rectangle(0, 0, aParentSize.Width, aParentSize.Height);
813 aRect.Intersection( aParentRect );
815 aRet.X = aRect.Left();
816 aRet.Y = aRect.Top();
817 aRet.Width = aRect.GetWidth();
818 aRet.Height = aRect.GetHeight();
821 return aRet;
824 awt::Point SAL_CALL ThumbnailViewItemAcc::getLocation()
826 const awt::Rectangle aRect( getBounds() );
827 awt::Point aRet;
829 aRet.X = aRect.X;
830 aRet.Y = aRect.Y;
832 return aRet;
835 awt::Point SAL_CALL ThumbnailViewItemAcc::getLocationOnScreen()
837 const SolarMutexGuard aSolarGuard;
838 awt::Point aRet;
840 if( mpParent )
842 const Point aPos = mpParent->getDrawArea().TopLeft();
844 aRet.X = aPos.X();
845 aRet.Y = aPos.Y();
847 // get position of the accessible parent in screen coordinates
848 uno::Reference< XAccessible > xParent = getAccessibleParent();
849 if ( xParent.is() )
851 uno::Reference<XAccessibleComponent> xParentComponent(xParent->getAccessibleContext(), uno::UNO_QUERY);
852 if (xParentComponent.is())
854 awt::Point aParentScreenLoc = xParentComponent->getLocationOnScreen();
855 aRet.X += aParentScreenLoc.X;
856 aRet.Y += aParentScreenLoc.Y;
861 return aRet;
864 awt::Size SAL_CALL ThumbnailViewItemAcc::getSize()
866 const awt::Rectangle aRect( getBounds() );
867 awt::Size aRet;
869 aRet.Width = aRect.Width;
870 aRet.Height = aRect.Height;
872 return aRet;
875 void SAL_CALL ThumbnailViewItemAcc::grabFocus()
877 // nothing to do
880 sal_Int32 SAL_CALL ThumbnailViewItemAcc::getForeground( )
882 Color nColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor();
883 return static_cast<sal_Int32>(nColor);
886 sal_Int32 SAL_CALL ThumbnailViewItemAcc::getBackground( )
888 return static_cast<sal_Int32>(Application::GetSettings().GetStyleSettings().GetWindowColor());
891 sal_Int64 SAL_CALL ThumbnailViewItemAcc::getSomething( const uno::Sequence< sal_Int8 >& rId )
893 sal_Int64 nRet;
895 if( isUnoTunnelId<ThumbnailViewItemAcc>(rId) )
896 nRet = reinterpret_cast< sal_Int64 >( this );
897 else
898 nRet = 0;
900 return nRet;
903 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */