sw/source/core/access/accpara.cxx | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
New commits: commit 4af3c5c7374cef5b39e3501e39c090514132b276 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Apr 24 10:44:55 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Apr 25 07:29:00 2025 +0200 sw a11y: Switch OSL_ENSURE to assert and drop fallback path Switch the OSL_ENSURE about `pFrame` being non-null to an assert, and drop the fallback path handling the null case in SwAccessibleParagraph::UpdatePortionData. In both callers of the method, `m_pPortionData` gets dereferenced afterwards (either directly or by calling SwAccessibleParagraph::GetPortionData), so the fallback path wasn't a safe one anyway. Also switch the OSL_ENSURE about the frame being a text frame to an assert. Drop the OSL_ASSERT about `m_pPortionData` being non-null at the end of the method, as that would only have been relevant for the fallback path. Change-Id: Ib570f609f355d12f9836ad397338225f72484655 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184550 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index 90b4b291c40b..5fb9344b32c8 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -385,18 +385,12 @@ void SwAccessibleParagraph::UpdatePortionData() { // obtain the text frame const SwTextFrame* pFrame = GetTextFrame(); - OSL_ENSURE( pFrame != nullptr, "The text frame has vanished!" ); - if (!pFrame) - ClearPortionData(); - else - { - OSL_ENSURE( pFrame->IsTextFrame(), "The text frame has mutated!" ); - // build new portion data - m_pPortionData.reset( new SwAccessiblePortionData( - pFrame, GetMap()->GetShell().GetViewOptions()) ); - pFrame->VisitPortions( *m_pPortionData ); - } - OSL_ENSURE( m_pPortionData != nullptr, "UpdatePortionData() failed" ); + assert(pFrame && "The text frame has vanished!"); + assert(pFrame->IsTextFrame() && "The text frame has mutated!"); + // build new portion data + m_pPortionData.reset( + new SwAccessiblePortionData(pFrame, GetMap()->GetShell().GetViewOptions())); + pFrame->VisitPortions(*m_pPortionData); } void SwAccessibleParagraph::ClearPortionData() commit dc17bf7ef685681af90845f58fe25476a5e25948 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Apr 24 10:28:39 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Apr 25 07:28:51 2025 +0200 sw a11y: Only get win if necessary There's no need to do so if `nOld == nNew`, so move it below that check + potential return. Change-Id: I113971ec2fcf84567621f29aae11c3a51bfabb21 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184549 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index a5e51a557ac0..90b4b291c40b 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -303,11 +303,11 @@ void SwAccessibleParagraph::InvalidateCursorPos_() GetMap()->SetCursorContext(this); } - vcl::Window *pWin = GetWindow(); if( nOld == nNew ) return; // The cursor's node position is simulated by the focus! + vcl::Window* pWin = GetWindow(); if( pWin && pWin->HasFocus() && -1 == nOld ) FireStateChangedEvent( AccessibleStateType::FOCUSED, true );