From e1cd8b5e01cd649d1527a8e9d5393f2563c79d94 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sat, 14 Nov 2026 18:58:38 +0100 Subject: [PATCH] docx: no_fill wins over a stored series colour Co-Authored-By: Claude Sonnet 5.5 --- crates/docx/src/chart_spec.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/docx/src/chart_spec.rs b/crates/docx/src/chart_spec.rs index 167be6b0d..a090c5c96 100644 --- a/crates/docx/src/chart_spec.rs +++ b/crates/docx/src/chart_spec.rs @@ -282,13 +282,14 @@ fn series_props(w: &mut W, s: &ChartSeries) { } w.open("c:spPr", &[]); if fill_set { + // "No fill" wins over a stored colour, so the pair reads back as it was written. match &s.fill { - Some(c) => { + Some(c) if !s.no_fill => { w.open("a:solidFill", &[]); w.empty("a:srgbClr", &[("val", &c.hex())]); w.close("a:solidFill"); } - None => w.empty("a:noFill", &[]), + _ => w.empty("a:noFill", &[]), } } if ln_set { @@ -677,6 +678,18 @@ mod tests { assert_eq!(spec_of(&parse(&plain)), Some(plain)); } + #[test] + fn no_fill_wins_over_a_stored_colour() { + let mut spec = ChartSpec::sample(ChartType::Column); + spec.series[0].fill = Some(Rgb(255, 0, 0)); + spec.series[0].no_fill = true; + let x = chart_xml(&spec); + assert!(!x.contains("FF0000"), "colour written next to no_fill"); + let back = spec_of(&parse(&spec)).expect("stays editable"); + assert!(back.series[0].no_fill); + assert_eq!(back.series[0].fill, None); + } + #[test] fn an_axis_format_is_limited_in_characters_not_bytes() { use craft_wordmodel::chart::MAX_FMT;