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 <vcl/settings.hxx>
23 #include <svtools/valueset.hxx>
24 #include "valueimp.hxx"
25 #include <comphelper/servicehelper.hxx>
26 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
27 #include <com/sun/star/accessibility/AccessibleRole.hpp>
28 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
29 #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
30 #include <unotools/accessiblerelationsethelper.hxx>
32 using namespace ::com::sun::star
;
38 ValueSetItem::ValueSetItem( ValueSet
& rParent
)
41 , meType(VALUESETITEM_NONE
)
51 ValueSetItem::~ValueSetItem()
55 static_cast< ValueItemAcc
* >( mpxAcc
->get() )->ParentDestroyed();
62 uno::Reference
< accessibility::XAccessible
> ValueSetItem::GetAccessible( bool bIsTransientChildrenDisabled
)
65 mpxAcc
= new uno::Reference
< accessibility::XAccessible
>( new ValueItemAcc( this, bIsTransientChildrenDisabled
) );
74 ValueSetAcc::ValueSetAcc( ValueSet
* pParent
, bool bIsTransientChildrenDisabled
) :
75 ValueSetAccComponentBase (m_aMutex
),
77 mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled
),
84 ValueSetAcc::~ValueSetAcc()
90 void ValueSetAcc::FireAccessibleEvent( short nEventId
, const uno::Any
& rOldValue
, const uno::Any
& rNewValue
)
94 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> > aTmpListeners( mxEventListeners
);
95 accessibility::AccessibleEventObject aEvtObject
;
97 aEvtObject
.EventId
= nEventId
;
98 aEvtObject
.Source
= static_cast<uno::XWeak
*>(this);
99 aEvtObject
.NewValue
= rNewValue
;
100 aEvtObject
.OldValue
= rOldValue
;
102 for (::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator
aIter( aTmpListeners
.begin() );
103 aIter
!= aTmpListeners
.end() ; ++aIter
)
107 (*aIter
)->notifyEvent( aEvtObject
);
109 catch(const uno::Exception
&)
118 class theValueSetAccUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theValueSetAccUnoTunnelId
> {};
121 const uno::Sequence
< sal_Int8
>& ValueSetAcc::getUnoTunnelId()
123 return theValueSetAccUnoTunnelId::get().getSeq();
128 ValueSetAcc
* ValueSetAcc::getImplementation( const uno::Reference
< uno::XInterface
>& rxData
)
133 uno::Reference
< lang::XUnoTunnel
> xUnoTunnel( rxData
, uno::UNO_QUERY
);
134 return( xUnoTunnel
.is() ? reinterpret_cast<ValueSetAcc
*>(sal::static_int_cast
<sal_IntPtr
>(xUnoTunnel
->getSomething( ValueSetAcc::getUnoTunnelId() ))) : NULL
);
136 catch(const ::com::sun::star::uno::Exception
&)
145 void ValueSetAcc::GetFocus()
149 // Broadcast the state change.
150 ::com::sun::star::uno::Any aOldState
, aNewState
;
151 aNewState
<<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED
;
153 ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED
,
154 aOldState
, aNewState
);
159 void ValueSetAcc::LoseFocus()
163 // Broadcast the state change.
164 ::com::sun::star::uno::Any aOldState
, aNewState
;
165 aOldState
<<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED
;
167 ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED
,
168 aOldState
, aNewState
);
173 uno::Reference
< accessibility::XAccessibleContext
> SAL_CALL
ValueSetAcc::getAccessibleContext()
174 throw (uno::RuntimeException
, std::exception
)
182 sal_Int32 SAL_CALL
ValueSetAcc::getAccessibleChildCount()
183 throw (uno::RuntimeException
, std::exception
)
185 const SolarMutexGuard aSolarGuard
;
188 sal_Int32 nCount
= mpParent
->ImplGetVisibleItemCount();
196 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueSetAcc::getAccessibleChild( sal_Int32 i
)
197 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
200 const SolarMutexGuard aSolarGuard
;
201 uno::Reference
< accessibility::XAccessible
> xRet
;
202 ValueSetItem
* pItem
= getItem (sal::static_int_cast
< sal_uInt16
>(i
));
205 xRet
= pItem
->GetAccessible( mbIsTransientChildrenDisabled
);
207 throw lang::IndexOutOfBoundsException();
214 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueSetAcc::getAccessibleParent()
215 throw (uno::RuntimeException
, std::exception
)
218 const SolarMutexGuard aSolarGuard
;
219 vcl::Window
* pParent
= mpParent
->GetParent();
220 uno::Reference
< accessibility::XAccessible
> xRet
;
223 xRet
= pParent
->GetAccessible();
230 sal_Int32 SAL_CALL
ValueSetAcc::getAccessibleIndexInParent()
231 throw (uno::RuntimeException
, std::exception
)
234 const SolarMutexGuard aSolarGuard
;
235 vcl::Window
* pParent
= mpParent
->GetParent();
242 for( sal_uInt16 i
= 0, nCount
= pParent
->GetChildCount(); ( i
< nCount
) && !bFound
; i
++ )
244 if( pParent
->GetChild( i
) == mpParent
)
257 sal_Int16 SAL_CALL
ValueSetAcc::getAccessibleRole()
258 throw (uno::RuntimeException
, std::exception
)
261 // #i73746# As the Java Access Bridge (v 2.0.1) uses "managesDescendants"
262 // always if the role is LIST, we need a different role in this case
263 return (mbIsTransientChildrenDisabled
264 ? accessibility::AccessibleRole::PANEL
265 : accessibility::AccessibleRole::LIST
);
270 OUString SAL_CALL
ValueSetAcc::getAccessibleDescription()
271 throw (uno::RuntimeException
, std::exception
)
274 const SolarMutexGuard aSolarGuard
;
275 OUString
aRet( "ValueSet" );
282 OUString SAL_CALL
ValueSetAcc::getAccessibleName()
283 throw (uno::RuntimeException
, std::exception
)
286 const SolarMutexGuard aSolarGuard
;
291 aRet
= mpParent
->GetAccessibleName();
293 if ( aRet
.isEmpty() )
295 vcl::Window
* pLabel
= mpParent
->GetAccessibleRelationLabeledBy();
296 if ( pLabel
&& pLabel
!= mpParent
)
297 aRet
= OutputDevice::GetNonMnemonicString( pLabel
->GetText() );
300 aRet
= mpParent
->GetQuickHelpText();
309 uno::Reference
< accessibility::XAccessibleRelationSet
> SAL_CALL
ValueSetAcc::getAccessibleRelationSet()
310 throw (uno::RuntimeException
, std::exception
)
314 uno::Reference
< accessibility::XAccessibleRelationSet
> xRelSet
;
315 vcl::Window
* pWindow
= (vcl::Window
*)mpParent
;
318 utl::AccessibleRelationSetHelper
* pRelationSet
= new utl::AccessibleRelationSetHelper
;
319 xRelSet
= pRelationSet
;
321 vcl::Window
*pLabeledBy
= pWindow
->GetAccessibleRelationLabeledBy();
322 if ( pLabeledBy
&& pLabeledBy
!= pWindow
)
324 uno::Sequence
< uno::Reference
< uno::XInterface
> > aSequence(1);
325 aSequence
[0] = pLabeledBy
->GetAccessible();
326 pRelationSet
->AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABELED_BY
, aSequence
) );
329 vcl::Window
* pMemberOf
= pWindow
->GetAccessibleRelationMemberOf();
330 if ( pMemberOf
&& pMemberOf
!= pWindow
)
332 uno::Sequence
< uno::Reference
< uno::XInterface
> > aSequence(1);
333 aSequence
[0] = pMemberOf
->GetAccessible();
334 pRelationSet
->AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::MEMBER_OF
, aSequence
) );
342 uno::Reference
< accessibility::XAccessibleStateSet
> SAL_CALL
ValueSetAcc::getAccessibleStateSet()
343 throw (uno::RuntimeException
, std::exception
)
346 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper();
349 pStateSet
->AddState (accessibility::AccessibleStateType::ENABLED
);
350 pStateSet
->AddState (accessibility::AccessibleStateType::SENSITIVE
);
351 pStateSet
->AddState (accessibility::AccessibleStateType::SHOWING
);
352 pStateSet
->AddState (accessibility::AccessibleStateType::VISIBLE
);
353 if ( !mbIsTransientChildrenDisabled
)
354 pStateSet
->AddState (accessibility::AccessibleStateType::MANAGES_DESCENDANTS
);
355 pStateSet
->AddState (accessibility::AccessibleStateType::FOCUSABLE
);
357 pStateSet
->AddState (accessibility::AccessibleStateType::FOCUSED
);
364 lang::Locale SAL_CALL
ValueSetAcc::getLocale()
365 throw (accessibility::IllegalAccessibleComponentStateException
, uno::RuntimeException
, std::exception
)
368 const SolarMutexGuard aSolarGuard
;
369 const OUString aEmptyStr
;
370 uno::Reference
< accessibility::XAccessible
> xParent( getAccessibleParent() );
371 lang::Locale
aRet( aEmptyStr
, aEmptyStr
, aEmptyStr
);
375 uno::Reference
< accessibility::XAccessibleContext
> xParentContext( xParent
->getAccessibleContext() );
377 if( xParentContext
.is() )
378 aRet
= xParentContext
->getLocale ();
386 void SAL_CALL
ValueSetAcc::addAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
387 throw (uno::RuntimeException
, std::exception
)
390 ::osl::MutexGuard
aGuard (m_aMutex
);
392 if( rxListener
.is() )
394 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator aIter
= mxEventListeners
.begin();
397 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
399 if( *aIter
== rxListener
)
406 mxEventListeners
.push_back( rxListener
);
412 void SAL_CALL
ValueSetAcc::removeAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
413 throw (uno::RuntimeException
, std::exception
)
416 ::osl::MutexGuard
aGuard (m_aMutex
);
418 if( rxListener
.is() )
420 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::iterator aIter
=
421 std::find(mxEventListeners
.begin(), mxEventListeners
.end(), rxListener
);
423 if (aIter
!= mxEventListeners
.end())
424 mxEventListeners
.erase(aIter
);
430 sal_Bool SAL_CALL
ValueSetAcc::containsPoint( const awt::Point
& aPoint
)
431 throw (uno::RuntimeException
, std::exception
)
434 const awt::Rectangle
aRect( getBounds() );
435 const Point
aSize( aRect
.Width
, aRect
.Height
);
436 const Point aNullPoint
, aTestPoint( aPoint
.X
, aPoint
.Y
);
438 return Rectangle( aNullPoint
, aSize
).IsInside( aTestPoint
);
443 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueSetAcc::getAccessibleAtPoint( const awt::Point
& aPoint
)
444 throw (uno::RuntimeException
, std::exception
)
447 const SolarMutexGuard aSolarGuard
;
448 const sal_uInt16 nItemId
= mpParent
->GetItemId( Point( aPoint
.X
, aPoint
.Y
) );
449 uno::Reference
< accessibility::XAccessible
> xRet
;
453 const size_t nItemPos
= mpParent
->GetItemPos( nItemId
);
455 if( VALUESET_ITEM_NONEITEM
!= nItemPos
)
457 ValueSetItem
*const pItem
= mpParent
->mItemList
[nItemPos
];
458 xRet
= pItem
->GetAccessible( mbIsTransientChildrenDisabled
);
467 awt::Rectangle SAL_CALL
ValueSetAcc::getBounds()
468 throw (uno::RuntimeException
, std::exception
)
471 const SolarMutexGuard aSolarGuard
;
472 const Point
aOutPos( mpParent
->GetPosPixel() );
473 const Size
aOutSize( mpParent
->GetOutputSizePixel() );
476 aRet
.X
= aOutPos
.X();
477 aRet
.Y
= aOutPos
.Y();
478 aRet
.Width
= aOutSize
.Width();
479 aRet
.Height
= aOutSize
.Height();
486 awt::Point SAL_CALL
ValueSetAcc::getLocation()
487 throw (uno::RuntimeException
, std::exception
)
490 const awt::Rectangle
aRect( getBounds() );
501 awt::Point SAL_CALL
ValueSetAcc::getLocationOnScreen()
502 throw (uno::RuntimeException
, std::exception
)
505 const SolarMutexGuard aSolarGuard
;
506 const Point
aScreenPos( mpParent
->OutputToAbsoluteScreenPixel( Point() ) );
509 aRet
.X
= aScreenPos
.X();
510 aRet
.Y
= aScreenPos
.Y();
517 awt::Size SAL_CALL
ValueSetAcc::getSize()
518 throw (uno::RuntimeException
, std::exception
)
521 const awt::Rectangle
aRect( getBounds() );
524 aRet
.Width
= aRect
.Width
;
525 aRet
.Height
= aRect
.Height
;
530 void SAL_CALL
ValueSetAcc::grabFocus()
531 throw (uno::RuntimeException
, std::exception
)
534 const SolarMutexGuard aSolarGuard
;
535 mpParent
->GrabFocus();
538 sal_Int32 SAL_CALL
ValueSetAcc::getForeground( )
539 throw (uno::RuntimeException
, std::exception
)
542 sal_uInt32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
543 return static_cast<sal_Int32
>(nColor
);
546 sal_Int32 SAL_CALL
ValueSetAcc::getBackground( )
547 throw (uno::RuntimeException
, std::exception
)
550 sal_uInt32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
551 return static_cast<sal_Int32
>(nColor
);
554 void SAL_CALL
ValueSetAcc::selectAccessibleChild( sal_Int32 nChildIndex
)
555 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
558 const SolarMutexGuard aSolarGuard
;
559 ValueSetItem
* pItem
= getItem (sal::static_int_cast
< sal_uInt16
>(nChildIndex
));
563 mpParent
->SelectItem( pItem
->mnId
);
567 throw lang::IndexOutOfBoundsException();
572 sal_Bool SAL_CALL
ValueSetAcc::isAccessibleChildSelected( sal_Int32 nChildIndex
)
573 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
576 const SolarMutexGuard aSolarGuard
;
577 ValueSetItem
* pItem
= getItem (sal::static_int_cast
< sal_uInt16
>(nChildIndex
));
581 bRet
= mpParent
->IsItemSelected( pItem
->mnId
);
583 throw lang::IndexOutOfBoundsException();
590 void SAL_CALL
ValueSetAcc::clearAccessibleSelection()
591 throw (uno::RuntimeException
, std::exception
)
594 const SolarMutexGuard aSolarGuard
;
595 mpParent
->SetNoSelection();
600 void SAL_CALL
ValueSetAcc::selectAllAccessibleChildren()
601 throw (uno::RuntimeException
, std::exception
)
604 // unsupported due to single selection only
609 sal_Int32 SAL_CALL
ValueSetAcc::getSelectedAccessibleChildCount()
610 throw (uno::RuntimeException
, std::exception
)
613 const SolarMutexGuard aSolarGuard
;
616 for( sal_uInt16 i
= 0, nCount
= getItemCount(); i
< nCount
; i
++ )
618 ValueSetItem
* pItem
= getItem (i
);
620 if( pItem
&& mpParent
->IsItemSelected( pItem
->mnId
) )
629 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueSetAcc::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
)
630 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
633 const SolarMutexGuard aSolarGuard
;
634 uno::Reference
< accessibility::XAccessible
> xRet
;
636 for( sal_uInt16 i
= 0, nCount
= getItemCount(), nSel
= 0; ( i
< nCount
) && !xRet
.is(); i
++ )
638 ValueSetItem
* pItem
= getItem(i
);
640 if( pItem
&& mpParent
->IsItemSelected( pItem
->mnId
) && ( nSelectedChildIndex
== static_cast< sal_Int32
>( nSel
++ ) ) )
641 xRet
= pItem
->GetAccessible( mbIsTransientChildrenDisabled
);
649 void SAL_CALL
ValueSetAcc::deselectAccessibleChild( sal_Int32 nChildIndex
)
650 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
653 const SolarMutexGuard aSolarGuard
;
654 // Because of the single selection we can reset the whole selection when
655 // the specified child is currently selected.
656 if (isAccessibleChildSelected(nChildIndex
))
657 mpParent
->SetNoSelection();
662 sal_Int64 SAL_CALL
ValueSetAcc::getSomething( const uno::Sequence
< sal_Int8
>& rId
) throw( uno::RuntimeException
, std::exception
)
666 if( ( rId
.getLength() == 16 ) && ( 0 == memcmp( ValueSetAcc::getUnoTunnelId().getConstArray(), rId
.getConstArray(), 16 ) ) )
667 nRet
= reinterpret_cast< sal_Int64
>( this );
677 void SAL_CALL
ValueSetAcc::disposing()
679 ::std::vector
<uno::Reference
<accessibility::XAccessibleEventListener
> > aListenerListCopy
;
682 // Make a copy of the list and clear the original.
683 const SolarMutexGuard aSolarGuard
;
684 ::osl::MutexGuard
aGuard (m_aMutex
);
685 aListenerListCopy
= mxEventListeners
;
686 mxEventListeners
.clear();
688 // Reset the pointer to the parent. It has to be the one who has
689 // disposed us because he is dying.
693 // Inform all listeners that this objects is disposing.
694 ::std::vector
<uno::Reference
<accessibility::XAccessibleEventListener
> >::const_iterator
695 aListenerIterator (aListenerListCopy
.begin());
696 lang::EventObject
aEvent (static_cast<accessibility::XAccessible
*>(this));
697 while (aListenerIterator
!= aListenerListCopy
.end())
701 (*aListenerIterator
)->disposing (aEvent
);
703 catch(const uno::Exception
&)
705 // Ignore exceptions.
713 sal_uInt16
ValueSetAcc::getItemCount() const
715 sal_uInt16 nCount
= mpParent
->ImplGetVisibleItemCount();
716 // When the None-Item is visible then increase the number of items by
724 ValueSetItem
* ValueSetAcc::getItem (sal_uInt16 nIndex
) const
726 ValueSetItem
* pItem
= NULL
;
731 // When present the first item is the then always visible none field.
732 pItem
= mpParent
->ImplGetItem (VALUESET_ITEM_NONEITEM
);
734 // Shift down the index to compensate for the none field.
738 pItem
= mpParent
->ImplGetItem (static_cast<sal_uInt16
>(nIndex
));
746 void ValueSetAcc::ThrowIfDisposed()
747 throw (::com::sun::star::lang::DisposedException
)
749 if (rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
751 OSL_TRACE ("Calling disposed object. Throwing exception:");
752 throw lang::DisposedException (
753 OUString("object has been already disposed"),
754 static_cast<uno::XWeak
*>(this));
758 DBG_ASSERT (mpParent
!=nullptr, "ValueSetAcc not disposed but mpParent == NULL");
762 bool ValueSetAcc::HasNoneField() const
764 assert(mpParent
&& "ValueSetAcc::HasNoneField called with mpParent==NULL");
765 return ((mpParent
->GetStyle() & WB_NONEFIELD
) != 0);
769 ValueItemAcc::ValueItemAcc( ValueSetItem
* pParent
, bool bIsTransientChildrenDisabled
) :
771 mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled
)
775 ValueItemAcc::~ValueItemAcc()
779 void ValueItemAcc::FireAccessibleEvent( short nEventId
, const uno::Any
& rOldValue
, const uno::Any
& rNewValue
)
783 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> > aTmpListeners( mxEventListeners
);
784 accessibility::AccessibleEventObject aEvtObject
;
786 aEvtObject
.EventId
= nEventId
;
787 aEvtObject
.Source
= static_cast<uno::XWeak
*>(this);
788 aEvtObject
.NewValue
= rNewValue
;
789 aEvtObject
.OldValue
= rOldValue
;
791 for (::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator
aIter( aTmpListeners
.begin() );
792 aIter
!= aTmpListeners
.end() ; ++aIter
)
794 (*aIter
)->notifyEvent( aEvtObject
);
801 void ValueItemAcc::ParentDestroyed()
803 const ::osl::MutexGuard
aGuard( maMutex
);
809 class theValueItemAccUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theValueItemAccUnoTunnelId
> {};
812 const uno::Sequence
< sal_Int8
>& ValueItemAcc::getUnoTunnelId()
814 return theValueItemAccUnoTunnelId::get().getSeq();
819 ValueItemAcc
* ValueItemAcc::getImplementation( const uno::Reference
< uno::XInterface
>& rxData
)
824 uno::Reference
< lang::XUnoTunnel
> xUnoTunnel( rxData
, uno::UNO_QUERY
);
825 return( xUnoTunnel
.is() ? reinterpret_cast<ValueItemAcc
*>(sal::static_int_cast
<sal_IntPtr
>(xUnoTunnel
->getSomething( ValueItemAcc::getUnoTunnelId() ))) : NULL
);
827 catch(const ::com::sun::star::uno::Exception
&)
835 uno::Reference
< accessibility::XAccessibleContext
> SAL_CALL
ValueItemAcc::getAccessibleContext()
836 throw (uno::RuntimeException
, std::exception
)
843 sal_Int32 SAL_CALL
ValueItemAcc::getAccessibleChildCount()
844 throw (uno::RuntimeException
, std::exception
)
851 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueItemAcc::getAccessibleChild( sal_Int32
)
852 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
854 throw lang::IndexOutOfBoundsException();
859 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueItemAcc::getAccessibleParent()
860 throw (uno::RuntimeException
, std::exception
)
862 const SolarMutexGuard aSolarGuard
;
863 uno::Reference
< accessibility::XAccessible
> xRet
;
866 xRet
= mpParent
->mrParent
.GetAccessible();
873 sal_Int32 SAL_CALL
ValueItemAcc::getAccessibleIndexInParent()
874 throw (uno::RuntimeException
, std::exception
)
876 const SolarMutexGuard aSolarGuard
;
877 // The index defaults to -1 to indicate the child does not belong to its
879 sal_Int32 nIndexInParent
= -1;
885 sal_uInt16 nCount
= mpParent
->mrParent
.ImplGetVisibleItemCount();
887 for (sal_uInt16 i
=0; i
<nCount
&& !bDone
; i
++)
889 // Guard the retrieval of the i-th child with a try/catch block
890 // just in case the number of children changes in the mean time.
893 pItem
= mpParent
->mrParent
.ImplGetItem(i
);
895 catch (const lang::IndexOutOfBoundsException
&)
900 // Do not create an accessible object for the test.
901 if (pItem
!= NULL
&& pItem
->mpxAcc
!= NULL
)
902 if (pItem
->GetAccessible( mbIsTransientChildrenDisabled
).get() == this )
910 //if this valueset contain a none field(common value is default), then we should increase the real index and set the noitem index value equal 0.
911 if ( mpParent
&& ( (mpParent
->mrParent
.GetStyle() & WB_NONEFIELD
) != 0 ) )
913 ValueSetItem
* pFirstItem
= mpParent
->mrParent
.ImplGetItem (VALUESET_ITEM_NONEITEM
);
914 if( pFirstItem
&& pFirstItem
->GetAccessible(mbIsTransientChildrenDisabled
).get() == this )
919 return nIndexInParent
;
924 sal_Int16 SAL_CALL
ValueItemAcc::getAccessibleRole()
925 throw (uno::RuntimeException
, std::exception
)
927 return accessibility::AccessibleRole::LIST_ITEM
;
932 OUString SAL_CALL
ValueItemAcc::getAccessibleDescription()
933 throw (uno::RuntimeException
, std::exception
)
940 OUString SAL_CALL
ValueItemAcc::getAccessibleName()
941 throw (uno::RuntimeException
, std::exception
)
943 const SolarMutexGuard aSolarGuard
;
948 aRet
= mpParent
->maText
;
952 OUStringBuffer
aBuffer("Item ");
953 aBuffer
.append(static_cast<sal_Int32
>(mpParent
->mnId
));
954 aRet
= aBuffer
.makeStringAndClear();
963 uno::Reference
< accessibility::XAccessibleRelationSet
> SAL_CALL
ValueItemAcc::getAccessibleRelationSet()
964 throw (uno::RuntimeException
, std::exception
)
966 return uno::Reference
< accessibility::XAccessibleRelationSet
>();
971 uno::Reference
< accessibility::XAccessibleStateSet
> SAL_CALL
ValueItemAcc::getAccessibleStateSet()
972 throw (uno::RuntimeException
, std::exception
)
974 const SolarMutexGuard aSolarGuard
;
975 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper
;
979 pStateSet
->AddState (accessibility::AccessibleStateType::ENABLED
);
980 pStateSet
->AddState (accessibility::AccessibleStateType::SENSITIVE
);
981 pStateSet
->AddState (accessibility::AccessibleStateType::SHOWING
);
982 pStateSet
->AddState (accessibility::AccessibleStateType::VISIBLE
);
983 if ( !mbIsTransientChildrenDisabled
)
984 pStateSet
->AddState (accessibility::AccessibleStateType::TRANSIENT
);
987 pStateSet
->AddState( accessibility::AccessibleStateType::SELECTABLE
);
988 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE );
991 if( mpParent
->mrParent
.GetSelectItemId() == mpParent
->mnId
)
993 pStateSet
->AddState( accessibility::AccessibleStateType::SELECTED
);
994 // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSED );
1003 lang::Locale SAL_CALL
ValueItemAcc::getLocale()
1004 throw (accessibility::IllegalAccessibleComponentStateException
, uno::RuntimeException
, std::exception
)
1006 const SolarMutexGuard aSolarGuard
;
1007 const OUString aEmptyStr
;
1008 uno::Reference
< accessibility::XAccessible
> xParent( getAccessibleParent() );
1009 lang::Locale
aRet( aEmptyStr
, aEmptyStr
, aEmptyStr
);
1013 uno::Reference
< accessibility::XAccessibleContext
> xParentContext( xParent
->getAccessibleContext() );
1015 if( xParentContext
.is() )
1016 aRet
= xParentContext
->getLocale();
1024 void SAL_CALL
ValueItemAcc::addAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
1025 throw (uno::RuntimeException
, std::exception
)
1027 const ::osl::MutexGuard
aGuard( maMutex
);
1029 if( rxListener
.is() )
1031 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::const_iterator aIter
= mxEventListeners
.begin();
1032 bool bFound
= false;
1034 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
1036 if( *aIter
== rxListener
)
1043 mxEventListeners
.push_back( rxListener
);
1049 void SAL_CALL
ValueItemAcc::removeAccessibleEventListener( const uno::Reference
< accessibility::XAccessibleEventListener
>& rxListener
)
1050 throw (uno::RuntimeException
, std::exception
)
1052 const ::osl::MutexGuard
aGuard( maMutex
);
1054 if( rxListener
.is() )
1056 ::std::vector
< uno::Reference
< accessibility::XAccessibleEventListener
> >::iterator aIter
=
1057 std::find(mxEventListeners
.begin(), mxEventListeners
.end(), rxListener
);
1059 if (aIter
!= mxEventListeners
.end())
1060 mxEventListeners
.erase(aIter
);
1066 sal_Bool SAL_CALL
ValueItemAcc::containsPoint( const awt::Point
& aPoint
)
1067 throw (uno::RuntimeException
, std::exception
)
1069 const awt::Rectangle
aRect( getBounds() );
1070 const Point
aSize( aRect
.Width
, aRect
.Height
);
1071 const Point aNullPoint
, aTestPoint( aPoint
.X
, aPoint
.Y
);
1073 return Rectangle( aNullPoint
, aSize
).IsInside( aTestPoint
);
1076 uno::Reference
< accessibility::XAccessible
> SAL_CALL
ValueItemAcc::getAccessibleAtPoint( const awt::Point
& )
1077 throw (uno::RuntimeException
, std::exception
)
1079 uno::Reference
< accessibility::XAccessible
> xRet
;
1083 awt::Rectangle SAL_CALL
ValueItemAcc::getBounds()
1084 throw (uno::RuntimeException
, std::exception
)
1086 const SolarMutexGuard aSolarGuard
;
1087 awt::Rectangle aRet
;
1091 Rectangle
aRect( mpParent
->mrParent
.GetItemRect(mpParent
->mnId
) );
1093 Rectangle
aParentRect( aOrigin
, mpParent
->mrParent
.GetOutputSizePixel() );
1095 aRect
.Intersection( aParentRect
);
1097 aRet
.X
= aRect
.Left();
1098 aRet
.Y
= aRect
.Top();
1099 aRet
.Width
= aRect
.GetWidth();
1100 aRet
.Height
= aRect
.GetHeight();
1106 awt::Point SAL_CALL
ValueItemAcc::getLocation()
1107 throw (uno::RuntimeException
, std::exception
)
1109 const awt::Rectangle
aRect( getBounds() );
1118 awt::Point SAL_CALL
ValueItemAcc::getLocationOnScreen()
1119 throw (uno::RuntimeException
, std::exception
)
1121 const SolarMutexGuard aSolarGuard
;
1126 const Point aPos
= mpParent
->mrParent
.GetItemRect(mpParent
->mnId
).TopLeft();
1127 const Point
aScreenPos( mpParent
->mrParent
.OutputToAbsoluteScreenPixel( aPos
) );
1129 aRet
.X
= aScreenPos
.X();
1130 aRet
.Y
= aScreenPos
.Y();
1136 awt::Size SAL_CALL
ValueItemAcc::getSize()
1137 throw (uno::RuntimeException
, std::exception
)
1139 const awt::Rectangle
aRect( getBounds() );
1142 aRet
.Width
= aRect
.Width
;
1143 aRet
.Height
= aRect
.Height
;
1148 void SAL_CALL
ValueItemAcc::grabFocus()
1149 throw (uno::RuntimeException
, std::exception
)
1154 sal_Int32 SAL_CALL
ValueItemAcc::getForeground( )
1155 throw (uno::RuntimeException
, std::exception
)
1157 sal_uInt32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
1158 return static_cast<sal_Int32
>(nColor
);
1161 sal_Int32 SAL_CALL
ValueItemAcc::getBackground( )
1162 throw (uno::RuntimeException
, std::exception
)
1165 if (mpParent
&& mpParent
->meType
== VALUESETITEM_COLOR
)
1166 nColor
= mpParent
->maColor
.GetColor();
1168 nColor
= Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
1169 return static_cast<sal_Int32
>(nColor
);
1172 sal_Int64 SAL_CALL
ValueItemAcc::getSomething( const uno::Sequence
< sal_Int8
>& rId
) throw( uno::RuntimeException
, std::exception
)
1176 if( ( rId
.getLength() == 16 ) && ( 0 == memcmp( ValueItemAcc::getUnoTunnelId().getConstArray(), rId
.getConstArray(), 16 ) ) )
1177 nRet
= reinterpret_cast< sal_Int64
>( this );
1184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */