diff options
author | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2021-06-11 22:25:42 +0200 |
---|---|---|
committer | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2021-06-11 12:31:59 +0200 |
commit | cabb9f5c8e22a23a453559636d9c9b3c2b0a5984 (patch) | |
tree | 7c008d7f21e06e5653e394dd3b118c2955ac865c /emfio/qa | |
parent | 2e415a90958bb00f460dccb303bc22853244292b (diff) |
WMF/EMF tdf#59814 tdf#142567 Fix RestoreDC record
With previous implementation, the RestoreDC index argument was skipped,
and always the last entry was taken.
With this commit the support for reading SaveDC by specific index
was added. The SaveDC/RestoreDC index support was added for
both EMF and WMF, according to [MS-WMF] and [MS-EMF] documentation.
Change-Id: I9b8a1a41462ae01de25ac3c85e453bcd80e05537
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117033
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'emfio/qa')
-rw-r--r-- | emfio/qa/cppunit/emf/EmfImportTest.cxx | 59 | ||||
-rw-r--r-- | emfio/qa/cppunit/emf/data/TestRestoreDC.emf | bin | 0 -> 1464 bytes | |||
-rw-r--r-- | emfio/qa/cppunit/wmf/data/TestRestoreDC.wmf | bin | 0 -> 190 bytes |
3 files changed, 59 insertions, 0 deletions
diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 8c56190203b0..1383b5fdfc03 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -65,10 +65,13 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestBitBltStretchBltWMF(); void TestExtTextOutOpaqueAndClipWMF(); void TestPaletteWMF(); + void TestRestoreDCWMF(); void TestRoundrectWMF(); void TestStretchDIBWMF(); void TestPolylinetoCloseStroke(); void TestPolyLineWidth(); + + void TestRestoreDC(); void TestRoundRect(); void TestCreatePen(); void TestPdfInEmf(); @@ -101,10 +104,12 @@ public: CPPUNIT_TEST(TestBitBltStretchBltWMF); CPPUNIT_TEST(TestExtTextOutOpaqueAndClipWMF); CPPUNIT_TEST(TestPaletteWMF); + CPPUNIT_TEST(TestRestoreDCWMF); CPPUNIT_TEST(TestRoundrectWMF); CPPUNIT_TEST(TestStretchDIBWMF); CPPUNIT_TEST(TestPolylinetoCloseStroke); CPPUNIT_TEST(TestPolyLineWidth); + CPPUNIT_TEST(TestRestoreDC); CPPUNIT_TEST(TestRoundRect); CPPUNIT_TEST(TestCreatePen); CPPUNIT_TEST(TestPdfInEmf); @@ -699,6 +704,7 @@ void Test::TestExtTextOutOpaqueAndClipWMF() #endif } + void Test::TestPaletteWMF() { // WMF import with records: CREATEPALETTE, SELECTOBJECT, CREATEPENINDIRECT, CREATEBRUSHINDIRECT, ELLIPSE. @@ -735,6 +741,40 @@ void Test::TestPaletteWMF() "width", "132"); } +void Test::TestRestoreDCWMF() +{ + // WMF records: RESTOREDC, SAVEDC, CREATEBRUSHINDIRECT, RECTANGLE. + Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/wmf/data/TestRestoreDC.wmf"); + 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/polypolygoncolor", 3); + assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[1]", + "color", "#0000ff"); + assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[1]/polypolygon", + "path", "m238 2884h1640v1110h-1640z"); + assertXPath(pDocument, "/primitive2D/metafile/transform/polygonhairline[1]", + "color", "#000000"); + assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonhairline[1]/polygon", + "238,2884 1878,2884 1878,3994 238,3994"); + + assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[2]", + "color", "#ff0000"); + assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[2]/polypolygon", + "path", "m238 238h1640v1110h-1640z"); + assertXPath(pDocument, "/primitive2D/metafile/transform/polygonhairline[2]", + "color", "#000000"); + + assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[3]", + "color", "#ff0000"); + assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[3]/polypolygon", + "path", "m238 5530h1640v1110h-1640z"); + assertXPath(pDocument, "/primitive2D/metafile/transform/polygonhairline[3]", + "color", "#000000"); +} + void Test::TestRoundrectWMF() { // WMF records: ROUNDRECT, SETBKCOLOR, CREATEBRUSHINDIRECT @@ -815,6 +855,25 @@ void Test::TestPolyLineWidth() "width", "71"); } +void Test::TestRestoreDC() +{ + // EMF records: SAVEDC, RESTOREDC, POLYGON16, MODIFYWORLDTRANSFORM + Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestRestoreDC.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/polypolygoncolor", + "color", "#ff0000"); + assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor/polypolygon", + "path", "m1148 4354v1481h4943v-1481z"); + assertXPath(pDocument, "/primitive2D/metafile/transform/polygonhairline", + "color", "#000000"); + assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonhairline/polygon", + "1148,4354 1148,5835 6091,5835 6091,4354"); +} + void Test::TestRoundRect() { // EMF import with records: CREATEPEN, ROUNDRECT. diff --git a/emfio/qa/cppunit/emf/data/TestRestoreDC.emf b/emfio/qa/cppunit/emf/data/TestRestoreDC.emf Binary files differnew file mode 100644 index 000000000000..b65b48d6b1f7 --- /dev/null +++ b/emfio/qa/cppunit/emf/data/TestRestoreDC.emf diff --git a/emfio/qa/cppunit/wmf/data/TestRestoreDC.wmf b/emfio/qa/cppunit/wmf/data/TestRestoreDC.wmf Binary files differnew file mode 100644 index 000000000000..c81244f6bf68 --- /dev/null +++ b/emfio/qa/cppunit/wmf/data/TestRestoreDC.wmf |