summaryrefslogtreecommitdiffstats
path: root/emfio
diff options
context:
space:
mode:
authorBartosz Kosiorek <gang65@poczta.onet.pl>2021-05-13 20:11:19 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-05-14 09:11:37 +0200
commitc0e6031e173c2c0efe0715af9fd8dd205c74a030 (patch)
tree325b468068fc22829385d0d3aa0ea26f34fe7d07 /emfio
parenttdf#112603 tdf#142014 tdf#142139 WMF/EMF Fix line width (diff)
downloadcore-c0e6031e173c2c0efe0715af9fd8dd205c74a030.tar.gz
core-c0e6031e173c2c0efe0715af9fd8dd205c74a030.zip
tdf#142014 Fix displaying strokes when line width is 0
Change-Id: I80e05ff2f24f5da2f5c124c0ee1b302a1c8226ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115570 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl> (cherry picked from commit 699295ca7cab3a4f4e801a14496f202c05d18899) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115514 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'emfio')
-rw-r--r--emfio/qa/cppunit/emf/EmfImportTest.cxx22
-rw-r--r--emfio/qa/cppunit/emf/data/TestPolylinetoCloseStroke.emfbin0 -> 356 bytes
-rw-r--r--emfio/source/reader/mtftools.cxx12
3 files changed, 30 insertions, 4 deletions
diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx
index 4629005984ed..fcdf2509f3a9 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 TestPolylinetoCloseStroke();
void TestPolyLineWidth();
void TestRoundRect();
void TestCreatePen();
@@ -82,6 +83,7 @@ public:
CPPUNIT_TEST(TestEllipseXformIntersectClipRect);
CPPUNIT_TEST(TestDrawPolyLine16WithClip);
CPPUNIT_TEST(TestFillRegion);
+ CPPUNIT_TEST(TestPolylinetoCloseStroke);
CPPUNIT_TEST(TestPolyLineWidth);
CPPUNIT_TEST(TestRoundRect);
CPPUNIT_TEST(TestCreatePen);
@@ -438,6 +440,26 @@ void Test::TestFillRegion()
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::TestPolyLineWidth()
{
// EMF import with records: CREATEPEN, ROUNDRECT.
diff --git a/emfio/qa/cppunit/emf/data/TestPolylinetoCloseStroke.emf b/emfio/qa/cppunit/emf/data/TestPolylinetoCloseStroke.emf
new file mode 100644
index 000000000000..e89e92272943
--- /dev/null
+++ b/emfio/qa/cppunit/emf/data/TestPolylinetoCloseStroke.emf
Binary files differ
diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx
index bdae896a0e4e..989970c9cb8b 100644
--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -1305,11 +1305,15 @@ namespace emfio
mpGDIMetaFile->AddAction( new MetaPopAction() );
}
// 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 ) ) )
+ if ( bStroke )
{
- sal_uInt16 i, nCount = maPathObj.Count();
- for ( i = 0; i < nCount; i++ )
- mpGDIMetaFile->AddAction( new MetaPolyLineAction( maPathObj[ i ], maLineStyle.aLineInfo ) );
+ // bFill is drawing hairstyle line. So we need to to draw it only when the width is different than 0
+ if ( !bFill || maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LineStyle::Dash ) )
+ {
+ sal_uInt16 i, nCount = maPathObj.Count();
+ for ( i = 0; i < nCount; i++ )
+ mpGDIMetaFile->AddAction( new MetaPolyLineAction( maPathObj[ i ], maLineStyle.aLineInfo ) );
+ }
}
ClearPath();
}