From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- svgio/qa/cppunit/SvgImportTest.cxx | 1103 ++++++++++++++++++++ svgio/qa/cppunit/SvgNumberTest.cxx | 95 ++ svgio/qa/cppunit/SvgRead.cxx | 127 +++ svgio/qa/cppunit/data/47446.svg | 19 + svgio/qa/cppunit/data/47446b.svg | 18 + svgio/qa/cppunit/data/ClipPathAndParentStyle.svg | 10 + svgio/qa/cppunit/data/ClipPathAndStyle.svg | 13 + svgio/qa/cppunit/data/ClipPathUsingClipPath.svg | 24 + svgio/qa/cppunit/data/ClipRule.svg | 18 + svgio/qa/cppunit/data/CssClassRedefinition.svg | 13 + svgio/qa/cppunit/data/Drawing_NoWidthHeight.svg | 12 + svgio/qa/cppunit/data/Drawing_WithWidthHeight.svg | 14 + svgio/qa/cppunit/data/FontsizeKeywords.svg | 14 + svgio/qa/cppunit/data/FontsizePercentage.svg | 3 + svgio/qa/cppunit/data/FontsizeRelative.svg | 6 + svgio/qa/cppunit/data/MarkerOrient.svg | 22 + svgio/qa/cppunit/data/RGBAColor.svg | 4 + svgio/qa/cppunit/data/RGBColor.svg | 4 + svgio/qa/cppunit/data/Rect.svg | 4 + svgio/qa/cppunit/data/RectWithParentStyles.svg | 13 + svgio/qa/cppunit/data/RectWithStyles.svg | 4 + svgio/qa/cppunit/data/RectWithStylesByGroup.svg | 18 + .../cppunit/data/ShapeWithClipPathAndCssStyle.svg | 13 + svgio/qa/cppunit/data/VisiotorTest-Rect.svg | 4 + svgio/qa/cppunit/data/em_units.svg | 14 + svgio/qa/cppunit/data/i125329.svg | 12 + svgio/qa/cppunit/data/markerInCssStyle.svg | 14 + svgio/qa/cppunit/data/maskText.svg | 26 + svgio/qa/cppunit/data/masking-path-07-b.svg | 147 +++ svgio/qa/cppunit/data/noneColor.svg | 3 + svgio/qa/cppunit/data/path.svg | 3 + svgio/qa/cppunit/data/symbol.svg | 11 + svgio/qa/cppunit/data/tdf101237.svg | 11 + svgio/qa/cppunit/data/tdf103888.svg | 11 + svgio/qa/cppunit/data/tdf104339.svg | 65 ++ svgio/qa/cppunit/data/tdf123926.svg | 14 + svgio/qa/cppunit/data/tdf149880.svg | 11 + svgio/qa/cppunit/data/tdf149893.svg | 3 + svgio/qa/cppunit/data/tdf45771.svg | 5 + svgio/qa/cppunit/data/tdf79163.svg | 8 + svgio/qa/cppunit/data/tdf85770.svg | 7 + svgio/qa/cppunit/data/tdf87309.svg | 4 + svgio/qa/cppunit/data/tdf94765.svg | 14 + svgio/qa/cppunit/data/tdf97542_1.svg | 15 + svgio/qa/cppunit/data/tdf97542_2.svg | 15 + svgio/qa/cppunit/data/tdf97543.svg | 4 + svgio/qa/cppunit/data/tdf97936.svg | 5 + svgio/qa/cppunit/data/tdf97941.svg | 6 + svgio/qa/cppunit/data/tdf99115.svg | 40 + svgio/qa/cppunit/data/tdf99994.svg | 8 + svgio/qa/cppunit/data/textXmlSpace.svg | 16 + svgio/qa/cppunit/data/tspan-fill-opacity.svg | 15 + 52 files changed, 2082 insertions(+) create mode 100644 svgio/qa/cppunit/SvgImportTest.cxx create mode 100644 svgio/qa/cppunit/SvgNumberTest.cxx create mode 100644 svgio/qa/cppunit/SvgRead.cxx create mode 100644 svgio/qa/cppunit/data/47446.svg create mode 100644 svgio/qa/cppunit/data/47446b.svg create mode 100644 svgio/qa/cppunit/data/ClipPathAndParentStyle.svg create mode 100644 svgio/qa/cppunit/data/ClipPathAndStyle.svg create mode 100644 svgio/qa/cppunit/data/ClipPathUsingClipPath.svg create mode 100644 svgio/qa/cppunit/data/ClipRule.svg create mode 100644 svgio/qa/cppunit/data/CssClassRedefinition.svg create mode 100644 svgio/qa/cppunit/data/Drawing_NoWidthHeight.svg create mode 100644 svgio/qa/cppunit/data/Drawing_WithWidthHeight.svg create mode 100644 svgio/qa/cppunit/data/FontsizeKeywords.svg create mode 100644 svgio/qa/cppunit/data/FontsizePercentage.svg create mode 100644 svgio/qa/cppunit/data/FontsizeRelative.svg create mode 100644 svgio/qa/cppunit/data/MarkerOrient.svg create mode 100644 svgio/qa/cppunit/data/RGBAColor.svg create mode 100644 svgio/qa/cppunit/data/RGBColor.svg create mode 100644 svgio/qa/cppunit/data/Rect.svg create mode 100644 svgio/qa/cppunit/data/RectWithParentStyles.svg create mode 100644 svgio/qa/cppunit/data/RectWithStyles.svg create mode 100644 svgio/qa/cppunit/data/RectWithStylesByGroup.svg create mode 100644 svgio/qa/cppunit/data/ShapeWithClipPathAndCssStyle.svg create mode 100644 svgio/qa/cppunit/data/VisiotorTest-Rect.svg create mode 100644 svgio/qa/cppunit/data/em_units.svg create mode 100644 svgio/qa/cppunit/data/i125329.svg create mode 100644 svgio/qa/cppunit/data/markerInCssStyle.svg create mode 100644 svgio/qa/cppunit/data/maskText.svg create mode 100644 svgio/qa/cppunit/data/masking-path-07-b.svg create mode 100644 svgio/qa/cppunit/data/noneColor.svg create mode 100644 svgio/qa/cppunit/data/path.svg create mode 100644 svgio/qa/cppunit/data/symbol.svg create mode 100644 svgio/qa/cppunit/data/tdf101237.svg create mode 100644 svgio/qa/cppunit/data/tdf103888.svg create mode 100644 svgio/qa/cppunit/data/tdf104339.svg create mode 100644 svgio/qa/cppunit/data/tdf123926.svg create mode 100644 svgio/qa/cppunit/data/tdf149880.svg create mode 100644 svgio/qa/cppunit/data/tdf149893.svg create mode 100644 svgio/qa/cppunit/data/tdf45771.svg create mode 100644 svgio/qa/cppunit/data/tdf79163.svg create mode 100644 svgio/qa/cppunit/data/tdf85770.svg create mode 100644 svgio/qa/cppunit/data/tdf87309.svg create mode 100644 svgio/qa/cppunit/data/tdf94765.svg create mode 100644 svgio/qa/cppunit/data/tdf97542_1.svg create mode 100644 svgio/qa/cppunit/data/tdf97542_2.svg create mode 100644 svgio/qa/cppunit/data/tdf97543.svg create mode 100644 svgio/qa/cppunit/data/tdf97936.svg create mode 100644 svgio/qa/cppunit/data/tdf97941.svg create mode 100644 svgio/qa/cppunit/data/tdf99115.svg create mode 100644 svgio/qa/cppunit/data/tdf99994.svg create mode 100644 svgio/qa/cppunit/data/textXmlSpace.svg create mode 100644 svgio/qa/cppunit/data/tspan-fill-opacity.svg (limited to 'svgio/qa') diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx new file mode 100644 index 000000000..ed178ffb6 --- /dev/null +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -0,0 +1,1103 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include +#include + +namespace +{ + +using namespace css; +using namespace css::uno; +using namespace css::io; +using namespace css::graphic; +using drawinglayer::primitive2d::Primitive2DSequence; +using drawinglayer::primitive2d::Primitive2DContainer; +using drawinglayer::primitive2d::Primitive2DReference; + +class Test : public test::BootstrapFixture, public XmlTestTools +{ + void checkRectPrimitive(Primitive2DSequence const & rPrimitive); + + void testStyles(); + void testSymbol(); + void testTdf87309(); + void testFontsizeKeywords(); + void testFontsizePercentage(); + void testFontsizeRelative(); + void testMarkerOrient(); + void testMarkerInCssStyle(); + void testTextXmlSpace(); + void testTdf45771(); + void testTdf97941(); + void testTdf104339(); + void testTdf85770(); + void testTdf79163(); + void testTdf97542_1(); + void testTdf97542_2(); + void testTdf97543(); + void testRGBColor(); + void testRGBAColor(); + void testNoneColor(); + void testTdf97936(); + void testTdf149893(); + void testShapeWithClipPathAndCssStyle(); + void testClipPathAndParentStyle(); + void testClipPathAndStyle(); + void testClipPathUsingClipPath(); + void testClipRule(); + void testi125329(); + void testMaskingPath07b(); + void test123926(); + void test47446(); + void test47446b(); + void testTdf103888(); + void testMaskText(); + void testTdf99994(); + void testTdf99115(); + void testTdf101237(); + void testTdf94765(); + void testBehaviourWhenWidthAndHeightIsOrIsNotSet(); + void testTdf97663(); + void testTdf149880(); + void testCssClassRedefinition(); + void testTspanFillOpacity(); + + Primitive2DSequence parseSvg(std::u16string_view aSource); + +public: + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(testStyles); + CPPUNIT_TEST(testSymbol); + CPPUNIT_TEST(testTdf87309); + CPPUNIT_TEST(testFontsizeKeywords); + CPPUNIT_TEST(testFontsizePercentage); + CPPUNIT_TEST(testFontsizeRelative); + CPPUNIT_TEST(testMarkerOrient); + CPPUNIT_TEST(testMarkerInCssStyle); + CPPUNIT_TEST(testTextXmlSpace); + CPPUNIT_TEST(testTdf45771); + CPPUNIT_TEST(testTdf97941); + CPPUNIT_TEST(testTdf104339); + CPPUNIT_TEST(testTdf85770); + CPPUNIT_TEST(testTdf79163); + CPPUNIT_TEST(testTdf97542_1); + CPPUNIT_TEST(testTdf97542_2); + CPPUNIT_TEST(testTdf97543); + CPPUNIT_TEST(testRGBColor); + CPPUNIT_TEST(testRGBAColor); + CPPUNIT_TEST(testNoneColor); + CPPUNIT_TEST(testTdf97936); + CPPUNIT_TEST(testTdf149893); + CPPUNIT_TEST(testShapeWithClipPathAndCssStyle); + CPPUNIT_TEST(testClipPathAndParentStyle); + CPPUNIT_TEST(testClipPathAndStyle); + CPPUNIT_TEST(testClipPathUsingClipPath); + CPPUNIT_TEST(testClipRule); + CPPUNIT_TEST(testi125329); + CPPUNIT_TEST(testMaskingPath07b); + CPPUNIT_TEST(test123926); + CPPUNIT_TEST(test47446); + CPPUNIT_TEST(test47446b); + CPPUNIT_TEST(testTdf103888); + CPPUNIT_TEST(testMaskText); + CPPUNIT_TEST(testTdf99994); + CPPUNIT_TEST(testTdf99115); + CPPUNIT_TEST(testTdf101237); + CPPUNIT_TEST(testTdf94765); + CPPUNIT_TEST(testBehaviourWhenWidthAndHeightIsOrIsNotSet); + CPPUNIT_TEST(testTdf97663); + CPPUNIT_TEST(testTdf149880); + CPPUNIT_TEST(testCssClassRedefinition); + CPPUNIT_TEST(testTspanFillOpacity); + CPPUNIT_TEST_SUITE_END(); +}; + +Primitive2DSequence Test::parseSvg(std::u16string_view aSource) +{ + const Reference xSvgParser = SvgTools::create(m_xContext); + + OUString aUrl = m_directories.getURLFromSrc(aSource); + OUString aPath = m_directories.getPathFromSrc(aSource); + + SvFileStream aFileStream(aUrl, StreamMode::READ); + std::size_t nSize = aFileStream.remainingSize(); + std::unique_ptr pBuffer(new sal_Int8[nSize + 1]); + aFileStream.ReadBytes(pBuffer.get(), nSize); + pBuffer[nSize] = 0; + + Sequence aData(pBuffer.get(), nSize + 1); + Reference aInputStream(new comphelper::SequenceInputStream(aData)); + + return xSvgParser->getDecomposition(aInputStream, aPath); +} + +void Test::checkRectPrimitive(Primitive2DSequence const & rPrimitive) +{ + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(rPrimitive)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#00cc00"); // rect background color + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "height", "100"); // rect background height + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "width", "100"); // rect background width + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "minx", "10"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "miny", "10"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "maxx", "110"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "maxy", "110"); + assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "color", "#ff0000"); // rect stroke color + assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "width", "3"); // rect stroke width + + +} + +bool arePrimitive2DSequencesEqual(const Primitive2DSequence& rA, const Primitive2DSequence& rB) +{ + return std::equal(rA.begin(), rA.end(), rB.begin(), rB.end(), + [](const css::uno::Reference& a, + const css::uno::Reference& b) + { + return drawinglayer::primitive2d::arePrimitive2DReferencesEqual(a, b); + }); +} + +// Attributes for an object (like rect as in this case) can be defined +// in different ways (directly with xml attributes, or with CSS styles), +// however the end result should be the same. +void Test::testStyles() +{ + Primitive2DSequence aSequenceRect = parseSvg(u"/svgio/qa/cppunit/data/Rect.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceRect.getLength())); + checkRectPrimitive(aSequenceRect); + + Primitive2DSequence aSequenceRectWithStyle = parseSvg(u"/svgio/qa/cppunit/data/RectWithStyles.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceRectWithStyle.getLength())); + checkRectPrimitive(aSequenceRectWithStyle); + + Primitive2DSequence aSequenceRectWithParentStyle = parseSvg(u"/svgio/qa/cppunit/data/RectWithParentStyles.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceRectWithParentStyle.getLength())); + checkRectPrimitive(aSequenceRectWithParentStyle); + + Primitive2DSequence aSequenceRectWithStylesByGroup = parseSvg(u"/svgio/qa/cppunit/data/RectWithStylesByGroup.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceRectWithStylesByGroup.getLength())); + checkRectPrimitive(aSequenceRectWithStylesByGroup); + + CPPUNIT_ASSERT(arePrimitive2DSequencesEqual(aSequenceRect, aSequenceRectWithStyle)); + CPPUNIT_ASSERT(arePrimitive2DSequencesEqual(aSequenceRect, aSequenceRectWithParentStyle)); + 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"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf87309.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf87309); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#000000"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "height", "100"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "width", "100"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "minx", "10"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "miny", "10"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "maxx", "110"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "maxy", "110"); +} + +void Test::testFontsizeKeywords() +{ + Primitive2DSequence aSequenceFontsizeKeywords = parseSvg(u"/svgio/qa/cppunit/data/FontsizeKeywords.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceFontsizeKeywords.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceFontsizeKeywords); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#000000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "Sample"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "9"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Times New Roman"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "fontcolor", "#ffffff"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", "Sample"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "height", "11"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "familyname", "Times New Roman"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "fontcolor", "#ffd700"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "text", "Sample"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "height", "13"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "familyname", "Times New Roman"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "fontcolor", "#ff0000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "text", "Sample"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "height", "16"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "familyname", "Times New Roman"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "fontcolor", "#ffff00"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "text", "Sample"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "height", "19"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "familyname", "Times New Roman"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "fontcolor", "#0000ff"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "text", "Sample"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "height", "23"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "familyname", "Times New Roman"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "fontcolor", "#008000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "text", "Sample"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "height", "27"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "familyname", "Times New Roman"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "fontcolor", "#ff7f50"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "text", "Sample"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "height", "13"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "familyname", "Times New Roman"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "fontcolor", "#ffc0cb"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "text", "Sample"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "height", "19"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "familyname", "Times New Roman"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[10]", "fontcolor", "#fffff0"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[10]", "text", "Sample"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[10]", "height", "16"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "familyname", "Times New Roman"); +} + + +void Test::testFontsizePercentage() +{ + //Check when font-size uses percentage and defined globally + Primitive2DSequence aSequenceFontsizePercentage = parseSvg(u"/svgio/qa/cppunit/data/FontsizePercentage.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceFontsizePercentage.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceFontsizePercentage); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#000000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "Sample"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "16"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Times New Roman"); +} + +void Test::testFontsizeRelative() +{ + //Check when font-size uses relative units (em,ex) and it's based on its parent's font-size + Primitive2DSequence aSequenceFontsizeRelative = parseSvg(u"/svgio/qa/cppunit/data/FontsizeRelative.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceFontsizeRelative.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceFontsizeRelative); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#000000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "Sample"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "50"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "serif"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "fontcolor", "#000000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", "Sample"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "height", "50"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "familyname", "serif"); +} + +void Test::testMarkerOrient() +{ + Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/MarkerOrient.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy11", "0"); + assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy12", "0"); + assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy13", "7"); + assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy21", "0"); + assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy22", "0"); + assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy23", "13"); + assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy31", "0"); + assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy32", "0"); + assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy33", "1"); + + assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy11", "0"); + assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy12", "0"); + assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy13", "87"); + assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy21", "0"); + assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy22", "0"); + assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy23", "87"); + assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy31", "0"); + assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy32", "0"); + 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::testTextXmlSpace() +{ + //Check tspan fontsize when using relative units + Primitive2DSequence aSequenceTdf97941 = parseSvg(u"/svgio/qa/cppunit/data/textXmlSpace.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf97941.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf97941); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[1]", "text", "a b"); + 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[6]", "text", "a b"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[7]", "text", "a b"); + assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[8]", "text", "a b"); +} + +void Test::testTdf45771() +{ + //Check text fontsize when using relative units + Primitive2DSequence aSequenceTdf45771 = parseSvg(u"/svgio/qa/cppunit/data/tdf45771.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf45771.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf45771); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#000000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "Sample"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "32"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Times New Roman"); +} + +void Test::testTdf97941() +{ + //Check tspan fontsize when using relative units + Primitive2DSequence aSequenceTdf97941 = parseSvg(u"/svgio/qa/cppunit/data/tdf97941.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf97941.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf97941); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#000000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "Sample"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "48"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Times New Roman"); +} + +void Test::testTdf104339() +{ + Primitive2DSequence aSequenceTdf104339 = parseSvg(u"/svgio/qa/cppunit/data/tdf104339.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf104339.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf104339); + + CPPUNIT_ASSERT (pDocument); + assertXPath(pDocument, "/primitive2D/transform/transform/transform/transform/transform/polypolygoncolor", "color", "#000000"); +} + +void Test::testTdf85770() +{ + Primitive2DSequence aSequenceTdf85770 = parseSvg(u"/svgio/qa/cppunit/data/tdf85770.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf85770.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf85770)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#000000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "Start Middle End"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "11"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Times New Roman"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "fontcolor", "#000000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", "Start"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "height", "11"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "familyname", "Times New Roman"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "fontcolor", "#000000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "text", "End"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "height", "11"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "familyname", "Times New Roman"); + +} + +void Test::testTdf79163() +{ + //Check Opacity + Primitive2DSequence aSequenceTdf79163 = parseSvg(u"/svgio/qa/cppunit/data/tdf79163.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf79163.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf79163)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/unifiedtransparence", "transparence", "50"); +} + +void Test::testTdf97542_1() +{ + Primitive2DSequence aSequenceTdf97542_1 = parseSvg(u"/svgio/qa/cppunit/data/tdf97542_1.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf97542_1.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf97542_1)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/objectinfo/textsimpleportion", "fontcolor", "#ffff00"); + assertXPath(pDocument, "/primitive2D/transform/objectinfo/textsimpleportion", "text", "Text"); + assertXPath(pDocument, "/primitive2D/transform/objectinfo/textsimpleportion", "height", "48"); + assertXPath(pDocument, "/primitive2D/transform/objectinfo/textsimpleportion", "familyname", "serif"); +} + +void Test::testTdf97542_2() +{ + Primitive2DSequence aSequenceTdf97542_2 = parseSvg(u"/svgio/qa/cppunit/data/tdf97542_2.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf97542_2.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf97542_2)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/objectinfo/svgradialgradient", "startx", "1"); + assertXPath(pDocument, "/primitive2D/transform/objectinfo/svgradialgradient", "starty", "1"); + assertXPath(pDocument, "/primitive2D/transform/objectinfo/svgradialgradient/focalx", 0); + assertXPath(pDocument, "/primitive2D/transform/objectinfo/svgradialgradient/focaly", 0); + assertXPath(pDocument, "/primitive2D/transform/objectinfo/svgradialgradient", "radius", "3"); + assertXPath(pDocument, "/primitive2D/transform/objectinfo/svgradialgradient", "spreadmethod", "pad"); + assertXPath(pDocument, "/primitive2D/transform/objectinfo/svgradialgradient", "opacity", "1"); +} + +void Test::testTdf97543() +{ + // check visibility="inherit" + Primitive2DSequence aSequenceTdf97543 = parseSvg(u"/svgio/qa/cppunit/data/tdf97543.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf97543.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf97543)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#00cc00"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "height", "100"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "width", "100"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "minx", "10"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "miny", "10"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "maxx", "110"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "maxy", "110"); +} + +void Test::testRGBColor() +{ + Primitive2DSequence aSequenceRGBColor = parseSvg(u"/svgio/qa/cppunit/data/RGBColor.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceRGBColor.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceRGBColor)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#646464"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "height", "100"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "width", "100"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "minx", "10"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "miny", "10"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "maxx", "110"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "maxy", "110"); +} + +void Test::testRGBAColor() +{ + Primitive2DSequence aSequenceRGBAColor = parseSvg(u"/svgio/qa/cppunit/data/RGBAColor.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceRGBAColor.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceRGBAColor)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/unifiedtransparence", "transparence", "50"); +} + +void Test::testNoneColor() +{ + Primitive2DSequence aSequenceRGBAColor = parseSvg(u"/svgio/qa/cppunit/data/noneColor.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceRGBAColor.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceRGBAColor)); + + CPPUNIT_ASSERT (pDocument); + + //No polypolygoncolor exists + assertXPath(pDocument, "/primitive2D/transform/mask/polypolygoncolor", 0); + assertXPath(pDocument, "/primitive2D/transform/mask/polypolygonstroke/line", "color", "#000000"); + assertXPath(pDocument, "/primitive2D/transform/mask/polypolygonstroke/line", "width", "3"); +} + +void Test::testTdf97936() +{ + // check that both rectangles are rendered in the viewBox + Primitive2DSequence aSequenceTdf97936 = parseSvg(u"/svgio/qa/cppunit/data/tdf97936.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf97936.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf97936)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]/polypolygon", "height", "50"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]/polypolygon", "width", "50"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]/polypolygon", "minx", "70"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]/polypolygon", "miny", "50"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]/polypolygon", "maxx", "120"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]/polypolygon", "maxy", "100"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]/polypolygon", "height", "50"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]/polypolygon", "width", "50"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]/polypolygon", "minx", "10"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]/polypolygon", "miny", "50"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]/polypolygon", "maxx", "60"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]/polypolygon", "maxy", "100"); +} + +void Test::testTdf149893() +{ + Primitive2DSequence aSequenceClipPathAndParentStyle = parseSvg(u"/svgio/qa/cppunit/data/tdf149893.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceClipPathAndParentStyle.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceClipPathAndParentStyle)); + + CPPUNIT_ASSERT (pDocument); + + // Without the fix in place, this test would have failed with + // - Expected: #008000 + // - Actual : #000000 + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#008000"); +} + +void Test::testShapeWithClipPathAndCssStyle() +{ + // tdf#97539: Check there is a mask and 3 polygons + Primitive2DSequence aSequenceClipPathAndStyle = parseSvg(u"/svgio/qa/cppunit/data/ShapeWithClipPathAndCssStyle.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", 2); + assertXPath(pDocument, "/primitive2D/transform/mask/polypolygoncolor/polypolygon/polygon", 1); +} + +void Test::testClipPathAndParentStyle() +{ + //Check that fill color, stroke color and stroke-width are inherited from use element + //when the element is within a clipPath element + Primitive2DSequence aSequenceClipPathAndParentStyle = parseSvg(u"/svgio/qa/cppunit/data/ClipPathAndParentStyle.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceClipPathAndParentStyle.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceClipPathAndParentStyle)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#ff0000"); + assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "color", "#000000"); + assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "width", "5"); + +} + +void Test::testClipPathAndStyle() +{ + //Check that fill color, stroke color and stroke-width are inherited from use element + //when the element is within a clipPath element + Primitive2DSequence aSequenceClipPathAndStyle = parseSvg(u"/svgio/qa/cppunit/data/ClipPathAndStyle.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/polypolygoncolor", "color", "#ccccff"); + assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "color", "#0000cc"); + assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "width", "2"); + +} + +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::testClipRule() +{ + Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/ClipRule.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); + + CPPUNIT_ASSERT (pDocument); + + // Without the place in place, this test would have failed with + // - Expected: 5 + // - 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[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); +} + +void Test::testi125329() +{ + //Check style inherit from * css element + Primitive2DSequence aSequencei125329 = parseSvg(u"/svgio/qa/cppunit/data/i125329.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequencei125329.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequencei125329)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor", "color", "#c0c0c0"); // rect background color + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "height", "30"); // rect background height + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "width", "50"); // rect background width + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "minx", "15"); + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "miny", "15"); + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "maxx", "65"); + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "maxy", "45"); + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygonstroke/line", "color", "#008000"); // rect stroke color + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygonstroke/line", "width", "1"); // rect stroke width +} + +void Test::testMaskingPath07b() +{ + //For the time being, check that masking-path-07-b.svg can be imported and it doesn't hang on loading + //it used to hang after d5649ae7b76278cb3155f951d6327157c7c92b65 + Primitive2DSequence aSequenceMaskingPath07b = parseSvg(u"/svgio/qa/cppunit/data/masking-path-07-b.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceMaskingPath07b.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceMaskingPath07b)); + + CPPUNIT_ASSERT (pDocument); + +} + +void Test::test123926() +{ + Primitive2DSequence aSequence123926 = parseSvg(u"/svgio/qa/cppunit/data/tdf123926.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence123926.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence123926)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/transform/transform/unifiedtransparence/polypolygoncolor", "color", "#7cb5ec"); +} + +void Test::test47446() +{ + //Check that marker's fill attribute is black is not set + Primitive2DSequence aSequence47446 = parseSvg(u"/svgio/qa/cppunit/data/47446.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence47446.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence47446)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/transform/transform/polypolygoncolor", "color", "#000000"); + +} + +void Test::test47446b() +{ + //Check that marker's fill attribute is inherit from def + Primitive2DSequence aSequence47446b = parseSvg(u"/svgio/qa/cppunit/data/47446b.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence47446b.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence47446b)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/transform/transform/polypolygoncolor", "color", "#ffff00"); + +} + +void Test::testTdf103888() +{ + Primitive2DSequence aSequenceMaskText = parseSvg(u"/svgio/qa/cppunit/data/tdf103888.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceMaskText.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceMaskText)); + + CPPUNIT_ASSERT (pDocument); + + // Without the fix in place, this test would have failed here with number of nodes is incorrect + assertXPath(pDocument, "/primitive2D/transform/transform/textsimpleportion[1]", "text", "Her"); + assertXPath(pDocument, "/primitive2D/transform/transform/textsimpleportion[2]", "text", "vor"); + assertXPath(pDocument, "/primitive2D/transform/transform/textsimpleportion[3]", "text", "hebung"); +} + +void Test::testMaskText() +{ + //Check that mask is applied on text + Primitive2DSequence aSequenceMaskText = parseSvg(u"/svgio/qa/cppunit/data/maskText.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceMaskText.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceMaskText)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor", "color", "#000000"); + assertXPath(pDocument, "/primitive2D/transform/transform/textsimpleportion", "fontcolor", "#ffffff"); + assertXPath(pDocument, "/primitive2D/transform/transform/textsimpleportion", "text", "Black White"); + assertXPath(pDocument, "/primitive2D/transform/transform/textsimpleportion", "height", "26"); + assertXPath(pDocument, "/primitive2D/transform/transform/textsimpleportion", "familyname", "Times New Roman"); +} + +void Test::testTdf99994() +{ + //Check text fontsize when using relative units + Primitive2DSequence aSequenceTdf99994 = parseSvg(u"/svgio/qa/cppunit/data/tdf99994.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf99994.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf99994)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#0000ff"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "16"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "test"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Sans"); +} + +void Test::testTdf99115() +{ + //Check that styles are resolved correctly where there is a * css selector + Primitive2DSequence aSequenceTdf99115 = parseSvg(u"/svgio/qa/cppunit/data/tdf99115.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf99115.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf99115) ); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "red 1"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#ff0000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "18"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", "red 2"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "fontcolor", "#ff0000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "height", "18"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "text", "red 3"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "fontcolor", "#ff0000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "height", "18"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "text", "blue 4"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "fontcolor", "#0000ff"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "height", "18"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "text", "blue 5"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "fontcolor", "#0000ff"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "height", "18"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "text", "blue 6"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "fontcolor", "#0000ff"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "height", "18"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "text", "green 7"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "fontcolor", "#008000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "height", "18"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "text", "green 8"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "fontcolor", "#008000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "height", "18"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "text", "green 9"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "fontcolor", "#008000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "height", "18"); +} + +void Test::testTdf101237() +{ + //Check that fill color, stroke color and stroke-width are inherited from use element + //when the element is within a clipPath element + Primitive2DSequence aSequenceTdf101237 = parseSvg(u"/svgio/qa/cppunit/data/tdf101237.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf101237.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf101237)); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#ff0000"); + assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "color", "#000000"); + assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "width", "5"); +} + +void Test::testTdf94765() +{ + Primitive2DSequence aSequenceTdf94765 = parseSvg(u"/svgio/qa/cppunit/data/tdf94765.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequenceTdf94765.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf94765)); + + CPPUNIT_ASSERT (pDocument); + + //Check that both rectangles use the gradient as fill + assertXPath(pDocument, "/primitive2D/transform/transform/svglineargradient[1]", "startx", "1"); + assertXPath(pDocument, "/primitive2D/transform/transform/svglineargradient[1]", "starty", "1"); + assertXPath(pDocument, "/primitive2D/transform/transform/svglineargradient[1]", "endx", "2"); + assertXPath(pDocument, "/primitive2D/transform/transform/svglineargradient[1]", "endy", "1"); + assertXPath(pDocument, "/primitive2D/transform/transform/svglineargradient[2]", "startx", "0"); + assertXPath(pDocument, "/primitive2D/transform/transform/svglineargradient[2]", "starty", "0"); + assertXPath(pDocument, "/primitive2D/transform/transform/svglineargradient[2]", "endx", "0"); + assertXPath(pDocument, "/primitive2D/transform/transform/svglineargradient[2]", "endy", "0"); +} + +void Test::testBehaviourWhenWidthAndHeightIsOrIsNotSet() +{ + // This test checks the behaviour when width and height attributes + // are and are not set. In both cases the result must be the same, + // however if the width / height are set, then the size of the image + // is enforced, but this isn't really possible in LibreOffice (or + // maybe we could lock the size in this case). + // The behaviour in browsers is that when a SVG image has width / height + // attributes set, then the image is shown with that size, but if it + // isn't set then it is shown as scalable image which is the size of + // the container. + + { + const Primitive2DSequence aSequence = parseSvg(u"svgio/qa/cppunit/data/Drawing_WithWidthHeight.svg"); + CPPUNIT_ASSERT(aSequence.hasElements()); + + geometry::RealRectangle2D aRealRect; + basegfx::B2DRange aRange; + uno::Sequence aViewParameters; + + for (css::uno::Reference const & xReference : aSequence) + { + if (xReference.is()) + { + aRealRect = xReference->getRange(aViewParameters); + aRange.expand(basegfx::B2DRange(aRealRect.X1, aRealRect.Y1, aRealRect.X2, aRealRect.Y2)); + } + } + + double fWidth = (aRange.getWidth() / 2540.0) * 96.0; + double fHeight = (aRange.getHeight() / 2540.0) * 96.0; + + CPPUNIT_ASSERT_DOUBLES_EQUAL(11.0, fWidth, 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(11.0, fHeight, 1E-12); + } + + { + const Primitive2DSequence aSequence = parseSvg(u"svgio/qa/cppunit/data/Drawing_NoWidthHeight.svg"); + CPPUNIT_ASSERT(aSequence.hasElements()); + + + geometry::RealRectangle2D aRealRect; + basegfx::B2DRange aRange; + uno::Sequence aViewParameters; + + for (css::uno::Reference const & xReference : aSequence) + { + if (xReference.is()) + { + aRealRect = xReference->getRange(aViewParameters); + aRange.expand(basegfx::B2DRange(aRealRect.X1, aRealRect.Y1, aRealRect.X2, aRealRect.Y2)); + } + } + + double fWidth = (aRange.getWidth() / 2540.0) * 96.0; + double fHeight = (aRange.getHeight() / 2540.0) * 96.0; + + CPPUNIT_ASSERT_DOUBLES_EQUAL(11.0, fWidth, 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(11.0, fHeight, 1E-12); + } +} + +void Test::testTdf97663() +{ + Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/em_units.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); + + CPPUNIT_ASSERT (pDocument); + + // tdf#97663: Without the fix in place, this test would have failed with + // - Expected: 236 + // - Actual : 204 + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "y", "236"); +} + +void Test::testTdf149880() +{ + Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf149880.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); + + CPPUNIT_ASSERT (pDocument); + + // Without the fix in place, this test would have failed with + // - Expected: 1 + // - Actual : 0 + // - In <>, XPath '/primitive2D/transform/mask/unhandled' number of nodes is incorrect + assertXPath(pDocument, + "/primitive2D/transform/mask/unhandled", "id", "PATTERNFILL"); + assertXPath(pDocument, + "/primitive2D/transform/mask/unhandled/mask/transform/transform/bitmap", 28); +} + +void Test::testCssClassRedefinition() +{ + // Tests for svg css class redefinition behavior + // Example: + // .c1 {fill:#00ff00} + // .c1 {font-family:Sans} + // .c1 {fill:#ff0000} + // Expected result is .c1 {font-family:Sans; fill:#ff0000} 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", "#ff0000"); + assertXPath( + pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Open Symbol"); +} + +void Test::testTspanFillOpacity() +{ + // Given an SVG file with : + std::u16string_view aPath = u"/svgio/qa/cppunit/data/tspan-fill-opacity.svg"; + + // When rendering that SVG: + Primitive2DSequence aSequence = parseSvg(aPath); + + // Then make sure that the text portion is wrapped in a transparency primitive with the correct + // transparency value: + drawinglayer::Primitive2dXmlDump aDumper; + xmlDocUniquePtr pDocument = aDumper.dumpAndParse(Primitive2DContainer(aSequence)); + sal_Int32 nTransparence = getXPath(pDocument, "//textsimpleportion[@text='hello']/parent::unifiedtransparence", "transparence").toInt32(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 0 + // - XPath '//textsimpleportion[@text='hello']/parent::unifiedtransparence' number of nodes is incorrect + // i.e. the relevant had no parent, the text was not + // semi-transparent. + CPPUNIT_ASSERT_EQUAL(static_cast(70), nTransparence); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(Test); + +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svgio/qa/cppunit/SvgNumberTest.cxx b/svgio/qa/cppunit/SvgNumberTest.cxx new file mode 100644 index 000000000..f420a44b4 --- /dev/null +++ b/svgio/qa/cppunit/SvgNumberTest.cxx @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include +#include +#include +#include + +#include + +namespace +{ +class TestNumber : public CppUnit::TestFixture +{ + void testSetting(); + void testSolve(); + +public: + CPPUNIT_TEST_SUITE(TestNumber); + CPPUNIT_TEST(testSetting); + CPPUNIT_TEST(testSolve); + CPPUNIT_TEST_SUITE_END(); +}; + +class TestInfoProvider : public svgio::svgreader::InfoProvider +{ +public: + basegfx::B2DRange getCurrentViewPort() const override + { + return basegfx::B2DRange(0.0, 0.0, 0.0, 0.0); + } + + double getCurrentFontSizeInherited() const override { return 12.0; } + + double getCurrentXHeightInherited() const override { return 5.0; } +}; + +void TestNumber::testSetting() +{ + { + svgio::svgreader::SvgNumber aNumber; + CPPUNIT_ASSERT_EQUAL(svgio::svgreader::SvgUnit::px, aNumber.getUnit()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, aNumber.getNumber(), 1e-8); + CPPUNIT_ASSERT_EQUAL(false, aNumber.isSet()); + } + { + svgio::svgreader::SvgNumber aNumber(0.01); + CPPUNIT_ASSERT_EQUAL(svgio::svgreader::SvgUnit::px, aNumber.getUnit()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.01, aNumber.getNumber(), 1e-8); + CPPUNIT_ASSERT_EQUAL(true, aNumber.isSet()); + } + { + svgio::svgreader::SvgNumber aNumber(1.01, svgio::svgreader::SvgUnit::cm); + CPPUNIT_ASSERT_EQUAL(svgio::svgreader::SvgUnit::cm, aNumber.getUnit()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.01, aNumber.getNumber(), 1e-8); + CPPUNIT_ASSERT_EQUAL(true, aNumber.isSet()); + } +} + +void TestNumber::testSolve() +{ + { + svgio::svgreader::SvgNumber aNumber(1.01); + TestInfoProvider aInfoProvider; + double aSolvedNumber = aNumber.solve(aInfoProvider); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.01, aSolvedNumber, 1e-8); + } + { + svgio::svgreader::SvgNumber aNumber(1.0, svgio::svgreader::SvgUnit::pt); + TestInfoProvider aInfoProvider; + double aSolvedNumber = aNumber.solve(aInfoProvider); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.333, aSolvedNumber, 1e-3); + } + { + svgio::svgreader::SvgNumber aNumber(2.54, svgio::svgreader::SvgUnit::cm); + TestInfoProvider aInfoProvider; + double aSolvedNumber = aNumber.solve(aInfoProvider); + CPPUNIT_ASSERT_DOUBLES_EQUAL(96.0, aSolvedNumber, 1e-3); + } +} + +CPPUNIT_TEST_SUITE_REGISTRATION(TestNumber); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svgio/qa/cppunit/SvgRead.cxx b/svgio/qa/cppunit/SvgRead.cxx new file mode 100644 index 000000000..127de19a7 --- /dev/null +++ b/svgio/qa/cppunit/SvgRead.cxx @@ -0,0 +1,127 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include + +#include + +#include +#include +#include + +#include +#include + +#include +#include + +namespace +{ +using namespace css; + +class TestParsing : public test::BootstrapFixture +{ + void testSimpleRectangle(); + void testPath(); + uno::Reference parseSvg(const OUString& aSource); + +public: + CPPUNIT_TEST_SUITE(TestParsing); + CPPUNIT_TEST(testSimpleRectangle); + CPPUNIT_TEST(testPath); + CPPUNIT_TEST_SUITE_END(); +}; + +uno::Reference TestParsing::parseSvg(const OUString& aSource) +{ + SvFileStream aFileStream(aSource, StreamMode::READ); + std::size_t nSize = aFileStream.remainingSize(); + std::unique_ptr pBuffer(new sal_Int8[nSize + 1]); + aFileStream.ReadBytes(pBuffer.get(), nSize); + pBuffer[nSize] = 0; + + uno::Sequence aData(pBuffer.get(), nSize + 1); + uno::Reference aInputStream(new comphelper::SequenceInputStream(aData)); + + return aInputStream; +} + +void TestParsing::testSimpleRectangle() +{ + OUString aSvgFile = "/svgio/qa/cppunit/data/VisiotorTest-Rect.svg"; + OUString aUrl = m_directories.getURLFromSrc(aSvgFile); + OUString aPath = m_directories.getPathFromSrc(aSvgFile); + + uno::Reference xStream = parseSvg(aUrl); + CPPUNIT_ASSERT(xStream.is()); + + uno::Reference xContext(comphelper::getProcessComponentContext()); + const uno::Reference xSvgParser = graphic::SvgTools::create(xContext); + + uno::Any aAny = xSvgParser->getDrawCommands(xStream, aPath); + CPPUNIT_ASSERT(aAny.has()); + auto* pDrawRoot = reinterpret_cast(aAny.get()); + + basegfx::B2DRange aSurfaceRectangle(0, 0, 120, 120); + + CPPUNIT_ASSERT_EQUAL(size_t(1), pDrawRoot->maChildren.size()); + CPPUNIT_ASSERT_EQUAL(aSurfaceRectangle, pDrawRoot->maRectangle); + + auto* pDrawBase = pDrawRoot->maChildren[0].get(); + CPPUNIT_ASSERT_EQUAL(gfx::DrawCommandType::Rectangle, pDrawRoot->maChildren[0]->getType()); + auto* pDrawRect = static_cast(pDrawBase); + CPPUNIT_ASSERT_EQUAL(basegfx::B2DRange(10, 10, 110, 110), pDrawRect->maRectangle); + CPPUNIT_ASSERT_EQUAL(3.0, pDrawRect->mnStrokeWidth); + CPPUNIT_ASSERT(bool(pDrawRect->mpStrokeColor)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xff0000), sal_Int32(Color(*pDrawRect->mpStrokeColor))); + CPPUNIT_ASSERT(bool(pDrawRect->mpFillColor)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00cc00), sal_Int32(Color(*pDrawRect->mpFillColor))); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1, pDrawRect->mnOpacity, 1E-12); +} + +void TestParsing::testPath() +{ + OUString aSvgFile = "/svgio/qa/cppunit/data/path.svg"; + OUString aUrl = m_directories.getURLFromSrc(aSvgFile); + OUString aPath = m_directories.getPathFromSrc(aSvgFile); + + uno::Reference xStream = parseSvg(aUrl); + CPPUNIT_ASSERT(xStream.is()); + + uno::Reference xContext(comphelper::getProcessComponentContext()); + const uno::Reference xSvgParser = graphic::SvgTools::create(xContext); + + uno::Any aAny = xSvgParser->getDrawCommands(xStream, aPath); + CPPUNIT_ASSERT(aAny.has()); + auto* pDrawRoot = reinterpret_cast(aAny.get()); + + CPPUNIT_ASSERT_EQUAL(size_t(1), pDrawRoot->maChildren.size()); + + auto* pDrawBase = pDrawRoot->maChildren[0].get(); + CPPUNIT_ASSERT_EQUAL(gfx::DrawCommandType::Path, pDrawBase->getType()); + auto* pDrawPath = static_cast(pDrawBase); + + CPPUNIT_ASSERT_EQUAL(OUString("m1 1h42v24h-42v-24z"), + basegfx::utils::exportToSvgD(pDrawPath->maPolyPolygon, true, true, false)); + CPPUNIT_ASSERT_EQUAL(0.0, pDrawPath->mnStrokeWidth); + CPPUNIT_ASSERT(bool(pDrawPath->mpStrokeColor)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), sal_Int32(Color(*pDrawPath->mpStrokeColor))); + CPPUNIT_ASSERT(bool(pDrawPath->mpFillColor)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x007aff), sal_Int32(Color(*pDrawPath->mpFillColor))); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1, pDrawPath->mnOpacity, 1E-12); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(TestParsing); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svgio/qa/cppunit/data/47446.svg b/svgio/qa/cppunit/data/47446.svg new file mode 100644 index 000000000..aec66b9bd --- /dev/null +++ b/svgio/qa/cppunit/data/47446.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + diff --git a/svgio/qa/cppunit/data/47446b.svg b/svgio/qa/cppunit/data/47446b.svg new file mode 100644 index 000000000..29cfce5d8 --- /dev/null +++ b/svgio/qa/cppunit/data/47446b.svg @@ -0,0 +1,18 @@ + + + + + + + + + + diff --git a/svgio/qa/cppunit/data/ClipPathAndParentStyle.svg b/svgio/qa/cppunit/data/ClipPathAndParentStyle.svg new file mode 100644 index 000000000..d85a95995 --- /dev/null +++ b/svgio/qa/cppunit/data/ClipPathAndParentStyle.svg @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/svgio/qa/cppunit/data/ClipPathAndStyle.svg b/svgio/qa/cppunit/data/ClipPathAndStyle.svg new file mode 100644 index 000000000..f3b1777fa --- /dev/null +++ b/svgio/qa/cppunit/data/ClipPathAndStyle.svg @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/svgio/qa/cppunit/data/ClipPathUsingClipPath.svg b/svgio/qa/cppunit/data/ClipPathUsingClipPath.svg new file mode 100644 index 000000000..5eaa7928c --- /dev/null +++ b/svgio/qa/cppunit/data/ClipPathUsingClipPath.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/svgio/qa/cppunit/data/ClipRule.svg b/svgio/qa/cppunit/data/ClipRule.svg new file mode 100644 index 000000000..55f0cb9ee --- /dev/null +++ b/svgio/qa/cppunit/data/ClipRule.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + diff --git a/svgio/qa/cppunit/data/CssClassRedefinition.svg b/svgio/qa/cppunit/data/CssClassRedefinition.svg new file mode 100644 index 000000000..384cf8848 --- /dev/null +++ b/svgio/qa/cppunit/data/CssClassRedefinition.svg @@ -0,0 +1,13 @@ + + + + test + + diff --git a/svgio/qa/cppunit/data/Drawing_NoWidthHeight.svg b/svgio/qa/cppunit/data/Drawing_NoWidthHeight.svg new file mode 100644 index 000000000..59520d6ab --- /dev/null +++ b/svgio/qa/cppunit/data/Drawing_NoWidthHeight.svg @@ -0,0 +1,12 @@ + + + + diff --git a/svgio/qa/cppunit/data/Drawing_WithWidthHeight.svg b/svgio/qa/cppunit/data/Drawing_WithWidthHeight.svg new file mode 100644 index 000000000..bc5afb553 --- /dev/null +++ b/svgio/qa/cppunit/data/Drawing_WithWidthHeight.svg @@ -0,0 +1,14 @@ + + + + diff --git a/svgio/qa/cppunit/data/FontsizeKeywords.svg b/svgio/qa/cppunit/data/FontsizeKeywords.svg new file mode 100644 index 000000000..9a97983c0 --- /dev/null +++ b/svgio/qa/cppunit/data/FontsizeKeywords.svg @@ -0,0 +1,14 @@ + + + +Sample +Sample +Sample +Sample +Sample +Sample +Sample +Sample +Sample +Sample + diff --git a/svgio/qa/cppunit/data/FontsizePercentage.svg b/svgio/qa/cppunit/data/FontsizePercentage.svg new file mode 100644 index 000000000..fc7c9fa61 --- /dev/null +++ b/svgio/qa/cppunit/data/FontsizePercentage.svg @@ -0,0 +1,3 @@ + + Sample + diff --git a/svgio/qa/cppunit/data/FontsizeRelative.svg b/svgio/qa/cppunit/data/FontsizeRelative.svg new file mode 100644 index 000000000..b957b90a3 --- /dev/null +++ b/svgio/qa/cppunit/data/FontsizeRelative.svg @@ -0,0 +1,6 @@ + + + Sample + Sample + + diff --git a/svgio/qa/cppunit/data/MarkerOrient.svg b/svgio/qa/cppunit/data/MarkerOrient.svg new file mode 100644 index 000000000..7997e1cce --- /dev/null +++ b/svgio/qa/cppunit/data/MarkerOrient.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + diff --git a/svgio/qa/cppunit/data/RGBAColor.svg b/svgio/qa/cppunit/data/RGBAColor.svg new file mode 100644 index 000000000..ddd7a3cc0 --- /dev/null +++ b/svgio/qa/cppunit/data/RGBAColor.svg @@ -0,0 +1,4 @@ + + + + diff --git a/svgio/qa/cppunit/data/RGBColor.svg b/svgio/qa/cppunit/data/RGBColor.svg new file mode 100644 index 000000000..ad60d5b55 --- /dev/null +++ b/svgio/qa/cppunit/data/RGBColor.svg @@ -0,0 +1,4 @@ + + + + diff --git a/svgio/qa/cppunit/data/Rect.svg b/svgio/qa/cppunit/data/Rect.svg new file mode 100644 index 000000000..7567cdfb5 --- /dev/null +++ b/svgio/qa/cppunit/data/Rect.svg @@ -0,0 +1,4 @@ + + + + diff --git a/svgio/qa/cppunit/data/RectWithParentStyles.svg b/svgio/qa/cppunit/data/RectWithParentStyles.svg new file mode 100644 index 000000000..a01ba3ff5 --- /dev/null +++ b/svgio/qa/cppunit/data/RectWithParentStyles.svg @@ -0,0 +1,13 @@ + + + + + diff --git a/svgio/qa/cppunit/data/RectWithStyles.svg b/svgio/qa/cppunit/data/RectWithStyles.svg new file mode 100644 index 000000000..b7068499b --- /dev/null +++ b/svgio/qa/cppunit/data/RectWithStyles.svg @@ -0,0 +1,4 @@ + + + + diff --git a/svgio/qa/cppunit/data/RectWithStylesByGroup.svg b/svgio/qa/cppunit/data/RectWithStylesByGroup.svg new file mode 100644 index 000000000..0a3b1e3cd --- /dev/null +++ b/svgio/qa/cppunit/data/RectWithStylesByGroup.svg @@ -0,0 +1,18 @@ + + + + + + + + + + diff --git a/svgio/qa/cppunit/data/ShapeWithClipPathAndCssStyle.svg b/svgio/qa/cppunit/data/ShapeWithClipPathAndCssStyle.svg new file mode 100644 index 000000000..4b6455c64 --- /dev/null +++ b/svgio/qa/cppunit/data/ShapeWithClipPathAndCssStyle.svg @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/svgio/qa/cppunit/data/VisiotorTest-Rect.svg b/svgio/qa/cppunit/data/VisiotorTest-Rect.svg new file mode 100644 index 000000000..4cd2d3602 --- /dev/null +++ b/svgio/qa/cppunit/data/VisiotorTest-Rect.svg @@ -0,0 +1,4 @@ + + + + diff --git a/svgio/qa/cppunit/data/em_units.svg b/svgio/qa/cppunit/data/em_units.svg new file mode 100644 index 000000000..1ad4d3e3a --- /dev/null +++ b/svgio/qa/cppunit/data/em_units.svg @@ -0,0 +1,14 @@ + + + + + + + + AWlllAWlll + + + diff --git a/svgio/qa/cppunit/data/i125329.svg b/svgio/qa/cppunit/data/i125329.svg new file mode 100644 index 000000000..86e3bd839 --- /dev/null +++ b/svgio/qa/cppunit/data/i125329.svg @@ -0,0 +1,12 @@ + + + all selector + + + diff --git a/svgio/qa/cppunit/data/markerInCssStyle.svg b/svgio/qa/cppunit/data/markerInCssStyle.svg new file mode 100644 index 000000000..a7a8374f6 --- /dev/null +++ b/svgio/qa/cppunit/data/markerInCssStyle.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/svgio/qa/cppunit/data/maskText.svg b/svgio/qa/cppunit/data/maskText.svg new file mode 100644 index 000000000..7405f6a56 --- /dev/null +++ b/svgio/qa/cppunit/data/maskText.svg @@ -0,0 +1,26 @@ + + + + + + + + + + Black White + + + + + + + + + + diff --git a/svgio/qa/cppunit/data/masking-path-07-b.svg b/svgio/qa/cppunit/data/masking-path-07-b.svg new file mode 100644 index 000000000..63f73d821 --- /dev/null +++ b/svgio/qa/cppunit/data/masking-path-07-b.svg @@ -0,0 +1,147 @@ + + + + + + + + + + + + +

