docx_reader/documents/
document_rels.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use serde::Serialize;

#[derive(Debug, Clone, PartialEq, Serialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct DocumentRels {
	pub has_comments: bool,
	pub has_numberings: bool,
	pub images: Vec<(String, String)>,
	pub hyperlinks: Vec<(String, String, String)>,
	pub custom_xml_count: usize,
	pub header_count: usize,
	pub footer_count: usize,
}

impl DocumentRels {
	pub fn new() -> DocumentRels {
		Default::default()
	}

	pub fn add_custom_item(mut self) -> Self {
		self.custom_xml_count += 1;
		self
	}

	pub fn add_image(mut self, id: impl Into<String>, path: impl Into<String>) -> Self {
		self.images.push((id.into(), path.into()));
		self
	}

	pub fn add_hyperlinks(
		mut self,
		id: impl Into<String>,
		path: impl Into<String>,
		r#type: impl Into<String>,
	) -> Self {
		self.hyperlinks
			.push((id.into(), path.into(), r#type.into()));
		self
	}
}