-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: read levelOverride * spec: update snaps
- Loading branch information
Showing
15 changed files
with
183 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use crate::documents::BuildXML; | ||
// use crate::xml_builder::*; | ||
|
||
use serde::Serialize; | ||
|
||
/* | ||
17.9.8 lvlOverride (Numbering Level Definition Override) | ||
This element specifies an optional override which shall be applied in place of zero or more levels from the abstract numbering definition for a given numbering definition instance. Each instance of this element is used to override the appearance and behavior of a given numbering level definition within the given abstract numbering definition. | ||
*/ | ||
#[derive(Debug, Clone, PartialEq, Serialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct LevelOverride { | ||
pub level: usize, | ||
pub start: Option<usize>, | ||
} | ||
|
||
impl LevelOverride { | ||
pub fn new(level: usize) -> LevelOverride { | ||
LevelOverride { level, start: None } | ||
} | ||
|
||
pub fn start(mut self, start: usize) -> LevelOverride { | ||
self.start = Some(start); | ||
self | ||
} | ||
} | ||
|
||
// TODO: Now read only | ||
impl BuildXML for LevelOverride { | ||
fn build(&self) -> Vec<u8> { | ||
vec![] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use std::io::Read; | ||
use std::str::FromStr; | ||
|
||
use xml::attribute::OwnedAttribute; | ||
use xml::reader::{EventReader, XmlEvent}; | ||
|
||
use super::*; | ||
|
||
impl ElementReader for LevelOverride { | ||
fn read<R: Read>( | ||
r: &mut EventReader<R>, | ||
attrs: &[OwnedAttribute], | ||
) -> Result<Self, ReaderError> { | ||
let mut o = LevelOverride::new(usize::from_str(&attrs[0].value)?); | ||
loop { | ||
let e = r.next(); | ||
match e { | ||
Ok(XmlEvent::StartElement { | ||
attributes, name, .. | ||
}) => { | ||
let e = XMLElement::from_str(&name.local_name).unwrap(); | ||
if let XMLElement::StartOverride = e { | ||
let val = usize::from_str(&attributes[0].value)?; | ||
o = o.start(val); | ||
continue; | ||
} | ||
} | ||
Ok(XmlEvent::EndElement { name, .. }) => { | ||
let e = XMLElement::from_str(&name.local_name).unwrap(); | ||
if e == XMLElement::LvlOverride { | ||
return Ok(o); | ||
} | ||
} | ||
Err(_) => return Err(ReaderError::XMLReadError), | ||
_ => {} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters