diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-02-26 16:44:01 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-02-26 22:54:51 +0100 |
commit | c455fcd88f950c87c1588859100c1310122980fa (patch) | |
tree | c77708bf951f3a1e9a5a871a7c8de462e54e4f69 /accessibility | |
parent | 86dff3ca4e994f69bf9ba6656ac3e1164a29ca11 (diff) |
tdf#159910 a11y: Distinguish a11y name and text of toolbar item
So far, the accessible name and the text of the item
were considered to be the same, and fallbacks to still
get something else for the accessible name in case
of no item text (to use the quick help text or the item
window's accessible name instead) were implemented directly in
`VCLXAccessibleToolBoxItem::implGetText`.
However, `VCLXAccessibleToolBoxItem::implGetText` is also
used by the implementations for the methods from the
`XAccessibleText` interface and that one is clearly about
text displayed on screen, so using e.g. the quick help/tooltip
text doesn't make sense then.
Let `VCLXAccessibleToolBoxItem::implGetText` only handle the
actual item text and move the fallbacks to a new helper
method `VCLXAccessibleToolBoxItem::implGetAccessibleName`
instead that is only used when the actual accessible name
is wanted.
Change-Id: Icc394022d036ca619622cee1390e28ab15014be1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163959
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'accessibility')
-rw-r--r-- | accessibility/inc/standard/vclxaccessibletoolboxitem.hxx | 2 | ||||
-rw-r--r-- | accessibility/source/standard/vclxaccessibletoolboxitem.cxx | 43 |
2 files changed, 25 insertions, 20 deletions
diff --git a/accessibility/inc/standard/vclxaccessibletoolboxitem.hxx b/accessibility/inc/standard/vclxaccessibletoolboxitem.hxx index 9676762d54bb..4ba54023f163 100644 --- a/accessibility/inc/standard/vclxaccessibletoolboxitem.hxx +++ b/accessibility/inc/standard/vclxaccessibletoolboxitem.hxx @@ -56,6 +56,8 @@ public: void setIndexInParent( sal_Int32 _nNewIndex ) { m_nIndexInParent = _nNewIndex; } private: + OUString implGetAccessibleName(); + virtual ~VCLXAccessibleToolBoxItem() override; virtual void SAL_CALL disposing() override; diff --git a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx index f8545eacc422..d338ec78e045 100644 --- a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx +++ b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx @@ -69,7 +69,7 @@ VCLXAccessibleToolBoxItem::VCLXAccessibleToolBoxItem( ToolBox* _pToolBox, sal_In { assert( m_pToolBox ); m_nItemId = m_pToolBox->GetItemId( m_nIndexInParent ); - m_sOldName = implGetText(); + m_sOldName = implGetAccessibleName(); m_bIsChecked = m_pToolBox->IsItemChecked( m_nItemId ); m_bIndeterminate = ( m_pToolBox->GetItemState( m_nItemId ) == TRISTATE_INDET ); ToolBoxItemType eType = m_pToolBox->GetItemType( m_nIndexInParent ); @@ -162,7 +162,7 @@ void VCLXAccessibleToolBoxItem::SetIndeterminate( bool _bIndeterminate ) void VCLXAccessibleToolBoxItem::NameChanged() { - OUString sNewName = implGetText(); + OUString sNewName = implGetAccessibleName(); if ( sNewName != m_sOldName ) { Any aOldValue, aNewValue; @@ -219,21 +219,7 @@ OUString VCLXAccessibleToolBoxItem::implGetText() if (!m_pToolBox || m_nItemId <= ToolBoxItemId(0)) return OUString(); - OUString sRet = m_pToolBox->GetItemText( m_nItemId ); - if (!sRet.isEmpty()) - return sRet; - - sRet = m_pToolBox->GetQuickHelpText( m_nItemId ); - if (!sRet.isEmpty()) - return sRet; - - vcl::Window* pItemWindow = m_pToolBox->GetItemWindow( m_nItemId ); - if ( m_nRole == AccessibleRole::PANEL && pItemWindow && pItemWindow->GetAccessible().is() && - pItemWindow->GetAccessible()->getAccessibleContext().is() ) - { - sRet = pItemWindow->GetAccessible()->getAccessibleContext()->getAccessibleName(); - } - return sRet; + return m_pToolBox->GetItemText(m_nItemId); } Locale VCLXAccessibleToolBoxItem::implGetLocale() @@ -352,12 +338,29 @@ OUString SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleDescription( ) } } +OUString VCLXAccessibleToolBoxItem::implGetAccessibleName() +{ + OUString sRet = implGetText(); + if (!sRet.isEmpty()) + return sRet; + + sRet = m_pToolBox->GetQuickHelpText( m_nItemId ); + if (!sRet.isEmpty()) + return sRet; + + vcl::Window* pItemWindow = m_pToolBox->GetItemWindow( m_nItemId ); + if ( m_nRole == AccessibleRole::PANEL && pItemWindow && pItemWindow->GetAccessible().is() && + pItemWindow->GetAccessible()->getAccessibleContext().is() ) + { + sRet = pItemWindow->GetAccessible()->getAccessibleContext()->getAccessibleName(); + } + return sRet; +} + OUString SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleName( ) { OExternalLockGuard aGuard( this ); - - // entry text == accessible name - return implGetText(); + return implGetAccessibleName(); } Reference< XAccessibleRelationSet > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleRelationSet( ) |