summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-05-01 16:30:52 +0100
committerMichael Meeks <michael.meeks@suse.com>2012-05-02 12:24:32 +0100
commit5730b57700045c49e039ca9bd357f40c5a43313f (patch)
tree1f7de5c9383b27d6730e6dfd588354cc68fbc858 /sw
parent6ad690ea62829fcbb7d4b270ba02c1aaba02bcde (diff)
Resolves: fdo#49208 performance problems with very long paragraphs
Signed-off-by: Michael Meeks <michael.meeks@suse.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/breakit.hxx7
-rw-r--r--sw/source/core/bastyp/breakit.cxx19
-rw-r--r--sw/source/core/txtnode/txtedt.cxx2
3 files changed, 20 insertions, 8 deletions
diff --git a/sw/inc/breakit.hxx b/sw/inc/breakit.hxx
index 3075fc9dfe63..0bdce8c9bb83 100644
--- a/sw/inc/breakit.hxx
+++ b/sw/inc/breakit.hxx
@@ -112,7 +112,12 @@ public:
sal_uInt16 GetRealScriptOfText( const String& rTxt, xub_StrLen nPos ) const;
sal_uInt16 GetAllScriptsOfText( const String& rTxt ) const;
- sal_Int32 getGraphemeCount(const rtl::OUString& rStr) const;
+ sal_Int32 getGraphemeCount(const rtl::OUString& rStr,
+ sal_Int32 nStart, sal_Int32 nEnd) const;
+ sal_Int32 getGraphemeCount(const rtl::OUString& rStr) const
+ {
+ return getGraphemeCount(rStr, 0, rStr.getLength());
+ }
};
#define SW_BREAKITER() SwBreakIt::Get()
diff --git a/sw/source/core/bastyp/breakit.cxx b/sw/source/core/bastyp/breakit.cxx
index bb9366023b7a..c35afa0e16fd 100644
--- a/sw/source/core/bastyp/breakit.cxx
+++ b/sw/source/core/bastyp/breakit.cxx
@@ -168,16 +168,23 @@ sal_uInt16 SwBreakIt::GetAllScriptsOfText( const String& rTxt ) const
return nRet;
}
-sal_Int32 SwBreakIt::getGraphemeCount(const rtl::OUString& rText) const
+sal_Int32 SwBreakIt::getGraphemeCount(const rtl::OUString& rText, sal_Int32 nStart, sal_Int32 nEnd) const
{
sal_Int32 nGraphemeCount = 0;
- sal_Int32 nCurPos = 0;
- while (nCurPos < rText.getLength())
+ sal_Int32 nCurPos = nStart;
+ while (nCurPos < nEnd)
{
- sal_Int32 nCount2 = 1;
- nCurPos = xBreak->nextCharacters(rText, nCurPos, lang::Locale(),
- i18n::CharacterIteratorMode::SKIPCELL, nCount2, nCount2);
+ //fdo#49208 cheat and assume that nothing can combine with a space
+ //to form a single grapheme
+ if (rText[nCurPos] == ' ')
+ ++nCurPos;
+ else
+ {
+ sal_Int32 nCount2 = 1;
+ nCurPos = xBreak->nextCharacters(rText, nCurPos, lang::Locale(),
+ i18n::CharacterIteratorMode::SKIPCELL, nCount2, nCount2);
+ }
++nGraphemeCount;
}
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 86e4b69940af..186d4eab581f 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -1863,7 +1863,7 @@ void SwTxtNode::CountWords( SwDocStat& rStat,
}
}
- nTmpChars = pBreakIt->getGraphemeCount(aExpandText.copy(nExpandBegin, nExpandEnd - nExpandBegin));
+ nTmpChars = pBreakIt->getGraphemeCount(aExpandText, nExpandBegin, nExpandEnd);
nTmpChars -= nNumOfMaskedChars;
// no nTmpCharsExcludingSpaces adjust needed neither for blanked out MaskedChars