From cd7116ff8d579a3a2b1a608a960b92d762d93202 Mon Sep 17 00:00:00 2001 From: aiongg <67543387+aiongg@users.noreply.github.com> Date: Thu, 8 Oct 2026 07:38:55 +0000 Subject: [PATCH] feat: read the numbering lists and AppliedNumberingList Preferences chunk 0x1A49B lists the default numbering list and the others; each list (class 0x1A483) has its name and two flags in chunk 0x1A49A. The converter writes every list in designmap.xml, the default first, in place of the constant default list, which it keeps only for a file whose lists it cannot read. Paragraph attribute 0x1A417 (AppliedNumberingList) names a list by UID. compare.py --exclude own/: - trustworthy value coverage 97.65% -> 97.66% (+896 values); all pairs 95.63% -> 95.64% (+1,231) - NumberingList 705 of 705 (216 more), AppliedNumberingList +32 - extra values unchanged; no key lost values - diff_outputs.py: other outputs differ only in the position of the AppliedNumberingList property --- docs/format/attributes.md | 1 + docs/format/idml-values.md | 11 ++++--- docs/format/objects.md | 17 +++++++++++ src/idml/attrs.rs | 1 + src/idml/designmap.rs | 39 ++++++++++++++++++------- src/idml/kind.rs | 6 ++++ src/model/document.rs | 7 +++++ src/model/ids.rs | 6 ++++ src/model/settings.rs | 59 ++++++++++++++++++++++++++++++++++++++ 9 files changed, 132 insertions(+), 15 deletions(-) diff --git a/docs/format/attributes.md b/docs/format/attributes.md index 6d15d58..a822d13 100644 --- a/docs/format/attributes.md +++ b/docs/format/attributes.md @@ -265,6 +265,7 @@ styles with INDD styles of the same name (486 styles), then checked with | 0x1A406 | `BulletChar` (Properties) | u32 type, u32 value; see below | 1/1 ranges, 84/84 styles | | 0x1A413 | `BulletsFont` (Properties) | font family UID, 0 = `$ID/` | 1/1 ranges, 84/84 styles | | 0x1A414 | `BulletsFontStyle` (Properties) | flag + string; empty = `Nothing` | 1/1 ranges, 84/84 styles | +| 0x1A417 | `AppliedNumberingList` (Properties) | numbering list UID (`objects.md`, numbering lists) | 519/519 styles | | 0x1A419 | `NumberingContinue` | 1 = true | 2/2 ranges, 78/78 styles | | 0x1A41F | `BulletsCharacterStyle` (Properties) | character style UID | 84/84 styles | | 0x1A420 | `NumberingCharacterStyle` (Properties) | character style UID | 79/79 styles | diff --git a/docs/format/idml-values.md b/docs/format/idml-values.md index cb18dca..4f62cbf 100644 --- a/docs/format/idml-values.md +++ b/docs/format/idml-values.md @@ -94,12 +94,15 @@ next to it are read from the INDD (`preferences.md`). ## Default numbering list -The root paragraph style refers to `NumberingList/$ID/[Default]`. All 240 -corpus IDML files have this element in `designmap.xml`, with the same +The root paragraph style refers to `NumberingList/$ID/[Default]`. Every +corpus IDML file has this element in `designmap.xml`, with the same attributes: `Name="$ID/[Default]"`, `ContinueNumbersAcrossStories="false"` and -`ContinueNumbersAcrossDocuments="false"`. The converter writes it after -`idPkg:Styles`, where the IDML schema puts it. +`ContinueNumbersAcrossDocuments="false"`. The converter reads the +numbering lists from the INDD (`objects.md`, numbering lists) and writes +them after `idPkg:Styles`, where the IDML schema puts them. It writes +this default list with these values only for a file whose lists it +cannot read. ## Built-in stroke styles diff --git a/docs/format/objects.md b/docs/format/objects.md index 6169eb4..f35bcd3 100644 --- a/docs/format/objects.md +++ b/docs/format/objects.md @@ -323,6 +323,23 @@ match the IDML in all 4,934 groups on every attribute. Over all 654 pairs the Alphabet variant is 0 in 652 files, 3 and 5 in one each, and the Cyrillic variant is 2 in all. +## Numbering lists (0x1A483) + +Chunk 0x1A49B of the preferences object: u32 UID of the default list, +u16 count *n*, *n* list UIDs, i32 −1. Each list has chunk 0x1A49A: a +flag byte (1 for a built-in key; 0 and 2 plain) and the name, then u8 +`ContinueNumbersAcrossStories` and, two bytes after the name, u8 +`ContinueNumbersAcrossDocuments` (1 `true`); the rest is not identified. + +IDML writes one `NumberingList` per list in `designmap.xml`, the default +(`$ID/[Default]`) first, then the *n* lists in stored order, with +`Self` `NumberingList/` and the name. The paragraph attribute 0x1A417 +(`AppliedNumberingList`, a `Properties` child of type `object`) is the +UID of a list. Evidence: 705 of 705 lists of the trustworthy pairs +(953 of 953 in all pairs), names, both flags and order; +`AppliedNumberingList` 519 of 519 paragraph styles and 489 of 489 text +defaults. + ## Assignments (0x1BE01) Every document has one object of class 0x1BE01, listed in chunk 0x1BE13 diff --git a/src/idml/attrs.rs b/src/idml/attrs.rs index cc1721d..ae57e33 100644 --- a/src/idml/attrs.rs +++ b/src/idml/attrs.rs @@ -381,6 +381,7 @@ pub(super) const TEXT_ATTRS: &[(u32, &str, Kind, bool)] = &[ (0x1A406, "BulletChar", Kind::BulletChar, true), (0x1A413, "BulletsFont", Kind::FontOrNone, true), (0x1A414, "BulletsFontStyle", Kind::StringOrNothing, true), + (0x1A417, "AppliedNumberingList", Kind::NumberingList, true), (0x1A419, "NumberingContinue", Kind::Equals(1), false), (0x1A41F, "BulletsCharacterStyle", Kind::CharacterStyle, true), ( diff --git a/src/idml/designmap.rs b/src/idml/designmap.rs index a62fedb..502da05 100644 --- a/src/idml/designmap.rs +++ b/src/idml/designmap.rs @@ -97,17 +97,34 @@ impl Writer<'_> { } } x.empty("idPkg:Styles", &[("src", "Resources/Styles.xml".into())]); - // Present, with these values, in every corpus IDML; the root - // paragraph style refers to it. See docs/format/idml-values.md. - x.empty( - "NumberingList", - &[ - ("Self", "NumberingList/$ID/[Default]".into()), - ("Name", "$ID/[Default]".into()), - ("ContinueNumbersAcrossStories", "false".into()), - ("ContinueNumbersAcrossDocuments", "false".into()), - ], - ); + // The numbering lists, the default first (objects.md, numbering + // lists). Without them, the default list every corpus IDML has + // (idml-values.md), which the root paragraph style refers to. + let default = [crate::model::NumberingList { + uid: 0, + name: "$ID/[Default]".into(), + across_stories: false, + across_documents: false, + }]; + let lists = if doc.numbering_lists.is_empty() { + &default[..] + } else { + &doc.numbering_lists[..] + }; + for l in lists { + x.empty( + "NumberingList", + &[ + ("Self", format!("NumberingList/{}", self_name(&l.name))), + ("Name", l.name.clone()), + ("ContinueNumbersAcrossStories", l.across_stories.to_string()), + ( + "ContinueNumbersAcrossDocuments", + l.across_documents.to_string(), + ), + ], + ); + } let major = doc.version.major; // Elements every IDML of the version has, with the values they // all have (idml-values.md), in the order of the IDML files. diff --git a/src/idml/kind.rs b/src/idml/kind.rs index a3aef34..942b883 100644 --- a/src/idml/kind.rs +++ b/src/idml/kind.rs @@ -57,6 +57,8 @@ pub(super) enum Kind { Font, /// A font family, or 0 for none (`$ID/`). FontOrNone, + /// A numbering list UID. + NumberingList, /// A string. String, /// A string, or the empty string for `Nothing`. @@ -181,6 +183,10 @@ impl Writer<'_> { 0 => Some(text("string", "Text Color".into())), u => swatch(u).map(|s| text("object", s)), }, + Kind::NumberingList => v + .as_u32() + .and_then(|u| self.doc.numbering_lists.iter().find(|l| l.uid == u)) + .map(|l| text("object", format!("NumberingList/{}", self_name(&l.name)))), Kind::Font => v .as_u32() .and_then(|u| self.doc.fonts.get(&u)) diff --git a/src/model/document.rs b/src/model/document.rs index 178f02c..7d4e8cf 100644 --- a/src/model/document.rs +++ b/src/model/document.rs @@ -25,6 +25,8 @@ pub struct Document { /// The document's label (chunk 0x1630B): key and value, as IDML /// writes them. pub label: Vec<(String, String)>, + /// The numbering lists, the default list first. + pub numbering_lists: Vec, /// Index sort groups (preferences chunk 0x1307E), in order: name, /// include flag and header variant. pub index_groups: Vec<(String, bool, u16)>, @@ -185,6 +187,10 @@ impl<'a> Reader<'a> { let constant_shade = self.constant_shade(); let assignments = self.assignments(); let users_script = self.users_script(DOC); + let numbering_lists = self.numbering_lists().unwrap_or_else(|e| { + self.warn(format!("numbering lists left out: {e}")); + Vec::new() + }); let label = self.label(DOC).unwrap_or_else(|e| { self.warn(format!("document label left out: {e}")); Vec::new() @@ -248,6 +254,7 @@ impl<'a> Reader<'a> { users, users_script, label, + numbering_lists, sections, text_variables: objects.text_variables, hyperlinks: objects.hyperlinks, diff --git a/src/model/ids.rs b/src/model/ids.rs index 5dda2a4..e76d8a1 100644 --- a/src/model/ids.rs +++ b/src/model/ids.rs @@ -58,6 +58,8 @@ pub mod class { pub const TABLE_STYLE_ROOT_GROUP: u32 = 0x1044F; /// Document-wide preferences. pub const PREFERENCES: u32 = 0x2202; + /// A numbering list. + pub const NUMBERING_LIST: u32 = 0x1A483; pub const GUIDE: u32 = 0x3301; pub const XML_TAG: u32 = 0xBF19; /// A colour used in the interface (XML tags). @@ -89,6 +91,10 @@ pub mod chunk { pub const DOC_USERS: u32 = 0xA443; /// Document label: u16 0x7B7B, u32 count, flagged key and value strings. pub const DOC_LABEL: u32 = 0x1630B; + /// Preferences: u32 default numbering list, u16 count, list UIDs, i32 -1. + pub const NUMBERING_LISTS: u32 = 0x1A49B; + /// Numbering list: flagged name, then u8 flags. + pub const NUMBERING_LIST_INFO: u32 = 0x1A49A; pub const SPREAD_CHILDREN: u32 = 0x503; pub const SPREAD_TRANSFORM: u32 = 0x56E; pub const SPREAD_BINDING: u32 = 0x1B8; diff --git a/src/model/settings.rs b/src/model/settings.rs index 007b090..e5156ac 100644 --- a/src/model/settings.rs +++ b/src/model/settings.rs @@ -6,6 +6,16 @@ use super::*; +/// A numbering list (class 0x1A483). +#[derive(Debug, Clone, PartialEq)] +pub struct NumberingList { + pub uid: u32, + /// The name as IDML writes it. + pub name: String, + pub across_stories: bool, + pub across_documents: bool, +} + /// A pasted smooth shade with a constant shading. See /// `docs/format/objects.md`, pasted smooth shades. #[derive(Debug, Clone, PartialEq)] @@ -173,6 +183,55 @@ impl<'a> Reader<'a> { .collect() } + /// The numbering lists (preferences chunk 0x1A49B): the default list + /// first, then the others in stored order. A list whose chunk cannot + /// be read is left out with a warning. See `docs/format/objects.md`. + pub(super) fn numbering_lists(&self) -> Result, Error> { + let Some(&(prefs, _)) = self + .db + .classes() + .iter() + .find(|(_, c)| *c == class::PREFERENCES) + else { + return Ok(Vec::new()); + }; + let Some(d) = self.chunk(prefs, chunk::NUMBERING_LISTS)? else { + return Ok(Vec::new()); + }; + let mut c = self.cursor(&d); + let default = c.u32()?; + let n = c.u16()? as usize; + let mut uids = vec![default]; + for _ in 0..n { + uids.push(c.u32()?); + } + let mut out = Vec::new(); + for uid in uids { + if self.class(uid) != Some(class::NUMBERING_LIST) { + continue; + } + let Some(d) = self.chunk(uid, chunk::NUMBERING_LIST_INFO)? else { + continue; + }; + let mut c = self.cursor(&d); + let read = (|| -> Result { + let name = c.name()?.idml(); + let flags = c.bytes(3)?; + Ok(NumberingList { + uid, + name, + across_stories: flags[0] == 1, + across_documents: flags[2] == 1, + }) + })(); + match read { + Ok(l) => out.push(l), + Err(e) => self.warn(format!("numbering list {uid} left out: {e}")), + } + } + Ok(out) + } + /// The label of an object (chunk 0x1630B of the document): u16 0x7B7B, /// u32 count, then key and value of each pair as a flag byte (1 for a /// built-in key) and an in-object string. See `docs/format/objects.md`.