From 8f8a3bff964fe872f6ef8a4e5bd889e9fd4d2d89 Mon Sep 17 00:00:00 2001 From: aiongg <67543387+aiongg@users.noreply.github.com> Date: Sat, 10 Oct 2026 09:39:52 +0000 Subject: [PATCH] feat: read the TOC style flags IncludeBookDocuments and CreateBookmarks The eight bytes after a TOC style's name are a u16 (0 in every style), the u16 IncludeBookDocuments and the u32 CreateBookmarks. They match all 1,520 TOC styles of the corpus whose IDML style has the same name. compare.py --exclude own/, trustworthy pairs: TOCStyle IncludeBookDocuments and CreateBookmarks 0 -> 1,304 of 1,304 each; no extra value. --- docs/format/objects.md | 18 ++++++++++++------ src/idml/designmap.rs | 4 +++- src/model/style.rs | 10 +++++++++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/docs/format/objects.md b/docs/format/objects.md index ea30da5..83939e1 100644 --- a/docs/format/objects.md +++ b/docs/format/objects.md @@ -607,8 +607,9 @@ of a named grid of the document; otherwise it leaves the attribute out. ## Table of contents styles (0x11605) -Chunk 0x11605: a flag byte (1 = built-in key) and the name, three u32 -(the third the UID of the title's paragraph style), a flag byte and the +Chunk 0x11605: a flag byte (1 = built-in key) and the name, a u16 (0 in +every style), a u16 `IncludeBookDocuments` and a u32 `CreateBookmarks` +(1 = true), the u32 UID of the title's paragraph style, a flag byte and the title, a flag byte and a string not identified, then u16 fields: at 0 `SetStoryDirection` (0 `Horizontal`, 1 `Vertical`), at 2 `NumberedParagraphs` (0 `IncludeFullParagraph`, 2 `ExcludeNumbers`), at @@ -627,10 +628,15 @@ writes match on `Name`, `Title` and `TitleStyle` (511 of 511), `Vertical` in two pairs of version 18), `MakeAnchor` (445 of 445 from DOM 9 on, 4 true) and `RemoveForcedLineBreak` (340 of 340 from DOM 13 on, 4 true); `AppliedTOCStyle` matches for 18,923 of 18,923 -stories (21 made by a table of contents). `CreateBookmarks` (false in 1 -of 676 IDML styles) and `IncludeBookDocuments` (true in 8) were not -found, and the entries (`TOCStyleEntry`, 130 in all corpus IDML files) -are not decoded: the converter writes the styles without them. +stories (21 made by a table of contents). `IncludeBookDocuments` and +`CreateBookmarks` match all 1,520 TOC styles of the corpus of 2026-10 +whose IDML style has the same name (1,304 trustworthy; 15 with +`IncludeBookDocuments="true"`, one with `CreateBookmarks="false"`, in a +stale pair). The flagged string after the title is the path of a book +file in some of these styles, but it does not decide +`IncludeBookDocuments`. The entries (`TOCStyleEntry`, 130 in all corpus +IDML files) are not decoded: the converter writes the styles without +them. Two TOC styles of the corpus pairs have another value at the `SetStoryDirection` field: 0x40 with no `SetStoryDirection` in the IDML (version 15.0) and 0xF6FC with `Horizontal` (a stale pair of version diff --git a/src/idml/designmap.rs b/src/idml/designmap.rs index 15cd73c..6c856f6 100644 --- a/src/idml/designmap.rs +++ b/src/idml/designmap.rs @@ -415,7 +415,9 @@ impl Writer<'_> { self.style_ref((t.title_style != 0).then_some(t.title_style), true), ) .attr("Title", &t.title) - .attr("Name", &name); + .attr("Name", &name) + .attr("IncludeBookDocuments", t.include_book_documents.to_string()) + .attr("CreateBookmarks", t.create_bookmarks.to_string()); let major = self.doc.version.major; let flag = |i: usize| t.flags.get(i).copied(); match flag(0) { diff --git a/src/model/style.rs b/src/model/style.rs index e560e3f..550b29f 100644 --- a/src/model/style.rs +++ b/src/model/style.rs @@ -106,6 +106,10 @@ pub struct TocStyle { pub builtin: bool, pub title: String, pub title_style: u32, + /// u16 at 2 after the name. + pub include_book_documents: bool, + /// u32 at 4 after the name. + pub create_bookmarks: bool, /// After a flag byte and a string: u16 at 2 numbered paragraphs, at 4 /// make anchor and at 6 remove forced line breaks, where the chunk /// has them. @@ -310,7 +314,9 @@ impl<'a> Reader<'a> { let mut c = self.cursor(&d); let builtin = c.flag()? == 1; let name = c.string()?; - c.skip(8)?; + c.u16()?; + let include_book_documents = c.u16()? == 1; + let create_bookmarks = c.u32()? == 1; let title_style = c.u32()?; c.flag()?; let title = c.string()?; @@ -326,6 +332,8 @@ impl<'a> Reader<'a> { builtin, title, title_style, + include_book_documents, + create_bookmarks, flags, })) })();