From d9cfc992a79e9f6b3ecce30d6efaca752de57b06 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 13 Nov 2026 04:53:22 -0500 Subject: [PATCH] Use shared IDML page item kind and geometry --- crates/idml/src/import/item.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/crates/idml/src/import/item.rs b/crates/idml/src/import/item.rs index 36b26b62c..6954396e3 100644 --- a/crates/idml/src/import/item.rs +++ b/crates/idml/src/import/item.rs @@ -34,13 +34,14 @@ fn svg_viewbox_size(data: &[u8]) -> Option<(f64, f64)> { impl<'r> Importer<'r> { pub(super) fn item(&mut self, e: &El, parent: Affine) -> Option { - let tag = e.local(); - let shape = match tag { - "Rectangle" | "TextFrame" => Shape::Rectangle, - "Oval" => Shape::Oval, - "Polygon" => Shape::Polygon, - "GraphicLine" => Shape::GraphicLine, - "Group" => Shape::Group, + let model_item = craft_idml::model::PageItem::from_el(&crate::xml::to_craft(e))?; + let tag = model_item.kind.name(); + let shape = match &model_item.kind { + craft_idml::model::ItemKind::Rectangle | craft_idml::model::ItemKind::TextFrame => Shape::Rectangle, + craft_idml::model::ItemKind::Oval => Shape::Oval, + craft_idml::model::ItemKind::Polygon => Shape::Polygon, + craft_idml::model::ItemKind::GraphicLine => Shape::GraphicLine, + craft_idml::model::ItemKind::Group => Shape::Group, _ => return None, }; let id = ItemId(self.alloc()); @@ -48,7 +49,7 @@ impl<'r> Importer<'r> { self.item_ids.insert(s.to_string(), id); } let layer = e.get("ItemLayer").and_then(|l| self.layer_ids.get(l)).copied().unwrap_or_else(|| self.layers[0].id); - let path = e.prop_el("PathGeometry").map(path_of).unwrap_or_default(); + let path = path_from_model(model_item.geometry()); let mut it = Item::new(id, layer, shape, path); it.xf = parent * parse_affine(e.get("ItemTransform")); it.name = e.get("Name").filter(|n| *n != "$ID/").unwrap_or("").to_string(); @@ -406,10 +407,6 @@ fn clipping_path(g: &El, to_graphic: Affine) -> Option PathData { - path_capped(pg, usize::MAX) -} - /// The path of a `…Geometry` element, keeping at most `max` anchors. fn path_capped(pg: &El, max: usize) -> PathData { let geometry = craft_idml::model::PathGeometry::from_el_capped(&crate::xml::to_craft(pg), max);