[Libreoffice-commits] mso-dumper.git: 3 commits - doc-dump.py Makefile msodumper/docdirstream.py msodumper/docrecord.py

Miklos Vajna vmiklos at collabora.co.uk
Sun Feb 9 08:30:27 PST 2014


 Makefile                  |    3 
 doc-dump.py               |    2 
 msodumper/docdirstream.py |   47 -
 msodumper/docrecord.py    | 1368 +++++++++++++++++++++++++---------------------
 4 files changed, 790 insertions(+), 630 deletions(-)

New commits:
commit baff7ee3cf79ea695fe5fcec3cd4cbcf68e52d9f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Sun Feb 9 17:27:44 2014 +0100

    docrecord: pep8 fixes

diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..cfb3d8c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,3 @@
+check:
+	cd test/doc && ./test.py
+	pep8 --ignore=E501 doc-dump.py msodumper/doc{dirstream,record}.py
diff --git a/msodumper/docrecord.py b/msodumper/docrecord.py
index 529a7bc..eaac4ff 100644
--- a/msodumper/docrecord.py
+++ b/msodumper/docrecord.py
@@ -11,11 +11,13 @@ from docdirstream import DOCDirStream
 import docsprm
 import msodraw
 
+
 def getWordModel(mainStream):
     model = globals.ModelBase(globals.ModelBase.HostAppType.Word)
     model.delayStream = mainStream
     return model
 
+
 class FcCompressed(DOCDirStream):
     """The FcCompressed structure specifies the location of text in the WordDocument Stream."""
     def __init__(self, bytes, mainStream, offset, size):
@@ -24,7 +26,7 @@ class FcCompressed(DOCDirStream):
         self.size = size
 
         buf = self.readuInt32()
-        self.fc = buf & ((2**32-1) >> 2) # bits 0..29
+        self.fc = buf & ((2 ** 32 - 1) >> 2)  # bits 0..29
         self.fCompressed = self.getBit(buf, 30)
         self.r1 = self.getBit(buf, 31)
 
@@ -35,6 +37,7 @@ class FcCompressed(DOCDirStream):
         self.printAndSet("r1", self.r1)
         print '</fcCompressed>'
 
+
 class Pcd(DOCDirStream):
     """The Pcd structure specifies the location of text in the WordDocument Stream and additional properties for this text."""
     def __init__(self, bytes, mainStream, offset, size):
@@ -46,7 +49,7 @@ class Pcd(DOCDirStream):
         self.fNoParaLast = self.getBit(buf, 0)
         self.fR1 = self.getBit(buf, 1)
         self.fDirty = self.getBit(buf, 2)
-        self.fR2 = buf & (2**13-1)
+        self.fR2 = buf & (2 ** 13 - 1)
         self.fc = FcCompressed(self.bytes, self.mainStream, self.pos, 4)
         self.pos += 4
 
@@ -59,6 +62,7 @@ class Pcd(DOCDirStream):
         self.fc.dump()
         print '</pcd>'
 
+
 class PLC:
     """The PLC structure is an array of character positions followed by an array of data elements."""
     def __init__(self, totalSize, structSize):
@@ -66,7 +70,7 @@ class PLC:
         self.structSize = structSize
 
     def getElements(self):
-        return (self.totalSize - 4) / (4 + self.structSize) # defined by 2.2.2
+        return (self.totalSize - 4) / (4 + self.structSize)  # defined by 2.2.2
 
     def getOffset(self, pos, i):
         return self.getPLCOffset(pos, self.getElements(), self.structSize, i)
@@ -75,6 +79,7 @@ class PLC:
     def getPLCOffset(pos, elements, structSize, i):
         return pos + (4 * (elements + 1)) + (structSize * i)
 
+
 class BKC(DOCDirStream):
     """The BKC structure contains information about how a bookmark interacts with tables."""
     def __init__(self, bkc):
@@ -82,13 +87,14 @@ class BKC(DOCDirStream):
 
     def dump(self):
         print '<bkc type="BKC">'
-        self.printAndSet("itcFirst", self.bkc & 0x007f) # 1..7th bits
+        self.printAndSet("itcFirst", self.bkc & 0x007f)  # 1..7th bits
         self.printAndSet("fPub", self.getBit(self.bkc, 8))
-        self.printAndSet("itcLim", (self.bkc & 0x3f00) >> 8) # 9..14th bits
+        self.printAndSet("itcLim", (self.bkc & 0x3f00) >> 8)  # 9..14th bits
         self.printAndSet("fNative", self.getBit(self.bkc, 15))
         self.printAndSet("fCol", self.getBit(self.bkc, 16))
         print '</bkc>'
 
+
 class FBKF(DOCDirStream):
     """The FBKF structure contains information about a bookmark."""
     def __init__(self, plcfAtnBkf, offset):
@@ -101,11 +107,12 @@ class FBKF(DOCDirStream):
         BKC(self.readuInt16()).dump()
         print '</aFBKF>'
 
+
 class PlcfBkf(DOCDirStream, PLC):
     """A PLCFBKF is a PLC whose data elements are FBKF structures."""
     def __init__(self, mainStream, offset, size):
-        DOCDirStream.__init__(self, mainStream.getTableStream().bytes, mainStream = mainStream)
-        PLC.__init__(self, size, 4) # 4 is defined by 2.8.10
+        DOCDirStream.__init__(self, mainStream.getTableStream().bytes, mainStream=mainStream)
+        PLC.__init__(self, size, 4)  # 4 is defined by 2.8.10
         self.pos = offset
         self.size = size
         self.aCP = []
@@ -116,7 +123,7 @@ class PlcfBkf(DOCDirStream, PLC):
         pos = self.pos
         for i in range(self.getElements()):
             # aCp
-            start = self.getuInt32(pos = pos)
+            start = self.getuInt32(pos=pos)
             self.aCP.append(start)
             print '<aCP index="%d" bookmarkStart="%d">' % (i, start)
             pos += 4
@@ -128,6 +135,7 @@ class PlcfBkf(DOCDirStream, PLC):
             print '</aCP>'
         print '</plcfBkf>'
 
+
 class Fldch(DOCDirStream):
     """The fldch structure determines the type of the field character."""
     def __init__(self, parent):
@@ -138,11 +146,12 @@ class Fldch(DOCDirStream):
     def dump(self):
         print '<fldch type="fldch" offset="%d" size="1 byte">' % self.pos
         buf = self.readuInt8()
-        self.printAndSet("ch", buf & 0x1f) # 1..5th bits
-        self.printAndSet("reserved", (buf & 0xe0) >> 5) # 6..8th bits
+        self.printAndSet("ch", buf & 0x1f)  # 1..5th bits
+        self.printAndSet("reserved", (buf & 0xe0) >> 5)  # 6..8th bits
         print '</fldch>'
         self.parent.pos = self.pos
 
+
 class Fld(DOCDirStream):
     """The Fld structure specifies a field character."""
     def __init__(self, parent, offset):
@@ -153,14 +162,15 @@ class Fld(DOCDirStream):
         print '<fld type="FLD" offset="%d" size="2 bytes">' % self.pos
         self.fldch = Fldch(self)
         self.fldch.dump()
-        self.printAndSet("grffld", self.readuInt8()) # TODO parse flt and grffldEnd
+        self.printAndSet("grffld", self.readuInt8())  # TODO parse flt and grffldEnd
         print '</fld>'
 
+
 class PlcFld(DOCDirStream, PLC):
     """The Plcfld structure specifies the location of fields in the document."""
     def __init__(self, mainStream):
-        DOCDirStream.__init__(self, mainStream.getTableStream().bytes, mainStream = mainStream)
-        PLC.__init__(self, mainStream.lcbPlcfFldMom, 2) # 2 is defined by 2.8.25
+        DOCDirStream.__init__(self, mainStream.getTableStream().bytes, mainStream=mainStream)
+        PLC.__init__(self, mainStream.lcbPlcfFldMom, 2)  # 2 is defined by 2.8.25
         self.pos = mainStream.fcPlcfFldMom
         self.size = mainStream.lcbPlcfFldMom
 
@@ -170,7 +180,7 @@ class PlcFld(DOCDirStream, PLC):
         aFlds = []
         for i in range(self.getElements()):
             # aCp
-            value = self.getuInt32(pos = pos)
+            value = self.getuInt32(pos=pos)
             print '<aCP index="%d" value="%d">' % (i, value)
             pos += 4
 
@@ -188,11 +198,12 @@ class PlcFld(DOCDirStream, PLC):
             print '</aCP>'
         print '</plcFld>'
 
+
 class PlcfBkl(DOCDirStream, PLC):
     """The Plcfbkl structure is a PLC that contains only CPs and no additional data."""
     def __init__(self, mainStream, offset, size, start):
-        DOCDirStream.__init__(self, mainStream.getTableStream().bytes, mainStream = mainStream)
-        PLC.__init__(self, size, 0) # 0 is defined by 2.8.12
+        DOCDirStream.__init__(self, mainStream.getTableStream().bytes, mainStream=mainStream)
+        PLC.__init__(self, size, 0)  # 0 is defined by 2.8.12
         self.pos = offset
         self.size = size
         self.start = start
@@ -202,7 +213,7 @@ class PlcfBkl(DOCDirStream, PLC):
         pos = self.pos
         for i in range(self.getElements()):
             # aCp
-            end = self.getuInt32(pos = pos)
+            end = self.getuInt32(pos=pos)
             print '<aCP index="%d" bookmarkEnd="%d">' % (i, end)
             start = self.start.aCP[self.start.aFBKF[i].ibkl]
             print '<transformed value="%s"/>' % self.quoteAttr(self.mainStream.retrieveCPs(start, end))
@@ -210,11 +221,12 @@ class PlcfBkl(DOCDirStream, PLC):
             print '</aCP>'
         print '</plcfBkl>'
 
+
 class PlcPcd(DOCDirStream, PLC):
     """The PlcPcd structure is a PLC whose data elements are Pcds (8 bytes each)."""
     def __init__(self, bytes, mainStream, offset, size):
         DOCDirStream.__init__(self, bytes, mainStream=mainStream)
-        PLC.__init__(self, size, 8) # 8 is defined by 2.8.35
+        PLC.__init__(self, size, 8)  # 8 is defined by 2.8.35
         self.pos = offset
         self.size = size
         self.aCp = []
@@ -224,8 +236,8 @@ class PlcPcd(DOCDirStream, PLC):
         pos = self.pos
         for i in range(self.getElements()):
             # aCp
-            start = self.getuInt32(pos = pos)
-            end = self.getuInt32(pos = pos + 4)
+            start = self.getuInt32(pos=pos)
+            end = self.getuInt32(pos=pos + 4)
             self.ranges.append((start, end))
             self.aCp.append(start)
             pos += 4
@@ -244,6 +256,7 @@ class PlcPcd(DOCDirStream, PLC):
             print '</aCP>'
         print '</plcPcd>'
 
+
 class Sepx(DOCDirStream):
     """The Sepx structure specifies an array of Prl structures and the size of the array."""
     def __init__(self, sed):
@@ -260,9 +273,11 @@ class Sepx(DOCDirStream):
             pos += prl.getSize()
         print '</sepx>'
 
+
 class Sed(DOCDirStream):
     """The Sed structure specifies the location of the section properties."""
-    size = 12 # defined by 2.8.26
+    size = 12  # defined by 2.8.26
+
     def __init__(self, plcfSed, offset):
         DOCDirStream.__init__(self, plcfSed.bytes)
         self.pos = offset
@@ -278,10 +293,11 @@ class Sed(DOCDirStream):
         self.printAndSet("fcMpr", self.readuInt32())
         print '</aSed>'
 
+
 class PlcfSed(DOCDirStream, PLC):
     """The PlcfSed structure is a PLC structure where the data elements are Sed structures."""
     def __init__(self, mainStream, offset, size):
-        DOCDirStream.__init__(self, mainStream.getTableStream().bytes, mainStream = mainStream)
+        DOCDirStream.__init__(self, mainStream.getTableStream().bytes, mainStream=mainStream)
         PLC.__init__(self, size, Sed.size)
         self.pos = offset
         self.size = size
@@ -291,8 +307,8 @@ class PlcfSed(DOCDirStream, PLC):
         pos = self.pos
         for i in range(self.getElements()):
             # aCp
-            start = self.getuInt32(pos = pos)
-            end = self.getuInt32(pos = pos + 4)
+            start = self.getuInt32(pos=pos)
+            end = self.getuInt32(pos=pos + 4)
             print '<aCP index="%d" start="%d" end="%d">' % (i, start, end)
             pos += 4
 
@@ -304,6 +320,7 @@ class PlcfSed(DOCDirStream, PLC):
             print '</aCP>'
         print '</plcfSed>'
 
+
 class Tcg(DOCDirStream):
     """The Tcg structure specifies command-related customizations."""
     def __init__(self, mainStream, offset, size):
@@ -319,6 +336,7 @@ class Tcg(DOCDirStream):
             print '<todo what="Tcg: chTerminator != 0x40"/>'
         print '</tcg>'
 
+
 class Sty(DOCDirStream):
     """The Sty structure specifies the type of the selection that was made."""
     def __init__(self, parent):
@@ -329,23 +347,24 @@ class Sty(DOCDirStream):
     def dump(self):
         value = self.readuInt16()
         styMap = {
-                0x0000: "styNil",
-                0x0001: "styChar",
-                0x0002: "styWord",
-                0x0003: "stySent",
-                0x0004: "styPara",
-                0x0005: "styLine",
-                0x000C: "styCol",
-                0x000D: "styRow",
-                0x000E: "styColAll",
-                0x000F: "styWholeTable",
-                0x001B: "styPrefix",
-                }
+            0x0000: "styNil",
+            0x0001: "styChar",
+            0x0002: "styWord",
+            0x0003: "stySent",
+            0x0004: "styPara",
+            0x0005: "styLine",
+            0x000C: "styCol",
+            0x000D: "styRow",
+            0x000E: "styColAll",
+            0x000F: "styWholeTable",
+            0x001B: "styPrefix",
+        }
         print '<sty name="%s" value="%s"/>' % (styMap[value], hex(value))
         self.parent.pos = self.pos
 
+
 class Selsf(DOCDirStream):
-    size = 36 # defined by 2.9.241
+    size = 36  # defined by 2.9.241
     """The Selsf structure specifies the last selection that was made to the document."""
     def __init__(self, mainStream):
         DOCDirStream.__init__(self, mainStream.getTableStream().bytes)
@@ -375,7 +394,7 @@ class Selsf(DOCDirStream):
         self.printAndSet("fIns", self.getBit(buf, 15))
 
         buf = self.readuInt8()
