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

Miklos Vajna vmiklos at collabora.co.uk
Thu Dec 3 03:32:22 PST 2015


 msodumper/msometa.py |   45 ++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 38 insertions(+), 7 deletions(-)

New commits:
commit 116c0d51b5fceda5338b5be5d995f304a14ecf4e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Dec 3 12:31:27 2015 +0100

    msometa: dump Dictionary

diff --git a/msodumper/msometa.py b/msodumper/msometa.py
index e5785e3..de42d87 100644
--- a/msodumper/msometa.py
+++ b/msodumper/msometa.py
@@ -85,6 +85,7 @@ class SummaryInformationStream(DOCDirStream):
 
 
 class PropertySetStream(DOCDirStream):
+    """Specified by [MS-OLEPS] 2.21, the stream format for simple property sets."""
     def __init__(self, parent, PropertyIds):
         DOCDirStream.__init__(self, parent.bytes)
         self.parent = parent
@@ -107,15 +108,18 @@ class PropertySetStream(DOCDirStream):
             GUID(self, "FMTID1").dump()
             self.printAndSet("Offset1", self.readuInt32())
             self.propertyIds = {}
-            PropertySet(self, self.Offset1).dump()
+            # The spec says: if NumPropertySets has the value 0x00000002,
+            # FMTID1 must be set to FMTID_UserDefinedProperties.
+            PropertySet(self, self.Offset1, userDefined=True).dump()
         print '</propertySetStream>'
 
 
 class PropertySet(DOCDirStream):
-    def __init__(self, parent, offset):
+    def __init__(self, parent, offset, userDefined=False):
         DOCDirStream.__init__(self, parent.bytes)
         self.parent = parent
         self.pos = offset
+        self.userDefined = userDefined
 
     def getCodePage(self):
         for index, idAndOffset in enumerate(self.idsAndOffsets):
@@ -137,9 +141,15 @@ class PropertySet(DOCDirStream):
             self.idsAndOffsets.append(idAndOffset)
         self.typedPropertyValues = []
         for i in range(self.NumProperties):
-            typedPropertyValue = TypedPropertyValue(self, i)
-            typedPropertyValue.dump()
-            self.typedPropertyValues.append(typedPropertyValue)
+            if self.userDefined and self.idsAndOffsets[i].PropertyIdentifier == 0x00000000:
+                # [MS-OLEPS] 2.18.1 says the Dictionary property (id=0 in user-defined sets) has a different type.
+                dictionary = Dictionary(self, i)
+                dictionary.dump()
+                self.typedPropertyValues.append("Dictionary")
+            else:
+                typedPropertyValue = TypedPropertyValue(self, i)
+                typedPropertyValue.dump()
+                self.typedPropertyValues.append(typedPropertyValue)
         print '</propertySet>'
 
 
@@ -232,6 +242,23 @@ PropertyType = {
 }
 
 
+class Dictionary(DOCDirStream):
+    """Specified by [MS-OLEPS] 2.17, represents all mappings between property
+    identifiers and property names in a property set."""
+    def __init__(self, parent, index):
+        DOCDirStream.__init__(self, parent.bytes)
+        self.parent = parent
+        self.index = index
+        self.pos = parent.posOrig + parent.idsAndOffsets[index].Offset
+
+    def dump(self):
+        print '<dictionary%s type="Dictionary" offset="%s">' % (self.index, self.pos)
+        self.printAndSet("NumEntries", self.readuInt32())
+        for i in range(self.NumEntries):
+            print '<todo what="Dictionary::dump: handle DictionaryEntry"/>'
+        print '</dictionary%s>' % self.index
+
+
 class TypedPropertyValue(DOCDirStream):
     def __init__(self, parent, index):
         DOCDirStream.__init__(self, parent.bytes)
commit 514537d404465068643afde6b800bdb2d3976032
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Dec 3 11:49:41 2015 +0100

    msometa: handle VARIANT_BOOL in TypedPropertyValue

diff --git a/msodumper/msometa.py b/msodumper/msometa.py
index 76eeca8..e5785e3 100644
--- a/msodumper/msometa.py
+++ b/msodumper/msometa.py
@@ -247,6 +247,8 @@ class TypedPropertyValue(DOCDirStream):
             self.printAndSet("Value", self.readInt16())
         elif self.Type == 0x0003:  # VT_I4
             self.printAndSet("Value", self.readInt32())
+        elif self.Type == 0x000b:  # VARIANT_BOOL
+            self.printAndSet("Value", self.readuInt32())
         elif self.Type == 0x0040:  # VT_FILETIME
             FILETIME(self, "Value").dump()
         elif self.Type == 0x001E:  # VT_LPSTR
commit f5e5b9bf8c020c3d306e1936cb276685583ba860
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Dec 3 11:26:57 2015 +0100

    msometa: handle VT_I4 in TypedPropertyValue

diff --git a/msodumper/msometa.py b/msodumper/msometa.py
index cdf8c9b..76eeca8 100644
--- a/msodumper/msometa.py
+++ b/msodumper/msometa.py
@@ -245,10 +245,12 @@ class TypedPropertyValue(DOCDirStream):
         self.printAndSet("Padding", self.readuInt16())
         if self.Type == 0x0002:  # VT_I2
             self.printAndSet("Value", self.readInt16())
-        elif self.Type == 0x001E:  # VT_LPSTR
-            CodePageString(self, "Value").dump()
+        elif self.Type == 0x0003:  # VT_I4
+            self.printAndSet("Value", self.readInt32())
         elif self.Type == 0x0040:  # VT_FILETIME
             FILETIME(self, "Value").dump()
+        elif self.Type == 0x001E:  # VT_LPSTR
+            CodePageString(self, "Value").dump()
         else:
             print '<todo what="TypedPropertyValue::dump: unhandled Type %s"/>' % hex(self.Type)
         print '</typedPropertyValue%s>' % self.index


More information about the Libreoffice-commits mailing list