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 OUString
aRet( "ValueSet" );
276 // -----------------------------------------------------------------------------
278 OUString SAL_CALL
ValueSetAcc::getAccessibleName()
279 throw (uno::RuntimeException
)
282 const SolarMutexGuard aSolarGuard
;
286 aRet
= mpParent
->GetAccessibleName();
288 if ( aRet
.isEmpty() )
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
=
388 std::find(mxEventListeners
.begin(), mxEventListeners
.end(), rxListener
);
390 if (aIter
!= mxEventListeners
.end())
391 mxEventListeners
.erase(aIter
);
395 // -----------------------------------------------------------------------------
397 sal_Bool SAL_CALL
ValueSetAcc::containsPoint( const awt::Point
& aPoint
)
398 throw (uno::RuntimeException
)
401 const awt::Rectangle
aRect( getBounds() );
402 const Point
aSize( aRect
.Width
, aRect
.Height
);
403 const Point aNullPoint
, aTestPoint( aPoint
.X
, aPoint
.Y
);
405 return Rectangle( aNullPoint
, aSize
).IsInside( aTestPoint
);
408 // -----------------------------------------------------------------------------
410 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueSetAcc::getAccessibleAtPoint( const awt::Point
& aPoint
)
411 throw (uno::RuntimeException
)
414 const SolarMutexGuard aSolarGuard
;
415 const sal_uInt16 nItemId
= mpParent
->GetItemId( Point( aPoint
.X
, aPoint
.Y
) );
416 uno::Reference
< accessibility::XAccessible
> xRet
;
420 const size_t nItemPos
= mpParent
->GetItemPos( nItemId
);
422 if( VALUESET_ITEM_NONEITEM
!= nItemPos
)
424 ValueSetItem
*const pItem
= mpParent
->mItemList
[nItemPos
];
425 xRet
= pItem
->GetAccessible( mbIsTransientChildrenDisabled
);
432 // -----------------------------------------------------------------------------
434 awt::Rectangle SAL_CALL
ValueSetAcc::getBounds()
435 throw (uno::RuntimeException
)
438 const SolarMutexGuard aSolarGuard
;
439 const Point
aOutPos( mpParent
->GetPosPixel() );
440 const Size
aOutSize( mpParent
->GetOutputSizePixel() );
443 aRet
.X
= aOutPos
.X();
444 aRet
.Y
= aOutPos
.Y();
445 aRet
.Width
= aOutSize
.Width();
446 aRet
.Height
= aOutSize
.Height();
451 // -----------------------------------------------------------------------------
453 awt::Point SAL_CALL
ValueSetAcc::getLocation()
454 throw (uno::RuntimeException
)
457 const awt::Rectangle
aRect( getBounds() );
466 // -----------------------------------------------------------------------------
468 awt::Point SAL_CALL
ValueSetAcc::getLocationOnScreen()
469 throw (uno::RuntimeException
)
472 const SolarMutexGuard aSolarGuard
;
473 const Point
aScreenPos( mpParent
->OutputToAbsoluteScreenPixel( Point() ) );
476 aRet
.X
= aScreenPos
.X();
477 aRet
.Y
= aScreenPos
.Y();
482 // -----------------------------------------------------------------------------
484 awt::Size SAL_CALL
ValueSetAcc::getSize()
485 throw (uno::RuntimeException
)
488 const awt::Rectangle
aRect( getBounds() );
491 aRet
.Width
= aRect
.Width
;
492 aRet
.Height
= aRect
.Height
;
497 // -----------------------------------------------------------------------------
499 void SAL_CALL
ValueSetAcc::grabFocus()
500 throw (uno::RuntimeException
)
503 const SolarMutexGuard aSolarGuard
;
504 mpParent
->GrabFocus();
507 // -----------------------------------------------------------------------------
509 uno::Any SAL_CALL
ValueSetAcc::getAccessibleKeyBinding()
510 throw (uno::RuntimeException
)
516 // -----------------------------------------------------------------------------
518 sal_Int32 SAL_CALL
ValueSetAcc::getForeground( )
519 throw (uno::RuntimeException
)
522 sal_uInt32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
523 return static_cast<sal_Int32
>(nColor
);
526 // -----------------------------------------------------------------------------
528 sal_Int32 SAL_CALL
ValueSetAcc::getBackground( )
529 throw (uno::RuntimeException
)
532 sal_uInt32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
533 return static_cast<sal_Int32
>(nColor
);
536 // -----------------------------------------------------------------------------
538 void SAL_CALL
ValueSetAcc::selectAccessibleChild( sal_Int32 nChildIndex
)
539 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
542 const SolarMutexGuard aSolarGuard
;
543 ValueSetItem
* pItem
= getItem (sal::static_int_cast
< sal_uInt16
>(nChildIndex
));
547 mpParent
->SelectItem( pItem
->mnId
);
551 throw lang::IndexOutOfBoundsException();
554 // -----------------------------------------------------------------------------
556 sal_Bool SAL_CALL
ValueSetAcc::isAccessibleChildSelected( sal_Int32 nChildIndex
)
557 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
560 const SolarMutexGuard aSolarGuard
;
561 ValueSetItem
* pItem
= getItem (sal::static_int_cast
< sal_uInt16
>(nChildIndex
));
562 sal_Bool bRet
= sal_False
;
565 bRet
= mpParent
->IsItemSelected( pItem
->mnId
);
567 throw lang::IndexOutOfBoundsException();
572 // -----------------------------------------------------------------------------
574 void SAL_CALL
ValueSetAcc::clearAccessibleSelection()
575 throw (uno::RuntimeException
)
578 const SolarMutexGuard aSolarGuard
;
579 mpParent
->SetNoSelection();
582 // -----------------------------------------------------------------------------
584 void SAL_CALL
ValueSetAcc::selectAllAccessibleChildren()
585 throw (uno::RuntimeException
)
588 // unsupported due to single selection only
591 // -----------------------------------------------------------------------------
593 sal_Int32 SAL_CALL
ValueSetAcc::getSelectedAccessibleChildCount()
594 throw (uno::RuntimeException
)
597 const SolarMutexGuard aSolarGuard
;
600 for( sal_uInt16 i
= 0, nCount
= getItemCount(); i
< nCount
; i
++ )
602 ValueSetItem
* pItem
= getItem (i
);
604 if( pItem
&& mpParent
->IsItemSelected( pItem
->mnId
) )
611 // -----------------------------------------------------------------------------
613 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueSetAcc::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
)
614 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
617 const SolarMutexGuard aSolarGuard
;
618 uno::Reference
< accessibility::XAccessible
> xRet
;
620 for( sal_uInt16 i
= 0, nCount
= getItemCount(), nSel
= 0; ( i
< nCount
) && !xRet
.is(); i
++ )
622 ValueSetItem
* pItem
= getItem(i
);
624 if( pItem
&& mpParent
->IsItemSelected( pItem
->mnId
) && ( nSelectedChildIndex
== static_cast< sal_Int32
>( nSel
++ ) ) )
625 xRet
= pItem
->GetAccessible( mbIsTransientChildrenDisabled
);
631 // -----------------------------------------------------------------------------
633 void SAL_CALL
ValueSetAcc::deselectAccessibleChild( sal_Int32 nChildIndex
)
634 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
637 const SolarMutexGuard aSolarGuard
;
638 // Because of the single selection we can reset the whole selection when
639 // the specified child is currently selected.
640 if (isAccessibleChildSelected(nChildIndex
))
641 mpParent
->SetNoSelection();
644 // -----------------------------------------------------------------------------
646 sal_Int64 SAL_CALL
ValueSetAcc::getSomething( const uno::Sequence
< sal_Int8
>& rId
) throw( uno::RuntimeException
)
650 if( ( rId
.getLength() == 16 ) && ( 0 == memcmp( ValueSetAcc::getUnoTunnelId().getConstArray(), rId
.getConstArray(), 16 ) ) )
651 nRet
= reinterpret_cast< sal_Int64
>( this );
661 void SAL_CALL
ValueSetAcc::disposing (void)
663 ::std::vector
<uno::Reference
<accessibility::XAccessibleEventListener
> > aListenerListCopy
;
666 // Make a copy of the list and clear the original.
667 const SolarMutexGuard aSolarGuard
;
668 ::osl::MutexGuard
aGuard (m_aMutex
);
669 aListenerListCopy
= mxEventListeners
;
670 mxEventListeners
.clear();
672 // Reset the pointer to the parent. It has to be the one who has
673 // disposed us because he is dying.
677 // Inform all listeners that this objects is disposing.
678 ::std::vector
<uno::Reference
<accessibility::XAccessibleEventListener
> >::const_iterator
679 aListenerIterator (aListenerListCopy
.begin());
680 lang::EventObject
aEvent (static_cast<accessibility::XAccessible
*>(this));
681 while (aListenerIterator
!= aListenerListCopy
.end())
685 (*aListenerIterator
)->disposing (aEvent
);
687 catch(const uno::Exception
&)
689 // Ignore exceptions.
697 sal_uInt16
ValueSetAcc::getItemCount (void) const
699 sal_uInt16 nCount
= mpParent
->ImplGetVisibleItemCount();
700 // When the None-Item is visible then increase the number of items by
708 ValueSetItem
* ValueSetAcc::getItem (sal_uInt16 nIndex
) const
710 ValueSetItem
* pItem
= NULL
;
715 // When present the first item is the then always visible none field.
716 pItem
= mpParent
->ImplGetItem (VALUESET_ITEM_NONEITEM
);
718 // Shift down the index to compensate for the none field.
722 pItem
= mpParent
->ImplGetVisibleItem (static_cast<sal_uInt16
>(nIndex
));
730 void ValueSetAcc::ThrowIfDisposed (void)
731 throw (::com::sun::star::lang::DisposedException
)
733 if (rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
735 OSL_TRACE ("Calling disposed object. Throwing exception:");
736 throw lang::DisposedException (
737 OUString("object has been already disposed"),
738 static_cast<uno::XWeak
*>(this));
742 DBG_ASSERT (mpParent
!=NULL
, "ValueSetAcc not disposed but mpParent == NULL");
748 bool ValueSetAcc::HasNoneField (void) const
750 DBG_ASSERT (mpParent
!=NULL
, "ValueSetAcc::HasNoneField called with mpParent==NULL");
751 return ((mpParent
->GetStyle() & WB_NONEFIELD
) != 0);
761 ValueItemAcc::ValueItemAcc( ValueSetItem
* pParent
, bool bIsTransientChildrenDisabled
) :
763 mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled
)
767 // -----------------------------------------------------------------------------
769 ValueItemAcc::~ValueItemAcc()
773 // -----------------------------------------------------------------------
775 void ValueItemAcc::FireAccessibleEvent( short nEventId
, const uno::Any
& rOldValue
, const uno::Any
& rNewValue
)
779 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> > aTmpListeners( mxEventListeners
);
780 accessibility::AccessibleEventObject aEvtObject
;
782 aEvtObject
.EventId
= nEventId
;
783 aEvtObject
.Source
= static_cast<uno::XWeak
*>(this);
784 aEvtObject
.NewValue
= rNewValue
;
785 aEvtObject
.OldValue
= rOldValue
;
787 for (::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator
aIter( aTmpListeners
.begin() );
788 aIter
!= aTmpListeners
.end() ; ++aIter
)
790 (*aIter
)->notifyEvent( aEvtObject
);
795 // -----------------------------------------------------------------------------
797 void ValueItemAcc::ParentDestroyed()
799 const ::osl::MutexGuard
aGuard( maMutex
);
805 class theValueItemAccUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theValueItemAccUnoTunnelId
> {};
808 const uno::Sequence
< sal_Int8
>& ValueItemAcc::getUnoTunnelId()
810 return theValueItemAccUnoTunnelId::get().getSeq();
813 // -----------------------------------------------------------------------------
815 ValueItemAcc
* ValueItemAcc::getImplementation( const uno::Reference
< uno::XInterface
>& rxData
)
820 uno::Reference
< lang::XUnoTunnel
> xUnoTunnel( rxData
, uno::UNO_QUERY
);
821 return( xUnoTunnel
.is() ? reinterpret_cast<ValueItemAcc
*>(sal::static_int_cast
<sal_IntPtr
>(xUnoTunnel
->getSomething( ValueItemAcc::getUnoTunnelId() ))) : NULL
);
823 catch(const ::com::sun::star::uno::Exception
&)
829 // -----------------------------------------------------------------------------
831 uno::Reference
< accessibility::XAccessibleContext
> SAL_CALL
ValueItemAcc::getAccessibleContext()
832 throw (uno::RuntimeException
)
837 // -----------------------------------------------------------------------------
839 sal_Int32 SAL_CALL
ValueItemAcc::getAccessibleChildCount()
840 throw (uno::RuntimeException
)
845 // -----------------------------------------------------------------------------
847 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueItemAcc::getAccessibleChild( sal_Int32
)
848 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
850 throw lang::IndexOutOfBoundsException();
853 // -----------------------------------------------------------------------------
855 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueItemAcc::getAccessibleParent()
856 throw (uno::RuntimeException
)
858 const SolarMutexGuard aSolarGuard
;
859 uno::Reference
< accessibility::XAccessible
> xRet
;
862 xRet
= mpParent
->mrParent
.GetAccessible();
867 // -----------------------------------------------------------------------------
869 sal_Int32 SAL_CALL
ValueItemAcc::getAccessibleIndexInParent()
870 throw (uno::RuntimeException
)
872 const SolarMutexGuard aSolarGuard
;
873 // The index defaults to -1 to indicate the child does not belong to its
875 sal_Int32 nIndexInParent
= -1;
881 sal_uInt16 nCount
= mpParent
->mrParent
.ImplGetVisibleItemCount();
883 for (sal_uInt16 i
=0; i
<nCount
&& !bDone
; i
++)
885 // Guard the retrieval of the i-th child with a try/catch block
886 // just in case the number of children changes in the mean time.
889 pItem
= mpParent
->mrParent
.ImplGetVisibleItem (i
);
891 catch (const lang::IndexOutOfBoundsException
&)
896 // Do not create an accessible object for the test.
897 if (pItem
!= NULL
&& pItem
->mpxAcc
!= NULL
)
898 if (pItem
->GetAccessible( mbIsTransientChildrenDisabled
).get() == this )
906 return nIndexInParent
;
909 // -----------------------------------------------------------------------------
911 sal_Int16 SAL_CALL
ValueItemAcc::getAccessibleRole()
912 throw (uno::RuntimeException
)
914 return accessibility::AccessibleRole::LIST_ITEM
;
917 // -----------------------------------------------------------------------------
919 OUString SAL_CALL
ValueItemAcc::getAccessibleDescription()
920 throw (uno::RuntimeException
)
925 // -----------------------------------------------------------------------------
927 OUString SAL_CALL
ValueItemAcc::getAccessibleName()
928 throw (uno::RuntimeException
)
930 const SolarMutexGuard aSolarGuard
;
935 aRet
= mpParent
->maText
;
939 OUStringBuffer
aBuffer("Item ");
940 aBuffer
.append(static_cast<sal_Int32
>(mpParent
->mnId
));
941 aRet
= aBuffer
.makeStringAndClear();
948 // -----------------------------------------------------------------------------
950 uno::Reference
< accessibility::XAccessibleRelationSet
> SAL_CALL
ValueItemAcc::getAccessibleRelationSet()
951 throw (uno::RuntimeException
)
953 return uno::Reference
< accessibility::XAccessibleRelationSet
>();
956 // -----------------------------------------------------------------------------
958 uno::Reference
< accessibility::XAccessibleStateSet
> SAL_CALL
ValueItemAcc::getAccessibleStateSet()
959 throw (uno::RuntimeException
)
961 const SolarMutexGuard aSolarGuard
;
962 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper
;
966 pStateSet
->AddState (accessibility::AccessibleStateType::ENABLED
);
967 pStateSet
->AddState (accessibility::AccessibleStateType::SENSITIVE
);
968 pStateSet
->AddState (accessibility::AccessibleStateType::SHOWING
);
969 pStateSet
->AddState (accessibility::AccessibleStateType::VISIBLE
);
970 if ( !mbIsTransientChildrenDisabled
)
971 pStateSet
->AddState (accessibility::AccessibleStateType::TRANSIENT
);
974 pStateSet
->AddState( accessibility::AccessibleStateType::SELECTABLE
);
975 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE );
978 if( mpParent
->mrParent
.GetSelectItemId() == mpParent
->mnId
)
980 pStateSet
->AddState( accessibility::AccessibleStateType::SELECTED
);
981 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSED );
988 // -----------------------------------------------------------------------------
990 lang::Locale SAL_CALL
ValueItemAcc::getLocale()
991 throw (accessibility::IllegalAccessibleComponentStateException
, uno::RuntimeException
)
993 const SolarMutexGuard aSolarGuard
;
994 const OUString aEmptyStr
;
995 uno::Reference
< accessibility::XAccessible
> xParent( getAccessibleParent() );
996 lang::Locale
aRet( aEmptyStr
, aEmptyStr
, aEmptyStr
);
1000 uno::Reference
< accessibility::XAccessibleContext
> xParentContext( xParent
->getAccessibleContext() );
1002 if( xParentContext
.is() )
1003 aRet
= xParentContext
->getLocale();
1009 // -----------------------------------------------------------------------------
1011 void SAL_CALL
ValueItemAcc::addAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
1012 throw (uno::RuntimeException
)
1014 const ::osl::MutexGuard
aGuard( maMutex
);
1016 if( rxListener
.is() )
1018 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator aIter
= mxEventListeners
.begin();
1019 sal_Bool bFound
= sal_False
;
1021 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
1023 if( *aIter
== rxListener
)
1030 mxEventListeners
.push_back( rxListener
);
1034 // -----------------------------------------------------------------------------
1036 void SAL_CALL
ValueItemAcc::removeAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
1037 throw (uno::RuntimeException
)
1039 const ::osl::MutexGuard
aGuard( maMutex
);
1041 if( rxListener
.is() )
1043 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::iterator aIter
=
1044 std::find(mxEventListeners
.begin(), mxEventListeners
.end(), rxListener
);
1046 if (aIter
!= mxEventListeners
.end())
1047 mxEventListeners
.erase(aIter
);
1051 // -----------------------------------------------------------------------------
1053 sal_Bool SAL_CALL
ValueItemAcc::containsPoint( const awt::Point
& aPoint
)
1054 throw (uno::RuntimeException
)
1056 const awt::Rectangle
aRect( getBounds() );
1057 const Point
aSize( aRect
.Width
, aRect
.Height
);
1058 const Point aNullPoint
, aTestPoint( aPoint
.X
, aPoint
.Y
);
1060 return Rectangle( aNullPoint
, aSize
).IsInside( aTestPoint
);
1063 // -----------------------------------------------------------------------------
1065 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueItemAcc::getAccessibleAtPoint( const awt::Point
& )
1066 throw (uno::RuntimeException
)
1068 uno::Reference
< accessibility::XAccessible
> xRet
;
1072 // -----------------------------------------------------------------------------
1074 awt::Rectangle SAL_CALL
ValueItemAcc::getBounds()
1075 throw (uno::RuntimeException
)
1077 const SolarMutexGuard aSolarGuard
;
1078 awt::Rectangle aRet
;
1082 Rectangle
aRect( mpParent
->mrParent
.GetItemRect(mpParent
->mnId
) );
1084 Rectangle
aParentRect( aOrigin
, mpParent
->mrParent
.GetOutputSizePixel() );
1086 aRect
.Intersection( aParentRect
);
1088 aRet
.X
= aRect
.Left();
1089 aRet
.Y
= aRect
.Top();
1090 aRet
.Width
= aRect
.GetWidth();
1091 aRet
.Height
= aRect
.GetHeight();
1097 // -----------------------------------------------------------------------------
1099 awt::Point SAL_CALL
ValueItemAcc::getLocation()
1100 throw (uno::RuntimeException
)
1102 const awt::Rectangle
aRect( getBounds() );
1111 // -----------------------------------------------------------------------------
1113 awt::Point SAL_CALL
ValueItemAcc::getLocationOnScreen()
1114 throw (uno::RuntimeException
)
1116 const SolarMutexGuard aSolarGuard
;
1121 const Point aPos
= mpParent
->mrParent
.GetItemRect(mpParent
->mnId
).TopLeft();
1122 const Point
aScreenPos( mpParent
->mrParent
.OutputToAbsoluteScreenPixel( aPos
) );
1124 aRet
.X
= aScreenPos
.X();
1125 aRet
.Y
= aScreenPos
.Y();
1131 // -----------------------------------------------------------------------------
1133 awt::Size SAL_CALL
ValueItemAcc::getSize()
1134 throw (uno::RuntimeException
)
1136 const awt::Rectangle
aRect( getBounds() );
1139 aRet
.Width
= aRect
.Width
;
1140 aRet
.Height
= aRect
.Height
;
1145 // -----------------------------------------------------------------------------
1147 void SAL_CALL
ValueItemAcc::grabFocus()
1148 throw (uno::RuntimeException
)
1153 // -----------------------------------------------------------------------------
1155 uno::Any SAL_CALL
ValueItemAcc::getAccessibleKeyBinding()
1156 throw (uno::RuntimeException
)
1161 // -----------------------------------------------------------------------------
1163 sal_Int32 SAL_CALL
ValueItemAcc::getForeground( )
1164 throw (uno::RuntimeException
)
1166 sal_uInt32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
1167 return static_cast<sal_Int32
>(nColor
);
1170 // -----------------------------------------------------------------------------
1172 sal_Int32 SAL_CALL
ValueItemAcc::getBackground( )
1173 throw (uno::RuntimeException
)
1176 if (mpParent
&& mpParent
->meType
== VALUESETITEM_COLOR
)
1177 nColor
= mpParent
->maColor
.GetColor();
1179 nColor
= Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
1180 return static_cast<sal_Int32
>(nColor
);
1183 // -----------------------------------------------------------------------------
1185 sal_Int64 SAL_CALL
ValueItemAcc::getSomething( const uno::Sequence
< sal_Int8
>& rId
) throw( uno::RuntimeException
)
1189 if( ( rId
.getLength() == 16 ) && ( 0 == memcmp( ValueItemAcc::getUnoTunnelId().getConstArray(), rId
.getConstArray(), 16 ) ) )
1190 nRet
= reinterpret_cast< sal_Int64
>( this );
1197 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */