[Libreoffice-commits] mso-dumper.git: 4 commits - msodumper/emfrecord.py msodumper/wmfrecord.py
Miklos Vajna
vmiklos at collabora.co.uk
Thu Apr 17 12:07:50 PDT 2014
msodumper/emfrecord.py | 91 ++++++++++++++++++++++++++++++++++++++++++++++---
msodumper/wmfrecord.py | 14 +++++++
2 files changed, 101 insertions(+), 4 deletions(-)
New commits:
commit 945fb415736a7cb9c228d14fef367e6e6a02ec17
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Apr 17 21:07:00 2014 +0200
dump EmrEndpath
diff --git a/msodumper/emfrecord.py b/msodumper/emfrecord.py
index b6d2922..2a360c2 100644
--- a/msodumper/emfrecord.py
+++ b/msodumper/emfrecord.py
@@ -305,6 +305,18 @@ class EmrBeginpath(EMFRecord):
assert self.pos - posOrig == self.Size
+class EmrEndpath(EMFRecord):
+ """This record closes a path bracket and selects the path defined by the bracket into the playback device context."""
+ 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)
+ assert self.pos - posOrig == self.Size
+
+
class RegionData(EMFRecord):
"""The RegionData object specifies data that defines a region, which is made of non-overlapping rectangles."""
def __init__(self, parent, name, size):
@@ -471,7 +483,7 @@ RecordType = {
0x00000039: ['EMR_SETARCDIRECTION'],
0x0000003A: ['EMR_SETMITERLIMIT'],
0x0000003B: ['EMR_BEGINPATH', EmrBeginpath],
- 0x0000003C: ['EMR_ENDPATH'],
+ 0x0000003C: ['EMR_ENDPATH', EmrEndpath],
0x0000003D: ['EMR_CLOSEFIGURE'],
0x0000003E: ['EMR_FILLPATH'],
0x0000003F: ['EMR_STROKEANDFILLPATH'],
commit b2eac9eebd1e4bfaa3c219d5df0c2d1f424b1bb5
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Apr 17 21:04:28 2014 +0200
dump EmrBeginpath
diff --git a/msodumper/emfrecord.py b/msodumper/emfrecord.py
index d823f87..b6d2922 100644
--- a/msodumper/emfrecord.py
+++ b/msodumper/emfrecord.py
@@ -293,6 +293,18 @@ class EmrPolygon16(EMFRecord):
assert self.pos - posOrig == self.Size
+class EmrBeginpath(EMFRecord):
+ """This record opens a path bracket in the current playback device context."""
+ 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)
+ assert self.pos - posOrig == self.Size
+
+
class RegionData(EMFRecord):
"""The RegionData object specifies data that defines a region, which is made of non-overlapping rectangles."""
def __init__(self, parent, name, size):
@@ -458,7 +470,7 @@ RecordType = {
0x00000038: ['EMR_POLYDRAW'],
0x00000039: ['EMR_SETARCDIRECTION'],
0x0000003A: ['EMR_SETMITERLIMIT'],
- 0x0000003B: ['EMR_BEGINPATH'],
+ 0x0000003B: ['EMR_BEGINPATH', EmrBeginpath],
0x0000003C: ['EMR_ENDPATH'],
0x0000003D: ['EMR_CLOSEFIGURE'],
0x0000003E: ['EMR_FILLPATH'],
commit 3308ef622503617abd3a55eed9a53fa44ff0afdd
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Apr 17 21:01:32 2014 +0200
dump EmrPolygon16
diff --git a/msodumper/emfrecord.py b/msodumper/emfrecord.py
index a0ee5e8..d823f87 100644
--- a/msodumper/emfrecord.py
+++ b/msodumper/emfrecord.py
@@ -275,6 +275,24 @@ class EmrSelectobject(EMFRecord):
assert self.pos - posOrig == self.Size
+class EmrPolygon16(EMFRecord):
+ """Draws a polygon consisting of two or more vertexes connected by straight lines."""
+ 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)
+ wmfrecord.RectL(self, "Bounds").dump()
+ self.printAndSet("Count", self.readuInt32(), hexdump=False)
+ print '<aPoints>'
+ for i in range(self.Count):
+ wmfrecord.PointS(self, "aPoint").dump()
+ print '</aPoints>'
+ assert self.pos - posOrig == self.Size
+
+
class RegionData(EMFRecord):
"""The RegionData object specifies data that defines a region, which is made of non-overlapping rectangles."""
def __init__(self, parent, name, size):
@@ -466,7 +484,7 @@ RecordType = {
0x00000053: ['EMR_EXTTEXTOUTA'],
0x00000054: ['EMR_EXTTEXTOUTW'],
0x00000055: ['EMR_POLYBEZIER16'],
- 0x00000056: ['EMR_POLYGON16'],
+ 0x00000056: ['EMR_POLYGON16', EmrPolygon16],
0x00000057: ['EMR_POLYLINE16'],
0x00000058: ['EMR_POLYBEZIERTO16'],
0x00000059: ['EMR_POLYLINETO16'],
diff --git a/msodumper/wmfrecord.py b/msodumper/wmfrecord.py
index 5cfcb1d..dd4e8ea 100644
--- a/msodumper/wmfrecord.py
+++ b/msodumper/wmfrecord.py
@@ -94,6 +94,20 @@ class PointL(WMFRecord):
self.parent.pos = self.pos
+class PointS(WMFRecord):
+ """The PointS Object defines the x- and y-coordinates of a point."""
+ def __init__(self, parent, name):
+ WMFRecord.__init__(self, parent)
+ self.name = name
+
+ def dump(self):
+ print '<%s type="PointS">' % self.name
+ self.printAndSet("x", self.readInt16(), hexdump=False)
+ self.printAndSet("y", self.readInt16(), hexdump=False)
+ print '</%s>' % self.name
+ self.parent.pos = self.pos
+
+
class ColorRef(WMFRecord):
"""The ColorRef Object defines the RGB color."""
def __init__(self, parent, name):
commit d35df0a1dfdcec968742c3e19c1e77c3a63df3df
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Apr 17 20:55:14 2014 +0200
dump EmrSelectobject
diff --git a/msodumper/emfrecord.py b/msodumper/emfrecord.py
index c89b10a..a0ee5e8 100644
--- a/msodumper/emfrecord.py
+++ b/msodumper/emfrecord.py
@@ -234,6 +234,47 @@ class EmrExtselectcliprgn(EMFRecord):
assert self.pos - posOrig == self.Size
+# Specifies the indexes of predefined logical graphics objects that can be used in graphics operations.
+StockObject = {
+ 0x80000000: "WHITE_BRUSH",
+ 0x80000001: "LTGRAY_BRUSH",
+ 0x80000002: "GRAY_BRUSH",
+ 0x80000003: "DKGRAY_BRUSH",
+ 0x80000004: "BLACK_BRUSH",
+ 0x80000005: "NULL_BRUSH",
+ 0x80000006: "WHITE_PEN",
+ 0x80000007: "BLACK_PEN",
+ 0x80000008: "NULL_PEN",
+ 0x8000000A: "OEM_FIXED_FONT",
+ 0x8000000B: "ANSI_FIXED_FONT",
+ 0x8000000C: "ANSI_VAR_FONT",
+ 0x8000000D: "SYSTEM_FONT",
+ 0x8000000E: "DEVICE_DEFAULT_FONT",
+ 0x8000000F: "DEFAULT_PALETTE",
+ 0x80000010: "SYSTEM_FIXED_FONT",
+ 0x80000011: "DEFAULT_GUI_FONT",
+ 0x80000012: "DC_BRUSH",
+ 0x80000013: "DC_PEN"
+}
+
+
+class EmrSelectobject(EMFRecord):
+ """Combines the specified region with the current clip region using the specified 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)
+ ihObject = self.getuInt32(pos=self.pos)
+ if ihObject < 0x80000000:
+ self.printAndSet("ihObject", self.readuInt32())
+ else:
+ self.printAndSet("ihObject", self.readuInt32(), dict=StockObject)
+ assert self.pos - posOrig == self.Size
+
+
class RegionData(EMFRecord):
"""The RegionData object specifies data that defines a region, which is made of non-overlapping rectangles."""
def __init__(self, parent, name, size):
@@ -377,7 +418,7 @@ RecordType = {
0x00000022: ['EMR_RESTOREDC', EmrRestoredc],
0x00000023: ['EMR_SETWORLDTRANSFORM'],
0x00000024: ['EMR_MODIFYWORLDTRANSFORM', EmrModifyworldtransform],
- 0x00000025: ['EMR_SELECTOBJECT'],
+ 0x00000025: ['EMR_SELECTOBJECT', EmrSelectobject],
0x00000026: ['EMR_CREATEPEN'],
0x00000027: ['EMR_CREATEBRUSHINDIRECT', EmrCreatebrushindirect],
0x00000028: ['EMR_DELETEOBJECT'],
More information about the Libreoffice-commits
mailing list