From 7c4c9947b8e52ce67af1ab131ed583a41f0ddbfa Mon Sep 17 00:00:00 2001 From: Maxim Monastirsky Date: Thu, 27 Apr 2017 03:19:48 +0300 Subject: tdf#107458 No active item for the overflow subtoolbar Item id 0 has two meanings inside ToolBox. Methods like GetCurItemId and GetDownItemId use it as "no item". But that's also the id of a separator item, so calling GetItemPos(0) will find a separator, if the ToolBox has one. Change-Id: I4f2c1fac1759fe0a3ae09d317909707084e16180 --- accessibility/source/standard/vclxaccessibletoolbox.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'accessibility') diff --git a/accessibility/source/standard/vclxaccessibletoolbox.cxx b/accessibility/source/standard/vclxaccessibletoolbox.cxx index aa4cad63acb8..b8dd8e2436f4 100644 --- a/accessibility/source/standard/vclxaccessibletoolbox.cxx +++ b/accessibility/source/standard/vclxaccessibletoolbox.cxx @@ -421,8 +421,8 @@ void VCLXAccessibleToolBox::UpdateCustomPopupItemp_Impl( vcl::Window* pWindow, b { const sal_uInt16 nDownItem = pToolBox->GetDownItemId(); if ( !nDownItem ) - // Items with ItemId == 0 are not allowed in ToolBox, which means that currently no item is in down state. - // Moreover, running GetItemPos with 0 could find a separator item if there is any. + // No item is currently in down state. + // Moreover, calling GetItemPos with 0 will find a separator if there is any. return; Reference< XAccessible > xChild( pWindow->GetAccessible() ); @@ -461,7 +461,13 @@ void VCLXAccessibleToolBox::HandleSubToolBarEvent( const VclWindowEvent& rVclWin && pToolBox == pChildWindow->GetParent() && pChildWindow->GetType() == WindowType::TOOLBOX ) { - ToolBox::ImplToolItems::size_type nIndex = pToolBox->GetItemPos( pToolBox->GetCurItemId() ); + const sal_uInt16 nCurItemId( pToolBox->GetCurItemId() ); + if ( !nCurItemId ) + // No item is currently active (might happen when opening the overflow popup). + // Moreover, calling GetItemPos with 0 will find a separator if there is any. + return; + + ToolBox::ImplToolItems::size_type nIndex = pToolBox->GetItemPos( nCurItemId ); Reference< XAccessible > xItem = getAccessibleChild( nIndex ); //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32! if ( xItem.is() ) -- cgit v1.2.3