summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorArnaud Versini <arnaud.versini@gmail.com>2018-03-18 20:25:25 +0100
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-03-25 12:57:21 +0200
commitdd5df4ccb33048fa5fa8f85b2e6e69a6a225be57 (patch)
tree2fe1c11f77fe2d93e371cc3b15dd62c14e63c12d /comphelper
parentdb22599c8c5a4a8b553194c05fff65bd6d71ab40 (diff)
accessibility: simplify OCommonAccessibleText
Change-Id: Ied5520179d15f0a854c16b14f5a5e6b84cef1300 Reviewed-on: https://gerrit.libreoffice.org/51514 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Arnaud Versini <arnaud.versini@libreoffice.org>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/accessibletexthelper.cxx61
1 files changed, 28 insertions, 33 deletions
diff --git a/comphelper/source/misc/accessibletexthelper.cxx b/comphelper/source/misc/accessibletexthelper.cxx
index 9f1cccea85ba..202be72977af 100644
--- a/comphelper/source/misc/accessibletexthelper.cxx
+++ b/comphelper/source/misc/accessibletexthelper.cxx
@@ -96,21 +96,19 @@ namespace comphelper
}
- void OCommonAccessibleText::implGetGlyphBoundary( i18n::Boundary& rBoundary, sal_Int32 nIndex )
+ void OCommonAccessibleText::implGetGlyphBoundary( const OUString& rText, i18n::Boundary& rBoundary, sal_Int32 nIndex )
{
- OUString sText( implGetText() );
-
- if ( implIsValidIndex( nIndex, sText.getLength() ) )
+ if ( implIsValidIndex( nIndex, rText.getLength() ) )
{
Reference < i18n::XBreakIterator > xBreakIter = implGetBreakIterator();
if ( xBreakIter.is() )
{
sal_Int32 nCount = 1;
sal_Int32 nDone;
- sal_Int32 nStartIndex = xBreakIter->previousCharacters( sText, nIndex, implGetLocale(), i18n::CharacterIteratorMode::SKIPCELL, nCount, nDone );
+ sal_Int32 nStartIndex = xBreakIter->previousCharacters( rText, nIndex, implGetLocale(), i18n::CharacterIteratorMode::SKIPCELL, nCount, nDone );
if ( nDone != 0 )
- nStartIndex = xBreakIter->nextCharacters( sText, nStartIndex, implGetLocale(), i18n::CharacterIteratorMode::SKIPCELL, nCount, nDone );
- sal_Int32 nEndIndex = xBreakIter->nextCharacters( sText, nStartIndex, implGetLocale(), i18n::CharacterIteratorMode::SKIPCELL, nCount, nDone );
+ nStartIndex = xBreakIter->nextCharacters( rText, nStartIndex, implGetLocale(), i18n::CharacterIteratorMode::SKIPCELL, nCount, nDone );
+ sal_Int32 nEndIndex = xBreakIter->nextCharacters( rText, nStartIndex, implGetLocale(), i18n::CharacterIteratorMode::SKIPCELL, nCount, nDone );
if ( nDone != 0 )
{
rBoundary.startPos = nStartIndex;
@@ -126,23 +124,22 @@ namespace comphelper
}
- bool OCommonAccessibleText::implGetWordBoundary( i18n::Boundary& rBoundary, sal_Int32 nIndex )
+ bool OCommonAccessibleText::implGetWordBoundary( const OUString& rText, i18n::Boundary& rBoundary, sal_Int32 nIndex )
{
bool bWord = false;
- OUString sText( implGetText() );
- if ( implIsValidIndex( nIndex, sText.getLength() ) )
+ if ( implIsValidIndex( nIndex, rText.getLength() ) )
{
Reference < i18n::XBreakIterator > xBreakIter = implGetBreakIterator();
if ( xBreakIter.is() )
{
- rBoundary = xBreakIter->getWordBoundary( sText, nIndex, implGetLocale(), i18n::WordType::ANY_WORD, true );
+ rBoundary = xBreakIter->getWordBoundary( rText, nIndex, implGetLocale(), i18n::WordType::ANY_WORD, true );
// it's a word, if the first character is an alpha-numeric character
Reference< i18n::XCharacterClassification > xCharClass = implGetCharacterClassification();
if ( xCharClass.is() )
{
- sal_Int32 nType = xCharClass->getCharacterType( sText, rBoundary.startPos, implGetLocale() );
+ sal_Int32 nType = xCharClass->getCharacterType( rText, rBoundary.startPos, implGetLocale() );
if ( ( nType & ( i18n::KCharacterType::LETTER | i18n::KCharacterType::DIGIT ) ) != 0 )
bWord = true;
}
@@ -158,18 +155,16 @@ namespace comphelper
}
- void OCommonAccessibleText::implGetSentenceBoundary( i18n::Boundary& rBoundary, sal_Int32 nIndex )
+ void OCommonAccessibleText::implGetSentenceBoundary( const OUString& rText, i18n::Boundary& rBoundary, sal_Int32 nIndex )
{
- OUString sText( implGetText() );
-
- if ( implIsValidIndex( nIndex, sText.getLength() ) )
+ if ( implIsValidIndex( nIndex, rText.getLength() ) )
{
Locale aLocale = implGetLocale();
Reference < i18n::XBreakIterator > xBreakIter = implGetBreakIterator();
if ( xBreakIter.is() )
{
- rBoundary.endPos = xBreakIter->endOfSentence( sText, nIndex, aLocale );
- rBoundary.startPos = xBreakIter->beginOfSentence( sText, rBoundary.endPos, aLocale );
+ rBoundary.endPos = xBreakIter->endOfSentence( rText, nIndex, aLocale );
+ rBoundary.startPos = xBreakIter->beginOfSentence( rText, rBoundary.endPos, aLocale );
}
}
else
@@ -313,7 +308,7 @@ namespace comphelper
case AccessibleTextType::GLYPH:
{
// get glyph at index
- implGetGlyphBoundary( aBoundary, nIndex );
+ implGetGlyphBoundary( sText, aBoundary, nIndex );
if ( implIsValidBoundary( aBoundary, nLength ) )
{
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
@@ -325,7 +320,7 @@ namespace comphelper
case AccessibleTextType::WORD:
{
// get word at index
- bool bWord = implGetWordBoundary( aBoundary, nIndex );
+ bool bWord = implGetWordBoundary( sText, aBoundary, nIndex );
if ( bWord && implIsValidBoundary( aBoundary, nLength ) )
{
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
@@ -337,7 +332,7 @@ namespace comphelper
case AccessibleTextType::SENTENCE:
{
// get sentence at index
- implGetSentenceBoundary( aBoundary, nIndex );
+ implGetSentenceBoundary( sText, aBoundary, nIndex );
if ( implIsValidBoundary( aBoundary, nLength ) )
{
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
@@ -417,11 +412,11 @@ namespace comphelper
case AccessibleTextType::GLYPH:
{
// get glyph at index
- implGetGlyphBoundary( aBoundary, nIndex );
+ implGetGlyphBoundary( sText, aBoundary, nIndex );
// get previous glyph
if ( aBoundary.startPos > 0 )
{
- implGetGlyphBoundary( aBoundary, aBoundary.startPos - 1 );
+ implGetGlyphBoundary( sText, aBoundary, aBoundary.startPos - 1 );
if ( implIsValidBoundary( aBoundary, nLength ) )
{
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
@@ -434,11 +429,11 @@ namespace comphelper
case AccessibleTextType::WORD:
{
// get word at index
- implGetWordBoundary( aBoundary, nIndex );
+ implGetWordBoundary( sText, aBoundary, nIndex );
// get previous word
bool bWord = false;
while ( !bWord && aBoundary.startPos > 0 )
- bWord = implGetWordBoundary( aBoundary, aBoundary.startPos - 1 );
+ bWord = implGetWordBoundary( sText, aBoundary, aBoundary.startPos - 1 );
if ( bWord && implIsValidBoundary( aBoundary, nLength ) )
{
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
@@ -450,11 +445,11 @@ namespace comphelper
case AccessibleTextType::SENTENCE:
{
// get sentence at index
- implGetSentenceBoundary( aBoundary, nIndex );
+ implGetSentenceBoundary( sText, aBoundary, nIndex );
// get previous sentence
if ( aBoundary.startPos > 0 )
{
- implGetSentenceBoundary( aBoundary, aBoundary.startPos - 1 );
+ implGetSentenceBoundary( sText, aBoundary, aBoundary.startPos - 1 );
if ( implIsValidBoundary( aBoundary, nLength ) )
{
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
@@ -541,11 +536,11 @@ namespace comphelper
case AccessibleTextType::GLYPH:
{
// get glyph at index
- implGetGlyphBoundary( aBoundary, nIndex );
+ implGetGlyphBoundary( sText, aBoundary, nIndex );
// get next glyph
if ( aBoundary.endPos < nLength )
{
- implGetGlyphBoundary( aBoundary, aBoundary.endPos );
+ implGetGlyphBoundary( sText, aBoundary, aBoundary.endPos );
if ( implIsValidBoundary( aBoundary, nLength ) )
{
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
@@ -558,11 +553,11 @@ namespace comphelper
case AccessibleTextType::WORD:
{
// get word at index
- implGetWordBoundary( aBoundary, nIndex );
+ implGetWordBoundary( sText, aBoundary, nIndex );
// get next word
bool bWord = false;
while ( !bWord && aBoundary.endPos < nLength )
- bWord = implGetWordBoundary( aBoundary, aBoundary.endPos );
+ bWord = implGetWordBoundary( sText, aBoundary, aBoundary.endPos );
if ( bWord && implIsValidBoundary( aBoundary, nLength ) )
{
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
@@ -574,14 +569,14 @@ namespace comphelper
case AccessibleTextType::SENTENCE:
{
// get sentence at index
- implGetSentenceBoundary( aBoundary, nIndex );
+ implGetSentenceBoundary( sText, aBoundary, nIndex );
// get next sentence
sal_Int32 nEnd = aBoundary.endPos;
sal_Int32 nI = aBoundary.endPos;
bool bFound = false;
while ( !bFound && ++nI < nLength )
{
- implGetSentenceBoundary( aBoundary, nI );
+ implGetSentenceBoundary( sText, aBoundary, nI );
bFound = ( aBoundary.endPos > nEnd );
}
if ( bFound && implIsValidBoundary( aBoundary, nLength ) )