-        self.printAndSet("fForward", buf & 0x7f) # 1..7th bits
+        self.printAndSet("fForward", buf & 0x7f)  # 1..7th bits
         self.printAndSet("fPrefixW2007", self.getBit(buf, 7))
 
         self.printAndSet("fInsEnd", self.readuInt8())
@@ -392,6 +411,7 @@ class Selsf(DOCDirStream):
         assert self.pos == self.mainStream.fcWss + Selsf.size
         print '</selsf>'
 
+
 class COLORREF(DOCDirStream):
     """The COLORREF structure specifies a color in terms of its red, green, and blue components."""
     def __init__(self, parent):
@@ -411,6 +431,7 @@ class COLORREF(DOCDirStream):
         self.printAndSet("fAuto", self.fAuto)
         print '</%s>' % name
 
+
 class BRC(DOCDirStream):
     """The Brc structure specifies a border."""
     def __init__(self, parent):
@@ -421,22 +442,23 @@ class BRC(DOCDirStream):
         self.dptLineWidth = self.readuInt8()
         self.brcType = self.readuInt8()
         buf = self.readuInt16()
-        self.dptSpace = buf & 0x1f # 1..5th bits
+        self.dptSpace = buf & 0x1f  # 1..5th bits
         self.fShadow = self.getBit(buf, 5)
         self.fFrame = self.getBit(buf, 6)
-        self.fReserved  = (buf & 0xff80) >> 7 # 8..16th bits
+        self.fReserved = (buf & 0xff80) >> 7  # 8..16th bits
 
     def dump(self):
         print '<brc type="BRC" offset="%d">' % self.posOrig
         self.cv.dump("cv")
         self.printAndSet("dptLineWidth", self.dptLineWidth)
-        self.printAndSet("brcType", self.brcType, dict = BrcType)
+        self.printAndSet("brcType", self.brcType, dict=BrcType)
         self.printAndSet("dptSpace", self.dptSpace)
         self.printAndSet("fShadow", self.fShadow)
         self.printAndSet("fFrame", self.fFrame)
         self.printAndSet("fReserved", self.fReserved)
         print '</brc>'
 
+
 class PChgTabsDel(DOCDirStream):
     """The PChgTabsDel structure specifies the locations at which custom tab stops are ignored."""
     def __init__(self, parent):
@@ -452,6 +474,7 @@ class PChgTabsDel(DOCDirStream):
         print '</pchgTabsDel>'
         self.parent.pos = self.pos
 
+
 class PChgTabsDelClose(DOCDirStream):
     """The PChgTabsDelClose structure specifies the locations at which custom tab stops are ignored."""
     def __init__(self, parent):
@@ -467,6 +490,7 @@ class PChgTabsDelClose(DOCDirStream):
         print '</pchgTabsDelClose>'
         self.parent.pos = self.pos
 
+
 class PChgTabsAdd(DOCDirStream):
     """The PChgTabsAdd structure specifies the locations and properties of custom tab stops."""
     def __init__(self, parent):
@@ -482,6 +506,7 @@ class PChgTabsAdd(DOCDirStream):
         print '</pchgTabsAdd>'
         self.parent.pos = self.pos
 
+
 class PChgTabsPapxOperand(DOCDirStream):
     """The PChgTabsPapxOperand structure is used by sprmPChgTabsPapx to specify custom tab stops to be added or ignored."""
     def __init__(self, parent):
@@ -495,6 +520,7 @@ class PChgTabsPapxOperand(DOCDirStream):
         PChgTabsAdd(self).dump()
         print '</pchgTabsPapxOperand>'
 
+
 class PChgTabsOperand(DOCDirStream):
     """The PChgTabsOperand structure is used by sprmPChgTabs to specify a list
     of custom tab stops to add and another list of custom tab stops to
@@ -512,86 +538,88 @@ class PChgTabsOperand(DOCDirStream):
 
 # The Ico structure specifies an entry in the color palette that is listed in the following table.
 Ico = {
-        0x00: "Red: 0x00, Green: 0x00, Blue: 0x00, fAuto: 0xFF",
-        0x01: "Red: 0x00, Green: 0x00, Blue: 0x00, fAuto: 0x00",
-        0x02: "Red: 0x00, Green: 0x00, Blue: 0xFF, fAuto: 0x00",
-        0x03: "Red: 0x00, Green: 0xFF, Blue: 0xFF, fAuto: 0x00",
-        0x04: "Red: 0x00, Green: 0xFF, Blue: 0x00, fAuto: 0x00",
-        0x05: "Red: 0xFF, Green: 0x00, Blue: 0xFF, fAuto: 0x00",
-        0x06: "Red: 0xFF, Green: 0x00, Blue: 0x00, fAuto: 0x00",
-        0x07: "Red: 0xFF, Green: 0xFF, Blue: 0x00, fAuto: 0x00",
-        0x08: "Red: 0xFF, Green: 0xFF, Blue: 0xFF, fAuto: 0x00",
-        0x09: "Red: 0x00, Green: 0x00, Blue: 0x80, fAuto: 0x00",
-        0x0A: "Red: 0x00, Green: 0x80, Blue: 0x80, fAuto: 0x00",
-        0x0B: "Red: 0x00, Green: 0x80, Blue: 0x00, fAuto: 0x00",
-        0x0C: "Red: 0x80, Green: 0x00, Blue: 0x80, fAuto: 0x00",
-        0x0D: "Red: 0x80, Green: 0x00, Blue: 0x80, fAuto: 0x00",
-        0x0E: "Red: 0x80, Green: 0x80, Blue: 0x00, fAuto: 0x00",
-        0x0F: "Red: 0x80, Green: 0x80, Blue: 0x80, fAuto: 0x00",
-        0x10: "Red: 0xC0, Green: 0xC0, Blue: 0xC0, fAuto: 0x00",
-        }
+    0x00: "Red: 0x00, Green: 0x00, Blue: 0x00, fAuto: 0xFF",
+    0x01: "Red: 0x00, Green: 0x00, Blue: 0x00, fAuto: 0x00",
+    0x02: "Red: 0x00, Green: 0x00, Blue: 0xFF, fAuto: 0x00",
+    0x03: "Red: 0x00, Green: 0xFF, Blue: 0xFF, fAuto: 0x00",
+    0x04: "Red: 0x00, Green: 0xFF, Blue: 0x00, fAuto: 0x00",
+    0x05: "Red: 0xFF, Green: 0x00, Blue: 0xFF, fAuto: 0x00",
+    0x06: "Red: 0xFF, Green: 0x00, Blue: 0x00, fAuto: 0x00",
+    0x07: "Red: 0xFF, Green: 0xFF, Blue: 0x00, fAuto: 0x00",
+    0x08: "Red: 0xFF, Green: 0xFF, Blue: 0xFF, fAuto: 0x00",
+    0x09: "Red: 0x00, Green: 0x00, Blue: 0x80, fAuto: 0x00",
+    0x0A: "Red: 0x00, Green: 0x80, Blue: 0x80, fAuto: 0x00",
+    0x0B: "Red: 0x00, Green: 0x80, Blue: 0x00, fAuto: 0x00",
+    0x0C: "Red: 0x80, Green: 0x00, Blue: 0x80, fAuto: 0x00",
+    0x0D: "Red: 0x80, Green: 0x00, Blue: 0x80, fAuto: 0x00",
+    0x0E: "Red: 0x80, Green: 0x80, Blue: 0x00, fAuto: 0x00",
+    0x0F: "Red: 0x80, Green: 0x80, Blue: 0x80, fAuto: 0x00",
+    0x10: "Red: 0xC0, Green: 0xC0, Blue: 0xC0, fAuto: 0x00",
+}
 
 # The Ipat enumeration is an index to a shading pattern.
 Ipat = {
-        0x0000: "ipatAuto",
-        0x0001: "ipatSolid",
-        0x0002: "ipatPct5",
-        0x0003: "ipatPct10",
-        0x0004: "ipatPct20",
-        0x0005: "ipatPct25",
-        0x0006: "ipatPct30",
-        0x0007: "ipatPct40",
-        0x0008: "ipatPct50",
-        0x0009: "ipatPct60",
-        0x000A: "ipatPct70",
-        0x000B: "ipatPct75",
-        0x000C: "ipatPct80",
-        0x000D: "ipatPct90",
-        0x000E: "ipatDkHorizontal",
-        0x000F: "ipatDkVertical",
-        0x0010: "ipatDkForeDiag",
-        0x0011: "ipatDkBackDiag",
-        0x0012: "ipatDkCross",
-        0x0013: "ipatDkDiagCross",
-        0x0014: "ipatHorizontal",
-        0x0015: "ipatVertical",
-        0x0016: "ipatForeDiag",
-        0x0017: "ipatBackDiag",
-        0x0018: "ipatCross",
-        0x0019: "ipatDiagCross",
-        0x0023: "ipatPctNew2",
-        0x0024: "ipatPctNew7",
-        0x0025: "ipatPctNew12",
-        0x0026: "ipatPctNew15",
-        0x0027: "ipatPctNew17",
-        0x0028: "ipatPctNew22",
-        0x0029: "ipatPctNew27",
-        0x002A: "ipatPctNew32",
-        0x002B: "ipatPctNew35",
-        0x002C: "ipatPctNew37",
-        0x002D: "ipatPctNew42",
-        0x002E: "ipatPctNew45",
-        0x002F: "ipatPctNew47",
-        0x0030: "ipatPctNew52",
-        0x0031: "ipatPctNew55",
-        0x0032: "ipatPctNew57",
-        0x0033: "ipatPctNew62",
-        0x0034: "ipatPctNew65",
-        0x0035: "ipatPctNew67",
-        0x0036: "ipatPctNew72",
-        0x0037: "ipatPctNew77",
-        0x0038: "ipatPctNew82",
-        0x0039: "ipatPctNew85",
-        0x003A: "ipatPctNew87",
-        0x003B: "ipatPctNew92",
-        0x003C: "ipatPctNew95",
-        0x003D: "ipatPctNew97",
-        0xFFFF: "ipatNil"
-        }
+    0x0000: "ipatAuto",
+    0x0001: "ipatSolid",
+    0x0002: "ipatPct5",
+    0x0003: "ipatPct10",
+    0x0004: "ipatPct20",
+    0x0005: "ipatPct25",
+    0x0006: "ipatPct30",
+    0x0007: "ipatPct40",
+    0x0008: "ipatPct50",
+    0x0009: "ipatPct60",
+    0x000A: "ipatPct70",
+    0x000B: "ipatPct75",
+    0x000C: "ipatPct80",
+    0x000D: "ipatPct90",
+    0x000E: "ipatDkHorizontal",
+    0x000F: "ipatDkVertical",
+    0x0010: "ipatDkForeDiag",
+    0x0011: "ipatDkBackDiag",
+    0x0012: "ipatDkCross",
+    0x0013: "ipatDkDiagCross",
+    0x0014: "ipatHorizontal",
+    0x0015: "ipatVertical",
+    0x0016: "ipatForeDiag",
+    0x0017: "ipatBackDiag",
+    0x0018: "ipatCross",
+    0x0019: "ipatDiagCross",
+    0x0023: "ipatPctNew2",
+    0x0024: "ipatPctNew7",
+    0x0025: "ipatPctNew12",
+    0x0026: "ipatPctNew15",
+    0x0027: "ipatPctNew17",
+    0x0028: "ipatPctNew22",
+    0x0029: "ipatPctNew27",
+    0x002A: "ipatPctNew32",
+    0x002B: "ipatPctNew35",
+    0x002C: "ipatPctNew37",
+    0x002D: "ipatPctNew42",
+    0x002E: "ipatPctNew45",
+    0x002F: "ipatPctNew47",
+    0x0030: "ipatPctNew52",
+    0x0031: "ipatPctNew55",
+    0x0032: "ipatPctNew57",
+    0x0033: "ipatPctNew62",
+    0x0034: "ipatPctNew65",
+    0x0035: "ipatPctNew67",
+    0x0036: "ipatPctNew72",
+    0x0037: "ipatPctNew77",
+    0x0038: "ipatPctNew82",
+    0x0039: "ipatPctNew85",
+    0x003A: "ipatPctNew87",
+    0x003B: "ipatPctNew92",
+    0x003C: "ipatPctNew95",
+    0x003D: "ipatPctNew97",
+    0xFFFF: "ipatNil"
+}
+
 
 class Shd80(DOCDirStream):
     """The Shd80 structure specifies the colors and pattern that are used for background shading."""
-    size = 2 # in bytes, see 2.9.245
+    size = 2  # in bytes, see 2.9.245
+
     def __init__(self, parent):
         DOCDirStream.__init__(self, parent.bytes)
         self.pos = parent.pos
@@ -600,12 +628,13 @@ class Shd80(DOCDirStream):
     def dump(self):
         print '<shd80 type="Shd80" offset="%d">' % self.pos
         buf = self.readuInt16()
-        self.printAndSet("icoFore",   buf & 0x001f, dict = Ico) # 1..5th bits
-        self.printAndSet("icoBack",  (buf & 0x03e0) >> 5, dict = Ico) # 6..10th bits
-        self.printAndSet("ipat",     (buf & 0xfc00) >> 10, dict = Ipat) # 11.16th bits
+        self.printAndSet("icoFore", buf & 0x001f, dict=Ico)  # 1..5th bits
+        self.printAndSet("icoBack", (buf & 0x03e0) >> 5, dict=Ico)  # 6..10th bits
+        self.printAndSet("ipat", (buf & 0xfc00) >> 10, dict=Ipat)  # 11.16th bits
         print '</shd80>'
         self.parent.pos = self.pos
 
+
 class DefTableShd80Operand(DOCDirStream):
     """The DefTableSdh800Operand structure is an operand that is used by several Table Sprms to
     specify each style of background shading that is applied to each of the cells in a single row."""
@@ -620,6 +649,7 @@ class DefTableShd80Operand(DOCDirStream):
             Shd80(self).dump()
         print '</defTableShd80Operand>'
 
+
 class CMajorityOperand(DOCDirStream):
     """The CMajorityOperand structure is used by sprmCMajority to specify which
     character properties of the text to reset to match that of the underlying
