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 quick_xml::events::BytesStart; use std::borrow::Cow; use errors::{Error, Result}; use schema::{SCHEMA_MAIN, SCHEMA_RELATIONSHIPS}; #[derive(Debug, Default, Xml)] #[xml(event = "Start")] #[xml(tag = "w:fonts")] #[xml(extend_attrs = "font_table_extend_attrs")] pub struct FontTable<'a> { #[xml(child)] #[xml(tag = "w:font")] pub fonts: Vec<Font<'a>>, } fn font_table_extend_attrs(_: &FontTable, start: &mut BytesStart) { start.push_attribute(("xmlns:w", SCHEMA_MAIN)); start.push_attribute(("xmlns:r", SCHEMA_RELATIONSHIPS)); } #[derive(Debug, Default, Xml)] #[xml(event = "Start")] #[xml(tag = "w:font")] pub struct Font<'a> { #[xml(attr = "w:name")] pub name: Cow<'a, str>, #[xml(flatten_empty)] #[xml(tag = "w:charset")] #[xml(attr = "w:val")] pub charset: Option<Cow<'a, str>>, #[xml(flatten_empty)] #[xml(tag = "w:family")] #[xml(attr = "w:val")] pub family: Option<Cow<'a, str>>, #[xml(flatten_empty)] #[xml(tag = "w:pitch")] #[xml(attr = "w:val")] pub pitch: Option<Cow<'a, str>>, }