sw/source/core/access/accpara.cxx | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-)
New commits: commit cc4edd9d4b6db142db21d20390d86cb1982054d7 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Aug 8 14:14:40 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Aug 9 07:01:08 2024 +0200 sw: Return early in SwAccessibleParagraph::getHyperLink Reduce scope of `xRet` and return early for the case there is a hyperlink, to simplify this a little bit. Change-Id: Ia9a4a63bbeb1583d798e7521d236220822c5bbe0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171629 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 9abcf83e77d6..b49211d23d10 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -2823,8 +2823,6 @@ uno::Reference< XAccessibleHyperlink > SAL_CALL ThrowIfDisposed(); - uno::Reference< XAccessibleHyperlink > xRet; - const SwTextFrame *pTextFrame = static_cast<const SwTextFrame*>( GetFrame() ); SwHyperlinkIter_Impl aHIter(*pTextFrame); SwTextNode const* pNode(nullptr); @@ -2833,6 +2831,7 @@ uno::Reference< XAccessibleHyperlink > SAL_CALL { if( nTIndex == nLinkIndex ) { // found + uno::Reference<XAccessibleHyperlink> xRet; if (!m_pHyperTextData) m_pHyperTextData.reset( new SwAccessibleHyperTextData ); SwAccessibleHyperTextData::iterator aIter = @@ -2860,16 +2859,14 @@ uno::Reference< XAccessibleHyperlink > SAL_CALL m_pHyperTextData->emplace( pHt, xRet ); } } - break; + return xRet; } // iterate next hyperlink pHt = aHIter.next(&pNode); } - if( !xRet.is() ) - throw lang::IndexOutOfBoundsException(); - return xRet; + throw lang::IndexOutOfBoundsException(); } sal_Int32 SAL_CALL SwAccessibleParagraph::getHyperLinkIndex( sal_Int32 nCharIndex ) commit f8efcc70d548870ca715dd76f8d93578bb94740b Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Aug 8 13:54:26 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Aug 9 07:01:01 2024 +0200 sw a11y: Use slightly less cryptic var names Change-Id: Ic8610ba534f400dab2ce5e30f2a74fc125748b63 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171627 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 1933df163745..9abcf83e77d6 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -2745,14 +2745,14 @@ class SwHyperlinkIter_Impl { SwTextFrame const& m_rFrame; sw::MergedAttrIter m_Iter; - TextFrameIndex m_nStt; + TextFrameIndex m_nStart; TextFrameIndex m_nEnd; public: explicit SwHyperlinkIter_Impl(const SwTextFrame & rTextFrame); const SwTextAttr *next(SwTextNode const** ppNode = nullptr); - TextFrameIndex startIdx() const { return m_nStt; } + TextFrameIndex startIdx() const { return m_nStart; } TextFrameIndex endIdx() const { return m_nEnd; } }; @@ -2761,7 +2761,7 @@ public: SwHyperlinkIter_Impl::SwHyperlinkIter_Impl(const SwTextFrame & rTextFrame) : m_rFrame(rTextFrame) , m_Iter(rTextFrame) - , m_nStt(rTextFrame.GetOffset()) + , m_nStart(rTextFrame.GetOffset()) { const SwTextFrame *const pFollFrame = rTextFrame.GetFollow(); m_nEnd = pFollFrame ? pFollFrame->GetOffset() : TextFrameIndex(rTextFrame.GetText().getLength()); @@ -2780,11 +2780,11 @@ const SwTextAttr *SwHyperlinkIter_Impl::next(SwTextNode const** ppNode) { if (RES_TXTATR_INETFMT == pHt->Which()) { - const TextFrameIndex nHtStt(m_rFrame.MapModelToView(pNode, pHt->GetStart())); + const TextFrameIndex nHtStart(m_rFrame.MapModelToView(pNode, pHt->GetStart())); const TextFrameIndex nHtEnd(m_rFrame.MapModelToView(pNode, pHt->GetAnyEnd())); - if (nHtEnd > nHtStt && - ((nHtStt >= m_nStt && nHtStt < m_nEnd) || - (nHtEnd > m_nStt && nHtEnd <= m_nEnd))) + if (nHtEnd > nHtStart && + ((nHtStart >= m_nStart && nHtStart < m_nEnd) || + (nHtEnd > m_nStart && nHtEnd <= m_nEnd))) { pAttr = pHt; if (ppNode) commit b5e818c8104e7a3c0a153fbe2cd14c8a946c4a1f Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Aug 8 13:44:31 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Aug 9 07:00:55 2024 +0200 sw a11y: Drop unnecessary const_cast A `const SwTextAttr*` is just fine here. Change-Id: I6b46d47ba9e395e04ca8458b9be0f2e618c94536 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171625 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 3c828b8e7d99..1933df163745 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -2828,7 +2828,7 @@ uno::Reference< XAccessibleHyperlink > SAL_CALL const SwTextFrame *pTextFrame = static_cast<const SwTextFrame*>( GetFrame() ); SwHyperlinkIter_Impl aHIter(*pTextFrame); SwTextNode const* pNode(nullptr); - SwTextAttr* pHt = const_cast<SwTextAttr*>(aHIter.next(&pNode)); + const SwTextAttr* pHt = aHIter.next(&pNode); for (sal_Int32 nTIndex = 0; pHt && nTIndex <= nLinkIndex; ++nTIndex) { if( nTIndex == nLinkIndex ) @@ -2864,7 +2864,7 @@ uno::Reference< XAccessibleHyperlink > SAL_CALL } // iterate next hyperlink - pHt = const_cast<SwTextAttr*>(aHIter.next(&pNode)); + pHt = aHIter.next(&pNode); } if( !xRet.is() ) throw lang::IndexOutOfBoundsException();