Skip to main content

docx_rs/documents/elements/
q_format.rs

1use crate::documents::BuildXML;
2use crate::xml_builder::*;
3use std::io::Write;
4
5//17.7.4.14
6// qFormat (Primary Style)
7// This element specifies whether this style shall be treated as a primary style when this document is loaded by an
8// application. If this element is set, then this style has been designated as being particularly important for the
9// current document, and this information can be used by an application in any means desired. [Note: This setting
10// 637ECMA-376 Part 1 does not imply any behavior for the style, only that the style is of particular significance for this document. end note]
11#[derive(Default)]
12pub struct QFormat {}
13
14impl QFormat {
15    pub fn new() -> QFormat {
16        Default::default()
17    }
18}
19
20impl BuildXML for QFormat {
21    fn build_to<W: Write>(
22        &self,
23        stream: xml::writer::EventWriter<W>,
24    ) -> xml::writer::Result<xml::writer::EventWriter<W>> {
25        XMLBuilder::from(stream).q_format()?.into_inner()
26    }
27}
28
29#[cfg(test)]
30mod tests {
31
32    use super::*;
33    #[cfg(test)]
34    use pretty_assertions::assert_eq;
35    use std::str;
36
37    #[test]
38    fn test_q_format() {
39        let c = QFormat::new();
40        let b = c.build();
41        assert_eq!(str::from_utf8(&b).unwrap(), r#"<w:qFormat />"#);
42    }
43}