summaryrefslogtreecommitdiff
path: root/emfio/qa/cppunit/emf/EmfImportTest.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'emfio/qa/cppunit/emf/EmfImportTest.cxx')
-rw-r--r--emfio/qa/cppunit/emf/EmfImportTest.cxx334
1 files changed, 304 insertions, 30 deletions
diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx
index e8d4833e6424..5f0567fd313b 100644
--- a/emfio/qa/cppunit/emf/EmfImportTest.cxx
+++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx
@@ -26,7 +26,6 @@
#include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
#include <drawinglayer/tools/primitive2dxmldump.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <memory>
@@ -51,6 +50,18 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest:
void TestLinearGradient();
void TestTextMapMode();
void TestEnglishMapMode();
+ void TestRectangleWithModifyWorldTransform();
+ void TestArcInsideWronglyDefinedRectangle();
+ void TestChordWithModifyWorldTransform();
+ void TestEllipseWithSelectClipPath();
+ void TestEllipseXformIntersectClipRect();
+ void TestDrawPolyLine16WithClip();
+ void TestFillRegion();
+ void TestPaletteWMF();
+ void TestRoundrectWMF();
+ void TestPolylinetoCloseStroke();
+ void TestPolyLineWidth();
+ void TestRoundRect();
void TestCreatePen();
void TestPdfInEmf();
@@ -69,6 +80,18 @@ public:
CPPUNIT_TEST(TestLinearGradient);
CPPUNIT_TEST(TestTextMapMode);
CPPUNIT_TEST(TestEnglishMapMode);
+ CPPUNIT_TEST(TestRectangleWithModifyWorldTransform);
+ CPPUNIT_TEST(TestArcInsideWronglyDefinedRectangle);
+ CPPUNIT_TEST(TestChordWithModifyWorldTransform);
+ CPPUNIT_TEST(TestEllipseWithSelectClipPath);
+ CPPUNIT_TEST(TestEllipseXformIntersectClipRect);
+ CPPUNIT_TEST(TestDrawPolyLine16WithClip);
+ CPPUNIT_TEST(TestFillRegion);
+ CPPUNIT_TEST(TestPaletteWMF);
+ CPPUNIT_TEST(TestRoundrectWMF);
+ CPPUNIT_TEST(TestPolylinetoCloseStroke);
+ CPPUNIT_TEST(TestPolyLineWidth);
+ CPPUNIT_TEST(TestRoundRect);
CPPUNIT_TEST(TestCreatePen);
CPPUNIT_TEST(TestPdfInEmf);
CPPUNIT_TEST_SUITE_END();
@@ -122,7 +145,7 @@ void Test::testPolyPolygon()
assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygon", "path", "m0 0h19746v14817h-19746z");
assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor", 2);
assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]", "color", "#ffffff");
- assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", "path", "m0 0h19780v14851h-19780z");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", "path", "m0 0h19781v14852h-19781z");
assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]/polypolygon", "path", "m2574 13194v-12065h15303v12065z");
assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke", 116);
@@ -289,7 +312,7 @@ void Test::TestEnglishMapMode()
assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor", 3);
assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]", "color", "#ffffad");
- assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", "path", "m-1-1h29699v21005h-29699z");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", "path", "m-1-1h29700v21001h-29700z");
assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]/polypolygon", "path", "m1058 7937v5293h3175v-1059h-2118v-4234z");
assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[3]/polypolygon", "path", "m12699 1058h4234v1060h-1587v4231h-1059v-4231h-1588z");
@@ -302,17 +325,274 @@ void Test::TestEnglishMapMode()
assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[1]", "height", "424");
assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline", 3);
- assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[1]/polygon", "-1,-1 29698,-1 29698,21004 -1,21004");
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[1]/polygon", "-1,-1 29699,-1 29699,21000 -1,21000");
assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[2]/polygon", "1058,7937 1058,13230 4233,13230 4233,12171 2115,12171 2115,7937");
assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[3]/polygon", "12699,1058 16933,1058 16933,2118 15346,2118 15346,6349 14287,6349 14287,2118 12699,2118");
+}
+
+void Test::TestRectangleWithModifyWorldTransform()
+{
+ // Check import of EMF image with records: EXTCREATEPEN, SELECTOBJECT, MODIFYWORLDTRANSFORM, RECTANGLE
+
+ Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestRectangleWithModifyWorldTransform.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", 1);
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[1]", "color", "#ffffff");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[1]/polypolygon", "path", "m1042 417 918 529 353 610-918-528z");
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke", 1);
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke[1]/polygon", "1042,417 1960,946 2313,1556 1395,1028");
+}
+
+void Test::TestChordWithModifyWorldTransform()
+{
+ // EMF import test with records: CHORD, MODIFYWORLDTRANSFORM, EXTCREATEPEN, SELECTOBJECT
+ Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestChordWithModifyWorldTransform.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", "#ffffff");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor/polypolygon", "path", "m590 448-154 93-54 57-21 45 24 67 45 21 224-6 265-97z");
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke/polygon", "590,448 436,541 382,598 361,643 385,710 430,731 654,725 919,628");
+}
+
+void Test::TestArcInsideWronglyDefinedRectangle()
+{
+ // tdf#142268 EMF import test with records: ARC
+ Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.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/polygonhairline", "color", "#000000");
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonhairline/polygon", "1630,1450 1650,1470 1850,1540 1990,1540 2040,1530 2190,1470 2270,1410 2330,1350 2390,1260 2430,1160 2430,1140 2440,1090 2450,1060 2450,950 2440,930 2430,880 2430,850 2420,820 2360,710 2310,650 2250,590 2110,510 1980,480 1870,480 1770,500 1670,540 1650,560 1630,570 1600,580 1540,640 1460,740 1450,770");
+}
+void Test::TestEllipseWithSelectClipPath()
+{
+ // EMF import test with records: RECTANGLE, BEGINPATH, ENDPATH, ELLIPSE
+ Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestEllipseWithSelectClipPath.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/group/mask/polypolygon", 1);
+ assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygon[1]", "path", "m2790 705-106-106-106-70-318-106-424-70h-706l-35 35-247 35h-142l-318 106-105 70-106 106v141l106 106 105 70 318 106 424 71h706l424-71 318-106 106-70 106-106");
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygoncolor", 1);
+ assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygoncolor[1]", "color", "#ffff00");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygoncolor[1]/polypolygon[1]", "path", "m353 353h2472v1057h-2472z");
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polygonstroke", 1);
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/group/mask/polygonstroke[1]/polygon", "353,353 2825,353 2825,1410 353,1410");
+}
+
+void Test::TestEllipseXformIntersectClipRect()
+{
+ // EMF import test with records: EXTCREATEPEN, CREATEBRUSHINDIRECT, MODIFYWORLDTRANSFORM, INTERSECTCLIPRECT, ELLIPSE
+ Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestEllipseXformIntersectClipRect.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 0h3000v2000h-3000z");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/group/mask/polypolygon", "path", "m370 152 1128-409 592 1623-1128 410z");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/group/mask/polypolygoncolor/polypolygon", "path", "m3565 155-58-55-205-150-90-42-124-30-392-45-368 21-211 39-598 217-187 105-21 46-121 81-66 24-87 69-272 287-75 102-42 90-61 247-9 79 97 265 57 54 205 150 91 42 124 31 392 45 112-3 467-58 597-217 187-105 296-220 271-286 76-103 42-90 60-247 9-78z");
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/group/mask/polygonstroke/polygon", "3565,155 3507,100 3302,-50 3212,-92 3088,-122 2696,-167 2328,-146 2117,-107 1519,110 1332,215 1311,261 1190,342 1124,366 1037,435 765,722 690,824 648,914 587,1161 578,1240 675,1505 732,1559 937,1709 1028,1751 1152,1782 1544,1827 1656,1824 2123,1766 2720,1549 2907,1444 3203,1224 3474,938 3550,835 3592,745 3652,498 3661,420");
+}
+
+void Test::TestDrawPolyLine16WithClip()
+{
+ // Check import of EMF image with records:
+ // CREATEBRUSHINDIRECT, FILLRGN, BEGINPATH, POLYGON16, SELECTCLIPPATH, MODIFYWORLDTRANSFORM, SELECTOBJECT
+ Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestDrawPolyLine16WithClip.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 0h3943v3939h-3943z");
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor", 1);
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon",
+ "path", "m1323 0h1323v1322h1323v1322h-1323v1322h-1323v-1322h-1323v-1322h1323z");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]", "color", "#b4ffff");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline", 1);
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[1]/polygon",
+ "1323,0 2646,0 2646,1322 3969,1322 3969,2644 2646,2644 2646,3966 1323,3966 1323,2644 0,2644 0,1322 1323,1322");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[1]", "color", "#000000");
+
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/group[1]/mask/polypolygon", "path", "m2646 0v1322h1323v1322h-1323v1322h-1323v-1322h-1323v-1322h1323v-1322");
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/group[1]/mask/polygonstroke/polygon", "0,793 3969,4230");
+}
+
+void Test::TestFillRegion()
+{
+ // EMF import with records: CREATEBRUSHINDIRECT, FILLRGN. The SETICMMODE is also used.
+ Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestFillRegion.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 0h3943v3939h-3943z");
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor", 1);
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon",
+ "path", "m1323 0h1323v1322h1323v1322h-1323v1322h-1323v-1322h-1323v-1322h1323z");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]", "color", "#ff0000");
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline", 1);
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[1]/polygon",
+ "1323,0 2646,0 2646,1322 3969,1322 3969,2644 2646,2644 2646,3966 1323,3966 1323,2644 0,2644 0,1322 1323,1322");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[1]", "color", "#000000");
+}
+
+void Test::TestPolylinetoCloseStroke()
+{
+ // EMF import with records: BEGINPATH, ARC, ENDPATH, STROKEPATH, EXTCREATEPEN.
+ Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestPolylinetoCloseStroke.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/polygonhairline", 2);
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonhairline[1]/polygon",
+ "1080,150 810,230 570,340 370,490 290,570 170,750 130,840 100,980 100,1080 140,1270 160,1320 210,1410 400,1620 500,1690");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polygonhairline[1]",
+ "color", "#000000");
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonhairline[2]/polygon",
+ "1760,1120 1500,1180 1350,1240 1230,1310 1210,1330 1120,1440 1110,1460 1100,1510 1100,1580 1140,1670 1170,1710 1190,1730");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polygonhairline[2]",
+ "color", "#000000");
+}
+
+void Test::TestPaletteWMF()
+{
+ // WMF import with records: CREATEPALETTE, SELECTOBJECT, CREATEPENINDIRECT, CREATEBRUSHINDIRECT, ELLIPSE.
+ Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/wmf/data/TestPalette.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/mask/polypolygoncolor", 2);
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon",
+ "path", "m0 0h3015v3015h-3015z");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]",
+ "color", "#ffff00");
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]/polypolygon",
+ "path", "m2222 2222h2698v2698h-2698z");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]",
+ "color", "#0080ff");
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke", 2);
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/polygon",
+ "0,0 3015,0 3015,3015 0,3015");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/line",
+ "color", "#ff0000");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/line",
+ "width", "132");
+
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[2]/polygon",
+ "2222,2222 4920,2222 4920,4920 2222,4920");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[2]/line",
+ "color", "#ff0000");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[2]/line",
+ "width", "132");
+}
+
+void Test::TestRoundrectWMF()
+{
+ // WMF records: ROUNDRECT, SETBKCOLOR, CREATEBRUSHINDIRECT
+ Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/wmf/data/TestRoundRect.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",
+ "color", "#ffffff");
+
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke/polygon",
+ "2865,661 2865,653 2865,645 2865,637 2865,621 2865,613 2865,605 2857,597 2857,589 2857,582 2857,566 2857,558 2849,550 2849,542 2849,534 2841,526 2841,518 2841,510 2833,502 2833,494 2825,486 2825,478 2817,470 2817,462 2809,454 2809,446 2801,438 2801,430 2793,422 2793,422 2785,414 2777,406 2777,398 2769,390 2761,390 2761,382 2753,374 2745,374 2737,366 2737,366 2729,358 2721,350 2714,350 2714,343 2706,343 2698,343 2690,335 2682,335 2682,335 2674,327 2666,327 2658,327 2650,327 2642,319 2634,319 2634,319 2626,319 2618,319 2610,319 573,319 565,319 557,319 549,319 549,319 541,319 533,327 525,327 517,327 509,327 501,335 501,335 493,335 485,343 477,343 469,343 469,350 462,350 454,358 446,366 446,366 438,374 430,374 422,382 422,390 414,390 406,398 406,406 398,414 390,422 390,422 382,430 382,438 374,446 374,454 366,462 366,470 358,478 358,486 350,494 350,502 342,510 342,518 342,526 334,534 334,542 334,550 326,558 326,566 326,582 326,589 326,597 318,605 318,613 318,621 318,637 318,645 318,653 318,661 318,1673 318,1681 318,1689 318,1697 318,1713 318,1721 318,1729 326,1737 326,1745 326,1752 326,1768 326,1776 334,1784 334,1792 334,1800 342,1808 342,1816 342,1824 350,1832 350,1840 358,1848 358,1856 366,1864 366,1872 374,1880 374,1888 382,1896 382,1904 390,1912 390,1912 398,1920 406,1928 406,1936 414,1944 422,1944 422,1952 430,1960 438,1960 446,1968 446,1968 454,1976 462,1984 469,1984 469,1991 477,1991 485,1991 493,1999 501,1999 501,1999 509,2007 517,2007 525,2007 533,2007 541,2015 549,2015 549,2015 557,2015 565,2015 573,2015 2610,2015 2618,2015 2626,2015 2634,2015 2634,2015 2642,2015 2650,2007 2658,2007 2666,2007 2674,2007 2682,1999 2682,1999 2690,1999 2698,1991 2706,1991 2714,1991 2714,1984 2721,1984 2729,1976 2737,1968 2737,1968 2745,1960 2753,1960 2761,1952 2761,1944 2769,1944 2777,1936 2777,1928 2785,1920 2793,1912 2793,1912 2801,1904 2801,1896 2809,1888 2809,1880 2817,1872 2817,1864 2825,1856 2825,1848 2833,1840 2833,1832 2841,1824 2841,1816 2841,1808 2849,1800 2849,1792 2849,1784 2857,1776 2857,1768 2857,1752 2857,1745 2857,1737 2865,1729 2865,1721 2865,1713 2865,1697 2865,1689 2865,1681 2865,1673");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke/line",
+ "color", "#000000");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke/line",
+ "width", "143");
+}
+
+void Test::TestPolyLineWidth()
+{
+ // EMF import with records: CREATEPEN, ROUNDRECT.
+ Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestPolyLineWidth.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/polypolygon",
+ "path", "m530 529 1236-176-707 352z");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor",
+ "color", "#ffff00");
+
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke/polygon",
+ "530,529 530,529 1766,353 1059,705");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke/line",
+ "color", "#000000");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke/line",
+ "width", "71");
+}
+
+void Test::TestRoundRect()
+{
+ // EMF import with records: CREATEPEN, ROUNDRECT.
+ Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestRoundRect.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", 2);
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[1]/polypolygon",
+ "path", "m100 100h4000v2000h-4000z");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[1]",
+ "color", "#ffffff");
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke", 2);
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke[1]/polygon",
+ "100,100 4100,100 4100,2100 100,2100");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke[1]/line",
+ "color", "#ff0000");
+
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[2]/polypolygon",
+ "path", "m4090 2650-10-50-10-30-50-90-100-110-20-10-30-20-20-20-30-20-90-40-100-30-170-30h-2730l-140 20-130 40-90 40-30 20-20 20-30 20-20 10-100 110-50 90-10 30-10 50v1090l10 50 10 30 50 90 100 110 20 10 30 20 20 20 30 20 90 40 100 30 170 30h2730l140-20 130-40 90-40 30-20 20-20 30-20 20-10 100-110 50-90 10-30 10-50z");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[2]",
+ "color", "#ffffff");
+
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke[2]/polygon",
+ "4090,2650 4080,2600 4070,2570 4020,2480 3920,2370 3900,2360 3870,2340 3850,2320 3820,2300 3730,2260 3630,2230 3460,2200 730,2200 590,2220 460,2260 370,2300 340,2320 320,2340 290,2360 270,2370 170,2480 120,2570 110,2600 100,2650 100,3740 110,3790 120,3820 170,3910 270,4020 290,4030 320,4050 340,4070 370,4090 460,4130 560,4160 730,4190 3460,4190 3600,4170 3730,4130 3820,4090 3850,4070 3870,4050 3900,4030 3920,4020 4020,3910 4070,3820 4080,3790 4090,3740");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke[2]/line",
+ "color", "#ff0000");
}
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
+ // The CREATEPEN record is used with PS_COSMETIC line style, which sometimes 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;
@@ -321,24 +601,24 @@ void Test::TestCreatePen()
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");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke", 748);
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/polygon", "27875,16523 27875,1453");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/line", "color", "#ff0000");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/line", "width", "6");
- 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[2]/polygon", "27975,16453 27875,16453");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[2]/line", "color", "#ff0000");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[2]/line", "width", "6");
- assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[3]/polygon", "17898,7381 20172,7381");
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[3]/polygon", "27925,16078 27875,16078");
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/polygonstroke[3]/line", "width", "6");
- 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/polygonhairline", 10);
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[5]", "color", "#008000");
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[5]/polygon", "25850,2179 25844,1958");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[10]", "color", "#000080");
+ assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[10]/polygon", "2025,1642 2025,1501");
assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion", 69);
assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[1]", "width", "374");
@@ -383,19 +663,13 @@ void Test::TestPdfInEmf()
// height was only 5cm, so it looked blurry.
CPPUNIT_ASSERT_EQUAL(14321.0, pVectorGraphicData->getSizeHint().getY());
-#if !defined(WNT) && !defined(MACOSX)
- // Hmm, manual testing on Windows looks OK.
- BitmapEx aBitmapEx = aGraphic.GetBitmapEx();
- AlphaMask aMask = aBitmapEx.GetAlpha();
- Bitmap::ScopedReadAccess pAccess(aMask);
- Color aColor(pAccess->GetPixel(0, 0));
// Without the accompanying fix in place, this test would have failed with:
- // - Expected: 220
+ // - Expected: 255
// - Actual : 0
- // i.e. the pixel at the top left corner was entirely opaque, while it should be mostly
- // transparent.
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(220), aColor.GetBlue());
-#endif
+ // i.e. the pixel in the center was entirely opaque, while it should be transparent.
+ BitmapEx aBitmapEx = aGraphic.GetBitmapEx();
+ Size size = aBitmapEx.GetSizePixel();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(255), aBitmapEx.GetTransparency(size.Width() / 2, size.Height() / 2));
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);