diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-02-26 15:13:19 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-02-26 22:37:34 +0100 |
commit | 492a683c70d98d005bcb472770be33d3277499d7 (patch) | |
tree | fda70630464b269ff0095eaff8acf759c4fd59a9 /accessibility | |
parent | bd3dc6fc18a6360929e3427abccc572950d0aa8e (diff) |
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.weghorn@posteo.de>
Diffstat (limited to 'accessibility')
-rw-r--r-- | accessibility/source/standard/vclxaccessibletoolboxitem.cxx | 34 |
1 files changed, 15 insertions, 19 deletions
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; } |