Files
docx/scripts/layout-probes/word-notes-final-table.pdf
Dolan c2816f8d20 feat(layout): lay out footnotes and endnotes, header pictures, cell spacing, header rows and tabs where round 25 shows Word's way, as Word does (#3709)
* feat(layout): lay out footnotes and endnotes, header pictures, cell spacing, header rows and tabs where round 25 shows Word's way, as Word does

Word's PDFs of the round-25 probes settle the cases docx/layout still
stopped at in notes (word-stops-notes2, word-stops-note-numbers, the
word-stops-endnotes-* documents, word-notes-across-pages and
word-notes-final-table) and around header pictures, contextual spacing in
cells, header rows and tabs (word-stops-edges). Where a case stays open,
the stop is narrowed to it.

* fix(layout): keep the space a cell's own blocks leave out when its table's edges leave out more

A paragraph after a table in a cell is compared with the end of the table's last row, which leaves out its
space before. The pass for the table the cell is in replaced what it left out with its own, so the paragraph
kept that space.

* fix(layout): lay out the endnotes of a section with no blocks of its own after it

Where the settings put endnotes at the end of each section, those of a section that suppresses its own go
after the next, which can have no blocks of its own, as its paragraphs are hidden. They weren't laid out at
all; now they go after the section before's last block, before the next section's first.

* docs(layout): put two doc comments back above their functions, and say what leftOut covers

* fix(layout): stop at more than 4 columns of footnotes, and don't make them

A document's w15:footnoteColumns can ask for any number of columns, and
each was made before the layout stopped. Word's Footnote and Endnote
dialog offers up to 4, so more stop, as not yet seen in Word, and the
section has no columns of footnotes to make.

* fix(layout): find where each section's endnotes go in one pass back

A section that suppresses its own endnotes puts them at the end of the
next that doesn't, and that was followed one section at a time, again
for every endnote. A long run of such sections overflowed the stack.
Each section's end is now found once, from the last section back, and
only where the settings put endnotes at the end of each section.

* fix(layout): lay out the endnotes of sections before the first block

Endnotes went after each body block, for the sections up to the next
block's, so those of sections before the first block's, whose paragraphs
are all left out as hidden, were never laid out, nor were any where the
body has no blocks at all. They now go before the first block, or alone.

* test(layout): cover a header's text box placed against its line or the page

The stop kept for a text box that text flows around in a header, placed
against its paragraph or line, is now tested for one against its line, and
one against the page is read as a drawing, as a picture there is.

* fix(layout): stop at endnotes in columns with no separator above them

The endnotes' columns start below their separator, so with an empty
separator note, which leaves none, a lone endnote at the document's end
left no start for the columns it ends in, and evening them out threw.
Word has been seen with endnotes in columns only below a separator, so
that stops, and guessing, the endnotes are laid out without evening out.

* docs(layout): say paragraphs kept before header rows go on only to the next page

The table section said the paragraphs kept with the next before a table
go on with its header rows to the next page or column. They go on to the
next page; in columns, or from the top of a page, the layout stops.

* fix(layout): cut a table row in a footnote across many pages in time

The search for where a footnote's table row is cut started from the rest
of the row and went up a line at a time, filling every earlier part of
the row again at each try, so the time grew far faster than the row: a
row of 400 lines across 7 pages took 4.7 seconds. Where the rest doesn't
fit, no part taller than the page does, so the search goes on from the
page's height, and the parts filled on a page are kept for the tries
after, filled afresh on each page as their lines may hold its number.
The cuts are the same: that row now takes 0.2 seconds, and one of 2,000
lines across 34 pages 3 seconds.

* fix(layout): stop at a left tab past the end of a later line only with a hanging indent

A tab to a left stop past the end of the line at the start of a later line
of a paragraph with a first line indent stopped, though that line starts at
the left indent, as TA9a's lines do, which Word put on a line of their own.
The stop is kept for the first line there, and for any line of a paragraph
with a hanging indent.

* fix(layout): find a line's footnote that starts on the next page afresh each time it is tried

The footnote of a line at the top of a page that starts on the next page,
after the line's others, was kept across the tries of the line, and a try
after a drawing was left out, a table placed or a column moved on to could
fit the line with all its footnotes, but still put the last on the next
page. It is now found again on each try.

* fix(layout): fill a footnote row's parts before its last in a loop

The parts of a table row in a footnote before its last were filled again
by recursion, once for each page the row had gone on to, after the parts
kept for a page were let go at its end. A row across thousands of pages
would run out of stack. They are now filled in a loop, and kept by the
rooms they were cut at one after the other rather than by a key that grew
with each page. The cuts and their times are the same.
2026-10-06 01:51:02 +01:00

27 KiB