Repository navigation
fix(docx): name a border Word draws at another width than the page, and write a separator of no width - #914
Merged
Merged
Conversation
…nd write a separator of no width A Word border is two to ninety-six eighths of a point wide, and the export held every border to that range without a note: a panel's, a row's and a table cell's borders, a rule written as a paragraph's border, and a text header's or footer's separator. A 20pt panel border was written 12pt wide, a 0.1pt rule a quarter of a point. DocxBorderWidths holds the range and says what falls outside it, to the eighth: a border is named (border width) once for a panel, once for a table, once for a rule, and once for a separator however many headers it is written into. A width that rounds to an eighth Word draws is drawn at it, unnamed. A separator of no width, which the PDF strokes as the thinnest line a device shows, was not written. It is drawn at Word's thinnest border and named, and the band's reach past the page margin counts the separator as Word draws it. One set below zero, or not a number, is named as not written.
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 Word border's
w:szruns from two to ninety-six eighths of a point, and the export heldevery border to that range without a word in its report: a panel's borders (a section's, a
container's, a row's, a shape container's panel in a cell), a table cell's rules, a rule written
as a paragraph's border, and a text header's or footer's separator. A 20pt panel border was
written 12pt wide and a 0.1pt hairline a quarter of a point, while the report promises that
what the file does not hold is said. In the corpus,
CompactMono's header rule is one:stroked 0.1pt, written 0.25pt, unreported.
A separator of no width, which the PDF strokes with a line width of 0 — the thinnest line a
device shows — was not written at all, and one set below zero or to NaN was dropped silently.
What changed
DocxBorderWidths(new, package-private):eighths(points)replaces the backend'sruleEighthsat every place a border width becomesw:sz;notHeld(what, plural, widths)says which widths fall outside Word's range once rounded to the eighth Word counts in, and
ofNoWidth(what)what a separator of no width becomes. A width that rounds to an eighth Worddraws (0.2pt → two eighths) is drawn at it and not named.
border width,APPROXIMATED): once for a panel (on its first piece, as itstranslucency note is), once for a table (its cells' rule widths collected across the grid,
covered positions too, deduplicated), once for a rule, and once for a separator however many
headers it is written into (
separatorsReported, which now remembers the band for its widthas well as its colour).
separatorShown/separatorWrittendecide it in one place. One of no width iswritten at Word's thinnest and named; its frame holds it, and
reachOf— whether a bandreaches past the page margin — now counts the separator as Word draws it, its width in
eighths and nothing for one not written (it counted the page's thickness on
showSeparatoralone). One below zero or NaN is named (DROPPED) and not written.DocxNodeFieldLedgerTest: the border-width case is in the entries of a panel's, a row's, atable's and a shape container's borders, a line's stroke, a filled bar's height and the
headersAndFootersoption.shape, line, table and header/footer rows), CHANGELOG v2.5.0 Public API.
Verification
./mvnw -B -ntp test -f render-docx/pom.xml—DocxBorderWidthsTest(new, 16): the eighthsand the threshold (0.2pt and 12.06pt held; 0.001pt, 0.05pt, 0.1pt, 16pt and 20pt named,
listed in order); a panel's 20pt border and a 0.1pt side (
w:sz96 and 2), a panel split by apage break named once, a row's border, a table's 0.05pt and 20pt rules named once, a divider's
and a line's 0.1pt rule, borders Word draws as the page does and strokes of no width not
named; a separator of no width written at two eighths, in its frame and reaching past a
margin it ends at (the margin written negative), a 20pt one named once though written into
two headers, a translucent 20pt one named for both, one below zero and one NaN not written,
named once, and one not written reaching nothing.
separator, its frame and its reach, the below-zero and NaN notes, once per band and per
panel, both thresholds, held widths, the clamp, strokes of no width — all caught.
CompactMonoheaderrules (CV and cover letter).
./mvnw -B -ntp clean verify— BUILD SUCCESS (core 821, render-docx 1736, examples 93,qa 1820); the knowledge pack's
--checkpasses.Lane: render-docx (semantic backend) — report notes and a separator of no width; no layout
change.