Repository navigation
fix(docx): name inline picture losses and write a %N marker as text - #937
Merged
Merged
Conversation
Word stands an inline picture on the baseline, and the export moves it by w:position to where the page sets it, from the layout's measure of the paragraph's first line. Where that measure does not hold, the report said nothing: - a picture beside text in a paragraph whose lines are not read stands on the baseline, where the page sets it by its alignment or offset; - a picture on a later line of another height is set by the first line's measure; - one Word paragraph takes one seat by its cap band (verticalAlign), its first text line's, where the page seats each line by its own; - a shape's picture is wider than its box, and where no text beside it gives that back - a shape opening its paragraph or following a picture or a line break, one before pictures alone, one in a list item or a right-to-left line - it moves what stands in its line, from the side the line's alignment sets it; - a chip padded below zero, which Word's shading does not follow; - an icon's gradient, which the raster draws flat in its first colour. Each is now named on the paragraph's, the shape's, the chip's or the icon's note, from half a point, but a picture set by its alignment in lines that are not read, where no line says how far. A list marker holding a percent sign before a digit (%1, Step %2:) was written as a Word list level, and Word reads %1 to %9 in a level's text as that level's number: measured, neither marker showed in Word. Such a list is now written as paragraphs with its markers as text. None of the corpus's 62 DOCX changes, and none of its 1246 notes.
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
Word stands an inline picture (an image, an SVG icon or a shape among a paragraph's words) on the
baseline. The DOCX export moves it by
w:positionto where the page sets it, from the layout'smeasure of the paragraph's first line (
writeInlinePicture). Where that does not hold, thepicture stands apart from the page, and the export report said nothing:
moves a picture beside text. It stands on the baseline, where the page sets it by its alignment
or its offset.
verticalAlign), its first textline's (
seatShift). The page seats each line by its own size and face (ParagraphSeating).or padding above and below that sums to zero, is not in the file.
beside it gives that back (
giveBackWidth). Where none does, the picture moves what stands inits line.
Separately, a list marker holding a percent sign before a digit (
%1,Step %2:) was written asa Word list level. Word reads
%1to%9in a level's text as that level's number. Measured inWord, neither marker showed; in LibreOffice they showed as
%andS.What changed
picturesLost(on the paragraph'sParagraphNodenote):says how far. One the page sets on the baseline is named from half a point off it
(
offTheBaseline: its offset, less what a shape's picture reaches below its box,DocxShapePictures.reachBelowItsBox).largest half-point difference is named.
seatLostcompares each text line's seat at Word's half point with the first text line's,and names the largest difference. Lines holding no text are skipped, as
seatShiftskips them.chipLostnames a left or a right padding below zero, and a top or bottom padding that isnot zero, whatever their sum.
widthNotGivenBackcomputes how far a shape moves what stands in its line, for the shape'snote:
giveBackWidthcan set closer counts as giving room back: someletters, on one line (
givesBack, now shared withgiveBackWidth). A run holding a linebreak gives back nothing.
a right-to-left paragraph aligns right by default.
what stands right of it.
reportInlinePictureadds the shape's figure from half a point, and an icon's flat gradient(
paintsAGradient).markerPerDepthreturns no per-depth markers when one holds%before a digit(
LEVEL_NUMBER). The list is then written as paragraphs with its markers as text, the path alist with two markers at one depth already takes.
50%stays a Word list.Only the report changes, but for such a list. Not named, and stated so in the docs:
giveBackWidthrounds to whole tenths a letter, which can miss the room by up to a twentieth ofa point a letter. Across the corpus's 226 give-backs the largest miss is 0.25pt.
of one, and the 31 at an end lose nothing.
The recipe (⚠️ .
docs/recipes/docx-export.md), the capability matrix and the CHANGELOG say what isnamed. The matrix's inline-image row goes from ✅ to
Verification
2.5-dev, and the 1246 notes unchanged. A scan of thecorpus's 278 inline shapes, its gradients, its chips' padding and its list markers finds none of
these losses at half a point or more.
%1andStep %2:written as levelsshowed nothing in Word. Written as text, they show as authored.
DocxInlinePictureLossTest(new, 30 tests). Each detector gets a positive and a negativecase, and each A5 case asserts its figure (1.75pt for one side of a 3pt stroke, 3.5pt for both):
opening a line, between words, ending a paragraph, before pictures alone, after or before a run
holding a line break, right-aligned, centred, right-to-left, a list item.
named for it.
./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 (render-docx 1985 tests, qa 1828). The JDK 17 checks pass: the knowledge
pack,
@Betastability doc, claims and routes, and core javadoc with 0 warnings.Lane: shared-engine (
render-docxexport report). No public API change.