diff options
author | Stephan van den Akker <stephanv778@gmail.com> | 2016-02-23 11:13:20 +0100 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2016-02-26 08:56:41 +0000 |
commit | 9db34a7712e277389b2041cfbd77a60476d7f7f1 (patch) | |
tree | 88db334ab10538aff698ebe5e06a349fcbea75b3 /vcl | |
parent | a6c26ef0c77c716d222bacb4f402af4638ba62c2 (diff) |
Improve the import of pen styles from EMF files
Change-Id: I643c29befeb29b7b1cdd66375f661f4adb0e6cfa
Reviewed-on: https://gerrit.libreoffice.org/22638
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qa/cppunit/wmf/data/line_styles.emf | bin | 0 -> 2748 bytes | |||
-rw-r--r-- | vcl/qa/cppunit/wmf/wmfimporttest.cxx | 46 | ||||
-rw-r--r-- | vcl/source/filter/wmf/enhwmf.cxx | 36 |
3 files changed, 70 insertions, 12 deletions
diff --git a/vcl/qa/cppunit/wmf/data/line_styles.emf b/vcl/qa/cppunit/wmf/data/line_styles.emf Binary files differnew file mode 100644 index 000000000000..07b78327dabb --- /dev/null +++ b/vcl/qa/cppunit/wmf/data/line_styles.emf diff --git a/vcl/qa/cppunit/wmf/wmfimporttest.cxx b/vcl/qa/cppunit/wmf/wmfimporttest.cxx index 6e595c070c8c..2a1a34196b60 100644 --- a/vcl/qa/cppunit/wmf/wmfimporttest.cxx +++ b/vcl/qa/cppunit/wmf/wmfimporttest.cxx @@ -43,6 +43,7 @@ public: void testNonPlaceableWmf(); void testSine(); void testEmfProblem(); + void testEmfLineStyles(); void testWorldTransformFontSize(); void testTdf93750(); @@ -50,6 +51,7 @@ public: CPPUNIT_TEST(testNonPlaceableWmf); CPPUNIT_TEST(testSine); CPPUNIT_TEST(testEmfProblem); + CPPUNIT_TEST(testEmfLineStyles); CPPUNIT_TEST(testWorldTransformFontSize); CPPUNIT_TEST(testTdf93750); @@ -120,6 +122,50 @@ void WmfTest::testEmfProblem() assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "right", "1876"); } +void WmfTest::testEmfLineStyles() +{ + SvFileStream aFileStream(getFullUrl("line_styles.emf"), StreamMode::READ); + GDIMetaFile aGDIMetaFile; + ReadWindowMetafile(aFileStream, aGDIMetaFile); + + MetafileXmlDump dumper; + dumper.filterAllActionTypes(); + dumper.filterActionType(MetaActionType::LINE, false); + dumper.filterActionType(MetaActionType::LINECOLOR, false); + xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile); + + CPPUNIT_ASSERT (pDoc); + + assertXPath(pDoc, "/metafile/line", 4); + assertXPath(pDoc, "/metafile/linecolor", 5); + + assertXPath(pDoc, "/metafile/linecolor[1]", "color", "#ffffff"); + assertXPath(pDoc, "/metafile/linecolor[2]", "color", "#00ff00"); + assertXPath(pDoc, "/metafile/linecolor[3]", "color", "#408080"); + assertXPath(pDoc, "/metafile/linecolor[4]", "color", "#ff0000"); + assertXPath(pDoc, "/metafile/linecolor[5]", "color", "#0000ff"); + + assertXPath(pDoc, "/metafile/line[1]", "style", "dash"); + assertXPath(pDoc, "/metafile/line[1]", "dashlen", "225"); + assertXPath(pDoc, "/metafile/line[1]", "dotlen", "0"); + assertXPath(pDoc, "/metafile/line[1]", "distance", "100"); + + assertXPath(pDoc, "/metafile/line[2]", "style", "dash"); + assertXPath(pDoc, "/metafile/line[2]", "dashlen", "0"); + assertXPath(pDoc, "/metafile/line[2]", "dotlen", "30"); + assertXPath(pDoc, "/metafile/line[2]", "distance", "50"); + + assertXPath(pDoc, "/metafile/line[3]", "style", "dash"); + assertXPath(pDoc, "/metafile/line[3]", "dashlen", "150"); + assertXPath(pDoc, "/metafile/line[3]", "dotlen", "30"); + assertXPath(pDoc, "/metafile/line[3]", "distance", "90"); + + assertXPath(pDoc, "/metafile/line[4]", "style", "dash"); + assertXPath(pDoc, "/metafile/line[4]", "dashlen", "150"); + assertXPath(pDoc, "/metafile/line[4]", "dotlen", "30"); + assertXPath(pDoc, "/metafile/line[4]", "distance", "50"); +}; + void WmfTest::testWorldTransformFontSize() { SvFileStream aFileStream(getFullUrl("image1.emf"), StreamMode::READ); diff --git a/vcl/source/filter/wmf/enhwmf.cxx b/vcl/source/filter/wmf/enhwmf.cxx index f8341e3adecf..02eebdfdf9eb 100644 --- a/vcl/source/filter/wmf/enhwmf.cxx +++ b/vcl/source/filter/wmf/enhwmf.cxx @@ -1008,20 +1008,38 @@ bool EnhWMFReader::ReadEnhWMF() aLineInfo.SetWidth( nWidth ); bool bTransparent = false; - sal_uInt16 nDashCount = 0; - sal_uInt16 nDotCount = 0; switch( nStyle & PS_STYLE_MASK ) { case PS_DASHDOTDOT : - nDotCount++; + aLineInfo.SetStyle( LINE_DASH ); + aLineInfo.SetDashCount( 1 ); + aLineInfo.SetDotCount( 2 ); + aLineInfo.SetDashLen( 150 ); + aLineInfo.SetDotLen( 30 ); + aLineInfo.SetDistance( 50 ); + break; case PS_DASHDOT : - nDashCount++; + aLineInfo.SetStyle( LINE_DASH ); + aLineInfo.SetDashCount( 1 ); + aLineInfo.SetDotCount( 1 ); + aLineInfo.SetDashLen( 150 ); + aLineInfo.SetDotLen( 30 ); + aLineInfo.SetDistance( 90 ); + break; case PS_DOT : - nDotCount++; + aLineInfo.SetStyle( LINE_DASH ); + aLineInfo.SetDashCount( 0 ); + aLineInfo.SetDotCount( 1 ); + aLineInfo.SetDotLen( 30 ); + aLineInfo.SetDistance( 50 ); break; case PS_DASH : - nDashCount++; + aLineInfo.SetStyle( LINE_DASH ); + aLineInfo.SetDashCount( 1 ); + aLineInfo.SetDotCount( 0 ); + aLineInfo.SetDashLen( 225 ); + aLineInfo.SetDistance( 100 ); break; case PS_NULL : bTransparent = true; @@ -1033,12 +1051,6 @@ bool EnhWMFReader::ReadEnhWMF() default : aLineInfo.SetStyle( LINE_SOLID ); } - if ( nDashCount | nDotCount ) - { - aLineInfo.SetStyle( LINE_DASH ); - aLineInfo.SetDashCount( nDashCount ); - aLineInfo.SetDotCount( nDotCount ); - } pOut->CreateObject( nIndex, GDI_PEN, new WinMtfLineStyle( aColorRef, aLineInfo, bTransparent ) ); } } |