summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorLuke Deller <luke@deller.id.au>2019-08-07 00:22:12 +1000
committerMiklos Vajna <vmiklos@collabora.com>2019-08-07 16:43:21 +0200
commit6369cab9b1e16275c8700692bb717aec3c42d346 (patch)
tree86d3edc226c7bd4d5f92270d2f6e5df0349a725f /vcl
parent75903a0298218f89a199a5ac151ee0166f4469d7 (diff)
tdf#126708 Fix EMF image size in CLI .doc export
Implement EMF image size detection, to fix this bug where an EMF image gets zero size when exported to .doc format from the command line. Change-Id: If980c5d65d4880150815fd1df9704d9c1b3b93c9 Reviewed-on: https://gerrit.libreoffice.org/77031 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/filter/graphicfilter2.cxx48
1 files changed, 44 insertions, 4 deletions
diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx
index 27dd780b57c8..8839807aa962 100644
--- a/vcl/source/filter/graphicfilter2.cxx
+++ b/vcl/source/filter/graphicfilter2.cxx
@@ -1044,12 +1044,52 @@ bool GraphicDescriptor::ImpDetectWMF( SvStream&, bool )
return bRet;
}
-bool GraphicDescriptor::ImpDetectEMF( SvStream&, bool )
+bool GraphicDescriptor::ImpDetectEMF( SvStream& rStm, bool bExtendedInfo )
{
- bool bRet = aPathExt.startsWith( "emf" );
- if (bRet)
- nFormat = GraphicFileFormat::EMF;
+ sal_uInt32 nRecordType = 0;
+ bool bRet = false;
+
+ sal_Int32 nStmPos = rStm.Tell();
+ rStm.SetEndian( SvStreamEndian::LITTLE );
+ rStm.ReadUInt32( nRecordType );
+
+ if ( nRecordType == 0x00000001 )
+ {
+ sal_uInt32 nHeaderSize = 0;
+ sal_Int32 nBoundLeft = 0, nBoundTop = 0, nBoundRight = 0, nBoundBottom = 0;
+ sal_Int32 nFrameLeft = 0, nFrameTop = 0, nFrameRight = 0, nFrameBottom = 0;
+ sal_uInt32 nSignature = 0;
+
+ rStm.ReadUInt32( nHeaderSize );
+ rStm.ReadInt32( nBoundLeft );
+ rStm.ReadInt32( nBoundTop );
+ rStm.ReadInt32( nBoundRight );
+ rStm.ReadInt32( nBoundBottom );
+ rStm.ReadInt32( nFrameLeft );
+ rStm.ReadInt32( nFrameTop );
+ rStm.ReadInt32( nFrameRight );
+ rStm.ReadInt32( nFrameBottom );
+ rStm.ReadUInt32( nSignature );
+
+ if ( nSignature == 0x464d4520 )
+ {
+ nFormat = GraphicFileFormat::EMF;
+ bRet = true;
+ if ( bExtendedInfo )
+ {
+ // size in pixels
+ aPixSize.setWidth( nBoundRight - nBoundLeft + 1 );
+ aPixSize.setHeight( nBoundBottom - nBoundTop + 1 );
+
+ // size in 0.01mm units
+ aLogSize.setWidth( nFrameRight - nFrameLeft + 1 );
+ aLogSize.setHeight( nFrameBottom - nFrameTop + 1 );
+ }
+ }
+ }
+
+ rStm.Seek( nStmPos );
return bRet;
}