svgio/inc/svgtools.hxx              |    1 
 svgio/source/svgreader/svgtools.cxx |   52 ++----------------------------------
 2 files changed, 3 insertions(+), 50 deletions(-)

New commits:
commit dcb991bbc6a1a66103b3c0fbc6e996a27e3e90b1
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri Sep 23 12:47:38 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Sep 23 14:41:41 2022 +0200

    svgio: Simplify by using replaceAll
    
    Change-Id: Id805787c5b5a812c6fd4fbfe3c3b2905578ce3bf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140482
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

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)
             {

Reply via email to