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 bdebe856d110700d757625f121879de920b9ef46 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 12:24:01 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> 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();