summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-10-10 16:49:58 +0200
committerMichael Stahl <Michael.Stahl@cib.de>2018-11-10 19:42:23 +0100
commita354a01cea06dc4b091fd57b7c559850c38f7413 (patch)
tree721e9afbfc275cf625e9e645961fe26957ab985e
parentcab6407f8f38d9fb1d70cb9e8a82f1ea5cf29667 (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
-rw-r--r--sw/source/core/access/accpara.cxx36
1 files changed, 3 insertions, 33 deletions
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index f323317d96cf..eec1a569da46 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();