docx_reader/documents/
taskpanes_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
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
pub struct TaskpanesRels {
	pub rels: Vec<(String, String, String)>,
}

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

	pub fn add_rel(mut self) -> Self {
		let index = self.rels.len() + 1;
		self.rels.push((
			"http://schemas.microsoft.com/office/2011/relationships/webextension".to_string(),
			format!("rId{}", index),
			format!("webextension{}.xml", index),
		));
		self
	}

	pub fn find_target(&self, rel_type: &str) -> Option<&(String, String, String)> {
		self.rels.iter().find(|rel| rel.0 == rel_type)
	}
}

impl Default for TaskpanesRels {
	fn default() -> Self {
		TaskpanesRels { rels: Vec::new() }
	}
}