From 1901b2fac64f2c55103d2c0129d4857d88571f30 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 16 Nov 2026 21:54:47 -0500 Subject: [PATCH 1/3] docx: satisfy clippy's range-contains lint in the chart title guard main's gate fails here for every pull request: `!(r < 1.0 || r > 359.0)` is exactly what `manual_range_contains` rejects. Express the same range as `(1.0..=359.0).contains(&r)`. --- crates/docx/src/read/chart/plot.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/docx/src/read/chart/plot.rs b/crates/docx/src/read/chart/plot.rs index 255b1c671..d70a67734 100644 --- a/crates/docx/src/read/chart/plot.rs +++ b/crates/docx/src/read/chart/plot.rs @@ -212,7 +212,7 @@ fn title_left(c: &Chart, cat_on: bool, val_on: bool, area_w: f32) -> f32 { fn flat_title_lines(c: &Chart, area_w: f32) -> Option> { let left = if c.horizontal { &c.cat } else { &c.val }; let r = left.title_rot?.rem_euclid(360.0); - if !(r < 1.0 || r > 359.0) { + if !(1.0..=359.0).contains(&r) { return None; } let width = if area_w.is_finite() { (area_w * 0.18).max(1.0) } else { 1.0 }; From b4d17d3943f9386f9a484c0c6c2e322628c1d4a0 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 16 Nov 2026 22:03:46 -0500 Subject: [PATCH 2/3] docx: preserve horizontal axis-title rotation guard semantics --- crates/docx/src/read/chart/plot.rs | 3 ++- crates/docx/src/read/chart/tests.rs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/docx/src/read/chart/plot.rs b/crates/docx/src/read/chart/plot.rs index d70a67734..901aa9a50 100644 --- a/crates/docx/src/read/chart/plot.rs +++ b/crates/docx/src/read/chart/plot.rs @@ -212,7 +212,8 @@ fn title_left(c: &Chart, cat_on: bool, val_on: bool, area_w: f32) -> f32 { fn flat_title_lines(c: &Chart, area_w: f32) -> Option> { let left = if c.horizontal { &c.cat } else { &c.val }; let r = left.title_rot?.rem_euclid(360.0); - if !(1.0..=359.0).contains(&r) { + // Only near-zero rotations fit the horizontal strip; non-finite rotations do not. + if !r.is_finite() || (1.0..=359.0).contains(&r) { return None; } let width = if area_w.is_finite() { (area_w * 0.18).max(1.0) } else { 1.0 }; diff --git a/crates/docx/src/read/chart/tests.rs b/crates/docx/src/read/chart/tests.rs index d785d4400..1aeab5235 100644 --- a/crates/docx/src/read/chart/tests.rs +++ b/crates/docx/src/read/chart/tests.rs @@ -745,6 +745,11 @@ fn value_axis_title_turns_counter_clockwise_like_word() { assert_eq!(angle(&line_with("", &title(r#""#))), Some(90.0)); // A horizontal title (`rot="0"`) stays horizontal: the plot makes room for it (see below). assert_eq!(angle(&line_with("", &title(r#""#))), Some(0.0)); + // The horizontal tolerance excludes both boundary angles and keeps equivalent full turns. + for (rot, expected) in [(30000, 0.0), (-30000, 0.0), (60000, -90.0), (-60000, -90.0), (10800000, -90.0), (21600000, 0.0)] { + let body = format!(r#""#); + assert_eq!(angle(&line_with("", &title(&body))), Some(expected), "rotation {rot}"); + } // Hostile values stay finite. let odd = angle(&line_with("", &title(r#""#))); assert!(odd.is_some_and(f32::is_finite)); From e0e05d025bd3d380f876bec27f4aa0d9055f27ec Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 16 Nov 2026 22:35:29 -0500 Subject: [PATCH 3/3] craft-xlsx: restore the xlsb fixtures' calls to the Result-returning writer #1386 made testing::zip return craft_opc::Error and left the xlsb call sites still expecting Vec, so craft-xlsx does not compile and Workspace / gate fails on every pull request. Unwrap the fixture's error where the bytes were expected. --- crates/xlsx/tests/xlsb.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/xlsx/tests/xlsb.rs b/crates/xlsx/tests/xlsb.rs index 3611cafbb..ef1464dd4 100644 --- a/crates/xlsx/tests/xlsb.rs +++ b/crates/xlsx/tests/xlsb.rs @@ -1010,7 +1010,7 @@ const NAMES_XML: &str = r#""#; let root = r#""#; - let bytes = zip(&[("[Content_Types].xml", types.as_bytes()), ("_rels/.rels", root.as_bytes()), ("xl/workbook.xml", xml.as_bytes())]); + let bytes = zip(&[("[Content_Types].xml", types.as_bytes()), ("_rels/.rels", root.as_bytes()), ("xl/workbook.xml", xml.as_bytes())]).unwrap(); Package::open(&bytes, &Limits::default()).unwrap().workbook().unwrap().defined_names } @@ -1146,7 +1146,8 @@ fn xml_sheet(xml: &str) -> (Vec, SheetPart) { ("xl/workbook.xml", book.as_bytes()), ("xl/_rels/workbook.xml.rels", rels.as_bytes()), ("xl/sheet.xml", xml.as_bytes()), - ]); + ]) + .unwrap(); let (rows, part, _) = sizes_of(&bytes).unwrap(); (rows, part) } @@ -1256,6 +1257,7 @@ fn styled_file(styles: &[u8], types: &str) -> Vec { ("data/two.bin", &worksheet(&[], &[])), ("look/styles.bin", styles), ]) + .unwrap() } /// The styles part of a package, and the warnings reading it gave. @@ -1440,7 +1442,8 @@ fn xml_styles(xml: &str) -> Styles { ("xl/workbook.xml", br#""#), ("xl/_rels/workbook.xml.rels", rels.as_bytes()), ("xl/styles.xml", xml.as_bytes()), - ]); + ]) + .unwrap(); styles_of(&bytes).0.unwrap() } @@ -1793,7 +1796,7 @@ fn book_with_tables(data: &[u8], tables: &[Vec]) -> Vec { ("text/strings.bin", &strings), ]; entries.extend(names.iter().map(String::as_str).zip(tables.iter().map(Vec::as_slice))); - zip(&entries) + zip(&entries).unwrap() } /// Sheet one's tables through `Package`, and its warnings. @@ -1834,7 +1837,8 @@ fn a_name_using_a_structured_reference_is_decoded_after_tables_are_indexed() { ("data/two.bin", two.as_slice()), ("text/strings.bin", strings.as_slice()), ("tables/t1.bin", table.as_slice()), - ]); + ]) + .unwrap(); let names = Package::open(&bytes, &Limits::default()).unwrap().workbook().unwrap().defined_names; assert_eq!(names.iter().find(|n| n.name == "Vals").map(|n| n.formula.as_str()), Some("Sales[Val]")); let wb = read(&bytes).unwrap();