Bump version to 24.04.3.4
[LibreOffice.git] / sfx2 / source / control / thumbnailviewacc.cxx
blob0a0f843a52d25880014cd91180b679d4231c76eb
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 <vcl/svapp.hxx>
26 #include <vcl/settings.hxx>
27 #include <sal/log.hxx>
28 #include <tools/debug.hxx>
29 #include <comphelper/diagnose_ex.hxx>
31 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
32 #include <com/sun/star/accessibility/AccessibleRole.hpp>
33 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
34 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
36 using namespace ::com::sun::star;
38 ThumbnailViewAcc::ThumbnailViewAcc( ThumbnailView* pParent ) :
39 mpParent( pParent )
43 ThumbnailViewAcc::~ThumbnailViewAcc()
47 uno::Reference< accessibility::XAccessibleContext > SAL_CALL ThumbnailViewAcc::getAccessibleContext()
49 ThrowIfDisposed();
50 return this;
53 sal_Int64 SAL_CALL ThumbnailViewAcc::getAccessibleChildCount()
55 const SolarMutexGuard aSolarGuard;
56 ThrowIfDisposed();
58 return mpParent->ImplGetVisibleItemCount();
61 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewAcc::getAccessibleChild( sal_Int64 i )
63 ThrowIfDisposed();
64 const SolarMutexGuard aSolarGuard;
66 if (i < 0 || i >= getAccessibleChildCount())
67 throw lang::IndexOutOfBoundsException();
69 ThumbnailViewItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(i));
71 if( !pItem )
72 throw lang::IndexOutOfBoundsException();
74 uno::Reference< accessibility::XAccessible > xRet = pItem->GetAccessible( /*bIsTransientChildrenDisabled*/false );
75 return xRet;
78 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewAcc::getAccessibleParent()
80 ThrowIfDisposed();
81 const SolarMutexGuard aSolarGuard;
82 return mpParent->GetDrawingArea()->get_accessible_parent();
85 sal_Int64 SAL_CALL ThumbnailViewAcc::getAccessibleIndexInParent()
87 ThrowIfDisposed();
88 const SolarMutexGuard aSolarGuard;
90 // -1 for child not found/no parent (according to specification)
91 sal_Int64 nRet = -1;
93 uno::Reference<accessibility::XAccessible> xParent(getAccessibleParent());
94 if (!xParent)
95 return nRet;
97 try
99 uno::Reference<accessibility::XAccessibleContext> xParentContext(xParent->getAccessibleContext());
101 // iterate over parent's children and search for this object
102 if ( xParentContext.is() )
104 sal_Int64 nChildCount = xParentContext->getAccessibleChildCount();
105 for ( sal_Int64 nChild = 0; ( nChild < nChildCount ) && ( -1 == nRet ); ++nChild )
107 uno::Reference<XAccessible> xChild(xParentContext->getAccessibleChild(nChild));
108 if ( xChild.get() == this )
109 nRet = nChild;
113 catch (const uno::Exception&)
115 TOOLS_WARN_EXCEPTION( "sfx", "ThumbnailViewAcc::getAccessibleIndexInParent" );
118 return nRet;
121 sal_Int16 SAL_CALL ThumbnailViewAcc::getAccessibleRole()
123 ThrowIfDisposed();
124 // #i73746# As the Java Access Bridge (v 2.0.1) uses "managesDescendants"
125 // always if the role is LIST, we need a different role in this case
126 return accessibility::AccessibleRole::LIST;
129 OUString SAL_CALL ThumbnailViewAcc::getAccessibleDescription()
131 ThrowIfDisposed();
132 return "ThumbnailView";
135 OUString SAL_CALL ThumbnailViewAcc::getAccessibleName()
137 ThrowIfDisposed();
138 const SolarMutexGuard aSolarGuard;
139 OUString aRet;
141 if (mpParent)
143 aRet = mpParent->GetAccessibleName();
146 return aRet;
149 uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ThumbnailViewAcc::getAccessibleRelationSet()
151 ThrowIfDisposed();
152 return uno::Reference< accessibility::XAccessibleRelationSet >();
155 sal_Int64 SAL_CALL ThumbnailViewAcc::getAccessibleStateSet()
157 ThrowIfDisposed();
158 sal_Int64 nStateSet = 0;
160 // Set some states.
161 nStateSet |= accessibility::AccessibleStateType::ENABLED;
162 nStateSet |= accessibility::AccessibleStateType::SENSITIVE;
163 nStateSet |= accessibility::AccessibleStateType::SHOWING;
164 nStateSet |= accessibility::AccessibleStateType::VISIBLE;
165 nStateSet |= accessibility::AccessibleStateType::MANAGES_DESCENDANTS;
166 nStateSet |= accessibility::AccessibleStateType::FOCUSABLE;
168 return nStateSet;
171 lang::Locale SAL_CALL ThumbnailViewAcc::getLocale()
173 ThrowIfDisposed();
174 const SolarMutexGuard aSolarGuard;
175 uno::Reference< accessibility::XAccessible > xParent( getAccessibleParent() );
176 lang::Locale aRet( "", "", "" );
178 if( xParent.is() )
180 uno::Reference< accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
182 if( xParentContext.is() )
183 aRet = xParentContext->getLocale ();
186 return aRet;
189 void SAL_CALL ThumbnailViewAcc::addAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
191 ThrowIfDisposed();
192 std::unique_lock aGuard (m_aMutex);
194 if( !rxListener.is() )
195 return;
197 bool bFound = false;
199 for (auto const& eventListener : mxEventListeners)
201 if( eventListener == rxListener )
203 bFound = true;
204 break;
208 if (!bFound)
209 mxEventListeners.push_back( rxListener );
212 void SAL_CALL ThumbnailViewAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
214 ThrowIfDisposed();
215 std::unique_lock aGuard (m_aMutex);
217 if( rxListener.is() )
219 std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::iterator aIter =
220 std::find(mxEventListeners.begin(), mxEventListeners.end(), rxListener);
222 if (aIter != mxEventListeners.end())
223 mxEventListeners.erase( aIter );
227 sal_Bool SAL_CALL ThumbnailViewAcc::containsPoint( const awt::Point& aPoint )
229 ThrowIfDisposed();
230 const awt::Rectangle aRect( getBounds() );
231 const Point aSize( aRect.Width, aRect.Height );
232 const Point aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
234 return tools::Rectangle( aNullPoint, aSize ).Contains( aTestPoint );
237 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewAcc::getAccessibleAtPoint( const awt::Point& aPoint )
239 ThrowIfDisposed();
240 const SolarMutexGuard aSolarGuard;
241 const sal_uInt16 nItemId = mpParent->GetItemId( Point( aPoint.X, aPoint.Y ) );
242 uno::Reference< accessibility::XAccessible > xRet;
244 if ( nItemId )
246 const size_t nItemPos = mpParent->GetItemPos( nItemId );
248 if( THUMBNAILVIEW_ITEM_NONEITEM != nItemPos )
250 ThumbnailViewItem *const pItem = mpParent->mFilteredItemList[nItemPos];
251 xRet = pItem->GetAccessible( /*bIsTransientChildrenDisabled*/false );
255 return xRet;
258 awt::Rectangle SAL_CALL ThumbnailViewAcc::getBounds()
260 ThrowIfDisposed();
261 const SolarMutexGuard aSolarGuard;
262 const Point aOutPos;
263 const Size aOutSize( mpParent->GetOutputSizePixel() );
264 awt::Rectangle aRet;
266 aRet.X = aOutPos.X();
267 aRet.Y = aOutPos.Y();
268 aRet.Width = aOutSize.Width();
269 aRet.Height = aOutSize.Height();
271 return aRet;
274 awt::Point SAL_CALL ThumbnailViewAcc::getLocation()
276 ThrowIfDisposed();
277 const awt::Rectangle aRect( getBounds() );
278 awt::Point aRet;
280 aRet.X = aRect.X;
281 aRet.Y = aRect.Y;
283 return aRet;
286 awt::Point SAL_CALL ThumbnailViewAcc::getLocationOnScreen()
288 ThrowIfDisposed();
289 const SolarMutexGuard aSolarGuard;
290 awt::Point aScreenLoc(0, 0);
292 uno::Reference<accessibility::XAccessible> xParent(getAccessibleParent());
293 if (xParent)
295 uno::Reference<accessibility::XAccessibleContext> xParentContext(xParent->getAccessibleContext());
296 uno::Reference<accessibility::XAccessibleComponent> xParentComponent(xParentContext, css::uno::UNO_QUERY);
297 OSL_ENSURE( xParentComponent.is(), "ThumbnailViewAcc::getLocationOnScreen: no parent component!" );
298 if ( xParentComponent.is() )
300 awt::Point aParentScreenLoc( xParentComponent->getLocationOnScreen() );
301 awt::Point aOwnRelativeLoc( getLocation() );
302 aScreenLoc.X = aParentScreenLoc.X + aOwnRelativeLoc.X;
303 aScreenLoc.Y = aParentScreenLoc.Y + aOwnRelativeLoc.Y;
307 return aScreenLoc;
310 awt::Size SAL_CALL ThumbnailViewAcc::getSize()
312 ThrowIfDisposed();
313 const awt::Rectangle aRect( getBounds() );
314 awt::Size aRet;
316 aRet.Width = aRect.Width;
317 aRet.Height = aRect.Height;
319 return aRet;
322 void SAL_CALL ThumbnailViewAcc::grabFocus()
324 ThrowIfDisposed();
325 const SolarMutexGuard aSolarGuard;
326 mpParent->GrabFocus();
329 sal_Int32 SAL_CALL ThumbnailViewAcc::getForeground( )
331 ThrowIfDisposed();
332 Color nColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor();
333 return static_cast<sal_Int32>(nColor);
336 sal_Int32 SAL_CALL ThumbnailViewAcc::getBackground( )
338 ThrowIfDisposed();
339 Color nColor = Application::GetSettings().GetStyleSettings().GetWindowColor();
340 return static_cast<sal_Int32>(nColor);
343 void SAL_CALL ThumbnailViewAcc::selectAccessibleChild( sal_Int64 nChildIndex )
345 ThrowIfDisposed();
346 const SolarMutexGuard aSolarGuard;
348 if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
349 throw lang::IndexOutOfBoundsException();
351 ThumbnailViewItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
353 if(pItem == nullptr)
354 throw lang::IndexOutOfBoundsException();
356 mpParent->SelectItem( pItem->mnId );
359 sal_Bool SAL_CALL ThumbnailViewAcc::isAccessibleChildSelected( sal_Int64 nChildIndex )
361 ThrowIfDisposed();
362 const SolarMutexGuard aSolarGuard;
364 if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
365 throw lang::IndexOutOfBoundsException();
367 ThumbnailViewItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
369 if (pItem == nullptr)
370 throw lang::IndexOutOfBoundsException();
372 return mpParent->IsItemSelected( pItem->mnId );
375 void SAL_CALL ThumbnailViewAcc::clearAccessibleSelection()
377 ThrowIfDisposed();
380 void SAL_CALL ThumbnailViewAcc::selectAllAccessibleChildren()
382 ThrowIfDisposed();
383 // unsupported due to single selection only
386 sal_Int64 SAL_CALL ThumbnailViewAcc::getSelectedAccessibleChildCount()
388 ThrowIfDisposed();
389 const SolarMutexGuard aSolarGuard;
390 sal_Int64 nRet = 0;
392 for( sal_uInt16 i = 0, nCount = getItemCount(); i < nCount; i++ )
394 ThumbnailViewItem* pItem = getItem (i);
396 if( pItem && mpParent->IsItemSelected( pItem->mnId ) )
397 ++nRet;
400 return nRet;
403 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewAcc::getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex )
405 ThrowIfDisposed();
406 const SolarMutexGuard aSolarGuard;
407 uno::Reference< accessibility::XAccessible > xRet;
409 for( sal_uInt16 i = 0, nCount = getItemCount(), nSel = 0; ( i < nCount ) && !xRet.is(); i++ )
411 ThumbnailViewItem* pItem = getItem(i);
413 if( pItem && mpParent->IsItemSelected( pItem->mnId ) && ( nSelectedChildIndex == static_cast< sal_Int32 >( nSel++ ) ) )
414 xRet = pItem->GetAccessible( /*bIsTransientChildrenDisabled*/false );
417 return xRet;
420 void SAL_CALL ThumbnailViewAcc::deselectAccessibleChild( sal_Int64 nChildIndex)
422 ThrowIfDisposed();
423 const SolarMutexGuard aSolarGuard;
425 if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
426 throw lang::IndexOutOfBoundsException();
428 // Because of the single selection we can reset the whole selection when
429 // the specified child is currently selected.
430 //FIXME TODO if (isAccessibleChildSelected(nChildIndex))
431 //FIXME TODO ;
434 void ThumbnailViewAcc::disposing(std::unique_lock<std::mutex>& rGuard)
436 ::std::vector<uno::Reference<accessibility::XAccessibleEventListener> > aListenerListCopy;
438 // unlock because we need to take solar and the lock mutex in the correct order
439 rGuard.unlock();
441 const SolarMutexGuard aSolarGuard;
442 std::unique_lock aGuard (m_aMutex);
444 // Reset the pointer to the parent. It has to be the one who has
445 // disposed us because he is dying.
446 mpParent = nullptr;
448 if (mxEventListeners.empty())
449 return;
451 // Make a copy of the list and clear the original.
452 aListenerListCopy = std::move(mxEventListeners);
455 // Inform all listeners that this objects is disposing.
456 lang::EventObject aEvent (static_cast<accessibility::XAccessible*>(this));
457 for (auto const& listener : aListenerListCopy)
461 listener->disposing (aEvent);
463 catch(const uno::Exception&)
465 // Ignore exceptions.
470 sal_uInt16 ThumbnailViewAcc::getItemCount() const
472 return mpParent->ImplGetVisibleItemCount();
475 ThumbnailViewItem* ThumbnailViewAcc::getItem (sal_uInt16 nIndex) const
477 return mpParent->ImplGetVisibleItem (nIndex);
480 void ThumbnailViewAcc::ThrowIfDisposed()
482 if (m_bDisposed)
484 SAL_WARN("sfx", "Calling disposed object. Throwing exception:");
485 throw lang::DisposedException (
486 "object has been already disposed",
487 getXWeak());
489 else
491 DBG_ASSERT (mpParent!=nullptr, "ValueSetAcc not disposed but mpParent == NULL");
495 ThumbnailViewItemAcc::ThumbnailViewItemAcc( ThumbnailViewItem* pParent, bool bIsTransientChildrenDisabled ) :
496 mpParent( pParent ),
497 mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled )
501 ThumbnailViewItemAcc::~ThumbnailViewItemAcc()
505 void ThumbnailViewItemAcc::ParentDestroyed()
507 std::scoped_lock aGuard( maMutex );
508 mpParent = nullptr;
511 void ThumbnailViewAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOldValue, const uno::Any& rNewValue )
513 if( !nEventId )
514 return;
516 ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > > aTmpListeners( mxEventListeners );
517 accessibility::AccessibleEventObject aEvtObject;
519 aEvtObject.EventId = nEventId;
520 aEvtObject.Source = getXWeak();
521 aEvtObject.NewValue = rNewValue;
522 aEvtObject.OldValue = rOldValue;
523 aEvtObject.IndexHint = -1;
525 for (auto const& tmpListener : aTmpListeners)
529 tmpListener->notifyEvent( aEvtObject );
531 catch(const uno::Exception&)
537 void ThumbnailViewAcc::GetFocus()
539 // Broadcast the state change.
540 css::uno::Any aOldState, aNewState;
541 aNewState <<= css::accessibility::AccessibleStateType::FOCUSED;
542 FireAccessibleEvent(
543 css::accessibility::AccessibleEventId::STATE_CHANGED,
544 aOldState, aNewState);
547 void ThumbnailViewAcc::LoseFocus()
549 // Broadcast the state change.
550 css::uno::Any aOldState, aNewState;
551 aOldState <<= css::accessibility::AccessibleStateType::FOCUSED;
552 FireAccessibleEvent(
553 css::accessibility::AccessibleEventId::STATE_CHANGED,
554 aOldState, aNewState);
557 uno::Reference< accessibility::XAccessibleContext > SAL_CALL ThumbnailViewItemAcc::getAccessibleContext()
559 return this;
562 sal_Int64 SAL_CALL ThumbnailViewItemAcc::getAccessibleChildCount()
564 return 0;
567 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewItemAcc::getAccessibleChild( sal_Int64 )
569 throw lang::IndexOutOfBoundsException();
572 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewItemAcc::getAccessibleParent()
574 const SolarMutexGuard aSolarGuard;
575 uno::Reference< accessibility::XAccessible > xRet;
577 if( mpParent )
578 xRet = mpParent->mrParent.getAccessible();
580 return xRet;
583 sal_Int64 SAL_CALL ThumbnailViewItemAcc::getAccessibleIndexInParent()
585 const SolarMutexGuard aSolarGuard;
586 // The index defaults to -1 to indicate the child does not belong to its
587 // parent.
588 sal_Int64 nIndexInParent = -1;
590 if( mpParent )
592 bool bDone = false;
594 sal_uInt16 nCount = mpParent->mrParent.ImplGetVisibleItemCount();
595 ThumbnailViewItem* pItem;
596 for (sal_uInt16 i=0; i<nCount && !bDone; i++)
598 // Guard the retrieval of the i-th child with a try/catch block
599 // just in case the number of children changes in the meantime.
602 pItem = mpParent->mrParent.ImplGetVisibleItem (i);
604 catch (const lang::IndexOutOfBoundsException&)
606 pItem = nullptr;
609 // Do not create an accessible object for the test.
610 if (pItem != nullptr && pItem->mxAcc.is())
611 if (pItem->GetAccessible( mbIsTransientChildrenDisabled ).get() == this )
613 nIndexInParent = i;
614 bDone = true;
619 return nIndexInParent;
622 sal_Int16 SAL_CALL ThumbnailViewItemAcc::getAccessibleRole()
624 return accessibility::AccessibleRole::LIST_ITEM;
627 OUString SAL_CALL ThumbnailViewItemAcc::getAccessibleDescription()
629 return OUString();
632 OUString SAL_CALL ThumbnailViewItemAcc::getAccessibleName()
634 const SolarMutexGuard aSolarGuard;
635 OUString aRet;
637 if( mpParent )
639 aRet = mpParent->maTitle;
641 if( aRet.isEmpty() )
643 aRet = "Item " + OUString::number(static_cast<sal_Int32>(mpParent->mnId));
647 return aRet;
650 uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ThumbnailViewItemAcc::getAccessibleRelationSet()
652 return uno::Reference< accessibility::XAccessibleRelationSet >();
655 sal_Int64 SAL_CALL ThumbnailViewItemAcc::getAccessibleStateSet()
657 const SolarMutexGuard aSolarGuard;
658 sal_Int64 nStateSet = 0;
660 if( mpParent )
662 nStateSet |= accessibility::AccessibleStateType::ENABLED;
663 nStateSet |= accessibility::AccessibleStateType::SENSITIVE;
664 nStateSet |= accessibility::AccessibleStateType::SHOWING;
665 nStateSet |= accessibility::AccessibleStateType::VISIBLE;
666 if ( !mbIsTransientChildrenDisabled )
667 nStateSet |= accessibility::AccessibleStateType::TRANSIENT;
669 nStateSet |= accessibility::AccessibleStateType::SELECTABLE;
670 nStateSet |= accessibility::AccessibleStateType::FOCUSABLE;
672 if( mpParent->isSelected() )
674 nStateSet |= accessibility::AccessibleStateType::SELECTED;
675 if (mpParent->mrParent.HasChildFocus())
676 nStateSet |= accessibility::AccessibleStateType::FOCUSED;
680 return nStateSet;
683 lang::Locale SAL_CALL ThumbnailViewItemAcc::getLocale()
685 const SolarMutexGuard aSolarGuard;
686 uno::Reference< accessibility::XAccessible > xParent( getAccessibleParent() );
687 lang::Locale aRet( "", "", "" );
689 if( xParent.is() )
691 uno::Reference< accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
693 if( xParentContext.is() )
694 aRet = xParentContext->getLocale();
697 return aRet;
700 void SAL_CALL ThumbnailViewItemAcc::addAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
702 std::scoped_lock aGuard( maMutex );
704 if( !rxListener.is() )
705 return;
707 bool bFound = false;
709 for (auto const& eventListener : mxEventListeners)
711 if( eventListener == rxListener )
713 bFound = true;
714 break;
718 if (!bFound)
719 mxEventListeners.push_back( rxListener );
722 void SAL_CALL ThumbnailViewItemAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
724 std::scoped_lock aGuard( maMutex );
726 if( rxListener.is() )
728 std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::iterator aIter =
729 std::find(mxEventListeners.begin(), mxEventListeners.end(), rxListener);
731 if (aIter != mxEventListeners.end())
732 mxEventListeners.erase( aIter );
736 sal_Bool SAL_CALL ThumbnailViewItemAcc::containsPoint( const awt::Point& aPoint )
738 const awt::Rectangle aRect( getBounds() );
739 const Point aSize( aRect.Width, aRect.Height );
740 const Point aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
742 return tools::Rectangle( aNullPoint, aSize ).Contains( aTestPoint );
745 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewItemAcc::getAccessibleAtPoint( const awt::Point& )
747 uno::Reference< accessibility::XAccessible > xRet;
748 return xRet;
751 awt::Rectangle SAL_CALL ThumbnailViewItemAcc::getBounds()
753 const SolarMutexGuard aSolarGuard;
754 awt::Rectangle aRet;
756 if( mpParent )
758 tools::Rectangle aRect( mpParent->getDrawArea() );
759 tools::Rectangle aParentRect;
761 // get position of the accessible parent in screen coordinates
762 uno::Reference< XAccessible > xParent = getAccessibleParent();
763 if ( xParent.is() )
765 uno::Reference<XAccessibleComponent> xParentComponent(xParent->getAccessibleContext(), uno::UNO_QUERY);
766 if (xParentComponent.is())
768 awt::Size aParentSize = xParentComponent->getSize();
769 aParentRect = tools::Rectangle(0, 0, aParentSize.Width, aParentSize.Height);
773 aRect.Intersection( aParentRect );
775 aRet.X = aRect.Left();
776 aRet.Y = aRect.Top();
777 aRet.Width = aRect.GetWidth();
778 aRet.Height = aRect.GetHeight();
781 return aRet;
784 awt::Point SAL_CALL ThumbnailViewItemAcc::getLocation()
786 const awt::Rectangle aRect( getBounds() );
787 awt::Point aRet;
789 aRet.X = aRect.X;
790 aRet.Y = aRect.Y;
792 return aRet;
795 // get position of the accessible parent in screen coordinates
796 awt::Point SAL_CALL ThumbnailViewItemAcc::getLocationOnScreen()
798 const SolarMutexGuard aSolarGuard;
799 awt::Point aRet;
801 if (mpParent)
803 const Point aPos = mpParent->getDrawArea().TopLeft();
804 const Point aScreenPos(mpParent->mrParent.GetDrawingArea()->get_accessible_location_on_screen());
806 aRet.X = aPos.X() + aScreenPos.X();
807 aRet.Y = aPos.Y() + aScreenPos.X();
810 return aRet;
813 awt::Size SAL_CALL ThumbnailViewItemAcc::getSize()
815 const awt::Rectangle aRect( getBounds() );
816 awt::Size aRet;
818 aRet.Width = aRect.Width;
819 aRet.Height = aRect.Height;
821 return aRet;
824 void SAL_CALL ThumbnailViewItemAcc::grabFocus()
826 // nothing to do
829 sal_Int32 SAL_CALL ThumbnailViewItemAcc::getForeground( )
831 Color nColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor();
832 return static_cast<sal_Int32>(nColor);
835 sal_Int32 SAL_CALL ThumbnailViewItemAcc::getBackground( )
837 return static_cast<sal_Int32>(Application::GetSettings().GetStyleSettings().GetWindowColor());
840 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */