From 43592075644f69a2933032354232fdc4ffb50bf9 Mon Sep 17 00:00:00 2001 From: aiongg <67543387+aiongg@users.noreply.github.com> Date: Wed, 7 Oct 2026 16:49:41 +0000 Subject: [PATCH] feat: write GraphicType for empty graphic frames --- docs/format/objects.md | 7 +++++++ src/idml/mod.rs | 2 +- src/model/mod.rs | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/format/objects.md b/docs/format/objects.md index de70e0a..885f84c 100644 --- a/docs/format/objects.md +++ b/docs/format/objects.md @@ -492,6 +492,13 @@ Frames, shapes and lines are all class 0x6201; groups are 0x401. | 0x6E03 | Attribute list: local formatting (see `attributes.md`) | | 0x1B916 | u32: applied object style | +**Content type.** A rectangle, oval or polygon with a placed graphic is +`ContentType="GraphicType"`. Without one, chunk 0x1623 (u16) decides: 1 +is `GraphicType` (an empty graphic frame), 0 or no chunk `Unassigned`. +In 200 of the trustworthy pairs, the 757 empty shapes with +`GraphicType` all have 1, and the 15,768 with `Unassigned` have 0 +(13,226) or no chunk. + Groups store their matrix in chunk 0x40D when they have no chunk 0x151: with it, the `ItemTransform` of all 5,670 groups of the trustworthy pairs (8,788 of 8,789 over all pairs) matches; without it, 5,277 of them were diff --git a/src/idml/mod.rs b/src/idml/mod.rs index af06041..9c0defd 100644 --- a/src/idml/mod.rs +++ b/src/idml/mod.rs @@ -3732,7 +3732,7 @@ impl Writer<'_> { .attr("NextTextFrame", uref(*next)) .attr("ContentType", "TextType"); } else if let ItemKind::Shape(_) = item.kind { - let content = if item.graphics.is_empty() { + let content = if item.graphics.is_empty() && !item.props.graphic_frame { "Unassigned" } else { "GraphicType" diff --git a/src/model/mod.rs b/src/model/mod.rs index 72cdd84..3e6c138 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -121,6 +121,8 @@ pub mod chunk { pub const ITEM_TRANSFORM: u32 = 0x151; /// A group's transform when it has no chunk 0x151. pub const GROUP_TRANSFORM: u32 = 0x40D; + /// u16 1 for a frame meant for a graphic. + pub const ITEM_CONTENT: u32 = 0x1623; pub const ITEM_PATHS: u32 = 0x162B; pub const ITEM_HIERARCHY: u32 = 0x15B; pub const COLUMN_FRAME_LIST: u32 = 0x220; @@ -426,6 +428,9 @@ pub struct ItemProps { /// The overridden master page item (0 for none) and the IDs of the /// attributes overridden (chunk 0x1424). pub overridden: Option<(u32, Vec)>, + /// Chunk 0x1623 is 1: a frame for a graphic (`ContentType` + /// `GraphicType` without a graphic). + pub graphic_frame: bool, } /// A page item name: a built-in key or a name given by the user. @@ -2127,6 +2132,9 @@ impl<'a> Reader<'a> { counts(chunk::ITEM_UPDATED_CHANGES)?, ], overridden, + graphic_frame: self + .chunk(uid, chunk::ITEM_CONTENT)? + .is_some_and(|d| d.len() >= 2 && Cursor::new(&d).u16().ok() == Some(1)), }) }