[Libreoffice-commits] .: src/docrecord.py src/docstream.py
Miklos Vajna
vmiklos at kemper.freedesktop.org
Sat Jan 5 08:17:09 PST 2013
src/docrecord.py | 12 ++++++++----
src/docstream.py | 13 +++++++------
2 files changed, 15 insertions(+), 10 deletions(-)
New commits:
commit 3ffc1fe7dd9132e6bc55a3a26c9aa7c01eaeb7f0
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Sat Jan 5 16:50:15 2013 +0100
doc: handle files with empty Fib.cswNew (LibreOffice produces these)
diff --git a/src/docrecord.py b/src/docrecord.py
index 71602de..fc041e5 100644
--- a/src/docrecord.py
+++ b/src/docrecord.py
@@ -1413,7 +1413,9 @@ class Dop(DOCDirStream):
def dump(self):
print '<dop type="Dop" offset="%s" size="%d bytes">' % (self.pos, self.size)
- if self.fib.nFibNew == 0x0112:
+ if self.fib.nFibNew == 0:
+ Dop97(self).dump()
+ elif self.fib.nFibNew == 0x0112:
Dop2007(self).dump()
else:
print """<todo what="Dop.dump() doesn't know how to handle nFibNew = %s">""" % hex(self.nFibNew)
@@ -1699,12 +1701,14 @@ class STSHI(DOCDirStream):
def dump(self):
print '<stshi type="STSHI" offset="%d" size="%d bytes">' % (self.pos, self.size)
+ posOrig = self.pos
self.stshif = Stshif(self.bytes, self.mainStream, self.pos)
self.stshif.dump()
self.pos += self.stshif.size
- self.printAndSet("ftcBi", self.readuInt16())
- stshiLsd = StshiLsd(self.bytes, self, self.pos)
- stshiLsd.dump()
+ if self.pos - posOrig < self.size:
+ self.printAndSet("ftcBi", self.readuInt16())
+ stshiLsd = StshiLsd(self.bytes, self, self.pos)
+ stshiLsd.dump()
print '</stshi>'
class LPStshi(DOCDirStream):
diff --git a/src/docstream.py b/src/docstream.py
index 47f8431..5d4f999 100644
--- a/src/docstream.py
+++ b/src/docstream.py
@@ -76,7 +76,7 @@ class WordDocumentStream(DOCDirStream):
def __getFibNew(self):
cswNew = self.getuInt16(pos = self.__getCswNewOffset())
if cswNew == 0:
- raise Exception()
+ return 0
else:
return self.getuInt16(pos = self.__getCswNewOffset() + 2)
@@ -399,10 +399,11 @@ class WordDocumentStream(DOCDirStream):
needsHandling = i[0].startswith("lcb") and value != 0 and (not i[0] in needsIgnoring)
self.printAndSet(i[0], value, end = ((not hasHandler) and (not needsHandling)), offset = True)
if hasHandler or needsHandling:
- if hasHandler:
- i[1]()
- else:
- print '<todo what="value is non-zero and unhandled"/>'
+ if needsHandling:
+ if hasHandler:
+ i[1]()
+ else:
+ print '<todo what="value is non-zero and unhandled"/>'
print '</%s>' % i[0]
def handleDop(self):
@@ -598,7 +599,7 @@ class WordDocumentStream(DOCDirStream):
self.printAndSet(i, self.readuInt32())
def dumpFibRgFcLcb2002(self, name):
- print '<%s type="dumpFibRgFcLcb2002" size="744 bytes">' % name
+ print '<%s type="FibRgFcLcb2002" size="744 bytes">' % name
self.__dumpFibRgFcLcb2002()
print '</%s>' % name
More information about the Libreoffice-commits
mailing list