Bump version to 4.1-6
[LibreOffice.git] / sfx2 / source / control / thumbnailviewacc.cxx
blobfc43115362627df9d238b3a5a0efdeff675ddd59
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>
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),
36 mpParent( pParent ),
37 mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled ),
38 mbIsFocused(false)
42 ThumbnailViewAcc::~ThumbnailViewAcc()
46 void ThumbnailViewAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOldValue, const uno::Any& rNewValue )
48 if( nEventId )
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)
61 try
63 (*aIter)->notifyEvent( aEvtObject );
65 catch(const uno::Exception&)
72 namespace
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 )
83 throw()
85 try
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&)
92 return NULL;
96 void ThumbnailViewAcc::GetFocus (void)
98 mbIsFocused = true;
100 // Boradcast the state change.
101 ::com::sun::star::uno::Any aOldState, aNewState;
102 aNewState <<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED;
103 FireAccessibleEvent(
104 ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED,
105 aOldState, aNewState);
108 void ThumbnailViewAcc::LoseFocus (void)
110 mbIsFocused = false;
112 // Boradcast the state change.
113 ::com::sun::star::uno::Any aOldState, aNewState;
114 aOldState <<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED;
115 FireAccessibleEvent(
116 ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED,
117 aOldState, aNewState);
120 uno::Reference< accessibility::XAccessibleContext > SAL_CALL ThumbnailViewAcc::getAccessibleContext()
121 throw (uno::RuntimeException)
123 ThrowIfDisposed();
124 return this;
127 sal_Int32 SAL_CALL ThumbnailViewAcc::getAccessibleChildCount()
128 throw (uno::RuntimeException)
130 const SolarMutexGuard aSolarGuard;
131 ThrowIfDisposed();
133 sal_Int32 nCount = mpParent->ImplGetVisibleItemCount();
134 return nCount;
137 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewAcc::getAccessibleChild( sal_Int32 i )
138 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
140 ThrowIfDisposed();
141 const SolarMutexGuard aSolarGuard;
142 uno::Reference< accessibility::XAccessible > xRet;
143 ThumbnailViewItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(i));
145 if( pItem )
146 xRet = pItem->GetAccessible( mbIsTransientChildrenDisabled );
147 else
148 throw lang::IndexOutOfBoundsException();
150 return xRet;
153 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewAcc::getAccessibleParent()
154 throw (uno::RuntimeException)
156 ThrowIfDisposed();
157 const SolarMutexGuard aSolarGuard;
158 Window* pParent = mpParent->GetParent();
159 uno::Reference< accessibility::XAccessible > xRet;
161 if( pParent )
162 xRet = pParent->GetAccessible();
164 return xRet;
167 sal_Int32 SAL_CALL ThumbnailViewAcc::getAccessibleIndexInParent()
168 throw (uno::RuntimeException)
170 ThrowIfDisposed();
171 const SolarMutexGuard aSolarGuard;
172 Window* pParent = mpParent->GetParent();
173 sal_Int32 nRet = 0;
175 if( pParent )
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 )
183 nRet = i;
184 bFound = sal_True;
189 return nRet;
192 sal_Int16 SAL_CALL ThumbnailViewAcc::getAccessibleRole()
193 throw (uno::RuntimeException)
195 ThrowIfDisposed();
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)
206 ThrowIfDisposed();
207 const SolarMutexGuard aSolarGuard;
208 return OUString("ThumbnailView");
211 OUString SAL_CALL ThumbnailViewAcc::getAccessibleName()
212 throw (uno::RuntimeException)
214 ThrowIfDisposed();
215 const SolarMutexGuard aSolarGuard;
216 OUString aRet;
218 if ( mpParent )
219 aRet = mpParent->GetAccessibleName();
221 if ( aRet.isEmpty() )
223 Window* pLabel = mpParent->GetAccessibleRelationLabeledBy();
224 if ( pLabel && pLabel != mpParent )
225 aRet = OutputDevice::GetNonMnemonicString( pLabel->GetText() );
228 return aRet;
231 uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ThumbnailViewAcc::getAccessibleRelationSet()
232 throw (uno::RuntimeException)
234 ThrowIfDisposed();
235 return uno::Reference< accessibility::XAccessibleRelationSet >();
238 uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL ThumbnailViewAcc::getAccessibleStateSet()
239 throw (uno::RuntimeException)
241 ThrowIfDisposed();
242 ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper();
244 // Set some states.
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);
252 if (mbIsFocused)
253 pStateSet->AddState (accessibility::AccessibleStateType::FOCUSED);
255 return pStateSet;
258 lang::Locale SAL_CALL ThumbnailViewAcc::getLocale()
259 throw (accessibility::IllegalAccessibleComponentStateException, uno::RuntimeException)
261 ThrowIfDisposed();
262 const SolarMutexGuard aSolarGuard;
263 const OUString aEmptyStr;
264 uno::Reference< accessibility::XAccessible > xParent( getAccessibleParent() );
265 lang::Locale aRet( aEmptyStr, aEmptyStr, aEmptyStr );
267 if( xParent.is() )
269 uno::Reference< accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
271 if( xParentContext.is() )
272 aRet = xParentContext->getLocale ();
275 return aRet;
278 void SAL_CALL ThumbnailViewAcc::addAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
279 throw (uno::RuntimeException)
281 ThrowIfDisposed();
282 ::osl::MutexGuard aGuard (m_aMutex);
284 if( rxListener.is() )
286 std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter = mxEventListeners.begin();
287 bool bFound = false;
289 while( !bFound && ( aIter != mxEventListeners.end() ) )
291 if( *aIter == rxListener )
292 bFound = true;
293 else
294 ++aIter;
297 if (!bFound)
298 mxEventListeners.push_back( rxListener );
302 void SAL_CALL ThumbnailViewAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
303 throw (uno::RuntimeException)
305 ThrowIfDisposed();
306 ::osl::MutexGuard aGuard (m_aMutex);
308 if( rxListener.is() )
310 std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::iterator aIter = mxEventListeners.begin();
311 bool bFound = false;
313 while( !bFound && ( aIter != mxEventListeners.end() ) )
315 if( *aIter == rxListener )
317 mxEventListeners.erase( aIter );
318 bFound = true;
320 else
321 ++aIter;
326 sal_Bool SAL_CALL ThumbnailViewAcc::containsPoint( const awt::Point& aPoint )
327 throw (uno::RuntimeException)
329 ThrowIfDisposed();
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)
340 ThrowIfDisposed();
341 const SolarMutexGuard aSolarGuard;
342 const sal_uInt16 nItemId = mpParent->GetItemId( Point( aPoint.X, aPoint.Y ) );
343 uno::Reference< accessibility::XAccessible > xRet;
345 if ( nItemId )
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 );
356 return xRet;
359 awt::Rectangle SAL_CALL ThumbnailViewAcc::getBounds()
360 throw (uno::RuntimeException)
362 ThrowIfDisposed();
363 const SolarMutexGuard aSolarGuard;
364 const Point aOutPos( mpParent->GetPosPixel() );
365 const Size aOutSize( mpParent->GetOutputSizePixel() );
366 awt::Rectangle aRet;
368 aRet.X = aOutPos.X();
369 aRet.Y = aOutPos.Y();
370 aRet.Width = aOutSize.Width();
371 aRet.Height = aOutSize.Height();
373 return aRet;
376 awt::Point SAL_CALL ThumbnailViewAcc::getLocation()
377 throw (uno::RuntimeException)
379 ThrowIfDisposed();
380 const awt::Rectangle aRect( getBounds() );
381 awt::Point aRet;
383 aRet.X = aRect.X;
384 aRet.Y = aRect.Y;
386 return aRet;
389 awt::Point SAL_CALL ThumbnailViewAcc::getLocationOnScreen()
390 throw (uno::RuntimeException)
392 ThrowIfDisposed();
393 const SolarMutexGuard aSolarGuard;
394 const Point aScreenPos( mpParent->OutputToAbsoluteScreenPixel( Point() ) );
395 awt::Point aRet;
397 aRet.X = aScreenPos.X();
398 aRet.Y = aScreenPos.Y();
400 return aRet;
403 awt::Size SAL_CALL ThumbnailViewAcc::getSize()
404 throw (uno::RuntimeException)
406 ThrowIfDisposed();
407 const awt::Rectangle aRect( getBounds() );
408 awt::Size aRet;
410 aRet.Width = aRect.Width;
411 aRet.Height = aRect.Height;
413 return aRet;
416 void SAL_CALL ThumbnailViewAcc::grabFocus()
417 throw (uno::RuntimeException)
419 ThrowIfDisposed();
420 const SolarMutexGuard aSolarGuard;
421 mpParent->GrabFocus();
424 uno::Any SAL_CALL ThumbnailViewAcc::getAccessibleKeyBinding()
425 throw (uno::RuntimeException)
427 ThrowIfDisposed();
428 return uno::Any();
431 sal_Int32 SAL_CALL ThumbnailViewAcc::getForeground( )
432 throw (uno::RuntimeException)
434 ThrowIfDisposed();
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)
442 ThrowIfDisposed();
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)
450 ThrowIfDisposed();
451 const SolarMutexGuard aSolarGuard;
452 ThumbnailViewItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
454 if(pItem != NULL)
456 mpParent->SelectItem( pItem->mnId );
458 else
459 throw lang::IndexOutOfBoundsException();
462 sal_Bool SAL_CALL ThumbnailViewAcc::isAccessibleChildSelected( sal_Int32 nChildIndex )
463 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
465 ThrowIfDisposed();
466 const SolarMutexGuard aSolarGuard;
467 ThumbnailViewItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
468 sal_Bool bRet = sal_False;
470 if (pItem != NULL)
471 bRet = mpParent->IsItemSelected( pItem->mnId );
472 else
473 throw lang::IndexOutOfBoundsException();
475 return bRet;
478 void SAL_CALL ThumbnailViewAcc::clearAccessibleSelection()
479 throw (uno::RuntimeException)
481 ThrowIfDisposed();
482 const SolarMutexGuard aSolarGuard;
485 void SAL_CALL ThumbnailViewAcc::selectAllAccessibleChildren()
486 throw (uno::RuntimeException)
488 ThrowIfDisposed();
489 // unsupported due to single selection only
492 sal_Int32 SAL_CALL ThumbnailViewAcc::getSelectedAccessibleChildCount()
493 throw (uno::RuntimeException)
495 ThrowIfDisposed();
496 const SolarMutexGuard aSolarGuard;
497 sal_Int32 nRet = 0;
499 for( sal_uInt16 i = 0, nCount = getItemCount(); i < nCount; i++ )
501 ThumbnailViewItem* pItem = getItem (i);
503 if( pItem && mpParent->IsItemSelected( pItem->mnId ) )
504 ++nRet;
507 return nRet;
510 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewAcc::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
511 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
513 ThrowIfDisposed();
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 );
525 return xRet;
528 void SAL_CALL ThumbnailViewAcc::deselectAccessibleChild( sal_Int32 nChildIndex )
529 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
531 ThrowIfDisposed();
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))
536 //FIXME TODO ;
537 (void) nChildIndex;
540 sal_Int64 SAL_CALL ThumbnailViewAcc::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw( uno::RuntimeException )
542 sal_Int64 nRet;
544 if( ( rId.getLength() == 16 ) && ( 0 == memcmp( ThumbnailViewAcc::getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
545 nRet = reinterpret_cast< sal_Int64 >( this );
546 else
547 nRet = 0;
549 return nRet;
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.
565 mpParent = NULL;
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.
583 ++aListenerIterator;
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));
607 else
609 DBG_ASSERT (mpParent!=NULL, "ValueSetAcc not disposed but mpParent == NULL");
613 ThumbnailViewItemAcc::ThumbnailViewItemAcc( ThumbnailViewItem* pParent, bool bIsTransientChildrenDisabled ) :
614 mpParent( pParent ),
615 mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled )
619 ThumbnailViewItemAcc::~ThumbnailViewItemAcc()
623 void ThumbnailViewItemAcc::ParentDestroyed()
625 const ::osl::MutexGuard aGuard( maMutex );
626 mpParent = NULL;
629 namespace
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)
642 return this;
645 sal_Int32 SAL_CALL ThumbnailViewItemAcc::getAccessibleChildCount()
646 throw (uno::RuntimeException)
648 return 0;
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;
663 if( mpParent )
664 xRet = mpParent->mrParent.GetAccessible();
666 return xRet;
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
674 // parent.
675 sal_Int32 nIndexInParent = -1;
677 if( mpParent )
679 bool bDone = false;
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&)
693 pItem = NULL;
696 // Do not create an accessible object for the test.
697 if (pItem != NULL && pItem->mpxAcc != NULL)
698 if (pItem->GetAccessible( mbIsTransientChildrenDisabled ).get() == this )
700 nIndexInParent = i;
701 bDone = true;
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)
718 return OUString();
721 OUString SAL_CALL ThumbnailViewItemAcc::getAccessibleName()
722 throw (uno::RuntimeException)
724 const SolarMutexGuard aSolarGuard;
725 OUString aRet;
727 if( mpParent )
729 aRet = mpParent->maTitle;
731 if( aRet.isEmpty() )
733 OUStringBuffer aBuffer("Item ");
734 aBuffer.append(static_cast<sal_Int32>(mpParent->mnId));
735 aRet = aBuffer.makeStringAndClear();
739 return aRet;
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;
754 if( mpParent )
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);
763 // SELECTABLE
764 pStateSet->AddState( accessibility::AccessibleStateType::SELECTABLE );
765 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE );
767 // SELECTED
768 if( mpParent->isSelected() )
770 pStateSet->AddState( accessibility::AccessibleStateType::SELECTED );
771 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSED );
775 return pStateSet;
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 );
786 if( xParent.is() )
788 uno::Reference< accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
790 if( xParentContext.is() )
791 aRet = xParentContext->getLocale();
794 return aRet;
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 )
810 bFound = sal_True;
811 else
812 ++aIter;
815 if (!bFound)
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 );
835 bFound = sal_True;
837 else
838 ++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;
857 return xRet;
860 awt::Rectangle SAL_CALL ThumbnailViewItemAcc::getBounds()
861 throw (uno::RuntimeException)
863 const SolarMutexGuard aSolarGuard;
864 awt::Rectangle aRet;
866 if( mpParent )
868 Rectangle aRect( mpParent->getDrawArea() );
869 Point aOrigin;
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();
880 return aRet;
883 awt::Point SAL_CALL ThumbnailViewItemAcc::getLocation()
884 throw (uno::RuntimeException)
886 const awt::Rectangle aRect( getBounds() );
887 awt::Point aRet;
889 aRet.X = aRect.X;
890 aRet.Y = aRect.Y;
892 return aRet;
895 awt::Point SAL_CALL ThumbnailViewItemAcc::getLocationOnScreen()
896 throw (uno::RuntimeException)
898 const SolarMutexGuard aSolarGuard;
899 awt::Point aRet;
901 if( mpParent )
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();
910 return aRet;
913 awt::Size SAL_CALL ThumbnailViewItemAcc::getSize()
914 throw (uno::RuntimeException)
916 const awt::Rectangle aRect( getBounds() );
917 awt::Size aRet;
919 aRet.Width = aRect.Width;
920 aRet.Height = aRect.Height;
922 return aRet;
925 void SAL_CALL ThumbnailViewItemAcc::grabFocus()
926 throw (uno::RuntimeException)
928 // nothing to do
931 uno::Any SAL_CALL ThumbnailViewItemAcc::getAccessibleKeyBinding()
932 throw (uno::RuntimeException)
934 return uno::Any();
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 )
952 sal_Int64 nRet;
954 if( ( rId.getLength() == 16 ) && ( 0 == memcmp( ThumbnailViewItemAcc::getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
955 nRet = reinterpret_cast< sal_Int64 >( this );
956 else
957 nRet = 0;
959 return nRet;
962 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */