Repository navigation
fix(docx): name a clip where it cuts what is painted, and a turned container's transform - #860
Merged
Merged
Conversation
…ntainer's transform A Word file has no clip a container can set round its layers. The report named a shape container's clip on one path only, and there of every container, cut or not; it named no layer stack's clip, nor the clip of a container written as a badge, a title and its dates, over the flow or as drawing alone. A turned container whose outline draws nothing lost its transform in silence. DocxClipInk measures, from the layout's fragments as the file draws them, whether a clip cuts any ink: strokes with their caps, joins and side borders as the PDF paints them (DocxInkOutline), pictures cropped to the ellipse they fill, text from its glyphs' outlines. reportClipCut names a clip that cuts something on every write path, and one composed in a table's cells on the table. Nothing written changes.
…draws a picture, and inside nested clips A stroke is the area java.awt.BasicStroke makes of it, as DocxShapePictures already strokes an inline shape, in place of geometry of its own. A contained picture is measured where it is drawn in its box; what a clip inside another cuts away is named on that clip only; a polygon or path clip indexes its edges by height. A standard face the PDF does not embed is measured by its line, its outlines being read through a stand-in in other units; any other face's letters count where they reach, past their line too. With no layout behind the export, every node that clips is named, its cut not measured. Nothing written changes.
…lass, each kind its own method
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 file has no clip a container can set round its layers. What a layer stack (
clipToBounds) or a shape container (CLIP_BOUNDS,CLIP_PATH) clips on the page is written whole.DocxExportReportpromises to name every loss, and here it did not:OVERFLOW_VISIBLEincluded, cut or not. That is 186 notes across the 62 documents of the DOCX fidelity corpus.cell drawingnote was unconditional too. It said a clip is not carried for every drawing in the table's cells.clipToBounds;DocxNodeFieldLedgerTestlisted all three as gaps.Most clips cut nothing: an icon drawn inside its box, a disc's initials, a photo filling its circle, a rota chip whose label's line stands past the chip while its digits stay inside. A note for each would bury the ones that do cut.
What changed
DocxClipInk(new, package-private) says whether a clip cuts what is painted inside it. It measures the layout's fragments as the page paints them, upright as the file writes them:fillsItsEllipse).DocxInk) on the baseline the page seats them on.DocxInk.readInTheLayoutsUnits): PDFBox reads its outlines through a stand-in font in that font's own units, and which stand-in it finds depends on the host.DocxInkOutline(new, package-private) builds the outlines as the page builds them.PdfShapeGeometryrounds them, ellipses, lines, polygons and paths.java.awt.BasicStrokemakes of it, with its cap, its join and the PDF's miter limit of 10, asDocxShapePicturesalready strokes an inline shape.Why not
PptxClipSafety. It asks the stricter question: does a clip provably cut nothing, so a slide can keep native shapes. It treats any stroked path, and any text near an edge, as possibly cut. On the corpus it leaves 177 clips unproven — 34 SVG icons and 101 shift chips among them — of which 2 cut.render-docxdoes not depend onrender-pptx.DocxLayoutMetrics.clipsOf(node)returns the clips a node opens on each page, with what the page paints until each one closes, in paint order. A clip composed in a table cell comes back among the table's own fragments.DocxSemanticBackend.reportClipCutruns at the top ofwriteNodeContent, which every write path goes through. It names a clip that cuts something:clipped shape container/clipped layer stack: "its clip is not in the file, so what its layers paint past its outline / box is written whole";clipped cell contenton a table, for a clip composed in its cells.With no layout behind the export — a direct
export(graph, context)— there is nothing to measure by. Every node that clips is then named, with "whether they do is not measured".letterReachwrapsDocxInkand the page's seating, and never fails the export.Notes reworded:
shape container: "its layers are written inline, one after another in source order". It no longer claims a clip.cell drawingnote and the one-time fallback log no longer speak of clips.drawOutlineOfnames the transform of a shape container whose outline draws nothing — unpainted, or an outline no shape shows: "its transform is not carried, so what it holds stands upright at its size".Ledger. A layer stack's
clipToBoundsand a shape container'sclipPolicyandtransformmove from a gap toREPORTED; 12 node-field gaps remain, each named.Docs. The recipe (shape containers, transforms, SVG icons), the capability matrix (the clip and transform rows) and the CHANGELOG say what each note names.
Verification
./mvnw -B -ntp install -pl :graph-compose-render-docx→ BUILD SUCCESS: 1063 tests, 0 failures, 1 skipped (the property-gated fidelity probe).DocxClipInkTestis new, 21 tests:DocxClipReportTestis new, 12 tests.OVERFLOW_VISIBLEaside.OVERFLOW_VISIBLE;OVERFLOW_VISIBLEthere.DocxFidelityCorpusTest -Dgraphcompose.docxFidelity=export, SHA-256 per file, 0 of 62 differ.LumaStudioInvoice's sidebar ornament, in both of its documents: circles set past the sidebar's side. Not named:CobaltRota's shift chips, composed in cells.-pl :graph-compose-core -Dtest='com.demcha.documentation.**'→ 166 tests, 0 failures;DocxPageZoneTest,DocxTransparentWrapperTest,TimelineRailAcrossBackendsTestandRtlAcrossBackendsTest→ 50 tests, 0 failures.Lane: render-docx backend (report only, no change to what is written) plus tests and docs.