use super::elements::Block;
use super::style::StyleSheet;
#[derive(Debug, Clone)]
pub struct Document {
pub metadata: Metadata,
pub pages: Vec<Page>,
pub styles: StyleSheet,
}
#[derive(Debug, Clone, Default)]
pub struct Metadata {
pub title: Option<String>,
pub author: Option<String>,
pub subject: Option<String>,
pub description: Option<String>,
pub created: Option<String>,
pub modified: Option<String>,
}
#[derive(Debug, Clone)]
pub enum Page {
Flow(FlowPage),
Fixed(FixedPage),
Sheet(SheetPage),
}
#[derive(Debug, Clone, Copy)]
pub struct PageSize {
pub width: f64,
pub height: f64,
}
impl Default for PageSize {
fn default() -> Self {
Self {
width: crate::defaults::A4_WIDTH_PT,
height: crate::defaults::A4_HEIGHT_PT,
}
}
}
#[derive(Debug, Clone, Copy)]
pub struct Margins {
pub top: f64,
pub bottom: f64,
pub left: f64,
pub right: f64,
}
impl Default for Margins {
fn default() -> Self {
Self {
top: crate::defaults::DEFAULT_MARGIN_PT,
bottom: crate::defaults::DEFAULT_MARGIN_PT,
left: crate::defaults::DEFAULT_MARGIN_PT,
right: crate::defaults::DEFAULT_MARGIN_PT,
}
}
}
#[derive(Debug, Clone)]
pub struct ColumnLayout {
pub num_columns: u32,
pub spacing: f64,
pub column_widths: Option<Vec<f64>>,
}
#[derive(Debug, Clone)]
pub struct FlowPage {
pub size: PageSize,
pub margins: Margins,
pub content: Vec<Block>,
pub header: Option<super::elements::HeaderFooter>,
pub footer: Option<super::elements::HeaderFooter>,
pub columns: Option<ColumnLayout>,
}
#[derive(Debug, Clone)]
pub struct FixedPage {
pub size: PageSize,
pub elements: Vec<FixedElement>,
pub background_color: Option<super::style::Color>,
pub background_gradient: Option<super::elements::GradientFill>,
}
#[derive(Debug, Clone)]
pub struct FixedElement {
pub x: f64,
pub y: f64,
pub width: f64,
pub height: f64,
pub kind: FixedElementKind,
}
#[derive(Debug, Clone)]
pub enum FixedElementKind {
TextBox(super::elements::TextBoxData),
Image(super::elements::ImageData),
Shape(super::elements::Shape),
Table(super::elements::Table),
SmartArt(super::elements::SmartArt),
Chart(super::elements::Chart),
}
#[derive(Debug, Clone)]
pub struct SheetPage {
pub name: String,
pub size: PageSize,
pub margins: Margins,
pub table: super::elements::Table,
pub header: Option<super::elements::HeaderFooter>,
pub footer: Option<super::elements::HeaderFooter>,
pub charts: Vec<(u32, super::elements::Chart)>,
}
#[cfg(test)]
#[path = "document_tests.rs"]
mod tests;