summaryrefslogtreecommitdiff
path: root/svgio
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-07-08 18:14:36 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-07-08 19:58:51 +0200
commitc1c8ce3b0f1037bca4d500af2f39363cd9d38db6 (patch)
tree635e2a3e9c5254aa6f38c3d30478c89fdfdab3ec /svgio
parente7cc4ceca48c263270c01e9178ac3d68869f0050 (diff)
svgio: Rename variable and add unittest
The meaning of the name got obsolete after cded65d05a01ac34af750ddb97f1ffb51f3d638a < tdf#149893: Color names are ASCII case-insensitive > Also add a unittest for 9b0069c2833313ba9fab91f45edd354ba334f94b "SVG: Using the marker property from a style sheet is equivalent to using all three (start, mid, end).ยท" when this code was added Change-Id: I87e0866cbd56bbc770920b0778ce681ac9d255b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136910 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio')
-rw-r--r--svgio/qa/cppunit/SvgImportTest.cxx22
-rw-r--r--svgio/qa/cppunit/data/markerInPresentation.svg12
-rw-r--r--svgio/source/svgreader/svgstyleattributes.cxx4
3 files changed, 36 insertions, 2 deletions
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx
index 1ce9b2e0fbfe..3165d596e333 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -45,6 +45,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools
void testFontsizePercentage();
void testFontsizeRelative();
void testMarkerOrient();
+ void testMarkerInPresentation();
void testTdf45771();
void testTdf97941();
void testTdf104339();
@@ -85,6 +86,7 @@ public:
CPPUNIT_TEST(testFontsizePercentage);
CPPUNIT_TEST(testFontsizeRelative);
CPPUNIT_TEST(testMarkerOrient);
+ CPPUNIT_TEST(testMarkerInPresentation);
CPPUNIT_TEST(testTdf45771);
CPPUNIT_TEST(testTdf97941);
CPPUNIT_TEST(testTdf104339);
@@ -343,6 +345,26 @@ void Test::testMarkerOrient()
assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy33", "1");
}
+void Test::testMarkerInPresentation()
+{
+ Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/markerInPresentation.svg");
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
+
+ drawinglayer::Primitive2dXmlDump dumper;
+ xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence);
+
+ CPPUNIT_ASSERT (pDocument);
+
+ assertXPath(pDocument, "/primitive2D/transform/transform/polypolygonstroke/line", 1);
+ assertXPath(pDocument, "/primitive2D/transform/transform/polypolygonstroke/polypolygon/polygon", 1);
+ assertXPath(pDocument, "/primitive2D/transform/transform/polypolygonstroke/polypolygon/polygon", 1);
+
+ // Without the fix in place, this test would have failed with
+ // - Expected: 0
+ // - Actual : 2
+ assertXPath(pDocument, "/primitive2D/transform/transform/transform", 0);
+}
+
void Test::testTdf45771()
{
//Check text fontsize when using relative units
diff --git a/svgio/qa/cppunit/data/markerInPresentation.svg b/svgio/qa/cppunit/data/markerInPresentation.svg
new file mode 100644
index 000000000000..5071544e39fd
--- /dev/null
+++ b/svgio/qa/cppunit/data/markerInPresentation.svg
@@ -0,0 +1,12 @@
+<svg version="1.1" baseProfile="full" id="svg-root"
+ width="100%" height="100%" viewBox="0 0 480 360"
+ xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <defs>
+ <marker id="marker2" markerUnits="strokeWidth" refX="100" refY="100" markerWidth="15" markerHeight="15" viewBox="0 0 200 200">
+ <rect width="200" height="200" fill="red" stroke="none"/>
+ </marker>
+ </defs>
+ <g marker="url(#marker2)" fill="gold" stroke="black" fill-rule="evenodd" transform="translate(50,20)">
+ <line x1="370" x2="280" y1="60" y2="140"/>
+ </g>
+</svg>
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index 70b019594248..f4f48e37d2c6 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1299,7 +1299,7 @@ namespace svgio::svgreader
void SvgStyleAttributes::parseStyleAttribute(
SVGToken aSVGToken,
const OUString& aContent,
- bool bCaseIndependent)
+ bool bIsInStyleSheet)
{
switch(aSVGToken)
{
@@ -1876,7 +1876,7 @@ namespace svgio::svgreader
}
case SVGToken::Marker:
{
- if(bCaseIndependent)
+ if(bIsInStyleSheet)
{
readLocalUrl(aContent, maMarkerEndXLink);
maMarkerStartXLink = maMarkerMidXLink = maMarkerEndXLink;