[Libreoffice-commits] .: xls-dump.py

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Apr 11 16:48:54 PDT 2011


 xls-dump.py |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

New commits:
commit 4d55509166fb44e08827d127752782b1c8c5e640
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Apr 11 19:47:10 2011 -0400

    Detect OLE stream by its stream name.

diff --git a/xls-dump.py b/xls-dump.py
index 42e3a73..7864b99 100755
--- a/xls-dump.py
+++ b/xls-dump.py
@@ -32,6 +32,21 @@ import ole, xlsstream, globals, node, xlsmodel
 
 from globals import error
 
+def isOleStream (dirname):
+    """Determine whether or not a stream is an OLE stream.
+
+Accodring to the spec, an OLE stream is always named 0x1,'O','l','e'."""
+
+    name = [0x01, 0x4F, 0x6C, 0x65] # 0x01, 'O', 'l', 'e'
+    if len(dirname) != len(name):
+        return False
+
+    for i in xrange(0, len(dirname)):
+        if ord(dirname[i]) != name[i]:
+            return False
+
+    return True
+
 class XLDumper(object):
 
     def __init__ (self, filepath, params):
@@ -117,6 +132,8 @@ class XLDumper(object):
             elif self.strmData.isPivotCacheStream(dirname):
                 dirstrm.type = xlsstream.DirType.PivotTableCache
                 self.__readSubStream(dirstrm)
+            elif isOleStream(dirname):
+                self.__readOleStream(dirstrm)
             else:
                 globals.dumpBytes(dirstrm.bytes, 512)
 
@@ -130,6 +147,9 @@ class XLDumper(object):
         except xlsstream.EndOfStream:
             return False
 
+    def __readOleStream (self, strm):
+        globals.dumpBytes(strm.bytes, 512)
+
     def __readSubStreamXML (self, strm):
         try:
             while True:


More information about the Libreoffice-commits mailing list