2019-12-06 12:18:48 +02:00
|
|
|
use super::{IndentLevel, NumberingId};
|
|
|
|
use crate::documents::BuildXML;
|
|
|
|
use crate::xml_builder::*;
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
2019-12-06 19:15:21 +02:00
|
|
|
pub struct NumberingProperty {
|
|
|
|
id: NumberingId,
|
2019-12-06 12:18:48 +02:00
|
|
|
level: IndentLevel,
|
|
|
|
}
|
|
|
|
|
2019-12-06 19:15:21 +02:00
|
|
|
impl NumberingProperty {
|
|
|
|
pub fn new(id: NumberingId, level: IndentLevel) -> NumberingProperty {
|
2019-12-06 12:18:48 +02:00
|
|
|
Self { id, level }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-06 19:15:21 +02:00
|
|
|
impl BuildXML for NumberingProperty {
|
2019-12-06 12:18:48 +02:00
|
|
|
fn build(&self) -> Vec<u8> {
|
|
|
|
let b = XMLBuilder::new();
|
|
|
|
b.open_numbering_property()
|
|
|
|
.add_child(&self.id)
|
|
|
|
.add_child(&self.level)
|
|
|
|
.close()
|
|
|
|
.build()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
|
|
|
|
use super::*;
|
|
|
|
#[cfg(test)]
|
|
|
|
use pretty_assertions::assert_eq;
|
|
|
|
use std::str;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_num_property() {
|
2019-12-06 19:15:21 +02:00
|
|
|
let c = NumberingProperty::new(NumberingId::new(0), IndentLevel::new(3));
|
2019-12-06 12:18:48 +02:00
|
|
|
let b = c.build();
|
|
|
|
assert_eq!(
|
|
|
|
str::from_utf8(&b).unwrap(),
|
2019-12-06 19:15:21 +02:00
|
|
|
r#"<w:numPr><w:numId w:val="0" /><w:ilvl w:val="3" /></w:numPr>"#
|
2019-12-06 12:18:48 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|