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

Miklos Vajna vmiklos at kemper.freedesktop.org
Fri Jun 7 06:37:48 PDT 2013


 src/docrecord.py |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 src/msodraw.py   |   29 +++++++++++++++++++++++++++
 2 files changed, 84 insertions(+), 2 deletions(-)

New commits:
commit 12002a3d896ed4bebebf857c86208f8f69f72703
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Jun 7 15:31:33 2013 +0200

    msodraw: dump wzDescription

diff --git a/src/msodraw.py b/src/msodraw.py
index e469f2e..b7b371d 100644
--- a/src/msodraw.py
+++ b/src/msodraw.py
@@ -480,6 +480,11 @@ class FOPT:
         def __init__(self):
             UnicodeComplex.__init__(self, "wzName")
 
+    class WzDescription(UnicodeComplex):
+
+        def __init__(self):
+            UnicodeComplex.__init__(self, "wzDescription")
+
     class PibName(UnicodeComplex):
 
         def __init__(self):
@@ -575,6 +580,7 @@ class FOPT:
         0x01C0: ['Line Color', LineColor],
         0x0303: ['Connector Shape Style (cxstyle)', CXStyle],
         0x0380: ['wzName', WzName],
+        0x0381: ['wzDescription', WzDescription],
         0x03BF: ['Group Shape Boolean Properties', GroupShape],
         0x0205: ['X Shadow Offset', ShadowOffsetX],
         0x01CB: ['Line Width', LineWidth],
commit fc29c6654dbcf76e13c8b0a7b051bb37c71c9744
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Jun 7 15:29:38 2013 +0200

    msodraw: dump pibName property

diff --git a/src/msodraw.py b/src/msodraw.py
index 6aa3b81..e469f2e 100644
--- a/src/msodraw.py
+++ b/src/msodraw.py
@@ -480,6 +480,11 @@ class FOPT:
         def __init__(self):
             UnicodeComplex.__init__(self, "wzName")
 
+    class PibName(UnicodeComplex):
+
+        def __init__(self):
+            UnicodeComplex.__init__(self, "pibName")
+
     class ShadowOffsetX:
 
         def appendLines(self, recHdl, prop, level):
@@ -607,6 +612,7 @@ class FOPT:
         0x0182: ['fillOpacity'],
         0x053F: ['Diagram Boolean Properties'],
         0x03A9: ['metroBlob', MetroBlob],
+        0x0105: ['pibName', PibName]
     }
 
     class E:
commit 7bd179339a1c3ec90bdd633b1e996c5a40c02b2d
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Jun 7 15:22:22 2013 +0200

    msodraw: dump metroBlob shape property

diff --git a/src/msodraw.py b/src/msodraw.py
index b6b4592..6aa3b81 100644
--- a/src/msodraw.py
+++ b/src/msodraw.py
@@ -46,6 +46,12 @@ def emu_to_mm100(value):
 def emu_to_twip(value):
     return mm100_to_twip(emu_to_mm100(value))
 
+def hexdump(value):
+    ret = []
+    for i in value:
+        ret.append("%02x" % ord(i))
+    return "".join(ret)
+
 class RecordHeader:
 
     size = 8
@@ -490,6 +496,16 @@ class FOPT:
         def dumpXml(self, recHdl, prop):
             recHdl.appendLine('<lineWidth value="%s" inTwips="%s"/>' % (prop.value, emu_to_twip(prop.value)))
 
+    class MetroBlob:
+        """The metroBlob property specifies alternative XML content for a
+        shape. This property specifies a binary serialization of an OPC
+        container. The package contains an OOXML DrawingML document."""
+
+        def appendLines(self, recHdl, prop, level):
+            recHdl.appendLine(indent(level)+"metroBlob: %s"%hexdump(prop.value))
+
+        def dumpXml(self, recHdl, prop):
+            recHdl.appendLine('<metroBlob value="%s"/>' % hexdump(prop.extra))
 
     class GroupShape:
 
@@ -590,6 +606,7 @@ class FOPT:
         0x00FF: ['Geometry Text Boolean Properties'],
         0x0182: ['fillOpacity'],
         0x053F: ['Diagram Boolean Properties'],
+        0x03A9: ['metroBlob', MetroBlob],
     }
 
     class E:
commit 6cee946c574b423e04ed1ce2267bd246d50997c1
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Jun 7 14:48:09 2013 +0200

    dump Rca

diff --git a/src/docrecord.py b/src/docrecord.py
index 6663578..429db6b 100644
--- a/src/docrecord.py
+++ b/src/docrecord.py
@@ -2657,6 +2657,22 @@ class STSH(DOCDirStream):
             print '</rglpstd>'
         print '</stsh>'
 