@@ -642,24 +672,25 @@ class CMajorityOperand(DOCDirStream):
 
 # The PgbApplyTo enumeration is used to specify the pages to which a page border applies.
 PgbApplyTo = {
-        0x0: "pgbAllPages",
-        0x1: "pgbFirstPage",
-        0x2: "pgbAllButFirst"
-        }
+    0x0: "pgbAllPages",
+    0x1: "pgbFirstPage",
+    0x2: "pgbAllButFirst"
+}
 
 # The PgbOffsetFrom enumeration is used to specify the location from which the offset of a page
 # border is measured.
 PgbOffsetFrom = {
-        0x0: "pgbFromText",
-        0x1: "pgbFromEdge"
-        }
+    0x0: "pgbFromText",
+    0x1: "pgbFromEdge"
+}
 
 # The PgbPageDepth enumeration is used to specify the "depth" of a page border in relation to other
 # page elements.
 PgbPageDepth = {
-        0x0: "pgbAtFront",
-        0x1: "pgbAtBack",
-        }
+    0x0: "pgbAtFront",
+    0x1: "pgbAtBack",
+}
+
 
 class SPgbPropOperand(DOCDirStream):
     """The SPgbPropOperand structure is the operand to sprmSPgbProp. It specifies the properties of a
@@ -671,12 +702,13 @@ class SPgbPropOperand(DOCDirStream):
     def dump(self):
         print '<sPgbPropOperand type="SPgbPropOperand" offset="%d">' % self.pos
         buf = self.readuInt8()
-        self.printAndSet("pgbApplyTo",     buf & 0x7,        dict = PgbApplyTo) # 1..3rd bits
-        self.printAndSet("pgbPageDepth",  (buf & 0x18) >> 3, dict = PgbPageDepth) # 4..5th bits
-        self.printAndSet("pgbOffsetFrom", (buf & 0xe0) >> 5, dict = PgbOffsetFrom) # 6..8th bits
+        self.printAndSet("pgbApplyTo", buf & 0x7, dict=PgbApplyTo)  # 1..3rd bits
+        self.printAndSet("pgbPageDepth", (buf & 0x18) >> 3, dict=PgbPageDepth)  # 4..5th bits
+        self.printAndSet("pgbOffsetFrom", (buf & 0xe0) >> 5, dict=PgbOffsetFrom)  # 6..8th bits
         self.printAndSet("reserved", self.readuInt8())
         print '</sPgbPropOperand>'
 
+
 class MFPF(DOCDirStream):
     """The MFPF structure specifies the type of picture data that is stored."""
     def __init__(self, parent):
@@ -686,17 +718,18 @@ class MFPF(DOCDirStream):
 
     def dump(self):
         mmDict = {
-                0x0064: "MM_SHAPE",
-                0x0066: "MM_SHAPEFILE",
-                }
+            0x0064: "MM_SHAPE",
+            0x0066: "MM_SHAPEFILE",
+        }
         print '<mfpf type="MFPF" offset="%d">' % self.pos
-        self.printAndSet("mm", self.readInt16(), dict = mmDict, default = "todo")
+        self.printAndSet("mm", self.readInt16(), dict=mmDict, default="todo")
         self.printAndSet("xExt", self.readuInt16())
         self.printAndSet("yExt", self.readuInt16())
         self.printAndSet("swHMF", self.readuInt16())
         self.parent.pos = self.pos
         print '</mfpf>'
 
+
 class PICF_Shape(DOCDirStream):
     """The PICF_Shape structure specifies additional header information for
     pictures of type MM_SHAPE or MM_SHAPEFILE."""
@@ -717,197 +750,198 @@ class PICF_Shape(DOCDirStream):
 
 # BrcType is an unsigned integer that specifies the type of border.
 BrcType = {
-        0x00: "none",
-        0x01: "single",
-        0x03: "double",
-        0x05: "A thin single solid line.",
-        0x06: "dotted",
-        0x07: "dashed",
-        0x08: "dotDash",
-        0x09: "dotDotDash",
-        0x0A: "triple",
-        0x0B: "thinThickSmallGap",
-        0x0C: "thickThinSmallGap",
-        0x0D: "thinThickThinSmallGap",
-        0x0E: "thinThickMediumGap",
-        0x0F: "thickThinMediumGap",
-        0x10: "thinThickThinMediumGap",
-        0x11: "thinThickLargeGap",
-        0x12: "thickThinLargeGap",
-        0x13: "thinThickThinLargeGap",
-        0x14: "wave",
-        0x15: "doubleWave",
-        0x16: "dashSmallGap",
-        0x17: "dashDotStroked",
-        0x18: "threeDEmboss",
-        0x19: "threeDEngrave",
-        0x1A: "outset",
-        0x1B: "inset",
-        0x40: "apples",
-        0x41: "archedScallops",
-        0x42: "babyPacifier",
-        0x43: "babyRattle",
-        0x44: "balloons3Colors",
-        0x45: "balloonsHotAir",
-        0x46: "basicBlackDashes",
-        0x47: "basicBlackDots",
-        0x48: "basicBlackSquares",
-        0x49: "basicThinLines",
-        0x4A: "basicWhiteDashes",
-        0x4B: "basicWhiteDots",
-        0x4C: "basicWhiteSquares",
-        0x4D: "basicWideInline",
-        0x4E: "basicWideMidline",
-        0x4F: "basicWideOutline",
-        0x50: "bats",
-        0x51: "birds",
-        0x52: "birdsFlight",
-        0x53: "cabins",
-        0x54: "cakeSlice",
-        0x55: "candyCorn",
-        0x56: "celticKnotwork",
-        0x57: "certificateBanner",
-        0x58: "chainLink",
-        0x59: "champagneBottle",
-        0x5A: "checkedBarBlack",
-        0x5B: "checkedBarColor",
-        0x5C: "checkered",
-        0x5D: "christmasTree",
-        0x5E: "circlesLines",
-        0x5F: "circlesRectangles",
-        0x60: "classicalWave",
-        0x61: "clocks",
-        0x62: "compass",
-        0x63: "confetti",
-        0x64: "confettiGrays",
-        0x65: "confettiOutline",
-        0x66: "confettiStreamers",
-        0x67: "confettiWhite",
-        0x68: "cornerTriangles",
-        0x69: "couponCutoutDashes",
-        0x6A: "couponCutoutDots",
-        0x6B: "crazyMaze",
-        0x6C: "creaturesButterfly",
-        0x6D: "creaturesFish",
-        0x6E: "creaturesInsects",
-        0x6F: "creaturesLadyBug",
-        0x70: "crossStitch",
-        0x71: "cup",
-        0x72: "decoArch",
-        0x73: "decoArchColor",
-        0x74: "decoBlocks",
-        0x75: "diamondsGray",
-        0x76: "doubleD",
-        0x77: "doubleDiamonds",
-        0x78: "earth1",
-        0x79: "earth2",
-        0x7A: "eclipsingSquares1",
-        0x7B: "eclipsingSquares2",
-        0x7C: "eggsBlack",
-        0x7D: "fans",
-        0x7E: "film",
-        0x7F: "firecrackers",
-        0x80: "flowersBlockPrint",
-        0x81: "flowersDaisies",
-        0x82: "flowersModern1",
-        0x83: "flowersModern2",
-        0x84: "flowersPansy",
-        0x85: "flowersRedRose",
-        0x86: "flowersRoses",
-        0x87: "flowersTeacup",
-        0x88: "flowersTiny",
-        0x89: "gems",
-        0x8A: "gingerbreadMan",
-        0x8B: "gradient",
-        0x8C: "handmade1",
-        0x8D: "handmade2",
-        0x8E: "heartBalloon",
-        0x8F: "heartGray",
-        0x90: "hearts",
-        0x91: "heebieJeebies",
-        0x92: "holly",
-        0x93: "houseFunky",
-        0x94: "hypnotic",
-        0x95: "iceCreamCones",
-        0x96: "lightBulb",
-        0x97: "lightning1",
-        0x98: "lightning2",
-        0x99: "mapPins",
-        0x9A: "mapleLeaf",
-        0x9B: "mapleMuffins",
-        0x9C: "marquee",
-        0x9D: "marqueeToothed",
-        0x9E: "moons",
-        0x9F: "mosaic",
-        0xA0: "musicNotes",
-        0xA1: "northwest",
-        0xA2: "ovals",
-        0xA3: "packages",
-        0xA4: "palmsBlack",
-        0xA5: "palmsColor",
-        0xA6: "paperClips",
-        0xA7: "papyrus",
-        0xA8: "partyFavor",
-        0xA9: "partyGlass",
-        0xAA: "pencils",
-        0xAB: "people",
-        0xAC: "peopleWaving",
-        0xAD: "peopleHats",
-        0xAE: "poinsettias",
-        0xAF: "postageStamp",
-        0xB0: "pumpkin1",
-        0xB1: "pushPinNote2",
-        0xB2: "pushPinNote1",
-        0xB3: "pyramids",
-        0xB4: "pyramidsAbove",
-        0xB5: "quadrants",
-        0xB6: "rings",
-        0xB7: "safari",
-        0xB8: "sawtooth",
-        0xB9: "sawtoothGray",
-        0xBA: "scaredCat",
-        0xBB: "seattle",
-        0xBC: "shadowedSquares",
-        0xBD: "sharksTeeth",
-        0xBE: "shorebirdTracks",
-        0xBF: "skyrocket",
-        0xC0: "snowflakeFancy",
-        0xC1: "snowflakes",
-        0xC2: "sombrero",
-        0xC3: "southwest",
-        0xC4: "stars",
-        0xC5: "starsTop",
-        0xC6: "stars3d",
-        0xC7: "starsBlack",
-        0xC8: "starsShadowed",
-        0xC9: "sun",
-        0xCA: "swirligig",
-        0xCB: "tornPaper",
-        0xCC: "tornPaperBlack",
-        0xCD: "trees",
-        0xCE: "triangleParty",
-        0xCF: "triangles",
-        0xD0: "tribal1",
-        0xD1: "tribal2",
-        0xD2: "tribal3",
-        0xD3: "tribal4",
-        0xD4: "tribal5",
-        0xD5: "tribal6",
-        0xD6: "twistedLines1",
-        0xD7: "twistedLines2",
-        0xD8: "vine",
-        0xD9: "waveline",
-        0xDA: "weavingAngles",
-        0xDB: "weavingBraid",
-        0xDC: "weavingRibbon",
-        0xDD: "weavingStrips",
-        0xDE: "whiteFlowers",
-        0xDF: "woodwork",
-        0xE0: "xIllusions",
-        0xE1: "zanyTriangles",
-        0xE2: "zigZag",
-        0xE3: "zigZagStitch"
-        }
+    0x00: "none",
+    0x01: "single",
+    0x03: "double",
+    0x05: "A thin single solid line.",
+    0x06: "dotted",
+    0x07: "dashed",
+    0x08: "dotDash",
+    0x09: "dotDotDash",
+    0x0A: "triple",
+    0x0B: "thinThickSmallGap",
+    0x0C: "thickThinSmallGap",
+    0x0D: "thinThickThinSmallGap",
+    0x0E: "thinThickMediumGap",
+    0x0F: "thickThinMediumGap",
+    0x10: "thinThickThinMediumGap",
+    0x11: "thinThickLargeGap",
+    0x12: "thickThinLargeGap",
+    0x13: "thinThickThinLargeGap",
+    0x14: "wave",
+    0x15: "doubleWave",
+    0x16: "dashSmallGap",
+    0x17: "dashDotStroked",
+    0x18: "threeDEmboss",
+    0x19: "threeDEngrave",
+    0x1A: "outset",
+    0x1B: "inset",
+    0x40: "apples",
+    0x41: "archedScallops",
+    0x42: "babyPacifier",
+    0x43: "babyRattle",
+    0x44: "balloons3Colors",
+    0x45: "balloonsHotAir",
+    0x46: "basicBlackDashes",
+    0x47: "basicBlackDots",
+    0x48: "basicBlackSquares",
+    0x49: "basicThinLines",
+    0x4A: "basicWhiteDashes",
+    0x4B: "basicWhiteDots",
+    0x4C: "basicWhiteSquares",
+    0x4D: "basicWideInline",
+    0x4E: "basicWideMidline",
+    0x4F: "basicWideOutline",
+    0x50: "bats",
+    0x51: "birds",
+    0x52: "birdsFlight",
+    0x53: "cabins",
+    0x54: "cakeSlice",
+    0x55: "candyCorn",
+    0x56: "celticKnotwork",
+    0x57: "certificateBanner",
+    0x58: "chainLink",
+    0x59: "champagneBottle",
+    0x5A: "checkedBarBlack",
+    0x5B: "checkedBarColor",
+    0x5C: "checkered",
+    0x5D: "christmasTree",
+    0x5E: "circlesLines",
+    0x5F: "circlesRectangles",
+    0x60: "classicalWave",
+    0x61: "clocks",
+    0x62: "compass",
+    0x63: "confetti",
+    0x64: "confettiGrays",
+    0x65: "confettiOutline",
+    0x66: "confettiStreamers",
+    0x67: "confettiWhite",
+    0x68: "cornerTriangles",
+    0x69: "couponCutoutDashes",
+    0x6A: "couponCutoutDots",
+    0x6B: "crazyMaze",
+    0x6C: "creaturesButterfly",
+    0x6D: "creaturesFish",
+    0x6E: "creaturesInsects",
+    0x6F: "creaturesLadyBug",
+    0x70: "crossStitch",
+    0x71: "cup",
+    0x72: "decoArch",
+    0x73: "decoArchColor",
+    0x74: "decoBlocks",
+    0x75: "diamondsGray",
+    0x76: "doubleD",
+    0x77: "doubleDiamonds",
+    0x78: "earth1",
+    0x79: "earth2",
+    0x7A: "eclipsingSquares1",
+    0x7B: "eclipsingSquares2",
+    0x7C: "eggsBlack",
+    0x7D: "fans",
+    0x7E: "film",
+    0x7F: "firecrackers",
+    0x80: "flowersBlockPrint",
+    0x81: "flowersDaisies",
+    0x82: "flowersModern1",
+    0x83: "flowersModern2",
+    0x84: "flowersPansy",
+    0x85: "flowersRedRose",
+    0x86: "flowersRoses",
+    0x87: "flowersTeacup",
+    0x88: "flowersTiny",
+    0x89: "gems",
+    0x8A: "gingerbreadMan",
+    0x8B: "gradient",
+    0x8C: "handmade1",
+    0x8D: "handmade2",
+    0x8E: "heartBalloon",
+    0x8F: "heartGray",
+    0x90: "hearts",
+    0x91: "heebieJeebies",
+    0x92: "holly",
+    0x93: "houseFunky",
+    0x94: "hypnotic",
+    0x95: "iceCreamCones",
+    0x96: "lightBulb",
+    0x97: "lightning1",
+    0x98: "lightning2",
+    0x99: "mapPins",
+    0x9A: "mapleLeaf",
+    0x9B: "mapleMuffins",
+    0x9C: "marquee",
+    0x9D: "marqueeToothed",
+    0x9E: "moons",
+    0x9F: "mosaic",
+    0xA0: "musicNotes",
+    0xA1: "northwest",
+    0xA2: "ovals",
+    0xA3: "packages",
+    0xA4: "palmsBlack",
+    0xA5: "palmsColor",
+    0xA6: "paperClips",
+    0xA7: "papyrus",
+    0xA8: "partyFavor",
+    0xA9: "partyGlass",
+    0xAA: "pencils",
+    0xAB: "people",
+    0xAC: "peopleWaving",
+    0xAD: "peopleHats",
+    0xAE: "poinsettias",
+    0xAF: "postageStamp",
+    0xB0: "pumpkin1",
+    0xB1: "pushPinNote2",
+    0xB2: "pushPinNote1",
+    0xB3: "pyramids",
+    0xB4: "pyramidsAbove",
+    0xB5: "quadrants",
+    0xB6: "rings",
+    0xB7: "safari",
+    0xB8: "sawtooth",
+    0xB9: "sawtoothGray",
+    0xBA: "scaredCat",
+    0xBB: "seattle",
+    0xBC: "shadowedSquares",
+    0xBD: "sharksTeeth",
+    0xBE: "shorebirdTracks",
+    0xBF: "skyrocket",
+    0xC0: "snowflakeFancy",
+    0xC1: "snowflakes",
+    0xC2: "sombrero",
+    0xC3: "southwest",
+    0xC4: "stars",
+    0xC5: "starsTop",
+    0xC6: "stars3d",
+    0xC7: "starsBlack",
+    0xC8: "starsShadowed",
+    0xC9: "sun",
+    0xCA: "swirligig",
+    0xCB: "tornPaper",
+    0xCC: "tornPaperBlack",
+    0xCD: "trees",
+    0xCE: "triangleParty",
+    0xCF: "triangles",
+    0xD0: "tribal1",
+    0xD1: "tribal2",
+    0xD2: "tribal3",
+    0xD3: "tribal4",
+    0xD4: "tribal5",
+    0xD5: "tribal6",
+    0xD6: "twistedLines1",
+    0xD7: "twistedLines2",
+    0xD8: "vine",
+    0xD9: "waveline",
+    0xDA: "weavingAngles",
+    0xDB: "weavingBraid",
+    0xDC: "weavingRibbon",
+    0xDD: "weavingStrips",
+    0xDE: "whiteFlowers",
+    0xDF: "woodwork",
+    0xE0: "xIllusions",
+    0xE1: "zanyTriangles",
+    0xE2: "zigZag",
+    0xE3: "zigZagStitch"
+}
+
 
 class Brc80(DOCDirStream):
     """The Brc80 structure describes a border."""
@@ -920,16 +954,17 @@ class Brc80(DOCDirStream):
     def dump(self):
         buf = self.readuInt32()
         print '<%s type="Brc80" offset="%d">' % (self.name, self.pos)
-        self.printAndSet("dptLineWidth", buf & 0x000000ff) # 1..8th bits
-        self.printAndSet("brcType", (buf & 0x0000ff00) >> 8, dict = BrcType) # 9..16th bits
-        self.printAndSet("ico", (buf & 0x00ff0000) >> 16, dict = Ico) # 17..24th bits
-        self.printAndSet("dptSpace", (buf & 0x1f000000) >> 24) # 25..29th bits
+        self.printAndSet("dptLineWidth", buf & 0x000000ff)  # 1..8th bits
+        self.printAndSet("brcType", (buf & 0x0000ff00) >> 8, dict=BrcType)  # 9..16th bits
+        self.printAndSet("ico", (buf & 0x00ff0000) >> 16, dict=Ico)  # 17..24th bits
+        self.printAndSet("dptSpace", (buf & 0x1f000000) >> 24)  # 25..29th bits
         self.printAndSet("fShadow", self.getBit(buf, 29))
         self.printAndSet("fFrame", self.getBit(buf, 30))
         self.printAndSet("reserved", self.getBit(buf, 31))
         print '</%s>' % self.name
         self.parent.pos = self.pos
 
+
 class Brc80MayBeNil(DOCDirStream):
     """The Brc80MayBeNil structure is a Brc80 structure. When all bits are set,
     this structure specifies that the region in question has no border."""
@@ -950,6 +985,7 @@ class Brc80MayBeNil(DOCDirStream):
             print '</%s>' % self.name
         self.parent.pos = self.pos
 
+
 class PICMID(DOCDirStream):
     """The PICMID structure specifies the size and border information for a picture."""
     def __init__(self, parent):
@@ -978,6 +1014,7 @@ class PICMID(DOCDirStream):
         self.parent.pos = self.pos
         print '</picmid>'
 
+
 class PICF(DOCDirStream):
     """The PICF structure specifies the type of a picture, as well as the size
     of the picture and information about its border."""
@@ -994,7 +1031,7 @@ class PICF(DOCDirStream):
         assert self.cbHeader == 0x44
         self.mfpf = MFPF(self)
         self.mfpf.dump()
-        if self.mfpf.mm == 0x0064: # MM_SHAPEFILE
+        if self.mfpf.mm == 0x0064:  # MM_SHAPEFILE
             PICF_Shape(self, "innerHeader").dump()
             PICMID(self).dump()
             self.printAndSet("cProps", self.readuInt16())
@@ -1003,6 +1040,7 @@ class PICF(DOCDirStream):
         self.parent.pos = self.pos
         print '</picf>'
 
+
 class PICFAndOfficeArtData(DOCDirStream):
     """The PICFAndOfficeArtData structure specifies header information and
     binary data for a picture."""
@@ -1016,7 +1054,7 @@ class PICFAndOfficeArtData(DOCDirStream):
         print '<PICFAndOfficeArtData>'
         found = False
         for prl in self.parent.parent.parent.prls:
-            if prl.sprm.sprm in (0x0806, 0x080a): # sprmCFData, sprmCFOle2
+            if prl.sprm.sprm in (0x0806, 0x080a):  # sprmCFData, sprmCFOle2
                 found = True
                 break
         if not found:
@@ -1024,9 +1062,9 @@ class PICFAndOfficeArtData(DOCDirStream):
             picf = PICF(self)
             picf.dump()
             assert self.pos == pos + 68
-            if picf.mfpf.mm == 0x0066: # MM_SHAPEFILE
+            if picf.mfpf.mm == 0x0066:  # MM_SHAPEFILE
                 print '<todo what="PICFAndOfficeArtData::dump(): picf.mfpf.mm == MM_SHAPEFILE is unhandled"/>'
-            elif picf.mfpf.mm == 0x0064: # MM_SHAPE
+            elif picf.mfpf.mm == 0x0064:  # MM_SHAPE
                 remaining = picf.lcb - (self.pos - pos)
                 msodraw.InlineSpContainer(self, remaining).dumpXml(self, getWordModel(self.parent.mainStream))
             else:
@@ -1038,37 +1076,38 @@ class PICFAndOfficeArtData(DOCDirStream):
 # The TextFlow enumeration specifies the rotation settings for a block of text and for the individual
 # East Asian characters in each line of the block.
 TextFlow = {
-        0x0000: "grpfTFlrtb",
-        0x0001: "grpfTFtbrl",
-        0x0003: "grpfTFbtlr",
-        0x0004: "grpfTFlrtbv",
-        0x0005: "grpfTFtbrlv"
-        }
+    0x0000: "grpfTFlrtb",
+    0x0001: "grpfTFtbrl",
+    0x0003: "grpfTFbtlr",
+    0x0004: "grpfTFlrtbv",
+    0x0005: "grpfTFtbrlv"
+}
 
 # The VerticalMergeFlag enumeration provides a 2-bit value that specifies whether a table cell is
 # merged with the cells above or below it.
 VerticalMergeFlag = {
-        0x00: "fvmClear",
-        0x01: "fvmMerge",
-        0x03: "fvmRestart"
-        }
+    0x00: "fvmClear",
+    0x01: "fvmMerge",
+    0x03: "fvmRestart"
+}
 
 # The VerticalAlign enumeration specifies the vertical alignment of content within table cells.
 VerticalAlign = {
-        0x00: "vaTop",
-        0x01: "vaCenter",
-        0x02: "vaBottom",
-        }
+    0x00: "vaTop",
+    0x01: "vaCenter",
+    0x02: "vaBottom",
+}
 
 # The Fts enumeration specifies how the preferred width for a table, table indent, table cell, cell
 # margin, or cell spacing is defined.
 Fts = {
-        0x00: "ftsNil",
-        0x01: "ftsAuto",
-        0x02: "ftsPercent",
-        0x03: "ftsDxa",
-        0x13: "ftsDxaSys"
-        }
+    0x00: "ftsNil",
+    0x01: "ftsAuto",
+    0x02: "ftsPercent",
+    0x03: "ftsDxa",
+    0x13: "ftsDxaSys"
+}
+
 
 class TCGRF(DOCDirStream):
     """A TCGRF structure specifies the text layout and cell merge properties for a single cell in a table."""
@@ -1080,11 +1119,11 @@ class TCGRF(DOCDirStream):
     def dump(self):
         print '<tcgrf type="TCGRF" offset="%d">' % self.pos
         buf = self.readuInt16()
-        self.printAndSet("horzMerge", buf & 0x0003) # 1..2nd bits
-        self.printAndSet("textFlow",  (buf & 0x001c) >> 2, dict = TextFlow, default = "todo") # 3..6th bits
-        self.printAndSet("vertMerge", (buf & 0x0060) >> 6, dict = VerticalMergeFlag) # 7..8th bits
-        self.printAndSet("vertAlign", (buf & 0x0180) >> 8, dict = VerticalAlign) # 9..10th bits
-        self.printAndSet("ftsWidth",  (buf & 0x0e00) >> 10, dict = Fts) # 11..12th bits
+        self.printAndSet("horzMerge", buf & 0x0003)  # 1..2nd bits
+        self.printAndSet("textFlow", (buf & 0x001c) >> 2, dict=TextFlow, default="todo")  # 3..6th bits
+        self.printAndSet("vertMerge", (buf & 0x0060) >> 6, dict=VerticalMergeFlag)  # 7..8th bits
+        self.printAndSet("vertAlign", (buf & 0x0180) >> 8, dict=VerticalAlign)  # 9..10th bits
+        self.printAndSet("ftsWidth", (buf & 0x0e00) >> 10, dict=Fts)  # 11..12th bits
         self.printAndSet("fFitText", self.getBit(buf, 12))
         self.printAndSet("fNoWrap", self.getBit(buf, 13))
         self.printAndSet("fHideMark", self.getBit(buf, 14))
@@ -1092,6 +1131,7 @@ class TCGRF(DOCDirStream):
         print '</tcgrf>'
         self.parent.pos = self.pos
 
+
 class TC80(DOCDirStream):
     """The TC80 structure specifies the border and other formatting for a single cell in a table."""
     def __init__(self, parent, index):
@@ -1103,7 +1143,7 @@ class TC80(DOCDirStream):
     def dump(self):
         print '<tc80 index="%d">' % self.index
         TCGRF(self).dump()
-        self.printAndSet("wWidth", self.readuInt16(), hexdump = False)
+        self.printAndSet("wWidth", self.readuInt16(), hexdump=False)
         Brc80MayBeNil(self, "brcTop").dump()
         Brc80MayBeNil(self, "brcLeft").dump()
         Brc80MayBeNil(self, "brcBottom").dump()
@@ -1111,6 +1151,7 @@ class TC80(DOCDirStream):
         print '</tc80>'
         self.parent.pos = self.pos
 
+
 class TDefTableOperand(DOCDirStream):
     """The TDefTableOperand structure is the operand that is used by the
     sprmTDefTable value. It specifies the initial layout of the columns in the
