summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2022-09-11 13:43:13 +0200
committerEike Rathke <erack@redhat.com>2022-09-11 23:01:36 +0200
commit4ca5c021c91680f1a5df47225d9cb0d41c0a8637 (patch)
tree476afcefaf38ad3f3ff5992e94180b8bd13f1713
parent5bb826373f766a0ec105406a98d5529e2c360e8c (diff)
Simplify by using replaceAll instead of insert in a loop (sc)
Change-Id: Ibf41f78521a390cc73e10adaf1b85cd499abc2ba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139769 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/source/filter/dif/difexp.cxx22
1 files changed, 4 insertions, 18 deletions
diff --git a/sc/source/filter/dif/difexp.cxx b/sc/source/filter/dif/difexp.cxx
index 30df4a26fcce..bea016b03e98 100644
--- a/sc/source/filter/dif/difexp.cxx
+++ b/sc/source/filter/dif/difexp.cxx
@@ -225,15 +225,8 @@ void ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument* pDoc,
// back to Unicode
OUString aStrDec = OStringToOUString(aStrEnc, eCharSet);
// search on re-decoded string
- sal_Int32 nPos = aStrDec.indexOf(aStrDelimDecoded);
- while (nPos >= 0)
- {
- OUStringBuffer aBuf(aStrDec);
- aBuf.insert(nPos, aStrDelimDecoded);
- aStrDec = aBuf.makeStringAndClear();
- nPos = aStrDec.indexOf(
- aStrDelimDecoded, nPos+1+aStrDelimDecoded.getLength());
- }
+ OUString aStrTo = aStrDelimDecoded + aStrDelimDecoded;
+ aStrDec = aStrDec.replaceAll(aStrDelimDecoded, aStrTo);
// write byte re-encoded
rOut.WriteUniOrByteChar( cStrDelim, eCharSet );
rOut.WriteUnicodeOrByteText( aStrDec, eCharSet );
@@ -243,15 +236,8 @@ void ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument* pDoc,
{
OString aStrEnc = OUStringToOString(aTmpStr, eCharSet);
// search on encoded string
- sal_Int32 nPos = aStrEnc.indexOf(aStrDelimEncoded);
- while (nPos >= 0)
- {
- OStringBuffer aBuf(aStrEnc);
- aBuf.insert(nPos, aStrDelimEncoded);
- aStrEnc = aBuf.makeStringAndClear();
- nPos = aStrEnc.indexOf(
- aStrDelimEncoded, nPos+1+aStrDelimEncoded.getLength());
- }
+ OString aStrTo = aStrDelimEncoded + aStrDelimEncoded;
+ aStrEnc = aStrEnc.replaceAll(aStrDelimEncoded, aStrTo);
// write byte encoded
rOut.WriteBytes(aStrDelimEncoded.getStr(), aStrDelimEncoded.getLength());
rOut.WriteBytes(aStrEnc.getStr(), aStrEnc.getLength());