From f7af4c311ad04ce5e54e08b9d7ccd71b75b7a32d Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Tue, 11 Jul 2023 16:08:38 +0200 Subject: tdf#156236: For the rx or ry properties, "0" is valid Change-Id: I32c865e409a339c444440e00ee0f624c45380773 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154307 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- svgio/qa/cppunit/SvgImportTest.cxx | 20 ++++++++++++++++++-- svgio/qa/cppunit/data/tdf156236.svg | 7 +++++++ svgio/source/svgreader/svgrectnode.cxx | 11 +++-------- 3 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 svgio/qa/cppunit/data/tdf156236.svg (limited to 'svgio') diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 0f8b31d4b1cc..9f0b8ff7b9d7 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -1048,11 +1048,11 @@ CPPUNIT_TEST_FIXTURE(Test, testClipRule) // - Actual : 10 assertXPath(pDocument, "/primitive2D/transform/mask[1]/polypolygon/polygon/point", 5); assertXPath(pDocument, "/primitive2D/transform/mask[1]/polypolygoncolor", "color", "#0000ff"); - assertXPath(pDocument, "/primitive2D/transform/mask[1]/polypolygoncolor/polypolygon/polygon/point", 5); + assertXPath(pDocument, "/primitive2D/transform/mask[1]/polypolygoncolor/polypolygon/polygon/point", 4); assertXPath(pDocument, "/primitive2D/transform/mask[2]/polypolygon/polygon/point", 5); assertXPath(pDocument, "/primitive2D/transform/mask[2]/polypolygoncolor", "color", "#ff0000"); - assertXPath(pDocument, "/primitive2D/transform/mask[2]/polypolygoncolor/polypolygon/polygon/point", 5); + assertXPath(pDocument, "/primitive2D/transform/mask[2]/polypolygoncolor/polypolygon/polygon/point", 4); } CPPUNIT_TEST_FIXTURE(Test, testi125329) @@ -1271,6 +1271,22 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf94765) assertXPath(pDocument, "/primitive2D/transform/transform/svglineargradient[2]", "endy", "0"); } +CPPUNIT_TEST_FIXTURE(Test, testTdf156236) +{ + Primitive2DSequence aSequenceTdf94765 = parseSvg(u"/svgio/qa/cppunit/data/tdf156236.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf94765.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf94765)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]/polypolygon", "path", "m50 180h-30v-60h60v60z"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]/polypolygon", "path", "m150 180h15c8.2842712474619 0 15-6.7157287525381 15-15v-30c0-8.2842712474619-6.7157287525381-15-15-15h-30c-8.2842712474619 0-15 6.7157287525381-15 15v30c0 8.2842712474619 6.7157287525381 15 15 15z"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[3]/polypolygon", "path", "m250 180h15c8.2842712474619 0 15-6.7157287525381 15-15v-30c0-8.2842712474619-6.7157287525381-15-15-15h-30c-8.2842712474619 0-15 6.7157287525381-15 15v30c0 8.2842712474619 6.7157287525381 15 15 15z"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[4]/polypolygon", "path", "m350 180c16.5685424949238 0 30-6.7157287525381 30-15v-30c0-8.2842712474619-13.4314575050762-15-30-15s-30 6.7157287525381-30 15v30c0 8.2842712474619 13.4314575050762 15 30 15z"); +} + CPPUNIT_TEST_FIXTURE(Test, testBehaviourWhenWidthAndHeightIsOrIsNotSet) { // This test checks the behaviour when width and height attributes diff --git a/svgio/qa/cppunit/data/tdf156236.svg b/svgio/qa/cppunit/data/tdf156236.svg new file mode 100644 index 000000000000..12268652c03b --- /dev/null +++ b/svgio/qa/cppunit/data/tdf156236.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/svgio/source/svgreader/svgrectnode.cxx b/svgio/source/svgreader/svgrectnode.cxx index 291d8540912f..c063ecf87195 100644 --- a/svgio/source/svgreader/svgrectnode.cxx +++ b/svgio/source/svgreader/svgrectnode.cxx @@ -32,9 +32,7 @@ namespace svgio::svgreader maX(0), maY(0), maWidth(0), - maHeight(0), - maRx(0), - maRy(0) + maHeight(0) { } @@ -176,14 +174,11 @@ namespace svgio::svgreader double frX(getRx().isSet() ? getRx().solve(*this, NumberType::xcoordinate) : 0.0); double frY(getRy().isSet() ? getRy().solve(*this, NumberType::ycoordinate) : 0.0); - frX = std::max(0.0, frX); - frY = std::max(0.0, frY); - - if(0.0 == frY && frX > 0.0) + if(!getRy().isSet() && 0.0 == frY && frX > 0.0) { frY = frX; } - else if(0.0 == frX && frY > 0.0) + else if(!getRx().isSet() && 0.0 == frX && frY > 0.0) { frX = frY; } -- cgit