accessibility/source/standard/vclxaccessibletoolboxitem.cxx | 34 +++++------- 1 file changed, 15 insertions(+), 19 deletions(-)
New commits: commit 492a683c70d98d005bcb472770be33d3277499d7 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Mon Feb 26 15:13:19 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Mon Feb 26 22:37:34 2024 +0100 tdf#159910 a11y: Slightly simplify VCLXAccessibleToolBoxItem::GetText * Avoid deep nesting by returning non-empty value right away. * Drop the `if (!sWinText.isEmpty())` before the last assignment. At this point, `sRet` is already empty, so reassigning an empty string makes no difference. Change-Id: Ib17e363f761e3ce09b359cebb1599042a8f6b8bb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163956 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx index 3b6bad772162..63ec17cdff7c 100644 --- a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx +++ b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx @@ -116,27 +116,23 @@ VCLXAccessibleToolBoxItem::~VCLXAccessibleToolBoxItem() OUString VCLXAccessibleToolBoxItem::GetText() const { - OUString sRet; // no text for separators and spaces - if ( m_pToolBox && m_nItemId > ToolBoxItemId(0) ) - { - sRet = m_pToolBox->GetItemText( m_nItemId ); - if (sRet.isEmpty()) - { - sRet = m_pToolBox->GetQuickHelpText( m_nItemId ); - if (sRet.isEmpty()) - { - vcl::Window* pItemWindow = m_pToolBox->GetItemWindow( m_nItemId ); - if ( m_nRole == AccessibleRole::PANEL && pItemWindow && pItemWindow->GetAccessible().is() && - pItemWindow->GetAccessible()->getAccessibleContext().is() ) - { - OUString sWinText = pItemWindow->GetAccessible()->getAccessibleContext()->getAccessibleName(); - if (!sWinText.isEmpty()) - sRet = sWinText; - } - } - } + 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; }