@@ -1132,6 +1173,7 @@ class TDefTableOperand(DOCDirStream):
             i += 1
         print '</tDefTableOperand>'
 
+
 class BrcOperand(DOCDirStream):
     """The BrcOperand structure is the operand to several SPRMs that control borders."""
     def __init__(self, parent):
@@ -1146,30 +1188,31 @@ class BrcOperand(DOCDirStream):
         self.brc.dump()
         print '</brcOperand>'
 
+
 class Sprm(DOCDirStream):
     """The Sprm structure specifies a modification to a property of a character, paragraph, table, or section."""
-    def __init__(self, parent,  mainStream = None, transformed = None):
-        DOCDirStream.__init__(self, parent.bytes, mainStream = mainStream)
+    def __init__(self, parent, mainStream=None, transformed=None):
+        DOCDirStream.__init__(self, parent.bytes, mainStream=mainStream)
         self.parent = parent
         self.pos = parent.pos
         self.operandSizeMap = {
-                0: 1,
-                1: 1,
-                2: 2,
-                3: 4,
-                4: 2,
-                5: 2,
-                7: 3,
-                }
+            0: 1,
+            1: 1,
+            2: 2,
+            3: 4,
+            4: 2,
+            5: 2,
+            7: 3,
+        }
 
         self.sprm = self.readuInt16()
 
-        self.ispmd = (self.sprm & 0x1ff)        # 1-9th bits
-        self.fSpec = (self.sprm & 0x200)  >> 9  # 10th bit
-        self.sgc   = (self.sprm & 0x1c00) >> 10 # 11-13th bits
-        self.spra  = (self.sprm & 0xe000) >> 13 # 14-16th bits
+        self.ispmd = (self.sprm & 0x1ff)  # 1-9th bits
+        self.fSpec = (self.sprm & 0x200) >> 9  # 10th bit
+        self.sgc = (self.sprm & 0x1c00) >> 10  # 11-13th bits
+        self.spra = (self.sprm & 0xe000) >> 13  # 14-16th bits
 
-        self.ct = False # If it's a complex type, it can't be dumped as a simple string.
+        self.ct = False  # If it's a complex type, it can't be dumped as a simple string.
         self.operand = "todo"
         if self.getOperandSize() == 1:
             self.operand = self.getuInt8()
@@ -1187,8 +1230,7 @@ class Sprm(DOCDirStream):
             self.operand = self.getuInt64() & 0x0fffffff
         elif self.getOperandSize() == 9:
             # top, left, bottom and right page / paragraph borders
-            if self.sprm in (0xd234, 0xd235, 0xd236, 0xd237,
-                    0xc64e, 0xc64f, 0xc650, 0xc651):
+            if self.sprm in (0xd234, 0xd235, 0xd236, 0xd237, 0xc64e, 0xc64f, 0xc650, 0xc651):
                 self.ct = BrcOperand(self)
             elif self.sprm == 0xc60d:
                 self.ct = PChgTabsPapxOperand(self)
