summaryrefslogtreecommitdiff
path: root/emfio/source
diff options
context:
space:
mode:
authorBartosz Kosiorek <gang65@poczta.onet.pl>2020-11-13 13:24:36 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2020-11-17 10:06:34 +0100
commit7131d5b085bf94cef009a71b59cbdeae09acb918 (patch)
tree01e68b3e2dd6a9f168f80cd65be95964bcb5b644 /emfio/source
parenta9132dc4c79088b25f6b10c5a5ba7dbcbcccf5d3 (diff)
tdf#35986 EMF import: Add support for PS_COSMETIC line style in CREATEPEN
When the PS_COSMETIC line style is set in CREATEPEN, line width should be set to one logical unit and a style that is a solid color This patch is fixing that, allowing to properly import EMF file. The corresponding unit tests were added Change-Id: I1a0caf6382d9c313d9725d0b94e2fcd37122a099 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105790 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105944
Diffstat (limited to 'emfio/source')
-rw-r--r--emfio/source/reader/emfreader.cxx28
1 files changed, 17 insertions, 11 deletions
diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx
index 2c932a440eeb..fee0fdef6f10 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -1115,19 +1115,23 @@ namespace emfio
mpInputStream->ReadUInt32( nIndex );
if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
{
-
LineInfo aLineInfo;
sal_uInt32 nStyle;
- Size aSize;
- // #fdo39428 Remove SvStream operator>>(long&)
- sal_Int32 nTmpW(0), nTmpH(0);
+ sal_Int32 nPenWidth, nIgnored;
- mpInputStream->ReadUInt32( nStyle ).ReadInt32( nTmpW ).ReadInt32( nTmpH );
- aSize.setWidth( nTmpW );
- aSize.setHeight( nTmpH );
+ mpInputStream->ReadUInt32( nStyle ).ReadInt32( nPenWidth ).ReadInt32( nIgnored );
- if ( aSize.Width() )
- aLineInfo.SetWidth( aSize.Width() );
+ SAL_INFO("emfio", "\t\tIndex: " << nIndex << " nStyle: 0x" << std::hex << nStyle << std::dec << " nPenWidth: " << nPenWidth);
+ // nStyle = PS_COSMETIC = 0x0 - line with a width of one logical unit and a style that is a solid color
+ if ( !nStyle )
+ {
+ // Width 0 means default width for LineInfo (HairLine) with 1 pixel wide
+ aLineInfo.SetWidth( 0 );
+ }
+ else
+ {
+ aLineInfo.SetWidth( nPenWidth );
+ }
bool bTransparent = false;
switch( nStyle & PS_STYLE_MASK )
@@ -1164,14 +1168,14 @@ namespace emfio
switch( nStyle & PS_ENDCAP_STYLE_MASK )
{
case PS_ENDCAP_ROUND :
- if ( aSize.Width() )
+ if ( nPenWidth )
{
aLineInfo.SetLineCap( css::drawing::LineCap_ROUND );
break;
}
[[fallthrough]];
case PS_ENDCAP_SQUARE :
- if ( aSize.Width() )
+ if ( nPenWidth )
{
aLineInfo.SetLineCap( css::drawing::LineCap_SQUARE );
break;
@@ -1210,6 +1214,8 @@ namespace emfio
if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
{
mpInputStream->ReadUInt32( offBmi ).ReadUInt32( cbBmi ).ReadUInt32( offBits ).ReadUInt32( cbBits ). ReadUInt32( nStyle ).ReadUInt32( nWidth ).ReadUInt32( nBrushStyle );
+ SAL_INFO("emfio", "\t\tStyle: 0x" << std::hex << nStyle << std::dec);
+ SAL_INFO("emfio", "\t\tWidth: " << nWidth);
aColorRef = ReadColor();
mpInputStream->ReadInt32( elpHatch ).ReadUInt32( elpNumEntries );