Repository navigation
fix(docx): stop reporting drawn tiles as dropped and alike corners as unequal - #902
Merged
Merged
Conversation
… unequal A table whose composed cells hold a box framing text leaves that box to the panel it is written as, and draws its other cells' boxes. Asked of the whole table whether it skipped a box, a tile, a shape or a rounded box in another cell was reported DROPPED, "not in the document", while it stood drawn. CellDrawing now keeps the boxes it skipped, and a box node is reported only in a cell one of them reaches into, past its edges included; with no cell box known it is reported as before. The page holds each corner's radius to half the box's shorter side and Word's rounded rectangle its one, so radii that differ only past that are drawn alike: 10 and 12 on a box 20 tall are both 10. DocxDrawings. roundsUnequally compares the held radii. A drawn shape's corners are now read off its fragment, as every drawn box's are; one composed in a cell, drawn as wide as its cell, is held to half its height.
…shape is still named A box framing text that reaches into none of its table's rows, pushed out by a layer's offset or a negative margin, stands in no cell the report can ask: that table now keeps the table-wide answer, and a box node there is still reported rather than lost in silence. A shape composed in a table cell is held to half its height, its width being the cell's; the CHANGELOG and the recipe now say one in a cell narrower than it is tall can still be named. Tests pin the shape that is not named, and the dropped box by its own note.
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
Two notes in the DOCX export's report claimed losses the export did not make.
A tile reported dropped while drawn. A table whose composed cells hold a box framing text leaves that box to the panel it is written as, and draws its other cells' boxes.
drawnByItsTableasked one table-wide flag whether the table skipped a box, so with a panel in one cell, a box node in any other cell was reportedDROPPED"… so it is not in the document". Probed in a two-cell table:document.xmlrect,ellipseDROPPED"shape container outline … not in the document"ShapeNoderectDROPPED"ShapeNode … its geometry has no semantic Word analogue"roundRect,ellipseDROPPEDCorners named unequal that are drawn alike. "its corners are drawn at the largest of their radii" was said wherever the radii differ. But the page holds each radius to half the box's shorter side (
PdfShapeFragmentRenderHandler.clampCornerRadius), and Word's rounded rectangle caps its one radius there too (DocxDrawings.roundness). So radii of 10 and 12 on a box 20 tall are both drawn at 10, in both, and the note named a loss that is not there.What changed
CellDrawing. It keeps the fragments it skipped instead of a flag; nested tables add theirs to the outer one's.skippedBoxes()stays for the row-paint note, which is about the whole table.drawnByItsTable. It asksskippedABoxInThisCell(): whether a skipped box reaches into the composed cell being written (CellBox.overlapsagainstcomposedCellBoxes, the boxes the layout placed that cell in). Overlap, not containment: a fixed box wider than its column still stands in its cell, and a box reaching into the next cell counts there too. The layout does not say which of a cell's boxes is which node. So in a cell a skipped box reaches into, a box node is still reported, asaBoxLostInACellIsStillReportedWhenItsTableDrawsSomethingElsepins. In any other cell, the table drew it. A skipped box that reaches into none of its table's rows (pushed out by a layer's offset or a negative margin) stands in no cell the report can ask, so that table keeps the old table-wide answer, as it does where no cell box is known.DocxDrawings.roundsUnequally(radius, width, height). It holds each radius to half the shorter side, as the page does, and compares the results. It decides at all three places the corner note is made:roundsCornersUnequally);ShapeNodein the flow, now read off its drawn fragment like the rest, where it was decided byisUniformalone. Its corner phrase now comes before a gradient's in its note;ShapeNodecomposed in a cell (cornersDiffer). A cell lays a shape out at its own width, so aShapeNodethere is held to half its height, which it is drawn at. That bound never misses a difference the page draws. A shape in a cell narrower than it is tall can still be named; the CHANGELOG and the recipe say so.Verification
DROPPEDafter the change, and the drawings indocument.xmlare the same.2.5-dev's, and all 1332 notes are unchanged: no corpus document holds either case.DocxComposedCellTest.aBoxInACellBesideOneItsTableLeavesToAPanelIsDrawnAndNotReportedDroppedhas a panel, a tile and a shape in one row. It asserts noDROPPEDnote and the three drawings.DocxCarriedWithoutReportTest.cornersWhoseRadiiDifferOnlyPastHalfTheShorterSideAreNotNamedchecks a shape, a container in the flow and a container in a cell. With radii 10/12 on a 20-tall box none of them is named; with 8/12 all of them are.aSectionDrawnOverTheFlowWithCornersOfDifferentRadiiSaysTheyAreDrawnAtTheLargestused a section whose box the layout makes 39.69 × 2.95pt. There its radii 2 and 8 are both drawn at 1.475. The section now has 10pt of padding, so its radii differ as drawn.DocxComposedCellTest.aBoxReachingPastItsCellIsStillReportedWhereItsTableLeftIt: a 140pt box framing text in a 60pt column is still reportedDROPPED.DocxComposedCellTest.aBoxPushedOutOfEveryCellIsStillReported: a box framing text pulled above its table by a negative margin is still reportedDROPPED.DocxCarriedWithoutReportTest.aShapeComposedInACellNamesTheCornersItIsDrawnWithAtTheCellsWidth: a 20 × 40 shape with radii 10/12 in a 100pt cell is drawn 100 wide, so its corners are named; a 20 × 20 one beside it holds both at 10 and is not.DROPPEDon a nested drawing the table does draw, so the flag is carried as the skipped boxes are, untested../mvnw -B -ntp clean verify→ BUILD SUCCESS (render-docx 1581, qa 1820).Lane: render-docx — report notes only; the Word file is unchanged