summaryrefslogtreecommitdiff
path: root/svgio/qa/cppunit
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-08-14 14:52:41 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2023-08-15 03:53:06 +0200
commit5cfd31e505b4d1b4f9d2e21b0f9f8aac22539f47 (patch)
treeb037f5d6ce2cfc412a75382db71a55249ba49b0c /svgio/qa/cppunit
parent850b66f969834e61f3cb1a1ccd4bfc15f23d558f (diff)
tdf#93583: use getTextWidth to calculate line's width
Since every character in the line might use different styles Change-Id: I2ce079d4308f4acde42a8366838749a7c20331b4 Change-Id: I01f51f157caa667cebc8860ae37d4458fac2d511 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155666 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio/qa/cppunit')
-rw-r--r--svgio/qa/cppunit/SvgImportTest.cxx27
-rw-r--r--svgio/qa/cppunit/data/tdf93583.svg7
2 files changed, 34 insertions, 0 deletions
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx
index d97892f8d98f..53f6b23da4fd 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -746,6 +746,33 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf85770)
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "familyname", "Times New Roman");
}
+CPPUNIT_TEST_FIXTURE(Test, testTdf93583)
+{
+ Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf93583.svg");
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
+
+ drawinglayer::Primitive2dXmlDump dumper;
+ xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence));
+
+ CPPUNIT_ASSERT (pDocument);
+
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "This is the");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "x", "62");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "y", "303");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "width", "16");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "16");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", " first");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "x", "127");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "y", "303");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "width", "32");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "height", "32");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "text", " line");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "x", "187");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "y", "303");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "width", "16");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "height", "16");
+}
+
CPPUNIT_TEST_FIXTURE(Test, testTdf156616)
{
Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf156616.svg");
diff --git a/svgio/qa/cppunit/data/tdf93583.svg b/svgio/qa/cppunit/data/tdf93583.svg
new file mode 100644
index 000000000000..13e63e677ffb
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf93583.svg
@@ -0,0 +1,7 @@
+<svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
+ <text
+ style="text-anchor:end"
+ x="214"
+ y="303"><tspan>This is the<tspan style="font-size:200%"> first </tspan>line</tspan>
+ </text>
+</svg>