summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2018-09-09 02:05:50 +0200
committerMatteo Casalin <matteo.casalin@yahoo.com>2018-09-09 21:07:58 +0200
commitd3596b7274934e124b6baf57a2fb2fe75d732598 (patch)
tree7145b4a950da3120b14e3fbf9dac86945f74d3e2 /editeng
parent82974d069bc35c0eaaae0dd1cbfe2a46bc237552 (diff)
Handle trailing token separator without copying string
Change-Id: I09770f343ed54645cfa1f56ed2604af5e18c1720
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/outliner/outliner.cxx13
1 files changed, 7 insertions, 6 deletions
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index 0c97d71bd60a..01f4a218708a 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -423,15 +423,16 @@ void Outliner::SetText( const OUString& rText, Paragraph* pPara )
}
else
{
- OUString aText(convertLineEnd(rText, LINEEND_LF));
-
- if (aText.endsWith("\x0A"))
- aText = aText.copy(0, aText.getLength()-1); // Delete the last break
+ const OUString aText(convertLineEnd(rText, LINEEND_LF));
sal_Int32 nPos = 0;
sal_Int32 nInsPos = nPara+1;
- sal_Int32 nIdx {aText.isEmpty() ? -1 : 0};
- while( nIdx>=0 )
+ sal_Int32 nIdx {0};
+ // Loop over all tokens, but ignore the last one if empty
+ // (i.e. if strings ends with the delimiter, detected by
+ // checking nIdx against string length). This check also
+ // handle empty strings.
+ while( nIdx>=0 && nIdx<aText.getLength() )
{
OUString aStr = aText.getToken( 0, '\x0A', nIdx );