@@ -1206,19 +1248,19 @@ class Sprm(DOCDirStream):
 
     def dump(self):
         sgcmap = {
-                1: 'paragraph',
-                2: 'character',
-                3: 'picture',
-                4: 'section',
-                5: 'table'
-                }
+            1: 'paragraph',
+            2: 'character',
+            3: 'picture',
+            4: 'section',
+            5: 'table'
+        }
         nameMap = {
-                1: docsprm.parMap,
-                2: docsprm.chrMap,
-                3: docsprm.picMap,
-                4: docsprm.secMap,
-                5: docsprm.tblMap,
-                }
+            1: docsprm.parMap,
+            2: docsprm.chrMap,
+            3: docsprm.picMap,
+            4: docsprm.secMap,
+            5: docsprm.tblMap,
+        }
         attrs = []
         close = False
         attrs.append('value="%s"' % hex(self.sprm))
@@ -1236,14 +1278,14 @@ class Sprm(DOCDirStream):
                 attrs.append('operand=""')
             else:
                 attrs.append('operand="%s"' % hex(self.operand))
-        print '<sprm %s%s>' % (" ".join(attrs), {True:"/", False:""}[close])
+        print '<sprm %s%s>' % (" ".join(attrs), {True: "/", False: ""}[close])
         if self.ct:
             self.ct.dump()
             print '</sprm>'
 
     def getOperandSize(self):
-        if self.spra == 6: # variable
-            if self.sprm not in [0xD608, 0xC615]: # sprmTDefTable, sprmPChgTabs
+        if self.spra == 6:  # variable
+            if self.sprm not in [0xD608, 0xC615]:  # sprmTDefTable, sprmPChgTabs
                 # these structures are prefixed with their size
                 return self.getuInt8() + 1
             elif self.sprm == 0xD608:
@@ -1257,9 +1299,10 @@ class Sprm(DOCDirStream):
             raise Exception("No idea what is the size of SPRM %s" % hex(self.sprm))
         return self.operandSizeMap[self.spra]
 
+
 class Prl(DOCDirStream):
     """The Prl structure is a Sprm that is followed by an operand."""
-    def __init__(self, parent, offset, mainStream = None, transformed = None, index = None):
+    def __init__(self, parent, offset, mainStream=None, transformed=None, index=None):
         DOCDirStream.__init__(self, parent.bytes)
         self.parent = parent
         self.pos = offset
@@ -1270,7 +1313,7 @@ class Prl(DOCDirStream):
 
     def dump(self):
         indexstr = ""
-        if self.index != None:
+        if self.index is not None:
             indexstr = ' index="%d"' % self.index
         print '<prl type="Prl" offset="%d"%s>' % (self.posOrig, indexstr)
         self.sprm.dump()
@@ -1279,6 +1322,7 @@ class Prl(DOCDirStream):
     def getSize(self):
         return 2 + self.sprm.getOperandSize()
 
+
 class GrpPrlAndIstd(DOCDirStream):
     """The GrpPrlAndIstd structure specifies the style and properties that are applied to a paragraph, a table row, or a table cell."""
     def __init__(self, bytes, offset, size):
@@ -1297,10 +1341,11 @@ class GrpPrlAndIstd(DOCDirStream):
             pos += prl.getSize()
         print '</grpPrlAndIstd>'
 
+
 class Chpx(DOCDirStream):
     """The Chpx structure specifies a set of properties for text."""
-    def __init__(self, bytes, mainStream, offset, transformed = None):
-        DOCDirStream.__init__(self, bytes, mainStream = mainStream)
+    def __init__(self, bytes, mainStream, offset, transformed=None):
+        DOCDirStream.__init__(self, bytes, mainStream=mainStream)
         self.pos = offset
         self.transformed = transformed
 
@@ -1321,6 +1366,7 @@ class Chpx(DOCDirStream):
             prl.dump()
         print '</chpx>'
 
+
 class PapxInFkp(DOCDirStream):
     """The PapxInFkp structure specifies a set of text properties."""
     def __init__(self, bytes, mainStream, offset):
@@ -1338,9 +1384,11 @@ class PapxInFkp(DOCDirStream):
         grpPrlAndIstd.dump()
         print '</papxInFkp>'
 
+
 class BxPap(DOCDirStream):
     """The BxPap structure specifies the offset of a PapxInFkp in PapxFkp."""
-    size = 13 # in bytes, see 2.9.23
+    size = 13  # in bytes, see 2.9.23
+
     def __init__(self, bytes, mainStream, offset, parentoffset):
         DOCDirStream.__init__(self, bytes)
         self.pos = offset
@@ -1349,26 +1397,27 @@ class BxPap(DOCDirStream):
     def dump(self):
         print '<bxPap type="BxPap" offset="%d" size="%d bytes">' % (self.pos, self.size)
         self.printAndSet("bOffset", self.readuInt8())
-        papxInFkp = PapxInFkp(self.bytes, self.mainStream, self.parentpos + self.bOffset*2)
+        papxInFkp = PapxInFkp(self.bytes, self.mainStream, self.parentpos + self.bOffset * 2)
         papxInFkp.dump()
         print '</bxPap>'
 
+
 class ChpxFkp(DOCDirStream):
     """The ChpxFkp structure maps text to its character properties."""
     def __init__(self, pnFkpChpx, offset, size):
-        DOCDirStream.__init__(self, pnFkpChpx.mainStream.bytes, mainStream = pnFkpChpx.mainStream)
+        DOCDirStream.__init__(self, pnFkpChpx.mainStream.bytes, mainStream=pnFkpChpx.mainStream)
         self.pos = offset
         self.size = size
         self.pnFkpChpx = pnFkpChpx
 
     def dump(self):
         print '<chpxFkp type="ChpxFkp" offset="%d" size="%d bytes">' % (self.pos, self.size)
-        self.crun = self.getuInt8(pos = self.pos + self.size - 1)
+        self.crun = self.getuInt8(pos=self.pos + self.size - 1)
         pos = self.pos
         for i in range(self.crun):
             # rgfc
-            start = self.getuInt32(pos = pos)
-            end = self.getuInt32(pos = pos + 4)
+            start = self.getuInt32(pos=pos)
+            end = self.getuInt32(pos=pos + 4)
             print '<rgfc index="%d" start="%d" end="%d">' % (i, start, end)
             self.transformed = self.quoteAttr(self.pnFkpChpx.mainStream.retrieveOffset(start, end))
             print '<transformed value="%s"/>' % self.transformed
@@ -1376,7 +1425,7 @@ class ChpxFkp(DOCDirStream):
 
             # rgbx
             offset = PLC.getPLCOffset(self.pos, self.crun, 1, i)
-            chpxOffset = self.getuInt8(pos = offset) * 2
+            chpxOffset = self.getuInt8(pos=offset) * 2
             chpx = Chpx(self.bytes, self.mainStream, self.pos + chpxOffset, self.transformed)
             chpx.dump()
             print '</rgfc>'
@@ -1384,21 +1433,22 @@ class ChpxFkp(DOCDirStream):
         self.printAndSet("crun", self.crun)
         print '</chpxFkp>'
 
+
 class PapxFkp(DOCDirStream):
     """The PapxFkp structure maps paragraphs, table rows, and table cells to their properties."""
     def __init__(self, bytes, mainStream, offset, size):
-        DOCDirStream.__init__(self, mainStream.bytes, mainStream = mainStream)
+        DOCDirStream.__init__(self, mainStream.bytes, mainStream=mainStream)
         self.pos = offset
         self.size = size
 
     def dump(self):
         print '<papxFkp type="PapxFkp" offset="%d" size="%d bytes">' % (self.pos, self.size)
-        self.cpara = self.getuInt8(pos = self.pos + self.size - 1)
+        self.cpara = self.getuInt8(pos=self.pos + self.size - 1)
         pos = self.pos
         for i in range(self.cpara):
             # rgfc
-            start = self.getuInt32(pos = pos)
-            end = self.getuInt32(pos = pos + 4)
+            start = self.getuInt32(pos=pos)
+            end = self.getuInt32(pos=pos + 4)
             print '<rgfc index="%d" start="%d" end="%d">' % (i, start, end)
             print '<transformed value="%s"/>' % self.quoteAttr(self.mainStream.retrieveOffset(start, end))
             pos += 4
@@ -1412,6 +1462,7 @@ class PapxFkp(DOCDirStream):
         self.printAndSet("cpara", self.cpara)
         print '</papxFkp>'
 
+
 class PnFkpChpx(DOCDirStream):
     """The PnFkpChpx structure specifies the location in the WordDocument Stream of a ChpxFkp structure."""
     def __init__(self, plcBteChpx, offset, size, name):
@@ -1424,11 +1475,12 @@ class PnFkpChpx(DOCDirStream):
     def dump(self):
         print '<%s type="PnFkpChpx" offset="%d" size="%d bytes">' % (self.name, self.pos, self.size)
         buf = self.readuInt32()
-        self.printAndSet("pn", buf & (2**22-1))
-        chpxFkp = ChpxFkp(self, self.pn*512, 512)
+        self.printAndSet("pn", buf & (2 ** 22 - 1))
+        chpxFkp = ChpxFkp(self, self.pn * 512, 512)
         chpxFkp.dump()
         print '</%s>' % self.name
 
+
 class LPXCharBuffer9(DOCDirStream):
     """The LPXCharBuffer9 structure is a length-prefixed buffer for up to 9 Unicode characters."""
     def __init__(self, parent, name):
@@ -1439,9 +1491,10 @@ class LPXCharBuffer9(DOCDirStream):
     def dump(self):
         print '<%s type="LPXCharBuffer9" offset="%d" size="20 bytes">' % (self.name, self.pos)
         self.printAndSet("cch", self.readuInt16())
-        self.printAndSet("xcharArray", self.bytes[self.pos:self.pos+(self.cch*2)].decode('utf-16'), hexdump = False)
+        self.printAndSet("xcharArray", self.bytes[self.pos:self.pos + (self.cch * 2)].decode('utf-16'), hexdump=False)
         print '</%s>' % self.name
 
+
 class ATRDPre10(DOCDirStream):
     """The ATRDPre10 structure contains information about a comment in the document."""
     def __init__(self, aPlcfandRef, offset):
@@ -1459,6 +1512,7 @@ class ATRDPre10(DOCDirStream):
         self.printAndSet("ITagBkmk", self.readInt32())
         print '</aATRDPre10>'
 
+
 class PnFkpPapx(DOCDirStream):
     """The PnFkpPapx structure specifies the offset of a PapxFkp in the WordDocument Stream."""
     def __init__(self, bytes, mainStream, offset, size, name):
@@ -1470,11 +1524,12 @@ class PnFkpPapx(DOCDirStream):
     def dump(self):
         print '<%s type="PnFkpPapx" offset="%d" size="%d bytes">' % (self.name, self.pos, self.size)
         buf = self.readuInt32()
-        self.printAndSet("pn", buf & (2**22-1))
-        papxFkp = PapxFkp(self.bytes, self.mainStream, self.pn*512, 512)
+        self.printAndSet("pn", buf & (2 ** 22 - 1))
+        papxFkp = PapxFkp(self.bytes, self.mainStream, self.pn * 512, 512)
         papxFkp.dump()
         print '</%s>' % self.name
 
+
 class PlcBteChpx(DOCDirStream, PLC):
     """The PlcBteChpx structure is a PLC that maps the offsets of text in the WordDocument stream to the character properties of that text."""
     def __init__(self, mainStream):
@@ -1488,8 +1543,8 @@ class PlcBteChpx(DOCDirStream, PLC):
         pos = self.pos
         for i in range(self.getElements()):
             # aFC
-            start = self.getuInt32(pos = pos)
-            end = self.getuInt32(pos = pos + 4)
+            start = self.getuInt32(pos=pos)
+            end = self.getuInt32(pos=pos + 4)
             print '<aFC index="%d" start="%d" end="%d">' % (i, start, end)
             pos += 4
 
@@ -1499,6 +1554,7 @@ class PlcBteChpx(DOCDirStream, PLC):
             print '</aFC>'
         print '</plcBteChpx>'
 
+
 class PlcfHdd(DOCDirStream, PLC):
     """The Plcfhdd structure is a PLC that contains only CPs and no additional data. It specifies where
     header document stories begin and end."""
@@ -1511,23 +1567,23 @@ class PlcfHdd(DOCDirStream, PLC):
     def getContents(self, i):
         if i <= 5:
             contentsMap = {
-                    0: "Footnote separator",
-                    1: "Footnote continuation separator",
-                    2: "Footnote continuation notice",
-                    3: "Endnote separator",
-                    4: "Endnote continuation separator",
-                    5: "Endnote continuation notice",
-                    }
+                0: "Footnote separator",
+                1: "Footnote continuation separator",
+                2: "Footnote continuation notice",
+                3: "Endnote separator",
+                4: "Endnote continuation separator",
+                5: "Endnote continuation notice",
+            }
             return contentsMap[i]
         else:
             contentsMap = {
-                    0: "Even page header",
-                    1: "Odd page header",
-                    2: "Even page footer",
-                    3: "Odd page footer",
-                    4: "First page header",
-                    5: "First page footer",
-                    }
+                0: "Even page header",
+                1: "Odd page header",
+                2: "Even page footer",
+                3: "Odd page footer",
+                4: "First page header",
+                5: "First page footer",
+            }
             sectionIndex = i / 6
             contentsIndex = i % 6
             return "%s (section #%s)" % (contentsMap[contentsIndex], sectionIndex)
@@ -1537,14 +1593,15 @@ class PlcfHdd(DOCDirStream, PLC):
         offset = self.mainStream.getHeaderOffset()
         pos = self.pos
         for i in range(self.getElements() - 1):
-            start = self.getuInt32(pos = pos)
-            end = self.getuInt32(pos = pos + 4)
+            start = self.getuInt32(pos=pos)
+            end = self.getuInt32(pos=pos + 4)
             print '<aCP index="%d" contents="%s" start="%d" end="%d">' % (i, self.getContents(i), start, end)
             print '<transformed value="%s"/>' % self.quoteAttr(self.mainStream.retrieveCPs(offset + start, offset + end))
             pos += 4
             print '</aCP>'
         print '</plcfHdd>'
 
+
 class PlcfandTxt(DOCDirStream, PLC):
     """The PlcfandTxt structure is a PLC that contains only CPs and no additional data."""
     def __init__(self, mainStream, offset, size):
@@ -1558,14 +1615,15 @@ class PlcfandTxt(DOCDirStream, PLC):
         offset = self.mainStream.getCommentOffset()
         pos = self.pos
         for i in range(self.getElements() - 1):
-            start = self.getuInt32(pos = pos)
-            end = self.getuInt32(pos = pos + 4)
+            start = self.getuInt32(pos=pos)
+            end = self.getuInt32(pos=pos + 4)
             print '<aCP index="%d" start="%d" end="%d">' % (i, start, end)
             print '<transformed value="%s"/>' % self.quoteAttr(self.mainStream.retrieveCPs(offset + start, offset + end))
             pos += 4
             print '</aCP>'
         print '</plcfandTxt>'
 
