diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2018-10-10 16:49:58 +0200 |
---|---|---|
committer | Michael Stahl <Michael.Stahl@cib.de> | 2018-11-15 15:09:59 +0100 |
commit | d278f5cc5a239b6fed7b5a73917caa6d6473e5c6 (patch) | |
tree | d863bbb50f51feee7bf533c8ccb0cb5136204811 /sw | |
parent | e1dc8eb76d303ad37549047d725dd8bdb168fd9c (diff) |
sw: simplify & fix SwAccessibleParagraph::getHyperLink()
There is an inconsistency between getHyperLinkCount and getHyperLink,
as the latter uses index 0 as a no-op for some ToC link that was never
implemented, so all the real hyperlinks have their index offset by 1.
Also it's pointless to call getHyperLinkCount once per loop iteration.
(regression from 76c549eb01dcb7b5bf28a271ce00e386f3d388ba)
Change-Id: Iec83b6680abbdff5d372ca40358bd1306f3bd991
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/access/accpara.cxx | 36 |
1 files changed, 3 insertions, 33 deletions
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index 003603150942..4c7d1fbe67ad 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -2892,36 +2892,13 @@ uno::Reference< XAccessibleHyperlink > SAL_CALL const SwTextFrame *pTextFrame = static_cast<const SwTextFrame*>( GetFrame() ); SwHyperlinkIter_Impl aHIter(*pTextFrame); - sal_Int32 nTIndex = -1; - SwTOXSortTabBase* pTBase = GetTOXSortTabBase(); SwTextNode const* pNode(nullptr); SwTextAttr* pHt = const_cast<SwTextAttr*>(aHIter.next(&pNode)); - while( (nLinkIndex < getHyperLinkCount()) && nTIndex < nLinkIndex) + for (sal_Int32 nTIndex = 0; pHt && nTIndex <= nLinkIndex; ++nTIndex) { - sal_Int32 nHStt = -1; - bool bH = false; - - if( pHt ) - nHStt = pHt->GetStart(); - bool bTOC = false; - // Inside TOC & get the first link - if( pTBase && nTIndex == -1 ) - { - nTIndex++; - bTOC = true; - } - else if( nHStt >= 0 ) - { - // only hyperlink available - nTIndex++; - bH = true; - } - if( nTIndex == nLinkIndex ) { // found - if( bH ) { // it's a hyperlink - if( pHt ) { if( !m_pHyperTextData ) m_pHyperTextData.reset( new SwAccessibleHyperTextData ); @@ -2955,15 +2932,8 @@ uno::Reference< XAccessibleHyperlink > SAL_CALL break; } - // iterate next - if( bH ) - // iterate next hyperlink - pHt = const_cast<SwTextAttr*>(aHIter.next(&pNode)); - else if(bTOC) - continue; - else - // no candidate, exit - break; + // iterate next hyperlink + pHt = const_cast<SwTextAttr*>(aHIter.next(&pNode)); } if( !xRet.is() ) throw lang::IndexOutOfBoundsException(); |