From 84958e1a1bd9a3019300f558c66e468f8accf279 Mon Sep 17 00:00:00 2001 From: Arnaud Versini Date: Sun, 25 Mar 2018 13:49:42 +0200 Subject: accessibility: more simplifiation in OCommonAccessibleText. Change-Id: If1284f2e50be08372dda08a8250263c9ec435923 Reviewed-on: https://gerrit.libreoffice.org/51825 Tested-by: Jenkins Tested-by: Arnaud Versini Reviewed-by: Noel Grandin --- comphelper/source/misc/accessibletexthelper.cxx | 37 ++++++++++++------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'comphelper/source') diff --git a/comphelper/source/misc/accessibletexthelper.cxx b/comphelper/source/misc/accessibletexthelper.cxx index 202be72977af..35fe769c1700 100644 --- a/comphelper/source/misc/accessibletexthelper.cxx +++ b/comphelper/source/misc/accessibletexthelper.cxx @@ -175,20 +175,18 @@ namespace comphelper } - void OCommonAccessibleText::implGetParagraphBoundary( i18n::Boundary& rBoundary, sal_Int32 nIndex ) + void OCommonAccessibleText::implGetParagraphBoundary( const OUString& rText, i18n::Boundary& rBoundary, sal_Int32 nIndex ) { - OUString sText( implGetText() ); - - if ( implIsValidIndex( nIndex, sText.getLength() ) ) + if ( implIsValidIndex( nIndex, rText.getLength() ) ) { rBoundary.startPos = 0; - rBoundary.endPos = sText.getLength(); + rBoundary.endPos = rText.getLength(); - sal_Int32 nFound = sText.lastIndexOf( '\n', nIndex ); + sal_Int32 nFound = rText.lastIndexOf( '\n', nIndex ); if ( nFound != -1 ) rBoundary.startPos = nFound + 1; - nFound = sText.indexOf( '\n', nIndex ); + nFound = rText.indexOf( '\n', nIndex ); if ( nFound != -1 ) rBoundary.endPos = nFound + 1; } @@ -200,10 +198,9 @@ namespace comphelper } - void OCommonAccessibleText::implGetLineBoundary( i18n::Boundary& rBoundary, sal_Int32 nIndex ) + void OCommonAccessibleText::implGetLineBoundary( const OUString& rText, i18n::Boundary& rBoundary, sal_Int32 nIndex ) { - OUString sText( implGetText() ); - sal_Int32 nLength = sText.getLength(); + sal_Int32 nLength = rText.getLength(); if ( implIsValidIndex( nIndex, nLength ) || nIndex == nLength ) { @@ -344,7 +341,7 @@ namespace comphelper case AccessibleTextType::PARAGRAPH: { // get paragraph at index - implGetParagraphBoundary( aBoundary, nIndex ); + implGetParagraphBoundary( sText, aBoundary, nIndex ); if ( implIsValidBoundary( aBoundary, nLength ) ) { aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos ); @@ -356,7 +353,7 @@ namespace comphelper case AccessibleTextType::LINE: { // get line at index - implGetLineBoundary( aBoundary, nIndex ); + implGetLineBoundary( sText, aBoundary, nIndex ); if ( implIsValidBoundary( aBoundary, nLength ) ) { aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos ); @@ -462,11 +459,11 @@ namespace comphelper case AccessibleTextType::PARAGRAPH: { // get paragraph at index - implGetParagraphBoundary( aBoundary, nIndex ); + implGetParagraphBoundary( sText, aBoundary, nIndex ); // get previous paragraph if ( aBoundary.startPos > 0 ) { - implGetParagraphBoundary( aBoundary, aBoundary.startPos - 1 ); + implGetParagraphBoundary( sText, aBoundary, aBoundary.startPos - 1 ); if ( implIsValidBoundary( aBoundary, nLength ) ) { aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos ); @@ -479,11 +476,11 @@ namespace comphelper case AccessibleTextType::LINE: { // get line at index - implGetLineBoundary( aBoundary, nIndex ); + implGetLineBoundary( sText, aBoundary, nIndex ); // get previous line if ( aBoundary.startPos > 0 ) { - implGetLineBoundary( aBoundary, aBoundary.startPos - 1 ); + implGetLineBoundary( sText, aBoundary, aBoundary.startPos - 1 ); if ( implIsValidBoundary( aBoundary, nLength ) ) { aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos ); @@ -590,11 +587,11 @@ namespace comphelper case AccessibleTextType::PARAGRAPH: { // get paragraph at index - implGetParagraphBoundary( aBoundary, nIndex ); + implGetParagraphBoundary( sText, aBoundary, nIndex ); // get next paragraph if ( aBoundary.endPos < nLength ) { - implGetParagraphBoundary( aBoundary, aBoundary.endPos ); + implGetParagraphBoundary( sText, aBoundary, aBoundary.endPos ); if ( implIsValidBoundary( aBoundary, nLength ) ) { aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos ); @@ -607,11 +604,11 @@ namespace comphelper case AccessibleTextType::LINE: { // get line at index - implGetLineBoundary( aBoundary, nIndex ); + implGetLineBoundary( sText, aBoundary, nIndex ); // get next line if ( aBoundary.endPos < nLength ) { - implGetLineBoundary( aBoundary, aBoundary.endPos ); + implGetLineBoundary( sText, aBoundary, aBoundary.endPos ); if ( implIsValidBoundary( aBoundary, nLength ) ) { aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos ); -- cgit