Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ follow semantic versioning; release dates are ISO 8601.

### Public API

- **A table or row the layout moves to a new page keeps its top edge there in DOCX.**
The page starts a block a page break moves down at its own top edge, and leaves the gap
before it at the foot of the page above where it fits there. Word has no space above a table, so the edge was
written below the paragraph before it, on the page above, and the long `LumaStudioInvoice`'s
closing pair stood 12pt high at the top of its third page. The edge is now a line of that
height kept with the table: Word drops a paragraph's space above at the top of a page, and
keeps a line's height. `LumaStudioInvoice`'s lines more than 2pt off fall from 20 to none
in Word, and from 22 to 2 in LibreOffice.
- **A paragraph opening a table cell keeps its lines the page's distance apart in DOCX.**
Word holds a paragraph's line gap inside its lines, and a paragraph of `n` lines then has a
gap too many, which comes off the space above it. A paragraph opening a cell has none, so
Expand Down
2 changes: 1 addition & 1 deletion docs/recipes/docx-export.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ creation date is real metadata.
|---|---|
| Paragraphs | Word paragraphs with alignment, font, size, colour, bold/italic/underline; inline runs preserved; a `\n` in the text is a line break (`w:br`), which Word would otherwise read as a space; a table cell's `text("a\nb")` stays one line, as the page sets it; a `bulletOffset` of spaces is an indent — the wrapped lines (`FROM_SECOND_LINE`), the first (`FIRST_LINE`) or all of them start that far in, measured in the paragraph's style as the page measures it; a prefix with letters in it is not written, but the wrapped lines still start after the spaces the page covers it with; no prefix is applied to a paragraph written over the flow, as one of an overlay's left-and-right pair, or in a header or footer |
| Lists | Real Word lists: a `numbering.xml` definition per list, `w:numPr` on each item, and the authored marker as the level's text. Nesting is a list level, so Enter continues the list and Tab demotes an item. See "What a list becomes" below for the kinds that stay plain paragraphs |
| Tables | Word tables, one cell per cell. Each cell states its own padding, on all four sides, so a row is as tall as the page draws it: as `w:tcMar`, and above and below partly in its paragraphs. Word and LibreOffice give every cell of a row the largest top and bottom margin of any cell in it, so a row's cells are written with its smallest, and the rest of a cell's padding above and below is space above its first paragraph and below its last (measured: a row whose day cells were padded 5.5pt above and 10.25pt below beside a label padded 0.75pt stood 60.3pt tall in both editors, where its tallest cell came to 46). A cell opening with a table has no paragraph above it to hold its padding, and a cell in a vertical merge has its bottom edge in another row: these keep their margins, and the row's comes down no lower than the largest of them. Its padding above and below gives up the room Word makes for the table's horizontal rules — half of a rule between two rows to each, the lower row's rule where the two differ, the rule above the table and the one below it whole to their row — which the page does not (measured: a 0.75pt rule made each row 0.75pt taller). A cell that holds nothing but an empty line — a row that is only a rule, its thickness the empty cell's font — has that line cut to the room its row leaves it, the page's row less the cell's own margins and border: the page draws the rule's borders across the line, and Word and LibreOffice keep them outside it and grow the row (measured: `CobaltRota`'s two rules under a 0.9pt border stood 0.9pt taller each). A line with letters, a picture or a paragraph border of its own keeps its height. A table that states no rule is written with the engine's default 1pt black rule, as the page draws it, not left on Word's thinner grid. Its `textAnchor` becomes `w:vAlign` and the paragraph's `w:jc`, with the engine's default — the vertical middle, on the left — where Word's is the top, so a line beside a taller neighbour sits where the page puts it and an amount column stays right-aligned. A cell with no style of its own is set in the engine's default cell face rather than the document's Normal. A cell's lines are one paragraph with line breaks; when its style's `lineSpacing(...)` is above zero and it has more than one line, they are a paragraph each, with the spacing after every line but the last, since Word has no space between the lines of one paragraph but a taller line. A column sized to its content gets a point more than the page gives it, so the editor's font substitute cannot wrap its widest cell. The width is written when the document states one or every column is fixed; otherwise Word sizes the table — see "What falls back". A table breaks across pages where the layout breaks it: every row the layout placed is kept whole (`w:cantSplit`), `repeatHeader(n)` rows repeat on each page (`w:tblHeader`) and stay with the row under them. Two tables in a row — rows included, since a row is carried as a table — are kept apart by a paragraph a tenth of a point tall, holding the rest of the gap between them: an editor joins two tables with nothing between them into one |
| Tables | Word tables, one cell per cell. Each cell states its own padding, on all four sides, so a row is as tall as the page draws it: as `w:tcMar`, and above and below partly in its paragraphs. Word and LibreOffice give every cell of a row the largest top and bottom margin of any cell in it, so a row's cells are written with its smallest, and the rest of a cell's padding above and below is space above its first paragraph and below its last (measured: a row whose day cells were padded 5.5pt above and 10.25pt below beside a label padded 0.75pt stood 60.3pt tall in both editors, where its tallest cell came to 46). A cell opening with a table has no paragraph above it to hold its padding, and a cell in a vertical merge has its bottom edge in another row: these keep their margins, and the row's comes down no lower than the largest of them. Its padding above and below gives up the room Word makes for the table's horizontal rules — half of a rule between two rows to each, the lower row's rule where the two differ, the rule above the table and the one below it whole to their row — which the page does not (measured: a 0.75pt rule made each row 0.75pt taller). A cell that holds nothing but an empty line — a row that is only a rule, its thickness the empty cell's font — has that line cut to the room its row leaves it, the page's row less the cell's own margins and border: the page draws the rule's borders across the line, and Word and LibreOffice keep them outside it and grow the row (measured: `CobaltRota`'s two rules under a 0.9pt border stood 0.9pt taller each). A line with letters, a picture or a paragraph border of its own keeps its height. A table that states no rule is written with the engine's default 1pt black rule, as the page draws it, not left on Word's thinner grid. Its `textAnchor` becomes `w:vAlign` and the paragraph's `w:jc`, with the engine's default — the vertical middle, on the left — where Word's is the top, so a line beside a taller neighbour sits where the page puts it and an amount column stays right-aligned. A cell with no style of its own is set in the engine's default cell face rather than the document's Normal. A cell's lines are one paragraph with line breaks; when its style's `lineSpacing(...)` is above zero and it has more than one line, they are a paragraph each, with the spacing after every line but the last, since Word has no space between the lines of one paragraph but a taller line. A column sized to its content gets a point more than the page gives it, so the editor's font substitute cannot wrap its widest cell. The width is written when the document states one or every column is fixed; otherwise Word sizes the table — see "What falls back". A table breaks across pages where the layout breaks it: every row the layout placed is kept whole (`w:cantSplit`), `repeatHeader(n)` rows repeat on each page (`w:tblHeader`) and stay with the row under them. Two tables in a row — rows included, since a row is carried as a table — are kept apart by a paragraph a tenth of a point tall, holding the rest of the gap between them: an editor joins two tables with nothing between them into one. A table or a row the layout moves to a new page keeps its own top edge there, as the page does — written as a line that tall, kept with it, since Word drops a paragraph's space above at the top of a page — while the gap between it and the block before stays at the foot of the page above, where it fits there; a paragraph moved to a new page does not yet keep its own |
| Composed cells (`DocumentTableCell.node(...)`) | Written by the same writers that write that node anywhere else, so a cell built from an image, a list or a table carries it. A nested table is a real `w:tbl` followed by the paragraph Word requires a cell to end with — a hairline, which the paragraph written next in the cell takes over, so no empty line opens under the table, and whose mark is hidden where it is left at the cell's end holding nothing and no space, since LibreOffice lays it out — and takes the width of the column it sits in — the column's, not the one the page gives it, because the layout reports a composed cell's content under the owner's path |
| Inline chips (`inlineCode(...)`, `inlineChip(...)`, `highlight(...)`) | The chip's fill becomes the run's own `w:shd`, in a paragraph and in a list item alike. Its shape does not travel — see "What a chip keeps and loses" below |
| Images | Embedded pictures at the node's declared size |
Expand Down
40 changes: 20 additions & 20 deletions qa/src/test/resources/docx-fidelity/libreoffice-linux-lines.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2604,26 +2604,26 @@ invoice-luma_studio_long 1:a894ec54e7f3 0.32 £1,700.00
invoice-luma_studio_long 1:57a66d21eb1b -0.92 totaldue
invoice-luma_studio_long 1:b4cb2a644826 0.51 £10,200.00
invoice-luma_studio_long 1:60fd7eb93483 0.01 page2of3
invoice-luma_studio_long 2:ab5aa97074c4 -11.83 notes
invoice-luma_studio_long 2:7c6ab37d83ef -12.15 thankyouforyourbusiness.
invoice-luma_studio_long 2:3d717dfb25d8 -12.20 ifyouhaveanyquestionsregarding
invoice-luma_studio_long 2:479a74142336 -12.24 thisinvoice,pleasegetintouch.
invoice-luma_studio_long 2:1960744391ed -12.28 allworkremainstheintellectualpro
invoice-luma_studio_long 2:eeb53247f32c -12.33 ofluma&co.studiountilpayment
invoice-luma_studio_long 2:9eef22d7d34e -12.37 hasbeenreceivedinfull.
invoice-luma_studio_long 2:3c7ade679fdf -11.83 paymentdetails
invoice-luma_studio_long 2:b1819c9cd5bf -12.10 pleasemakepaymentbybanktransfert
invoice-luma_studio_long 2:8c1e4a24f6a8 -11.86 luma&co.studioltd
invoice-luma_studio_long 2:4381dc2ab142 -11.90 bank
invoice-luma_studio_long 2:447827e26127 -11.90 starlingbank
invoice-luma_studio_long 2:10aeacde20ff -11.90 sortcode
invoice-luma_studio_long 2:c14b2f2f32e4 -11.90 60-83-71
invoice-luma_studio_long 2:f5bd52edd4c2 -11.90 accountno.
invoice-luma_studio_long 2:4e20613ec3a6 -11.90 98765432
invoice-luma_studio_long 2:d53cd2cae33d -11.89 iban
invoice-luma_studio_long 2:279d55d978a1 -11.89 gb36srlg60837198765432
invoice-luma_studio_long 2:e398486c0acf -11.89 bic
invoice-luma_studio_long 2:ddc998160ae0 -11.89 srlggb2l
invoice-luma_studio_long 2:ab5aa97074c4 0.17 notes
invoice-luma_studio_long 2:7c6ab37d83ef -0.15 thankyouforyourbusiness.
invoice-luma_studio_long 2:3d717dfb25d8 -0.20 ifyouhaveanyquestionsregarding
invoice-luma_studio_long 2:479a74142336 -0.24 thisinvoice,pleasegetintouch.
invoice-luma_studio_long 2:1960744391ed -0.28 allworkremainstheintellectualpro
invoice-luma_studio_long 2:eeb53247f32c -0.33 ofluma&co.studiountilpayment
invoice-luma_studio_long 2:9eef22d7d34e -0.37 hasbeenreceivedinfull.
invoice-luma_studio_long 2:3c7ade679fdf 0.17 paymentdetails
invoice-luma_studio_long 2:b1819c9cd5bf -0.10 pleasemakepaymentbybanktransfert
invoice-luma_studio_long 2:8c1e4a24f6a8 0.14 luma&co.studioltd
invoice-luma_studio_long 2:4381dc2ab142 0.10 bank
invoice-luma_studio_long 2:447827e26127 0.10 starlingbank
invoice-luma_studio_long 2:10aeacde20ff 0.10 sortcode
invoice-luma_studio_long 2:c14b2f2f32e4 0.10 60-83-71
invoice-luma_studio_long 2:f5bd52edd4c2 0.10 accountno.
invoice-luma_studio_long 2:4e20613ec3a6 0.10 98765432
invoice-luma_studio_long 2:d53cd2cae33d 0.11 iban
invoice-luma_studio_long 2:279d55d978a1 0.11 gb36srlg60837198765432
invoice-luma_studio_long 2:e398486c0acf 0.11 bic
invoice-luma_studio_long 2:ddc998160ae0 0.11 srlggb2l
invoice-luma_studio_long 2:543a2e86433f 0.23 thankyouforchoosingluma&co.studi
invoice-luma_studio_long 2:7111b3fcbf69 -0.08 paymentisdueby19june2024.
invoice-luma_studio_long 2:bc6d215b63ee 0.01 page3of3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ invoice-classic_long 2 2 166 166 0.20 0.27 0
invoice-consulting 1 1 92 92 0.87 1.16 3
invoice-consulting_long 2 2 236 236 0.79 1.26 3
invoice-luma_studio 1 1 97 97 0.12 0.52 2
invoice-luma_studio_long 3 3 192 192 0.24 11.83 22
invoice-luma_studio_long 3 3 192 192 0.20 0.41 2
invoice-merchant 1 1 94 94 0.73 1.72 5
invoice-metered 1 1 99 99 0.91 10.00 48
invoice-modern 1 1 54 54 0.07 0.20 0
Expand Down
40 changes: 20 additions & 20 deletions qa/src/test/resources/docx-fidelity/libreoffice-windows-lines.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2509,26 +2509,26 @@ invoice-luma_studio_long 1:a894ec54e7f3 0.32 £1,700.00
invoice-luma_studio_long 1:57a66d21eb1b -0.92 totaldue
invoice-luma_studio_long 1:b4cb2a644826 0.51 £10,200.00
invoice-luma_studio_long 1:60fd7eb93483 0.01 page2of3
invoice-luma_studio_long 2:ab5aa97074c4 -11.83 notes
invoice-luma_studio_long 2:7c6ab37d83ef -12.15 thankyouforyourbusiness.
invoice-luma_studio_long 2:3d717dfb25d8 -12.20 ifyouhaveanyquestionsregarding
invoice-luma_studio_long 2:479a74142336 -12.24 thisinvoice,pleasegetintouch.
invoice-luma_studio_long 2:1960744391ed -12.28 allworkremainstheintellectualpro
invoice-luma_studio_long 2:eeb53247f32c -12.33 ofluma&co.studiountilpayment
invoice-luma_studio_long 2:9eef22d7d34e -12.37 hasbeenreceivedinfull.
invoice-luma_studio_long 2:3c7ade679fdf -11.83 paymentdetails
invoice-luma_studio_long 2:b1819c9cd5bf -12.10 pleasemakepaymentbybanktransfert
invoice-luma_studio_long 2:8c1e4a24f6a8 -11.86 luma&co.studioltd
invoice-luma_studio_long 2:4381dc2ab142 -11.90 bank
invoice-luma_studio_long 2:447827e26127 -11.90 starlingbank
invoice-luma_studio_long 2:10aeacde20ff -11.90 sortcode
invoice-luma_studio_long 2:c14b2f2f32e4 -11.90 60-83-71
invoice-luma_studio_long 2:f5bd52edd4c2 -11.90 accountno.
invoice-luma_studio_long 2:4e20613ec3a6 -11.90 98765432
invoice-luma_studio_long 2:d53cd2cae33d -11.89 iban
invoice-luma_studio_long 2:279d55d978a1 -11.89 gb36srlg60837198765432
invoice-luma_studio_long 2:e398486c0acf -11.89 bic
invoice-luma_studio_long 2:ddc998160ae0 -11.89 srlggb2l
invoice-luma_studio_long 2:ab5aa97074c4 0.17 notes
invoice-luma_studio_long 2:7c6ab37d83ef -0.15 thankyouforyourbusiness.
invoice-luma_studio_long 2:3d717dfb25d8 -0.20 ifyouhaveanyquestionsregarding
invoice-luma_studio_long 2:479a74142336 -0.24 thisinvoice,pleasegetintouch.
invoice-luma_studio_long 2:1960744391ed -0.28 allworkremainstheintellectualpro
invoice-luma_studio_long 2:eeb53247f32c -0.33 ofluma&co.studiountilpayment
invoice-luma_studio_long 2:9eef22d7d34e -0.37 hasbeenreceivedinfull.
invoice-luma_studio_long 2:3c7ade679fdf 0.17 paymentdetails
invoice-luma_studio_long 2:b1819c9cd5bf -0.10 pleasemakepaymentbybanktransfert
invoice-luma_studio_long 2:8c1e4a24f6a8 0.14 luma&co.studioltd
invoice-luma_studio_long 2:4381dc2ab142 0.10 bank
invoice-luma_studio_long 2:447827e26127 0.10 starlingbank
invoice-luma_studio_long 2:10aeacde20ff 0.10 sortcode
invoice-luma_studio_long 2:c14b2f2f32e4 0.10 60-83-71
invoice-luma_studio_long 2:f5bd52edd4c2 0.10 accountno.
invoice-luma_studio_long 2:4e20613ec3a6 0.10 98765432
invoice-luma_studio_long 2:d53cd2cae33d 0.11 iban
invoice-luma_studio_long 2:279d55d978a1 0.11 gb36srlg60837198765432
invoice-luma_studio_long 2:e398486c0acf 0.11 bic
invoice-luma_studio_long 2:ddc998160ae0 0.11 srlggb2l
invoice-luma_studio_long 2:543a2e86433f 0.23 thankyouforchoosingluma&co.studi
invoice-luma_studio_long 2:7111b3fcbf69 -0.08 paymentisdueby19june2024.
invoice-luma_studio_long 2:bc6d215b63ee 0.01 page3of3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ invoice-classic_long 2 2 166 166 0.47 0.87 0
invoice-consulting 1 1 92 92 0.99 1.61 3
invoice-consulting_long 2 2 236 236 0.96 1.41 3
invoice-luma_studio 1 1 97 97 0.12 0.52 2
invoice-luma_studio_long 3 3 192 192 0.24 11.83 22
invoice-luma_studio_long 3 3 192 192 0.20 0.41 2
invoice-merchant 1 2 94 90 0.21 0.67 0
invoice-metered 1 1 99 99 0.25 0.69 0
invoice-modern 1 1 54 54 0.32 0.52 0
Expand Down
40 changes: 20 additions & 20 deletions qa/src/test/resources/docx-fidelity/word-windows-lines.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2603,26 +2603,26 @@ invoice-luma_studio_long 1:a894ec54e7f3 0.52 £1,700.00
invoice-luma_studio_long 1:57a66d21eb1b -0.09 totaldue
invoice-luma_studio_long 1:b4cb2a644826 0.57 £10,200.00
invoice-luma_studio_long 1:60fd7eb93483 0.17 page2of3
invoice-luma_studio_long 2:ab5aa97074c4 -11.75 notes
invoice-luma_studio_long 2:7c6ab37d83ef -12.19 thankyouforyourbusiness.
invoice-luma_studio_long 2:3d717dfb25d8 -12.25 ifyouhaveanyquestionsregarding
invoice-luma_studio_long 2:479a74142336 -12.32 thisinvoice,pleasegetintouch.
invoice-luma_studio_long 2:1960744391ed -12.33 allworkremainstheintellectualpro
invoice-luma_studio_long 2:eeb53247f32c -12.41 ofluma&co.studiountilpayment
invoice-luma_studio_long 2:9eef22d7d34e -12.36 hasbeenreceivedinfull.
invoice-luma_studio_long 2:3c7ade679fdf -11.75 paymentdetails
invoice-luma_studio_long 2:b1819c9cd5bf -12.07 pleasemakepaymentbybanktransfert
invoice-luma_studio_long 2:8c1e4a24f6a8 -11.82 luma&co.studioltd
invoice-luma_studio_long 2:4381dc2ab142 -11.91 bank
invoice-luma_studio_long 2:447827e26127 -11.91 starlingbank
invoice-luma_studio_long 2:10aeacde20ff -11.91 sortcode
invoice-luma_studio_long 2:c14b2f2f32e4 -11.91 60-83-71
invoice-luma_studio_long 2:f5bd52edd4c2 -11.91 accountno.
invoice-luma_studio_long 2:4e20613ec3a6 -11.91 98765432
invoice-luma_studio_long 2:d53cd2cae33d -11.90 iban
invoice-luma_studio_long 2:279d55d978a1 -11.90 gb36srlg60837198765432
invoice-luma_studio_long 2:e398486c0acf -11.90 bic
invoice-luma_studio_long 2:ddc998160ae0 -11.90 srlggb2l
invoice-luma_studio_long 2:ab5aa97074c4 0.25 notes
invoice-luma_studio_long 2:7c6ab37d83ef -0.17 thankyouforyourbusiness.
invoice-luma_studio_long 2:3d717dfb25d8 -0.25 ifyouhaveanyquestionsregarding
invoice-luma_studio_long 2:479a74142336 -0.32 thisinvoice,pleasegetintouch.
invoice-luma_studio_long 2:1960744391ed -0.33 allworkremainstheintellectualpro
invoice-luma_studio_long 2:eeb53247f32c -0.41 ofluma&co.studiountilpayment
invoice-luma_studio_long 2:9eef22d7d34e -0.36 hasbeenreceivedinfull.
invoice-luma_studio_long 2:3c7ade679fdf 0.25 paymentdetails
invoice-luma_studio_long 2:b1819c9cd5bf -0.05 pleasemakepaymentbybanktransfert
invoice-luma_studio_long 2:8c1e4a24f6a8 0.18 luma&co.studioltd
invoice-luma_studio_long 2:4381dc2ab142 0.09 bank
invoice-luma_studio_long 2:447827e26127 0.09 starlingbank
invoice-luma_studio_long 2:10aeacde20ff 0.09 sortcode
invoice-luma_studio_long 2:c14b2f2f32e4 0.09 60-83-71
invoice-luma_studio_long 2:f5bd52edd4c2 0.09 accountno.
invoice-luma_studio_long 2:4e20613ec3a6 0.09 98765432
invoice-luma_studio_long 2:d53cd2cae33d 0.10 iban
invoice-luma_studio_long 2:279d55d978a1 0.10 gb36srlg60837198765432
invoice-luma_studio_long 2:e398486c0acf 0.10 bic
invoice-luma_studio_long 2:ddc998160ae0 0.10 srlggb2l
invoice-luma_studio_long 2:543a2e86433f 0.35 thankyouforchoosingluma&co.studi
invoice-luma_studio_long 2:7111b3fcbf69 -0.06 paymentisdueby19june2024.
invoice-luma_studio_long 2:bc6d215b63ee 0.17 page3of3
Expand Down
2 changes: 1 addition & 1 deletion qa/src/test/resources/docx-fidelity/word-windows.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ invoice-classic_long 2 2 166 166 0.51 0.88 0
invoice-consulting 1 1 92 92 1.10 1.65 3
invoice-consulting_long 2 2 236 236 0.99 1.40 3
invoice-luma_studio 1 1 97 97 0.13 0.42 0
invoice-luma_studio_long 3 3 192 192 0.23 11.75 20
invoice-luma_studio_long 3 3 192 192 0.22 0.38 0
invoice-merchant 1 1 94 94 0.30 0.75 0
invoice-metered 1 1 99 99 0.37 0.77 0
invoice-modern 1 1 54 54 0.31 0.57 0
Expand Down
Loading
Loading