diff options
author | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2020-11-13 13:24:36 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-11-14 18:12:42 +0100 |
commit | eb2fdd9bc6696732fa472f6883993334898cef7a (patch) | |
tree | edf9b24fdedf5f84c0254a5b11c5f131a7befbb7 /emfio/qa | |
parent | b0b78838e795fcd7f3c53e7f74fb32b2921a5ccb (diff) |
tdf#35986 EMF import: Add support for PS_COSMETIC line style in CREATEPEN
When the PS_COSMETIC line style is set in CREATEPEN,
line width should be set to one logical unit and a style that is a solid color
This patch is fixing that, allowing to properly import EMF file.
The corresponding unit tests were added
Change-Id: I1a0caf6382d9c313d9725d0b94e2fcd37122a099
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105790
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'emfio/qa')
-rw-r--r-- | emfio/qa/cppunit/emf/EmfImportTest.cxx | 53 | ||||
-rw-r--r-- | emfio/qa/cppunit/emf/data/TestCreatePen.emf | bin | 0 -> 133136 bytes |
2 files changed, 53 insertions, 0 deletions
diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 94914da60f8a..29c084874b6d 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -50,6 +50,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestDrawLine(); void TestLinearGradient(); void TestTextMapMode(); + void TestCreatePen(); void TestPdfInEmf(); Primitive2DSequence parseEmf(const OUString& aSource); @@ -66,6 +67,7 @@ public: CPPUNIT_TEST(TestDrawLine); CPPUNIT_TEST(TestLinearGradient); CPPUNIT_TEST(TestTextMapMode); + CPPUNIT_TEST(TestCreatePen); CPPUNIT_TEST(TestPdfInEmf); CPPUNIT_TEST_SUITE_END(); }; @@ -270,6 +272,57 @@ void Test::TestTextMapMode() assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke[20]/line", "width", "11"); } + +void Test::TestCreatePen() +{ + // Check import of EMF image with records: RESTOREDC, SAVEDC, MOVETOEX, LINETO, POLYLINE16, EXTTEXTOUTW with DxBuffer + // The CREATEPEN record is used with PS_COSMETIC line style, which will be displayed as solid hairline + Primitive2DSequence aSequence = parseEmf("/emfio/qa/cppunit/emf/data/TestCreatePen.emf"); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength())); + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequence)); + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygon", "path", "m0 0h31250v18192h-31250z"); + + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke", 3); + assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/polygon", "17898,5693 20172,5693"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/line", "color", "#008000"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/line", "width", "3"); + + assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[2]/polygon", "17898,6959 20172,6959"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[2]/line", "color", "#000080"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[2]/line", "width", "3"); + + assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[3]/polygon", "17898,7381 20172,7381"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[3]/line", "color", "#ff0000"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[3]/line", "width", "3"); + + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline", 755); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[10]", "color", "#ff0000"); + assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[10]/polygon", "27925,14180 27875,14180"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[100]", "color", "#008000"); + assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[100]/polygon", "26100,14414 26050,14414"); + + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion", 69); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[1]", "width", "374"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[1]", "x", "28124"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[1]", "y", "16581"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[1]", "text", "0.0"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[1]", "fontcolor", "#000000"); + + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[10]", "width", "266"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[10]", "x", "28000"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[10]", "y", "428"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[10]", "text", "-6"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[10]", "fontcolor", "#000000"); + + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/pointarray", 8); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/pointarray[1]", "color", "#008000"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/pointarray[1]/point", "x", "25844"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/pointarray[1]/point", "y", "8918"); +} + void Test::TestPdfInEmf() { // Load a PPTX file, which has a shape, with a bitmap fill, which is an EMF, containing a PDF. diff --git a/emfio/qa/cppunit/emf/data/TestCreatePen.emf b/emfio/qa/cppunit/emf/data/TestCreatePen.emf Binary files differnew file mode 100644 index 000000000000..5a13910ecf79 --- /dev/null +++ b/emfio/qa/cppunit/emf/data/TestCreatePen.emf |