+
 class PlcfandRef(DOCDirStream, PLC):
     """The PlcfandRef structure is a PLC whose data elements are ATRDPre10 structures."""
     def __init__(self, mainStream, offset, size):
@@ -1578,7 +1636,7 @@ class PlcfandRef(DOCDirStream, PLC):
         print '<plcfandRef type="PlcfandRef" offset="%d" size="%d bytes">' % (self.pos, self.size)
         pos = self.pos
         for i in range(self.getElements()):
-            start = self.getuInt32(pos = pos)
+            start = self.getuInt32(pos=pos)
             print '<aCP index="%d" commentEnd="%d">' % (i, start)
             print '<transformed value="%s"/>' % self.quoteAttr(self.mainStream.retrieveCP(start))
             pos += 4
@@ -1589,6 +1647,7 @@ class PlcfandRef(DOCDirStream, PLC):
             print '</aCP>'
         print '</plcfandRef>'
 
+
 class PlcBtePapx(DOCDirStream, PLC):
     """The PlcBtePapx structure is a PLC that specifies paragraph, table row, or table cell properties."""
     def __init__(self, bytes, mainStream, offset, size):
@@ -1602,8 +1661,8 @@ class PlcBtePapx(DOCDirStream, PLC):
         pos = self.pos
         for i in range(self.getElements()):
             # aFC
-            start = self.getuInt32(pos = pos)
-            end = self.getuInt32(pos = pos + 4)
+            start = self.getuInt32(pos=pos)
+            end = self.getuInt32(pos=pos + 4)
             print '<aFC index="%d" start="%d" end="%d">' % (i, start, end)
             pos += 4
 
@@ -1613,6 +1672,7 @@ class PlcBtePapx(DOCDirStream, PLC):
             print '</aFC>'
         print '</plcBtePapx>'
 
+
 class Pcdt(DOCDirStream):
     """The Pcdt structure contains a PlcPcd structure and specifies its size."""
     def __init__(self, bytes, mainStream, offset, size):
@@ -1631,6 +1691,7 @@ class Pcdt(DOCDirStream):
         self.plcPcd.dump()
         print '</pcdt>'
 
+
 class PrcData(DOCDirStream):
     """The PrcData structure specifies an array of Prl elements and the size of
     the array."""
@@ -1657,6 +1718,7 @@ class PrcData(DOCDirStream):
         print '</grpPrl>'
         print '</prcData>'
 
+
 class Prc(DOCDirStream):
     """The Prc structure specifies a set of properties for document content
     that is referenced by a Pcd structure."""
@@ -1673,6 +1735,7 @@ class Prc(DOCDirStream):
         self.prcData.dump()
         print '</prc>'
 
+
 class Clx(DOCDirStream):
     def __init__(self, bytes, mainStream, offset, size):
         DOCDirStream.__init__(self, bytes, mainStream=mainStream)
@@ -1695,6 +1758,7 @@ class Clx(DOCDirStream):
         self.pcdt.dump()
         print '</clx>'
 
+
 class Copts60(DOCDirStream):
     """The Copts60 structure specifies compatibility options."""
     def __init__(self, dop):
@@ -1726,6 +1790,7 @@ class Copts60(DOCDirStream):
         self.printAndSet("fDntBlnSbDbWid", self.getBit(buf, 7))
         print '</copts60>'
 
+
 class DTTM(DOCDirStream):
     """The DTTM structure specifies date and time."""
     def __init__(self, parent, name):
@@ -1737,16 +1802,17 @@ class DTTM(DOCDirStream):
     def dump(self):
         buf = self.readuInt32()
         print '<%s type="DTTM" offset="%d" size="4 bytes">' % (self.name, self.pos)
-        self.printAndSet("mint", buf & 0x0000003f) # 1..6th bits
-        self.printAndSet("hr",  (buf & 0x000007c0) >> 6) # 7..11th bits
-        self.printAndSet("dom", (buf & 0x0000f800) >> 11) # 12..16th bits
-        self.printAndSet("mon", (buf & 0x000f0000) >> 16) # 17..20th bits
-        self.printAndSet("yr",  (buf & 0x1ff00000) >> 20) # 21..29th bits
-        self.printAndSet("wdy", (buf & 0xe0000000) >> 29) # 30..32th bits
-        print '<transformed value="%s-%s-%s %s:%s"/>' % (1900+self.yr, self.mon, self.dom, self.hr, self.mint)
+        self.printAndSet("mint", buf & 0x0000003f)  # 1..6th bits
+        self.printAndSet("hr", (buf & 0x000007c0) >> 6)  # 7..11th bits
+        self.printAndSet("dom", (buf & 0x0000f800) >> 11)  # 12..16th bits
+        self.printAndSet("mon", (buf & 0x000f0000) >> 16)  # 17..20th bits
+        self.printAndSet("yr", (buf & 0x1ff00000) >> 20)  # 21..29th bits
+        self.printAndSet("wdy", (buf & 0xe0000000) >> 29)  # 30..32th bits
+        print '<transformed value="%s-%s-%s %s:%s"/>' % (1900 + self.yr, self.mon, self.dom, self.hr, self.mint)
         print '</%s>' % self.name
         self.parent.pos = self.pos
 
+
 class GRFSTD(DOCDirStream):
     """The GRFSTD structure specifies the general properties of a style."""
     def __init__(self, parent):
@@ -1772,13 +1838,15 @@ class GRFSTD(DOCDirStream):
         self.printAndSet("fInternalUse", self.getBit(buf, 2))
         self.printAndSet("fUnhideWhenUsed", self.getBit(buf, 3))
         self.printAndSet("fQFormat", self.getBit(buf, 4))
-        self.printAndSet("fReserved", (buf & 0xe0) >> 5) # 6..8th bits
+        self.printAndSet("fReserved", (buf & 0xe0) >> 5)  # 6..8th bits
         print '</grfstd>'
         self.parent.pos = self.pos
 
+
 class DopBase(DOCDirStream):
     """The DopBase structure contains document and compatibility settings."""
     size = 84
+
     def __init__(self, dop):
         DOCDirStream.__init__(self, dop.bytes)
         self.pos = dop.pos
