Repository navigation
fix(docx): name a layer written under the layers the page lays it over - #904
Merged
Merged
Conversation
A layer stack's layers are written one after the other, as a band or in a column's cell, each resuming the page's distance below the layers before it. Where the page starts a layer above where those end, that distance was clamped to nothing and the layer written under them in silence: a caption over the foot of its photo, a label in a card's corner, text over text. DocxLayerColumns.flow now records, in Plan and Band, how far above where the layers before it end the page starts a layer's highest block, a panel among them ending at its box's foot; within half a point is touching. writeOverlayBand and writeLayerColumns name such a layer (overlapping layer). A stack composed in a table cell, with no place of its own, is named with its layers not measured. The resume is measured as before, so the file does not change. The ledger's LayerStackNode.layers is REPORTED.
The note measures from a layer's highest block, so it says so, and it names a shape container's band as one. The not-measured note is written only for a stack writing more than one layer: the docs, the ledger and the changelog say so, and name an export with no layout too. The changelog's corpus claim is narrowed to what was measured, and the recipe names the one clamp left unnamed: a layer nearer the layers before it than its own top margin. Tests cover a title over a badge in a shape container, a stack writing one layer over a drawing in a cell, and an export with no layout; the number in a note is read without an uncaught NumberFormatException.
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 writes one block under another. So a layer stack's layers go into the file one after the other: as one band (
DocxLayerColumns.band), or one after another in a column's cell (DocxLayerColumns.of). Each later layer resumes the page's distance below the layers before it.Where the page starts a layer above where those layers end, that distance is below zero, and
resumeclamped it to nothing. What the layer writes in the flow was written under them, and the report said nothing:A stack composed in a table cell has no place of its own, and neither has any stack exported with no layout, so neither is a band nor columns. Their layers were written one after another with nothing said either. The ledger called
LayerStackNode.layersWRITTEN.What changed
DocxLayerColumns.flowmeasures where the layers before a layer end (endOf) against the top of the layer's highest written block (highestLeaf).EDGE) above their end is recorded inover, whichPlanandBandboth carry. Half a point or less is a layer touching the one above it.spaceAbovereturns the gap to the first block's box, and the caller takes the block's margin off. The file does not change.overwith the panel predicate.bandnow takes it asDocxSemanticBackend::paintsAPanel, which the columns' painted predicate shares.writeOverlayBandandwriteLayerColumnsname such a layer. The note isoverlapping layer, "the page starts its highest block N pt above where the layers before it in its stack|shape container|column end, and Word writes one block under another: what it writes in the flow is written under them".writeContainerChildrennames a stack that writes more than one layer and has no place in the layout. That is a stack composed in a table cell, or one exported with no layout. Its note says its layers are written one after another, and that whether the page lays one over another is not measured. A stack writing a single layer over drawing is not named.LayerStackNode.layersisREPORTED.docs/recipes/docx-export.md: the band bullet names both notes, and the limit below.backend-capability-matrix.md: the layer stack row names both notes. A clause sayingSidebarPortrait's subtitle stands under its name strip is gone: since fix(docx): write a strip drawn in two layers as one strip #765 the export writes it in the strip, in the same cell as the name.CHANGELOG.md: an entry for the notes.Verification
Word. The probe documents, converted through Word and measured with PyMuPDF:
Each was written under the layers before it.
DocxOverlappingLayerTest, 14 tests. It covers:Expected numbers are read off the layout.
DocxOverlayBandTest, 1 new test. It pins that a later layer's top margin is written once in the gap above it.Sabotage, 14 of 14 caught:
EDGE;Corpus. All 62 DOCX are byte-identical to
2.5-dev, and the reports are unchanged at 1246 notes.Build.
./mvnw -B -ntp clean verify→ BUILD SUCCESS (render-docx 1599, qa 1820).Notes for review
>and>=cannot be told apart by a stable test. The test checks 0.3pt and 1pt.Lane: render-docx (
DocxSemanticBackend,DocxLayerColumns) — report and ledger only, the file unchanged.