Kaydet (Commit) 0c2beb9e authored tarafından Arnaud Versini's avatar Arnaud Versini Kaydeden (comit) Noel Grandin

accessibility : remove useless guards and simplify.

Change-Id: I9e0d5967f71b2bd822c64690f8e02a0c95c8b88f
Reviewed-on: https://gerrit.libreoffice.org/52581Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst c0af8057
...@@ -44,6 +44,8 @@ private: ...@@ -44,6 +44,8 @@ private:
virtual ~VCLXAccessibleCheckBox() override = default; virtual ~VCLXAccessibleCheckBox() override = default;
sal_Int32 implGetMaximumValue();
bool IsChecked(); bool IsChecked();
bool IsIndeterminate(); bool IsIndeterminate();
......
...@@ -46,6 +46,7 @@ private: ...@@ -46,6 +46,7 @@ private:
virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override;
virtual void FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) override; virtual void FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) override;
sal_Int16 implGetAccessibleRole();
// OCommonAccessibleText // OCommonAccessibleText
virtual OUString implGetText() override; virtual OUString implGetText() override;
......
...@@ -92,7 +92,7 @@ public: ...@@ -92,7 +92,7 @@ public:
getAccessibleContext() override; getAccessibleContext() override;
// XAccessibleContext // XAccessibleContext
virtual sal_Int32 SAL_CALL getAccessibleChildCount() override; virtual sal_Int32 SAL_CALL getAccessibleChildCount() override final;
css::uno::Reference< css::accessibility::XAccessible> SAL_CALL css::uno::Reference< css::accessibility::XAccessible> SAL_CALL
getAccessibleChild (sal_Int32 i) override; getAccessibleChild (sal_Int32 i) override;
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
...@@ -144,6 +144,8 @@ private: ...@@ -144,6 +144,8 @@ private:
virtual ~VCLXAccessibleList() override = default; virtual ~VCLXAccessibleList() override = default;
sal_Int32 implGetAccessibleChildCount();
/** This function is called from the implementation helper during a /** This function is called from the implementation helper during a
XComponent::dispose call. Free the list of items and the items themselves. XComponent::dispose call. Free the list of items and the items themselves.
*/ */
......
...@@ -44,6 +44,10 @@ private: ...@@ -44,6 +44,10 @@ private:
AccessibleChildren m_aAccessibleChildren; AccessibleChildren m_aAccessibleChildren;
VclPtr<TabControl> m_pTabControl; VclPtr<TabControl> m_pTabControl;
css::uno::Reference< css::accessibility::XAccessible > implGetAccessibleChild( sal_Int32 i );
bool implIsAccessibleChildSelected( sal_Int32 nChildIndex );
void UpdateFocused(); void UpdateFocused();
void UpdateSelected( sal_Int32 i, bool bSelected ); void UpdateSelected( sal_Int32 i, bool bSelected );
void UpdatePageText( sal_Int32 i ); void UpdatePageText( sal_Int32 i );
......
...@@ -55,6 +55,8 @@ private: ...@@ -55,6 +55,8 @@ private:
bool m_bSelected; bool m_bSelected;
OUString m_sPageText; OUString m_sPageText;
sal_Int32 implGetAccessibleChildCount();
bool IsFocused(); bool IsFocused();
bool IsSelected(); bool IsSelected();
......
...@@ -53,6 +53,8 @@ private: ...@@ -53,6 +53,8 @@ private:
void UpdateCustomPopupItemp_Impl( vcl::Window* pWindow, bool bOpen ); void UpdateCustomPopupItemp_Impl( vcl::Window* pWindow, bool bOpen );
void HandleSubToolBarEvent( const VclWindowEvent& rVclWindowEvent ); void HandleSubToolBarEvent( const VclWindowEvent& rVclWindowEvent );
void ReleaseSubToolBox( ToolBox* _pSubToolBox ); void ReleaseSubToolBox( ToolBox* _pSubToolBox );
sal_Int32 implGetAccessibleChildCount();
sal_Int32 implGetSelectedAccessibleChildCount();
virtual ~VCLXAccessibleToolBox() override; virtual ~VCLXAccessibleToolBox() override;
......
...@@ -128,8 +128,6 @@ Sequence< OUString > VCLXAccessibleButton::getSupportedServiceNames() ...@@ -128,8 +128,6 @@ Sequence< OUString > VCLXAccessibleButton::getSupportedServiceNames()
OUString VCLXAccessibleButton::getAccessibleName( ) OUString VCLXAccessibleButton::getAccessibleName( )
{ {
OExternalLockGuard aGuard( this );
OUString aName( VCLXAccessibleTextComponent::getAccessibleName() ); OUString aName( VCLXAccessibleTextComponent::getAccessibleName() );
sal_Int32 nLength = aName.getLength(); sal_Int32 nLength = aName.getLength();
......
...@@ -285,8 +285,7 @@ sal_Bool VCLXAccessibleCheckBox::setCurrentValue( const Any& aNumber ) ...@@ -285,8 +285,7 @@ sal_Bool VCLXAccessibleCheckBox::setCurrentValue( const Any& aNumber )
{ {
sal_Int32 nValue = 0, nValueMin = 0, nValueMax = 0; sal_Int32 nValue = 0, nValueMin = 0, nValueMax = 0;
OSL_VERIFY( aNumber >>= nValue ); OSL_VERIFY( aNumber >>= nValue );
OSL_VERIFY( getMinimumValue() >>= nValueMin ); nValueMax=implGetMaximumValue();
OSL_VERIFY( getMaximumValue() >>= nValueMax );
if ( nValue < nValueMin ) if ( nValue < nValueMin )
nValue = nValueMin; nValue = nValueMin;
...@@ -306,17 +305,20 @@ Any VCLXAccessibleCheckBox::getMaximumValue( ) ...@@ -306,17 +305,20 @@ Any VCLXAccessibleCheckBox::getMaximumValue( )
OExternalLockGuard aGuard( this ); OExternalLockGuard aGuard( this );
Any aValue; Any aValue;
aValue <<= implGetMaximumValue();
return aValue;
}
sal_Int32 VCLXAccessibleCheckBox::implGetMaximumValue( )
{
VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >(); VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
if ( pCheckBox && pCheckBox->IsTriStateEnabled() ) if ( pCheckBox && pCheckBox->IsTriStateEnabled() )
aValue <<= sal_Int32(2); return 2;
else
aValue <<= sal_Int32(1);
return aValue; return 1;
} }
Any VCLXAccessibleCheckBox::getMinimumValue( ) Any VCLXAccessibleCheckBox::getMinimumValue( )
{ {
OExternalLockGuard aGuard( this ); OExternalLockGuard aGuard( this );
......
...@@ -132,7 +132,7 @@ OUString VCLXAccessibleEdit::implGetText() ...@@ -132,7 +132,7 @@ OUString VCLXAccessibleEdit::implGetText()
{ {
aText = OutputDevice::GetNonMnemonicString( pEdit->GetText() ); aText = OutputDevice::GetNonMnemonicString( pEdit->GetText() );
if ( getAccessibleRole() == AccessibleRole::PASSWORD_TEXT ) if ( implGetAccessibleRole() == AccessibleRole::PASSWORD_TEXT )
{ {
sal_Unicode cEchoChar = pEdit->GetEchoChar(); sal_Unicode cEchoChar = pEdit->GetEchoChar();
if ( !cEchoChar ) if ( !cEchoChar )
...@@ -197,14 +197,9 @@ sal_Int32 VCLXAccessibleEdit::getAccessibleChildCount() ...@@ -197,14 +197,9 @@ sal_Int32 VCLXAccessibleEdit::getAccessibleChildCount()
} }
Reference< XAccessible > VCLXAccessibleEdit::getAccessibleChild( sal_Int32 i ) Reference< XAccessible > VCLXAccessibleEdit::getAccessibleChild( sal_Int32 )
{ {
OExternalLockGuard aGuard( this ); throw IndexOutOfBoundsException();
if ( i < 0 || i >= getAccessibleChildCount() )
throw IndexOutOfBoundsException();
return Reference< XAccessible >();
} }
...@@ -212,6 +207,11 @@ sal_Int16 VCLXAccessibleEdit::getAccessibleRole( ) ...@@ -212,6 +207,11 @@ sal_Int16 VCLXAccessibleEdit::getAccessibleRole( )
{ {
OExternalLockGuard aGuard( this ); OExternalLockGuard aGuard( this );
return implGetAccessibleRole();
}
sal_Int16 VCLXAccessibleEdit::implGetAccessibleRole( )
{
sal_Int16 nRole; sal_Int16 nRole;
VclPtr< Edit > pEdit = GetAs< Edit >(); VclPtr< Edit > pEdit = GetAs< Edit >();
if ( pEdit && ( ( pEdit->GetStyle() & WB_PASSWORD ) || pEdit->GetEchoChar() ) ) if ( pEdit && ( ( pEdit->GetStyle() & WB_PASSWORD ) || pEdit->GetEchoChar() ) )
......
...@@ -525,7 +525,11 @@ sal_Int32 SAL_CALL VCLXAccessibleList::getAccessibleChildCount() ...@@ -525,7 +525,11 @@ sal_Int32 SAL_CALL VCLXAccessibleList::getAccessibleChildCount()
{ {
SolarMutexGuard aSolarGuard; SolarMutexGuard aSolarGuard;
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
return implGetAccessibleChildCount();
}
sal_Int32 VCLXAccessibleList::implGetAccessibleChildCount()
{
sal_Int32 nCount = 0; sal_Int32 nCount = 0;
if ( m_pListBoxHelper ) if ( m_pListBoxHelper )
nCount = m_pListBoxHelper->GetEntryCount(); nCount = m_pListBoxHelper->GetEntryCount();
......
...@@ -355,9 +355,14 @@ Reference< XAccessible > VCLXAccessibleTabControl::getAccessibleChild( sal_Int32 ...@@ -355,9 +355,14 @@ Reference< XAccessible > VCLXAccessibleTabControl::getAccessibleChild( sal_Int32
{ {
OExternalLockGuard aGuard( this ); OExternalLockGuard aGuard( this );
if ( i < 0 || i >= getAccessibleChildCount() ) if ( i < 0 || static_cast<std::size_t>(i) >= m_aAccessibleChildren.size() )
throw IndexOutOfBoundsException(); throw IndexOutOfBoundsException();
return implGetAccessibleChild( i );
}
Reference< XAccessible > VCLXAccessibleTabControl::implGetAccessibleChild( sal_Int32 i )
{
Reference< XAccessible > xChild = m_aAccessibleChildren[i]; Reference< XAccessible > xChild = m_aAccessibleChildren[i];
if ( !xChild.is() ) if ( !xChild.is() )
{ {
...@@ -398,7 +403,7 @@ void VCLXAccessibleTabControl::selectAccessibleChild( sal_Int32 nChildIndex ) ...@@ -398,7 +403,7 @@ void VCLXAccessibleTabControl::selectAccessibleChild( sal_Int32 nChildIndex )
{ {
OExternalLockGuard aGuard( this ); OExternalLockGuard aGuard( this );
if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() ) if ( nChildIndex < 0 || static_cast<std::size_t>(nChildIndex) >= m_aAccessibleChildren.size() )
throw IndexOutOfBoundsException(); throw IndexOutOfBoundsException();
if ( m_pTabControl ) if ( m_pTabControl )
...@@ -410,9 +415,14 @@ sal_Bool VCLXAccessibleTabControl::isAccessibleChildSelected( sal_Int32 nChildIn ...@@ -410,9 +415,14 @@ sal_Bool VCLXAccessibleTabControl::isAccessibleChildSelected( sal_Int32 nChildIn
{ {
OExternalLockGuard aGuard( this ); OExternalLockGuard aGuard( this );
if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() ) if ( nChildIndex < 0 || static_cast<std::size_t>(nChildIndex) >= m_aAccessibleChildren.size() )
throw IndexOutOfBoundsException(); throw IndexOutOfBoundsException();
return implIsAccessibleChildSelected( nChildIndex );
}
bool VCLXAccessibleTabControl::implIsAccessibleChildSelected( sal_Int32 nChildIndex )
{
bool bSelected = false; bool bSelected = false;
if ( m_pTabControl && m_pTabControl->GetCurPageId() == m_pTabControl->GetPageId( static_cast<sal_uInt16>(nChildIndex) ) ) if ( m_pTabControl && m_pTabControl->GetCurPageId() == m_pTabControl->GetPageId( static_cast<sal_uInt16>(nChildIndex) ) )
bSelected = true; bSelected = true;
...@@ -429,8 +439,6 @@ void VCLXAccessibleTabControl::clearAccessibleSelection( ) ...@@ -429,8 +439,6 @@ void VCLXAccessibleTabControl::clearAccessibleSelection( )
void VCLXAccessibleTabControl::selectAllAccessibleChildren( ) void VCLXAccessibleTabControl::selectAllAccessibleChildren( )
{ {
OExternalLockGuard aGuard( this );
selectAccessibleChild( 0 ); selectAccessibleChild( 0 );
} }
...@@ -447,16 +455,16 @@ Reference< XAccessible > VCLXAccessibleTabControl::getSelectedAccessibleChild( s ...@@ -447,16 +455,16 @@ Reference< XAccessible > VCLXAccessibleTabControl::getSelectedAccessibleChild( s
{ {
OExternalLockGuard aGuard( this ); OExternalLockGuard aGuard( this );
if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() ) if ( nSelectedChildIndex != 0 )
throw IndexOutOfBoundsException(); throw IndexOutOfBoundsException();
Reference< XAccessible > xChild; Reference< XAccessible > xChild;
for ( sal_Int32 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; i++ ) for ( std::size_t i = 0, nCount = m_aAccessibleChildren.size(); i < nCount; i++ )
{ {
if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) ) if ( implIsAccessibleChildSelected( i ) )
{ {
xChild = getAccessibleChild( i ); xChild = implGetAccessibleChild( i );
break; break;
} }
} }
...@@ -469,7 +477,7 @@ void VCLXAccessibleTabControl::deselectAccessibleChild( sal_Int32 nChildIndex ) ...@@ -469,7 +477,7 @@ void VCLXAccessibleTabControl::deselectAccessibleChild( sal_Int32 nChildIndex )
{ {
OExternalLockGuard aGuard( this ); OExternalLockGuard aGuard( this );
if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() ) if ( nChildIndex < 0 || static_cast<std::size_t>(nChildIndex) >= m_aAccessibleChildren.size() )
throw IndexOutOfBoundsException(); throw IndexOutOfBoundsException();
// This method makes no sense in a tab control, and so does nothing. // This method makes no sense in a tab control, and so does nothing.
......
...@@ -280,7 +280,11 @@ Reference< XAccessibleContext > VCLXAccessibleTabPage::getAccessibleContext( ) ...@@ -280,7 +280,11 @@ Reference< XAccessibleContext > VCLXAccessibleTabPage::getAccessibleContext( )
sal_Int32 VCLXAccessibleTabPage::getAccessibleChildCount() sal_Int32 VCLXAccessibleTabPage::getAccessibleChildCount()
{ {
OExternalLockGuard aGuard( this ); OExternalLockGuard aGuard( this );
return implGetAccessibleChildCount();
}
sal_Int32 VCLXAccessibleTabPage::implGetAccessibleChildCount()
{
sal_Int32 nCount = 0; sal_Int32 nCount = 0;
if ( m_pTabControl ) if ( m_pTabControl )
{ {
...@@ -297,7 +301,7 @@ Reference< XAccessible > VCLXAccessibleTabPage::getAccessibleChild( sal_Int32 i ...@@ -297,7 +301,7 @@ Reference< XAccessible > VCLXAccessibleTabPage::getAccessibleChild( sal_Int32 i
{ {
OExternalLockGuard aGuard( this ); OExternalLockGuard aGuard( this );
if ( i < 0 || i >= getAccessibleChildCount() ) if ( i < 0 || i >= implGetAccessibleChildCount() )
throw IndexOutOfBoundsException(); throw IndexOutOfBoundsException();
Reference< XAccessible > xChild; Reference< XAccessible > xChild;
......
...@@ -144,8 +144,6 @@ sal_Int32 VCLXAccessibleTextComponent::getCaretPosition() ...@@ -144,8 +144,6 @@ sal_Int32 VCLXAccessibleTextComponent::getCaretPosition()
sal_Bool VCLXAccessibleTextComponent::setCaretPosition( sal_Int32 nIndex ) sal_Bool VCLXAccessibleTextComponent::setCaretPosition( sal_Int32 nIndex )
{ {
OExternalLockGuard aGuard( this );
return setSelection( nIndex, nIndex ); return setSelection( nIndex, nIndex );
} }
...@@ -357,7 +355,7 @@ sal_Bool VCLXAccessibleTextComponent::copyText( sal_Int32 nStartIndex, sal_Int32 ...@@ -357,7 +355,7 @@ sal_Bool VCLXAccessibleTextComponent::copyText( sal_Int32 nStartIndex, sal_Int32
Reference< datatransfer::clipboard::XClipboard > xClipboard = pWindow->GetClipboard(); Reference< datatransfer::clipboard::XClipboard > xClipboard = pWindow->GetClipboard();
if ( xClipboard.is() ) if ( xClipboard.is() )
{ {
OUString sText( getTextRange( nStartIndex, nEndIndex ) ); OUString sText( OCommonAccessibleText::implGetTextRange( implGetText(), nStartIndex, nEndIndex ) );
vcl::unohelper::TextDataObject* pDataObj = new vcl::unohelper::TextDataObject( sText ); vcl::unohelper::TextDataObject* pDataObj = new vcl::unohelper::TextDataObject( sText );
......
...@@ -694,7 +694,11 @@ Sequence< OUString > VCLXAccessibleToolBox::getSupportedServiceNames() ...@@ -694,7 +694,11 @@ Sequence< OUString > VCLXAccessibleToolBox::getSupportedServiceNames()
sal_Int32 SAL_CALL VCLXAccessibleToolBox::getAccessibleChildCount( ) sal_Int32 SAL_CALL VCLXAccessibleToolBox::getAccessibleChildCount( )
{ {
comphelper::OExternalLockGuard aGuard( this ); comphelper::OExternalLockGuard aGuard( this );
return implGetAccessibleChildCount();
}
sal_Int32 VCLXAccessibleToolBox::implGetAccessibleChildCount( )
{
sal_Int32 nCount = 0; sal_Int32 nCount = 0;
VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); VclPtr< ToolBox > pToolBox = GetAs< ToolBox >();
if ( pToolBox ) if ( pToolBox )
...@@ -706,49 +710,44 @@ sal_Int32 SAL_CALL VCLXAccessibleToolBox::getAccessibleChildCount( ) ...@@ -706,49 +710,44 @@ sal_Int32 SAL_CALL VCLXAccessibleToolBox::getAccessibleChildCount( )
Reference< XAccessible > SAL_CALL VCLXAccessibleToolBox::getAccessibleChild( sal_Int32 i ) Reference< XAccessible > SAL_CALL VCLXAccessibleToolBox::getAccessibleChild( sal_Int32 i )
{ {
if ( i < 0 || i >= getAccessibleChildCount() )
throw IndexOutOfBoundsException();
comphelper::OExternalLockGuard aGuard( this ); comphelper::OExternalLockGuard aGuard( this );
VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); VclPtr< ToolBox > pToolBox = GetAs< ToolBox >();
if ( pToolBox ) if ( (!pToolBox) || i < 0 || static_cast<size_t>(i) >= pToolBox->GetItemCount() )
throw IndexOutOfBoundsException();
Reference< XAccessible > xChild;
// search for the child
ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find(i);
if ( m_aAccessibleChildren.end() == aIter )
{ {
Reference< XAccessible > xChild; sal_uInt16 nItemId = pToolBox->GetItemId( i );
// search for the child sal_uInt16 nHighlightItemId = pToolBox->GetHighlightItemId();
ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find(i); vcl::Window* pItemWindow = pToolBox->GetItemWindow( nItemId );
if ( m_aAccessibleChildren.end() == aIter ) // not found -> create a new child
{ VCLXAccessibleToolBoxItem* pChild = new VCLXAccessibleToolBoxItem( pToolBox, i );
sal_uInt16 nItemId = pToolBox->GetItemId( i ); Reference< XAccessible> xParent = pChild;
sal_uInt16 nHighlightItemId = pToolBox->GetHighlightItemId(); if ( pItemWindow )
vcl::Window* pItemWindow = pToolBox->GetItemWindow( nItemId );
// not found -> create a new child
VCLXAccessibleToolBoxItem* pChild = new VCLXAccessibleToolBoxItem( pToolBox, i );
Reference< XAccessible> xParent = pChild;
if ( pItemWindow )
{
xChild = new OToolBoxWindowItem(0,::comphelper::getProcessComponentContext(),pItemWindow->GetAccessible(),xParent);
pItemWindow->SetAccessible(xChild);
pChild->SetChild( xChild );
}
xChild = pChild;
if ( nHighlightItemId > 0 && nItemId == nHighlightItemId )
pChild->SetFocus( true );
if ( pToolBox->IsItemChecked( nItemId ) )
pChild->SetChecked( true );
if ( pToolBox->GetItemState( nItemId ) == TRISTATE_INDET )
pChild->SetIndeterminate( true );
m_aAccessibleChildren.emplace( i, xChild );
}
else
{ {
// found it xChild = new OToolBoxWindowItem(0,::comphelper::getProcessComponentContext(),pItemWindow->GetAccessible(),xParent);
xChild = aIter->second; pItemWindow->SetAccessible(xChild);
pChild->SetChild( xChild );
} }
return xChild; xChild = pChild;
if ( nHighlightItemId > 0 && nItemId == nHighlightItemId )
pChild->SetFocus( true );
if ( pToolBox->IsItemChecked( nItemId ) )
pChild->SetChecked( true );
if ( pToolBox->GetItemState( nItemId ) == TRISTATE_INDET )
pChild->SetIndeterminate( true );
m_aAccessibleChildren.emplace( i, xChild );
} }
else
return nullptr; {
// found it
xChild = aIter->second;
}
return xChild;
} }
Reference< XAccessible > SAL_CALL VCLXAccessibleToolBox::getAccessibleAtPoint( const awt::Point& _rPoint ) Reference< XAccessible > SAL_CALL VCLXAccessibleToolBox::getAccessibleAtPoint( const awt::Point& _rPoint )
...@@ -801,19 +800,22 @@ Reference< XAccessible > VCLXAccessibleToolBox::GetChildAccessible( const VclWin ...@@ -801,19 +800,22 @@ Reference< XAccessible > VCLXAccessibleToolBox::GetChildAccessible( const VclWin
void VCLXAccessibleToolBox::selectAccessibleChild( sal_Int32 nChildIndex ) void VCLXAccessibleToolBox::selectAccessibleChild( sal_Int32 nChildIndex )
{ {
OExternalLockGuard aGuard( this ); OExternalLockGuard aGuard( this );
if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
throw IndexOutOfBoundsException();
VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); VclPtr< ToolBox > pToolBox = GetAs< ToolBox >();
if ( (!pToolBox) || nChildIndex < 0 || static_cast<size_t> (nChildIndex) >= pToolBox->GetItemCount() )
throw IndexOutOfBoundsException();
pToolBox->ChangeHighlight( nChildIndex ); pToolBox->ChangeHighlight( nChildIndex );
} }
sal_Bool VCLXAccessibleToolBox::isAccessibleChildSelected( sal_Int32 nChildIndex ) sal_Bool VCLXAccessibleToolBox::isAccessibleChildSelected( sal_Int32 nChildIndex )
{ {
OExternalLockGuard aGuard( this ); OExternalLockGuard aGuard( this );
if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
throw IndexOutOfBoundsException();
VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); VclPtr< ToolBox > pToolBox = GetAs< ToolBox >();
if ( pToolBox && pToolBox->GetHighlightItemId() == pToolBox->GetItemId( nChildIndex ) ) if ( (!pToolBox) || nChildIndex < 0 || static_cast<size_t>(nChildIndex) >= pToolBox->GetItemCount() )
throw IndexOutOfBoundsException();
if ( pToolBox->GetHighlightItemId() == pToolBox->GetItemId( nChildIndex ) )
return true; return true;
else else
return false; return false;
...@@ -835,8 +837,9 @@ void VCLXAccessibleToolBox::selectAllAccessibleChildren( ) ...@@ -835,8 +837,9 @@ void VCLXAccessibleToolBox::selectAllAccessibleChildren( )
sal_Int32 VCLXAccessibleToolBox::getSelectedAccessibleChildCount( ) sal_Int32 VCLXAccessibleToolBox::getSelectedAccessibleChildCount( )
{ {
OExternalLockGuard aGuard( this ); OExternalLockGuard aGuard( this );
sal_Int32 nRet = 0; sal_Int32 nRet = 0;
for ( sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; i++ ) for ( sal_Int32 i = 0, nCount = implGetAccessibleChildCount(); i < nCount; i++ )
{ {
if ( isAccessibleChildSelected( i ) ) if ( isAccessibleChildSelected( i ) )
{ {
...@@ -850,24 +853,28 @@ sal_Int32 VCLXAccessibleToolBox::getSelectedAccessibleChildCount( ) ...@@ -850,24 +853,28 @@ sal_Int32 VCLXAccessibleToolBox::getSelectedAccessibleChildCount( )
Reference< XAccessible > VCLXAccessibleToolBox::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) Reference< XAccessible > VCLXAccessibleToolBox::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
{ {
OExternalLockGuard aGuard( this ); OExternalLockGuard aGuard( this );
if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() ) if ( nSelectedChildIndex != 0 )
throw IndexOutOfBoundsException(); throw IndexOutOfBoundsException();
Reference< XAccessible > xChild; Reference< XAccessible > xChild;
for ( sal_Int32 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; i++ ) for ( sal_Int32 i = 0, nCount = implGetAccessibleChildCount(); i < nCount; i++ )
{ {
if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) ) if ( isAccessibleChildSelected( i ) )
{ {
xChild = getAccessibleChild( i ); xChild = getAccessibleChild( i );
break; break;
} }
} }
if (!xChild)
throw IndexOutOfBoundsException();
return xChild; return xChild;
} }
void VCLXAccessibleToolBox::deselectAccessibleChild( sal_Int32 nChildIndex ) void VCLXAccessibleToolBox::deselectAccessibleChild( sal_Int32 nChildIndex )
{ {
OExternalLockGuard aGuard( this ); OExternalLockGuard aGuard( this );
if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() ) if ( nChildIndex < 0 || nChildIndex >= implGetAccessibleChildCount() )
throw IndexOutOfBoundsException(); throw IndexOutOfBoundsException();
clearAccessibleSelection(); // a toolbox can only have (n)one selected child clearAccessibleSelection(); // a toolbox can only have (n)one selected child
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment