[Libreoffice-commits] .: src/ole.py src/xlsstream.py xls-dump.py
Kohei Yoshida
kohei at kemper.freedesktop.org
Thu Apr 7 20:46:43 PDT 2011
src/ole.py | 9 ++++++++-
src/xlsstream.py | 10 ++++------
xls-dump.py | 18 ++++++++++--------
3 files changed, 22 insertions(+), 15 deletions(-)
New commits:
commit 84c6b072d3107e4e418449e153bc223d6d55b773
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Thu Apr 7 23:43:56 2011 -0400
Skip reading directories that are storages.
Storages are equivalent of directories in a normal file system, so
they only have header infos but no data streams (except for the
root entry). Don't treat them like streams.
diff --git a/src/ole.py b/src/ole.py
index 9b01928..744cda7 100644
--- a/src/ole.py
+++ b/src/ole.py
@@ -499,6 +499,9 @@ entire file stream.
self.StreamSize = 0
self.bytes = []
+ def isStorage (self):
+ return self.Type == Directory.Type.RootStorage or \
+ self.Type == Directory.Type.UserStorage
def __init__ (self, header, params):
self.sectorSize = header.getSectorSize()
@@ -533,7 +536,6 @@ entire file stream.
elif entry.StreamLocation == StreamLocation.SSAT:
chain = self.header.getSSAT().getSectorIDChain(entry.StreamSectorID)
-
if entry.StreamLocation == StreamLocation.SSAT:
# Get the root storage stream.
if self.RootStorage == None:
@@ -556,6 +558,9 @@ entire file stream.
return bytes
+ def getRawStream (self, entry):
+ bytes = self.__getRawStream(entry)
+ return bytes
def getRawStreamByName (self, name):
bytes = []
@@ -694,6 +699,8 @@ entire file stream.
output("%2.2X "%ord(byte))
print("")
+ def getDirectoryEntries (self):
+ return self.entries
def getDirectoryNames (self):
names = []
diff --git a/src/xlsstream.py b/src/xlsstream.py
index 0595d1f..6ab4195 100644
--- a/src/xlsstream.py
+++ b/src/xlsstream.py
@@ -367,19 +367,17 @@ class XLStream(object):
return
obj.output()
-
- def getDirectoryNames (self):
+ def getDirectoryEntries (self):
obj = self.__getDirectoryObj()
if obj == None:
return
- return obj.getDirectoryNames()
-
+ return obj.getDirectoryEntries()
- def getDirectoryStreamByName (self, name):
+ def getDirectoryStream (self, entry):
obj = self.__getDirectoryObj()
bytes = []
if obj != None:
- bytes = obj.getRawStreamByName(name)
+ bytes = obj.getRawStream(entry)
strm = XLDirStream(bytes, self.params, self.strmData)
return strm
diff --git a/xls-dump.py b/xls-dump.py
index 52ec00e..f47f260 100755
--- a/xls-dump.py
+++ b/xls-dump.py
@@ -90,14 +90,18 @@ class XLDumper(object):
self.strm.printSAT()
self.strm.printSSAT()
self.strm.printDirectory()
- dirnames = self.strm.getDirectoryNames()
- for dirname in dirnames:
- if len(dirname) == 0 or dirname == 'Root Entry':
+ dirEntries = self.strm.getDirectoryEntries()
+ for entry in dirEntries:
+ dirname = entry.Name
+ if len(dirname) == 0:
continue
- dirstrm = self.strm.getDirectoryStreamByName(dirname)
+ dirstrm = self.strm.getDirectoryStream(entry)
self.__printDirHeader(dirname, len(dirstrm.bytes))
- if dirname == "Workbook":
+ if entry.isStorage():
+ continue
+
+ elif dirname == "Workbook":
success = True
while success:
success = self.__readSubStream(dirstrm)
@@ -105,9 +109,7 @@ class XLDumper(object):
elif dirname == "Revision Log":
dirstrm.type = xlsstream.DirType.RevisionLog
self.__readSubStream(dirstrm)
- elif dirname == '_SX_DB_CUR':
- dirstrm.type = xlsstream.DirType.PivotTableCache
- self.__readSubStream(dirstrm)
+
elif self.strmData.isPivotCacheStream(dirname):
dirstrm.type = xlsstream.DirType.PivotTableCache
self.__readSubStream(dirstrm)
More information about the Libreoffice-commits
mailing list