From 78bd6b2b72beb1ad6620f147d03d84db6ecf2229 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 1 Nov 2026 23:46:56 +0000 Subject: [PATCH] Gap 19: a kept ODT form control made another kind saves as that kind Review fix. A button kept verbatim was still written as the button after its content control was made another kind (a check box, a list). The kept form XML is now used only while the control is still the plain text control it was read as. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GBVQLyDnrG8Tn1yDQcUabC --- crates/formats/src/odt/forms.rs | 5 +++-- crates/formats/src/odt/tests_more/forms.rs | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/crates/formats/src/odt/forms.rs b/crates/formats/src/odt/forms.rs index b34a27866f..2501cc5665 100644 --- a/crates/formats/src/odt/forms.rs +++ b/crates/formats/src/odt/forms.rs @@ -242,8 +242,9 @@ pub(in crate::odt) fn form_xml(c: &ContentControl, text: &str, id: &str, n: usiz None => (xml, w, h), } }; - // A control kept verbatim, with its new id. - if !c.form_xml.is_empty() { + // A control kept verbatim, with its new id, while it is still the control it was read as + // (made another kind, it is written as that). + if !c.form_xml.is_empty() && c.kind == (ControlKind::Text { multi_line: false }) { let end = c.form_xml.find(|ch: char| ch.is_whitespace() || ch == '>')?; let (head, rest) = (c.form_xml.get(..end)?, c.form_xml.get(end..)?); return Some(size((format!("{head} xml:id=\"{id}\" form:id=\"{id}\"{rest}"), 72.0, 20.0))); diff --git a/crates/formats/src/odt/tests_more/forms.rs b/crates/formats/src/odt/tests_more/forms.rs index f2a4574395..40b0dce3bd 100644 --- a/crates/formats/src/odt/tests_more/forms.rs +++ b/crates/formats/src/odt/tests_more/forms.rs @@ -130,6 +130,20 @@ fn buttons_are_kept() { "{c}" ); assert!(c.contains(r#"svg:width="72pt" svg:height="21.6pt" draw:control="control1""#), "{c}"); + // Made a check box, it is saved as one. + let mut c = wordcraft_doc::control::ContentControl::new(ControlKind::Text { multi_line: false }); + c.form_xml = "".into(); + let kept = crate::odt::forms::form_xml(&c, "Go", "control1", 1).unwrap().0; + assert!(kept.starts_with(r#""#), "{kept}"); + c.kind = ControlKind::CheckBox { + checked: true, + checked_char: '\u{2612}', + checked_font: String::new(), + unchecked_char: '\u{2610}', + unchecked_font: String::new(), + }; + let made = crate::odt::forms::form_xml(&c, "\u{2612}", "control1", 1).unwrap().0; + assert!(made.starts_with("