1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: valueacc.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 #define _SV_VALUESET_CXX
36 #include <unotools/accessiblestatesethelper.hxx>
37 #include <vcl/svapp.hxx>
38 #include <svtools/valueset.hxx>
39 #include "valueimp.hxx"
40 #include <com/sun/star/accessibility/AccessibleRole.hpp>
41 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
43 using namespace ::com::sun::star
;
49 ValueSetItem::ValueSetItem( ValueSet
& rParent
) :
58 // -----------------------------------------------------------------------
60 ValueSetItem::~ValueSetItem()
64 static_cast< ValueItemAcc
* >( mpxAcc
->get() )->ParentDestroyed();
69 // -----------------------------------------------------------------------
71 uno::Reference
< accessibility::XAccessible
> ValueSetItem::GetAccessible( bool bIsTransientChildrenDisabled
)
74 mpxAcc
= new uno::Reference
< accessibility::XAccessible
>( new ValueItemAcc( this, bIsTransientChildrenDisabled
) );
79 // -----------------------------------------------------------------------
81 void ValueSetItem::ClearAccessible()
84 delete mpxAcc
, mpxAcc
= NULL
;
92 ValueSetAcc::ValueSetAcc( ValueSet
* pParent
, bool bIsTransientChildrenDisabled
) :
93 ValueSetAccComponentBase (m_aMutex
),
95 mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled
)
99 // -----------------------------------------------------------------------------
101 ValueSetAcc::~ValueSetAcc()
105 // -----------------------------------------------------------------------
107 void ValueSetAcc::FireAccessibleEvent( short nEventId
, const uno::Any
& rOldValue
, const uno::Any
& rNewValue
)
111 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> > aTmpListeners( mxEventListeners
);
112 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator
aIter( aTmpListeners
.begin() );
113 accessibility::AccessibleEventObject aEvtObject
;
115 aEvtObject
.EventId
= nEventId
;
116 aEvtObject
.Source
= static_cast<uno::XWeak
*>(this);
117 aEvtObject
.NewValue
= rNewValue
;
118 aEvtObject
.OldValue
= rOldValue
;
120 while( aIter
!= aTmpListeners
.end() )
124 (*aIter
)->notifyEvent( aEvtObject
);
126 catch( uno::Exception
& )
135 // -----------------------------------------------------------------------------
137 const uno::Sequence
< sal_Int8
>& ValueSetAcc::getUnoTunnelId()
139 static uno::Sequence
< sal_Int8
> aSeq
;
141 if( !aSeq
.getLength() )
143 static osl::Mutex aCreateMutex
;
144 osl::Guard
< osl::Mutex
> aGuard( aCreateMutex
);
147 rtl_createUuid( reinterpret_cast< sal_uInt8
* >( aSeq
.getArray() ), 0, sal_True
);
153 // -----------------------------------------------------------------------------
155 ValueSetAcc
* ValueSetAcc::getImplementation( const uno::Reference
< uno::XInterface
>& rxData
)
160 uno::Reference
< lang::XUnoTunnel
> xUnoTunnel( rxData
, uno::UNO_QUERY
);
161 return( xUnoTunnel
.is() ? reinterpret_cast<ValueSetAcc
*>(sal::static_int_cast
<sal_IntPtr
>(xUnoTunnel
->getSomething( ValueSetAcc::getUnoTunnelId() ))) : NULL
);
163 catch( const ::com::sun::star::uno::Exception
& )
169 // -----------------------------------------------------------------------------
171 uno::Reference
< accessibility::XAccessibleContext
> SAL_CALL
ValueSetAcc::getAccessibleContext()
172 throw (uno::RuntimeException
)
178 // -----------------------------------------------------------------------------
180 sal_Int32 SAL_CALL
ValueSetAcc::getAccessibleChildCount()
181 throw (uno::RuntimeException
)
183 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
186 sal_Int32 nCount
= mpParent
->ImplGetVisibleItemCount();
192 // -----------------------------------------------------------------------------
194 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueSetAcc::getAccessibleChild( sal_Int32 i
)
195 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
198 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
199 uno::Reference
< accessibility::XAccessible
> xRet
;
200 ValueSetItem
* pItem
= getItem (sal::static_int_cast
< USHORT
>(i
));
203 xRet
= pItem
->GetAccessible( mbIsTransientChildrenDisabled
);
205 throw lang::IndexOutOfBoundsException();
210 // -----------------------------------------------------------------------------
212 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueSetAcc::getAccessibleParent()
213 throw (uno::RuntimeException
)
216 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
217 Window
* pParent
= mpParent
->GetParent();
218 uno::Reference
< accessibility::XAccessible
> xRet
;
221 xRet
= pParent
->GetAccessible();
226 // -----------------------------------------------------------------------------
228 sal_Int32 SAL_CALL
ValueSetAcc::getAccessibleIndexInParent()
229 throw (uno::RuntimeException
)
232 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
233 Window
* pParent
= mpParent
->GetParent();
238 sal_Bool bFound
= sal_False
;
240 for( USHORT i
= 0, nCount
= pParent
->GetChildCount(); ( i
< nCount
) && !bFound
; i
++ )
242 if( pParent
->GetChild( i
) == mpParent
)
253 // -----------------------------------------------------------------------------
255 sal_Int16 SAL_CALL
ValueSetAcc::getAccessibleRole()
256 throw (uno::RuntimeException
)
259 // #i73746# As the Java Access Bridge (v 2.0.1) uses "managesDescendants"
260 // always if the role is LIST, we need a different role in this case
261 return (mbIsTransientChildrenDisabled
262 ? accessibility::AccessibleRole::PANEL
263 : accessibility::AccessibleRole::LIST
);
266 // -----------------------------------------------------------------------------
268 ::rtl::OUString SAL_CALL
ValueSetAcc::getAccessibleDescription()
269 throw (uno::RuntimeException
)
272 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
273 String
aRet( RTL_CONSTASCII_USTRINGPARAM( "ValueSet" ) );
278 // -----------------------------------------------------------------------------
280 ::rtl::OUString SAL_CALL
ValueSetAcc::getAccessibleName()
281 throw (uno::RuntimeException
)
284 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
288 aRet
= mpParent
->GetAccessibleName();
292 Window
* pLabel
= mpParent
->GetLabeledBy();
293 if ( pLabel
&& pLabel
!= mpParent
)
294 aRet
= OutputDevice::GetNonMnemonicString( pLabel
->GetText() );
300 // -----------------------------------------------------------------------------
302 uno::Reference
< accessibility::XAccessibleRelationSet
> SAL_CALL
ValueSetAcc::getAccessibleRelationSet()
303 throw (uno::RuntimeException
)
306 return uno::Reference
< accessibility::XAccessibleRelationSet
>();
309 // -----------------------------------------------------------------------------
311 uno::Reference
< accessibility::XAccessibleStateSet
> SAL_CALL
ValueSetAcc::getAccessibleStateSet()
312 throw (uno::RuntimeException
)
315 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper();
318 pStateSet
->AddState (accessibility::AccessibleStateType::ENABLED
);
319 pStateSet
->AddState (accessibility::AccessibleStateType::SENSITIVE
);
320 pStateSet
->AddState (accessibility::AccessibleStateType::SHOWING
);
321 pStateSet
->AddState (accessibility::AccessibleStateType::VISIBLE
);
322 if ( !mbIsTransientChildrenDisabled
)
323 pStateSet
->AddState (accessibility::AccessibleStateType::MANAGES_DESCENDANTS
);
328 // -----------------------------------------------------------------------------
330 lang::Locale SAL_CALL
ValueSetAcc::getLocale()
331 throw (accessibility::IllegalAccessibleComponentStateException
, uno::RuntimeException
)
334 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
335 const ::rtl::OUString aEmptyStr
;
336 uno::Reference
< accessibility::XAccessible
> xParent( getAccessibleParent() );
337 lang::Locale
aRet( aEmptyStr
, aEmptyStr
, aEmptyStr
);
341 uno::Reference
< accessibility::XAccessibleContext
> xParentContext( xParent
->getAccessibleContext() );
343 if( xParentContext
.is() )
344 aRet
= xParentContext
->getLocale ();
350 // -----------------------------------------------------------------------------
352 void SAL_CALL
ValueSetAcc::addEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
353 throw (uno::RuntimeException
)
356 ::osl::MutexGuard
aGuard (m_aMutex
);
358 if( rxListener
.is() )
360 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator aIter
= mxEventListeners
.begin();
361 sal_Bool bFound
= sal_False
;
363 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
365 if( *aIter
== rxListener
)
372 mxEventListeners
.push_back( rxListener
);
376 // -----------------------------------------------------------------------------
378 void SAL_CALL
ValueSetAcc::removeEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
379 throw (uno::RuntimeException
)
382 ::osl::MutexGuard
aGuard (m_aMutex
);
384 if( rxListener
.is() )
386 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::iterator aIter
= mxEventListeners
.begin();
387 sal_Bool bFound
= sal_False
;
389 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
391 if( *aIter
== rxListener
)
393 mxEventListeners
.erase( aIter
);
402 // -----------------------------------------------------------------------------
404 sal_Bool SAL_CALL
ValueSetAcc::containsPoint( const awt::Point
& aPoint
)
405 throw (uno::RuntimeException
)
408 const awt::Rectangle
aRect( getBounds() );
409 const Point
aSize( aRect
.Width
, aRect
.Height
);
410 const Point aNullPoint
, aTestPoint( aPoint
.X
, aPoint
.Y
);
412 return Rectangle( aNullPoint
, aSize
).IsInside( aTestPoint
);
415 // -----------------------------------------------------------------------------
417 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueSetAcc::getAccessibleAtPoint( const awt::Point
& aPoint
)
418 throw (uno::RuntimeException
)
421 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
422 const USHORT nItemId
= mpParent
->GetItemId( Point( aPoint
.X
, aPoint
.Y
) );
423 uno::Reference
< accessibility::XAccessible
> xRet
;
425 if( VALUESET_ITEM_NOTFOUND
!= nItemId
)
427 const USHORT nItemPos
= mpParent
->GetItemPos( nItemId
);
429 if( VALUESET_ITEM_NONEITEM
!= nItemPos
)
431 ValueSetItem
* pItem
= mpParent
->mpImpl
->mpItemList
->GetObject( nItemPos
);
433 if( ( pItem
->meType
!= VALUESETITEM_SPACE
) && !pItem
->maRect
.IsEmpty() )
434 xRet
= pItem
->GetAccessible( mbIsTransientChildrenDisabled
);
441 // -----------------------------------------------------------------------------
443 awt::Rectangle SAL_CALL
ValueSetAcc::getBounds()
444 throw (uno::RuntimeException
)
447 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
448 const Point
aOutPos( mpParent
->GetPosPixel() );
449 const Size
aOutSize( mpParent
->GetOutputSizePixel() );
452 aRet
.X
= aOutPos
.X();
453 aRet
.Y
= aOutPos
.Y();
454 aRet
.Width
= aOutSize
.Width();
455 aRet
.Height
= aOutSize
.Height();
460 // -----------------------------------------------------------------------------
462 awt::Point SAL_CALL
ValueSetAcc::getLocation()
463 throw (uno::RuntimeException
)
466 const awt::Rectangle
aRect( getBounds() );
475 // -----------------------------------------------------------------------------
477 awt::Point SAL_CALL
ValueSetAcc::getLocationOnScreen()
478 throw (uno::RuntimeException
)
481 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
482 const Point
aScreenPos( mpParent
->OutputToAbsoluteScreenPixel( Point() ) );
485 aRet
.X
= aScreenPos
.X();
486 aRet
.Y
= aScreenPos
.Y();
491 // -----------------------------------------------------------------------------
493 awt::Size SAL_CALL
ValueSetAcc::getSize()
494 throw (uno::RuntimeException
)
497 const awt::Rectangle
aRect( getBounds() );
500 aRet
.Width
= aRect
.Width
;
501 aRet
.Height
= aRect
.Height
;
506 // -----------------------------------------------------------------------------
508 void SAL_CALL
ValueSetAcc::grabFocus()
509 throw (uno::RuntimeException
)
512 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
513 mpParent
->GrabFocus();
516 // -----------------------------------------------------------------------------
518 uno::Any SAL_CALL
ValueSetAcc::getAccessibleKeyBinding()
519 throw (uno::RuntimeException
)
525 // -----------------------------------------------------------------------------
527 sal_Int32 SAL_CALL
ValueSetAcc::getForeground( )
528 throw (uno::RuntimeException
)
531 UINT32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
532 return static_cast<sal_Int32
>(nColor
);
535 // -----------------------------------------------------------------------------
537 sal_Int32 SAL_CALL
ValueSetAcc::getBackground( )
538 throw (uno::RuntimeException
)
541 UINT32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
542 return static_cast<sal_Int32
>(nColor
);
545 // -----------------------------------------------------------------------------
547 void SAL_CALL
ValueSetAcc::selectAccessibleChild( sal_Int32 nChildIndex
)
548 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
551 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
552 ValueSetItem
* pItem
= getItem (sal::static_int_cast
< USHORT
>(nChildIndex
));
556 mpParent
->SelectItem( pItem
->mnId
);
560 throw lang::IndexOutOfBoundsException();
563 // -----------------------------------------------------------------------------
565 sal_Bool SAL_CALL
ValueSetAcc::isAccessibleChildSelected( sal_Int32 nChildIndex
)
566 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
569 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
570 ValueSetItem
* pItem
= getItem (sal::static_int_cast
< USHORT
>(nChildIndex
));
571 sal_Bool bRet
= sal_False
;
574 bRet
= mpParent
->IsItemSelected( pItem
->mnId
);
576 throw lang::IndexOutOfBoundsException();
581 // -----------------------------------------------------------------------------
583 void SAL_CALL
ValueSetAcc::clearAccessibleSelection()
584 throw (uno::RuntimeException
)
587 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
588 mpParent
->SetNoSelection();
591 // -----------------------------------------------------------------------------
593 void SAL_CALL
ValueSetAcc::selectAllAccessibleChildren()
594 throw (uno::RuntimeException
)
597 // unsupported due to single selection only
600 // -----------------------------------------------------------------------------
602 sal_Int32 SAL_CALL
ValueSetAcc::getSelectedAccessibleChildCount()
603 throw (uno::RuntimeException
)
606 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
609 for( USHORT i
= 0, nCount
= getItemCount(); i
< nCount
; i
++ )
611 ValueSetItem
* pItem
= getItem (i
);
613 if( pItem
&& mpParent
->IsItemSelected( pItem
->mnId
) )
620 // -----------------------------------------------------------------------------
622 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueSetAcc::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
)
623 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
626 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
627 uno::Reference
< accessibility::XAccessible
> xRet
;
629 for( USHORT i
= 0, nCount
= getItemCount(), nSel
= 0; ( i
< nCount
) && !xRet
.is(); i
++ )
631 ValueSetItem
* pItem
= getItem(i
);
633 if( pItem
&& mpParent
->IsItemSelected( pItem
->mnId
) && ( nSelectedChildIndex
== static_cast< sal_Int32
>( nSel
++ ) ) )
634 xRet
= pItem
->GetAccessible( mbIsTransientChildrenDisabled
);
640 // -----------------------------------------------------------------------------
642 void SAL_CALL
ValueSetAcc::deselectAccessibleChild( sal_Int32 nChildIndex
)
643 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
646 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
647 // Because of the single selection we can reset the whole selection when
648 // the specified child is currently selected.
649 if (isAccessibleChildSelected(nChildIndex
))
650 mpParent
->SetNoSelection();
653 // -----------------------------------------------------------------------------
655 sal_Int64 SAL_CALL
ValueSetAcc::getSomething( const uno::Sequence
< sal_Int8
>& rId
) throw( uno::RuntimeException
)
659 if( ( rId
.getLength() == 16 ) && ( 0 == rtl_compareMemory( ValueSetAcc::getUnoTunnelId().getConstArray(), rId
.getConstArray(), 16 ) ) )
660 nRet
= reinterpret_cast< sal_Int64
>( this );
670 void SAL_CALL
ValueSetAcc::disposing (void)
672 ::std::vector
<uno::Reference
<accessibility::XAccessibleEventListener
> > aListenerListCopy
;
675 // Make a copy of the list and clear the original.
676 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
677 ::osl::MutexGuard
aGuard (m_aMutex
);
678 aListenerListCopy
= mxEventListeners
;
679 mxEventListeners
.clear();
681 // Reset the pointer to the parent. It has to be the one who has
682 // disposed us because he is dying.
686 // Inform all listeners that this objects is disposing.
687 ::std::vector
<uno::Reference
<accessibility::XAccessibleEventListener
> >::const_iterator
688 aListenerIterator (aListenerListCopy
.begin());
689 lang::EventObject
aEvent (static_cast<accessibility::XAccessible
*>(this));
690 while (aListenerIterator
!= aListenerListCopy
.end())
694 (*aListenerIterator
)->disposing (aEvent
);
696 catch( uno::Exception
& )
698 // Ignore exceptions.
706 USHORT
ValueSetAcc::getItemCount (void) const
708 USHORT nCount
= mpParent
->ImplGetVisibleItemCount();
709 // When the None-Item is visible then increase the number of items by
717 ValueSetItem
* ValueSetAcc::getItem (USHORT nIndex
) const
719 ValueSetItem
* pItem
= NULL
;
724 // When present the first item is the then allways visible none field.
725 pItem
= mpParent
->ImplGetItem (VALUESET_ITEM_NONEITEM
);
727 // Shift down the index to compensate for the none field.
731 pItem
= mpParent
->ImplGetVisibleItem (static_cast<USHORT
>(nIndex
));
739 void ValueSetAcc::ThrowIfDisposed (void)
740 throw (::com::sun::star::lang::DisposedException
)
742 if (rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
744 OSL_TRACE ("Calling disposed object. Throwing exception:");
745 throw lang::DisposedException (
746 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("object has been already disposed")),
747 static_cast<uno::XWeak
*>(this));
751 DBG_ASSERT (mpParent
!=NULL
, "ValueSetAcc not disposed but mpParent == NULL");
757 sal_Bool
ValueSetAcc::IsDisposed (void)
759 return (rBHelper
.bDisposed
|| rBHelper
.bInDispose
);
765 bool ValueSetAcc::HasNoneField (void) const
767 DBG_ASSERT (mpParent
!=NULL
, "ValueSetAcc::HasNoneField called with mpParent==NULL");
768 return ((mpParent
->GetStyle() & WB_NONEFIELD
) != 0);
778 ValueItemAcc::ValueItemAcc( ValueSetItem
* pParent
, bool bIsTransientChildrenDisabled
) :
780 mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled
)
784 // -----------------------------------------------------------------------------
786 ValueItemAcc::~ValueItemAcc()
790 // -----------------------------------------------------------------------
792 void ValueItemAcc::FireAccessibleEvent( short nEventId
, const uno::Any
& rOldValue
, const uno::Any
& rNewValue
)
796 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> > aTmpListeners( mxEventListeners
);
797 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator
aIter( aTmpListeners
.begin() );
798 accessibility::AccessibleEventObject aEvtObject
;
800 aEvtObject
.EventId
= nEventId
;
801 aEvtObject
.Source
= static_cast<uno::XWeak
*>(this);
802 aEvtObject
.NewValue
= rNewValue
;
803 aEvtObject
.OldValue
= rOldValue
;
805 while( aIter
!= aTmpListeners
.end() )
807 (*aIter
)->notifyEvent( aEvtObject
);
813 // -----------------------------------------------------------------------------
815 void ValueItemAcc::ParentDestroyed()
817 const ::vos::OGuard
aGuard( maMutex
);
821 // -----------------------------------------------------------------------------
823 const uno::Sequence
< sal_Int8
>& ValueItemAcc::getUnoTunnelId()
825 static uno::Sequence
< sal_Int8
> aSeq
;
827 if( !aSeq
.getLength() )
829 static osl::Mutex aCreateMutex
;
830 osl::Guard
< osl::Mutex
> aGuard( aCreateMutex
);
833 rtl_createUuid( reinterpret_cast< sal_uInt8
* >( aSeq
.getArray() ), 0, sal_True
);
839 // -----------------------------------------------------------------------------
841 ValueItemAcc
* ValueItemAcc::getImplementation( const uno::Reference
< uno::XInterface
>& rxData
)
846 uno::Reference
< lang::XUnoTunnel
> xUnoTunnel( rxData
, uno::UNO_QUERY
);
847 return( xUnoTunnel
.is() ? reinterpret_cast<ValueItemAcc
*>(sal::static_int_cast
<sal_IntPtr
>(xUnoTunnel
->getSomething( ValueItemAcc::getUnoTunnelId() ))) : NULL
);
849 catch( const ::com::sun::star::uno::Exception
& )
855 // -----------------------------------------------------------------------------
857 uno::Reference
< accessibility::XAccessibleContext
> SAL_CALL
ValueItemAcc::getAccessibleContext()
858 throw (uno::RuntimeException
)
863 // -----------------------------------------------------------------------------
865 sal_Int32 SAL_CALL
ValueItemAcc::getAccessibleChildCount()
866 throw (uno::RuntimeException
)
871 // -----------------------------------------------------------------------------
873 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueItemAcc::getAccessibleChild( sal_Int32
)
874 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
876 throw lang::IndexOutOfBoundsException();
879 // -----------------------------------------------------------------------------
881 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueItemAcc::getAccessibleParent()
882 throw (uno::RuntimeException
)
884 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
885 uno::Reference
< accessibility::XAccessible
> xRet
;
888 xRet
= mpParent
->mrParent
.GetAccessible();
893 // -----------------------------------------------------------------------------
895 sal_Int32 SAL_CALL
ValueItemAcc::getAccessibleIndexInParent()
896 throw (uno::RuntimeException
)
898 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
899 // The index defaults to -1 to indicate the child does not belong to its
901 sal_Int32 nIndexInParent
= -1;
907 USHORT nCount
= mpParent
->mrParent
.ImplGetVisibleItemCount();
909 for (USHORT i
=0; i
<nCount
&& !bDone
; i
++)
911 // Guard the retrieval of the i-th child with a try/catch block
912 // just in case the number of children changes in the mean time.
915 pItem
= mpParent
->mrParent
.ImplGetVisibleItem (i
);
917 catch (lang::IndexOutOfBoundsException aException
)
922 // Do not create an accessible object for the test.
923 if (pItem
!= NULL
&& pItem
->mpxAcc
!= NULL
)
924 if (pItem
->GetAccessible( mbIsTransientChildrenDisabled
).get() == this )
932 return nIndexInParent
;
935 // -----------------------------------------------------------------------------
937 sal_Int16 SAL_CALL
ValueItemAcc::getAccessibleRole()
938 throw (uno::RuntimeException
)
940 return accessibility::AccessibleRole::LIST_ITEM
;
943 // -----------------------------------------------------------------------------
945 ::rtl::OUString SAL_CALL
ValueItemAcc::getAccessibleDescription()
946 throw (uno::RuntimeException
)
948 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
949 String
aRet( RTL_CONSTASCII_USTRINGPARAM( "ValueSet item" ) );
954 // -----------------------------------------------------------------------------
956 ::rtl::OUString SAL_CALL
ValueItemAcc::getAccessibleName()
957 throw (uno::RuntimeException
)
959 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
964 aRet
= mpParent
->maText
;
968 aRet
= String( RTL_CONSTASCII_USTRINGPARAM( "Item " ) );
969 aRet
+= String::CreateFromInt32( mpParent
->mnId
);
976 // -----------------------------------------------------------------------------
978 uno::Reference
< accessibility::XAccessibleRelationSet
> SAL_CALL
ValueItemAcc::getAccessibleRelationSet()
979 throw (uno::RuntimeException
)
981 return uno::Reference
< accessibility::XAccessibleRelationSet
>();
984 // -----------------------------------------------------------------------------
986 uno::Reference
< accessibility::XAccessibleStateSet
> SAL_CALL
ValueItemAcc::getAccessibleStateSet()
987 throw (uno::RuntimeException
)
989 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
990 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper
;
994 pStateSet
->AddState (accessibility::AccessibleStateType::ENABLED
);
995 pStateSet
->AddState (accessibility::AccessibleStateType::SENSITIVE
);
996 pStateSet
->AddState (accessibility::AccessibleStateType::SHOWING
);
997 pStateSet
->AddState (accessibility::AccessibleStateType::VISIBLE
);
998 if ( !mbIsTransientChildrenDisabled
)
999 pStateSet
->AddState (accessibility::AccessibleStateType::TRANSIENT
);
1002 pStateSet
->AddState( accessibility::AccessibleStateType::SELECTABLE
);
1003 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE );
1006 if( mpParent
->mrParent
.GetSelectItemId() == mpParent
->mnId
)
1008 pStateSet
->AddState( accessibility::AccessibleStateType::SELECTED
);
1009 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSED );
1016 // -----------------------------------------------------------------------------
1018 lang::Locale SAL_CALL
ValueItemAcc::getLocale()
1019 throw (accessibility::IllegalAccessibleComponentStateException
, uno::RuntimeException
)
1021 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
1022 const ::rtl::OUString aEmptyStr
;
1023 uno::Reference
< accessibility::XAccessible
> xParent( getAccessibleParent() );
1024 lang::Locale
aRet( aEmptyStr
, aEmptyStr
, aEmptyStr
);
1028 uno::Reference
< accessibility::XAccessibleContext
> xParentContext( xParent
->getAccessibleContext() );
1030 if( xParentContext
.is() )
1031 aRet
= xParentContext
->getLocale();
1037 // -----------------------------------------------------------------------------
1039 void SAL_CALL
ValueItemAcc::addEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
1040 throw (uno::RuntimeException
)
1042 const ::vos::OGuard
aGuard( maMutex
);
1044 if( rxListener
.is() )
1046 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator aIter
= mxEventListeners
.begin();
1047 sal_Bool bFound
= sal_False
;
1049 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
1051 if( *aIter
== rxListener
)
1058 mxEventListeners
.push_back( rxListener
);
1062 // -----------------------------------------------------------------------------
1064 void SAL_CALL
ValueItemAcc::removeEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
1065 throw (uno::RuntimeException
)
1067 const ::vos::OGuard
aGuard( maMutex
);
1069 if( rxListener
.is() )
1071 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::iterator aIter
= mxEventListeners
.begin();
1072 sal_Bool bFound
= sal_False
;
1074 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
1076 if( *aIter
== rxListener
)
1078 mxEventListeners
.erase( aIter
);
1087 // -----------------------------------------------------------------------------
1089 sal_Bool SAL_CALL
ValueItemAcc::containsPoint( const awt::Point
& aPoint
)
1090 throw (uno::RuntimeException
)
1092 const awt::Rectangle
aRect( getBounds() );
1093 const Point
aSize( aRect
.Width
, aRect
.Height
);
1094 const Point aNullPoint
, aTestPoint( aPoint
.X
, aPoint
.Y
);
1096 return Rectangle( aNullPoint
, aSize
).IsInside( aTestPoint
);
1099 // -----------------------------------------------------------------------------
1101 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueItemAcc::getAccessibleAtPoint( const awt::Point
& )
1102 throw (uno::RuntimeException
)
1104 uno::Reference
< accessibility::XAccessible
> xRet
;
1108 // -----------------------------------------------------------------------------
1110 awt::Rectangle SAL_CALL
ValueItemAcc::getBounds()
1111 throw (uno::RuntimeException
)
1113 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
1114 awt::Rectangle aRet
;
1118 Rectangle
aRect( mpParent
->maRect
);
1120 Rectangle
aParentRect( aOrigin
, mpParent
->mrParent
.GetOutputSizePixel() );
1122 aRect
.Intersection( aParentRect
);
1124 aRet
.X
= aRect
.Left();
1125 aRet
.Y
= aRect
.Top();
1126 aRet
.Width
= aRect
.GetWidth();
1127 aRet
.Height
= aRect
.GetHeight();
1133 // -----------------------------------------------------------------------------
1135 awt::Point SAL_CALL
ValueItemAcc::getLocation()
1136 throw (uno::RuntimeException
)
1138 const awt::Rectangle
aRect( getBounds() );
1147 // -----------------------------------------------------------------------------
1149 awt::Point SAL_CALL
ValueItemAcc::getLocationOnScreen()
1150 throw (uno::RuntimeException
)
1152 const vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
1157 const Point
aScreenPos( mpParent
->mrParent
.OutputToAbsoluteScreenPixel( mpParent
->maRect
.TopLeft() ) );
1159 aRet
.X
= aScreenPos
.X();
1160 aRet
.Y
= aScreenPos
.Y();
1166 // -----------------------------------------------------------------------------
1168 awt::Size SAL_CALL
ValueItemAcc::getSize()
1169 throw (uno::RuntimeException
)
1171 const awt::Rectangle
aRect( getBounds() );
1174 aRet
.Width
= aRect
.Width
;
1175 aRet
.Height
= aRect
.Height
;
1180 // -----------------------------------------------------------------------------
1182 void SAL_CALL
ValueItemAcc::grabFocus()
1183 throw (uno::RuntimeException
)
1188 // -----------------------------------------------------------------------------
1190 uno::Any SAL_CALL
ValueItemAcc::getAccessibleKeyBinding()
1191 throw (uno::RuntimeException
)
1196 // -----------------------------------------------------------------------------
1198 sal_Int32 SAL_CALL
ValueItemAcc::getForeground( )
1199 throw (uno::RuntimeException
)
1201 UINT32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
1202 return static_cast<sal_Int32
>(nColor
);
1205 // -----------------------------------------------------------------------------
1207 sal_Int32 SAL_CALL
ValueItemAcc::getBackground( )
1208 throw (uno::RuntimeException
)
1211 if (mpParent
->meType
== VALUESETITEM_COLOR
)
1212 nColor
= mpParent
->maColor
.GetColor();
1214 nColor
= Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
1215 return static_cast<sal_Int32
>(nColor
);
1218 // -----------------------------------------------------------------------------
1220 sal_Int64 SAL_CALL
ValueItemAcc::getSomething( const uno::Sequence
< sal_Int8
>& rId
) throw( uno::RuntimeException
)
1224 if( ( rId
.getLength() == 16 ) && ( 0 == rtl_compareMemory( ValueItemAcc::getUnoTunnelId().getConstArray(), rId
.getConstArray(), 16 ) ) )
1225 nRet
= reinterpret_cast< sal_Int64
>( this );