bump product version to 4.2.0.1
[LibreOffice.git] / sfx2 / source / control / thumbnailviewacc.cxx
blob3f612442bc9fd071523a5ad5dd948960edc37594
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 =
311 std::find(mxEventListeners.begin(), mxEventListeners.end(), rxListener);
313 if (aIter != mxEventListeners.end())
314 mxEventListeners.erase( aIter );
318 sal_Bool SAL_CALL ThumbnailViewAcc::containsPoint( const awt::Point& aPoint )
319 throw (uno::RuntimeException)
321 ThrowIfDisposed();
322 const awt::Rectangle aRect( getBounds() );
323 const Point aSize( aRect.Width, aRect.Height );
324 const Point aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
326 return Rectangle( aNullPoint, aSize ).IsInside( aTestPoint );
329 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewAcc::getAccessibleAtPoint( const awt::Point& aPoint )
330 throw (uno::RuntimeException)
332 ThrowIfDisposed();
333 const SolarMutexGuard aSolarGuard;
334 const sal_uInt16 nItemId = mpParent->GetItemId( Point( aPoint.X, aPoint.Y ) );
335 uno::Reference< accessibility::XAccessible > xRet;
337 if ( nItemId )
339 const size_t nItemPos = mpParent->GetItemPos( nItemId );
341 if( THUMBNAILVIEW_ITEM_NONEITEM != nItemPos )
343 ThumbnailViewItem *const pItem = mpParent->mFilteredItemList[nItemPos];
344 xRet = pItem->GetAccessible( mbIsTransientChildrenDisabled );
348 return xRet;
351 awt::Rectangle SAL_CALL ThumbnailViewAcc::getBounds()
352 throw (uno::RuntimeException)
354 ThrowIfDisposed();
355 const SolarMutexGuard aSolarGuard;
356 const Point aOutPos( mpParent->GetPosPixel() );
357 const Size aOutSize( mpParent->GetOutputSizePixel() );
358 awt::Rectangle aRet;
360 aRet.X = aOutPos.X();
361 aRet.Y = aOutPos.Y();
362 aRet.Width = aOutSize.Width();
363 aRet.Height = aOutSize.Height();
365 return aRet;
368 awt::Point SAL_CALL ThumbnailViewAcc::getLocation()
369 throw (uno::RuntimeException)
371 ThrowIfDisposed();
372 const awt::Rectangle aRect( getBounds() );
373 awt::Point aRet;
375 aRet.X = aRect.X;
376 aRet.Y = aRect.Y;
378 return aRet;
381 awt::Point SAL_CALL ThumbnailViewAcc::getLocationOnScreen()
382 throw (uno::RuntimeException)
384 ThrowIfDisposed();
385 const SolarMutexGuard aSolarGuard;
386 const Point aScreenPos( mpParent->OutputToAbsoluteScreenPixel( Point() ) );
387 awt::Point aRet;
389 aRet.X = aScreenPos.X();
390 aRet.Y = aScreenPos.Y();
392 return aRet;
395 awt::Size SAL_CALL ThumbnailViewAcc::getSize()
396 throw (uno::RuntimeException)
398 ThrowIfDisposed();
399 const awt::Rectangle aRect( getBounds() );
400 awt::Size aRet;
402 aRet.Width = aRect.Width;
403 aRet.Height = aRect.Height;
405 return aRet;
408 void SAL_CALL ThumbnailViewAcc::grabFocus()
409 throw (uno::RuntimeException)
411 ThrowIfDisposed();
412 const SolarMutexGuard aSolarGuard;
413 mpParent->GrabFocus();
416 uno::Any SAL_CALL ThumbnailViewAcc::getAccessibleKeyBinding()
417 throw (uno::RuntimeException)
419 ThrowIfDisposed();
420 return uno::Any();
423 sal_Int32 SAL_CALL ThumbnailViewAcc::getForeground( )
424 throw (uno::RuntimeException)
426 ThrowIfDisposed();
427 sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
428 return static_cast<sal_Int32>(nColor);
431 sal_Int32 SAL_CALL ThumbnailViewAcc::getBackground( )
432 throw (uno::RuntimeException)
434 ThrowIfDisposed();
435 sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
436 return static_cast<sal_Int32>(nColor);
439 void SAL_CALL ThumbnailViewAcc::selectAccessibleChild( sal_Int32 nChildIndex )
440 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
442 ThrowIfDisposed();
443 const SolarMutexGuard aSolarGuard;
444 ThumbnailViewItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
446 if(pItem != NULL)
448 mpParent->SelectItem( pItem->mnId );
450 else
451 throw lang::IndexOutOfBoundsException();
454 sal_Bool SAL_CALL ThumbnailViewAcc::isAccessibleChildSelected( sal_Int32 nChildIndex )
455 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
457 ThrowIfDisposed();
458 const SolarMutexGuard aSolarGuard;
459 ThumbnailViewItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
460 sal_Bool bRet = sal_False;
462 if (pItem != NULL)
463 bRet = mpParent->IsItemSelected( pItem->mnId );
464 else
465 throw lang::IndexOutOfBoundsException();
467 return bRet;
470 void SAL_CALL ThumbnailViewAcc::clearAccessibleSelection()
471 throw (uno::RuntimeException)
473 ThrowIfDisposed();
474 const SolarMutexGuard aSolarGuard;
477 void SAL_CALL ThumbnailViewAcc::selectAllAccessibleChildren()
478 throw (uno::RuntimeException)
480 ThrowIfDisposed();
481 // unsupported due to single selection only
484 sal_Int32 SAL_CALL ThumbnailViewAcc::getSelectedAccessibleChildCount()
485 throw (uno::RuntimeException)
487 ThrowIfDisposed();
488 const SolarMutexGuard aSolarGuard;
489 sal_Int32 nRet = 0;
491 for( sal_uInt16 i = 0, nCount = getItemCount(); i < nCount; i++ )
493 ThumbnailViewItem* pItem = getItem (i);
495 if( pItem && mpParent->IsItemSelected( pItem->mnId ) )
496 ++nRet;
499 return nRet;
502 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewAcc::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
503 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
505 ThrowIfDisposed();
506 const SolarMutexGuard aSolarGuard;
507 uno::Reference< accessibility::XAccessible > xRet;
509 for( sal_uInt16 i = 0, nCount = getItemCount(), nSel = 0; ( i < nCount ) && !xRet.is(); i++ )
511 ThumbnailViewItem* pItem = getItem(i);
513 if( pItem && mpParent->IsItemSelected( pItem->mnId ) && ( nSelectedChildIndex == static_cast< sal_Int32 >( nSel++ ) ) )
514 xRet = pItem->GetAccessible( mbIsTransientChildrenDisabled );
517 return xRet;
520 void SAL_CALL ThumbnailViewAcc::deselectAccessibleChild( sal_Int32 nChildIndex )
521 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
523 ThrowIfDisposed();
524 const SolarMutexGuard aSolarGuard;
525 // Because of the single selection we can reset the whole selection when
526 // the specified child is currently selected.
527 //FIXME TODO if (isAccessibleChildSelected(nChildIndex))
528 //FIXME TODO ;
529 (void) nChildIndex;
532 sal_Int64 SAL_CALL ThumbnailViewAcc::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw( uno::RuntimeException )
534 sal_Int64 nRet;
536 if( ( rId.getLength() == 16 ) && ( 0 == memcmp( ThumbnailViewAcc::getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
537 nRet = reinterpret_cast< sal_Int64 >( this );
538 else
539 nRet = 0;
541 return nRet;
544 void SAL_CALL ThumbnailViewAcc::disposing (void)
546 ::std::vector<uno::Reference<accessibility::XAccessibleEventListener> > aListenerListCopy;
549 // Make a copy of the list and clear the original.
550 const SolarMutexGuard aSolarGuard;
551 ::osl::MutexGuard aGuard (m_aMutex);
552 aListenerListCopy = mxEventListeners;
553 mxEventListeners.clear();
555 // Reset the pointer to the parent. It has to be the one who has
556 // disposed us because he is dying.
557 mpParent = NULL;
560 // Inform all listeners that this objects is disposing.
561 ::std::vector<uno::Reference<accessibility::XAccessibleEventListener> >::const_iterator
562 aListenerIterator (aListenerListCopy.begin());
563 lang::EventObject aEvent (static_cast<accessibility::XAccessible*>(this));
564 while (aListenerIterator != aListenerListCopy.end())
568 (*aListenerIterator)->disposing (aEvent);
570 catch(const uno::Exception&)
572 // Ignore exceptions.
575 ++aListenerIterator;
579 sal_uInt16 ThumbnailViewAcc::getItemCount (void) const
581 return mpParent->ImplGetVisibleItemCount();
584 ThumbnailViewItem* ThumbnailViewAcc::getItem (sal_uInt16 nIndex) const
586 return mpParent->ImplGetVisibleItem (static_cast<sal_uInt16>(nIndex));
589 void ThumbnailViewAcc::ThrowIfDisposed (void)
590 throw (::com::sun::star::lang::DisposedException)
592 if (rBHelper.bDisposed || rBHelper.bInDispose)
594 OSL_TRACE ("Calling disposed object. Throwing exception:");
595 throw lang::DisposedException (
596 OUString("object has been already disposed"),
597 static_cast<uno::XWeak*>(this));
599 else
601 DBG_ASSERT (mpParent!=NULL, "ValueSetAcc not disposed but mpParent == NULL");
605 ThumbnailViewItemAcc::ThumbnailViewItemAcc( ThumbnailViewItem* pParent, bool bIsTransientChildrenDisabled ) :
606 mpParent( pParent ),
607 mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled )
611 ThumbnailViewItemAcc::~ThumbnailViewItemAcc()
615 void ThumbnailViewItemAcc::ParentDestroyed()
617 const ::osl::MutexGuard aGuard( maMutex );
618 mpParent = NULL;
621 namespace
623 class theValueItemAccUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theValueItemAccUnoTunnelId > {};
626 const uno::Sequence< sal_Int8 >& ThumbnailViewItemAcc::getUnoTunnelId()
628 return theValueItemAccUnoTunnelId::get().getSeq();
631 uno::Reference< accessibility::XAccessibleContext > SAL_CALL ThumbnailViewItemAcc::getAccessibleContext()
632 throw (uno::RuntimeException)
634 return this;
637 sal_Int32 SAL_CALL ThumbnailViewItemAcc::getAccessibleChildCount()
638 throw (uno::RuntimeException)
640 return 0;
643 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewItemAcc::getAccessibleChild( sal_Int32 )
644 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
646 throw lang::IndexOutOfBoundsException();
649 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewItemAcc::getAccessibleParent()
650 throw (uno::RuntimeException)
652 const SolarMutexGuard aSolarGuard;
653 uno::Reference< accessibility::XAccessible > xRet;
655 if( mpParent )
656 xRet = mpParent->mrParent.GetAccessible();
658 return xRet;
661 sal_Int32 SAL_CALL ThumbnailViewItemAcc::getAccessibleIndexInParent()
662 throw (uno::RuntimeException)
664 const SolarMutexGuard aSolarGuard;
665 // The index defaults to -1 to indicate the child does not belong to its
666 // parent.
667 sal_Int32 nIndexInParent = -1;
669 if( mpParent )
671 bool bDone = false;
673 sal_uInt16 nCount = mpParent->mrParent.ImplGetVisibleItemCount();
674 ThumbnailViewItem* pItem;
675 for (sal_uInt16 i=0; i<nCount && !bDone; i++)
677 // Guard the retrieval of the i-th child with a try/catch block
678 // just in case the number of children changes in the mean time.
681 pItem = mpParent->mrParent.ImplGetVisibleItem (i);
683 catch (const lang::IndexOutOfBoundsException&)
685 pItem = NULL;
688 // Do not create an accessible object for the test.
689 if (pItem != NULL && pItem->mpxAcc != NULL)
690 if (pItem->GetAccessible( mbIsTransientChildrenDisabled ).get() == this )
692 nIndexInParent = i;
693 bDone = true;
698 return nIndexInParent;
701 sal_Int16 SAL_CALL ThumbnailViewItemAcc::getAccessibleRole()
702 throw (uno::RuntimeException)
704 return accessibility::AccessibleRole::LIST_ITEM;
707 OUString SAL_CALL ThumbnailViewItemAcc::getAccessibleDescription()
708 throw (uno::RuntimeException)
710 return OUString();
713 OUString SAL_CALL ThumbnailViewItemAcc::getAccessibleName()
714 throw (uno::RuntimeException)
716 const SolarMutexGuard aSolarGuard;
717 OUString aRet;
719 if( mpParent )
721 aRet = mpParent->maTitle;
723 if( aRet.isEmpty() )
725 OUStringBuffer aBuffer("Item ");
726 aBuffer.append(static_cast<sal_Int32>(mpParent->mnId));
727 aRet = aBuffer.makeStringAndClear();
731 return aRet;
734 uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ThumbnailViewItemAcc::getAccessibleRelationSet()
735 throw (uno::RuntimeException)
737 return uno::Reference< accessibility::XAccessibleRelationSet >();
740 uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL ThumbnailViewItemAcc::getAccessibleStateSet()
741 throw (uno::RuntimeException)
743 const SolarMutexGuard aSolarGuard;
744 ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper;
746 if( mpParent )
748 pStateSet->AddState (accessibility::AccessibleStateType::ENABLED);
749 pStateSet->AddState (accessibility::AccessibleStateType::SENSITIVE);
750 pStateSet->AddState (accessibility::AccessibleStateType::SHOWING);
751 pStateSet->AddState (accessibility::AccessibleStateType::VISIBLE);
752 if ( !mbIsTransientChildrenDisabled )
753 pStateSet->AddState (accessibility::AccessibleStateType::TRANSIENT);
755 // SELECTABLE
756 pStateSet->AddState( accessibility::AccessibleStateType::SELECTABLE );
757 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE );
759 // SELECTED
760 if( mpParent->isSelected() )
762 pStateSet->AddState( accessibility::AccessibleStateType::SELECTED );
763 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSED );
767 return pStateSet;
770 lang::Locale SAL_CALL ThumbnailViewItemAcc::getLocale()
771 throw (accessibility::IllegalAccessibleComponentStateException, uno::RuntimeException)
773 const SolarMutexGuard aSolarGuard;
774 const OUString aEmptyStr;
775 uno::Reference< accessibility::XAccessible > xParent( getAccessibleParent() );
776 lang::Locale aRet( aEmptyStr, aEmptyStr, aEmptyStr );
778 if( xParent.is() )
780 uno::Reference< accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
782 if( xParentContext.is() )
783 aRet = xParentContext->getLocale();
786 return aRet;
789 void SAL_CALL ThumbnailViewItemAcc::addAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
790 throw (uno::RuntimeException)
792 const ::osl::MutexGuard aGuard( maMutex );
794 if( rxListener.is() )
796 ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter = mxEventListeners.begin();
797 sal_Bool bFound = sal_False;
799 while( !bFound && ( aIter != mxEventListeners.end() ) )
801 if( *aIter == rxListener )
802 bFound = sal_True;
803 else
804 ++aIter;
807 if (!bFound)
808 mxEventListeners.push_back( rxListener );
812 void SAL_CALL ThumbnailViewItemAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
813 throw (uno::RuntimeException)
815 const ::osl::MutexGuard aGuard( maMutex );
817 if( rxListener.is() )
819 std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::iterator aIter =
820 std::find(mxEventListeners.begin(), mxEventListeners.end(), rxListener);
822 if (aIter != mxEventListeners.end())
823 mxEventListeners.erase( aIter );
827 sal_Bool SAL_CALL ThumbnailViewItemAcc::containsPoint( const awt::Point& aPoint )
828 throw (uno::RuntimeException)
830 const awt::Rectangle aRect( getBounds() );
831 const Point aSize( aRect.Width, aRect.Height );
832 const Point aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
834 return Rectangle( aNullPoint, aSize ).IsInside( aTestPoint );
837 uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewItemAcc::getAccessibleAtPoint( const awt::Point& )
838 throw (uno::RuntimeException)
840 uno::Reference< accessibility::XAccessible > xRet;
841 return xRet;
844 awt::Rectangle SAL_CALL ThumbnailViewItemAcc::getBounds()
845 throw (uno::RuntimeException)
847 const SolarMutexGuard aSolarGuard;
848 awt::Rectangle aRet;
850 if( mpParent )
852 Rectangle aRect( mpParent->getDrawArea() );
853 Point aOrigin;
854 Rectangle aParentRect( aOrigin, mpParent->mrParent.GetOutputSizePixel() );
856 aRect.Intersection( aParentRect );
858 aRet.X = aRect.Left();
859 aRet.Y = aRect.Top();
860 aRet.Width = aRect.GetWidth();
861 aRet.Height = aRect.GetHeight();
864 return aRet;
867 awt::Point SAL_CALL ThumbnailViewItemAcc::getLocation()
868 throw (uno::RuntimeException)
870 const awt::Rectangle aRect( getBounds() );
871 awt::Point aRet;
873 aRet.X = aRect.X;
874 aRet.Y = aRect.Y;
876 return aRet;
879 awt::Point SAL_CALL ThumbnailViewItemAcc::getLocationOnScreen()
880 throw (uno::RuntimeException)
882 const SolarMutexGuard aSolarGuard;
883 awt::Point aRet;
885 if( mpParent )
887 const Point aPos = mpParent->getDrawArea().TopLeft();
888 const Point aScreenPos( mpParent->mrParent.OutputToAbsoluteScreenPixel( aPos ) );
890 aRet.X = aScreenPos.X();
891 aRet.Y = aScreenPos.Y();
894 return aRet;
897 awt::Size SAL_CALL ThumbnailViewItemAcc::getSize()
898 throw (uno::RuntimeException)
900 const awt::Rectangle aRect( getBounds() );
901 awt::Size aRet;
903 aRet.Width = aRect.Width;
904 aRet.Height = aRect.Height;
906 return aRet;
909 void SAL_CALL ThumbnailViewItemAcc::grabFocus()
910 throw (uno::RuntimeException)
912 // nothing to do
915 uno::Any SAL_CALL ThumbnailViewItemAcc::getAccessibleKeyBinding()
916 throw (uno::RuntimeException)
918 return uno::Any();
921 sal_Int32 SAL_CALL ThumbnailViewItemAcc::getForeground( )
922 throw (uno::RuntimeException)
924 sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
925 return static_cast<sal_Int32>(nColor);
928 sal_Int32 SAL_CALL ThumbnailViewItemAcc::getBackground( )
929 throw (uno::RuntimeException)
931 return static_cast<sal_Int32>(Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor());
934 sal_Int64 SAL_CALL ThumbnailViewItemAcc::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw( uno::RuntimeException )
936 sal_Int64 nRet;
938 if( ( rId.getLength() == 16 ) && ( 0 == memcmp( ThumbnailViewItemAcc::getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
939 nRet = reinterpret_cast< sal_Int64 >( this );
940 else
941 nRet = 0;
943 return nRet;
946 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */