spreadsheet_ods/
macro_text.rs1macro_rules! text_tag {
3 ($tag:ident, $xml:literal) => {
4 #[derive(Debug)]
6 pub struct $tag {
7 xml: XmlTag,
8 }
9
10 impl From<$tag> for XmlTag {
11 fn from(t: $tag) -> XmlTag {
12 t.xml
13 }
14 }
15
16 impl Display for $tag {
17 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
18 write!(f, "{}", self.xml)
19 }
20 }
21
22 impl Default for $tag {
23 fn default() -> Self {
24 Self::new()
25 }
26 }
27
28 impl $tag {
29 pub fn new() -> Self {
31 $tag {
32 xml: XmlTag::new($xml),
33 }
34 }
35
36 pub fn tag<T: Into<XmlTag>>(mut self, tag: T) -> Self {
38 self.xml.add_tag(tag);
39 self
40 }
41
42 pub fn text<S: Into<String>>(mut self, text: S) -> Self {
44 self.xml.add_text(text);
45 self
46 }
47
48 pub fn into_xmltag(self) -> XmlTag {
50 self.xml
51 }
52 }
53 };
54}