Repository navigation
fix(docx): name what a text header or footer shows otherwise in Word - #921
Merged
Merged
Conversation
A text band is written as one exact line of a Word header or footer, its slots set by a centre and a right tab stop. Measured in Word and LibreOffice on Windows, four things showed otherwise than on the page, with nothing said: - A band too shallow for its line, which is written from the page's edge: 9pt text in a header 11pt tall stood 2.14pt lower in Word than on the page (2.10 in LibreOffice), in a footer 10pt tall 1.04pt higher (1.21), that footer's separator 0.92pt higher (1.06). - Page numbers in letters: Word letters a number past 26 by repeating one letter, page 28 bb and a total of 56 ddd, where the page and LibreOffice read ab and bd. - Slots that overlap where the page sets them, which it draws over one another: both editors set a slot that would overlap the text before it after that text, Word on the same line as far as past the right margin, LibreOffice on it or on a line below. - A slot wider than the line, which the page runs past the margins and both editors wrap onto a line below. The report now names each (page header / page footer): the shallow band with about how far its text and separator move, a lettered band where the layout runs to 28 pages or more, or where it would with no layout, and the slots with on how many of the band's pages, each page read as the page reads it. The DOCX is written as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A text header or footer (
DocumentHeaderFooter) is written as one exact line of a Word header orfooter: its left slot, its centre slot at a centre tab and its right slot at a right tab, page tokens
as fields. Measured in Word 16 and LibreOffice on Windows, four things showed otherwise than on the
page, and the report said nothing.
The line is exact and starts at the page's edge. A shorter line, or text raised in it, would cut its
letters: Word draws an exact line's text only inside the line on screen.
What changed
DocxTextBands:baselineFromEdge: where the page sets the baseline;baselineMovedIn: how much further in Word stands it, where the line stops at the edge;separatorMovedIn: the separator ruled past a line taller than its band;slotsOverlap: the page's three slot positions against one another.distanceFromEdge(band)now readsbaselineFromEdge; same arithmetic, the corpus is byte-identical.DocxSemanticBackend.reportBandText, given once per band from its writer:APPROXIMATEDnotes, subject
page header/page footer:0.1pt or more;
LOWER_ALPHA/UPPER_ALPHA) with a{page}or{pages}token,where the layout runs to 28 pages or more, or with no layout behind it, "where the document
runs that far";
the M pages".
slotsSetOnreads each page the band is drawn on as the page does:DocxNodeFieldLedgerTest'sheadersAndFootersentry;Verification
DocxBandTextReportTest(new, 9 tests):{page}and{pages}; 27 pages, roman numbers and a band with notoken not named; no layout hedged;
digit more on page 10 makes the overlap);
DocxTextBandsTest(+4): the shifts, the separator, the overlap geometry.shares, page 28, the token and letter conditions, the no-layout branches, the first page counted,
each overlap edge, unread tokens, the separator's width, a band read once counted once, a wide
slot unmeasured.
./mvnw -B -ntp clean verify: BUILD SUCCESS (core 821, render-docx 1793, examples 93, qa 1820); the knowledge pack's--checkpasses.Lane: render-docx (semantic backend). Report notes only; no output change.