[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - svgio/qa svgio/source
svgio/qa/cppunit/SvgImportTest.cxx |2 +- svgio/qa/cppunit/data/textXmlSpace.svg |4 ++-- svgio/source/svgreader/svgtools.cxx|8 +++- 3 files changed, 6 insertions(+), 8 deletions(-) New commits: commit f5af51332344b35bc5d7a2588e785c01116277a8 Author: Xisco Fauli AuthorDate: Fri Sep 23 13:25:06 2022 +0200 Commit: Xisco Fauli CommitDate: Mon Sep 26 11:02:45 2022 +0200 tdf#151118: don't trim leading/trailing spaces in 'preserve' case Thanks again to Mike Kaganski for spotting Change-Id: Ifd8dcf15d7714ebc4f19083fefe0d78d27d46b4c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140483 Tested-by: Jenkins Reviewed-by: Xisco Fauli (cherry picked from commit 5e6b02055a887bc49c5252c1ae359ae96947e80c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140500 diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 49f88768d148..28a6d0b8784a 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -409,7 +409,7 @@ void Test::testTextXmlSpace() assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[2]", "text", "a b"); assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[3]", "text", "a b"); assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[4]", "text", "ab"); -assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[5]", "text", "a b"); +assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[5]", "text", " a b "); assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[6]", "text", "a b"); assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[7]", "text", "a b"); assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[8]", "text", "a b"); diff --git a/svgio/qa/cppunit/data/textXmlSpace.svg b/svgio/qa/cppunit/data/textXmlSpace.svg index f200d74dd3f3..fe1bc8ceeb79 100644 --- a/svgio/qa/cppunit/data/textXmlSpace.svg +++ b/svgio/qa/cppunit/data/textXmlSpace.svg @@ -1,12 +1,12 @@ http://www.w3.org/2000/svg; version="1.1" viewBox="0 0 250 250"> - a b + a b a b a b a b - a b + a b a b a b diff --git a/svgio/source/svgreader/svgtools.cxx b/svgio/source/svgreader/svgtools.cxx index e4303bbb8fc8..0da6e4f8219a 100644 --- a/svgio/source/svgreader/svgtools.cxx +++ b/svgio/source/svgreader/svgtools.cxx @@ -1512,13 +1512,11 @@ namespace svgio::svgreader // convert tab to space aRetval = convert(aRetval, aTab, aSpace, false); -// strip of all leading and trailing spaces -aRetval = aRetval.trim(); - if(bIsDefault) { -// consolidate contiguous space -aRetval = consolidateContiguousSpace(aRetval); +// strip of all leading and trailing spaces +// and consolidate contiguous space +aRetval = consolidateContiguousSpace(aRetval.trim()); } return aRetval;
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - svgio/qa svgio/source
svgio/qa/cppunit/SvgImportTest.cxx| 24 svgio/qa/cppunit/data/markerInCssStyle.svg| 14 ++ svgio/source/svgreader/svgstyleattributes.cxx |3 ++- 3 files changed, 40 insertions(+), 1 deletion(-) New commits: commit 2e1583b59816296e22b080809b2d9a8ef94b49cf Author: Xisco Fauli AuthorDate: Wed Aug 10 14:58:28 2022 +0200 Commit: Adolfo Jayme Barrientos CommitDate: Sat Aug 13 19:59:54 2022 +0200 tdf#150323: also add markers if there is a css style parent Change-Id: Ia900726ee31b7b19e98122d40b33581c9a60dcc7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138090 Tested-by: Jenkins Reviewed-by: Xisco Fauli Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138139 Reviewed-by: Adolfo Jayme Barrientos diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 3fe1b48660ce..2a254b0afd17 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -46,6 +46,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools void testFontsizePercentage(); void testFontsizeRelative(); void testMarkerOrient(); +void testMarkerInCssStyle(); void testTdf45771(); void testTdf97941(); void testTdf104339(); @@ -90,6 +91,7 @@ public: CPPUNIT_TEST(testFontsizePercentage); CPPUNIT_TEST(testFontsizeRelative); CPPUNIT_TEST(testMarkerOrient); +CPPUNIT_TEST(testMarkerInCssStyle); CPPUNIT_TEST(testTdf45771); CPPUNIT_TEST(testTdf97941); CPPUNIT_TEST(testTdf104339); @@ -368,6 +370,28 @@ void Test::testMarkerOrient() assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy33", "1"); } +void Test::testMarkerInCssStyle() +{ +Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/markerInCssStyle.svg"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); + +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence); + +CPPUNIT_ASSERT (pDocument); + +// Without the fix in place, this test would have failed with +// - Expected: 20 +// - Actual : 0 +assertXPath(pDocument, "/primitive2D/transform/transform/polypolygonstroke/line", 20); + +assertXPath(pDocument, "/primitive2D/transform/transform[1]/polypolygonstroke/line", "color", "#008000"); +assertXPath(pDocument, "/primitive2D/transform/transform[1]/polypolygonstroke/line", "width", "1"); +assertXPath(pDocument, "/primitive2D/transform/transform[1]/polypolygonstroke/line", "linejoin", "Miter"); +assertXPath(pDocument, "/primitive2D/transform/transform[1]/polypolygonstroke/line", "miterangle", "28"); +assertXPath(pDocument, "/primitive2D/transform/transform[1]/polypolygonstroke/line", "linecap", "BUTT"); +} + void Test::testTdf45771() { //Check text fontsize when using relative units diff --git a/svgio/qa/cppunit/data/markerInCssStyle.svg b/svgio/qa/cppunit/data/markerInCssStyle.svg new file mode 100644 index ..a7a8374f6ee3 --- /dev/null +++ b/svgio/qa/cppunit/data/markerInCssStyle.svg @@ -0,0 +1,14 @@ + +http://www.w3.org/2000/svg; xmlns:xlink="http://www.w3.org/1999/xlink;> + + + + + + + +path.boundary {stroke: red; fill: #ccc; stroke-width: 3; marker-mid: url(#bip); marker-end: url(#bip)} + + + + diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx index 156fadc7c689..da44e3bbb292 100644 --- a/svgio/source/svgreader/svgstyleattributes.cxx +++ b/svgio/source/svgreader/svgstyleattributes.cxx @@ -1148,7 +1148,8 @@ namespace svgio::svgreader // Svg supports markers for path, polygon, polyline and line if(SVGToken::Path == mrOwner.getType() || // path SVGToken::Polygon == mrOwner.getType() || // polygon, polyline -SVGToken::Line == mrOwner.getType()) // line +SVGToken::Line == mrOwner.getType() ||// line +getCssStyleParent()) { // try to add markers add_markers(rPath, rTarget, pHelpPointIndices);
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - svgio/qa svgio/source
svgio/qa/cppunit/SvgImportTest.cxx | 19 +++ svgio/qa/cppunit/data/symbol.svg | 11 +++ svgio/source/svgreader/svgsymbolnode.cxx |2 +- 3 files changed, 31 insertions(+), 1 deletion(-) New commits: commit 4b4773183e92be941b24fffdfd16a554c6a35439 Author: Xisco Fauli AuthorDate: Mon Jul 18 16:50:36 2022 +0200 Commit: Adolfo Jayme Barrientos CommitDate: Tue Jul 19 06:59:31 2022 +0200 tdf#126330: use correct type for symbol node Change-Id: Ibd4b7e021dac28469cb3ea2d30e79de8f24c88be Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137201 Tested-by: Jenkins Reviewed-by: Xisco Fauli (cherry picked from commit 67c422585db43e30f0c9e4c9753fcd14f87a277f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137179 Reviewed-by: Adolfo Jayme Barrientos diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index d9b803deea33..9d74ffc026b9 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -40,6 +40,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools void checkRectPrimitive(Primitive2DSequence const & rPrimitive); void testStyles(); +void testSymbol(); void testTdf87309(); void testFontsizeKeywords(); void testFontsizePercentage(); @@ -82,6 +83,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools public: CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testStyles); +CPPUNIT_TEST(testSymbol); CPPUNIT_TEST(testTdf87309); CPPUNIT_TEST(testFontsizeKeywords); CPPUNIT_TEST(testFontsizePercentage); @@ -196,6 +198,23 @@ void Test::testStyles() CPPUNIT_ASSERT(arePrimitive2DSequencesEqual(aSequenceRect, aSequenceRectWithStylesByGroup)); } +void Test::testSymbol() +{ +Primitive2DSequence aSequenceTdf87309 = parseSvg(u"/svgio/qa/cppunit/data/symbol.svg"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf87309.getLength())); + +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf87309); + +CPPUNIT_ASSERT (pDocument); + +// tdf#126330: Without the fix in place, this test would have failed with +// - Expected: 1 +// - Actual : 2 +// number of nodes is incorrect +assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#00d000"); +} + void Test::testTdf87309() { Primitive2DSequence aSequenceTdf87309 = parseSvg(u"/svgio/qa/cppunit/data/tdf87309.svg"); diff --git a/svgio/qa/cppunit/data/symbol.svg b/svgio/qa/cppunit/data/symbol.svg new file mode 100644 index ..55110f3740b0 --- /dev/null +++ b/svgio/qa/cppunit/data/symbol.svg @@ -0,0 +1,11 @@ + +http://www.w3.org/2000/svg;> + + + + + + + diff --git a/svgio/source/svgreader/svgsymbolnode.cxx b/svgio/source/svgreader/svgsymbolnode.cxx index b505a7500dc0..2d19c6a84547 100644 --- a/svgio/source/svgreader/svgsymbolnode.cxx +++ b/svgio/source/svgreader/svgsymbolnode.cxx @@ -24,7 +24,7 @@ namespace svgio::svgreader SvgSymbolNode::SvgSymbolNode( SvgDocument& rDocument, SvgNode* pParent) -: SvgNode(SVGToken::Svg, rDocument, pParent), +: SvgNode(SVGToken::Symbol, rDocument, pParent), maSvgStyleAttributes(*this) { }
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - svgio/qa svgio/source
svgio/qa/cppunit/SvgImportTest.cxx | 16 svgio/qa/cppunit/data/ClipPathUsingClipPath.svg | 24 svgio/source/svgreader/svgstyleattributes.cxx |3 ++- 3 files changed, 42 insertions(+), 1 deletion(-) New commits: commit 6cd06c36b9755cb3a9058ee1572b68e3ef4a3fad Author: Xisco Fauli AuthorDate: Mon Jul 18 13:21:35 2022 +0200 Commit: Adolfo Jayme Barrientos CommitDate: Tue Jul 19 06:58:39 2022 +0200 related: tdf#97539: SVGIO: iterate over parent's clippaths This commit reintroduces fb33451a27d8668bc14f5bcfd6ea742fc4c5b84c "tdf#97539: SVGIO: iterate over parent's clippaths" which I reverted it in 82c0a363abbceac6464b62c3571aa3225415c7db "tdf#97539; if parent is css style, look one level up" because I thought it was no longer necessary, but I was wrong. Also add a unittest Change-Id: Ib66ca0afd63e8e52be6677b6965179e092a61aa8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137195 Tested-by: Jenkins Reviewed-by: Xisco Fauli Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137208 Reviewed-by: Adolfo Jayme Barrientos diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index ff28c43f7a52..d9b803deea33 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -61,6 +61,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools void testShapeWithClipPathAndCssStyle(); void testClipPathAndParentStyle(); void testClipPathAndStyle(); +void testClipPathUsingClipPath(); void testi125329(); void testMaskingPath07b(); void test123926(); @@ -102,6 +103,7 @@ public: CPPUNIT_TEST(testShapeWithClipPathAndCssStyle); CPPUNIT_TEST(testClipPathAndParentStyle); CPPUNIT_TEST(testClipPathAndStyle); +CPPUNIT_TEST(testClipPathUsingClipPath); CPPUNIT_TEST(testi125329); CPPUNIT_TEST(testMaskingPath07b); CPPUNIT_TEST(test123926); @@ -627,6 +629,20 @@ void Test::testClipPathAndStyle() } +void Test::testClipPathUsingClipPath() +{ +Primitive2DSequence aSequenceClipPathAndStyle = parseSvg(u"/svgio/qa/cppunit/data/ClipPathUsingClipPath.svg"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceClipPathAndStyle.getLength())); + +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceClipPathAndStyle)); + +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/transform/mask/polypolygon/polygon/point", 20); +assertXPath(pDocument, "/primitive2D/transform/mask/mask/polypolygon/polygon/point", 13); +} + void Test::testi125329() { //Check style inherit from * css element diff --git a/svgio/qa/cppunit/data/ClipPathUsingClipPath.svg b/svgio/qa/cppunit/data/ClipPathUsingClipPath.svg new file mode 100644 index ..5eaa7928cb85 --- /dev/null +++ b/svgio/qa/cppunit/data/ClipPathUsingClipPath.svg @@ -0,0 +1,24 @@ + +http://www.w3.org/2000/svg; xmlns:xlink="http://www.w3.org/1999/xlink;> + + + + + + + + + + + + + + + + + + + + diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx index c7240e6fbefc..2d1a04eeb052 100644 --- a/svgio/source/svgreader/svgstyleattributes.cxx +++ b/svgio/source/svgreader/svgstyleattributes.cxx @@ -1195,10 +1195,11 @@ namespace svgio::svgreader } const SvgClipPathNode* pClip = accessClipPathXLink(); -if(pClip) +while(pClip) { // #i124852# transform may be needed when SvgUnits::userSpaceOnUse pClip->apply(aSource, pTransform); +pClip = pClip->getSvgStyleAttributes()->accessClipPathXLink(); } if(!aSource.empty()) // test again, applied clipPath may have lead to empty geometry
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - svgio/qa svgio/source
svgio/qa/cppunit/data/tdf149893.svg |2 +- svgio/source/svgreader/svgtools.cxx |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) New commits: commit 7e5abaa388e39e01b02c0d6c9b2d60ae56442f78 Author: Xisco Fauli AuthorDate: Fri Jul 8 12:12:54 2022 +0200 Commit: Adolfo Jayme Barrientos CommitDate: Sat Jul 9 09:18:23 2022 +0200 related: tdf#149893: trim the color name Change-Id: I50689993cbe979557a10d2d16eb2112471bef77d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136895 Tested-by: Jenkins Reviewed-by: Xisco Fauli (cherry picked from commit dbcedd38c2720b6a85486bddb6544417326a9402) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136873 Reviewed-by: Adolfo Jayme Barrientos diff --git a/svgio/qa/cppunit/data/tdf149893.svg b/svgio/qa/cppunit/data/tdf149893.svg index 05c41eac96af..b6b241566d13 100644 --- a/svgio/qa/cppunit/data/tdf149893.svg +++ b/svgio/qa/cppunit/data/tdf149893.svg @@ -1,3 +1,3 @@ http://www.w3.org/2000/svg;> - + diff --git a/svgio/source/svgreader/svgtools.cxx b/svgio/source/svgreader/svgtools.cxx index 94f8f20d5f0e..32a6030a7203 100644 --- a/svgio/source/svgreader/svgtools.cxx +++ b/svgio/source/svgreader/svgtools.cxx @@ -640,7 +640,7 @@ namespace svgio::svgreader { ColorTokenValueType(OUString("yellowgreen"), Color(154, 205, 50) ) }, }; -ColorTokenMapper::const_iterator aResult(aColorTokenMapperList.find(rName.toAsciiLowerCase())); +ColorTokenMapper::const_iterator aResult(aColorTokenMapperList.find(rName.toAsciiLowerCase().trim())); if(aResult == aColorTokenMapperList.end()) {
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - svgio/qa
svgio/qa/cppunit/SvgImportTest.cxx |3 ++- svgio/qa/cppunit/data/CssClassRedefinition.svg |2 +- 2 files changed, 3 insertions(+), 2 deletions(-) New commits: commit 3c4acc718549ab027be5465d60c8d5a0e3b8feaa Author: Stephan Bergmann AuthorDate: Thu Jun 23 21:52:52 2022 +0200 Commit: Stephan Bergmann CommitDate: Fri Jun 24 07:55:36 2022 +0200 Make CppunitTest_svgio CPPUNIT_TEST_NAME=Test::testCssClassRedefinition robust That recently introduced test systematically failed on my Fedora 36 machine with > /home/sbergman/lo2/core/test/source/xmltesttools.cxx:89:(anonymous namespace)::Test::testCssClassRedefinition > equality assertion failed > - Expected: 1 > - Actual : 0 > - In <>, XPath '/primitive2D/transform/textsimpleportion[1]' number of nodes is incorrect because the dumped data was > > > > > > > > > > > > > > > > rather than the expected > > > > > > > 0,0 50,0 50,100 0,100 > > > > because in SvgSvgNode::decomposeSvgNode (svgio/source/svgreader/svgsvgnode.cxx) aSvgCanvasRange = 50x100@(0,0) vs. aContentRange = 31x11@(20,9) did not match the > if(aSvgCanvasRange.isInside(aContentRange)) branch ("no clip needed, but an invisible HiddenGeometryPrimitive2D...") but rather the > else if(aSvgCanvasRange.overlaps(aContentRange)) branch ("Clip is necessary") introducing the additional element. The size of aContentRange (and thus whether it is contained in or merely overlaps aSvgCanvasRange) is apparently affected by what actual font gets substituted for "Sans" in any given environment. The only font that is guaranteed to always be available and is not subject to --with-fonts (which isn't already demanded via gb_CppunitTest_use_more_fonts in svgio/CppunitTest_svgio.mk) appears to be "Open Symbol" (cf. extras/Package_fonts.mk), so use that (even if it doesn't have glyphs for the given text, but which should be irrelevant for this test). Change-Id: If6f6fdc481b313aa08803b4b3f406e01ff0be1ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136350 Tested-by: Jenkins Reviewed-by: Stephan Bergmann (cherry picked from commit a817e83be44d82f259dc857dbca57f05da89b984) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136330 diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 650dbdde67f6..4b5af1e54d84 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -852,7 +852,8 @@ void Test::testCssClassRedefinition() CPPUNIT_ASSERT (pDocument); assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "test"); assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#ff"); -assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Sans"); +assertXPath( +pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Open Symbol"); } CPPUNIT_TEST_SUITE_REGISTRATION(Test); diff --git a/svgio/qa/cppunit/data/CssClassRedefinition.svg b/svgio/qa/cppunit/data/CssClassRedefinition.svg index 87eb2023384b..384cf88482f9 100644 --- a/svgio/qa/cppunit/data/CssClassRedefinition.svg +++ b/svgio/qa/cppunit/data/CssClassRedefinition.svg @@ -2,7 +2,7 @@
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - svgio/qa
svgio/qa/cppunit/SvgImportTest.cxx | 22 ++ svgio/qa/cppunit/data/CssClassRedefinition.svg | 13 + 2 files changed, 35 insertions(+) New commits: commit d931e8876cbaf8e409ebbba97d991d0099124de4 Author: offtkp AuthorDate: Mon Jun 20 15:23:14 2022 +0300 Commit: Stephan Bergmann CommitDate: Thu Jun 23 23:08:24 2022 +0200 tdf#149449 Add unit test for CSS class redefinition inside SVGs Tests what happens when a CSS class is redefined with new attributes and with already defined attributes Change-Id: I5996fa4dce6c98c1792001a11387bf570d159a8f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136151 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit eedc5b1c576fcaaea85a5278762efc8ba8c5a084) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136315 Reviewed-by: Stephan Bergmann diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 4f9ee58f68db..650dbdde67f6 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -70,6 +70,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools void testTdf94765(); void testBehaviourWhenWidthAndHeightIsOrIsNotSet(); void testTdf97663(); +void testCssClassRedefinition(); Primitive2DSequence parseSvg(std::u16string_view aSource); @@ -106,6 +107,7 @@ public: CPPUNIT_TEST(testTdf94765); CPPUNIT_TEST(testBehaviourWhenWidthAndHeightIsOrIsNotSet); CPPUNIT_TEST(testTdf97663); +CPPUNIT_TEST(testCssClassRedefinition); CPPUNIT_TEST_SUITE_END(); }; @@ -833,6 +835,26 @@ void Test::testTdf97663() assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "y", "236"); } +void Test::testCssClassRedefinition() +{ +// Tests for svg css class redefinition behavior +// Example: +// .c1 {fill:#00ff00} +// .c1 {font-family:Sans} +// .c1 {fill:#ff} +// Expected result is .c1 {font-family:Sans; fill:#ff} because +// the second redefinition appends attributes to the class and the +// third redefinition replaces the already existing +// attribute in the original definition +Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/CssClassRedefinition.svg"); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "test"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#ff"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Sans"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } diff --git a/svgio/qa/cppunit/data/CssClassRedefinition.svg b/svgio/qa/cppunit/data/CssClassRedefinition.svg new file mode 100644 index ..87eb2023384b --- /dev/null +++ b/svgio/qa/cppunit/data/CssClassRedefinition.svg @@ -0,0 +1,13 @@ +http://www.w3.org/2000/svg; width="50 px" height="100 px"> + +.c1 {fill:#00ff00} + +.c1 {font-family:Sans} + +.c1 {fill:#ff} + + + +test + +