+class Rca(DOCDirStream):
+    """The Rca structure is used to define the coordinates of a rectangular area in the document."""
+    def __init__(self, parent):
+        DOCDirStream.__init__(self, parent.bytes)
+        self.parent = parent
+        self.pos = parent.pos
+
+    def dump(self):
+        print '<rca type="Rca" offset="%s">' % self.pos
+        self.printAndSet("left", self.readuInt32())
+        self.printAndSet("top", self.readuInt32())
+        self.printAndSet("right", self.readuInt32())
+        self.printAndSet("bottom", self.readuInt32())
+        print '</rca>'
+        self.parent.pos = self.pos
+
 class SPA(DOCDirStream):
     """The Spa structure specifies information about the shapes and drawings that the document contains."""
     size = 26 # defined by 2.8.37
@@ -2669,8 +2685,7 @@ class SPA(DOCDirStream):
         pos = self.pos
         print '<spa type="SPA" offset="%s" size="%d bytes">' % (self.pos, SPA.size)
         self.printAndSet("lid", self.readuInt32())
-        # TODO rca
-        self.pos += 16
+        Rca(self).dump()
         buf = self.readuInt16()
         self.printAndSet("fHdr", self.getBit(buf, 0)) # 1st bit
         self.printAndSet("bx", (buf & 0x6) >> 1) # 2..3rd bits
commit bc6ea49c079ac8b53d3e920051c627e91408ed04
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Jun 7 14:40:40 2013 +0200

    dump SPA

diff --git a/src/docrecord.py b/src/docrecord.py
index 873b04d..6663578 100644
--- a/src/docrecord.py
+++ b/src/docrecord.py
@@ -2657,6 +2657,33 @@ class STSH(DOCDirStream):
             print '</rglpstd>'
         print '</stsh>'
 
+class SPA(DOCDirStream):
+    """The Spa structure specifies information about the shapes and drawings that the document contains."""
+    size = 26 # defined by 2.8.37
+    def __init__(self, parent, offset):
+        DOCDirStream.__init__(self, parent.bytes)
+        self.parent = parent
+        self.pos = offset
+
+    def dump(self):
+        pos = self.pos
+        print '<spa type="SPA" offset="%s" size="%d bytes">' % (self.pos, SPA.size)
+        self.printAndSet("lid", self.readuInt32())
+        # TODO rca
+        self.pos += 16
+        buf = self.readuInt16()
+        self.printAndSet("fHdr", self.getBit(buf, 0)) # 1st bit
+        self.printAndSet("bx", (buf & 0x6) >> 1) # 2..3rd bits
+        self.printAndSet("by", (buf & 0x18) >> 3) # 4..5th bits
+        self.printAndSet("wr", (buf & 0x1e0) >> 5) # 6..9th bits
+        self.printAndSet("wrk", (buf & 0x1e00) >> 9) # 10..13th bits
+        self.printAndSet("fRcaSimple", self.getBit(buf, 13)) # 14th bit
+        self.printAndSet("fBelowText", self.getBit(buf, 14)) # 15th bit
+        self.printAndSet("fAnchorLock", self.getBit(buf, 15)) # 16th bit
+        self.printAndSet("cTxbx", self.readuInt32())
+        print '</spa>'
+        assert pos + SPA.size == self.pos
+
 class SPLS(DOCDirStream):
     """The SPLS structure specifies the current state of a range of text with regard to one of the language checking features."""
     size = 2 # defined by 2.9.253
@@ -2859,8 +2886,19 @@ class PlcfSpa(DOCDirStream, PLC):
     def dump(self):
         print '<plcfSpa type="PlcfSpa" offset="%d" size="%d bytes">' % (self.pos, self.size)
         pos = self.pos
-        if self.getElements() - 1 != 0:
-            print '<todo what="PlcfSpa: self.getElements() - 1 != 0"/>'
+        for i in range(self.getElements()):
+            # aCp
+            start = self.getuInt32(pos = pos)
+            end = self.getuInt32(pos = pos + 4)
+            print '<aCP index="%d" start="%d" end="%d">' % (i, start, end)
+            pos += 4
+
+            # aSpa
+            aSpa = SPA(self, self.getOffset(self.pos, i))
+            aSpa.dump()
+
+            print '<transformed value="%s"/>' % self.quoteAttr(self.mainStream.retrieveCPs(start, end))
+            print '</aCP>'
         print '</plcfSpa>'
 
 class PlcfGram(DOCDirStream, PLC):


More information about the Libreoffice-commits mailing list