use std::rc::Rc;
use f_office_units::{Edges, Length};
use f_office_xml::enumeration::{Values, another, own};
use f_office_xml::{Document, NodeId};
use super::links::{Hyperlink, LinkMark};
use super::{BufferOnly, Content, InlineDrawing, NoteId, Paragraph, Run, shown_branch};
use crate::ns::{MC, R, W, W14, W16SE, WP};
use crate::numbers;
use crate::on_off;
use crate::params::{
HYPERLINK_FIELD_EXTRA_LENGTH, HYPERLINK_HISTORY_OFF_LENGTH, TEXT_BUFFER_MARK_LENGTH,
};
use crate::picture::Picture;
use crate::props::{
Color, FontRef, ListRef, MathScript, ParaProps, RunProps, Strike, TabKind, Underline,
};
use crate::reader::PartReader;
use crate::source_span::SourceSpan;
use crate::warnings::{Drawing, Feature, Reason};
pub(super) fn read_paragraph(reader: &mut PartReader, node: NodeId) -> Paragraph {
let doc = reader.doc;
let mut paragraph = Paragraph {
id: reader.paragraph_id(),
props: ParaProps::default(),
runs: Vec::new(),
source: SourceSpan::of(doc, node),
};
for ppr in doc
.child_elements(node)
.filter(|child| doc.is(*child, W, "pPr"))
{
paragraph.props.read_into(reader, ppr);
if doc.child(ppr, W, "pPrChange").is_some() {
paragraph.props.mark.changed = Some(true);
}
}
let alone = crate::math::holds_only_equations(doc, node);
let display = alone || crate::math::is_display(doc, node);
let labeled = display
&& reader
.list_of(¶graph.props)
.and_then(ListRef::id)
.is_some();
let equations = if labeled {
Equations::Inline
} else if alone {
Equations::Display
} else {
Equations::AsWritten
};
collect_runs(reader, node, equations, &mut paragraph.runs);
if display && !labeled {
paragraph.props.alignment = Some(crate::math::display_alignment(reader, node));
paragraph.props.indent_first = Some(Length::ZERO);
}
paragraph
}
pub(super) fn bookmark_run(doc: &Document, node: NodeId) -> Option<Run> {
let name = doc.attribute(node, Some(W), "name")?;
Some(Run {
content: vec![Content::Bookmark(name.to_owned())],
..Run::default()
})
}
#[derive(Clone, Copy)]
enum Equations {
AsWritten,
Display,
Inline,
}
impl Equations {
fn script(self, display: bool) -> MathScript {
match self {
Self::AsWritten if display => MathScript::display(),
Self::Display => MathScript::display(),
Self::AsWritten | Self::Inline => MathScript::default(),
}
}
}
fn collect_runs(reader: &mut PartReader, node: NodeId, equations: Equations, runs: &mut Vec<Run>) {
let doc = reader.doc;
let nested = |reader: &mut PartReader, child, runs: &mut Vec<Run>| {
collect_runs(reader, child, Equations::AsWritten, runs);
};
let mut after_equation = false;
for child in doc.child_elements(node) {
let local = doc.element(child).map_or("", |e| e.name.local);
if let Some(wrapper) = RunWrapper::of(local) {
collect_wrapped(reader, (child, local), wrapper, runs);
after_equation = false;
continue;
}
let drawn = runs.len();
match local {
"r" => runs.extend(read_run(reader, child)),
"br" => runs.push(Run {
content: vec![read_break(reader, child)],
..Run::default()
}),
"AlternateContent" if doc.is(child, MC, "AlternateContent") => {
if let Some(branch) = shown_branch(reader, child) {
nested(reader, branch, runs);
}
}
"bookmarkStart" => runs.extend(bookmark_run(doc, child)),
"oMath" | "oMathPara" if doc.is(child, crate::ns::M, local) => {
let script = equations.script(local == "oMathPara");
crate::math::read(reader, child, (script, after_equation), runs);
after_equation = local == "oMath";
continue;
}
"fldSimple" => {
let code = doc.attribute(child, Some(W), "instr").unwrap_or("");
let marker = |content: Vec<Content>| Run {
content,
..Run::default()
};
let mut begin = vec![Content::FieldBegin];
begin.extend(field_locked(doc, child).then_some(Content::FieldLock));
begin.extend([Content::FieldCode(code.to_owned()), Content::FieldSeparate]);
runs.push(marker(begin));
nested(reader, child, runs);
runs.push(marker(vec![Content::FieldEnd]));
}
"dir" | "bdo" if doc.is(child, W, local) => {
reader.feature_not_supported(Feature::BidirectionalEmbedding);
}
_ => {}
}
after_equation &= runs.len() == drawn;
}
}
fn collect_wrapped(
reader: &mut PartReader,
(node, local): (NodeId, &str),
wrapper: RunWrapper,
runs: &mut Vec<Run>,
) {
let doc = reader.doc;
let control = local == "sdt";
if control {
runs.push(Run {
content: vec![Content::ControlEdge],
..mark_run(TEXT_BUFFER_MARK_LENGTH, 1)
});
}
let start = runs.len();
read_wrapped(doc, node, wrapper, runs, |runs| {
collect_runs(reader, node, Equations::AsWritten, runs);
});
mark_hyperlink_edges(doc, (node, local), start, runs);
if control {
for run in runs.get_mut(start..).unwrap_or_default() {
run.buffer_only.open += 1;
run.buffer_only.held += 1;
}
runs.push(Run {
content: vec![Content::ControlEdge],
..mark_run(TEXT_BUFFER_MARK_LENGTH, 0)
});
}
}
fn buffered(doc: &Document, node: NodeId) -> Option<usize> {
doc.attribute(node, Some(crate::ns::NOTE), "buffered")
.and_then(|value| value.parse().ok())
}
fn mark_run(characters: usize, open: usize) -> Run {
Run {
buffer_only: BufferOnly {
characters,
open,
..BufferOnly::default()
},
..Run::default()
}
}
fn mark_hyperlink_edges(
doc: &Document,
(node, local): (NodeId, &str),
start: usize,
runs: &mut Vec<Run>,
) {
if local != "hyperlink" {
return;
}
let edge = |buffer_only| Run {
content: vec![Content::HyperlinkEdge],
buffer_only,
..Run::default()
};
let start = start.min(runs.len());
runs.insert(
start,
Run {
buffer_only: hyperlink_field_start(doc, node),
links: vec![LinkMark::Start(Box::new(Hyperlink::of_element(doc, node)))],
..Run::default()
},
);
runs.insert(
start,
edge(BufferOnly {
characters: TEXT_BUFFER_MARK_LENGTH + HYPERLINK_FIELD_EXTRA_LENGTH,
..BufferOnly::default()
}),
);
runs.push(Run {
links: vec![LinkMark::End],
..edge(BufferOnly {
characters: TEXT_BUFFER_MARK_LENGTH,
..BufferOnly::default()
})
});
}
fn hyperlink_field_start(doc: &Document, node: NodeId) -> BufferOnly {
let utf16 = crate::buffers::characters;
let value = |name: &str| doc.attribute(node, Some(W), name);
let relationship = doc.attribute(node, Some(R), "id").map(str::to_owned);
let mut code = utf16("HYPERLINK");
if relationship.is_some() {
code += utf16(" \"\"");
}
for (switch, name) in [
("l", "anchor"),
("o", "tooltip"),
("t", "tgtFrame"),
("l", "docLocation"),
] {
if let Some(text) = value(name) {
code += utf16(&format!(" \\{switch} \"{text}\""));
}
}
if value("history").is_none_or(|history| on_off::read(history) != Some(true)) {
code += HYPERLINK_HISTORY_OFF_LENGTH;
}
BufferOnly {
characters: code + TEXT_BUFFER_MARK_LENGTH,
relationship,
..BufferOnly::default()
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum RunWrapper {
Change { removed: bool },
Container,
}
impl RunWrapper {
pub(crate) fn of(local: &str) -> Option<Self> {
match local {
"ins" | "del" | "moveFrom" | "moveTo" => Some(Self::Change {
removed: crate::revisions::REMOVED.contains(&local),
}),
"hyperlink" | "smartTag" | "customXml" | "sdt" | "sdtContent" => Some(Self::Container),
_ => None,
}
}
}
pub(crate) fn read_wrapped(
doc: &Document,
node: NodeId,
wrapper: RunWrapper,
runs: &mut Vec<Run>,
read: impl FnOnce(&mut Vec<Run>),
) {
let start = runs.len();
read(runs);
if let RunWrapper::Change { removed } = wrapper {
let author = doc.attribute(node, Some(W), "author").unwrap_or("");
for run in runs.get_mut(start..).unwrap_or_default() {
mark_change(&mut run.props, author, removed);
}
}
}
use crate::params::{AUTHOR_COLORS, FNV_32};
fn mark_change(props: &mut RunProps, author: &str, removed: bool) {
props.color = Some(Color::Rgb(author_color(author)));
props.changed = Some(true);
if removed {
props.strike = Some(Strike::Single);
} else {
props.underline = Some(Underline::Single);
}
}
pub(crate) fn author_color(author: &str) -> [u8; 3] {
let (basis, prime) = FNV_32;
let hash = author.bytes().fold(basis, |hash, byte| {
(hash ^ u32::from(byte)).wrapping_mul(prime)
});
let index = usize::try_from(hash).unwrap_or(0) % AUTHOR_COLORS.len();
AUTHOR_COLORS.get(index).copied().unwrap_or_default()
}
fn read_run(reader: &mut PartReader, node: NodeId) -> Vec<Run> {
let doc = reader.doc;
let mut runs = Vec::new();
let mut revision = |name: &str| reader.hex(node, name, numbers::LONG_HEX);
let change = doc
.attribute(node, Some(crate::ns::NOTE), "change")
.and_then(|value| value.parse().ok());
let mut run = Run {
revisions: [revision("rsidR"), revision("rsidRPr"), change],
starts_buffer: false,
..Run::default()
};
if doc
.attribute(node, Some(crate::ns::NOTE), "removed")
.is_some()
{
run.content.push(Content::RemovedEdge);
}
run.buffer_only.characters = buffered(doc, node).unwrap_or(0);
for child in doc.child_elements(node) {
if doc.is(child, W, "sym") {
let Some(symbol) = read_symbol(reader, child, &run) else {
continue;
};
let rest = run.part(run.props.clone(), Vec::new());
let before = std::mem::replace(&mut run, rest);
if !before.content.is_empty() {
runs.push(before);
}
runs.push(symbol);
} else {
read_run_child(reader, child, &mut runs, &mut run);
}
}
if !run.content.is_empty() || runs.is_empty() {
runs.push(run);
}
runs
}
fn read_symbol(reader: &mut PartReader, node: NodeId, run: &Run) -> Option<Run> {
let doc = reader.doc;
let ch = reader
.hex(node, "char", numbers::SHORT_HEX)
.and_then(char::from_u32)?;
let mut props = run.props.clone();
if let Some(font) = doc.attribute(node, Some(W), "font") {
let font = Some(FontRef::Name(font.to_owned()));
props.font_ascii.clone_from(&font);
props.font_hansi = font;
}
Some(run.part(props, vec![Content::Text(ch.to_string())]))
}
fn read_run_props(reader: &mut PartReader, child: NodeId, runs: &mut Vec<Run>, run: &mut Run) {
let doc = reader.doc;
if run
.content
.iter()
.any(|content| !matches!(content, Content::RemovedEdge))
{
let rest = run.part(run.props.clone(), Vec::new());
runs.push(std::mem::replace(run, rest));
}
run.props.read_into(reader, child);
run.record.read_into(doc, child);
if let Some(style) = doc
.child(child, W, "rStyle")
.and_then(|s| doc.attribute(s, Some(W), "val"))
{
run.style = Some(style.to_owned());
}
}
fn read_run_child(reader: &mut PartReader, child: NodeId, runs: &mut Vec<Run>, run: &mut Run) {
let doc = reader.doc;
{
let Some(element) = doc.element(child) else {
return;
};
let local = element.name.local;
match local {
"AlternateContent" if doc.is(child, MC, "AlternateContent") => {
let branch = shown_branch(reader, child);
for inner in branch.into_iter().flat_map(|b| doc.child_elements(b)) {
read_run_child(reader, inner, runs, run);
}
}
"rPr" => read_run_props(reader, child, runs, run),
"t" | "delText" => push_text(
run,
&compose_marks(&doc.text_content(child).replace(['\n', '\r'], " ")),
),
"noBreakHyphen" => push_text(run, &crate::text::NON_BREAKING_HYPHEN.to_string()),
"softHyphen" => push_text(run, &crate::text::SOFT_HYPHEN.to_string()),
"tab" => run.content.push(Content::Tab),
"ptab" => run.content.push(Content::PositionTab {
kind: reader
.enumeration(child, "alignment", PTAB_ALIGNMENT)
.unwrap_or(TabKind::Left),
leader: reader.enumeration(child, "leader", PTAB_LEADER).flatten(),
}),
"cr" => run.content.push(Content::LineBreak),
"br" => run.content.push(read_break(reader, child)),
"instrText" | "delInstrText" => run
.content
.push(Content::FieldCode(doc.text_content(child))),
"pict" | "object" => run.content.extend(crate::vml::read(reader, child)),
"contentPart" if doc.is(child, W14, "contentPart") => {
reader.drawing_skipped(Drawing::Shape, Reason::Unsupported);
}
"symEx" if doc.is(child, W16SE, "symEx") => {
reader.feature_not_supported(Feature::SymbolExtension);
}
"drawing" => {
run.content.extend(read_inline(reader, child));
run.content.extend(
crate::floating::read_anchor(reader, child)
.map(|floating| Content::Floating(Box::new(floating))),
);
}
"footnoteReference" => run.content.extend(NoteId::read(reader, child).map(|id| {
reader.note_reference(crate::NoteKind::Footnote, id);
Content::FootnoteReference(id, super::NoteMark::read(doc, child))
})),
"footnoteRef" => run.content.push(Content::FootnoteMark),
"commentReference" => run.content.extend(
doc.attribute(child, Some(W), "id")
.map(|id| Content::CommentAnchor(id.to_owned())),
),
"endnoteReference" => run.content.extend(NoteId::read(reader, child).map(|id| {
reader.note_reference(crate::NoteKind::Endnote, id);
Content::EndnoteReference(id, super::NoteMark::read(doc, child))
})),
"endnoteRef" => run.content.push(Content::EndnoteMark),
"annotationRef" => run.content.push(Content::CommentMark),
"separator" => run.content.push(Content::Separator),
"continuationSeparator" => run.content.push(Content::ContinuationSeparator),
"fldChar" => match reader.enumeration(child, "fldCharType", FIELD_CHAR) {
Some(FieldChar::Begin) => {
run.content.push(Content::FieldBegin);
if field_locked(doc, child) {
run.content.push(Content::FieldLock);
}
run.content
.extend(read_check_box(reader, child).map(Content::CheckBox));
run.content
.extend(read_drop_down(reader, child).map(Content::DropDown));
}
Some(FieldChar::Separate) => run.content.push(Content::FieldSeparate),
Some(FieldChar::End) => run.content.push(Content::FieldEnd),
None => {}
},
_ => warn_of_left_out_run_child(reader, child, local),
}
}
}
const WARNED_RUN_CHILDREN: [(&str, Feature); 8] = [
("ruby", Feature::Ruby),
("pgNum", Feature::PageNumberElement),
("dayShort", Feature::DateBlock),
("dayLong", Feature::DateBlock),
("monthShort", Feature::DateBlock),
("monthLong", Feature::DateBlock),
("yearShort", Feature::DateBlock),
("yearLong", Feature::DateBlock),
];
fn warn_of_left_out_run_child(reader: &mut PartReader, child: NodeId, local: &str) {
let feature = WARNED_RUN_CHILDREN
.iter()
.find(|(name, _)| *name == local)
.map(|&(_, feature)| feature);
if let Some(feature) = feature.filter(|_| reader.doc.is(child, W, local)) {
reader.feature_not_supported(feature);
}
}
fn field_locked(doc: &Document, node: NodeId) -> bool {
doc.attribute(node, Some(W), "fldLock")
.is_some_and(|value| on_off::read(value) == Some(true))
}
fn read_check_box(reader: &mut PartReader, begin: NodeId) -> Option<super::CheckBox> {
let doc = reader.doc;
let check_box = doc.child(doc.child(begin, W, "ffData")?, W, "checkBox")?;
let on = |name: &str| {
doc.child(check_box, W, name)
.map(|node| on_off::element(doc, node, W))
};
let size = doc
.child(check_box, W, "size")
.and_then(|node| reader.half_points(node, "val"));
Some(super::CheckBox {
size,
checked: on("checked").or_else(|| on("default")).unwrap_or(false),
})
}
fn read_drop_down(reader: &mut PartReader, begin: NodeId) -> Option<String> {
let doc = reader.doc;
let list = doc.child(doc.child(begin, W, "ffData")?, W, "ddList")?;
let entries: Vec<&str> = doc
.children(list)
.iter()
.filter(|&&node| doc.is(node, W, "listEntry"))
.filter_map(|&node| crate::reader::val(doc, node))
.collect();
let range = numbers::indices(entries.len());
let mut index = |name: &str| {
let node = doc.child(list, W, name)?;
reader.number::<usize>(node, "val", range.clone())
};
let selected = index("result").or_else(|| index("default")).unwrap_or(0);
entries.get(selected).map(|entry| (*entry).to_owned())
}
fn read_inline(reader: &mut PartReader, drawing: NodeId) -> Option<Content> {
let doc = reader.doc;
let inline = doc.child(drawing, WP, "inline")?;
let (
[cx, cy],
Edges {
left,
top,
right,
bottom,
},
) = crate::floating::extents(reader, inline);
let rotation = crate::picture::rotation(doc, inline);
let (box_width, box_height) = reader.turned_pictures().turned_box((cx, cy), rotation);
let width = (box_width + left + right).max(Length::ZERO);
let height = (box_height + top + bottom).max(Length::ZERO);
let frame_left = left + (box_width - cx).div_round(2);
let frame_top = top + (box_height - cy).div_round(2);
let picture = Edges::placed(frame_left, frame_top, cx, cy)
.and_then(|frame| Picture::read(reader, inline, frame));
let shape = picture
.is_none()
.then(|| crate::floating::read_inline_shape(reader, inline, cx, cy))
.flatten()
.map(|shape| InlineDrawing {
width,
height,
left,
top,
shape,
drops: false,
anchor_locked: false,
extent: Some(cy),
});
Some(match shape {
Some(drawing) => Content::Drawing(Rc::new(drawing)),
None => Content::Object {
width,
height,
picture: picture.map(Box::new),
extent: Some(box_height),
},
})
}
fn compose_marks(text: &str) -> String {
let mut out = String::with_capacity(text.len());
let mut last: Option<char> = None;
for ch in text.chars() {
if let Some(previous) = last {
let mark = unicode_normalization::char::canonical_combining_class(ch) > 0;
if let Some(composed) =
unicode_normalization::char::compose(previous, ch).filter(|_| mark)
{
last = Some(composed);
continue;
}
out.push(previous);
}
last = Some(ch);
}
out.extend(last);
out
}
fn push_text(run: &mut Run, text: &str) {
if let Some(Content::Text(existing)) = run.content.last_mut() {
existing.push_str(text);
} else {
run.content.push(Content::Text(text.to_owned()));
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(super) enum BreakKind {
Page,
Column,
TextWrapping,
}
pub(super) const BREAK_KIND: &Values<BreakKind> = &Values::new(&[
own("page", BreakKind::Page),
own("column", BreakKind::Column),
own("textWrapping", BreakKind::TextWrapping),
]);
pub(super) const BREAK_CLEAR: &Values<bool> = &Values::new(&[
own("none", false),
another("left", false),
another("right", false),
own("all", true),
]);
fn read_break(reader: &mut PartReader, node: NodeId) -> Content {
match reader.enumeration(node, "type", BREAK_KIND) {
Some(BreakKind::Page) => Content::PageBreak,
Some(BreakKind::Column) => Content::ColumnBreak,
_ if reader.enumeration(node, "clear", BREAK_CLEAR) == Some(true) => Content::ClearingBreak,
_ => Content::LineBreak,
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum FieldChar {
Begin,
Separate,
End,
}
pub(crate) const FIELD_CHAR: &Values<FieldChar> = &Values::new(&[
own("begin", FieldChar::Begin),
own("separate", FieldChar::Separate),
own("end", FieldChar::End),
]);
pub(super) const PTAB_LEADER: &Values<Option<char>> = &Values::new(&[
own("none", None),
own("dot", Some('.')),
own("hyphen", Some('-')),
own("underscore", Some('_')),
own("middleDot", Some('\u{b7}')),
]);
pub(super) const PTAB_ALIGNMENT: &Values<TabKind> = &Values::new(&[
own("left", TabKind::Left),
own("center", TabKind::Center),
own("right", TabKind::Right),
]);
#[cfg(test)]
mod tests {
use f_office_units::Length;
use f_office_xml::{Document, Limits};
use super::{read_inline, read_paragraph};
use crate::body::Content;
use crate::ns::{W, WP};
use crate::props::{Alignment, ListLevel, ListRef};
use crate::reader::PartReader;
#[test]
fn merges_multiple_ppr_siblings_with_later_overriding_earlier() {
let xml = format!(
concat!(
r#"<w:p xmlns:w="{w}">"#,
r#"<w:pPr><w:numPr><w:ilvl w:val="0"/><w:numId w:val="1"/></w:numPr><w:ind w:left="720"/></w:pPr>"#,
r#"<w:pPr><w:numPr><w:ilvl w:val="1"/><w:numId w:val="2"/></w:numPr><w:jc w:val="right"/><w:spacing w:after="240"/></w:pPr>"#,
r#"<w:r><w:t>text</w:t></w:r></w:p>"#,
),
w = W
);
let doc = Document::parse(xml.as_bytes(), &Limits::default()).unwrap();
let paragraph = read_paragraph(&mut PartReader::new(&doc), doc.root().unwrap());
assert_eq!(
paragraph.props.numbering,
Some(ListRef::Id(std::num::NonZeroU32::new(2).unwrap()))
);
assert_eq!(paragraph.props.numbering_level, Some(ListLevel::At(1)));
assert_eq!(paragraph.props.indent_left, Length::from_twips(720));
assert_eq!(paragraph.props.alignment, Some(Alignment::End));
assert_eq!(
paragraph.props.space_after(),
Length::from_twips(240).unwrap()
);
}
#[test]
fn merges_leading_rpr_siblings_and_splits_run_on_later_rpr() {
let xml = format!(
concat!(
r#"<w:p xmlns:w="{w}">"#,
r#"<w:r><w:t>P2</w:t><w:rPr><w:sz w:val="48"/></w:rPr></w:r>"#,
r#"<w:r><w:rPr><w:rStyle w:val="PlainBlue"/><w:sz w:val="36"/></w:rPr>"#,
r#"<w:rPr><w:sz w:val="48"/></w:rPr><w:t>P5</w:t></w:r>"#,
r#"<w:r><w:lastRenderedPageBreak/><w:rPr><w:sz w:val="48"/></w:rPr><w:t>P8</w:t></w:r>"#,
r#"<w:r><w:t>A</w:t><w:rPr><w:sz w:val="48"/></w:rPr><w:t>B</w:t></w:r>"#,
r#"</w:p>"#,
),
w = W
);
let doc = Document::parse(xml.as_bytes(), &Limits::default()).unwrap();
let paragraph = read_paragraph(&mut PartReader::new(&doc), doc.root().unwrap());
let got: Vec<_> = paragraph
.runs
.iter()
.map(|r| (&r.content[..], r.style.as_deref(), r.props.size))
.collect();
let text = |s: &str| [Content::Text(s.to_owned())];
let expected = [
(text("P2"), None, None),
(text("P5"), Some("PlainBlue"), Some(48)),
(text("P8"), None, Some(48)),
(text("A"), None, None),
(text("B"), None, Some(48)),
];
let expected: Vec<_> = expected
.iter()
.map(|(c, style, size)| (&c[..], *style, *size))
.collect();
assert_eq!(got, expected);
}
#[test]
fn sizes_an_inline_drawing_whose_extents_add_up_beyond_the_range_of_a_length() {
let most = f_office_drawingml::COORDINATE_LIMIT;
let xml = format!(
r#"<w:drawing xmlns:w="{W}" xmlns:wp="{WP}"><wp:inline><wp:extent cx="{most}" cy="914400"/><wp:effectExtent l="{most}" t="0" r="{most}" b="0"/></wp:inline></w:drawing>"#
);
let doc = Document::parse(xml.as_bytes(), &Limits::default()).unwrap();
let drawing = read_inline(&mut PartReader::new(&doc), doc.root().unwrap());
let Some(Content::Object { width, height, .. }) = drawing else {
panic!("{drawing:?}");
};
assert_eq!(width, Length::from_emus(most).unwrap() * 3);
assert_eq!(height, Length::from_emus(914_400).unwrap());
}
}