diff options
author | Thomas Arnhold <thomas@arnhold.org> | 2013-09-04 22:24:21 +0200 |
---|---|---|
committer | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-09-05 08:01:42 +0000 |
commit | 17ff0d2b866f0e501057695d1485bf7d8d882f2a (patch) | |
tree | 3bb5a97e3db3ed67d46d6c2dd85d89573393fe19 /starmath | |
parent | 51b810fbf78fa02e2b00dab596551a4f40dbff4b (diff) |
String to OUString for SmDocShell::ReplaceBadChars
And simplify a little bit.
Change-Id: I3b3cf2ea29f59f173e74b59a8e999f19f86e9a0a
Reviewed-on: https://gerrit.libreoffice.org/5818
Tested-by: Andrzej J.R. Hunt <andrzej@ahunt.org>
Reviewed-by: Andrzej J.R. Hunt <andrzej@ahunt.org>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/source/document.cxx | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index 5d1fde88cfb5..5923fe416697 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -873,31 +873,24 @@ sal_Bool SmDocShell::Save() sal_Bool SmDocShell::ReplaceBadChars() { sal_Bool bReplace = sal_False; + if (pEditEngine) { - String aEngTxt( pEditEngine->GetText( LINEEND_LF ) ); - const sal_Unicode *pEngTxt = aEngTxt.GetBuffer(); - xub_StrLen nLen = aEngTxt.Len(); - for (xub_StrLen i = 0; i < nLen && !bReplace; ++i) - { - const sal_Unicode c = *pEngTxt++; - if (c < ' ' && c != '\r' && c != '\n' && c != '\t') - bReplace = sal_True; - } - if (bReplace) + OUStringBuffer aBuf( pEditEngine->GetText( LINEEND_LF ) ); + + for (sal_Int32 i = 0; i < aBuf.getLength(); ++i) { - sal_Unicode *pChgTxt = aEngTxt.GetBufferAccess(); - for (xub_StrLen i = 0; i < nLen; ++i) + if (aBuf[i] < ' ' && aBuf[i] != '\r' && aBuf[i] != '\n' && aBuf[i] != '\t') { - sal_Unicode &rc = *pChgTxt++; - if (rc < ' ' && rc != '\r' && rc != '\n' && rc != '\t') - rc = ' '; + aBuf[i] = ' '; + bReplace = sal_True; } - aEngTxt.ReleaseBufferAccess( nLen ); - - aText = aEngTxt; } + + if (bReplace) + aText = aBuf.makeStringAndClear(); } + return bReplace; } |