2019-11-06 05:29:17 +02:00
|
|
|
mod build_xml;
|
2019-11-05 11:03:23 +02:00
|
|
|
mod content_types;
|
2019-11-05 12:20:40 +02:00
|
|
|
mod doc_props;
|
2019-11-07 09:08:59 +02:00
|
|
|
mod document;
|
2019-11-06 07:55:14 +02:00
|
|
|
mod elements;
|
2019-11-05 11:03:23 +02:00
|
|
|
mod rels;
|
2019-11-07 06:57:58 +02:00
|
|
|
mod styles;
|
2019-11-05 08:10:48 +02:00
|
|
|
|
2019-11-07 10:31:04 +02:00
|
|
|
pub(crate) use crate::xml_builder::*;
|
2019-11-06 07:55:14 +02:00
|
|
|
pub(crate) use build_xml::*;
|
|
|
|
|
2019-11-07 09:08:59 +02:00
|
|
|
pub use content_types::*;
|
|
|
|
pub use doc_props::*;
|
|
|
|
pub use document::*;
|
|
|
|
pub use elements::*;
|
|
|
|
pub use rels::*;
|
|
|
|
pub use styles::*;
|
2019-11-05 08:10:48 +02:00
|
|
|
|
2019-11-07 10:31:04 +02:00
|
|
|
pub struct Docx {
|
2019-11-05 08:10:48 +02:00
|
|
|
content_type: ContentTypes,
|
2019-11-05 11:03:23 +02:00
|
|
|
rels: Rels,
|
2019-11-05 12:20:40 +02:00
|
|
|
doc_props: DocProps,
|
2019-11-07 10:31:04 +02:00
|
|
|
styles: Styles,
|
|
|
|
document: Document,
|
2019-11-05 08:10:48 +02:00
|
|
|
}
|
|
|
|
|
2019-11-07 10:31:04 +02:00
|
|
|
impl Default for Docx {
|
|
|
|
fn default() -> Self {
|
2019-11-05 08:10:48 +02:00
|
|
|
let content_type = ContentTypes::new();
|
2019-11-05 11:03:23 +02:00
|
|
|
let rels = Rels::new();
|
2019-11-06 05:29:17 +02:00
|
|
|
let doc_props = DocProps::new(None, None /* TODO: */);
|
2019-11-07 10:31:04 +02:00
|
|
|
let styles = Styles::new();
|
|
|
|
let document = Document::new();
|
2019-11-07 09:08:59 +02:00
|
|
|
Docx {
|
2019-11-05 12:20:40 +02:00
|
|
|
content_type,
|
|
|
|
rels,
|
|
|
|
doc_props,
|
2019-11-07 10:31:04 +02:00
|
|
|
styles,
|
|
|
|
document,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct XMLDocx {
|
|
|
|
pub content_type: Vec<u8>,
|
|
|
|
pub rels: Vec<u8>,
|
|
|
|
pub doc_props: XMLDocProps,
|
|
|
|
pub styles: Vec<u8>,
|
|
|
|
pub document: Vec<u8>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Docx {
|
|
|
|
pub fn new() -> Docx {
|
|
|
|
Default::default()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn add_paragraph(mut self, p: Paragraph) -> Docx {
|
|
|
|
self.document = self.document.add_paragraph(p);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn build(&self) -> XMLDocx {
|
|
|
|
XMLDocx {
|
|
|
|
content_type: self.content_type.build(),
|
|
|
|
rels: self.rels.build(),
|
|
|
|
doc_props: self.doc_props.build(),
|
|
|
|
styles: self.styles.build(),
|
|
|
|
document: self.document.build(),
|
2019-11-05 12:20:40 +02:00
|
|
|
}
|
2019-11-05 08:10:48 +02:00
|
|
|
}
|
|
|
|
}
|