diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-12-03 14:22:37 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-12-03 14:22:37 +0100 |
commit | d88a8efc8cb82b6e4620beaaa58264dc19971fd1 (patch) | |
tree | f48ee2bb8f9e4b0be5627c70d2cde3811a88c745 /msodumper/msometa.py | |
parent | 116c0d51b5fceda5338b5be5d995f304a14ecf4e (diff) |
msometa: dump DictionaryEntry
Diffstat (limited to 'msodumper/msometa.py')
-rw-r--r-- | msodumper/msometa.py | 30 |
1 files changed, 29 insertions, 1 deletions
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 |