emfio/qa/cppunit/emf/EmfImportTest.cxx | 24 ++++++++++++++++++++++++ emfio/qa/cppunit/emf/data/TestPolyLineWidth.emf |binary emfio/source/reader/mtftools.cxx | 10 +++++++++- 3 files changed, 33 insertions(+), 1 deletion(-)
New commits: commit 3ffc0afce0f26900a4e1d9feed2c21108e1ed41b Author: Bartosz Kosiorek <gan...@poczta.onet.pl> AuthorDate: Wed May 12 19:03:59 2021 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Wed May 12 22:23:58 2021 +0200 tdf#112603 tdf#142014 tdf#142139 WMF/EMF Fix line width Previosly line width was always 1, and changing width do not affect line. Change-Id: I462096b915e053fa089e85860f124466b650558a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115497 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek <gan...@poczta.onet.pl> (cherry picked from commit b5ece3fbc7f878846298fd9196e5a30ba50e0dc2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115512 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 52fab033941a..4629005984ed 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -56,6 +56,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestEllipseXformIntersectClipRect(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); + void TestPolyLineWidth(); void TestRoundRect(); void TestCreatePen(); void TestPdfInEmf(); @@ -81,6 +82,7 @@ public: CPPUNIT_TEST(TestEllipseXformIntersectClipRect); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); + CPPUNIT_TEST(TestPolyLineWidth); CPPUNIT_TEST(TestRoundRect); CPPUNIT_TEST(TestCreatePen); CPPUNIT_TEST(TestPdfInEmf); @@ -436,6 +438,28 @@ void Test::TestFillRegion() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[1]", "color", "#000000"); } +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. diff --git a/emfio/qa/cppunit/emf/data/TestPolyLineWidth.emf b/emfio/qa/cppunit/emf/data/TestPolyLineWidth.emf new file mode 100644 index 000000000000..792694fa8c99 Binary files /dev/null and b/emfio/qa/cppunit/emf/data/TestPolyLineWidth.emf differ diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index d54e0ff763ae..bdae896a0e4e 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -1304,7 +1304,8 @@ namespace emfio if ( !bStroke ) mpGDIMetaFile->AddAction( new MetaPopAction() ); } - else + // tdf#142014 By default the stroke is made with hairline. If width is bigger, we need to use PolyLineAction + if ( bStroke && ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LineStyle::Dash ) ) ) { sal_uInt16 i, nCount = maPathObj.Count(); for ( i = 0; i < nCount; i++ ) @@ -1390,6 +1391,13 @@ namespace emfio UpdateLineStyle(); UpdateFillStyle(); mpGDIMetaFile->AddAction( new MetaRoundRectAction( ImplMap( rRect ), std::abs( ImplMap( rSize ).Width() ), std::abs( ImplMap( rSize ).Height() ) ) ); + // tdf#142139 Wrong line width during WMF import + if ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LineStyle::Dash ) ) + { + tools::Polygon aRoundRectPoly( rRect, rSize.Width(), rSize.Height() ); + aRoundRectPoly.Optimize( PolyOptimizeFlags::EDGES ); + mpGDIMetaFile->AddAction( new MetaPolyLineAction( ImplMap( aRoundRectPoly ), maLineStyle.aLineInfo ) ); + } } void MtfTools::DrawEllipse( const tools::Rectangle& rRect ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits