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();