[Libreoffice-commits] mso-dumper.git: msodumper/msometa.py test/vsd-test.py
Miklos Vajna
vmiklos at collabora.co.uk
Thu Dec 3 02:24:28 PST 2015
msodumper/msometa.py | 32 ++++++++++++++++++++++++++++++++
test/vsd-test.py | 34 ++++------------------------------
2 files changed, 36 insertions(+), 30 deletions(-)
New commits:
commit 81134ab008b2c8d4c227e0f0cd35515083f9ba51
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Dec 3 11:23:58 2015 +0100
msometa: handle VT_FILETIME in TypedPropertyValue
diff --git a/msodumper/msometa.py b/msodumper/msometa.py
index ef9f64b..cdf8c9b 100644
--- a/msodumper/msometa.py
+++ b/msodumper/msometa.py
@@ -7,6 +7,7 @@
from docdirstream import DOCDirStream
import globals
+import time
PIDDSI = {
@@ -246,6 +247,8 @@ class TypedPropertyValue(DOCDirStream):
self.printAndSet("Value", self.readInt16())
elif self.Type == 0x001E: # VT_LPSTR
CodePageString(self, "Value").dump()
+ elif self.Type == 0x0040: # VT_FILETIME
+ FILETIME(self, "Value").dump()
else:
print '<todo what="TypedPropertyValue::dump: unhandled Type %s"/>' % hex(self.Type)
print '</typedPropertyValue%s>' % self.index
@@ -304,4 +307,33 @@ class GUID(DOCDirStream):
print '<%s type="GUID" value="%s"/>' % (self.name, value)
self.parent.pos = self.pos
+
+class OLERecord(DOCDirStream):
+ def __init__(self, parent):
+ DOCDirStream.__init__(self, parent.bytes)
+ self.parent = parent
+ self.pos = parent.pos
+
+
+class FILETIME(OLERecord):
+ def __init__(self, parent, name):
+ OLERecord.__init__(self, parent)
+ self.name = name
+
+ def dump(self):
+ # ft is number of 100ns since Jan 1 1601
+ ft = self.readuInt64()
+ if ft > 0:
+ epoch = 11644473600
+ sec = (ft / 10000000) - epoch
+ else:
+ sec = ft
+ try:
+ pretty = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.localtime(sec))
+ except ValueError:
+ pretty = "ValueError"
+ print '<%s type="FILETIME" value="%d" pretty="%s"/>' % (self.name, sec, pretty)
+ self.parent.pos = self.pos
+
+
# vim:set filetype=python shiftwidth=4 softtabstop=4 expandtab:
diff --git a/test/vsd-test.py b/test/vsd-test.py
index a5fac0c..eb382fa 100755
--- a/test/vsd-test.py
+++ b/test/vsd-test.py
@@ -17,7 +17,6 @@ sys.path.append(sys.path[0] + "/..")
import msodumper.docdirstream
import msodumper.globals
import msodumper.msometa
-import time
class OLEStream(msodumper.docdirstream.DOCDirStream):
@@ -50,21 +49,14 @@ class OLEStream(msodumper.docdirstream.DOCDirStream):
msodumper.msometa.GUID(self, "CLSID").dump()
StateBits = self.readuInt32()
print '<StateBits value="0x%x"/>' % StateBits
- FILETIME(self, "CreationTime").dump()
- FILETIME(self, "ModifiedTime").dump()
+ msodumper.msometa.FILETIME(self, "CreationTime").dump()
+ msodumper.msometa.FILETIME(self, "ModifiedTime").dump()
print '</stream>'
-class OLERecord(msodumper.docdirstream.DOCDirStream):
+class Header(msodumper.msometa.OLERecord):
def __init__(self, parent):
- msodumper.docdirstream.DOCDirStream.__init__(self, parent.bytes)
- self.parent = parent
- self.pos = parent.pos
-
-
-class Header(OLERecord):
- def __init__(self, parent):
- OLERecord.__init__(self, parent)
+ msodumper.msometa.OLERecord.__init__(self, parent)
def dump(self):
print '<CFHeader>'
@@ -100,24 +92,6 @@ class Header(OLERecord):
print '</CFHeader>'
-class FILETIME(OLERecord):
- def __init__(self, parent, name):
- OLERecord.__init__(self, parent)
- self.name = name
-
- def dump(self):
- # ft is number of 100ns since Jan 1 1601
- ft = self.readuInt64()
- if ft > 0:
- epoch = 11644473600
- sec = (ft / 10000000) - epoch
- else:
- sec = ft
- pretty = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.localtime(sec))
- print '<%s type="FILETIME" value="%d" pretty="%s"/>' % (self.name, sec, pretty)
- self.parent.pos = self.pos
-
-
class OLEDumper:
def __init__(self, filepath):
self.filepath = filepath
More information about the Libreoffice-commits
mailing list