[Libreoffice-commits] core.git: emfio/inc emfio/source

Patrick Jaap patrick.jaap at tu-dresden.de
Thu Oct 26 18:19:15 UTC 2017


 emfio/inc/emfreader.hxx           |    1 +
 emfio/source/reader/emfreader.cxx |   18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

New commits:
commit e06807f51d157844b357dab1bbf960cc55162330
Author: Patrick Jaap <patrick.jaap at tu-dresden.de>
Date:   Mon Oct 2 16:21:04 2017 +0200

    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 <patrick.jaap at tu-dresden.de>
    Reviewed-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>
    Tested-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>

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 )


More information about the Libreoffice-commits mailing list