From c513cdf03dabac70e4d8103656eeebe09879fab0 Mon Sep 17 00:00:00 2001 From: aiongg <67543387+aiongg@users.noreply.github.com> Date: Sat, 10 Oct 2026 12:51:16 +0000 Subject: [PATCH] feat: write the drop shadow colour and ColumnRuleOverride of page items - Item attribute 0x10837 is the drop shadow EffectColor, written by the object style comparison of the other transparency values. Where the style stores no swatch, Black is left out: one item has it, and its IDML has no EffectColor. - ColumnRuleOverride is the u32 at 0 of chunk 0x22646 and is written as true or false. compare.py --exclude own/, trustworthy pairs: DropShadowSetting EffectColor 0 -> 11/11, TextFramePreference ColumnRuleOverride 21,165 -> 21,167/21,167, 4 more Color elements (swatches the shadows use). No new extra values; no pair loses values. --- docs/format/objects.md | 14 +++++++++++--- docs/format/transparency.md | 22 ++++++++++++++++++---- src/idml/spread.rs | 7 ++++--- src/idml/transparency.rs | 29 +++++++++++++++++++++++------ src/model/ids.rs | 1 - src/model/item.rs | 14 ++++++++------ 6 files changed, 64 insertions(+), 23 deletions(-) diff --git a/docs/format/objects.md b/docs/format/objects.md index 3b5090a..e8ea37d 100644 --- a/docs/format/objects.md +++ b/docs/format/objects.md @@ -2537,6 +2537,7 @@ From the frame's multi-column frame object (class 0x263): | 0x2D1 | u8 12 | `UseFixedColumnWidth` | | 0x2D1 | f64 32 | `TextColumnMaxWidth` (in 40-byte chunks) | | 0x3730 | u16 | `IgnoreWrap` | +| 0x22646 | u32 0 | `ColumnRuleOverride`: 1 true, 0 false (below) | | 0x22646 | f64 28, u32 36 | `ColumnRuleStrokeWidth`, `ColumnRuleStrokeColor` (a swatch; 0 = `n`) | | 0x22608 | u16 2, f64 4, f64 12 | `FootnotesSpanAcrossColumns` (1 = true), `FootnotesMinimumSpacing`, `FootnotesSpaceBetween` | | 0x2834 | 24 bytes | `BaselineFrameGridOption` (below) | @@ -2627,9 +2628,16 @@ values, the rule leaves out 379,953 values that the IDML does not have, keeps the 200,434 it has, and leaves out one value that the IDML has (a `TextColumnFixedWidth` equal to its style's). -`ColumnRuleOverride`: chunk 0x2265A is all zero in the frames of the -pairs except one, whose IDML has `true`; the converter writes `false` -for zero chunks and frames without it (7,247 of 7,248). +`ColumnRuleOverride`: the u32 at offset 0 of chunk 0x22646 (60 bytes). +In the conversions of the 1,251 trustworthy pairs after 2026-10, 11,319 +frames have the chunk: 2 frames (a 15.0 and an 18.4 document) have 1, +and IDML has `ColumnRuleOverride="true"` on both; the other 11,317 have +0, and IDML has `false` wherever it writes the attribute. The converter +writes `true` for 1 and `false` otherwise, also for frames without the +chunk: 21,167 of 21,167 values, no extra value. The same 2 frames are +the only ones whose chunk 0x2265A (32 bytes) is not all zero, so the +corpus cannot tell the two chunks apart; offset 0 of 0x22646 is taken +because the chunk holds the other column rule values of the frame. **Baseline frame grid of text frames.** Chunk 0x2834 of the multi-column frame (24 bytes) holds the frame's baseline grid: diff --git a/docs/format/transparency.md b/docs/format/transparency.md index 99ba009..b829197 100644 --- a/docs/format/transparency.md +++ b/docs/format/transparency.md @@ -81,6 +81,7 @@ nothing else in the transparency settings of the trustworthy pairs. | 0x1081C | `DropShadowSetting/YOffset` | f64 | 649 of 649; 256 of these items have X ≠ Y | | 0x10820 | `DropShadowSetting/Size` | f64 | 6 items, two values; 406 of 406 rectangles and text frames over the 654 pairs of the later corpus | | 0x1084A | `DropShadowSetting/Spread` | f64, percent | 28 of 28 items in 9 files | +| 0x10837 | `DropShadowSetting/EffectColor` | swatch UID | 11 of 11 items in 6 files (below) | | 0x1084D | `InnerShadowSetting/Applied` | u16: 1 true, 0 false | 10 items with 1 | | 0x1084E | `InnerShadowSetting/EffectColor` | swatch UID | 10 items (below) | | 0x10852 | `InnerShadowSetting/Distance` | f64 | 10 items with 0 | @@ -151,6 +152,22 @@ swatch that IDML writes as `EffectColor`. Items without the effect store UID 0xB, where the IDML default is `n` (no colour). The converter writes the colour only when the effect is applied. +**Drop shadow colour.** Item attribute 0x10837 is the swatch of the +drop shadow, IDML `EffectColor`. With the write rule above, the +converter reproduces all 11 `EffectColor` values of the trustworthy +pairs (8 polygons, 2 rectangles, 1 text frame; swatches such as +`Color/Paper` and named colours), with no extra value. In 7 of these +items the object style chain stores 0 for the attribute, which names no +swatch, so every item colour differs from it. The one other item whose +style stores 0 has the Black swatch, and its IDML has no +`EffectColor`. One item cannot show whether IDML compares with Black or +leaves the value out for another reason; the converter leaves out +Black when the style stores 0. + +Not covered: items whose drop shadow is off (`Mode="None"`) for which +IDML still writes a `DropShadowSetting` (the "D empty, IDML writes it" +column above). + ## Stroke and fill transparency Only the gradient feather has values that tell its attributes apart: @@ -197,10 +214,7 @@ settings), 170 of 170. ## Not converted -- Drop shadow `EffectColor` (probably 0x10837: all 11 items whose IDML - writes it store that ID, but most stored values are not written and - the style values were not resolved), `Noise`, `KnockedOut` and - `UseGlobalLight`. +- Drop shadow `Noise`, `KnockedOut` and `UseGlobalLight`. - Stroke, fill and content blending (opacity and blend mode) and the other effects (feather, outer and inner glow, bevel and emboss, satin, directional feather): no item or style in the pairs has a value other diff --git a/src/idml/spread.rs b/src/idml/spread.rs index d4e57c4..185e9a0 100644 --- a/src/idml/spread.rs +++ b/src/idml/spread.rs @@ -353,9 +353,10 @@ impl Writer<'_> { if let Some(c) = color { attrs.push(("ColumnRuleStrokeColor", c)); } - if p.column_rule_override != Some(true) { - attrs.push(("ColumnRuleOverride", "false".into())); - } + attrs.push(( + "ColumnRuleOverride", + (p.column_rule_override == Some(true)).to_string(), + )); } if has("FootnotesEnableOverrides") && footnotes { let [spacing, between] = p.footnotes.unwrap_or([12.0, 6.0]); diff --git a/src/idml/transparency.rs b/src/idml/transparency.rs index da6403f..8a8a8c8 100644 --- a/src/idml/transparency.rs +++ b/src/idml/transparency.rs @@ -117,6 +117,13 @@ const ATTRS: &[(u32, &str, &str, &str, Kind)] = &[ "Spread", Kind::Range(0.0, 100.0), ), + ( + DROP_SHADOW_COLOR, + "TransparencySetting", + "DropShadowSetting", + "EffectColor", + Kind::Swatch, + ), ( 0x1084D, "TransparencySetting", @@ -326,6 +333,13 @@ const STOPS: &[(u32, &str)] = &[ /// effect is applied. const COLOR_APPLIED: &[(&str, u32)] = &[("InnerShadowSetting", 0x1084D)]; +/// The drop shadow's `EffectColor`. Where the object style stores no +/// swatch (0), IDML writes the item's colour, except for the one item +/// whose colour is Black; the converter leaves Black out there, as the +/// samples do not show why (`docs/format/transparency.md`, drop shadow +/// colour). +const DROP_SHADOW_COLOR: u32 = 0x10837; + /// An effect element: name, attributes and opacity stops. type Effect = (&'static str, Vec<(&'static str, String)>, Vec); @@ -401,12 +415,15 @@ pub(super) fn write( } match w.value_text(kind, v) { Some(t) => { - let same = style.is_some_and(|s| { - s.transparency(id) - .and_then(|sv| w.value_text(kind, sv)) - .is_some_and(|st| st == t) - }); - if !same { + let style_text = style + .and_then(|s| s.transparency(id)) + .and_then(|sv| w.value_text(kind, sv)); + let same = style_text.as_ref().is_some_and(|st| *st == t); + let unshown = id == DROP_SHADOW_COLOR + && style.is_some() + && style_text.is_none() + && t == "Color/Black"; + if !same && !unshown { values.push((name, t)); } } diff --git a/src/model/ids.rs b/src/model/ids.rs index 8cde9e4..cf45cd0 100644 --- a/src/model/ids.rs +++ b/src/model/ids.rs @@ -258,7 +258,6 @@ pub mod chunk { pub const FRAME_BASELINE_GRID: u32 = 0x2834; pub const FRAME_COLUMNS: u32 = 0x2D1; pub const FRAME_COLUMN_RULE: u32 = 0x22646; - pub const FRAME_COLUMN_RULE_OVERRIDE: u32 = 0x2265A; pub const FRAME_FOOTNOTES: u32 = 0x22608; pub const FRAME_IGNORE_WRAP: u32 = 0x3730; /// Frame grid of a multi-column frame: u16 1 at 0 for a frame grid. diff --git a/src/model/item.rs b/src/model/item.rs index 5bbccae..fa1757d 100644 --- a/src/model/item.rs +++ b/src/model/item.rs @@ -424,7 +424,7 @@ pub struct TextFramePreferences { pub ignore_wrap: Option, /// Column rule (chunk 0x22646): f64 width at 28, u32 colour at 36. pub column_rule: Option<(f64, u32)>, - /// Chunk 0x2265A: all zero in every sample but one. + /// Column rule override: u32 at 0 of chunk 0x22646, 1 for true. pub column_rule_override: Option, /// Footnote options (chunk 0x22608): u16, u16 span across columns, /// f64 minimum spacing, f64 space between. @@ -610,8 +610,9 @@ impl<'a> Reader<'a> { flag(46), ) }); - let column_rule = match self.chunk(mcf, chunk::FRAME_COLUMN_RULE)? { - Some(d) => match (self.enc().f64_at(&d, 28), self.enc().u32_at(&d, 36)) { + let rule_chunk = self.chunk(mcf, chunk::FRAME_COLUMN_RULE)?; + let column_rule = match &rule_chunk { + Some(d) => match (self.enc().f64_at(d, 28), self.enc().u32_at(d, 36)) { (Some(w), Some(c)) => Some((w, c)), _ => None, }, @@ -657,9 +658,10 @@ impl<'a> Reader<'a> { .and_then(|d| self.enc().u16_at(&d, 0)) .map(|v| v != 0), column_rule, - column_rule_override: self - .chunk(mcf, chunk::FRAME_COLUMN_RULE_OVERRIDE)? - .map(|d| d.iter().any(|&b| b != 0)), + column_rule_override: rule_chunk + .as_ref() + .and_then(|d| self.enc().u32_at(d, 0)) + .map(|v| v == 1), footnotes, footnote_span: footnote_chunk.and_then(|d| self.enc().u16_at(&d, 2)) == Some(1), baseline_grid,