From c1e7153500b8e52c369c310f3a8762ff99d9b80d Mon Sep 17 00:00:00 2001 From: P40b0s Date: Thu, 16 Jun 2022 14:03:24 +0300 Subject: [PATCH 1/3] no need Some for val=false properties --- docx-core/src/reader/run_property.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/docx-core/src/reader/run_property.rs b/docx-core/src/reader/run_property.rs index df8af7b72..473e2e380 100644 --- a/docx-core/src/reader/run_property.rs +++ b/docx-core/src/reader/run_property.rs @@ -66,19 +66,15 @@ impl ElementReader for RunProperty { } } XMLElement::Bold => { - if !read_bool(&attributes) { - rp = rp.disable_bold(); - continue; + if read_bool(&attributes) { + rp = rp.bold(); } - rp = rp.bold(); } XMLElement::Highlight => rp = rp.highlight(attributes[0].value.clone()), XMLElement::Strike => { - if !read_bool(&attributes) { - rp.strike = Some(Strike::new().disable()); - continue; + if read_bool(&attributes) { + rp = rp.strike(); } - rp = rp.strike(); } XMLElement::VertAlign => { if let Ok(v) = VertAlignType::from_str(&attributes[0].value) { @@ -100,11 +96,10 @@ impl ElementReader for RunProperty { } XMLElement::Underline => rp = rp.underline(&attributes[0].value.clone()), XMLElement::Italic => { - if !read_bool(&attributes) { - rp = rp.disable_italic(); - continue; + if read_bool(&attributes) { + rp = rp.italic(); } - rp = rp.italic(); + } XMLElement::Vanish => rp = rp.vanish(), XMLElement::TextBorder => { From b1bf99687bf3da7d54bfbb6db345b025acfdcf70 Mon Sep 17 00:00:00 2001 From: P40b0s <103313854+P40b0s@users.noreply.github.com> Date: Thu, 16 Jun 2022 17:57:39 +0300 Subject: [PATCH 2/3] Change tests for bold and italic --- docx-core/src/reader/run.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docx-core/src/reader/run.rs b/docx-core/src/reader/run.rs index b80edc2f8..340c2bc1c 100644 --- a/docx-core/src/reader/run.rs +++ b/docx-core/src/reader/run.rs @@ -253,8 +253,8 @@ mod tests { run_property: RunProperty { bold: Some(Bold::new()), bold_cs: Some(BoldCs::new()), - italic: Some(Italic::new().disable()), - italic_cs: Some(ItalicCs::new().disable()), + italic: None), + italic_cs: None), ..RunProperty::default() }, } @@ -278,8 +278,8 @@ mod tests { run_property: RunProperty { bold: Some(Bold::new()), bold_cs: Some(BoldCs::new()), - italic: Some(Italic::new().disable()), - italic_cs: Some(ItalicCs::new().disable()), + italic: None), + italic_cs: None), ..RunProperty::default() }, } From 81f54d335c4ed7ada496e15a5e2775b7214323a5 Mon Sep 17 00:00:00 2001 From: P40b0s Date: Fri, 17 Jun 2022 11:15:09 +0300 Subject: [PATCH 3/3] lost bracket, edit from phone... --- docx-core/src/reader/run.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docx-core/src/reader/run.rs b/docx-core/src/reader/run.rs index 340c2bc1c..5bb65cdae 100644 --- a/docx-core/src/reader/run.rs +++ b/docx-core/src/reader/run.rs @@ -253,8 +253,8 @@ mod tests { run_property: RunProperty { bold: Some(Bold::new()), bold_cs: Some(BoldCs::new()), - italic: None), - italic_cs: None), + italic: None, + italic_cs: None, ..RunProperty::default() }, } @@ -278,8 +278,8 @@ mod tests { run_property: RunProperty { bold: Some(Bold::new()), bold_cs: Some(BoldCs::new()), - italic: None), - italic_cs: None), + italic: None, + italic_cs: None, ..RunProperty::default() }, }