[Libreoffice-commits] mso-dumper.git: msodumper/wmfrecord.py

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Sep 28 07:51:13 UTC 2021


 msodumper/wmfrecord.py |   40 ++++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)

New commits:
commit 5b01cfd6971e8822b8d52e0ba3bad2134a9e5aa9
Author:     Hossein <hossein at libreoffice.org>
AuthorDate: Tue Sep 28 09:42:03 2021 +0200
Commit:     Hossein <hossein at libreoffice.org>
CommitDate: Tue Sep 28 09:50:54 2021 +0200

    Added dump() for 2 wmf records in wmf-dump
    
    Added dump() for 2 wmf records to wmf-dump.py
    
    List of records:
    
    1. SaveDC (META_SAVEDC)
    2. RestoreDC (META_RESTOREDC)
    
    Change-Id: I12007c40d385b3b3ca25876428f37e01e241757d
    Reviewed-on: https://gerrit.libreoffice.org/c/mso-dumper/+/122754
    Tested-by: Hossein <hossein at libreoffice.org>
    Reviewed-by: Hossein <hossein at libreoffice.org>

diff --git a/msodumper/wmfrecord.py b/msodumper/wmfrecord.py
index dc1ecdb..6065163 100644
--- a/msodumper/wmfrecord.py
+++ b/msodumper/wmfrecord.py
@@ -953,13 +953,22 @@ class SetTextCharacterExtra(WMFRecord):
         pass
 
 
-class RestoreDC:
-    def __init__(self, parent):
+class RestoreDC(WMFRecord):
+    def __init__(self, parent, name=None):
         WMFRecord.__init__(self, parent)
+        if name:
+            self.name = name
+        else:
+            self.name = "restoredc"
 
     def dump(self):
-        print("<todo/>")
-        pass
+        dataPos = self.pos
+        print('<%s type="RestoreDC">' % self.name)
+        self.printAndSet("RecordSize", self.readuInt32(), hexdump=False)
+        self.printAndSet("RecordFunction", self.readuInt16(), hexdump=True)
+        self.printAndSet("nSavedDC", self.readInt16(), hexdump=False)
+        # RecordSize is described in words, so we should double for bytes
+        assert self.pos == dataPos + self.RecordSize * 2
 
 
 class ResizePalette(WMFRecord):
@@ -1423,21 +1432,20 @@ class RoundRect(WMFRecord):
 
 
 class SaveDC(WMFRecord):
-    def __init__(self, parent):
-        WMFRecord.__init__(self, parent)
-
-    def dump(self):
-        print("<todo/>")
-        pass
-
-
-class SaveDC(WMFRecord):
-    def __init__(self, parent):
+    def __init__(self, parent, name=None):
         WMFRecord.__init__(self, parent)
+        if name:
+            self.name = name
+        else:
+            self.name = "savedc"
 
     def dump(self):
-        print("<todo/>")
-        pass
+        dataPos = self.pos
+        print('<%s type="SaveDC">' % self.name)
+        self.printAndSet("RecordSize", self.readuInt32(), hexdump=False)
+        self.printAndSet("RecordFunction", self.readuInt16(), hexdump=True)
+        # RecordSize is described in words, so we should double for bytes
+        assert self.pos == dataPos + self.RecordSize * 2
 
 
 class Pie(WMFRecord):


More information about the Libreoffice-commits mailing list