mirror of
https://github.com/dolanmiu/docx.git
synced 2026-11-30 16:47:55 +01:00
* fix: define the TOC 1 to TOC 9 styles, so LibreOffice keeps the levels of a table of contents indented (#3819) Since 9.9.0 a table of contents is written with its entries, in the styles TOC1 to TOC9, which docx never defined. Opening it, LibreOffice gives its Contents 2 to Contents 9 styles no indent, so once it updates the index every level is flush left. 9.8.1 wrote no entries, and LibreOffice kept its own indents. docx now writes the styles as Word adds them: based on Normal, 5 points of space after, and each level indented by Normal's font size more than the one above (200 twips a level at docx's default 10 points, 220 at 11 points, as Word for Mac writes them). They are hidden until used, as Word's are. A style with their id replaces them, as for the other default styles, and so does a style with their name, such as a template's "toc 1" with a localized id, so no two styles share a name. The entries no longer need an indent of their own, which assumed 220 twips. Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep the text-and-spacing layout demo's Tab stops heading clear of the bottom of a page The TOC styles give the table of contents' entries 5 points of space after, as Word's do, instead of the demo's 8, so the text after the table moved up 33 points. That left the Tab stops heading and its first line ending less than a point below the bottom margin of page 9. Word and docx/layout fit them there; LibreOffice, which compare-layout.sh checks against, moves them to page 10. Word and LibreOffice put every other line of the page in the same place. The hanging-indent paragraph above the heading has 80 words instead of 90, a line fewer, so the heading fits with room to spare. All 368 headings of the layout demos are now on LibreOffice's page, and Word puts this demo's on the same pages. Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep docx's TOC styles beside a character style with their name Only a paragraph style named "toc 1" to "toc 9" takes the place of docx's TOC1 to TOC9. A table of contents' entries are paragraphs, which can't take a character style, so a character style named "toc 2" left the entries naming a TOC2 that docx no longer wrote. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c * fix: indent the TOC styles patchDocument adds by the template's Normal font size Word indents each level of a table of contents by the size of the Normal style's font, and a Document does too, but the TOC1 to TOC9 styles that patchDocument adds to a template without them always stepped by docx's 10 points. They now follow the template's Normal: its own size, or else the document's default size, such as the 12 points Word for Mac saves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c * fix: take the TOC indent from the template's style that patchDocument bases the TOC styles on The TOC styles patchDocument adds are based on the template's style with Normal's id, or else on its style named Normal. Their indent now follows the font size of that same style, so a template whose Normal has another name still gets its size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>