use crate::chart::Placed;
use crate::model::{MathNode, Picture, Span};
#[derive(Debug, Default)]
pub(crate) struct WordDoc {
pub(crate) body: Vec<Item>,
pub(crate) notes: Vec<Note>,
pub(crate) pictures: Vec<Picture>,
pub(crate) title: Option<String>,
pub(crate) body_size_pt: f32,
pub(crate) body_font: String,
}
#[derive(Debug)]
pub(crate) enum Item {
Para(Para),
Table(Table),
}
#[derive(Debug, Default)]
pub(crate) struct Para {
pub(crate) style: String,
pub(crate) outline: Option<u8>,
pub(crate) list: Option<ListMark>,
pub(crate) inlines: Vec<Inline>,
pub(crate) bookmarks: Vec<String>,
}
#[derive(Debug, Clone, PartialEq)]
pub(crate) struct ListMark {
pub(crate) level: u8,
pub(crate) marker: Option<String>,
}
#[derive(Debug)]
pub(crate) enum Inline {
Text(Span),
Math {
node: MathNode,
display: bool,
},
Picture {
index: Option<usize>,
width_pt: f32,
height_pt: f32,
alt: String,
},
Chart(Box<(Placed, Option<usize>)>),
NoteRef {
endnote: bool,
id: String,
},
}
#[derive(Debug)]
pub(crate) struct Note {
pub(crate) endnote: bool,
pub(crate) id: String,
pub(crate) body: Vec<Item>,
}
#[derive(Debug, Default)]
pub(crate) struct Table {
pub(crate) rows: Vec<Row>,
}
#[derive(Debug, Default)]
pub(crate) struct Row {
pub(crate) cells: Vec<Cell>,
pub(crate) header: bool,
}
#[derive(Debug, Default)]
pub(crate) struct Cell {
pub(crate) span: usize,
pub(crate) merge: VMerge,
pub(crate) body: Vec<Item>,
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub(crate) enum VMerge {
#[default]
None,
Restart,
Continue,
}
impl Para {
pub(crate) fn text(&self) -> String {
self.inlines
.iter()
.map(|inline| match inline {
Inline::Text(span) => span.text.clone(),
Inline::Math { node, .. } => super::omml::plain_text(node),
_ => String::new(),
})
.collect()
}
}