From 9b544a4a965ee4ce80b4b9c2a262cd218ae844d8 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Sun, 25 Oct 2026 06:12:17 +0000 Subject: [PATCH] Persist current table style (CTABLESTYLE) in DXF header Found while testing crates/io/src/dxf_write.rs:1964-1970 (xrecords written) and crates/io/src/dxf_read.rs:2049-2052 (apply) Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/io/src/dxf_write/header.rs | 1 + crates/io/tests/it/tables_objects_roundtrip.rs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/io/src/dxf_write/header.rs b/crates/io/src/dxf_write/header.rs index 354c293c89..9b8c1f800c 100644 --- a/crates/io/src/dxf_write/header.rs +++ b/crates/io/src/dxf_write/header.rs @@ -19,6 +19,7 @@ const HEADER_VARS: &[(&str, i32)] = &[ ("CMLJUST", 70), ("CMLSCALE", 40), ("TEXTSTYLE", 7), + ("CTABLESTYLE", 7), ("CLAYER", 8), ("CELTYPE", 6), ("CECOLOR", 62), diff --git a/crates/io/tests/it/tables_objects_roundtrip.rs b/crates/io/tests/it/tables_objects_roundtrip.rs index 0f75e4cd3d..ec2fe77266 100644 --- a/crates/io/tests/it/tables_objects_roundtrip.rs +++ b/crates/io/tests/it/tables_objects_roundtrip.rs @@ -2,7 +2,9 @@ //! multileader styles, layout page setups, named views, UCSs and groups. use cadcraft_doc::geom::{Vec2, Vec3}; -use cadcraft_doc::{Common, DashElement, Drawing, EntityKind, Group, Line, Linetype, MLeaderStyle, NamedView, Space, TextStyle, Ucs, library}; +use cadcraft_doc::{ + Common, DashElement, Drawing, EntityKind, Group, Line, Linetype, MLeaderStyle, NamedView, Space, TableStyle, TextStyle, Ucs, library, +}; use cadcraft_io::{read_dxf, write_dxf}; fn round_trip(d: &Drawing) -> Drawing { @@ -82,6 +84,15 @@ fn multileader_styles_and_current_style_round_trip() { assert_eq!(r.header.str("CMLEADERSTYLE", ""), "Callout"); } +#[test] +fn current_table_style_round_trips() { + let mut d = Drawing::new_imperial(); + d.table_styles.push(TableStyle { name: "TS".into(), ..TableStyle::default() }); + d.header.set_str("CTABLESTYLE", "TS"); + let r = round_trip(&d); + assert_eq!(r.header.str("CTABLESTYLE", ""), "TS"); +} + #[test] fn layout_page_setup_and_paper_view_round_trip() { let mut d = Drawing::new_imperial();