[Libreoffice-commits] mso-dumper.git: src/docrecord.py test/doc
Miklos Vajna
vmiklos at kemper.freedesktop.org
Wed Jun 12 02:28:08 PDT 2013
src/docrecord.py | 66 +++++++++++++++++++++++++++++++++++++++++--------
test/doc/abi1157-1.doc |binary
test/doc/test.py | 3 ++
3 files changed, 59 insertions(+), 10 deletions(-)
New commits:
commit 1f3ea3de7dac77f977b29600c68732674e67bbdb
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Wed Jun 12 11:24:14 2013 +0200
dump Prl and PrcData
diff --git a/src/docrecord.py b/src/docrecord.py
index 429db6b..4d2039b 100644
--- a/src/docrecord.py
+++ b/src/docrecord.py
@@ -850,11 +850,12 @@ class Prl(DOCDirStream):
def __init__(self, bytes, offset):
DOCDirStream.__init__(self, bytes)
self.pos = offset
-
- def dump(self):
- print '<prl type="Prl" offset="%d">' % self.pos
+ self.posOrig = self.pos
self.sprm = Sprm(self.bytes, self.pos)
self.pos += 2
+
+ def dump(self):
+ print '<prl type="Prl" offset="%d">' % self.posOrig
self.sprm.dump()
print '</prl>'
@@ -1204,6 +1205,48 @@ 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."""
+ def __init__(self, parent):
+ DOCDirStream.__init__(self, parent.bytes)
+ self.pos = parent.pos
+
+ self.cbGrpprl = self.readInt16()
+ pos = 0
+ self.prls = []
+ while self.cbGrpprl - pos > 0:
+ prl = Prl(self.bytes, self.pos + pos)
+ pos += prl.getSize()
+ self.prls.append(prl)
+ self.pos += self.cbGrpprl
+ parent.pos = self.pos
+
+ def dump(self):
+ print '<prcData>'
+ self.printAndSet("cbGrpprl", self.cbGrpprl)
+ print '<grpPrl>'
+ for i in self.prls:
+ i.dump()
+ 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."""
+ def __init__(self, parent):
+ DOCDirStream.__init__(self, parent.bytes)
+ self.pos = parent.pos
+
+ self.clxt = self.readuInt8()
+ self.prcData = PrcData(self)
+ parent.pos = self.pos
+
+ def dump(self, index):
+ print '<prc index="%d">' % index
+ self.prcData.dump()
+ print '</prc>'
+
class Clx(DOCDirStream):
def __init__(self, bytes, mainStream, offset, size):
DOCDirStream.__init__(self, bytes, mainStream=mainStream)
@@ -1211,16 +1254,19 @@ class Clx(DOCDirStream):
self.size = size
self.firstByte = self.getuInt8()
- if self.firstByte == 0x02:
- self.pcdt = Pcdt(self.bytes, self.mainStream, self.pos, self.size)
+ self.prcs = []
+ while True:
+ self.firstByte = self.getuInt8()
+ if self.firstByte != 0x01:
+ break
+ self.prcs.append(Prc(self))
+ self.pcdt = Pcdt(self.bytes, self.mainStream, self.pos, self.size)
def dump(self):
print '<clx type="Clx" offset="%d" size="%d bytes">' % (self.pos, self.size)
- if self.firstByte == 0x02:
- print '<info what="Array of Prc, 0 elements"/>'
- self.pcdt.dump()
- else:
- print '<todo what="Clx::dump() first byte is not 0x02"/>'
+ for index, elem in enumerate(self.prcs):
+ elem.dump(index)
+ self.pcdt.dump()
print '</clx>'
class Copts60(DOCDirStream):
diff --git a/test/doc/abi1157-1.doc b/test/doc/abi1157-1.doc
new file mode 100644
index 0000000..8adac06
Binary files /dev/null and b/test/doc/abi1157-1.doc differ
diff --git a/test/doc/test.py b/test/doc/test.py
index 2bf3f01..97951cb 100755
--- a/test/doc/test.py
+++ b/test/doc/test.py
@@ -182,6 +182,9 @@ class Test(unittest.TestCase):
firstHeader = self.root.findall('stream[@name="WordDocument"]/fib/fibRgFcLcbBlob/lcbPlcfHdd/plcfHdd/aCP[@index="7"]')
self.assertEqual("This is a header.\\x0D\\x0D", firstHeader[0].findall('transformed')[0].attrib['value'])
+ def test_abi1157(self):
+ self.dump('abi1157-1')
+
if __name__ == '__main__':
unittest.main()
More information about the Libreoffice-commits
mailing list