summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan van den Akker <stephanv778@gmail.com>2016-02-23 11:13:20 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-03-01 14:39:15 +0000
commit39b1a23c09231bb61c0196d7ab24cb3e0cac9afc (patch)
treefa67d46a769052bd96f14945414515a662e78593
parent56972b9899b2ec3fdc8c35cb293e0a232d7ffca3 (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/22714 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-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 5904e0928889..af35d6da5c6e 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 ) );
}
}