[Libreoffice-commits] mso-dumper.git: msodumper/msometa.py
Miklos Vajna
vmiklos at collabora.co.uk
Thu Dec 3 05:22:59 PST 2015
msodumper/msometa.py | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
New commits:
commit d88a8efc8cb82b6e4620beaaa58264dc19971fd1
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Dec 3 14:22:37 2015 +0100
msometa: dump DictionaryEntry
diff --git a/msodumper/msometa.py b/msodumper/msometa.py
index de42d87..542444c 100644
--- a/msodumper/msometa.py
+++ b/msodumper/msometa.py
@@ -242,6 +242,33 @@ PropertyType = {
}
+class DictionaryEntry(DOCDirStream):
+ """"Specified by [MS-OLEPS] 2.16, represents a mapping between a property
+ identifier and a property name."""
+ def __init__(self, parent):
+ DOCDirStream.__init__(self, parent.bytes)
+ self.parent = parent
+ self.pos = parent.pos
+
+ def dump(self):
+ print '<dictionaryEntry offset="%s">' % self.pos
+ self.printAndSet("PropertyIdentifier", self.readuInt32())
+ self.printAndSet("Length", self.readuInt32())
+
+ bytes = []
+ for dummy in range(self.Length):
+ c = self.readuInt8()
+ if c == 0:
+ break
+ bytes.append(c)
+ # TODO support non-latin1
+ encoding = "latin1"
+ print '<Name value="%s"/>' % globals.encodeName("".join(map(lambda c: chr(c), bytes)).decode(encoding), lowOnly=True).encode('utf-8')
+
+ print '</dictionaryEntry>'
+ self.parent.pos = self.pos
+
+
class Dictionary(DOCDirStream):
"""Specified by [MS-OLEPS] 2.17, represents all mappings between property
identifiers and property names in a property set."""
@@ -255,7 +282,8 @@ class Dictionary(DOCDirStream):
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"/>'
+ dictionaryEntry = DictionaryEntry(self)
+ dictionaryEntry.dump()
print '</dictionary%s>' % self.index
More information about the Libreoffice-commits
mailing list