@@ -1790,15 +1858,15 @@ class DopBase(DOCDirStream):
         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("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.readuInt8())
 
         buf = self.readuInt16()
-        self.printAndSet("rncFtn", buf & 0x03) # 1..2nd bits
-        self.printAndSet("nFtn", (buf & 0xfffc) >> 2) # 3..16th bits
+        self.printAndSet("rncFtn", buf & 0x03)  # 1..2nd bits
+        self.printAndSet("nFtn", (buf & 0xfffc) >> 2)  # 3..16th bits
 
         buf = self.readuInt8()
         self.printAndSet("unused5", self.getBit(buf, 0))
@@ -1860,13 +1928,13 @@ class DopBase(DOCDirStream):
         self.printAndSet("cParas", self.readInt32())
 
         buf = self.readuInt16()
-        self.printAndSet("rncEdn", buf & 0x0003) # 1..2nd bits
-        self.printAndSet("nEdn", (buf & 0xfffc) >> 2) # 3..16th bits
+        self.printAndSet("rncEdn", buf & 0x0003)  # 1..2nd bits
+        self.printAndSet("nEdn", (buf & 0xfffc) >> 2)  # 3..16th bits
 
         buf = self.readuInt16()
-        self.printAndSet("epc", buf & 0x0003) # 1..2nd bits
-        self.printAndSet("unused14", (buf & 0x003c) >> 2) # 3..6th bits
-        self.printAndSet("unused15", (buf & 0x03c0) >> 6) # 7..10th bits
+        self.printAndSet("epc", buf & 0x0003)  # 1..2nd bits
+        self.printAndSet("unused14", (buf & 0x003c) >> 2)  # 3..6th bits
+        self.printAndSet("unused15", (buf & 0x03c0) >> 6)  # 7..10th bits
         self.printAndSet("fPrintFormData", self.getBit(buf, 10))
         self.printAndSet("fSaveFormData", self.getBit(buf, 11))
         self.printAndSet("fShadeFormData", self.getBit(buf, 12))
@@ -1883,15 +1951,16 @@ class DopBase(DOCDirStream):
         self.printAndSet("lKeyProtDoc", self.readInt32())
 
         buf = self.readuInt16()
-        self.printAndSet("wvkoSaved", buf & 0x0007) # 1..3rd bits
-        self.printAndSet("pctWwdSaved", (buf & 0x0ff8) >> 3) # 4..12th bits
-        self.printAndSet("zkSaved", (buf & 0x3000) >> 12) # 13..14th bits
+        self.printAndSet("wvkoSaved", buf & 0x0007)  # 1..3rd bits
+        self.printAndSet("pctWwdSaved", (buf & 0x0ff8) >> 3)  # 4..12th bits
+        self.printAndSet("zkSaved", (buf & 0x3000) >> 12)  # 13..14th bits
         self.printAndSet("unused16", self.getBit(buf, 14))
         self.printAndSet("iGutterPos", self.getBit(buf, 15))
         print '</dopBase>'
         assert self.pos == self.dop.pos + DopBase.size
         self.dop.pos = self.pos
 
+
 class Copts80(DOCDirStream):
     """The Copts80 structure specifies compatibility options."""
     def __init__(self, dop):
@@ -1924,9 +1993,11 @@ class Copts80(DOCDirStream):
         self.printAndSet("fPrintMet", self.getBit(buf, 7))
         print '</copts80>'
 
+
 class Copts(DOCDirStream):
     """A structure that specifies compatibility options."""
     size = 32
+
     def __init__(self, dop):
         DOCDirStream.__init__(self, dop.bytes)
         self.pos = dop.pos
@@ -1979,7 +2050,7 @@ class Copts(DOCDirStream):
 
         buf = self.readuInt32()
         self.printAndSet("fCachedColBalance", self.getBit(buf, 0))
-        self.printAndSet("empty1", (buf & 0xfffffffe) >> 1) # 2..32th bits
+        self.printAndSet("empty1", (buf & 0xfffffffe) >> 1)  # 2..32th bits
         self.printAndSet("empty2", self.readuInt32())
         self.printAndSet("empty3", self.readuInt32())
         self.printAndSet("empty4", self.readuInt32())
@@ -1989,9 +2060,11 @@ class Copts(DOCDirStream):
         assert self.pos == self.dop.pos + Copts.size
         self.dop.pos = self.pos
 
+
 class Dop95(DOCDirStream):
     """The Dop95 structure contains document and compatibility settings."""
     size = 88
+
     def __init__(self, dop, dopSize):
         DOCDirStream.__init__(self, dop.bytes)
         self.pos = dop.pos
@@ -2013,9 +2086,11 @@ class Dop95(DOCDirStream):
         assert self.pos == self.dop.pos + Dop95.size
         self.dop.pos = self.pos
 
+
 class DopTypography(DOCDirStream):
     """The DopTypography structure contains East Asian language typography settings."""
     size = 310
+
     def __init__(self, dop):
         DOCDirStream.__init__(self, dop.bytes)
         self.pos = dop.pos
@@ -2025,30 +2100,32 @@ class DopTypography(DOCDirStream):
         print '<dopTypography type="DopTypography" offset="%d" size="310 bytes">' % self.pos
         buf = self.readuInt16()
         self.printAndSet("fKerningPunct", self.getBit(buf, 0))
-        self.printAndSet("iJustification", (buf & 0x0006) >> 1) # 2..3rd bits
-        self.printAndSet("iLevelOfKinsoku", (buf & 0x0018) >> 1) # 4..5th bits
+        self.printAndSet("iJustification", (buf & 0x0006) >> 1)  # 2..3rd bits
+        self.printAndSet("iLevelOfKinsoku", (buf & 0x0018) >> 1)  # 4..5th bits
         self.printAndSet("f2on1", self.getBit(buf, 5))
         self.printAndSet("unused", self.getBit(buf, 6))
-        self.printAndSet("iCustomKsu", (buf & 0x0380) >> 7) # 8..10th bits
+        self.printAndSet("iCustomKsu", (buf & 0x0380) >> 7)  # 8..10th bits
         self.printAndSet("fJapaneseUseLevel2", self.getBit(buf, 10))
-        self.printAndSet("reserved", (buf & 0xf800) >> 11) # 12..16th bits
+        self.printAndSet("reserved", (buf & 0xf800) >> 11)  # 12..16th bits
 
         self.printAndSet("cchFollowingPunct", self.readInt16())
         self.printAndSet("cchLeadingPunct", self.readInt16())
 
-        self.printAndSet("rgxchFPunct", self.getString(self.cchFollowingPunct), hexdump = False)
+        self.printAndSet("rgxchFPunct", self.getString(self.cchFollowingPunct), hexdump=False)
         self.pos += 202
 
-        self.printAndSet("rgxchLPunct", self.getString(self.cchLeadingPunct), hexdump = False)
+        self.printAndSet("rgxchLPunct", self.getString(self.cchLeadingPunct), hexdump=False)
         self.pos += 102
 
         print '</dopTypography>'
         assert self.pos == self.dop.pos + DopTypography.size
         self.dop.pos = self.pos
 
+
 class Dogrid(DOCDirStream):
     """The Dogrid structure specifies parameters for the drawn object properties of the document."""
     size = 10
+
     def __init__(self, dop):
         DOCDirStream.__init__(self, dop.bytes)
         self.pos = dop.pos
@@ -2062,16 +2139,17 @@ class Dogrid(DOCDirStream):
         self.printAndSet("dyaGrid", self.readuInt16())
 
         buf = self.readuInt8()
-        self.printAndSet("dyGridDisplay", (buf & 0x7f)) # 1..7th bits
+        self.printAndSet("dyGridDisplay", (buf & 0x7f))  # 1..7th bits
         self.printAndSet("unused", self.getBit(buf, 7))
 
         buf = self.readuInt8()
-        self.printAndSet("dxGridDisplay", (buf & 0x7f)) # 1..7th bits
+        self.printAndSet("dxGridDisplay", (buf & 0x7f))  # 1..7th bits
         self.printAndSet("fFollowMargins", self.getBit(buf, 7))
         print '</dogrid>'
         assert self.pos == self.dop.pos + Dogrid.size
         self.dop.pos = self.pos
 
+
 class Asumyi(DOCDirStream):
     """The Asumyi structure specifies AutoSummary state information"""
     def __init__(self, dop):
@@ -2083,18 +2161,20 @@ class Asumyi(DOCDirStream):
         buf = self.readuInt16()
         self.printAndSet("fValid", self.getBit(buf, 0))
         self.printAndSet("fView", self.getBit(buf, 1))
-        self.printAndSet("iViewBy", (buf & 0x0c) >> 2) # 3..4th bits
+        self.printAndSet("iViewBy", (buf & 0x0c) >> 2)  # 3..4th bits
         self.printAndSet("fUpdateProps", self.getBit(buf, 4))
-        self.printAndSet("reserved", (buf & 0xffe0) >> 5) # 6..16th bits
+        self.printAndSet("reserved", (buf & 0xffe0) >> 5)  # 6..16th bits
 
         self.printAndSet("wDlgLevel", self.readuInt16())
         self.printAndSet("lHighestLevel", self.readuInt32())
         self.printAndSet("lCurrentLevel", self.readuInt32())
         print '</asumyi>'
 
+
 class Dop97(DOCDirStream):
     """The Dop97 structure contains document and compatibility settings."""
     size = 500
+
     def __init__(self, dop, dopSize):
         DOCDirStream.__init__(self, dop.bytes)
         self.pos = dop.pos
@@ -2119,7 +2199,7 @@ class Dop97(DOCDirStream):
 
         buf = self.readuInt8()
         self.printAndSet("unused1", self.getBit(buf, 0))
-        self.printAndSet("lvlDop", (buf & 0x1e) >> 1) # 2..5th bits
+        self.printAndSet("lvlDop", (buf & 0x1e) >> 1)  # 2..5th bits
         self.printAndSet("fGramAllDone", self.getBit(buf, 5))
         self.printAndSet("fGramAllClean", self.getBit(buf, 6))
         self.printAndSet("fSubsetFonts", self.getBit(buf, 7))
@@ -2169,9 +2249,11 @@ class Dop97(DOCDirStream):
         assert self.pos == self.dop.pos + Dop97.size
         self.dop.pos = self.pos
 
+
 class Dop2000(DOCDirStream):
     """The Dop2000 structure contains document and compatibility settings."""
     size = 544
+
     def __init__(self, dop, dopSize):
         DOCDirStream.__init__(self, dop.bytes)
         self.pos = dop.pos
@@ -2198,19 +2280,19 @@ class Dop2000(DOCDirStream):
         self.printAndSet("fEnvelopeVis", self.getBit(buf, 1))
         self.printAndSet("fMaybeTentativeListInDoc", self.getBit(buf, 2))
         self.printAndSet("fMaybeFitText", self.getBit(buf, 3))
-        self.printAndSet("empty1", (buf & 0xf0) >> 4) # 5..8th bits
+        self.printAndSet("empty1", (buf & 0xf0) >> 4)  # 5..8th bits
 
         buf = self.readuInt8()
         self.printAndSet("fFCCAllDone", self.getBit(buf, 0))
         self.printAndSet("fRelyOnCSS_WebOpt", self.getBit(buf, 1))
         self.printAndSet("fRelyOnVML_WebOpt", self.getBit(buf, 2))
         self.printAndSet("fAllowPNG_WebOpt", self.getBit(buf, 3))
-        self.printAndSet("screenSize_WebOpt", (buf & 0xf0) >> 4) # 5..8th bits
+        self.printAndSet("screenSize_WebOpt", (buf & 0xf0) >> 4)  # 5..8th bits
 
         buf = self.readuInt16()
         self.printAndSet("fOrganizeInFolder_WebOpt", self.getBit(buf, 0))
         self.printAndSet("fUseLongFileNames_WebOpt", self.getBit(buf, 1))
-        self.printAndSet("iPixelsPerInch_WebOpt", (buf & 0x0ffc) >> 2) # 3..12th bits
+        self.printAndSet("iPixelsPerInch_WebOpt", (buf & 0x0ffc) >> 2)  # 3..12th bits
         self.printAndSet("fWebOptionsInit", self.getBit(buf, 12))
         self.printAndSet("fMaybeFEL", self.getBit(buf, 12))
         self.printAndSet("fCharLineUnits", self.getBit(buf, 12))
@@ -2243,9 +2325,11 @@ class Dop2000(DOCDirStream):
         assert self.pos == self.dop.pos + Dop2000.size
         self.dop.pos = self.pos
 
+
 class Dop2002(DOCDirStream):
     """The Dop2002 structure contains document and compatibility settings."""
     size = 594
+
     def __init__(self, dop, dopSize):
         DOCDirStream.__init__(self, dop.bytes)
         self.pos = dop.pos
@@ -2270,7 +2354,7 @@ class Dop2002(DOCDirStream):
         self.printAndSet("fReverseFolio", self.getBit(buf, 7))
 
         buf = self.readuInt8()
-        self.printAndSet("iTextLineEnding", (buf & 0x7)) # 1..3rd bits
+        self.printAndSet("iTextLineEnding", (buf & 0x7))  # 1..3rd bits
         self.printAndSet("fHideFcc", self.getBit(buf, 3))
         self.printAndSet("fAcetateShowMarkup", self.getBit(buf, 4))
         self.printAndSet("fAcetateShowAtn", self.getBit(buf, 5))
@@ -2294,9 +2378,11 @@ class Dop2002(DOCDirStream):
         assert self.pos == self.dop.pos + Dop2002.size
         self.dop.pos = self.pos
 
+
 class Dop2003(DOCDirStream):
     """The Dop2003 structure contains document and compatibility settings."""
     size = 616
+
     def __init__(self, dop, dopSize):
         DOCDirStream.__init__(self, dop.bytes)
         self.pos = dop.pos
@@ -2324,7 +2410,7 @@ class Dop2003(DOCDirStream):
         self.printAndSet("fWord97Doc", self.getBit(buf, 2))
         self.printAndSet("fStyleLockTheme", self.getBit(buf, 3))
         self.printAndSet("fStyleLockQFSet", self.getBit(buf, 4))
-        self.printAndSet("empty1", (buf & 0xe0) >> 5) # 6..8th bits
+        self.printAndSet("empty1", (buf & 0xe0) >> 5)  # 6..8th bits
         self.printAndSet("empty1_", self.readuInt16())
 
         buf = self.readuInt8()
@@ -2332,7 +2418,7 @@ class Dop2003(DOCDirStream):
         self.printAndSet("fAcetateShowInkAtn", self.getBit(buf, 1))
         self.printAndSet("fFilterDttm", self.getBit(buf, 2))
         self.printAndSet("fEnforceDocProt", self.getBit(buf, 3))
-        self.printAndSet("iDocProtCur", (buf & 0x70) >> 4) # 5..7th bits
+        self.printAndSet("iDocProtCur", (buf & 0x70) >> 4)  # 5..7th bits
         self.printAndSet("fDispBkSpSaved", self.getBit(buf, 7))
 
         self.printAndSet("empty2", self.readuInt8())
@@ -2346,6 +2432,7 @@ class Dop2003(DOCDirStream):
         assert self.pos == self.dop.pos + Dop2003.size
         self.dop.pos = self.pos
 
+
 class DopMth(DOCDirStream):
     """The DopMth structure specifies document-wide math settings."""
     def __init__(self, dop):
@@ -2355,16 +2442,16 @@ class DopMth(DOCDirStream):
     def dump(self):
         print '<dopMth type="DopMth" offset="%d" size="34 bytes">' % self.pos
         buf = self.readuInt32()
-        self.printAndSet("mthbrk", (buf & 0x03)) # 1..2nd bits
-        self.printAndSet("mthbrkSub", (buf & 0xc) >> 2) # 3..4th bits
-        self.printAndSet("mthbpjc", (buf & 0x70) >> 4) # 5..7th bits
+        self.printAndSet("mthbrk", (buf & 0x03))  # 1..2nd bits
+        self.printAndSet("mthbrkSub", (buf & 0xc) >> 2)  # 3..4th bits
+        self.printAndSet("mthbpjc", (buf & 0x70) >> 4)  # 5..7th bits
         self.printAndSet("reserved1", self.getBit(buf, 7))
         self.printAndSet("fMathSmallFrac", self.getBit(buf, 8))
         self.printAndSet("fMathIntLimUndOvr", self.getBit(buf, 9))
         self.printAndSet("fMathNaryLimUndOvr", self.getBit(buf, 10))
         self.printAndSet("fMathWrapAlignLeft", self.getBit(buf, 11))
         self.printAndSet("fMathUseDispDefaults", self.getBit(buf, 12))
-        self.printAndSet("reserved2", (buf & 0xffffe000) >> 13) # 14..32th bits
+        self.printAndSet("reserved2", (buf & 0xffffe000) >> 13)  # 14..32th bits
 
         self.printAndSet("ftcMath", self.readuInt16())
         self.printAndSet("dxaLeftMargin", self.readuInt32())
@@ -2376,6 +2463,7 @@ class DopMth(DOCDirStream):
         self.printAndSet("dxaIndentWrapped", self.readuInt32())
         print '</dopMth>'
 
+
 class Dop2007(DOCDirStream):
     """The Dop2007 structure contains document and compatibility settings."""
     def __init__(self, dop, dopSize):
@@ -2397,10 +2485,10 @@ class Dop2007(DOCDirStream):
         self.printAndSet("reserved2", self.getBit(buf, 2))
         self.printAndSet("empty1", self.getBit(buf, 3))
         self.printAndSet("empty2", self.getBit(buf, 4))
-        self.printAndSet("ssm", (buf & 0x01e0) >> 5) # 6..9th bits
+        self.printAndSet("ssm", (buf & 0x01e0) >> 5)  # 6..9th bits
         self.printAndSet("fReadingModeInkLockDownActualPage", self.getBit(buf, 9))
         self.printAndSet("fAutoCompressPictures", self.getBit(buf, 10))
-        self.printAndSet("reserved3", (buf & 0xf800) >> 11) # 12..16th bits
+        self.printAndSet("reserved3", (buf & 0xf800) >> 11)  # 12..16th bits
         self.printAndSet("reserved3_", self.readuInt16())
 
         self.printAndSet("empty3", self.readuInt32())
@@ -2411,6 +2499,7 @@ class Dop2007(DOCDirStream):
         self.pos += 34
         print '</dop2007>'
 
+
 class RC4EncryptionHeader(DOCDirStream):
     """The encryption header structure used for RC4 encryption."""
     def __init__(self, fib, pos, size):
@@ -2430,6 +2519,7 @@ class RC4EncryptionHeader(DOCDirStream):
         print '</RC4EncryptionHeader>'
         assert self.pos == self.size
 
+
 class Dop(DOCDirStream):
     """The Dop structure contains the document and compatibility settings for the document."""
     def __init__(self, fib):
@@ -2452,6 +2542,7 @@ class Dop(DOCDirStream):
             print """<todo what="Dop.dump() doesn't know how to handle nFibNew = %s"/>""" % hex(self.fib.nFibNew)
         print '</dop>'
 
+
 class FFID(DOCDirStream):
     """The FFID structure specifies the font family and character pitch for a font."""
     def __init__(self, bytes, offset):
@@ -2461,14 +2552,15 @@ class FFID(DOCDirStream):
     def dump(self):
         self.ffid = self.readuInt8()
 
-        self.prq =       (self.ffid & 0x3)       # first two bits
+        self.prq = (self.ffid & 0x3)  # first two bits
         self.fTrueType = (self.ffid & 0x4) >> 2  # 3rd bit
-        self.unused1 =   (self.ffid & 0x8) >> 3  # 4th bit
-        self.ff =        (self.ffid & 0x70) >> 4 # 5-7th bits
-        self.unused2 =   (self.ffid & 0x80) >> 7 # 8th bit
+        self.unused1 = (self.ffid & 0x8) >> 3  # 4th bit
+        self.ff = (self.ffid & 0x70) >> 4  # 5-7th bits
+        self.unused2 = (self.ffid & 0x80) >> 7  # 8th bit
 
         print '<ffid value="%s" prq="%s" fTrueType="%s" ff="%s"/>' % (hex(self.ffid), hex(self.prq), self.fTrueType, hex(self.ff))
 
+
 class PANOSE(DOCDirStream):
     """The PANOSE structure defines the PANOSE font classification values for a TrueType font."""
     def __init__(self, bytes, offset):
@@ -2481,6 +2573,7 @@ class PANOSE(DOCDirStream):
             self.printAndSet(i, self.readuInt8())
         print '</panose>'
 
+
 class FontSignature(DOCDirStream):
     """Contains information identifying the code pages and Unicode subranges for which a given font provides glyphs."""
     def __init__(self, bytes, offset):
@@ -2495,8 +2588,9 @@ class FontSignature(DOCDirStream):
         fsCsb1 = self.readuInt32()
         fsCsb2 = self.readInt32()
         print '<fontSignature fsUsb1="%s" fsUsb2="%s" fsUsb3="%s" fsUsb4="%s" fsCsb1="%s" fsCsb2="%s"/>' % (
-                hex(fsUsb1), hex(fsUsb2), hex(fsUsb3), hex(fsUsb4), hex(fsCsb1), hex(fsCsb2)
-                )
+            hex(fsUsb1), hex(fsUsb2), hex(fsUsb3), hex(fsUsb4), hex(fsCsb1), hex(fsCsb2)
+        )
+
 
 class FFN(DOCDirStream):
     """The FFN structure specifies information about a font that is used in the document."""
@@ -2509,8 +2603,8 @@ class FFN(DOCDirStream):
         print '<ffn type="FFN" offset="%d" size="%d bytes">' % (self.pos, self.size)
         FFID(self.bytes, self.pos).dump()
         self.pos += 1
-        self.printAndSet("wWeight", self.readInt16(), hexdump = False)
-        self.printAndSet("chs", self.readuInt8(), hexdump = False)
+        self.printAndSet("wWeight", self.readInt16(), hexdump=False)
+        self.printAndSet("chs", self.readuInt8(), hexdump=False)
         self.printAndSet("ixchSzAlt", self.readuInt8())
         PANOSE(self.bytes, self.pos).dump()
         self.pos += 10
@@ -2519,6 +2613,7 @@ class FFN(DOCDirStream):
         print '<xszFfn value="%s"/>' % self.readString()
         print '</ffn>'
 
+
 class SttbfFfn(DOCDirStream):
     """The SttbfFfn structure is an STTB whose strings are FFN records that specify details of system fonts."""
     def __init__(self, bytes, mainStream, offset, size):
@@ -2538,6 +2633,7 @@ class SttbfFfn(DOCDirStream):
             print '</cchData>'
         print '</sttbfFfn>'
 
+
 class GrpXstAtnOwners(DOCDirStream):
     """This array contains the names of authors of comments in the document."""
     def __init__(self, mainStream):
@@ -2555,6 +2651,7 @@ class GrpXstAtnOwners(DOCDirStream):
             self.pos = xst.pos
         print '</grpXstAtnOwners>'
 
