diff options
author | Arnaud Versini <arnaud.versini@gmail.com> | 2018-03-25 13:49:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-03 10:39:12 +0200 |
commit | 84958e1a1bd9a3019300f558c66e468f8accf279 (patch) | |
tree | e90a8f51d7b325c14ed4452e476c73574d78d954 /comphelper | |
parent | 8bc951daf79decbd8a599a409c6d33c5456710e0 (diff) |
accessibility: more simplifiation in OCommonAccessibleText.
Change-Id: If1284f2e50be08372dda08a8250263c9ec435923
Reviewed-on: https://gerrit.libreoffice.org/51825
Tested-by: Jenkins <ci@libreoffice.org>
Tested-by: Arnaud Versini <arnaud.versini@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/misc/accessibletexthelper.cxx | 37 |
1 files changed, 17 insertions, 20 deletions
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 ); |