Repository navigation
fix(docx): stand a nested list item with no marker where the page sets its text - #840
Merged
Merged
Conversation
…s its text A project's description under its name is a nested rich item with no marker; the export wrote it two spaces a level in with no indent, so in Word it started up to 3.4pt short of the page's and wrapped back 6 to 7.9pt short. Where the layout's items are matched to the list's, it now stands every line as far past the list's edge as the layout set its text, and its lines are measured at Word's half-point sizes as a paragraph's are, so it breaks at the page's words. Lines more than 2pt off across fall from 49 to 24 in Word and from 54 to 30 in LibreOffice; LibreOffice's lines past 2pt down fall from 127 to 118.
| // that is never below its edge, and an item past it there still stands its distance in. | ||
| indent.setLeft(BigInteger.valueOf(leftIndentTwips(insetLeft + cellTextShift + past))); | ||
| double room = availableWidth() - past; | ||
| double measure = Double.isFinite(room) && room > 0 ? wordsMeasure(laidOut.lines(), room) : Double.NaN; |
… only items at their text A list that nests only rich items with no marker, each now standing where the layout set its text, sets its top level at the page's column too: kept at a space, a project's name started the gap less a space left of the description under it. A list that nests any other item keeps the space. itemLines keeps the later fragment where marker and text start together. The Linux LibreOffice baseline is this branch's CI measure; the prose names the first page's foot and the cases that keep the spaces exactly.
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
ParagraphPrimitive.writeBulletedPairsets a project's name and its description as onehangingIndent(true)list: the name a bulleted item, the description a nested item with no marker (markerFor(1, none())). Both are rich, so the DOCX export writes them as paragraphs." ".repeat(depth)), with no indent. In Word every such description inPanel,Executive,ModernProfessional,MinimalUnderlinedandBoxedSectionsstarted up to 3.4pt short of the page's and wrapped back 6 to 7.9pt short, at the list's edge.MinimalUnderlined's first page stood 14pt high under them.What changed
DocxLayoutMetrics.itemLinesreports each item's text as well as its lines:ItemText(lines, x), x being where its text fragment starts (fragment x plus the payload's left padding). For an item laid out with its marker in a column, the text is the fragment to the right, or the later one where the two start together.indentAsTheItemIs. A nested rich item with no marker stands where the layout set its text. Its left indent is the insets plus its distance past the list's edge (listTextLeft, the list's placement plus its padding), written asapplyInsetwrites insets, and the spaces are dropped.wordsMeasure(List<ParagraphLine>, room), factored out ofwordsMeasure(ParagraphNode, room), whose behaviour is unchanged), and the right indent gives or takes the difference. Measured at the page's place alone,Panel's magazine description broke its first line a word sooner in Word than the page does.nestsBesideItsText. A list of paragraphs that nests only such items, with its items matched to the layout's, sets its top level at the page's column too (setInAColumn): marker, tab, and lines hung there, as fix(docx): give a hanging list's top level the page's marker column, text markers too #836 does for a list that does not nest. Kept at a space, the name started the gap less a space left of the description now set at the page's place.Verification
scripts/docx-visual/word-fidelity.ps1 -Update(Word 16.0.20430) → BUILD SUCCESS.Panel−3.17/−7.75,Executive−3.36/−7.92,ModernProfessional−0.48/−6.00,MinimalUnderlined−1.78/−6.34,BoxedSections−1.86/−6.42 → all within 0.07. A wrapped line of aPanelproject name, −7.75 → +0.07.Panelfinds one line more (74 of 79). No line lost.MinimalUnderlined's first page, 14pt high, comes within 1.4pt; lines past 2pt down: 127 → 118.DocxListMarkerGapTest, three new:nests()): the name test fails;./mvnw -B -ntp clean verify -pl :graph-compose-core,:graph-compose-render-pdf,:graph-compose-render-docx,:graph-compose-render-pptx,:graph-compose-templates,:graph-compose-testing,:graph-compose-qa,:graph-compose-coverage -am→ BUILD SUCCESS (qa 1820 tests).CommittedAssetDriftTest→ 3/3 green.Notes
writeListLine, which writes it two spaces a level in when the list is not a Word list.Lane: shared-engine (render-docx).