1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <unotools/accessiblestatesethelper.hxx>
21 #include <vcl/svapp.hxx>
22 #include <svtools/valueset.hxx>
23 #include "valueimp.hxx"
24 #include <comphelper/servicehelper.hxx>
25 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
26 #include <com/sun/star/accessibility/AccessibleRole.hpp>
27 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
29 using namespace ::com::sun::star
;
35 ValueSetItem::ValueSetItem( ValueSet
& rParent
)
38 , meType(VALUESETITEM_NONE
)
45 // -----------------------------------------------------------------------
47 ValueSetItem::~ValueSetItem()
51 static_cast< ValueItemAcc
* >( mpxAcc
->get() )->ParentDestroyed();
56 // -----------------------------------------------------------------------
58 uno::Reference
< accessibility::XAccessible
> ValueSetItem::GetAccessible( bool bIsTransientChildrenDisabled
)
61 mpxAcc
= new uno::Reference
< accessibility::XAccessible
>( new ValueItemAcc( this, bIsTransientChildrenDisabled
) );
70 ValueSetAcc::ValueSetAcc( ValueSet
* pParent
, bool bIsTransientChildrenDisabled
) :
71 ValueSetAccComponentBase (m_aMutex
),
73 mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled
),
78 // -----------------------------------------------------------------------------
80 ValueSetAcc::~ValueSetAcc()
84 // -----------------------------------------------------------------------
86 void ValueSetAcc::FireAccessibleEvent( short nEventId
, const uno::Any
& rOldValue
, const uno::Any
& rNewValue
)
90 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> > aTmpListeners( mxEventListeners
);
91 accessibility::AccessibleEventObject aEvtObject
;
93 aEvtObject
.EventId
= nEventId
;
94 aEvtObject
.Source
= static_cast<uno::XWeak
*>(this);
95 aEvtObject
.NewValue
= rNewValue
;
96 aEvtObject
.OldValue
= rOldValue
;
98 for (::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator
aIter( aTmpListeners
.begin() );
99 aIter
!= aTmpListeners
.end() ; ++aIter
)
103 (*aIter
)->notifyEvent( aEvtObject
);
105 catch(const uno::Exception
&)
114 class theValueSetAccUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theValueSetAccUnoTunnelId
> {};
117 const uno::Sequence
< sal_Int8
>& ValueSetAcc::getUnoTunnelId()
119 return theValueSetAccUnoTunnelId::get().getSeq();
122 // -----------------------------------------------------------------------------
124 ValueSetAcc
* ValueSetAcc::getImplementation( const uno::Reference
< uno::XInterface
>& rxData
)
129 uno::Reference
< lang::XUnoTunnel
> xUnoTunnel( rxData
, uno::UNO_QUERY
);
130 return( xUnoTunnel
.is() ? reinterpret_cast<ValueSetAcc
*>(sal::static_int_cast
<sal_IntPtr
>(xUnoTunnel
->getSomething( ValueSetAcc::getUnoTunnelId() ))) : NULL
);
132 catch(const ::com::sun::star::uno::Exception
&)
139 // -----------------------------------------------------------------------------
141 void ValueSetAcc::GetFocus (void)
145 // Boradcast the state change.
146 ::com::sun::star::uno::Any aOldState
, aNewState
;
147 aNewState
<<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED
;
149 ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED
,
150 aOldState
, aNewState
);
153 // -----------------------------------------------------------------------------
155 void ValueSetAcc::LoseFocus (void)
159 // Boradcast the state change.
160 ::com::sun::star::uno::Any aOldState
, aNewState
;
161 aOldState
<<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED
;
163 ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED
,
164 aOldState
, aNewState
);
167 // -----------------------------------------------------------------------------
169 uno::Reference
< accessibility::XAccessibleContext
> SAL_CALL
ValueSetAcc::getAccessibleContext()
170 throw (uno::RuntimeException
)
176 // -----------------------------------------------------------------------------
178 sal_Int32 SAL_CALL
ValueSetAcc::getAccessibleChildCount()
179 throw (uno::RuntimeException
)
181 const SolarMutexGuard aSolarGuard
;
184 sal_Int32 nCount
= mpParent
->ImplGetVisibleItemCount();
190 // -----------------------------------------------------------------------------
192 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueSetAcc::getAccessibleChild( sal_Int32 i
)
193 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
196 const SolarMutexGuard aSolarGuard
;
197 uno::Reference
< accessibility::XAccessible
> xRet
;
198 ValueSetItem
* pItem
= getItem (sal::static_int_cast
< sal_uInt16
>(i
));
201 xRet
= pItem
->GetAccessible( mbIsTransientChildrenDisabled
);
203 throw lang::IndexOutOfBoundsException();
208 // -----------------------------------------------------------------------------
210 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueSetAcc::getAccessibleParent()
211 throw (uno::RuntimeException
)
214 const SolarMutexGuard aSolarGuard
;
215 Window
* pParent
= mpParent
->GetParent();
216 uno::Reference
< accessibility::XAccessible
> xRet
;
219 xRet
= pParent
->GetAccessible();
224 // -----------------------------------------------------------------------------
226 sal_Int32 SAL_CALL
ValueSetAcc::getAccessibleIndexInParent()
227 throw (uno::RuntimeException
)
230 const SolarMutexGuard aSolarGuard
;
231 Window
* pParent
= mpParent
->GetParent();
236 sal_Bool bFound
= sal_False
;
238 for( sal_uInt16 i
= 0, nCount
= pParent
->GetChildCount(); ( i
< nCount
) && !bFound
; i
++ )
240 if( pParent
->GetChild( i
) == mpParent
)
251 // -----------------------------------------------------------------------------
253 sal_Int16 SAL_CALL
ValueSetAcc::getAccessibleRole()
254 throw (uno::RuntimeException
)
257 // #i73746# As the Java Access Bridge (v 2.0.1) uses "managesDescendants"
258 // always if the role is LIST, we need a different role in this case
259 return (mbIsTransientChildrenDisabled
260 ? accessibility::AccessibleRole::PANEL
261 : accessibility::AccessibleRole::LIST
);
264 // -----------------------------------------------------------------------------
266 OUString SAL_CALL
ValueSetAcc::getAccessibleDescription()
267 throw (uno::RuntimeException
)
270 const SolarMutexGuard aSolarGuard
;
271 String
aRet( RTL_CONSTASCII_USTRINGPARAM( "ValueSet" ) );
276 // -----------------------------------------------------------------------------
278 OUString SAL_CALL
ValueSetAcc::getAccessibleName()
279 throw (uno::RuntimeException
)
282 const SolarMutexGuard aSolarGuard
;
286 aRet
= mpParent
->GetAccessibleName();
290 Window
* pLabel
= mpParent
->GetAccessibleRelationLabeledBy();
291 if ( pLabel
&& pLabel
!= mpParent
)
292 aRet
= OutputDevice::GetNonMnemonicString( pLabel
->GetText() );
298 // -----------------------------------------------------------------------------
300 uno::Reference
< accessibility::XAccessibleRelationSet
> SAL_CALL
ValueSetAcc::getAccessibleRelationSet()
301 throw (uno::RuntimeException
)
304 return uno::Reference
< accessibility::XAccessibleRelationSet
>();
307 // -----------------------------------------------------------------------------
309 uno::Reference
< accessibility::XAccessibleStateSet
> SAL_CALL
ValueSetAcc::getAccessibleStateSet()
310 throw (uno::RuntimeException
)
313 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper();
316 pStateSet
->AddState (accessibility::AccessibleStateType::ENABLED
);
317 pStateSet
->AddState (accessibility::AccessibleStateType::SENSITIVE
);
318 pStateSet
->AddState (accessibility::AccessibleStateType::SHOWING
);
319 pStateSet
->AddState (accessibility::AccessibleStateType::VISIBLE
);
320 if ( !mbIsTransientChildrenDisabled
)
321 pStateSet
->AddState (accessibility::AccessibleStateType::MANAGES_DESCENDANTS
);
322 pStateSet
->AddState (accessibility::AccessibleStateType::FOCUSABLE
);
324 pStateSet
->AddState (accessibility::AccessibleStateType::FOCUSED
);
329 // -----------------------------------------------------------------------------
331 lang::Locale SAL_CALL
ValueSetAcc::getLocale()
332 throw (accessibility::IllegalAccessibleComponentStateException
, uno::RuntimeException
)
335 const SolarMutexGuard aSolarGuard
;
336 const OUString aEmptyStr
;
337 uno::Reference
< accessibility::XAccessible
> xParent( getAccessibleParent() );
338 lang::Locale
aRet( aEmptyStr
, aEmptyStr
, aEmptyStr
);
342 uno::Reference
< accessibility::XAccessibleContext
> xParentContext( xParent
->getAccessibleContext() );
344 if( xParentContext
.is() )
345 aRet
= xParentContext
->getLocale ();
351 // -----------------------------------------------------------------------------
353 void SAL_CALL
ValueSetAcc::addAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
354 throw (uno::RuntimeException
)
357 ::osl::MutexGuard
aGuard (m_aMutex
);
359 if( rxListener
.is() )
361 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator aIter
= mxEventListeners
.begin();
362 sal_Bool bFound
= sal_False
;
364 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
366 if( *aIter
== rxListener
)
373 mxEventListeners
.push_back( rxListener
);
377 // -----------------------------------------------------------------------------
379 void SAL_CALL
ValueSetAcc::removeAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
380 throw (uno::RuntimeException
)
383 ::osl::MutexGuard
aGuard (m_aMutex
);
385 if( rxListener
.is() )
387 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::iterator aIter
= mxEventListeners
.begin();
388 sal_Bool bFound
= sal_False
;
390 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
392 if( *aIter
== rxListener
)
394 mxEventListeners
.erase( aIter
);
403 // -----------------------------------------------------------------------------
405 sal_Bool SAL_CALL
ValueSetAcc::containsPoint( const awt::Point
& aPoint
)
406 throw (uno::RuntimeException
)
409 const awt::Rectangle
aRect( getBounds() );
410 const Point
aSize( aRect
.Width
, aRect
.Height
);
411 const Point aNullPoint
, aTestPoint( aPoint
.X
, aPoint
.Y
);
413 return Rectangle( aNullPoint
, aSize
).IsInside( aTestPoint
);
416 // -----------------------------------------------------------------------------
418 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueSetAcc::getAccessibleAtPoint( const awt::Point
& aPoint
)
419 throw (uno::RuntimeException
)
422 const SolarMutexGuard aSolarGuard
;
423 const sal_uInt16 nItemId
= mpParent
->GetItemId( Point( aPoint
.X
, aPoint
.Y
) );
424 uno::Reference
< accessibility::XAccessible
> xRet
;
428 const size_t nItemPos
= mpParent
->GetItemPos( nItemId
);
430 if( VALUESET_ITEM_NONEITEM
!= nItemPos
)
432 ValueSetItem
*const pItem
= mpParent
->mItemList
[nItemPos
];
433 xRet
= pItem
->GetAccessible( mbIsTransientChildrenDisabled
);
440 // -----------------------------------------------------------------------------
442 awt::Rectangle SAL_CALL
ValueSetAcc::getBounds()
443 throw (uno::RuntimeException
)
446 const SolarMutexGuard aSolarGuard
;
447 const Point
aOutPos( mpParent
->GetPosPixel() );
448 const Size
aOutSize( mpParent
->GetOutputSizePixel() );
451 aRet
.X
= aOutPos
.X();
452 aRet
.Y
= aOutPos
.Y();
453 aRet
.Width
= aOutSize
.Width();
454 aRet
.Height
= aOutSize
.Height();
459 // -----------------------------------------------------------------------------
461 awt::Point SAL_CALL
ValueSetAcc::getLocation()
462 throw (uno::RuntimeException
)
465 const awt::Rectangle
aRect( getBounds() );
474 // -----------------------------------------------------------------------------
476 awt::Point SAL_CALL
ValueSetAcc::getLocationOnScreen()
477 throw (uno::RuntimeException
)
480 const SolarMutexGuard aSolarGuard
;
481 const Point
aScreenPos( mpParent
->OutputToAbsoluteScreenPixel( Point() ) );
484 aRet
.X
= aScreenPos
.X();
485 aRet
.Y
= aScreenPos
.Y();
490 // -----------------------------------------------------------------------------
492 awt::Size SAL_CALL
ValueSetAcc::getSize()
493 throw (uno::RuntimeException
)
496 const awt::Rectangle
aRect( getBounds() );
499 aRet
.Width
= aRect
.Width
;
500 aRet
.Height
= aRect
.Height
;
505 // -----------------------------------------------------------------------------
507 void SAL_CALL
ValueSetAcc::grabFocus()
508 throw (uno::RuntimeException
)
511 const SolarMutexGuard aSolarGuard
;
512 mpParent
->GrabFocus();
515 // -----------------------------------------------------------------------------
517 uno::Any SAL_CALL
ValueSetAcc::getAccessibleKeyBinding()
518 throw (uno::RuntimeException
)
524 // -----------------------------------------------------------------------------
526 sal_Int32 SAL_CALL
ValueSetAcc::getForeground( )
527 throw (uno::RuntimeException
)
530 sal_uInt32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
531 return static_cast<sal_Int32
>(nColor
);
534 // -----------------------------------------------------------------------------
536 sal_Int32 SAL_CALL
ValueSetAcc::getBackground( )
537 throw (uno::RuntimeException
)
540 sal_uInt32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
541 return static_cast<sal_Int32
>(nColor
);
544 // -----------------------------------------------------------------------------
546 void SAL_CALL
ValueSetAcc::selectAccessibleChild( sal_Int32 nChildIndex
)
547 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
550 const SolarMutexGuard aSolarGuard
;
551 ValueSetItem
* pItem
= getItem (sal::static_int_cast
< sal_uInt16
>(nChildIndex
));
555 mpParent
->SelectItem( pItem
->mnId
);
559 throw lang::IndexOutOfBoundsException();
562 // -----------------------------------------------------------------------------
564 sal_Bool SAL_CALL
ValueSetAcc::isAccessibleChildSelected( sal_Int32 nChildIndex
)
565 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
568 const SolarMutexGuard aSolarGuard
;
569 ValueSetItem
* pItem
= getItem (sal::static_int_cast
< sal_uInt16
>(nChildIndex
));
570 sal_Bool bRet
= sal_False
;
573 bRet
= mpParent
->IsItemSelected( pItem
->mnId
);
575 throw lang::IndexOutOfBoundsException();
580 // -----------------------------------------------------------------------------
582 void SAL_CALL
ValueSetAcc::clearAccessibleSelection()
583 throw (uno::RuntimeException
)
586 const SolarMutexGuard aSolarGuard
;
587 mpParent
->SetNoSelection();
590 // -----------------------------------------------------------------------------
592 void SAL_CALL
ValueSetAcc::selectAllAccessibleChildren()
593 throw (uno::RuntimeException
)
596 // unsupported due to single selection only
599 // -----------------------------------------------------------------------------
601 sal_Int32 SAL_CALL
ValueSetAcc::getSelectedAccessibleChildCount()
602 throw (uno::RuntimeException
)
605 const SolarMutexGuard aSolarGuard
;
608 for( sal_uInt16 i
= 0, nCount
= getItemCount(); i
< nCount
; i
++ )
610 ValueSetItem
* pItem
= getItem (i
);
612 if( pItem
&& mpParent
->IsItemSelected( pItem
->mnId
) )
619 // -----------------------------------------------------------------------------
621 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueSetAcc::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
)
622 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
625 const SolarMutexGuard aSolarGuard
;
626 uno::Reference
< accessibility::XAccessible
> xRet
;
628 for( sal_uInt16 i
= 0, nCount
= getItemCount(), nSel
= 0; ( i
< nCount
) && !xRet
.is(); i
++ )
630 ValueSetItem
* pItem
= getItem(i
);
632 if( pItem
&& mpParent
->IsItemSelected( pItem
->mnId
) && ( nSelectedChildIndex
== static_cast< sal_Int32
>( nSel
++ ) ) )
633 xRet
= pItem
->GetAccessible( mbIsTransientChildrenDisabled
);
639 // -----------------------------------------------------------------------------
641 void SAL_CALL
ValueSetAcc::deselectAccessibleChild( sal_Int32 nChildIndex
)
642 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
645 const SolarMutexGuard aSolarGuard
;
646 // Because of the single selection we can reset the whole selection when
647 // the specified child is currently selected.
648 if (isAccessibleChildSelected(nChildIndex
))
649 mpParent
->SetNoSelection();
652 // -----------------------------------------------------------------------------
654 sal_Int64 SAL_CALL
ValueSetAcc::getSomething( const uno::Sequence
< sal_Int8
>& rId
) throw( uno::RuntimeException
)
658 if( ( rId
.getLength() == 16 ) && ( 0 == memcmp( ValueSetAcc::getUnoTunnelId().getConstArray(), rId
.getConstArray(), 16 ) ) )
659 nRet
= reinterpret_cast< sal_Int64
>( this );
669 void SAL_CALL
ValueSetAcc::disposing (void)
671 ::std::vector
<uno::Reference
<accessibility::XAccessibleEventListener
> > aListenerListCopy
;
674 // Make a copy of the list and clear the original.
675 const SolarMutexGuard aSolarGuard
;
676 ::osl::MutexGuard
aGuard (m_aMutex
);
677 aListenerListCopy
= mxEventListeners
;
678 mxEventListeners
.clear();
680 // Reset the pointer to the parent. It has to be the one who has
681 // disposed us because he is dying.
685 // Inform all listeners that this objects is disposing.
686 ::std::vector
<uno::Reference
<accessibility::XAccessibleEventListener
> >::const_iterator
687 aListenerIterator (aListenerListCopy
.begin());
688 lang::EventObject
aEvent (static_cast<accessibility::XAccessible
*>(this));
689 while (aListenerIterator
!= aListenerListCopy
.end())
693 (*aListenerIterator
)->disposing (aEvent
);
695 catch(const uno::Exception
&)
697 // Ignore exceptions.
705 sal_uInt16
ValueSetAcc::getItemCount (void) const
707 sal_uInt16 nCount
= mpParent
->ImplGetVisibleItemCount();
708 // When the None-Item is visible then increase the number of items by
716 ValueSetItem
* ValueSetAcc::getItem (sal_uInt16 nIndex
) const
718 ValueSetItem
* pItem
= NULL
;
723 // When present the first item is the then always visible none field.
724 pItem
= mpParent
->ImplGetItem (VALUESET_ITEM_NONEITEM
);
726 // Shift down the index to compensate for the none field.
730 pItem
= mpParent
->ImplGetVisibleItem (static_cast<sal_uInt16
>(nIndex
));
738 void ValueSetAcc::ThrowIfDisposed (void)
739 throw (::com::sun::star::lang::DisposedException
)
741 if (rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
743 OSL_TRACE ("Calling disposed object. Throwing exception:");
744 throw lang::DisposedException (
745 OUString("object has been already disposed"),
746 static_cast<uno::XWeak
*>(this));
750 DBG_ASSERT (mpParent
!=NULL
, "ValueSetAcc not disposed but mpParent == NULL");
756 bool ValueSetAcc::HasNoneField (void) const
758 DBG_ASSERT (mpParent
!=NULL
, "ValueSetAcc::HasNoneField called with mpParent==NULL");
759 return ((mpParent
->GetStyle() & WB_NONEFIELD
) != 0);
769 ValueItemAcc::ValueItemAcc( ValueSetItem
* pParent
, bool bIsTransientChildrenDisabled
) :
771 mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled
)
775 // -----------------------------------------------------------------------------
777 ValueItemAcc::~ValueItemAcc()
781 // -----------------------------------------------------------------------
783 void ValueItemAcc::FireAccessibleEvent( short nEventId
, const uno::Any
& rOldValue
, const uno::Any
& rNewValue
)
787 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> > aTmpListeners( mxEventListeners
);
788 accessibility::AccessibleEventObject aEvtObject
;
790 aEvtObject
.EventId
= nEventId
;
791 aEvtObject
.Source
= static_cast<uno::XWeak
*>(this);
792 aEvtObject
.NewValue
= rNewValue
;
793 aEvtObject
.OldValue
= rOldValue
;
795 for (::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator
aIter( aTmpListeners
.begin() );
796 aIter
!= aTmpListeners
.end() ; ++aIter
)
798 (*aIter
)->notifyEvent( aEvtObject
);
803 // -----------------------------------------------------------------------------
805 void ValueItemAcc::ParentDestroyed()
807 const ::osl::MutexGuard
aGuard( maMutex
);
813 class theValueItemAccUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theValueItemAccUnoTunnelId
> {};
816 const uno::Sequence
< sal_Int8
>& ValueItemAcc::getUnoTunnelId()
818 return theValueItemAccUnoTunnelId::get().getSeq();
821 // -----------------------------------------------------------------------------
823 ValueItemAcc
* ValueItemAcc::getImplementation( const uno::Reference
< uno::XInterface
>& rxData
)
828 uno::Reference
< lang::XUnoTunnel
> xUnoTunnel( rxData
, uno::UNO_QUERY
);
829 return( xUnoTunnel
.is() ? reinterpret_cast<ValueItemAcc
*>(sal::static_int_cast
<sal_IntPtr
>(xUnoTunnel
->getSomething( ValueItemAcc::getUnoTunnelId() ))) : NULL
);
831 catch(const ::com::sun::star::uno::Exception
&)
837 // -----------------------------------------------------------------------------
839 uno::Reference
< accessibility::XAccessibleContext
> SAL_CALL
ValueItemAcc::getAccessibleContext()
840 throw (uno::RuntimeException
)
845 // -----------------------------------------------------------------------------
847 sal_Int32 SAL_CALL
ValueItemAcc::getAccessibleChildCount()
848 throw (uno::RuntimeException
)
853 // -----------------------------------------------------------------------------
855 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueItemAcc::getAccessibleChild( sal_Int32
)
856 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
858 throw lang::IndexOutOfBoundsException();
861 // -----------------------------------------------------------------------------
863 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueItemAcc::getAccessibleParent()
864 throw (uno::RuntimeException
)
866 const SolarMutexGuard aSolarGuard
;
867 uno::Reference
< accessibility::XAccessible
> xRet
;
870 xRet
= mpParent
->mrParent
.GetAccessible();
875 // -----------------------------------------------------------------------------
877 sal_Int32 SAL_CALL
ValueItemAcc::getAccessibleIndexInParent()
878 throw (uno::RuntimeException
)
880 const SolarMutexGuard aSolarGuard
;
881 // The index defaults to -1 to indicate the child does not belong to its
883 sal_Int32 nIndexInParent
= -1;
889 sal_uInt16 nCount
= mpParent
->mrParent
.ImplGetVisibleItemCount();
891 for (sal_uInt16 i
=0; i
<nCount
&& !bDone
; i
++)
893 // Guard the retrieval of the i-th child with a try/catch block
894 // just in case the number of children changes in the mean time.
897 pItem
= mpParent
->mrParent
.ImplGetVisibleItem (i
);
899 catch (const lang::IndexOutOfBoundsException
&)
904 // Do not create an accessible object for the test.
905 if (pItem
!= NULL
&& pItem
->mpxAcc
!= NULL
)
906 if (pItem
->GetAccessible( mbIsTransientChildrenDisabled
).get() == this )
914 return nIndexInParent
;
917 // -----------------------------------------------------------------------------
919 sal_Int16 SAL_CALL
ValueItemAcc::getAccessibleRole()
920 throw (uno::RuntimeException
)
922 return accessibility::AccessibleRole::LIST_ITEM
;
925 // -----------------------------------------------------------------------------
927 OUString SAL_CALL
ValueItemAcc::getAccessibleDescription()
928 throw (uno::RuntimeException
)
933 // -----------------------------------------------------------------------------
935 OUString SAL_CALL
ValueItemAcc::getAccessibleName()
936 throw (uno::RuntimeException
)
938 const SolarMutexGuard aSolarGuard
;
943 aRet
= mpParent
->maText
;
947 OUStringBuffer
aBuffer("Item ");
948 aBuffer
.append(static_cast<sal_Int32
>(mpParent
->mnId
));
949 aRet
= aBuffer
.makeStringAndClear();
956 // -----------------------------------------------------------------------------
958 uno::Reference
< accessibility::XAccessibleRelationSet
> SAL_CALL
ValueItemAcc::getAccessibleRelationSet()
959 throw (uno::RuntimeException
)
961 return uno::Reference
< accessibility::XAccessibleRelationSet
>();
964 // -----------------------------------------------------------------------------
966 uno::Reference
< accessibility::XAccessibleStateSet
> SAL_CALL
ValueItemAcc::getAccessibleStateSet()
967 throw (uno::RuntimeException
)
969 const SolarMutexGuard aSolarGuard
;
970 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper
;
974 pStateSet
->AddState (accessibility::AccessibleStateType::ENABLED
);
975 pStateSet
->AddState (accessibility::AccessibleStateType::SENSITIVE
);
976 pStateSet
->AddState (accessibility::AccessibleStateType::SHOWING
);
977 pStateSet
->AddState (accessibility::AccessibleStateType::VISIBLE
);
978 if ( !mbIsTransientChildrenDisabled
)
979 pStateSet
->AddState (accessibility::AccessibleStateType::TRANSIENT
);
982 pStateSet
->AddState( accessibility::AccessibleStateType::SELECTABLE
);
983 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE );
986 if( mpParent
->mrParent
.GetSelectItemId() == mpParent
->mnId
)
988 pStateSet
->AddState( accessibility::AccessibleStateType::SELECTED
);
989 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSED );
996 // -----------------------------------------------------------------------------
998 lang::Locale SAL_CALL
ValueItemAcc::getLocale()
999 throw (accessibility::IllegalAccessibleComponentStateException
, uno::RuntimeException
)
1001 const SolarMutexGuard aSolarGuard
;
1002 const OUString aEmptyStr
;
1003 uno::Reference
< accessibility::XAccessible
> xParent( getAccessibleParent() );
1004 lang::Locale
aRet( aEmptyStr
, aEmptyStr
, aEmptyStr
);
1008 uno::Reference
< accessibility::XAccessibleContext
> xParentContext( xParent
->getAccessibleContext() );
1010 if( xParentContext
.is() )
1011 aRet
= xParentContext
->getLocale();
1017 // -----------------------------------------------------------------------------
1019 void SAL_CALL
ValueItemAcc::addAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
1020 throw (uno::RuntimeException
)
1022 const ::osl::MutexGuard
aGuard( maMutex
);
1024 if( rxListener
.is() )
1026 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator aIter
= mxEventListeners
.begin();
1027 sal_Bool bFound
= sal_False
;
1029 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
1031 if( *aIter
== rxListener
)
1038 mxEventListeners
.push_back( rxListener
);
1042 // -----------------------------------------------------------------------------
1044 void SAL_CALL
ValueItemAcc::removeAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
1045 throw (uno::RuntimeException
)
1047 const ::osl::MutexGuard
aGuard( maMutex
);
1049 if( rxListener
.is() )
1051 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::iterator aIter
= mxEventListeners
.begin();
1052 sal_Bool bFound
= sal_False
;
1054 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
1056 if( *aIter
== rxListener
)
1058 mxEventListeners
.erase( aIter
);
1067 // -----------------------------------------------------------------------------
1069 sal_Bool SAL_CALL
ValueItemAcc::containsPoint( const awt::Point
& aPoint
)
1070 throw (uno::RuntimeException
)
1072 const awt::Rectangle
aRect( getBounds() );
1073 const Point
aSize( aRect
.Width
, aRect
.Height
);
1074 const Point aNullPoint
, aTestPoint( aPoint
.X
, aPoint
.Y
);
1076 return Rectangle( aNullPoint
, aSize
).IsInside( aTestPoint
);
1079 // -----------------------------------------------------------------------------
1081 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueItemAcc::getAccessibleAtPoint( const awt::Point
& )
1082 throw (uno::RuntimeException
)
1084 uno::Reference
< accessibility::XAccessible
> xRet
;
1088 // -----------------------------------------------------------------------------
1090 awt::Rectangle SAL_CALL
ValueItemAcc::getBounds()
1091 throw (uno::RuntimeException
)
1093 const SolarMutexGuard aSolarGuard
;
1094 awt::Rectangle aRet
;
1098 Rectangle
aRect( mpParent
->mrParent
.GetItemRect(mpParent
->mnId
) );
1100 Rectangle
aParentRect( aOrigin
, mpParent
->mrParent
.GetOutputSizePixel() );
1102 aRect
.Intersection( aParentRect
);
1104 aRet
.X
= aRect
.Left();
1105 aRet
.Y
= aRect
.Top();
1106 aRet
.Width
= aRect
.GetWidth();
1107 aRet
.Height
= aRect
.GetHeight();
1113 // -----------------------------------------------------------------------------
1115 awt::Point SAL_CALL
ValueItemAcc::getLocation()
1116 throw (uno::RuntimeException
)
1118 const awt::Rectangle
aRect( getBounds() );
1127 // -----------------------------------------------------------------------------
1129 awt::Point SAL_CALL
ValueItemAcc::getLocationOnScreen()
1130 throw (uno::RuntimeException
)
1132 const SolarMutexGuard aSolarGuard
;
1137 const Point aPos
= mpParent
->mrParent
.GetItemRect(mpParent
->mnId
).TopLeft();
1138 const Point
aScreenPos( mpParent
->mrParent
.OutputToAbsoluteScreenPixel( aPos
) );
1140 aRet
.X
= aScreenPos
.X();
1141 aRet
.Y
= aScreenPos
.Y();
1147 // -----------------------------------------------------------------------------
1149 awt::Size SAL_CALL
ValueItemAcc::getSize()
1150 throw (uno::RuntimeException
)
1152 const awt::Rectangle
aRect( getBounds() );
1155 aRet
.Width
= aRect
.Width
;
1156 aRet
.Height
= aRect
.Height
;
1161 // -----------------------------------------------------------------------------
1163 void SAL_CALL
ValueItemAcc::grabFocus()
1164 throw (uno::RuntimeException
)
1169 // -----------------------------------------------------------------------------
1171 uno::Any SAL_CALL
ValueItemAcc::getAccessibleKeyBinding()
1172 throw (uno::RuntimeException
)
1177 // -----------------------------------------------------------------------------
1179 sal_Int32 SAL_CALL
ValueItemAcc::getForeground( )
1180 throw (uno::RuntimeException
)
1182 sal_uInt32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
1183 return static_cast<sal_Int32
>(nColor
);
1186 // -----------------------------------------------------------------------------
1188 sal_Int32 SAL_CALL
ValueItemAcc::getBackground( )
1189 throw (uno::RuntimeException
)
1192 if (mpParent
&& mpParent
->meType
== VALUESETITEM_COLOR
)
1193 nColor
= mpParent
->maColor
.GetColor();
1195 nColor
= Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
1196 return static_cast<sal_Int32
>(nColor
);
1199 // -----------------------------------------------------------------------------
1201 sal_Int64 SAL_CALL
ValueItemAcc::getSomething( const uno::Sequence
< sal_Int8
>& rId
) throw( uno::RuntimeException
)
1205 if( ( rId
.getLength() == 16 ) && ( 0 == memcmp( ValueItemAcc::getUnoTunnelId().getConstArray(), rId
.getConstArray(), 16 ) ) )
1206 nRet
= reinterpret_cast< sal_Int64
>( this );
1213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */