diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-09-22 16:49:30 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-09-23 12:24:01 +0200 |
commit | bdebe856d110700d757625f121879de920b9ef46 (patch) | |
tree | b0ebb4755a7f6507d01e9a423889b488dc88cb43 /svgio | |
parent | e47e0cb0ad1dc3554e9b57f8562a217cf785edbf (diff) |
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 <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio')
-rw-r--r-- | svgio/inc/svgtools.hxx | 2 | ||||
-rw-r--r-- | svgio/qa/cppunit/SvgImportTest.cxx | 8 | ||||
-rw-r--r-- | svgio/qa/cppunit/data/textXmlSpace.svg | 10 | ||||
-rw-r--r-- | svgio/source/svgreader/svgcharacternode.cxx | 9 | ||||
-rw-r--r-- | svgio/source/svgreader/svgtools.cxx | 12 |
5 files changed, 22 insertions, 19 deletions
diff --git a/svgio/inc/svgtools.hxx b/svgio/inc/svgtools.hxx index 0a4e200c746b..66570f00df78 100644 --- a/svgio/inc/svgtools.hxx +++ b/svgio/inc/svgtools.hxx @@ -125,7 +125,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 23734777cf2c..d2cc7bd90828 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -436,9 +436,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 456a3abc8013..9e6f91aa9dd2 100644 --- a/svgio/source/svgreader/svgcharacternode.cxx +++ b/svgio/source/svgreader/svgcharacternode.cxx @@ -539,14 +539,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::concatenate(std::u16string_view rText) diff --git a/svgio/source/svgreader/svgtools.cxx b/svgio/source/svgreader/svgtools.cxx index 92b2ecab3fb3..eeca00ac3330 100644 --- a/svgio/source/svgreader/svgtools.cxx +++ b/svgio/source/svgreader/svgtools.cxx @@ -1375,7 +1375,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()); @@ -1392,7 +1392,11 @@ namespace svgio::svgreader if(nPattern == aChar) { bChanged = true; - aBuffer.append(nNew); + + if(!bRemove) + { + aBuffer.append(nNew); + } } else { @@ -1516,10 +1520,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(); |