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

Miklos Vajna vmiklos at kemper.freedesktop.org
Sat Aug 17 13:26:30 PDT 2013


 src/docrecord.py |   70 +++++++++++++++++++++++++++++++++----------------------
 1 file changed, 42 insertions(+), 28 deletions(-)

New commits:
commit 31e6f11e6bcf071035a78568f6a3624a5bade5cc
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Sat Aug 17 22:25:27 2013 +0200

    sprmCPicLocation: don't try to handle NilPICFAndBinData as PICFAndOfficeArtData
    
    The spec says that if sprmCFData is present, then the position is a
    NilPICFAndBinData.

diff --git a/src/docrecord.py b/src/docrecord.py
index bae6c73..e424e65 100644
--- a/src/docrecord.py
+++ b/src/docrecord.py
@@ -1007,14 +1007,21 @@ class PICFAndOfficeArtData(DOCDirStream):
 
     def dump(self):
         print '<PICFAndOfficeArtData>'
-        pos = self.pos
-        picf = PICF(self)
-        picf.dump()
-        assert self.pos == pos + 68
-        if picf.mfpf.mm == 0x0066:
-            print '<todo what="PICFAndOfficeArtData::dump(): picf.mfpf.mm == MM_SHAPEFILE is unhandled"/>'
-        remaining = picf.lcb - (self.pos - pos)
-        msodraw.InlineSpContainer(self, remaining).dumpXml(self, getWordModel(self.parent.mainStream))
+        found = False
+        for prl in self.parent.parent.parent.prls:
+            if prl.sprm.sprm == 0x0806: # sprmCFData
+                found = True
+        if not found:
+            pos = self.pos
+            picf = PICF(self)
+            picf.dump()
+            assert self.pos == pos + 68
+            if picf.mfpf.mm == 0x0066:
+                print '<todo what="PICFAndOfficeArtData::dump(): picf.mfpf.mm == MM_SHAPEFILE is unhandled"/>'
+            remaining = picf.lcb - (self.pos - pos)
+            msodraw.InlineSpContainer(self, remaining).dumpXml(self, getWordModel(self.parent.mainStream))
+        else:
+            print '<todo what="PICFAndOfficeArtData::dump(): handle sprmCFData"/>'
         print '</PICFAndOfficeArtData>'
 
 # The TextFlow enumeration specifies the rotation settings for a block of text and for the individual
@@ -1130,9 +1137,10 @@ class BrcOperand(DOCDirStream):
 
 class Sprm(DOCDirStream):
     """The Sprm structure specifies a modification to a property of a character, paragraph, table, or section."""
-    def __init__(self, bytes, offset, mainStream = None, transformed = None):
-        DOCDirStream.__init__(self, bytes, mainStream = mainStream)
-        self.pos = offset
+    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,
@@ -1245,7 +1253,7 @@ class Prl(DOCDirStream):
         self.parent = parent
         self.pos = offset
         self.posOrig = self.pos
-        self.sprm = Sprm(self.bytes, self.pos, mainStream, transformed)
+        self.sprm = Sprm(self, mainStream, transformed)
         self.pos += 2
         self.index = index
 
commit 904807016f444db2d5686ddec27060b34f1d97cf
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Sat Aug 17 22:17:18 2013 +0200

    let a Prl access its parent

diff --git a/src/docrecord.py b/src/docrecord.py
index 41353d5..bae6c73 100644
--- a/src/docrecord.py
+++ b/src/docrecord.py
@@ -253,7 +253,7 @@ class Sepx(DOCDirStream):
         self.printAndSet("cb", self.readInt16())
         pos = self.pos
         while (self.cb - (pos - self.pos)) > 0:
-            prl = Prl(self.bytes, pos)
+            prl = Prl(self, pos)
             prl.dump()
             pos += prl.getSize()
         print '</sepx>'
@@ -631,7 +631,7 @@ class CMajorityOperand(DOCDirStream):
         pos = 0
         print '<grpprl offset="%d" size="%d bytes">' % (self.pos, self.cb)
         while self.cb - pos > 0:
-            prl = Prl(self.bytes, self.pos + pos)
+            prl = Prl(self, self.pos + pos)
             prl.dump()
             pos += prl.getSize()
         print '</grpprl>'
@@ -1240,8 +1240,9 @@ class Sprm(DOCDirStream):
 
 class Prl(DOCDirStream):
     """The Prl structure is a Sprm that is followed by an operand."""
-    def __init__(self, bytes, offset, mainStream = None, transformed = None, index = None):
-        DOCDirStream.__init__(self, bytes)
+    def __init__(self, parent, offset, mainStream = None, transformed = None, index = None):
+        DOCDirStream.__init__(self, parent.bytes)
+        self.parent = parent
         self.pos = offset
         self.posOrig = self.pos
         self.sprm = Sprm(self.bytes, self.pos, mainStream, transformed)
