Repository navigation
fix(docx): elect Normal from text in runs and table cells, so restyling it reaches the body - #851
Merged
Merged
Conversation
…e style it is written in
…y cell, and style a band's mark
…om-table-text # Conflicts: # CHANGELOG.md
…om-table-text # Conflicts: # CHANGELOG.md
…ected from runs and cells
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
Restyling Normal in Word is how a reader changes a document's body, and the export makes body runs that restate Normal say nothing so the restyle reaches them. Normal is elected as the style the most characters are set in (
dominantTextStyle), but the count left text out:Where most of the text is in runs or cells — invoices, proposals, a rota — Normal came from the few paragraphs left. The body then carried a direct size that restyling Normal never reached: Normal 14pt over 10pt text in
ProposalEditorial, 12pt over 10.5pt inCobaltRota. The Word editing protocol (#847) found the body following Normal in 54 of the 62 corpus documents.What changed
DocxSemanticBackend.weighTextStylescounts each piece of text in the style it is written in:resolveCellTextStyle, now static), the engine's default cell face where nothing states one;An empty cell counts for nothing, so a grid of blank cells does not outvote the body.
dominantTextStylenow picks the face and size with the most text first, then the colour with the most text among them. Body text set in two colours is one body still:ProposalNorthline's 9pt text, in its body colour and a muted one, lost to its 10pt while each colour counted alone.A header's or footer's band paragraph (
writeBand) now has its mark set in its text's style, as body paragraphs have since #849. Enter there continues the band's text, not Normal.The recipe's "Named styles" section says what counts. CHANGELOG is updated.
Verification
Editing protocol (Word 16.0.20430, 62 documents): restyling Normal by +2pt reaches the body in 62 / 62, against 54. "Enter and type" stays at 62 / 62.
LibreOffice (Windows).
VioletGridis set on one page, as the PDF, instead of two, and its lines past 2pt go from 37 to 0. 65 lines move in all:VioletGrid's;CobaltRota's, by 0.05–0.4pt across.The baselines are committed. LibreOffice on the Linux CI does the same:
VioletGridgoes from 2 pages to 1 and from 37 lines past 2pt to 0, with 67 lines moving; that baseline comes from this PR's CI artifact.Word corpus. One line moves: the right-hand slot of
CobaltRota's footer, 0.36pt further across (−3.26 → −3.62). It was already one of the three Word lines past 2pt. Styling the band's mark did not move it back, and the cause is not established. Nothing else moves.Tests:
DocxDocumentStyleTest:Three tests in
DocxParagraphMarkTestandDocxRunStyleTestdepended on the old count, where a paragraph's runs were invisible. Their documents now hold more body text, so they still test what they did.Sabotage. Each change fails its test:
render-docx. 901 tests green.
Full reactor gate.
./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).Examples.
CommittedAssetDriftTest→ 3 / 3 green.Notes
DocxRunStyleTest.aCodeChipCarriesItsOwnGlyphStyleRatherThanTheParagraphs) now expects fix(docx): write a chip's side padding as the room it takes on the page #844's split runs of this PR's longer text. Re-measured after the merge, render-docx runs 920 tests green, and Word and LibreOffice move no line against the merged baselines. fix(docx): close a document ending in a table with an ordinary paragraph where its last page has room #848's room for an ordinary closing paragraph is reckoned at Normal's size, and with Normal smaller in one more document, 18 corpus documents now close with an ordinary paragraph and 15 with the hairline, against 17 and 16.Lane: shared-engine (render-docx).