summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorStephan van den Akker <stephanv778@gmail.com>2016-02-23 11:13:20 +0100
committerChris Sherlock <chris.sherlock79@gmail.com>2016-03-05 00:49:59 +0000
commit86b1846bbbd0a7ec84ed9d87fed411910b747765 (patch)
tree9d717e6301bf0c1caa4ce1b9f1bb669824abc142 /vcl
parentda2f91b5ceef6d7c6a7b833b25a48f12f58643f5 (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> (cherry picked from commit 9db34a7712e277389b2041cfbd77a60476d7f7f1) Reviewed-on: https://gerrit.libreoffice.org/22718 Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/wmf/data/line_styles.emfbin0 -> 2748 bytes
-rw-r--r--vcl/qa/cppunit/wmf/wmfimporttest.cxx46
-rw-r--r--vcl/source/filter/wmf/enhwmf.cxx36
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
new file mode 100644
index 000000000000..07b78327dabb
--- /dev/null
+++ b/vcl/qa/cppunit/wmf/data/line_styles.emf
Binary files differ
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 f130fad1fd98..470e1b290674 100644
--- a/vcl/source/filter/wmf/enhwmf.cxx
+++ b/vcl/source/filter/wmf/enhwmf.cxx
@@ -998,20 +998,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;
@@ -1023,12 +1041,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 ) );
}
}