Repository navigation
fix(docx): set a canvas's side-by-side text where the page sets it - #1086
Merged
Merged
Conversation
A canvas was written to DOCX as its contents: its drawings where it placed them, its text one block under another from its corner. A canvas that places its text side by side or out of reading order came out with all of it stacked at its left edge - TwinOutputExample's 43 lines as much as 820pt off in Word 16 and LibreOffice, the Maven banner's caption on the next page and the four pages after it one page later. Such a canvas in the body's flow, holding only drawing and plain paragraphs, is now written over its page, as a block laid over the flow is: its drawings where the page draws them, each paragraph in a text box where the page sets it. The flow holds the canvas's room where something follows it, in an exact-height line where the canvas opens a page, whose top Word and LibreOffice drop a paragraph's space above at. A canvas whose blocks read down one under another - a CV's name over its title - stays in the flow, where a reader of the flow reaches its text; so does one anywhere else, or holding a link, a picture, a table or any other block. Each is named as before.
A canvas written over its page owed its room as space to the next block, so a canvas alone on its page - a cover before a paragraph on the next page, the first of two pages that are each a canvas - wrote nothing on that page, and its text boxes, carried by a paragraph on their page, were dropped. Such a canvas now holds its room in the exact-height line it already writes where it opens a page, and the line carries them there. A canvas last in the flow is recorded as written over it, so a closing paragraph after a table stands below what it draws. The canvas report test keeps its single caption without a link: one block always reads down, so the link was never what kept it in the flow.
A canvas alone on its page and not followed there - a cover or a slide before a page break, a deck's last page - wrote no room line, so its text boxes were carried by the page break's paragraph or the closing one, set at the page's top. Word set a box placed from the page's edge whose top fell within that paragraph's line on the line's baseline, 7pt high; LibreOffice did not. It now writes its line whether or not anything follows it, and the line carries them. A page break right after that line goes in the line: its own paragraph, under a line filling its page, stood on the next page and broke it again - three canvas pages split by breaks came out as four in Word and LibreOffice.
…tion A page set against other margins than the page before starts a Word section, ended by the paragraph before it. A page break written in that paragraph - the one after a canvas alone on its page now goes in the line holding its room - stayed in front of the section's own break and would open a blank page. It is taken out, as a page break's own paragraph's is; the paragraph keeps its height and what it carries. The canvas's report note now says its room is in the flow where the flow holds it: nothing is written for a canvas nothing follows on a page it shares.
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 canvas (
addCanvas,CanvasLayerNode) was written to DOCX as its contents: its drawings stood where it placed them, and its text one block under another from its corner. A canvas that places its text side by side or out of reading order — a poster, a slide — came out with all of it stacked at its left edge.Measured by baseline against the engine's PDF, in Word 16 and LibreOffice 26.8:
TwinOutputExample(one 960×540pt page that is one canvas): Word set every one of its 43 lines, and LibreOffice every one it set, as much as 820pt across and 222pt down from the page.MavenBannerPptxExample: the first page is a canvas; its caption went to page 2, and the four flow pages after it each came one page later — 6 pages in both editors where the page has 5.What changed
DocxSemanticBackend.writeCanvasnow writes such a canvas over its page (writeCanvasOverItsPage) — the path a block laid over the flow already takes (laidOverTheFlow/writeTextOverTheFlow,LumaStudioInvoice's sidebar): its drawings stand where the page draws them, each paragraph in a text box where the page sets it, anchored in a paragraph on its page.Its room in the flow:
holdItsRoomInALine), whether or not anything follows it. Word and LibreOffice drop a paragraph's space above at the top of a page: owed as that space, the paragraph under a canvas moved to a new page stood 139.8pt high in both, and after a page break 119.8pt; held in the line, within 0.3pt. The bottom margin is in the line because, owed below it, the line fitted at the foot of the page above where the canvas did not;aloneOnItsPage: the layout puts nothing else there) — the same line, which is then what carries its text boxes on that page. Owed as space, a cover filling the first page before a paragraph on the second, and the first of two pages that are each a canvas, had nothing written on their page and their text was dropped. Carried by a page break's paragraph or the closing one instead, both at the page's top, a box placed from the page's edge whose top fell within that paragraph's line was set on its baseline by Word — 7pt high — and not by LibreOffice;writePageBreak): its own paragraph, under a line filling its page, stood on the next page and broke it again — three canvas pages split by breaks came out as four in both editors. Where the next page is set against other margins (pageMargins),DocxPageMarginSectionsends the section with that line and now takes its page break out, as it takes out a break's own paragraph's — kept, it would open a blank page before the section's own break — and the line keeps its height;holdTheSpaceOf), as for a canvas that only draws;hangBelowTheFlow, so a closing paragraph after a table stands below what it draws.A line in the middle of a page is not written: it sets the paragraph under it 0.3pt low in both editors (its first line is raised into the space above it, which a line leaves none of).
It applies only where that path can carry the canvas (
writesOverItsPage) and where the flow cannot:CanvasWrites.readsDown, new). A canvas whose blocks read down one under another stays in the flow, where a reader of the flow reaches its text —MintEditorial's masthead with a header band (name over title) is that, and is written as before;floatable): a link, a bookmark, an anchor, a picture, a table, a list or any other block keeps it written as its contents, named as before.Report: the canvas is named
written over its page: …, and each paragraphplaced by its canvas where one block under another would not stand: set in a text box where the page sets it, anchored …— the over-the-flow lead (laid over the flow, which gives it no room) is not true of a canvas, which holds its room.No public API changes.
Measured after
TwinOutputExampleMavenBannerPptxExamplepage 1CanvasLayerExampleTwo paragraphs break otherwise, by the text-box path's existing width rule (a box of several lines is its width plus the editor's 2pt):
TwinOutputExample's Lead, set at 12.3pt and written at 12.5pt — a Word file holds a size to the half point — breaks a word sooner in both editors, andCanvasLayerExample's centred citation, whose first line the engine broke within a point of its 443pt width, takes one more word in both.MintEditorialwith a header band writes the same bytes as before.LibreOffice here is the Windows 26.8 build, not CI's 24.2. CI's
DOCX Fidelity (LibreOffice)job runs the corpus on 24.2; the corpus has no canvas that places its text side by side, so it does not reach this path.Tests
DocxCanvasOverItsPageTest(new, 16): paragraphs set in text boxes at the canvas's places (page-relative x, offsets between boxes), none in the flow, boxes in front of the text; the canvas and paragraph notes; a canvas stacking from its corner, and one whose blocks read down, stay in the flow; a link or a picture keeps it as its contents; as a shape container's layer, in a stack of one layer, in a painted panel and in a table cell it is written as its contents; the room line where it opens a page the layout moves it to and after a page break; no room held before a page break; a cover and two page-sized canvases carried on their own pages with nothing dropped; a page break after a canvas alone on its page written in its line; last after a table, the closing paragraph set below what it draws.DocxPageMarginSectionsTest.aPageBreakInTheLineBeforeOtherMarginsBecomesTheSectionsBreakAndTheLineKeepsItsHeight: no page break left, the section ends with the line, which keeps its height and carries the text boxes.DocxCanvasRoomTest.aCanvasWrittenOverItsPageHoldsItsWholeRoom: the flow after it stands its margins and height below, as on the page.