summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorStephan van den Akker <stephanv778@gmail.com>2016-03-02 00:17:03 +0100
committerTomaž Vajngerl <quikee@gmail.com>2016-03-02 12:20:05 +0000
commitfe3ac0788666294eff66bb999f68e9cce9c3169e (patch)
tree51d706715f639db4abdbe01661be82a3bc7c6752 /vcl
parent3a4b68260bc6c1e8bcb694f640c70652b830c621 (diff)
Fix the import of line joins and caps from EMF files
Change-Id: I976336d35366b661e402db484820b4dd9a7b0228 Reviewed-on: https://gerrit.libreoffice.org/22821 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/wmf/wmfimporttest.cxx16
-rw-r--r--vcl/source/filter/wmf/enhwmf.cxx36
-rw-r--r--vcl/source/filter/wmf/winmtf.hxx9
3 files changed, 55 insertions, 6 deletions
diff --git a/vcl/qa/cppunit/wmf/wmfimporttest.cxx b/vcl/qa/cppunit/wmf/wmfimporttest.cxx
index 2a1a34196b60..32c4d9019c95 100644
--- a/vcl/qa/cppunit/wmf/wmfimporttest.cxx
+++ b/vcl/qa/cppunit/wmf/wmfimporttest.cxx
@@ -147,23 +147,39 @@ void WmfTest::testEmfLineStyles()
assertXPath(pDoc, "/metafile/line[1]", "style", "dash");
assertXPath(pDoc, "/metafile/line[1]", "dashlen", "225");
+ assertXPath(pDoc, "/metafile/line[1]", "dashcount", "1");
assertXPath(pDoc, "/metafile/line[1]", "dotlen", "0");
+ assertXPath(pDoc, "/metafile/line[1]", "dotcount", "0");
assertXPath(pDoc, "/metafile/line[1]", "distance", "100");
+ assertXPath(pDoc, "/metafile/line[1]", "join", "miter");
+ assertXPath(pDoc, "/metafile/line[1]", "cap", "butt");
assertXPath(pDoc, "/metafile/line[2]", "style", "dash");
assertXPath(pDoc, "/metafile/line[2]", "dashlen", "0");
+ assertXPath(pDoc, "/metafile/line[2]", "dashcount", "0");
assertXPath(pDoc, "/metafile/line[2]", "dotlen", "30");
+ assertXPath(pDoc, "/metafile/line[2]", "dotcount", "1");
assertXPath(pDoc, "/metafile/line[2]", "distance", "50");
+ assertXPath(pDoc, "/metafile/line[2]", "join", "miter");
+ assertXPath(pDoc, "/metafile/line[2]", "cap", "butt");
assertXPath(pDoc, "/metafile/line[3]", "style", "dash");
assertXPath(pDoc, "/metafile/line[3]", "dashlen", "150");
+ assertXPath(pDoc, "/metafile/line[3]", "dashcount", "1");
assertXPath(pDoc, "/metafile/line[3]", "dotlen", "30");
+ assertXPath(pDoc, "/metafile/line[3]", "dotcount", "1");
assertXPath(pDoc, "/metafile/line[3]", "distance", "90");
+ assertXPath(pDoc, "/metafile/line[3]", "join", "miter");
+ assertXPath(pDoc, "/metafile/line[3]", "cap", "butt");
assertXPath(pDoc, "/metafile/line[4]", "style", "dash");
assertXPath(pDoc, "/metafile/line[4]", "dashlen", "150");
+ assertXPath(pDoc, "/metafile/line[4]", "dashcount", "1");
assertXPath(pDoc, "/metafile/line[4]", "dotlen", "30");
+ assertXPath(pDoc, "/metafile/line[4]", "dotcount", "2");
assertXPath(pDoc, "/metafile/line[4]", "distance", "50");
+ assertXPath(pDoc, "/metafile/line[4]", "join", "miter");
+ assertXPath(pDoc, "/metafile/line[4]", "cap", "butt");
};
void WmfTest::testWorldTransformFontSize()
diff --git a/vcl/source/filter/wmf/enhwmf.cxx b/vcl/source/filter/wmf/enhwmf.cxx
index 02eebdfdf9eb..8c63027e869f 100644
--- a/vcl/source/filter/wmf/enhwmf.cxx
+++ b/vcl/source/filter/wmf/enhwmf.cxx
@@ -953,7 +953,7 @@ bool EnhWMFReader::ReadEnhWMF()
default :
aLineInfo.SetStyle( LINE_SOLID );
}
- switch( nStyle & 0xF00 )
+ switch( nStyle & PS_ENDCAP_STYLE_MASK )
{
case PS_ENDCAP_ROUND :
if ( aSize.Width() )
@@ -971,7 +971,7 @@ bool EnhWMFReader::ReadEnhWMF()
default :
aLineInfo.SetLineCap( css::drawing::LineCap_BUTT );
}
- switch( nStyle & 0xF000 )
+ switch( nStyle & PS_JOIN_STYLE_MASK )
{
case PS_JOIN_ROUND :
aLineInfo.SetLineJoin ( basegfx::B2DLineJoin::Round );
@@ -1051,6 +1051,38 @@ bool EnhWMFReader::ReadEnhWMF()
default :
aLineInfo.SetStyle( LINE_SOLID );
}
+ switch( nStyle & PS_ENDCAP_STYLE_MASK )
+ {
+ case PS_ENDCAP_ROUND :
+ if ( aLineInfo.GetWidth() )
+ {
+ aLineInfo.SetLineCap( css::drawing::LineCap_ROUND );
+ break;
+ }
+ case PS_ENDCAP_SQUARE :
+ if ( aLineInfo.GetWidth() )
+ {
+ aLineInfo.SetLineCap( css::drawing::LineCap_SQUARE );
+ break;
+ }
+ case PS_ENDCAP_FLAT :
+ default :
+ aLineInfo.SetLineCap( css::drawing::LineCap_BUTT );
+ }
+ switch( nStyle & PS_JOIN_STYLE_MASK )
+ {
+ case PS_JOIN_ROUND :
+ aLineInfo.SetLineJoin ( basegfx::B2DLineJoin::Round );
+ break;
+ case PS_JOIN_MITER :
+ aLineInfo.SetLineJoin ( basegfx::B2DLineJoin::Miter );
+ break;
+ case PS_JOIN_BEVEL :
+ aLineInfo.SetLineJoin ( basegfx::B2DLineJoin::Bevel );
+ break;
+ default :
+ aLineInfo.SetLineJoin ( basegfx::B2DLineJoin::NONE );
+ }
pOut->CreateObject( nIndex, GDI_PEN, new WinMtfLineStyle( aColorRef, aLineInfo, bTransparent ) );
}
}
diff --git a/vcl/source/filter/wmf/winmtf.hxx b/vcl/source/filter/wmf/winmtf.hxx
index 0d0f96b74a34..6b9a25e326c2 100644
--- a/vcl/source/filter/wmf/winmtf.hxx
+++ b/vcl/source/filter/wmf/winmtf.hxx
@@ -149,14 +149,15 @@ struct WMF_EXTERNALHEADER;
#define PS_INSIDEFRAME 6
#define PS_STYLE_MASK 15
-#define PS_ENDCAP_ROUND 0x000
-#define PS_ENDCAP_SQUARE 0x100
-#define PS_ENDCAP_FLAT 0x200
+#define PS_ENDCAP_ROUND 0x000
+#define PS_ENDCAP_SQUARE 0x100
+#define PS_ENDCAP_FLAT 0x200
+#define PS_ENDCAP_STYLE_MASK 0xF00
#define PS_JOIN_ROUND 0x0000
#define PS_JOIN_BEVEL 0x1000
#define PS_JOIN_MITER 0x2000
-
+#define PS_JOIN_STYLE_MASK 0xF000
#define ANSI_CHARSET 0
#define DEFAULT_CHARSET 1