1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/// The META_CHORD Record draws a chord, which is defined by a region bounded by
/// the intersection of an ellipse with a line segment. The chord is outlined
/// using the pen and filled using the brush that are defined in the playback
/// device context.
#[derive(Clone, Debug)]
pub struct META_CHORD {
/// RecordSize (4 bytes): A 32-bit unsigned integer that defines the number
/// of WORD structures, defined in [MS-DTYP] section 2.2.61, in the WMF
/// record.
pub record_size: crate::wmf::parser::RecordSize,
/// RecordFunction (2 bytes): A 16-bit unsigned integer that defines this
/// WMF record type. The lower byte MUST match the lower byte of the
/// RecordType Enumeration table value META_CHORD.
pub record_function: u16,
/// YRadial2 (2 bytes): A 16-bit signed integer that defines the
/// y-coordinate, in logical coordinates, of the endpoint of the second
/// radial.
pub y_radial2: i16,
/// XRadial2 (2 bytes): A 16-bit signed integer that defines the
/// x-coordinate, in logical coordinates, of the endpoint of the second
/// radial.
pub x_radial2: i16,
/// YRadial1 (2 bytes): A 16-bit signed integer that defines the
/// y-coordinate, in logical coordinates, of the endpoint of the first
/// radial.
pub y_radial1: i16,
/// XRadial1 (2 bytes): A 16-bit signed integer that defines the
/// x-coordinate, in logical coordinates, of the endpoint of the first
/// radial.
pub x_radial1: i16,
/// BottomRect (2 bytes): A 16-bit signed integer that defines the
/// y-coordinate, in logical units, of the lower-right corner of the
/// bounding rectangle.
pub bottom_rect: i16,
/// RightRect (2 bytes): A 16-bit signed integer that defines the
/// x-coordinate, in logical units, of the lower-right corner of the
/// bounding rectangle.
pub right_rect: i16,
/// TopRect (2 bytes): A 16-bit signed integer that defines the
/// y-coordinate, in logical units, of the upper-left corner of the
/// bounding rectangle.
pub top_rect: i16,
/// LeftRect (2 bytes): A 16-bit signed integer that defines the
/// x-coordinate, in logical units, of the upper-left corner of the
/// bounding rectangle.
pub left_rect: i16,
}
impl META_CHORD {
#[cfg_attr(feature = "tracing", tracing::instrument(
level = tracing::Level::TRACE,
skip_all,
fields(
%record_size,
record_function = %format!("{record_function:#06X}"),
),
err(level = tracing::Level::ERROR, Display),
))]
pub fn parse<R: crate::wmf::Read>(
buf: &mut R,
mut record_size: crate::wmf::parser::RecordSize,
record_function: u16,
) -> Result<Self, crate::wmf::parser::ParseError> {
crate::wmf::parser::records::check_lower_byte_matches(
record_function,
crate::wmf::parser::RecordType::META_CHORD,
)?;
let (
(y_radial2, y_radial2_bytes),
(x_radial2, x_radial2_bytes),
(y_radial1, y_radial1_bytes),
(x_radial1, x_radial1_bytes),
(bottom_rect, bottom_rect_bytes),
(right_rect, right_rect_bytes),
(top_rect, top_rect_bytes),
(left_rect, left_rect_bytes),
) = (
crate::wmf::parser::read_i16_from_le_bytes(buf)?,
crate::wmf::parser::read_i16_from_le_bytes(buf)?,
crate::wmf::parser::read_i16_from_le_bytes(buf)?,
crate::wmf::parser::read_i16_from_le_bytes(buf)?,
crate::wmf::parser::read_i16_from_le_bytes(buf)?,
crate::wmf::parser::read_i16_from_le_bytes(buf)?,
crate::wmf::parser::read_i16_from_le_bytes(buf)?,
crate::wmf::parser::read_i16_from_le_bytes(buf)?,
);
record_size.consume(
y_radial2_bytes
+ x_radial2_bytes
+ y_radial1_bytes
+ x_radial1_bytes
+ bottom_rect_bytes
+ right_rect_bytes
+ top_rect_bytes
+ left_rect_bytes,
);
crate::wmf::parser::records::consume_remaining_bytes(buf, record_size)?;
Ok(Self {
record_size,
record_function,
y_radial2,
x_radial2,
y_radial1,
x_radial1,
bottom_rect,
right_rect,
top_rect,
left_rect,
})
}
}