diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-09-05 13:09:40 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-09-05 16:30:23 +0200 |
commit | 12f271ac519dfb018395b9680f082c183cd3dd14 (patch) | |
tree | ee183acb9f4d518ec05cadf524b6dba4de20d313 /svgio | |
parent | e1247697aff263fa3098edb6fd78e0c47b5ab026 (diff) |
tdf#156569: '%' can be in the middle of the string
Change-Id: I5d6ab57c17ab2cbce4d3df629a91a006fad2198d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156564
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio')
-rw-r--r-- | svgio/qa/cppunit/SvgImportTest.cxx | 33 | ||||
-rw-r--r-- | svgio/qa/cppunit/data/tdf156569.svg | 4 | ||||
-rw-r--r-- | svgio/source/svgreader/svgtools.cxx | 17 |
3 files changed, 44 insertions, 10 deletions
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 0450d3617e11..c0792504cfba 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -1787,6 +1787,39 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156283) assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "dx2", "63"); } +CPPUNIT_TEST_FIXTURE(Test, testTdf156569) +{ + Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf156569.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]", "width", "16"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "16"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "x", "0"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "y", "20"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "ABC"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "dx0", "40"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "dx1", "80"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "dx2", "91"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "width", "16"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "height", "16"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "x", "0"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "y", "30"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", "ABC"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "dx0", "40"); + + // Without the fix in place, this test would have failed with + // - Expected: 80 + // - Actual : 51 + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "dx1", "80"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "dx2", "91"); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf156837) { Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf156837.svg"); diff --git a/svgio/qa/cppunit/data/tdf156569.svg b/svgio/qa/cppunit/data/tdf156569.svg new file mode 100644 index 000000000000..ea9b3f513a0b --- /dev/null +++ b/svgio/qa/cppunit/data/tdf156569.svg @@ -0,0 +1,4 @@ +<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> + <text x="0,40,80" y="20%">ABC</text> + <text x="0 40% 80%" y="30%">ABC</text> +</svg> diff --git a/svgio/source/svgreader/svgtools.cxx b/svgio/source/svgreader/svgtools.cxx index 9cc805757544..999de3075336 100644 --- a/svgio/source/svgreader/svgtools.cxx +++ b/svgio/source/svgreader/svgtools.cxx @@ -446,7 +446,13 @@ namespace svgio::svgreader { const sal_Unicode aCharA(rCandidate[nPos]); - if(nPos + 1 < nLen) + if('%' == aCharA) + { + // percent used, relative to current + nPos++; + aRetval = SvgUnit::percent; + } + else if(nPos + 1 < nLen) { const sal_Unicode aCharB(rCandidate[nPos + 1]); bool bTwoCharValid(false); @@ -527,15 +533,6 @@ namespace svgio::svgreader nPos += 2; } } - else - { - if('%' == aCharA) - { - // percent used, relative to current - nPos++; - aRetval = SvgUnit::percent; - } - } } return aRetval; |