summaryrefslogtreecommitdiff
path: root/svgio
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-08-14 17:34:00 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2023-08-15 03:53:18 +0200
commita2b6be8af9be3237efc3ed1244302cf899680e97 (patch)
tree017b45b5a69c97a8301dbea0431edb2ae4da1424 /svgio
parent5cfd31e505b4d1b4f9d2e21b0f9f8aac22539f47 (diff)
tdf#86938: fix calculation of baseline-shift
Change-Id: I8c30c29052f2ea1fe6e49360b972af868851131b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155671 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio')
-rw-r--r--svgio/qa/cppunit/SvgImportTest.cxx25
-rw-r--r--svgio/qa/cppunit/data/tdf86938.svg13
-rw-r--r--svgio/source/svgreader/svgcharacternode.cxx2
3 files changed, 39 insertions, 1 deletions
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx
index 53f6b23da4fd..d68e7ebf728a 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -746,6 +746,31 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf85770)
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "familyname", "Times New Roman");
}
+CPPUNIT_TEST_FIXTURE(Test, testTdf86938)
+{
+ Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf86938.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", "line");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "x", "290");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "y", "183");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", "above");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "x", "290");
+
+ // Without the fix in place, this test would have failed with
+ // - Expected: 159
+ // - Actual : 207
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "y", "159");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "text", "below");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "x", "290");
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "y", "207");
+}
+
CPPUNIT_TEST_FIXTURE(Test, testTdf93583)
{
Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf93583.svg");
diff --git a/svgio/qa/cppunit/data/tdf86938.svg b/svgio/qa/cppunit/data/tdf86938.svg
new file mode 100644
index 000000000000..40287a39de88
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf86938.svg
@@ -0,0 +1,13 @@
+<svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
+ <text
+ x="290"
+ y="183"> line </text>
+ <text
+ x="290"
+ y="183"
+ baseline-shift="24"> above </text>
+ <text
+ x="290"
+ y="183"
+ baseline-shift="-24"> below </text>
+</svg>
diff --git a/svgio/source/svgreader/svgcharacternode.cxx b/svgio/source/svgreader/svgcharacternode.cxx
index ebc317c3a445..91ec98ae9b68 100644
--- a/svgio/source/svgreader/svgcharacternode.cxx
+++ b/svgio/source/svgreader/svgcharacternode.cxx
@@ -301,7 +301,7 @@ namespace svgio::svgreader
const SvgNumber aNumber(rSvgStyleAttributes.getBaselineShiftNumber());
const double mfBaselineShift(aNumber.solve(*this));
- aPosition.setY(aPosition.getY() + mfBaselineShift);
+ aPosition.setY(aPosition.getY() - mfBaselineShift);
break;
}
default: // BaselineShift::Baseline