[Libreoffice-commits] mso-dumper.git: msodumper/docrecord.py

Miklos Vajna vmiklos at collabora.co.uk
Mon May 5 00:51:57 PDT 2014


 msodumper/docrecord.py |   31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

New commits:
commit ace8c2bce95132942b7116a92cf3ac97742ffcae
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon May 5 09:51:34 2014 +0200

    dump TableBordersOperand

diff --git a/msodumper/docrecord.py b/msodumper/docrecord.py
index 61512d7..63d3744 100644
--- a/msodumper/docrecord.py
+++ b/msodumper/docrecord.py
@@ -434,9 +434,11 @@ class COLORREF(DOCDirStream):
 
 class BRC(DOCDirStream):
     """The Brc structure specifies a border."""
-    def __init__(self, parent):
+    def __init__(self, parent, name="brc"):
         DOCDirStream.__init__(self, parent.bytes)
         self.pos = parent.pos
+        self.parent = parent
+        self.name = name
         self.posOrig = self.pos
         self.cv = COLORREF(self)
         self.dptLineWidth = self.readuInt8()
@@ -448,7 +450,7 @@ class BRC(DOCDirStream):
         self.fReserved = (buf & 0xff80) >> 7  # 8..16th bits
 
     def dump(self):
-        print '<brc type="BRC" offset="%d">' % self.posOrig
+        print '<%s type="BRC" offset="%d">' % (self.name, self.posOrig)
         self.cv.dump("cv")
         self.printAndSet("dptLineWidth", self.dptLineWidth)
         self.printAndSet("brcType", self.brcType, dict=BrcType)
@@ -456,7 +458,8 @@ class BRC(DOCDirStream):
         self.printAndSet("fShadow", self.fShadow)
         self.printAndSet("fFrame", self.fFrame)
         self.printAndSet("fReserved", self.fReserved)
-        print '</brc>'
+        print '</%s>' % self.name
+        self.parent.pos = self.pos
 
 
 class PChgTabsDel(DOCDirStream):
@@ -1189,6 +1192,26 @@ class TDefTableOperand(DOCDirStream):
         print '</tDefTableOperand>'
 
 
+class TableBordersOperand(DOCDirStream):
+    """The TableBordersOperand structure specifies a set of borders for a table row."""
+    def __init__(self, parent):
+        DOCDirStream.__init__(self, parent.bytes)
+        self.pos = parent.pos
+
+    def dump(self):
+        print '<tableBordersOperand>'
+        self.printAndSet("cb", self.readuInt8())
+        posOrig = self.pos
+        BRC(self, "brcTop").dump()
+        BRC(self, "brcLeft").dump()
+        BRC(self, "brcBottom").dump()
+        BRC(self, "brcRight").dump()
+        BRC(self, "brcHorizontalInside").dump()
+        BRC(self, "brcVerticalInside").dump()
+        assert self.pos == posOrig + 0x30
+        print '</tableBordersOperand>'
+
+
 class SHDOperand(DOCDirStream):
     """The SDHOperand structure is an operand that is used by several Sprm
     structures to specify the background shading to be applied."""
@@ -1276,6 +1299,8 @@ class Sprm(DOCDirStream):
                 self.ct = TDefTableOperand(self)
             elif self.sprm == 0xca71:
                 self.ct = SHDOperand(self)
+            elif self.sprm == 0xd613:
+                self.ct = TableBordersOperand(self)
             else:
                 print '<todo what="Sprm::__init__() unhandled sprm of size %s: %s"/>' % (self.getOperandSize(), hex(self.sprm))
 


More information about the Libreoffice-commits mailing list