[Libreoffice-commits] .: 3 commits - src/docdirstream.py src/docrecord.py src/docstream.py
Miklos Vajna
vmiklos at kemper.freedesktop.org
Thu Nov 22 03:14:12 PST 2012
src/docdirstream.py | 9 +-
src/docrecord.py | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/docstream.py | 64 ++++++++++++++++--
3 files changed, 242 insertions(+), 9 deletions(-)
New commits:
commit 75b68567423ace986c8aec7d02dd0b0be084c4f0
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Thu Nov 22 12:14:05 2012 +0100
dump Copts60
diff --git a/src/docrecord.py b/src/docrecord.py
index d3fdbd6..e19843a 100755
--- a/src/docrecord.py
+++ b/src/docrecord.py
@@ -595,6 +595,184 @@ class Clx(DOCDirStream):
print '<todo what="Clx::dump() first byte is not 0x02"/>'
print '</clx>'
+class DopBase(DOCDirStream):
+ """The DopBase structure contains document and compatibility settings."""
+ def __init__(self, dop):
+ DOCDirStream.__init__(self, dop.bytes)
+ self.pos = dop.pos
+ self.dop = dop
+
+ def dump(self):
+ posorig = self.pos
+ buf = self.getuInt8()
+ self.pos += 1
+ self.printAndSet("fFacingPages", self.getBit(buf, 0))
+ self.printAndSet("unused1", self.getBit(buf, 1))
+ self.printAndSet("fPMHMainDoc", self.getBit(buf, 2))
+ self.printAndSet("unused2", (buf & 0x18) >> 3) # 4..5th bits
+ self.printAndSet("fpc", (buf & 0x60) >> 5) # 6..7th bits
+ self.printAndSet("unused3", self.getBit(buf, 7))
+
+ self.printAndSet("unused4", self.getuInt8())
+ self.pos += 1
+
+ buf = self.getuInt16()
+ self.pos += 2
+ self.printAndSet("rncFtn", buf & 0x03) # 1..2nd bits
+ self.printAndSet("nFtn", (buf & 0xfffc) >> 2) # 3..16th bits
+
+ buf = self.getuInt8()
+ self.pos += 1
+ self.printAndSet("unused5", self.getBit(buf, 0))
+ self.printAndSet("unused6", self.getBit(buf, 1))
+ self.printAndSet("unused7", self.getBit(buf, 2))
+ self.printAndSet("unused8", self.getBit(buf, 3))
+ self.printAndSet("unused9", self.getBit(buf, 4))
+ self.printAndSet("unused10", self.getBit(buf, 5))
+ self.printAndSet("fSplAllDone", self.getBit(buf, 6))
+ self.printAndSet("fSplAllClean", self.getBit(buf, 7))
+
+ buf = self.getuInt8()
+ self.pos += 1
+ self.printAndSet("fSplHideErrors", self.getBit(buf, 0))
+ self.printAndSet("fGramHideErrors", self.getBit(buf, 1))
+ self.printAndSet("fLabelDoc", self.getBit(buf, 2))
+ self.printAndSet("fHyphCapitals", self.getBit(buf, 3))
+ self.printAndSet("fAutoHyphen", self.getBit(buf, 4))
+ self.printAndSet("fFormNoFields", self.getBit(buf, 5))
+ self.printAndSet("fLinkStyles", self.getBit(buf, 6))
+ self.printAndSet("fRevMarking", self.getBit(buf, 7))
+
+ buf = self.getuInt8()
+ self.pos += 1
+ self.printAndSet("unused11", self.getBit(buf, 0))
+ self.printAndSet("fExactCWords", self.getBit(buf, 1))
+ self.printAndSet("fPagHidden", self.getBit(buf, 2))
+ self.printAndSet("fPagResults", self.getBit(buf, 3))
+ self.printAndSet("fLockAtn", self.getBit(buf, 4))
+ self.printAndSet("fMirrorMargins", self.getBit(buf, 5))
+ self.printAndSet("fWord97Compat", self.getBit(buf, 6))
+ self.printAndSet("unused12", self.getBit(buf, 7))
+
+ buf = self.getuInt8()
+ self.pos += 1
+ self.printAndSet("unused13", self.getBit(buf, 0))
+ self.printAndSet("fProtEnabled", self.getBit(buf, 1))
+ self.printAndSet("fDispFormFldSel", self.getBit(buf, 2))
+ self.printAndSet("fRMView", self.getBit(buf, 3))
+ self.printAndSet("fRMPrint", self.getBit(buf, 4))
+ self.printAndSet("fLockVbaProj", self.getBit(buf, 5))
+ self.printAndSet("fLockRev", self.getBit(buf, 6))
+ self.printAndSet("fEmbedFonts", self.getBit(buf, 7))
+
+ # Copts60 first byte
+ buf = self.getuInt8()
+ self.pos += 1
+ self.printAndSet("fNoTabForInd", self.getBit(buf, 0))
+ self.printAndSet("fNoSpaceRaiseLower", self.getBit(buf, 1))
+ self.printAndSet("fSuppressSpBfAfterPgBrk", self.getBit(buf, 2))
+ self.printAndSet("fWrapTrailSpaces", self.getBit(buf, 3))
+ self.printAndSet("fMapPrintTextColor", self.getBit(buf, 4))
+ self.printAndSet("fNoColumnBalance", self.getBit(buf, 5))
+ self.printAndSet("fConvMailMergeEsc", self.getBit(buf, 6))
+ self.printAndSet("fSuppressTopSpacing", self.getBit(buf, 7))
+
+ # Copts60 second byte
+ buf = self.getuInt8()
+ self.pos += 1
+ self.printAndSet("fOrigWordTableRules", self.getBit(buf, 0))
+ self.printAndSet("unused14", self.getBit(buf, 1))
+ self.printAndSet("fShowBreaksInFrames", self.getBit(buf, 2))
+ self.printAndSet("fSwapBordersFacingPgs", self.getBit(buf, 3))
+ self.printAndSet("fLeaveBackslashAlone", self.getBit(buf, 4))
+ self.printAndSet("fExpShRtn", self.getBit(buf, 5))
+ self.printAndSet("fDntULTrlSpc", self.getBit(buf, 6))
+ self.printAndSet("fDntBlnSbDbWid", self.getBit(buf, 7))
+
+ print '<debug offset="%d"/>' % (self.pos - posorig)
+
+class Dop95(DOCDirStream):
+ """The Dop95 structure contains document and compatibility settings."""
+ def __init__(self, dop):
+ DOCDirStream.__init__(self, dop.bytes)
+ self.pos = dop.pos
+ self.dop = dop
+
+ def dump(self):
+ DopBase(self).dump()
+ self.pos += 84
+
+class Dop97(DOCDirStream):
+ """The Dop97 structure contains document and compatibility settings."""
+ def __init__(self, dop):
+ DOCDirStream.__init__(self, dop.bytes)
+ self.pos = dop.pos
+ self.dop = dop
+
+ def dump(self):
+ Dop95(self).dump()
+ self.pos += 88
+
+class Dop2000(DOCDirStream):
+ """The Dop2000 structure contains document and compatibility settings."""
+ def __init__(self, dop):
+ DOCDirStream.__init__(self, dop.bytes)
+ self.pos = dop.pos
+ self.dop = dop
+
+ def dump(self):
+ Dop97(self).dump()
+ self.pos += 500
+
+class Dop2002(DOCDirStream):
+ """The Dop2002 structure contains document and compatibility settings."""
+ def __init__(self, dop):
+ DOCDirStream.__init__(self, dop.bytes)
+ self.pos = dop.pos
+ self.dop = dop
+
+ def dump(self):
+ Dop2000(self).dump()
+ self.pos += 544
+
+class Dop2003(DOCDirStream):
+ """The Dop2003 structure contains document and compatibility settings."""
+ def __init__(self, dop):
+ DOCDirStream.__init__(self, dop.bytes)
+ self.pos = dop.pos
+ self.dop = dop
+
+ def dump(self):
+ Dop2002(self).dump()
+ self.pos += 594
+
+class Dop2007(DOCDirStream):
+ """The Dop2007 structure contains document and compatibility settings."""
+ def __init__(self, dop):
+ DOCDirStream.__init__(self, dop.bytes)
+ self.pos = dop.pos
+ self.dop = dop
+
+ def dump(self):
+ Dop2003(self).dump()
+ self.pos += 616
+
+class Dop(DOCDirStream):
+ """The Dop structure contains the document and compatibility settings for the document."""
+ def __init__(self, fib):
+ DOCDirStream.__init__(self, fib.doc.getDirectoryStreamByName("1Table").bytes)
+ self.pos = fib.fcDop
+ self.size = fib.lcbDop
+ self.fib = fib
+
+ def dump(self):
+ print '<dop type="Dop" offset="%s" size="%d bytes">' % (self.pos, self.size)
+ if self.fib.nFibNew == 0x0112:
+ Dop2007(self).dump()
+ else:
+ print """<todo what="Dop.dump() doesn't know how to handle nFibNew = %s">""" % hex(self.nFibNew)
+ print '</dop>'
+
class FFID(DOCDirStream):
"""The FFID structure specifies the font family and character pitch for a font."""
def __init__(self, bytes, offset):
diff --git a/src/docstream.py b/src/docstream.py
index 1b7731c..37421bb 100755
--- a/src/docstream.py
+++ b/src/docstream.py
@@ -65,15 +65,28 @@ class WordDocumentStream(DOCDirStream):
self.dumpFibRgLw97("fibRgLw")
self.printAndSet("cbRgFcLcb", self.getuInt16())
self.pos += 2
- pos = self.pos
+
+ self.blobOffset = self.pos
+ self.nFibNew = self.__getFibNew()
self.dumpFibRgFcLcb("fibRgFcLcbBlob")
- self.pos = pos + (8 * self.cbRgFcLcb)
+ self.pos = self.__getCswNewOffset()
+
self.printAndSet("cswNew", self.getuInt16(), offset = True)
self.pos += 2
if self.cswNew != 0:
self.dumpFibRgCswNew("fibRgCswNew")
print '</fib>'
+ def __getFibNew(self):
+ cswNew = self.getuInt16(pos = self.__getCswNewOffset())
+ if cswNew == 0:
+ raise Exception()
+ else:
+ return self.getuInt16(pos = self.__getCswNewOffset() + 2)
+
+ def __getCswNewOffset(self):
+ return self.blobOffset + (8 * self.cbRgFcLcb)
+
def dumpFibRgCswNew(self, name):
print '<%s type="FibRgCswNew" size="%d bytes">' % (name, self.cswNew)
self.printAndSet("nFibNew", self.getuInt16())
@@ -285,7 +298,7 @@ class WordDocumentStream(DOCDirStream):
["fcWss"],
["lcbWss"],
["fcDop"],
- ["lcbDop"],
+ ["lcbDop", self.handleDop],
["fcSttbfAssoc"],
["lcbSttbfAssoc"],
["fcClx"],
@@ -423,6 +436,9 @@ class WordDocumentStream(DOCDirStream):
print '<todo what="value is non-zero and unhandled"/>'
print '</%s>' % i[0]
+ def handleDop(self):
+ docrecord.Dop(self).dump()
+
def handleLcbClx(self):
offset = self.fcClx
size = self.lcbClx
commit 170de485264ecf90cd746433e9bb4f0870c4b6a1
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Thu Nov 22 11:13:59 2012 +0100
dump FibRgCswNew
diff --git a/src/docdirstream.py b/src/docdirstream.py
index 04c1c31..d4d16a4 100755
--- a/src/docdirstream.py
+++ b/src/docdirstream.py
@@ -20,14 +20,17 @@ class DOCDirStream:
self.mainStream = mainStream
self.doc = doc
- def printAndSet(self, key, value, hexdump = True, end = True):
+ def printAndSet(self, key, value, hexdump = True, end = True, offset = False):
setattr(self, key, value)
if hexdump:
value = hex(value)
+ offstr = ""
+ if offset:
+ offstr += ' offset="%s"' % hex(self.pos)
if end:
- print '<%s value="%s"/>' % (key, value)
+ print '<%s value="%s"%s/>' % (key, value, offstr)
else:
- print '<%s value="%s">' % (key, value)
+ print '<%s value="%s"%s>' % (key, value, offstr)
def getuInt8(self, bytes = None, pos = None):
if not bytes:
diff --git a/src/docstream.py b/src/docstream.py
index 66fed15..1b7731c 100755
--- a/src/docstream.py
+++ b/src/docstream.py
@@ -65,15 +65,44 @@ class WordDocumentStream(DOCDirStream):
self.dumpFibRgLw97("fibRgLw")
self.printAndSet("cbRgFcLcb", self.getuInt16())
self.pos += 2
+ pos = self.pos
self.dumpFibRgFcLcb("fibRgFcLcbBlob")
- self.printAndSet("cswNew", self.getuInt16())
+ self.pos = pos + (8 * self.cbRgFcLcb)
+ self.printAndSet("cswNew", self.getuInt16(), offset = True)
self.pos += 2
+ if self.cswNew != 0:
+ self.dumpFibRgCswNew("fibRgCswNew")
print '</fib>'
+ def dumpFibRgCswNew(self, name):
+ print '<%s type="FibRgCswNew" size="%d bytes">' % (name, self.cswNew)
+ self.printAndSet("nFibNew", self.getuInt16())
+ self.pos += 2
+ if self.nFibNew == 0x0112:
+ self.dumpFibRgCswNewData2007("fibRgCswNewData2007")
+ else:
+ print """<todo what="dumpFibRgCswNew() doesn't know how to handle nFibNew = %s">""" % hex(self.nFibNew)
+ print '</%s>' % name
+
+ def __dumpFibRgCswNewData2000(self):
+ self.printAndSet("cQuickSavesNew", self.getuInt16())
+ self.pos += 2
+
+ def dumpFibRgCswNewData2007(self, name):
+ print '<%s type="FibRgCswNewData2007" size="%d bytes">' % (name, 8)
+ self.__dumpFibRgCswNewData2000()
+ self.printAndSet("lidThemeOther", self.getuInt16())
+ self.pos += 2
+ self.printAndSet("lidThemeFE", self.getuInt16())
+ self.pos += 2
+ self.printAndSet("lidThemeCS", self.getuInt16())
+ self.pos += 2
+ print '</%s>' % name
+
def dumpFibBase(self, name):
print '<%s type="FibBase" size="32 bytes">' % name
- self.printAndSet("wIndent", self.getuInt16())
+ self.printAndSet("wIdent", self.getuInt16())
self.pos += 2
self.printAndSet("nFib", self.getuInt16())
@@ -385,7 +414,7 @@ class WordDocumentStream(DOCDirStream):
hasHandler = len(i) > 1
# a member needs handling if it defines the size of a struct and it's non-zero
needsHandling = i[0].startswith("lcb") and value != 0
- self.printAndSet(i[0], self.getuInt32(), end = ((not hasHandler) and (not needsHandling)))
+ self.printAndSet(i[0], self.getuInt32(), end = ((not hasHandler) and (not needsHandling)), offset = True)
self.pos += 4
if hasHandler or needsHandling:
if hasHandler:
commit 321935e6a5f2bc7045f08573aea1882ef15711b5
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Thu Nov 22 10:14:01 2012 +0100
docstream: print a todo for all pointers pointing to a non-zero struct
diff --git a/src/docstream.py b/src/docstream.py
index 94ed4ba..66fed15 100755
--- a/src/docstream.py
+++ b/src/docstream.py
@@ -381,10 +381,17 @@ class WordDocumentStream(DOCDirStream):
["lcbSttbfUssr"],
]
for i in fields:
- self.printAndSet(i[0], self.getuInt32(), end = len(i) == 1)
+ value = self.getuInt32()
+ hasHandler = len(i) > 1
+ # a member needs handling if it defines the size of a struct and it's non-zero
+ needsHandling = i[0].startswith("lcb") and value != 0
+ self.printAndSet(i[0], self.getuInt32(), end = ((not hasHandler) and (not needsHandling)))
self.pos += 4
- if len(i) > 1:
- i[1]()
+ if hasHandler or needsHandling:
+ if hasHandler:
+ i[1]()
+ else:
+ print '<todo what="value is non-zero and unhandled"/>'
print '</%s>' % i[0]
def handleLcbClx(self):
More information about the Libreoffice-commits
mailing list