svgio/qa/cppunit/SvgImportTest.cxx          |   25 +++++++++++++++++++++++++
 svgio/qa/cppunit/data/tdf86938.svg          |   13 +++++++++++++
 svgio/source/svgreader/svgcharacternode.cxx |    2 +-
 3 files changed, 39 insertions(+), 1 deletion(-)

New commits:
commit 86d39aec6ab4205955921406d2512d6eab8d3fe8
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon Aug 14 17:34:00 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Sat Aug 19 11:47:22 2023 +0200

    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 <xiscofa...@libreoffice.org>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155725

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 73b3150b3a8d..298608773352 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -763,6 +763,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

Reply via email to