summaryrefslogtreecommitdiff
path: root/svgio
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-09-23 12:47:38 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-09-23 14:41:41 +0200
commitdcb991bbc6a1a66103b3c0fbc6e996a27e3e90b1 (patch)
tree3afe35894e5aae1a8d8ed416157439a45b5d2c7f /svgio
parent5e6b02055a887bc49c5252c1ae359ae96947e80c (diff)
svgio: Simplify by using replaceAll
Change-Id: Id805787c5b5a812c6fd4fbfe3c3b2905578ce3bf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140482 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio')
-rw-r--r--svgio/inc/svgtools.hxx1
-rw-r--r--svgio/source/svgreader/svgtools.cxx52
2 files changed, 3 insertions, 50 deletions
diff --git a/svgio/inc/svgtools.hxx b/svgio/inc/svgtools.hxx
index 66570f00df78..4147344b4640 100644
--- a/svgio/inc/svgtools.hxx
+++ b/svgio/inc/svgtools.hxx
@@ -125,7 +125,6 @@ namespace svgio::svgreader
void readImageLink(const OUString& rCandidate, OUString& rXLink, OUString& rUrl, OUString& rMimeType, OUString& rData);
- OUString convert(const OUString& rCandidate, sal_Unicode nPattern, sal_Unicode nNew, bool bRemove);
OUString consolidateContiguousSpace(const OUString& rCandidate);
OUString xmlSpaceHandling(const OUString& rCandidate, bool bIsDefault);
diff --git a/svgio/source/svgreader/svgtools.cxx b/svgio/source/svgreader/svgtools.cxx
index 02a37dc0e8b4..c0bee33995a0 100644
--- a/svgio/source/svgreader/svgtools.cxx
+++ b/svgio/source/svgreader/svgtools.cxx
@@ -1375,46 +1375,6 @@ namespace svgio::svgreader
}
}
- OUString convert(const OUString& rCandidate, sal_Unicode nPattern, sal_Unicode nNew, bool bRemove)
- {
- const sal_Int32 nLen(rCandidate.getLength());
-
- if(nLen)
- {
- sal_Int32 nPos(0);
- OUStringBuffer aBuffer;
- bool bChanged(false);
-
- while(nPos < nLen)
- {
- const sal_Unicode aChar(rCandidate[nPos]);
-
- if(nPattern == aChar)
- {
- bChanged = true;
-
- if(!bRemove)
- {
- aBuffer.append(nNew);
- }
- }
- else
- {
- aBuffer.append(aChar);
- }
-
- nPos++;
- }
-
- if(bChanged)
- {
- return aBuffer.makeStringAndClear();
- }
- }
-
- return rCandidate;
- }
-
// #i125325#
OUString removeBlockComments(const OUString& rCandidate)
{
@@ -1515,15 +1475,9 @@ namespace svgio::svgreader
OUString xmlSpaceHandling(const OUString& rCandidate, bool bIsDefault)
{
- const sal_Unicode aNewline('\n');
- const sal_Unicode aTab('\t');
- const sal_Unicode aSpace(' ');
-
- // remove all newline characters
- OUString aRetval(convert(rCandidate, aNewline, aSpace, bIsDefault));
-
- // convert tab to space
- aRetval = convert(aRetval, aTab, aSpace, false);
+ // if xml:space="default" then remove all newline characters, otherwise convert them to space
+ // convert tab to space too
+ OUString aRetval(rCandidate.replaceAll(u"\n", bIsDefault ? u"" : u" ").replaceAll(u"\t", u" "));
if(bIsDefault)
{