svgio/inc/svgtools.hxx                      |    2 +-
 svgio/qa/cppunit/SvgImportTest.cxx          |    8 +++++---
 svgio/qa/cppunit/data/textXmlSpace.svg      |   10 +++++++---
 svgio/source/svgreader/svgcharacternode.cxx |    9 +--------
 svgio/source/svgreader/svgtools.cxx         |   12 ++++++++----
 5 files changed, 22 insertions(+), 19 deletions(-)

New commits:
commit 88442b612be20158d6dee067af7e8a67f7646b68
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu Sep 22 16:49:30 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Sep 23 16:39:51 2022 +0200

    tdf#151118: svg: don't replace newline with space when xml:space="default"
    
    Partially revert ddf695db44bcb23dc2f1459fd439f93c0b6d5f2a
    "tdf#151118: svg: fix handling of xml:space="preserve""
    
    See discussion in https://gerrit.libreoffice.org/c/core/+/140404
    
    Thanks to Mike Kaganski for spotting it
    
    Change-Id: Ifdd26b8de2f5cc392127f215e148599ae63036dc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140444
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140481

diff --git a/svgio/inc/svgtools.hxx b/svgio/inc/svgtools.hxx
index 9ee0130f29d2..5effa7df36fc 100644
--- a/svgio/inc/svgtools.hxx
+++ b/svgio/inc/svgtools.hxx
@@ -124,7 +124,7 @@ 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);
+        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/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 9e0a07430a6f..49f88768d148 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -408,9 +408,11 @@ void Test::testTextXmlSpace()
     assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[1]", 
"text", "a b");
     assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[2]", 
"text", "a b");
     assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[3]", 
"text", "a b");
-    assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[4]", 
"text", "a  b");
-    assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[5]", 
"text", "a b");
-    assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[6]", 
"text", "a   b");
+    assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[4]", 
"text", "ab");
+    assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[5]", 
"text", "a  b");
+    assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[6]", 
"text", "a b");
+    assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[7]", 
"text", "a   b");
+    assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[8]", 
"text", "a b");
 }
 
 void Test::testTdf45771()
diff --git a/svgio/qa/cppunit/data/textXmlSpace.svg 
b/svgio/qa/cppunit/data/textXmlSpace.svg
index 606e2eb7a306..f200d74dd3f3 100644
--- a/svgio/qa/cppunit/data/textXmlSpace.svg
+++ b/svgio/qa/cppunit/data/textXmlSpace.svg
@@ -4,9 +4,13 @@
   <text y="30" xml:space="default">a   b</text>
   <text y="50" xml:space="default">a
   b</text>
-  <text y="70" xml:space="preserve">a  b</text>
-  <text y="90" xml:space="preserve">a  b</text>
-  <text y="110" xml:space="preserve">a
+  <text y="70" xml:space="default">a
+b</text>
+  <text y="90" xml:space="preserve">a  b</text>
+  <text y="110" xml:space="preserve">a b</text>
+  <text y="130" xml:space="preserve">a
   b</text>
+  <text y="150" xml:space="preserve">a
+b</text>
 </svg>
 
diff --git a/svgio/source/svgreader/svgcharacternode.cxx 
b/svgio/source/svgreader/svgcharacternode.cxx
index 696011bab66d..79bdda4c6ea8 100644
--- a/svgio/source/svgreader/svgcharacternode.cxx
+++ b/svgio/source/svgreader/svgcharacternode.cxx
@@ -535,14 +535,7 @@ namespace svgio::svgreader
 
         void SvgCharacterNode::whiteSpaceHandling()
         {
-            if (XmlSpace::Default == getXmlSpace())
-            {
-                maText = xmlSpaceHandling(maText, true);
-            }
-            else
-            {
-                maText = xmlSpaceHandling(maText, false);
-            }
+            maText = xmlSpaceHandling(maText, XmlSpace::Default == 
getXmlSpace());
         }
 
         void SvgCharacterNode::addGap()
diff --git a/svgio/source/svgreader/svgtools.cxx 
b/svgio/source/svgreader/svgtools.cxx
index b15ad2494821..e4303bbb8fc8 100644
--- a/svgio/source/svgreader/svgtools.cxx
+++ b/svgio/source/svgreader/svgtools.cxx
@@ -1362,7 +1362,7 @@ namespace svgio::svgreader
             }
         }
 
-        OUString convert(const OUString& rCandidate, sal_Unicode nPattern, 
sal_Unicode nNew)
+        OUString convert(const OUString& rCandidate, sal_Unicode nPattern, 
sal_Unicode nNew, bool bRemove)
         {
             const sal_Int32 nLen(rCandidate.getLength());
 
@@ -1379,7 +1379,11 @@ namespace svgio::svgreader
                     if(nPattern == aChar)
                     {
                         bChanged = true;
-                        aBuffer.append(nNew);
+
+                        if(!bRemove)
+                        {
+                            aBuffer.append(nNew);
+                        }
                     }
                     else
                     {
@@ -1503,10 +1507,10 @@ namespace svgio::svgreader
             const sal_Unicode aSpace(' ');
 
             // remove all newline characters
-            OUString aRetval(convert(rCandidate, aNewline, aSpace));
+            OUString aRetval(convert(rCandidate, aNewline, aSpace, 
bIsDefault));
 
             // convert tab to space
-            aRetval = convert(aRetval, aTab, aSpace);
+            aRetval = convert(aRetval, aTab, aSpace, false);
 
             // strip of all leading and trailing spaces
             aRetval = aRetval.trim();

Reply via email to