@@ -1272,7 +1273,7 @@ class GrpPrlAndIstd(DOCDirStream):
         self.printAndSet("istd", self.getuInt16())
         pos += 2
         while (self.size - (pos - self.pos)) > 0:
-            prl = Prl(self.bytes, pos)
+            prl = Prl(self, pos)
             prl.dump()
             pos += prl.getSize()
         print '</grpPrlAndIstd>'
@@ -1289,7 +1290,7 @@ class Chpx(DOCDirStream):
         index = 0
         self.prls = []
         while (self.cb - (pos - self.pos)) > 0:
-            prl = Prl(self.bytes, pos, self.mainStream, self.transformed, index)
+            prl = Prl(self, pos, self.mainStream, self.transformed, index)
             self.prls.append(prl)
             pos += prl.getSize()
             index += 1
@@ -1622,7 +1623,7 @@ class PrcData(DOCDirStream):
         pos = 0
         self.prls = []
         while self.cbGrpprl - pos > 0:
-            prl = Prl(self.bytes, self.pos + pos)
+            prl = Prl(self, self.pos + pos)
             pos += prl.getSize()
             self.prls.append(prl)
         self.pos += self.cbGrpprl
@@ -2856,7 +2857,7 @@ class UpxPapx(DOCDirStream):
         pos = 0
         print '<grpprlPapx offset="%d" size="%d bytes">' % (self.pos, size)
         while size - pos > 0:
-            prl = Prl(self.bytes, self.pos + pos)
+            prl = Prl(self, self.pos + pos)
             prl.dump()
             pos += prl.getSize()
         print '</grpprlPapx>'
@@ -2875,7 +2876,7 @@ class UpxChpx(DOCDirStream):
         pos = 0
         print '<grpprlChpx offset="%d" size="%d bytes">' % (self.pos, size)
         while size - pos > 0:
-            prl = Prl(self.bytes, self.pos + pos)
+            prl = Prl(self, self.pos + pos)
             prl.dump()
             pos += prl.getSize()
         print '</grpprlChpx>'
@@ -2894,7 +2895,7 @@ class UpxTapx(DOCDirStream):
         pos = 0
         print '<grpprlTapx offset="%d" size="%d bytes">' % (self.pos, size)
         while size - pos > 0:
-            prl = Prl(self.bytes, self.pos + pos)
+            prl = Prl(self, self.pos + pos)
             prl.dump()
             pos += prl.getSize()
         print '</grpprlTapx>'
@@ -3463,7 +3464,7 @@ class LVL(DOCDirStream):
         print '<grpprlPapx offset="%d">' % self.pos
         pos = self.pos
         while (lvlf.cbGrpprlPapx - (pos - self.pos)) > 0:
-            prl = Prl(self.bytes, pos)
+            prl = Prl(self, pos)
             prl.dump()
             pos += prl.getSize()
         self.pos = pos
@@ -3472,7 +3473,7 @@ class LVL(DOCDirStream):
         print '<grpprlChpx offset="%d">' % self.pos
         pos = self.pos
         while (lvlf.cbGrpprlChpx - (pos - self.pos)) > 0:
-            prl = Prl(self.bytes, pos)
+            prl = Prl(self, pos)
             prl.dump()
             pos += prl.getSize()
         self.pos = pos
commit e2efad697063585457ac2beb7ff49e18278bda5c
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Sat Aug 17 22:11:53 2013 +0200

    Chpx: parse this in the ctor

diff --git a/src/docrecord.py b/src/docrecord.py
index be56d48..41353d5 100644
--- a/src/docrecord.py
+++ b/src/docrecord.py
@@ -1284,16 +1284,21 @@ class Chpx(DOCDirStream):
         self.pos = offset
         self.transformed = transformed
 
-    def dump(self):
-        print '<chpx type="Chpx" offset="%d">' % self.pos
-        self.printAndSet("cb", self.readuInt8())
+        self.cb = self.readuInt8()
         pos = self.pos
         index = 0
+        self.prls = []
         while (self.cb - (pos - self.pos)) > 0:
             prl = Prl(self.bytes, pos, self.mainStream, self.transformed, index)
-            prl.dump()
+            self.prls.append(prl)
             pos += prl.getSize()
             index += 1
+
+    def dump(self):
+        print '<chpx type="Chpx" offset="%d">' % self.pos
+        self.printAndSet("cb", self.cb)
+        for prl in self.prls:
+            prl.dump()
         print '</chpx>'
     
 class PapxInFkp(DOCDirStream):


More information about the Libreoffice-commits mailing list