diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2025-01-14 10:23:43 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2025-01-15 10:09:59 +0100 |
commit | 104c099a77cb8b0cf2629204c7fcfc3e9ec9bb3b (patch) | |
tree | 9eddfa92cca92a2850a46ed59437672e034b9363 /sw | |
parent | 1367092fa695456c430b5d1a63dd890382b58ccf (diff) |
sw a11y: Flatten SwAccessibleSelectionHelper::getSelectedAccessibleChildCount
Change-Id: Idb66fa1728fd9bea6cd9cff639ea7f1056ae6118
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180229
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/access/accselectionhelper.cxx | 66 |
1 files changed, 32 insertions, 34 deletions
diff --git a/sw/source/core/access/accselectionhelper.cxx b/sw/source/core/access/accselectionhelper.cxx index ef119047b41d..1e28a253c019 100644 --- a/sw/source/core/access/accselectionhelper.cxx +++ b/sw/source/core/access/accselectionhelper.cxx @@ -193,47 +193,45 @@ sal_Int64 SwAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) { SolarMutexGuard aGuard; - sal_Int64 nCount = 0; + const SwFEShell* pFEShell = GetFEShell(); + if (!pFEShell) + return 0; + // Only one frame can be selected at a time, and we only frames // for selectable children. - if (const SwFEShell* pFEShell = GetFEShell()) + const SwFlyFrame* pFlyFrame = pFEShell->GetSelectedFlyFrame(); + if ( pFlyFrame ) + return 1; + + sal_Int64 nCount = 0; + const size_t nSelObjs = pFEShell->GetSelectedObjCount(); + if( nSelObjs > 0 ) { - const SwFlyFrame* pFlyFrame = pFEShell->GetSelectedFlyFrame(); - if( pFlyFrame ) - { - nCount = 1; - } - else + std::list< SwAccessibleChild > aChildren; + m_rContext.GetChildren( *(m_rContext.GetMap()), aChildren ); + + for( const SwAccessibleChild& rChild : aChildren ) { - const size_t nSelObjs = pFEShell->GetSelectedObjCount(); - if( nSelObjs > 0 ) + if( rChild.GetDrawObject() && !rChild.GetSwFrame() && + SwAccessibleFrame::GetParent(rChild, m_rContext.IsInPagePreview()) + == m_rContext.GetFrame() && + pFEShell->IsObjSelected( *rChild.GetDrawObject() ) ) { - std::list< SwAccessibleChild > aChildren; - m_rContext.GetChildren( *(m_rContext.GetMap()), aChildren ); - - for( const SwAccessibleChild& rChild : aChildren ) - { - if( rChild.GetDrawObject() && !rChild.GetSwFrame() && - SwAccessibleFrame::GetParent(rChild, m_rContext.IsInPagePreview()) - == m_rContext.GetFrame() && - pFEShell->IsObjSelected( *rChild.GetDrawObject() ) ) - { - nCount++; - } - if (o3tl::make_unsigned(nCount) >= nSelObjs) - break; - } + nCount++; } + if (o3tl::make_unsigned(nCount) >= nSelObjs) + break; } - //If the SwFrameOrObj is not selected directly in the UI, - //we should check whether it is selected in the selection cursor. - if( nCount == 0 ) - { - std::list< SwAccessibleChild > aChildren; - m_rContext.GetChildren( *(m_rContext.GetMap()), aChildren ); - nCount = static_cast<sal_Int32>(std::count_if(aChildren.begin(), aChildren.end(), - [this](const SwAccessibleChild& aChild) { return lcl_getSelectedState(aChild, &m_rContext, m_rContext.GetMap()); })); - } + } + + //If the SwFrameOrObj is not selected directly in the UI, + //we should check whether it is selected in the selection cursor. + if( nCount == 0 ) + { + std::list< SwAccessibleChild > aChildren; + m_rContext.GetChildren( *(m_rContext.GetMap()), aChildren ); + nCount = static_cast<sal_Int32>(std::count_if(aChildren.begin(), aChildren.end(), + [this](const SwAccessibleChild& aChild) { return lcl_getSelectedState(aChild, &m_rContext, m_rContext.GetMap()); })); } return nCount; } |