[Libreoffice-commits] mso-dumper.git: 3 commits - src/docrecord.py src/msodraw.py test/doc
Miklos Vajna
vmiklos at kemper.freedesktop.org
Sat Aug 17 13:00:01 PDT 2013
src/docrecord.py | 12 +++++++++---
src/msodraw.py | 32 ++++++++++++++++++++++----------
test/doc/picture-wrap.doc |binary
test/doc/test.py | 9 +++++++++
4 files changed, 40 insertions(+), 13 deletions(-)
New commits:
commit 2f9ec729a39007720bff356bac32db92ce5a0554
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Sat Aug 17 21:47:33 2013 +0200
msodraw: dump non-inline images
diff --git a/src/docrecord.py b/src/docrecord.py
index b62679a..be56d48 100644
--- a/src/docrecord.py
+++ b/src/docrecord.py
@@ -11,6 +11,11 @@ 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):
@@ -998,6 +1003,7 @@ class PICFAndOfficeArtData(DOCDirStream):
dataStream = parent.mainStream.doc.getDirectoryStreamByName("Data")
DOCDirStream.__init__(self, dataStream.bytes)
self.pos = parent.operand
+ self.parent = parent
def dump(self):
print '<PICFAndOfficeArtData>'
@@ -1008,7 +1014,7 @@ class PICFAndOfficeArtData(DOCDirStream):
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, globals.ModelBase(globals.ModelBase.HostAppType.Word))
+ msodraw.InlineSpContainer(self, remaining).dumpXml(self, getWordModel(self.parent.mainStream))
print '</PICFAndOfficeArtData>'
# The TextFlow enumeration specifies the rotation settings for a block of text and for the individual
@@ -2580,7 +2586,7 @@ class OfficeArtWordDrawing(DOCDirStream):
def dump(self):
print '<officeArtWordDrawing type="OfficeArtWordDrawing" pos="%d">' % self.pos
self.printAndSet("dgglbl", self.readuInt8())
- msodraw.DgContainer(self, "container").dumpXml(self, globals.ModelBase(globals.ModelBase.HostAppType.Word))
+ msodraw.DgContainer(self, "container").dumpXml(self, getWordModel(self.officeArtContent.mainStream))
print '</officeArtWordDrawing>'
self.officeArtContent.pos = self.pos
@@ -2594,7 +2600,7 @@ class OfficeArtContent(DOCDirStream):
def dump(self):
print '<officeArtContent type="OfficeArtContent" offset="%d" size="%d bytes">' % (self.pos, self.size)
- msodraw.DggContainer(self, "DrawingGroupData").dumpXml(self, globals.ModelBase(globals.ModelBase.HostAppType.Word))
+ msodraw.DggContainer(self, "DrawingGroupData").dumpXml(self, getWordModel(self.mainStream))
print '<Drawings type="main" offset="%d">' % self.pos
OfficeArtWordDrawing(self).dump()
print '</Drawings>'
diff --git a/src/msodraw.py b/src/msodraw.py
index f467d80..97a8ffd 100644
--- a/src/msodraw.py
+++ b/src/msodraw.py
@@ -1070,6 +1070,17 @@ class FBSE:
pass
def dumpXml(self, recHdl, model, rh):
+
+ def dumpChild(strm):
+ rh = RecordHeader(strm)
+ rh.dumpXml(recHdl)
+ if rh.recType in recData:
+ child = recData[rh.recType](strm)
+ child.dumpXml(strm, model, rh)
+ else:
+ recHdl.appendLine('<todo what="FBSE::dumpXml(): recType = %s unhandled (size: %d bytes)"/>' % (hex(rh.recType), rh.recLen))
+ strm.pos += rh.recLen
+
recHdl.appendLine('<fbse>')
recHdl.appendLine('<btWin32 value="%s" name="%s"/>' % (self.btWin32, globals.getValueOrUnknown(MSOBLIPTYPE, self.btWin32, "todo")))
recHdl.appendLine('<btMacOS value="%s" name="%s"/>' % (self.btMacOS, globals.getValueOrUnknown(MSOBLIPTYPE, self.btMacOS, "todo")))
@@ -1085,14 +1096,14 @@ class FBSE:
if self.cbName != 0:
recHdl.appendLine('<todo what="FBSE::dumpXml(): cbName != 0"/>')
if self.strm.pos < self.posOrig + rh.recLen:
- rh = RecordHeader(self.strm)
- rh.dumpXml(recHdl)
- if rh.recType in recData:
- child = recData[rh.recType](self.strm)
- child.dumpXml(self.strm, model, rh)
- else:
- recHdl.appendLine('<todo what="FBSE::dumpXml(): recType = %s unhandled (size: %d bytes)"/>' % (hex(rh.recType), rh.recLen))
- self.strm.pos += rh.recLen
+ dumpChild(self.strm)
+ elif self.foDelay != 0xffffffff:
+ # Picture is in the delay stream, try to dump it.
+ if model.hostApp == globals.ModelBase.HostAppType.Word:
+ posOrig = model.delayStream.pos
+ model.delayStream.pos = self.foDelay
+ dumpChild(model.delayStream)
+ model.delayStream.pos = posOrig
recHdl.appendLine('</fbse>')
class FClientAnchorSheet:
diff --git a/test/doc/picture-wrap.doc b/test/doc/picture-wrap.doc
new file mode 100755
index 0000000..b33d0b8
Binary files /dev/null and b/test/doc/picture-wrap.doc differ
diff --git a/test/doc/test.py b/test/doc/test.py
index da0de0a..c6f71d7 100755
--- a/test/doc/test.py
+++ b/test/doc/test.py
@@ -196,6 +196,15 @@ class Test(unittest.TestCase):
actual = runs[1].findall('chpx/prl[@index="0"]/sprm/PICFAndOfficeArtData/inlineSpContainer/fbse/blipPng/BLIPFileData')[0].attrib['value']
self.assertEqual(expected, actual)
+ def test_picture_wrap(self):
+ self.dump('picture-wrap')
+
+ # make sure the correct PNG data is dumped
+ expected = "89504e470d0a1a0a0000000d4948445200000010000000100802000000909168360000015049444154789c9592c14a02511486bf99714ccb322d7521140541cb6a11448b164150fb8a363d41f4083d40cba0655044d0a637a837682fd1a6a2488b10b23475bcb77b671c491dc1cee23077e67cf7fcff39139252f29f08b59e3e1dae8b4c45998ff501a82e070f5cbd3366733acb5c6fa609fc0872651236df0deeca7d002a6cc33d1b941a146ab49ca937e37610e0c590c5c92b67f926a07243b293613f8b1108a8a84aadb01575c9799edd0c895010a0ae71048e77b99b6a92e53861a387a48a6033c5d208c297a43ca8a3697601d217b010632dd9a9f34be09968021698bea4c76ab72f5dd0d6216c3211e1bec2a0c5e59bce9303baa770c7bd38aca7d729692bcd4d512b53bb3b7cc2f45dd604ab098e67b499366025ce5e96a317fd2162e2d76bbbb725bdcd80b12a603aca4581e7aade97e14ec2916ca719ed96e4c54692f5241f755de7019641eacfaff10b469261dc6a800dd30000000049454e44ae426082"
+ xpath = 'stream[@name="WordDocument"]/fib/fibRgFcLcbBlob/lcbDggInfo/officeArtContent/DrawingGroupData/bStoreContainer/fbse/blipPng/BLIPFileData'
+ actual = self.root.findall(xpath)[0].attrib['value']
+ self.assertEqual(expected, actual)
+
if __name__ == '__main__':
unittest.main()
commit 949c0e98bad70d71851fed1497a7defda4356081
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Sat Aug 17 19:16:16 2013 +0200
msodraw: recognize pib shape property
diff --git a/src/msodraw.py b/src/msodraw.py
index 8d9886c..f467d80 100644
--- a/src/msodraw.py
+++ b/src/msodraw.py
@@ -738,6 +738,7 @@ class FOPT:
0x01C1: ['lineOpacity'],
0x01D6: ['lineJoinStyle'],
0x01D7: ['lineEndCapStyle'],
+ 0x0104: ['pib'],
}
class E:
commit f9e66bd2d731c694444e933020db9085147ad218
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Sat Aug 17 19:09:47 2013 +0200
msodraw: fix two typos
diff --git a/src/msodraw.py b/src/msodraw.py
index 6b196e0..8d9886c 100644
--- a/src/msodraw.py
+++ b/src/msodraw.py
@@ -706,9 +706,9 @@ class FOPT:
0x0304: ['Black-and-white Display Mode'],
0x033F: ['Shape Boolean Properties', ShapeBooleanProperties],
0x0081: ['dxTextLeft'],
- 0x0082: ['dxTextTop'],
+ 0x0082: ['dyTextTop'],
0x0083: ['dxTextRight'],
- 0x0084: ['dxTextBottom'],
+ 0x0084: ['dyTextBottom'],
0x0088: ['txflTextFlow'],
0x0183: ['fillBackColor'],
0x01C2: ['lineBackColor'],
More information about the Libreoffice-commits
mailing list