From 35229a6409273182308160457bbcd8b83badd862 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Mon, 12 Oct 2026 16:18:25 -0400 Subject: [PATCH] Tables: DeckCraft's own table styles still map back to their ids Co-Authored-By: Claude Opus 5.5 (1M context) --- crates/pptx/src/read/shapes.rs | 7 ++++++- crates/pptx/src/tables.rs | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/pptx/src/read/shapes.rs b/crates/pptx/src/read/shapes.rs index a7769a5a..0c454255 100644 --- a/crates/pptx/src/read/shapes.rs +++ b/crates/pptx/src/read/shapes.rs @@ -402,8 +402,13 @@ fn table(imp: &mut Imp, part: &Part, tbl: &El) -> Table { t.band_col = pr.bool("bandCol").unwrap_or(false); if let Some(id) = pr.child("tableStyleId").map(|e| e.text()) { // A style the file defines is drawn from its definition (by its GUID). + // DeckCraft's own styles (written with GUIDs derived from their ids) map back to them. let up = id.trim().to_ascii_uppercase(); - t.style = if imp.table_style_ids.contains(&up) { up } else { crate::tables::style_from_guid(id.trim()) }; + t.style = if imp.table_style_ids.contains(&up) && !crate::tables::is_own_guid(&up) { + up + } else { + crate::tables::style_from_guid(id.trim()) + }; } } t.cols = tbl diff --git a/crates/pptx/src/tables.rs b/crates/pptx/src/tables.rs index 06401254..24b011c3 100644 --- a/crates/pptx/src/tables.rs +++ b/crates/pptx/src/tables.rs @@ -47,6 +47,12 @@ fn own_guid(style: &str) -> String { guid(&format!("deckcraft-table-style:{style}")) } +/// Is `g` the GUID DeckCraft writes for one of its own styles? +pub fn is_own_guid(g: &str) -> bool { + let up = g.to_ascii_uppercase(); + deckcraft_model::table::table_styles().iter().any(|(id, _)| own_guid(id) == up) +} + /// Table style GUID → our style id (or the GUID itself when unknown). pub fn style_from_guid(g: &str) -> String { let up = g.to_ascii_uppercase();