diff --git a/crates/doc/src/settings.rs b/crates/doc/src/settings.rs index 1fd4e598dd..dee3ac282b 100644 --- a/crates/doc/src/settings.rs +++ b/crates/doc/src/settings.rs @@ -183,6 +183,13 @@ pub struct Settings { /// comments and tracked changes are saved without `w:date`. #[serde(skip_serializing_if = "std::ops::Not::not")] pub remove_date_time: bool, + /// Hide spelling errors in this document only (`w:hideSpellingErrors`): no squiggles under + /// misspelled words. + #[serde(skip_serializing_if = "std::ops::Not::not")] + pub hide_spelling_errors: bool, + /// Hide grammar errors in this document only (`w:hideGrammaticalErrors`). + #[serde(skip_serializing_if = "std::ops::Not::not")] + pub hide_grammar_errors: bool, /// The document was opened from ODF: the standard's rules that differ from Word's apply as /// it is laid out. #[serde(skip_serializing_if = "Option::is_none")] @@ -349,6 +356,8 @@ impl Default for Settings { zoom: None, remove_personal_info: false, remove_date_time: false, + hide_spelling_errors: false, + hide_grammar_errors: false, odf: None, } } diff --git a/crates/docx/tests/it/fixtures.rs b/crates/docx/tests/it/fixtures.rs index 37de5afb9f..5663f751dd 100644 --- a/crates/docx/tests/it/fixtures.rs +++ b/crates/docx/tests/it/fixtures.rs @@ -4781,3 +4781,20 @@ fn vml_horizontal_rules_are_read_and_kept() { let d = read_body(&body); assert_eq!(rules(&d).iter().map(|r| r.0).collect::>(), [None, None]); } + +#[test] +fn hide_spelling_and_grammar_errors_survive_a_save() { + let settings_xml = |d: &Document| { + let bytes = wordcraft_docx::write(d).unwrap(); + let mut z = craft_zip::Archive::open(&bytes, craft_zip::Limits { max_entries: 10_000, max_total_bytes: 64 << 20 }).unwrap(); + String::from_utf8(z.read("word/settings.xml", 16 << 20).unwrap().unwrap()).unwrap() + }; + let d = with_settings(Some("")); + let saved = settings_xml(&d); + assert!(saved.contains(""#), "cycle {cycle}: {xml}"); assert!(xml.contains(r#"w:chapStyle="1" w:chapSep="hyphen""#), "cycle {cycle}: {xml}"); assert!(xml.contains(r#"w:chapStyle="10" w:chapSep="colon""#), "cycle {cycle}: {xml}"); - assert!(xml.contains("xmlns:w15=") && xml.contains("mc:Ignorable=\"w14 w15 w16du wp14\""), "cycle {cycle}: {xml}"); + assert!(xml.contains("xmlns:w15=") && xml.contains("mc:Ignorable=\"w14 w15 wp14 w16du\""), "cycle {cycle}: {xml}"); document = wordcraft_docx::read(&bytes).unwrap(); let json = serde_json::to_vec(&document).unwrap(); document = serde_json::from_slice(&json).unwrap();