Skip to main content

rdocx_layout/
input.rs

1//! Input types for the layout engine.
2
3use std::collections::HashMap;
4
5use rdocx_oxml::core_properties::CoreProperties;
6use rdocx_oxml::document::CT_Document;
7use rdocx_oxml::footnotes::CT_Footnotes;
8use rdocx_oxml::header_footer::CT_HdrFtr;
9use rdocx_oxml::numbering::CT_Numbering;
10use rdocx_oxml::styles::CT_Styles;
11use rdocx_oxml::theme::Theme;
12
13/// Image data keyed by relationship/embed ID.
14#[derive(Debug, Clone)]
15pub struct ImageData {
16    /// Raw image bytes (PNG, JPEG, etc.).
17    pub data: Vec<u8>,
18    /// MIME content type (e.g., "image/png").
19    pub content_type: String,
20}
21
22/// Font data provided by the user or extracted from a DOCX file.
23#[derive(Debug, Clone)]
24pub struct FontFile {
25    /// Font family name (e.g., "Calibri", "Arial").
26    pub family: String,
27    /// Raw font file bytes (TTF/OTF).
28    pub data: Vec<u8>,
29}
30
31/// All inputs needed to lay out a DOCX document.
32#[derive(Debug, Clone)]
33pub struct LayoutInput {
34    /// The parsed document content.
35    pub document: CT_Document,
36    /// Style definitions.
37    pub styles: CT_Styles,
38    /// Numbering definitions (optional).
39    pub numbering: Option<CT_Numbering>,
40    /// Header parts keyed by relationship ID.
41    pub headers: HashMap<String, CT_HdrFtr>,
42    /// Footer parts keyed by relationship ID.
43    pub footers: HashMap<String, CT_HdrFtr>,
44    /// Images keyed by embed ID.
45    pub images: HashMap<String, ImageData>,
46    /// Document core properties (metadata).
47    pub core_properties: Option<CoreProperties>,
48    /// Hyperlink URLs keyed by relationship ID.
49    pub hyperlink_urls: HashMap<String, String>,
50    /// Footnote definitions.
51    pub footnotes: Option<CT_Footnotes>,
52    /// Endnote definitions.
53    pub endnotes: Option<CT_Footnotes>,
54    /// Document theme (colors + fonts).
55    pub theme: Option<Theme>,
56    /// User-provided or DOCX-embedded font files.
57    /// These are loaded before system fonts, so they take priority.
58    pub fonts: Vec<FontFile>,
59}