[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - test/source vcl/qa vcl/source
Stephan van den Akker
stephanv778 at gmail.com
Sun Mar 6 16:40:40 UTC 2016
test/source/mtfxmldump.cxx | 28 ++++++++++++++++++++++++++-
vcl/qa/cppunit/wmf/wmfimporttest.cxx | 16 +++++++++++++++
vcl/source/filter/wmf/enhwmf.cxx | 36 +++++++++++++++++++++++++++++++++--
vcl/source/filter/wmf/winmtf.hxx | 9 ++++----
4 files changed, 82 insertions(+), 7 deletions(-)
New commits:
commit 4a17335d608c2954c482734ce4912100cb0e7aff
Author: Stephan van den Akker <stephanv778 at gmail.com>
Date: Wed Mar 2 00:17:03 2016 +0100
Fix the import of line joins and caps from EMF files
Backported fix to 5.0. Note that commit 42f771d6e changed from constant
values for line joins to an enum, but that only got into the 5.1 branch
so have had to use the old constants.
Change-Id: I976336d35366b661e402db484820b4dd9a7b0228
Reviewed-on: https://gerrit.libreoffice.org/22821
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/22947
Reviewed-by: Chris Sherlock <chris.sherlock79 at gmail.com>
Tested-by: Chris Sherlock <chris.sherlock79 at gmail.com>
diff --git a/test/source/mtfxmldump.cxx b/test/source/mtfxmldump.cxx
index 3df33b9..9ca0603 100644
--- a/test/source/mtfxmldump.cxx
+++ b/test/source/mtfxmldump.cxx
@@ -124,6 +124,29 @@ OUString convertLineStyleToString(LineStyle eAlign)
return OUString();
}
+OUString convertLineJoinToString(basegfx::B2DLineJoin eJoin)
+{
+ switch (eJoin)
+ {
+ default:
+ case basegfx::B2DLINEJOIN_NONE: return OUString("none");
+ case basegfx::B2DLINEJOIN_BEVEL: return OUString("bevel");
+ case basegfx::B2DLINEJOIN_MITER: return OUString("miter");
+ case basegfx::B2DLINEJOIN_ROUND: return OUString("round");
+ }
+}
+
+OUString convertLineCapToString(css::drawing::LineCap eCap)
+{
+ switch (eCap)
+ {
+ default:
+ case css::drawing::LineCap_BUTT: return OUString("butt");
+ case css::drawing::LineCap_ROUND: return OUString("round");
+ case css::drawing::LineCap_SQUARE: return OUString("square");
+ }
+}
+
OUString convertFontWeigthToString(FontWeight eFontWeight)
{
enum FontWeight { WEIGHT_DONTKNOW, WEIGHT_THIN, WEIGHT_ULTRALIGHT,
@@ -282,9 +305,12 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter)
rWriter.attribute("style", convertLineStyleToString(aLineInfo.GetStyle()));
rWriter.attribute("width", aLineInfo.GetWidth());
rWriter.attribute("dashlen", aLineInfo.GetDashLen());
+ rWriter.attribute("dashcount", aLineInfo.GetDashCount());
rWriter.attribute("dotlen", aLineInfo.GetDotLen());
+ rWriter.attribute("dotcount", aLineInfo.GetDotCount());
rWriter.attribute("distance", aLineInfo.GetDistance());
-
+ rWriter.attribute("join", convertLineJoinToString(aLineInfo.GetLineJoin()));
+ rWriter.attribute("cap", convertLineCapToString(aLineInfo.GetLineCap()));
rWriter.endElement();
}
break;
diff --git a/vcl/qa/cppunit/wmf/wmfimporttest.cxx b/vcl/qa/cppunit/wmf/wmfimporttest.cxx
index 2a1a341..32c4d90 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 470e1b2..5b1099d 100644
--- a/vcl/source/filter/wmf/enhwmf.cxx
+++ b/vcl/source/filter/wmf/enhwmf.cxx
@@ -943,7 +943,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() )
@@ -961,7 +961,7 @@ bool EnhWMFReader::ReadEnhWMF()
default :
aLineInfo.SetLineCap( com::sun::star::drawing::LineCap_BUTT );
}
- switch( nStyle & 0xF000 )
+ switch( nStyle & PS_JOIN_STYLE_MASK )
{
case PS_JOIN_ROUND :
aLineInfo.SetLineJoin ( basegfx::B2DLINEJOIN_ROUND );
@@ -1041,6 +1041,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 dd35561..fcc06a9 100644
--- a/vcl/source/filter/wmf/winmtf.hxx
+++ b/vcl/source/filter/wmf/winmtf.hxx
@@ -148,14 +148,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
More information about the Libreoffice-commits
mailing list