Repository navigation
fix(docx): draw a cell's rule once, a thick line at its thickness, a shape before a break - #905
Merged
Merged
Conversation
…shape before a break A rule composed in a table cell was written as a paragraph border and drawn again by its table, which draws what its composed cells paint: every line in such a cell stood twice in Word, and one centred by addAligned was drawn centred and written again at the cell's left. writeRule now takes its drawing from the table's waiting drawings and is written where it places it. It takes one only where nothing else can be it - as many drawings like it wait in the cell as rules like it are left to write, and the rule stands in the cell itself; otherwise both stay and the report says the rule stands twice. The table's cell drawing note is written only where something its rules did not take is drawn. A horizontal line thicker than Word's 12pt border was written as a 12pt border; it is drawn as a shape at its thickness, holding its room in the flow and in a stack of one layer, and named as holding none in a cell. A shape alone on a page before a page break was dropped under a note saying it was drawn. The break's paragraph now carries its page where nothing else written there does. A drawing nothing carries is named on its own note, DROPPED, which DocxDrawingAnchors learns from the owner each queued shape is drawn for.
… as it is matched A rule's drawing reaching past its cell was not counted among the drawings like it, so an underline as thick laid over a mark could be taken for the rule's and lost, the rule's own drawing left standing twice unnamed. The drawings like a rule are now those reaching into its cell at all. Rules are counted alike as their drawings are matched, so a short rule before a full-width one of the same stroke each take their own; a refused rule's note no longer names a reason it may not have. A line too thick to be a rule holds its room among the text of a stack of one layer whether or not something follows it there, as a rule does, and only a line in the flow of its cell is named as taking no room there. The recipe ranks a page break's paragraph last among a page's carriers, as the export does.
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
Three drawings the DOCX export lost or doubled, while its report said nothing or said otherwise.
DocumentTableCell.node(...)) paint as shapes (drawCellDrawing). A cell's line or bar is also written as a rule: a paragraph whose bottom border is the stroke.invoice-obsidian,invoice-platformandproposal-indigo.addAligned(...)was drawn centred, and written again at the cell's left.DocxDrawingAnchors.endSectionfound no paragraph on that page to anchor it in, and named only "1 shape(s) on page 1".What changed
DocxRules.ofLinerefuses a line stroked thicker thanMAX_RULE_POINTS, asofShapealready refused a bar.inTheFlow).DocxRules.thickerThanABorder).writeRulein a composed cell takes its drawing (takeTheDrawingOf) from the table's waiting drawings.collectRulesin writing order,drawnAlikematchingdrawingsOf). This rule must be the next one. And it must be written in the composed cell itself.cellMarginOf), so a centred line is written centred.cell drawingnote is written after its rows, and only where something its rules did not take is drawn.DocxDrawingAnchors.breakOn). A break's paragraph after a table that fills its page would flow to the next page, so the cell paragraph comes first.DocxDrawingAnchorskeeps, for each queued shape, the note it is drawn for (Owner). The owners are drawn nodes, a drawn picture, a text box over the flow, a timeline's rail, and a table's cell drawings.endSectionreturns, per owner, whether all its shapes were anchored nowhere.DROPPEDnote in the place of each note that said the drawing was there, within the section (DocxExportReport.Builder.replace), or adds one naming the part where only some of its shapes went.docs/recipes/docx-export.mdandbackend-capability-matrix.md: the thickest rule, the rule composed in a cell (and when it stands twice), the break's paragraph and the uncarried drawing.CHANGELOG.md: an entry for the three fixes.Verification
invoice-obsidiankeeps its 5 composed-cell borders and loses the 5 duplicate lines drawn over them.DocxCellRuleTest, 12 tests. It covers:cell drawingnote where only rules are composed.DocxDrawingCarrierTest, 2 tests. A shape before a break is anchored in the break's paragraph. A shape on a page no paragraph is written on has oneDROPPEDnote on itself, and no page note.DocxDrawingAnchorsTest, 2 new tests. It covers an owner carried in part against one dropped whole, and a break's paragraph used only where no cell paragraph stands on its page.DocxExportReportTest, 1 new test.replacereaches only the section's notes, and every one of them.DocxRuleTest.aThickStrokeStopsAtWordsThickestBorderpinned the 12pt border. It is nowaStrokeThickerThanWordsThickestBorderIsDrawnAtItsThickness: a 12pt stroke is still the thickest border, and a 20pt one is drawn.replacenot scoped;drawnAlikeout of step withdrawingsOf;2.5-dev. The other 3 differ only by the 14 duplicate line drawings removed; their rule paragraphs are the same. Report notes go from 1246 to 1244: twocell drawingnotes on tables whose cells draw only rules../mvnw -B -ntp clean verify→ BUILD SUCCESS (render-docx 1617, qa 1820).Lane: render-docx (
DocxSemanticBackend,DocxRules,DocxDrawingAnchors,DocxExportReport).