summaryrefslogtreecommitdiff
path: root/svgio/qa/cppunit
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-09-22 10:59:29 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-09-22 13:43:59 +0200
commitddf695db44bcb23dc2f1459fd439f93c0b6d5f2a (patch)
tree6aab04eba98b423b424db3ca878ab8bc9d2839a7 /svgio/qa/cppunit
parentcde237f7612cc34b1a7e46b83507877754b8e921 (diff)
tdf#151118: svg: fix handling of xml:space="preserve"
This allows the code to be simplified a bit Change-Id: If42dd9d3ebd7860ece9ff78cb090ff1b07e1b432 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140404 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio/qa/cppunit')
-rw-r--r--svgio/qa/cppunit/SvgImportTest.cxx21
-rw-r--r--svgio/qa/cppunit/data/textXmlSpace.svg12
2 files changed, 33 insertions, 0 deletions
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx
index 07a98f4a5a2f..23734777cf2c 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -48,6 +48,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools
void testMarkerOrient();
void testMarkerInPresentation();
void testMarkerInCssStyle();
+ void testTextXmlSpace();
void testTdf45771();
void testTdf97941();
void testTdf104339();
@@ -97,6 +98,7 @@ public:
CPPUNIT_TEST(testMarkerOrient);
CPPUNIT_TEST(testMarkerInPresentation);
CPPUNIT_TEST(testMarkerInCssStyle);
+ CPPUNIT_TEST(testTextXmlSpace);
CPPUNIT_TEST(testTdf45771);
CPPUNIT_TEST(testTdf97941);
CPPUNIT_TEST(testTdf104339);
@@ -420,6 +422,25 @@ void Test::testMarkerInCssStyle()
assertXPath(pDocument, "/primitive2D/transform/transform[1]/polypolygonstroke/line", "linecap", "BUTT");
}
+void Test::testTextXmlSpace()
+{
+ //Check tspan fontsize when using relative units
+ Primitive2DSequence aSequenceTdf97941 = parseSvg(u"/svgio/qa/cppunit/data/textXmlSpace.svg");
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf97941.getLength()));
+
+ drawinglayer::Primitive2dXmlDump dumper;
+ xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf97941);
+
+ CPPUNIT_ASSERT (pDocument);
+
+ 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");
+}
+
void Test::testTdf45771()
{
//Check text fontsize when using relative units
diff --git a/svgio/qa/cppunit/data/textXmlSpace.svg b/svgio/qa/cppunit/data/textXmlSpace.svg
new file mode 100644
index 000000000000..606e2eb7a306
--- /dev/null
+++ b/svgio/qa/cppunit/data/textXmlSpace.svg
@@ -0,0 +1,12 @@
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
+ viewBox="0 0 250 250">
+ <text y="10" xml:space="default">a b</text>
+ <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
+ b</text>
+</svg>
+