msodumper/emfrecord.py | 28 ++++++++++++++++++++++++-- test/emf/pass/fdo31814-2.emf |binary test/emf/test.py | 46 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 2 deletions(-)
New commits: commit f69b2c1e24c711c7451a93cc30a317c113b09d6a Author: Miklos Vajna <[email protected]> Date: Thu May 1 14:05:43 2014 +0200 add testcase for fdo31814-2.emf diff --git a/test/emf/pass/fdo31814-2.emf b/test/emf/pass/fdo31814-2.emf new file mode 100644 index 0000000..8b3923e Binary files /dev/null and b/test/emf/pass/fdo31814-2.emf differ diff --git a/test/emf/test.py b/test/emf/test.py new file mode 100755 index 0000000..c4091f5 --- /dev/null +++ b/test/emf/test.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python2 +# -*- encoding: UTF-8 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +import sys +sys.path.append(sys.path[0] + "/../..") +emf_dumper = __import__('emf-dump') +from xml.etree import ElementTree +import unittest +import os + + +class Test(unittest.TestCase): + def dump(self, name): + try: + os.unlink("%s.emf.xml" % name) + except OSError: + pass + sock = open("%s.emf.xml" % name, "w") + saved = sys.stdout + sys.stdout = sock + emf_dumper.main(["emf-dumper", "%s.emf" % name]) + sys.stdout = saved + sock.close() + tree = ElementTree.parse('%s.emf.xml' % name) + self.root = tree.getroot() + # Make sure everything is dumped - so it can't happen that dump(a) == dump(b), but a != b. + self.assertEqual(0, len(self.root.findall('todo'))) + + def test_pass(self): + """This test just makes sure that all files in the 'pass' directory are + dumped without problems.""" + + for dirname, dirnames, filenames in os.walk('pass'): + for filename in filenames: + if filename.endswith(".emf"): + self.dump(os.path.join(dirname, filename).replace('.emf', '')) + +if __name__ == '__main__': + unittest.main() + +# vim:set filetype=python shiftwidth=4 softtabstop=4 expandtab: commit e110cc9eb66a5f1bc40a2f8864bd9977e614c5ad Author: Miklos Vajna <[email protected]> Date: Thu May 1 14:01:11 2014 +0200 EMF: fix dumping of fdo31814-2.emf diff --git a/msodumper/emfrecord.py b/msodumper/emfrecord.py index b25218c..4ed10b1 100644 --- a/msodumper/emfrecord.py +++ b/msodumper/emfrecord.py @@ -52,6 +52,7 @@ PenStyle = { 0x00010000: "PS_GEOMETRIC", # Additional combinations 0x00010200: "PS_GEOMETRIC, PS_ENDCAP_FLAT", + 0x00011100: "PS_GEOMETRIC, PS_JOIN_BEVEL, PS_ENDCAP_SQUARE", } commit 2bf7f7eb23ba7fc9e94c9fb21b5cda12d336d550 Author: Miklos Vajna <[email protected]> Date: Thu May 1 13:56:25 2014 +0200 EmrComment: dump comment identifier value in case it's not a known one diff --git a/msodumper/emfrecord.py b/msodumper/emfrecord.py index 20502cb..b25218c 100644 --- a/msodumper/emfrecord.py +++ b/msodumper/emfrecord.py @@ -235,7 +235,7 @@ class EmrComment(EMFRecord): elif commentIdentifier == 0x43494447: # EMR_COMMENT_PUBLIC print '<todo what="EmrComment::dump(): handle EMR_COMMENT_PUBLIC"/>' else: - print '<todo what="EmrComment::dump(): handle EMR_COMMENT"/>' + print '<todo what="EmrComment::dump(): handle EMR_COMMENT: %s"/>' % hex(commentIdentifier) class EmrSetviewportorgex(EMFRecord): commit 5c0096ada4e991a19a70d8e056c84617ed90c0fe Author: Miklos Vajna <[email protected]> Date: Thu May 1 13:45:01 2014 +0200 dump EmrSetstretchbltmode diff --git a/msodumper/emfrecord.py b/msodumper/emfrecord.py index 1683b7f..20502cb 100644 --- a/msodumper/emfrecord.py +++ b/msodumper/emfrecord.py @@ -271,6 +271,29 @@ class EmrSetpolyfillmode(EMFRecord): assert self.pos - posOrig == self.Size +# Used to specify how color data is added to or removed from bitmaps that are +# stretched or compressed. +StretchMode = { + 0x01: "STRETCH_ANDSCANS", + 0x02: "STRETCH_ORSCANS", + 0x03: "STRETCH_DELETESCANS", + 0x04: "STRETCH_HALFTONE", +} + + +class EmrSetstretchbltmode(EMFRecord): + """Specifies bitmap stretch mode.""" + def __init__(self, parent): + EMFRecord.__init__(self, parent) + + def dump(self): + posOrig = self.pos + self.printAndSet("Type", self.readuInt32()) + self.printAndSet("Size", self.readuInt32(), hexdump=False) + self.printAndSet("StretchMode", self.readuInt32(), dict=StretchMode) + assert self.pos - posOrig == self.Size + + class EmrExtselectcliprgn(EMFRecord): """Combines the specified region with the current clip region using the specified mode.""" def __init__(self, parent): @@ -782,7 +805,7 @@ RecordType = { 0x00000012: ['EMR_SETBKMODE'], 0x00000013: ['EMR_SETPOLYFILLMODE', EmrSetpolyfillmode], 0x00000014: ['EMR_SETROP2'], - 0x00000015: ['EMR_SETSTRETCHBLTMODE'], + 0x00000015: ['EMR_SETSTRETCHBLTMODE', EmrSetstretchbltmode], 0x00000016: ['EMR_SETTEXTALIGN'], 0x00000017: ['EMR_SETCOLORADJUSTMENT'], 0x00000018: ['EMR_SETTEXTCOLOR'], _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
