From e06807f51d157844b357dab1bbf960cc55162330 Mon Sep 17 00:00:00 2001 From: Patrick Jaap Date: Mon, 2 Oct 2017 16:21:04 +0200 Subject: tdf#31814 EMF/EMF+ implement dual mode There can be a dual mode flag set in the EMF+ data. If set, we should process either EMF or EMF+ data, because the contained information should be equal (says the documentation). The more advanced EMF+ renderer is chosen here. The flag is read in the EMFPlusReader and blocks the reading of other EMF records than HEADER, EOF and COMMENT. Thanks to Chris, for pointing out the dual mode! Change-Id: I8522930cebbb9e9ecc732397cbb3deea9e8c9127 Reviewed-on: https://gerrit.libreoffice.org/43122 Reviewed-by: Patrick Jaap Reviewed-by: Bartosz Kosiorek Tested-by: Bartosz Kosiorek --- emfio/inc/emfreader.hxx | 1 + emfio/source/reader/emfreader.cxx | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) (limited to 'emfio') diff --git a/emfio/inc/emfreader.hxx b/emfio/inc/emfreader.hxx index 8ee533c24068..4b2855cf54f6 100644 --- a/emfio/inc/emfreader.hxx +++ b/emfio/inc/emfreader.hxx @@ -31,6 +31,7 @@ namespace emfio bool mbRecordPath : 1; bool mbEMFPlus : 1; + bool mbEMFPlusDualMode : 1; bool ReadHeader(); // reads and converts the rectangle diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index 859c3510b759..8ff413b79033 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -384,6 +384,7 @@ namespace emfio , mnRecordCount(0) , mbRecordPath(false) , mbEMFPlus(false) + ,mbEMFPlusDualMode(false) { } @@ -443,6 +444,15 @@ namespace emfio SAL_INFO ("vcl.emf", "\t\tEMF+ lock DC (device context)"); } + // look for the "dual mode" in header + // it indicates that either EMF or EMF+ records should be processed + // 0x4001 = EMF+ header + // flags & 1 = dual mode active + if ( type == 0x4001 && flags & 1 ) + { + mbEMFPlusDualMode = true; + } + // Get the length of the remaining data of this record based // on the alleged size sal_uInt32 nRemainingRecordData = size >= nRequiredHeaderSize ? @@ -697,6 +707,14 @@ namespace emfio } } } + else if ( !bHaveDC && mbEMFPlusDualMode && nRecType != EMR_HEADER && nRecType != EMR_EOF ) + { + // skip content (EMF record) in dual mode + // we process only EMR_COMMENT (see above) to access EMF+ data + // with 2 exceptions, according to EMF+ specification: + // EMR_HEADER and EMR_EOF + // if a device context is given (bHaveDC) process the following EMF record, too. + } else if( !mbEMFPlus || bHaveDC || nRecType == EMR_EOF ) { switch( nRecType ) -- cgit