+
 class SttbfAssoc(DOCDirStream):
     """The SttbfAssoc structure is an STTB that contains strings which are associated with this document."""
     def __init__(self, mainStream):
@@ -2565,25 +2662,25 @@ class SttbfAssoc(DOCDirStream):
 
     def dump(self):
         indexMap = {
-                0x00: "Unused. MUST be ignored.",
-                0x01: "The path of the associated document template (2), if it is not the default Normal template.",
-                0x02: "The title of the document.",
-                0x03: "The subject of the document.",
-                0x04: "Key words associated with the document.",
-                0x05: "Unused. This index MUST be ignored.",
-                0x06: "The author of the document.",
-                0x07: "The user who last revised the document.",
-                0x08: "The path of the associated mail merge data source.",
-                0x09: "The path of the associated mail merge header document.",
-                0x0A: "Unused. This index MUST be ignored.",
-                0x0B: "Unused. This index MUST be ignored.",
-                0x0C: "Unused. This index MUST be ignored.",
-                0x0D: "Unused. This index MUST be ignored.",
-                0x0E: "Unused. This index MUST be ignored.",
-                0x0F: "Unused. This index MUST be ignored.",
-                0x10: "Unused. This index MUST be ignored.",
-                0x11: "The write-reservation password of the document.",
-                }
+            0x00: "Unused. MUST be ignored.",
+            0x01: "The path of the associated document template (2), if it is not the default Normal template.",
+            0x02: "The title of the document.",
+            0x03: "The subject of the document.",
+            0x04: "Key words associated with the document.",
+            0x05: "Unused. This index MUST be ignored.",
+            0x06: "The author of the document.",
+            0x07: "The user who last revised the document.",
+            0x08: "The path of the associated mail merge data source.",
+            0x09: "The path of the associated mail merge header document.",
+            0x0A: "Unused. This index MUST be ignored.",
+            0x0B: "Unused. This index MUST be ignored.",
+            0x0C: "Unused. This index MUST be ignored.",
+            0x0D: "Unused. This index MUST be ignored.",
+            0x0E: "Unused. This index MUST be ignored.",
+            0x0F: "Unused. This index MUST be ignored.",
+            0x10: "Unused. This index MUST be ignored.",
+            0x11: "The write-reservation password of the document.",
+        }
         print '<sttbfAssoc type="SttbfAssoc" offset="%d" size="%d bytes">' % (self.pos, self.size)
         self.printAndSet("fExtend", self.readuInt16())
         self.printAndSet("cData", self.readuInt16())
@@ -2599,14 +2696,15 @@ class SttbfAssoc(DOCDirStream):
                 print '<info what="SttbfAssoc::dump() wanted to read beyond the end of the stream"/>'
                 break
             print '<cchData index="%s" meaning="%s" offset="%d" size="%d bytes">' % (hex(i), meaning, self.pos, cchData)
-            print '<string value="%s"/>' % globals.encodeName(self.bytes[self.pos:self.pos+2*cchData].decode('utf-16'), lowOnly = True)
-            self.pos += 2*cchData
+            print '<string value="%s"/>' % globals.encodeName(self.bytes[self.pos:self.pos + 2 * cchData].decode('utf-16'), lowOnly=True)
+            self.pos += 2 * cchData
             print '</cchData>'
         # Probably this was cleared manually.
         if self.cData != 0:
             assert self.pos == self.mainStream.fcSttbfAssoc + self.size
         print '</sttbfAssoc>'
 
+
 class SttbfRMark(DOCDirStream):
     """The SttbfRMark structure is an STTB structure where the strings specify the names of the authors of the revision marks, comments, and e-mail messages in the document."""
     def __init__(self, mainStream):
@@ -2623,13 +2721,14 @@ class SttbfRMark(DOCDirStream):
         for i in range(self.cData):
             cchData = self.readuInt16()
             print '<cchData index="%s" offset="%d" size="%d bytes">' % (i, self.pos, cchData)
-            print '<string value="%s"/>' % globals.encodeName(self.bytes[self.pos:self.pos+2*cchData].decode('utf-16'), lowOnly = True)
-            self.pos += 2*cchData
+            print '<string value="%s"/>' % globals.encodeName(self.bytes[self.pos:self.pos + 2 * cchData].decode('utf-16'), lowOnly=True)
+            self.pos += 2 * cchData
             print '</cchData>'
         if self.cData != 0:
             assert self.pos == self.mainStream.fcSttbfRMark + self.size
         print '</sttbfRMark>'
 
+
 class OfficeArtWordDrawing(DOCDirStream):
     """The OfficeArtWordDrawing structure specifies information about the drawings in the document."""
     def __init__(self, officeArtContent):
@@ -2644,6 +2743,7 @@ class OfficeArtWordDrawing(DOCDirStream):
         print '</officeArtWordDrawing>'
         self.officeArtContent.pos = self.pos
 
+
 class OfficeArtContent(DOCDirStream):
     """The OfficeArtContent structure specifies information about a drawing in the document."""
     def __init__(self, mainStream):
@@ -2665,9 +2765,11 @@ class OfficeArtContent(DOCDirStream):
         assert self.pos == self.mainStream.fcDggInfo + self.size
         print '</officeArtContent>'
 
+
 class ATNBE(DOCDirStream):
     """The ATNBE structure contains information about an annotation bookmark in the document."""
-    size = 10 # in bytes, see 2.9.4
+    size = 10  # in bytes, see 2.9.4
+
     def __init__(self, sttbfAtnBkmk):
         DOCDirStream.__init__(self, sttbfAtnBkmk.bytes)
         self.pos = sttbfAtnBkmk.pos
@@ -2679,6 +2781,7 @@ class ATNBE(DOCDirStream):
         self.printAndSet("ITagOld", self.readuInt32())
         print '</atnbe>'
 
+
 class SttbfAtnBkmk(DOCDirStream):
     """The SttbfAtnBkmk structure is an STTB whose strings are all of zero length."""
     def __init__(self, mainStream, offset, size):
@@ -2701,6 +2804,7 @@ class SttbfAtnBkmk(DOCDirStream):
             print '</extraData>'
         print '</sttbfAtnBkmk>'
 
+
 class Stshif(DOCDirStream):
     """The Stshif structure specifies general stylesheet information."""
     def __init__(self, bytes, mainStream, offset):
@@ -2713,8 +2817,8 @@ class Stshif(DOCDirStream):
         self.printAndSet("cstd", self.readuInt16())
         self.printAndSet("cbSTDBaseInFile", self.readuInt16())
         buf = self.readuInt16()
-        self.printAndSet("fStdStylenamesWritten", buf & 1) # first bit
-        self.printAndSet("fReserved", (buf & 0xfe) >> 1) # 2..16th bits
+        self.printAndSet("fStdStylenamesWritten", buf & 1)  # first bit
+        self.printAndSet("fReserved", (buf & 0xfe) >> 1)  # 2..16th bits
         self.printAndSet("stiMaxWhenSaved", self.readuInt16())
         self.printAndSet("istdMaxFixedWhenSaved", self.readuInt16())
         self.printAndSet("nVerBuiltInNamesWhenSaved", self.readuInt16())
@@ -2723,6 +2827,7 @@ class Stshif(DOCDirStream):
         self.printAndSet("ftcOther", self.readuInt16())
         print '</stshif>'
 
+
 class LSD(DOCDirStream):
     """The LSD structure specifies the properties to be used for latent application-defined styles (see StshiLsd) when they are created."""
     def __init__(self, bytes, offset):
@@ -2735,9 +2840,10 @@ class LSD(DOCDirStream):
         self.printAndSet("fSemiHidden", self.getBit(buf, 2))
         self.printAndSet("fUnhideWhenUsed", self.getBit(buf, 3))
         self.printAndSet("fQFormat", self.getBit(buf, 4))
-        self.printAndSet("iPriority", (buf & 0xfff0) >> 4) # 5-16th bits
+        self.printAndSet("iPriority", (buf & 0xfff0) >> 4)  # 5-16th bits
         self.printAndSet("fReserved", self.readuInt16())
 
+
 class StshiLsd(DOCDirStream):
     """The StshiLsd structure specifies latent style data for application-defined styles."""
     def __init__(self, bytes, stshi, offset):
@@ -2755,6 +2861,7 @@ class StshiLsd(DOCDirStream):
             self.pos += self.cbLSD
         print '</stshiLsd>'
 
+
 class STSHI(DOCDirStream):
     """The STSHI structure specifies general stylesheet and related information."""
     def __init__(self, bytes, mainStream, offset, size):
@@ -2775,6 +2882,7 @@ class STSHI(DOCDirStream):
                 stshiLsd.dump()
         print '</stshi>'
 
+
 class LPStshi(DOCDirStream):
     """The LPStshi structure specifies general stylesheet information."""
     def __init__(self, bytes, mainStream, offset):
@@ -2783,12 +2891,13 @@ class LPStshi(DOCDirStream):
 
     def dump(self):
         print '<lpstshi type="LPStshi" offset="%d">' % self.pos
-        self.printAndSet("cbStshi", self.readuInt16(), hexdump = False)
+        self.printAndSet("cbStshi", self.readuInt16(), hexdump=False)
         self.stshi = STSHI(self.bytes, self.mainStream, self.pos, self.cbStshi)
         self.stshi.dump()
         self.pos += self.cbStshi
         print '</lpstshi>'
 
+
 class StdfBase(DOCDirStream):
     """The Stdf structure specifies general information about the style."""
     def __init__(self, bytes, mainStream, offset):
@@ -2799,52 +2908,54 @@ class StdfBase(DOCDirStream):
     def dump(self):
         print '<stdfBase type="StdfBase" offset="%d" size="%d bytes">' % (self.pos, self.size)
         buf = self.readuInt16()
-        self.printAndSet("sti", buf & 0x0fff) # 1..12th bits
+        self.printAndSet("sti", buf & 0x0fff)  # 1..12th bits
         self.printAndSet("fScratch", self.getBit(buf, 13))
         self.printAndSet("fInvalHeight", self.getBit(buf, 14))
         self.printAndSet("fHasUpe", self.getBit(buf, 15))
         self.printAndSet("fMassCopy", self.getBit(buf, 16))
         buf = self.readuInt16()
-        self.stk = buf & 0x000f # 1..4th bits
+        self.stk = buf & 0x000f  # 1..4th bits
         stkmap = {
-                1: "paragraph",
-                2: "character",
-                3: "table",
-                4: "numbering"
-                }
+            1: "paragraph",
+            2: "character",
+            3: "table",
+            4: "numbering"
+        }
         print '<stk value="%d" name="%s"/>' % (self.stk, stkmap[self.stk])
-        self.printAndSet("istdBase", (buf & 0xfff0) >> 4) # 5..16th bits
+        self.printAndSet("istdBase", (buf & 0xfff0) >> 4)  # 5..16th bits
         buf = self.readuInt16()
-        self.printAndSet("cupx", buf & 0x000f) # 1..4th bits
-        self.printAndSet("istdNext", (buf & 0xfff0) >> 4) # 5..16th bits
-        self.printAndSet("bchUpe", self.readuInt16(), hexdump = False)
+        self.printAndSet("cupx", buf & 0x000f)  # 1..4th bits
+        self.printAndSet("istdNext", (buf & 0xfff0) >> 4)  # 5..16th bits
+        self.printAndSet("bchUpe", self.readuInt16(), hexdump=False)
         GRFSTD(self).dump()
         print '</stdfBase>'
 
+
 class StdfPost2000(DOCDirStream):
     """The StdfPost2000 structure specifies general information about a style."""
     def __init__(self, stdf):
-        DOCDirStream.__init__(self, stdf.bytes, mainStream = stdf.mainStream)
+        DOCDirStream.__init__(self, stdf.bytes, mainStream=stdf.mainStream)
         self.pos = stdf.pos
         self.size = 8
 
     def dump(self):
         print '<stdfPost2000 type="StdfPost2000" offset="%d" size="%d bytes">' % (self.pos, self.size)
         buf = self.readuInt16()
-        self.printAndSet("istdLink", buf & 0xfff) # 1..12th bits
-        self.printAndSet("fHasOriginalStyle", self.getBit(buf, 13)) # 13th bit
-        self.printAndSet("fSpare", (buf & 0xe000) >> 13) # 14..16th bits
+        self.printAndSet("istdLink", buf & 0xfff)  # 1..12th bits
+        self.printAndSet("fHasOriginalStyle", self.getBit(buf, 13))  # 13th bit
+        self.printAndSet("fSpare", (buf & 0xe000) >> 13)  # 14..16th bits
         self.printAndSet("rsid", self.readuInt32())
         buf = self.readuInt16()
-        self.printAndSet("iftcHtml", buf & 0x7) # 1..3rd bits
+        self.printAndSet("iftcHtml", buf & 0x7)  # 1..3rd bits
         self.printAndSet("unused", self.getBit(buf, 4))
-        self.printAndSet("iPriority", (buf & 0xfff0) >> 4) # 5..16th bits
+        self.printAndSet("iPriority", (buf & 0xfff0) >> 4)  # 5..16th bits
         print '</stdfPost2000>'
 
+
 class Stdf(DOCDirStream):
     """The Stdf structure specifies general information about the style."""
     def __init__(self, std):
-        DOCDirStream.__init__(self, std.bytes, mainStream = std.mainStream)
+        DOCDirStream.__init__(self, std.bytes, mainStream=std.mainStream)
         self.std = std
         self.pos = std.pos
 
@@ -2854,7 +2965,7 @@ class Stdf(DOCDirStream):
         self.stdfBase.dump()
         self.pos += self.stdfBase.size
         if self.pos - self.std.pos < self.std.size:
-            stsh = self.std.lpstd.stsh # root of the stylesheet table
+            stsh = self.std.lpstd.stsh  # root of the stylesheet table
             cbSTDBaseInFile = stsh.lpstshi.stshi.stshif.cbSTDBaseInFile
             print '<stdfPost2000OrNone cbSTDBaseInFile="%s">' % hex(cbSTDBaseInFile)
             if cbSTDBaseInFile == 0x0012:
@@ -2864,6 +2975,7 @@ class Stdf(DOCDirStream):
             print '</stdfPost2000OrNone>'
         print '</stdf>'
 
+
 class Xst(DOCDirStream):
     """The Xst structure is a string. The string is prepended by its length and is not null-terminated."""
     def __init__(self, parent):
@@ -2873,10 +2985,11 @@ class Xst(DOCDirStream):
     def dump(self):
         print '<xst type="Xst" offset="%d">' % self.pos
         self.printAndSet("cch", self.readuInt16())

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list