+ This tests that 'clipPath' elements can be used together and how the clipping paths are intersected. +

+

+ There is a gray-white pattern as a background for the two subtest rectangles. This is to show that the holes that are cut out using clip-paths are transparent. + The first subtest verifies that when you use the 'clip-path' property on a child element inside a 'clipPath' element the child element is clipped correctly. + The second subtest verifies that when a 'clipPath' element has a 'clip-path' property the result is the intersection of the two clip paths. +

+ + +

+ Run the test. No interaction required. +

+
+ +

+ The test has passed if the following conditions are met: +

+
    +
  • There is no red visible.
  • +
  • No shapes extend outside of the rects that have a thick black border.
  • +
  • For the left subtest: +
      +
    • There must be a large blue rect with a transparent smaller rect in it, and the intersection of two circles.
    • +
    • The borders of the clipregions are shown with black stroke.
    • +
    • The blue shapes must be visible only inside of these stroked regions.
    • +
    +
  • +
  • For the right subtest: +
      +
    • The test on the right must show part of the large blue rect shape with a transparent rect in it, and part of a circle.
    • +
    • The blue shapes must only be visible inside of the circle that has black stroke.
    • +
    +
  • +
+
+ + $RCSfile: masking-path-07-b.svg,v $ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Test clip unions and intersections + + + + + + + + + + + + + + + + + + + + + + + + + + + + $Revision: 1.11 $ + + + + diff --git a/svgio/qa/cppunit/data/noneColor.svg b/svgio/qa/cppunit/data/noneColor.svg new file mode 100644 index 000000000..552a1cf5a --- /dev/null +++ b/svgio/qa/cppunit/data/noneColor.svg @@ -0,0 +1,3 @@ + + + diff --git a/svgio/qa/cppunit/data/path.svg b/svgio/qa/cppunit/data/path.svg new file mode 100644 index 000000000..559ceec6d --- /dev/null +++ b/svgio/qa/cppunit/data/path.svg @@ -0,0 +1,3 @@ + + + diff --git a/svgio/qa/cppunit/data/symbol.svg b/svgio/qa/cppunit/data/symbol.svg new file mode 100644 index 000000000..55110f374 --- /dev/null +++ b/svgio/qa/cppunit/data/symbol.svg @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/svgio/qa/cppunit/data/tdf101237.svg b/svgio/qa/cppunit/data/tdf101237.svg new file mode 100644 index 000000000..e5afa3738 --- /dev/null +++ b/svgio/qa/cppunit/data/tdf101237.svg @@ -0,0 +1,11 @@ + + + + + + + diff --git a/svgio/qa/cppunit/data/tdf103888.svg b/svgio/qa/cppunit/data/tdf103888.svg new file mode 100644 index 000000000..1663fa395 --- /dev/null +++ b/svgio/qa/cppunit/data/tdf103888.svg @@ -0,0 +1,11 @@ + + + + Hervorhebung + diff --git a/svgio/qa/cppunit/data/tdf104339.svg b/svgio/qa/cppunit/data/tdf104339.svg new file mode 100644 index 000000000..d06ff695c --- /dev/null +++ b/svgio/qa/cppunit/data/tdf104339.svg @@ -0,0 +1,65 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/svgio/qa/cppunit/data/tdf123926.svg b/svgio/qa/cppunit/data/tdf123926.svg new file mode 100644 index 000000000..1a5c2758a --- /dev/null +++ b/svgio/qa/cppunit/data/tdf123926.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/svgio/qa/cppunit/data/tdf149880.svg b/svgio/qa/cppunit/data/tdf149880.svg new file mode 100644 index 000000000..08ba74848 --- /dev/null +++ b/svgio/qa/cppunit/data/tdf149880.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/svgio/qa/cppunit/data/tdf149893.svg b/svgio/qa/cppunit/data/tdf149893.svg new file mode 100644 index 000000000..b6b241566 --- /dev/null +++ b/svgio/qa/cppunit/data/tdf149893.svg @@ -0,0 +1,3 @@ + + + diff --git a/svgio/qa/cppunit/data/tdf45771.svg b/svgio/qa/cppunit/data/tdf45771.svg new file mode 100644 index 000000000..f49e0f569 --- /dev/null +++ b/svgio/qa/cppunit/data/tdf45771.svg @@ -0,0 +1,5 @@ + + + +Sample + diff --git a/svgio/qa/cppunit/data/tdf79163.svg b/svgio/qa/cppunit/data/tdf79163.svg new file mode 100644 index 000000000..015303723 --- /dev/null +++ b/svgio/qa/cppunit/data/tdf79163.svg @@ -0,0 +1,8 @@ + + + + + diff --git a/svgio/qa/cppunit/data/tdf85770.svg b/svgio/qa/cppunit/data/tdf85770.svg new file mode 100644 index 000000000..b1cf9eb3c --- /dev/null +++ b/svgio/qa/cppunit/data/tdf85770.svg @@ -0,0 +1,7 @@ + +Start Middle End +Start Middle End + diff --git a/svgio/qa/cppunit/data/tdf87309.svg b/svgio/qa/cppunit/data/tdf87309.svg new file mode 100644 index 000000000..af8a7df25 --- /dev/null +++ b/svgio/qa/cppunit/data/tdf87309.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/svgio/qa/cppunit/data/tdf94765.svg b/svgio/qa/cppunit/data/tdf94765.svg new file mode 100644 index 000000000..009bfc8ed --- /dev/null +++ b/svgio/qa/cppunit/data/tdf94765.svg @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/svgio/qa/cppunit/data/tdf97542_1.svg b/svgio/qa/cppunit/data/tdf97542_1.svg new file mode 100644 index 000000000..328bd971a --- /dev/null +++ b/svgio/qa/cppunit/data/tdf97542_1.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + Layer 1 + + Text + + diff --git a/svgio/qa/cppunit/data/tdf97542_2.svg b/svgio/qa/cppunit/data/tdf97542_2.svg new file mode 100644 index 000000000..03cee9683 --- /dev/null +++ b/svgio/qa/cppunit/data/tdf97542_2.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + Layer 1 + + Text + + diff --git a/svgio/qa/cppunit/data/tdf97543.svg b/svgio/qa/cppunit/data/tdf97543.svg new file mode 100644 index 000000000..fa30b2244 --- /dev/null +++ b/svgio/qa/cppunit/data/tdf97543.svg @@ -0,0 +1,4 @@ + + + + diff --git a/svgio/qa/cppunit/data/tdf97936.svg b/svgio/qa/cppunit/data/tdf97936.svg new file mode 100644 index 000000000..6c059ec5d --- /dev/null +++ b/svgio/qa/cppunit/data/tdf97936.svg @@ -0,0 +1,5 @@ + + + + diff --git a/svgio/qa/cppunit/data/tdf97941.svg b/svgio/qa/cppunit/data/tdf97941.svg new file mode 100644 index 000000000..cfe1ca8c4 --- /dev/null +++ b/svgio/qa/cppunit/data/tdf97941.svg @@ -0,0 +1,6 @@ + + + + + Sample + diff --git a/svgio/qa/cppunit/data/tdf99115.svg b/svgio/qa/cppunit/data/tdf99115.svg new file mode 100644 index 000000000..6d4b5e9c1 --- /dev/null +++ b/svgio/qa/cppunit/data/tdf99115.svg @@ -0,0 +1,40 @@ + + + + red 1 + + + red 2 + + + red 3 + + + + blue 4 + + + blue 5 + + + blue 6 + + + + green 7 + + + green 8 + + + green 9 + + + diff --git a/svgio/qa/cppunit/data/tdf99994.svg b/svgio/qa/cppunit/data/tdf99994.svg new file mode 100644 index 000000000..b4dec353e --- /dev/null +++ b/svgio/qa/cppunit/data/tdf99994.svg @@ -0,0 +1,8 @@ + + + + test + + diff --git a/svgio/qa/cppunit/data/textXmlSpace.svg b/svgio/qa/cppunit/data/textXmlSpace.svg new file mode 100644 index 000000000..fe1bc8cee --- /dev/null +++ b/svgio/qa/cppunit/data/textXmlSpace.svg @@ -0,0 +1,16 @@ + + a b + a b + a + b + a +b + a b + a b + a + b + a +b + + diff --git a/svgio/qa/cppunit/data/tspan-fill-opacity.svg b/svgio/qa/cppunit/data/tspan-fill-opacity.svg new file mode 100644 index 000000000..ef6d5352a --- /dev/null +++ b/svgio/qa/cppunit/data/tspan-fill-opacity.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + hello + + + -- cgit v1.2.3