File Coverage

blib/lib/Data/ParseBinary/Graphics/WMF.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Data::ParseBinary::Graphics::WMF;
2 1     1   800 use strict;
  1         1  
  1         31  
3 1     1   5 use warnings;
  1         2  
  1         27  
4 1     1   4 use Data::ParseBinary;
  1         1  
  1         366  
5 1     1   5 use Data::ParseBinary qw{Optional GreedyRange};
  1         2  
  1         392  
6            
7             #####
8             # Windows Meta File
9             #####
10            
11             my $wmf_record = Struct("records",
12             ULInt32("size"), # size in words, including the size, function and params
13             Enum(ULInt16("function"),
14             Arc => 0x0817,
15             Chord => 0x0830,
16             Ellipse => 0x0418,
17             ExcludeClipRect => 0x0415,
18             FloodFill => 0x0419,
19             IntersectClipRect => 0x0416,
20             LineTo => 0x0213,
21             MoveTo => 0x0214,
22             OffsetClipRgn => 0x0220,
23             OffsetViewportOrg => 0x0211,
24             OffsetWindowOrg => 0x020F,
25             PatBlt => 0x061D,
26             Pie => 0x081A,
27             RealizePalette => 0x0035,
28             Rectangle => 0x041B,
29             ResizePalette => 0x0139,
30             RestoreDC => 0x0127,
31             RoundRect => 0x061C,
32             SaveDC => 0x001E,
33             ScaleViewportExt => 0x0412,
34             ScaleWindowExt => 0x0400,
35             SetBkColor => 0x0201,
36             SetBkMode => 0x0102,
37             SetMapMode => 0x0103,
38             SetMapperFlags => 0x0231,
39             SetPixel => 0x041F,
40             SetPolyFillMode => 0x0106,
41             SetROP2 => 0x0104,
42             SetStretchBltMode => 0x0107,
43             SetTextAlign => 0x012E,
44             SetTextCharacterExtra => 0x0108,
45             SetTextColor => 0x0209,
46             SetTextJustification => 0x020A,
47             SetViewportExt => 0x020E,
48             SetViewportOrg => 0x020D,
49             SetWindowExt => 0x020C,
50             SetWindowOrg => 0x020B,
51             _default_ => $DefaultPass,
52             ),
53             Array(sub { $_->ctx->{size} - 3 }, ULInt16("params")),
54             );
55            
56             my $wmf_placeable_header = Struct("placeable_header",
57             Const(ULInt32("key"), 0x9AC6CDD7),
58             ULInt16("handle"),
59             SLInt16("left"),
60             SLInt16("top"),
61             SLInt16("right"),
62             SLInt16("bottom"),
63             ULInt16("units_per_inch"),
64             Padding(4),
65             ULInt16("checksum")
66             );
67            
68             our $wmf_parser = Struct("wmf_file",
69             # --- optional placeable header ---
70             Optional($wmf_placeable_header),
71            
72             # --- header ---
73             Enum(ULInt16("type"),
74             InMemory => 0,
75             File => 1,
76             ),
77             Const(ULInt16("header_size"), 9),
78             ULInt16("version"),
79             ULInt32("size"), # file size is in words
80             ULInt16("number_of_objects"),
81             ULInt32("size_of_largest_record"),
82             ULInt16("number_of_params"),
83            
84             # --- records ---
85             GreedyRange($wmf_record)
86             );
87            
88             require Exporter;
89             our @ISA = qw(Exporter);
90             our @EXPORT = qw($wmf_parser);
91            
92             1;
93            
94             __END__