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(-)

New commits:
commit f6df2e640342b6114e46b7957de093386ad35459
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Jul 11 16:08:38 2023 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Wed Jul 12 10:50:19 2023 +0200

    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 <xiscofa...@libreoffice.org>
    (cherry picked from commit 9a5c1bbedad8813e7563bd5f3a3c1217d38a3c25)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154318
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 5b733e960b77..ee21d95c1970 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -1044,11 +1044,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)
@@ -1267,6 +1267,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<int>(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 @@
+<svg viewBox="0 0 500 200" xmlns="http://www.w3.org/2000/svg";>
+  <rect x="20" y="120" width="60" height="60" rx="0" ry="15" />
+  <rect x="120" y="120" width="60" height="60" ry="15" />
+  <rect x="220" y="120" width="60" height="60" rx="-150" ry="15" />
+  <rect x="320" y="120" width="60" height="60" rx="150" ry="15" />
+</svg>
+
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;
                 }

Reply via email to