From dae8a622ebc7340c0573846b5773326dcc33741d Mon Sep 17 00:00:00 2001 From: skylar taylor-barrick Date: Sat, 24 Oct 2026 21:13:58 -0600 Subject: [PATCH] Count distinct placement ids in the IDML layer-variant guard A duplicated text frame holding an anchored placed PDF leaves two placements sharing one ItemId, so the raw update count exceeded the variant count and a correct export failed. The guard now checks that every mapped id was reached. Replaces the mismatch test with a duplicated-frame export regression. --- crates/engine/src/cmd/interchange.rs | 49 +++++++++++++++++++++------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/crates/engine/src/cmd/interchange.rs b/crates/engine/src/cmd/interchange.rs index e7fcb0a0f..1ff29d634 100644 --- a/crates/engine/src/cmd/interchange.rs +++ b/crates/engine/src/cmd/interchange.rs @@ -87,9 +87,13 @@ fn with_pdf_layer_variants(doc: &Document, embed: bool) -> Result Result = doc.placed_items().into_iter().filter(|i| i.has_pdf_layer_override()).map(|i| i.id).collect(); + assert_eq!(with_choice, [chosen, chosen], "both placements share one id"); + assert!(doc.check().unwrap_err().to_string().contains(&format!("duplicate item id {chosen}"))); + let result = s.execute("file.exportIdml", &json!({})).unwrap(); + let imported = designcraft_idml::import_idml(&base64_decode(result["base64"].as_str().unwrap())).unwrap(); + let mut layers: Vec<_> = + imported.assets.values().filter(|a| designcraft_render::is_pdf(&a.data)).map(|a| designcraft_render::pdf_layers(&a.data)).collect(); + layers.sort(); + assert_eq!(layers, vec![states(false, true), states(true, false)]); } #[test]