svgio/inc/svgstyleattributes.hxx | 2 +- svgio/qa/cppunit/SvgImportTest.cxx | 25 +++++++++++++++++++++++++ svgio/qa/cppunit/data/tdf156837.svg | 13 +++++++++++++ svgio/source/svgreader/svgstyleattributes.cxx | 22 +++++++++++++++++++++- 4 files changed, 60 insertions(+), 2 deletions(-)
New commits: commit 8961c5abbd981d40fad6bb658688bd6582cbaab6 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon Aug 21 14:15:56 2023 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Aug 21 19:59:15 2023 +0200 tdf#156837: check baseline-shift from parent too Change-Id: I6e62d794dd4410447db3bee26c1e18fe9dad6a9c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155895 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit 56a360328790eb009efed6fce94a795f6fe0a7d2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155911 diff --git a/svgio/inc/svgstyleattributes.hxx b/svgio/inc/svgstyleattributes.hxx index 52876ea0576d..0db313243a8c 100644 --- a/svgio/inc/svgstyleattributes.hxx +++ b/svgio/inc/svgstyleattributes.hxx @@ -442,7 +442,7 @@ namespace svgio::svgreader // BaselineShift void setBaselineShift(const BaselineShift aBaselineShift) { maBaselineShift = aBaselineShift; } - BaselineShift getBaselineShift() const { return maBaselineShift; } + BaselineShift getBaselineShift() const; SvgNumber getBaselineShiftNumber() const; }; diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 298608773352..c7bf11ba32c5 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -1736,6 +1736,31 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156283) assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "dx2", "63"); } +CPPUNIT_TEST_FIXTURE(Test, testTdf156837) +{ + Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf156837.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", 2); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "x", "114"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "y", "103"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "16"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "x"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "x", "122"); + + // Without the fix in place, this test would have failed with + // - Expected: 94 + // - Actual : 103 + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "y", "94"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "height", "10"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", "3"); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf156271) { Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf156271.svg"); diff --git a/svgio/qa/cppunit/data/tdf156837.svg b/svgio/qa/cppunit/data/tdf156837.svg new file mode 100644 index 000000000000..f04cb015d313 --- /dev/null +++ b/svgio/qa/cppunit/data/tdf156837.svg @@ -0,0 +1,13 @@ +<svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg"> + +<defs><style type="text/css"> +.super{ + font-size: 65%; +} +</style></defs> + + <text> + <tspan x="114" y="103">x </tspan> + <tspan class="super" baseline-shift="super">3</tspan> + </text> +</svg> diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx index 6cc76cbd0e65..95c83c2f2c33 100644 --- a/svgio/source/svgreader/svgstyleattributes.cxx +++ b/svgio/source/svgreader/svgstyleattributes.cxx @@ -1292,7 +1292,7 @@ namespace svgio::svgreader maClipRule(FillRule::notset), maBaselineShift(BaselineShift::Baseline), maBaselineShiftNumber(0), - maResolvingParent(29, 0), + maResolvingParent(30, 0), mbIsClipPathContent(SVGToken::ClipPathNode == mrOwner.getType()), mbStrokeDasharraySet(false) { @@ -3093,6 +3093,26 @@ namespace svgio::svgreader return maBaselineShiftNumber; } + + BaselineShift SvgStyleAttributes::getBaselineShift() const + { + if(maBaselineShift != BaselineShift::Baseline) + { + return maBaselineShift; + } + + const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle(); + + if (pSvgStyleAttributes && maResolvingParent[29] < nStyleDepthLimit) + { + ++maResolvingParent[29]; + auto ret = pSvgStyleAttributes->getBaselineShift(); + --maResolvingParent[29]; + return ret; + } + + return BaselineShift::Baseline; + } } // end of namespace svgio /* vim:set shiftwidth=4 softtabstop=4 expandtab: */