25#include <com/sun/star/accessibility/AccessibleEventId.hpp>
26#include <com/sun/star/accessibility/AccessibleStateType.hpp>
27#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
50 class OToolBoxWindowItemContext final :
public OAccessibleContextWrapper
52 sal_Int32 m_nIndexInParent;
54 OToolBoxWindowItemContext(sal_Int32 _nIndexInParent,
55 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
56 const css::uno::Reference< css::accessibility::XAccessibleContext >& _rxInnerAccessibleContext,
57 const css::uno::Reference< css::accessibility::XAccessible >& _rxOwningAccessible,
58 const css::uno::Reference< css::accessibility::XAccessible >& _rxParentAccessible
59 ) : OAccessibleContextWrapper(
61 _rxInnerAccessibleContext,
64 ,m_nIndexInParent(_nIndexInParent)
67 virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( )
override;
71 sal_Int64 SAL_CALL OToolBoxWindowItemContext::getAccessibleIndexInParent( )
73 ::osl::MutexGuard aGuard( m_aMutex );
74 return m_nIndexInParent;
82 class OToolBoxWindowItem :
public OAccessibleWrapper
85 sal_Int32 m_nIndexInParent;
88 sal_Int32 getIndexInParent()
const {
return m_nIndexInParent; }
89 void setIndexInParent( sal_Int32 _nNewIndex ) { m_nIndexInParent = _nNewIndex; }
92 OToolBoxWindowItem(sal_Int32 _nIndexInParent,
93 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
94 const css::uno::Reference< css::accessibility::XAccessible >& _rxInnerAccessible,
95 const css::uno::Reference< css::accessibility::XAccessible >& _rxParentAccessible
96 ) : OAccessibleWrapper(
100 ,m_nIndexInParent(_nIndexInParent)
107 const css::uno::Reference< css::accessibility::XAccessibleContext >& _rxInnerContext
112 const Reference< XAccessibleContext >& _rxInnerContext )
114 return new OToolBoxWindowItemContext( m_nIndexInParent,
getComponentContext(), _rxInnerContext,
this, getParent() );
122 ImplInheritanceHelper( pVCLXWindow )
154 bool bHasFocus =
false;
155 if ( pToolBox->HasFocus() )
160 ToolBox* pToolBoxParent =
dynamic_cast< ToolBox*
>( pToolBox->GetParent() );
162 if ( pToolBoxParent && pToolBoxParent->
HasFocus() )
169 ToolBoxItemId nHighlightItemId = pToolBox->GetHighlightItemId();
170 sal_uInt16 nFocusCount = 0;
179 if ( pItem->
HasFocus() && nItemId != nHighlightItemId )
185 if ( nItemId == nHighlightItemId )
193 if ( nFocusCount > 1 )
230 pItem->
SetChecked( pToolBox->IsItemChecked( nItemId ) );
231 if ( nItemId == nFocusId )
259 bool _bNotifyRemoval )
262 if ( !xItemAcc.is() )
265 if ( _bNotifyRemoval )
267 NotifyAccessibleEvent( AccessibleEventId::CHILD,
Any( xItemAcc ),
Any() );
270 auto pWindowItem =
dynamic_cast<OToolBoxWindowItem*
>(xItemAcc.get());
274 ::comphelper::disposeComponent( xItemAcc );
278 Reference< XAccessibleContext > xContext( pWindowItem->getContextNoCreate() );
279 ::comphelper::disposeComponent( xContext );
302 auto pWindowItem =
dynamic_cast<OToolBoxWindowItem*
>(xItemAcc.get());
315 sal_Int32
nIndex = pWindowItem->getIndexInParent( );
317 pWindowItem->setIndexInParent(
nIndex );
327 NotifyAccessibleEvent( AccessibleEventId::CHILD,
Any(), aNewChild );
345 ToolBox::ImplToolItems::size_type
i,
nCount = pToolBox->GetItemCount();
350 NotifyAccessibleEvent( AccessibleEventId::CHILD,
Any(), aNewValue );
357 if( !(pWindow && pToolBox) )
398 && pChildWindow->
GetType() == WindowType::TOOLBOX) )
407 ToolBox::ImplToolItems::size_type
nIndex = pToolBox->GetItemPos( nCurItemId );
425 ToolBox::ImplToolItems::size_type
nIndex = pToolBox->GetItemPos( pToolBox->GetCurItemId() );
445 VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet );
450 rStateSet |= AccessibleStateType::FOCUSABLE;
451 if ( pToolBox->IsHorizontal() )
452 rStateSet |= AccessibleStateType::HORIZONTAL;
454 rStateSet |= AccessibleStateType::VERTICAL;
461 Reference< XAccessibleContext > xHoldAlive =
this;
463 switch ( rVclWindowEvent.
GetId() )
465 case VclEventId::ToolboxClick:
466 case VclEventId::ToolboxSelect:
469 if ( rVclWindowEvent.
GetData() )
471 UpdateChecked_Impl(
static_cast<ToolBox::ImplToolItems::size_type
>(
reinterpret_cast<sal_IntPtr
>(rVclWindowEvent.
GetData())) );
481 case VclEventId::ToolboxDoubleClick:
482 case VclEventId::ToolboxActivate:
483 case VclEventId::ToolboxDeactivate:
487 case VclEventId::ToolboxItemUpdated:
489 if ( rVclWindowEvent.
GetData() )
497 case VclEventId::ToolboxHighlight:
501 case VclEventId::ToolboxHighlightOff:
502 ReleaseFocus_Impl(
static_cast<ToolBox::ImplToolItems::size_type
>(
reinterpret_cast<sal_IntPtr
>(rVclWindowEvent.
GetData())) );
505 case VclEventId::ToolboxItemAdded :
506 UpdateItem_Impl(
static_cast<ToolBox::ImplToolItems::size_type
>(
reinterpret_cast<sal_IntPtr
>(rVclWindowEvent.
GetData())) );
509 case VclEventId::ToolboxItemRemoved :
510 case VclEventId::ToolboxAllItemsChanged :
516 case VclEventId::ToolboxItemWindowChanged:
518 auto nPos =
static_cast<ToolBox::ImplToolItems::size_type
>(
reinterpret_cast<sal_IntPtr
>(rVclWindowEvent.
GetData()));
529 NotifyAccessibleEvent( AccessibleEventId::CHILD,
Any(), aNewValue );
532 case VclEventId::ToolboxItemTextChanged :
533 UpdateItemName_Impl(
static_cast<ToolBox::ImplToolItems::size_type
>(
reinterpret_cast<sal_IntPtr
>(rVclWindowEvent.
GetData())) );
536 case VclEventId::ToolboxItemEnabled :
537 case VclEventId::ToolboxItemDisabled :
543 case VclEventId::DropdownOpen:
544 case VclEventId::DropdownClose:
550 case VclEventId::ObjectDying :
554 if ( pWin && pWin->GetParent() &&
555 pWin->GetParent()->GetType() == WindowType::TOOLBOX )
557 auto pParentAccContext = pWin->GetParent()->GetAccessible()->getAccessibleContext();
575 VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
581 switch ( rVclWindowEvent.
GetId() )
583 case VclEventId::WindowShow:
587 NotifyAccessibleEvent( AccessibleEventId::CHILD,
Any(),
Any(xReturn) );
594 VCLXAccessibleComponent::ProcessWindowChildEvent( rVclWindowEvent );
602 VCLXAccessibleComponent::disposing();
616 return "com.sun.star.comp.toolkit.AccessibleToolBox";
622 Sequence<OUString>{
"com.sun.star.accessibility.AccessibleToolBox"});
637 nCount = pToolBox->GetItemCount();
648 throw IndexOutOfBoundsException();
656 ToolBoxItemId nHighlightItemId = pToolBox->GetHighlightItemId();
657 vcl::Window* pItemWindow = pToolBox->GetItemWindow( nItemId );
660 Reference< XAccessible> xParent = pChild;
663 xChild =
new OToolBoxWindowItem(0,::comphelper::getProcessComponentContext(),pItemWindow->
GetAccessible(),xParent);
665 pChild->SetChild( xChild );
668 if ( nHighlightItemId >
ToolBoxItemId(0) && nItemId == nHighlightItemId )
669 pChild->SetFocus(
true );
670 if ( pToolBox->IsItemChecked( nItemId ) )
671 pChild->SetChecked(
true );
673 pChild->SetIndeterminate(
true );
679 xChild = aIter->second;
692 ToolBox::ImplToolItems::size_type nItemPos = pToolBox->GetItemPos(
VCLPoint( _rPoint ) );
705 if ( pChildWindow && pToolBox )
707 ToolBox::ImplToolItems::size_type
nCount = pToolBox->GetItemCount();
708 for (ToolBox::ImplToolItems::size_type
i = 0 ;
i <
nCount && !xReturn.is() ; ++
i)
711 vcl::Window* pItemWindow = pToolBox->GetItemWindow( nItemId );
712 if ( pItemWindow == pChildWindow )
724 xReturn = VCLXAccessibleComponent::GetChildAccessible(rVclWindowEvent);
731 OExternalLockGuard aGuard(
this );
734 if ( (!pToolBox) || nChildIndex < 0 ||
o3tl::make_unsigned(nChildIndex) >= pToolBox->GetItemCount() )
735 throw IndexOutOfBoundsException();
737 pToolBox->ChangeHighlight( nChildIndex );
742 OExternalLockGuard aGuard(
this );
744 if ( (!pToolBox) || nChildIndex < 0 ||
o3tl::make_unsigned(nChildIndex) >= pToolBox->GetItemCount() )
745 throw IndexOutOfBoundsException();
747 if ( pToolBox->GetHighlightItemId() == pToolBox->GetItemId( nChildIndex ) )
755 OExternalLockGuard aGuard(
this );
762 OExternalLockGuard aGuard(
this );
768 OExternalLockGuard aGuard(
this );
774 ToolBoxItemId nHighlightItemId = pToolBox->GetHighlightItemId();
775 for (
size_t i = 0,
nCount = pToolBox->GetItemCount();
i <
nCount;
i++ )
777 if ( nHighlightItemId == pToolBox->GetItemId(
i ) )
790 OExternalLockGuard aGuard(
this );
791 if ( nSelectedChildIndex != 0 )
792 throw IndexOutOfBoundsException();
798 ToolBoxItemId nHighlightItemId = pToolBox->GetHighlightItemId();
799 for (ToolBox::ImplToolItems::size_type
i = 0,
nCount = pToolBox->GetItemCount();
i <
nCount;
i++ )
801 if ( nHighlightItemId == pToolBox->GetItemId(
i ) )
810 throw IndexOutOfBoundsException();
817 OExternalLockGuard aGuard(
this );
819 throw IndexOutOfBoundsException();
reference_type * get() const
vcl::Window * GetParent() const
WindowType GetType() const
void SetAccessible(const css::uno::Reference< css::accessibility::XAccessible > &)
css::uno::Reference< css::accessibility::XAccessible > GetAccessible(bool bCreate=true)
inline ::Point VCLPoint(const css::awt::Point &rAWTPoint)
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)