From 103f57875214d50ce354b1e4cc306b8fd6b77558 Mon Sep 17 00:00:00 2001
From: DemchaAV
Date: Sun, 11 Oct 2026 10:04:41 +0100
Subject: [PATCH 1/2] fix(docx): stand a table's text cells on the page's
baselines, through their row's margins
- A row of text cells is moved by its top and bottom margins together
(moveTheRowsText): the page sets a cell's line its face's ascent below the
line's top, Word four fifths of the way down the exact line, and both
editors give every cell of a row its largest margins, so every cell's text
moves with its room at any anchor while the row keeps its height. By the
least its cells call for, no further than the margin holds; not a row
holding a composed cell, one the layout did not measure, one in a vertical
merge or whose cells call for opposite ways, nor under a tenth of a point.
- A paragraph written at its tallest line owes what its rounding to the twip
takes (settleTheLinesWithThePage), as one written at another height does.
- A cell's rules come off its padding as wide as Word draws them, in eighths
of a point (writtenRuleWidth), and are written from Word's thinnest.
- Docs: the recipe's Tables and Line height rows, the backend capability
matrix, the CHANGELOG.
- Fidelity baselines rewritten (Word, LibreOffice on Windows); the committed
preview word-export-companion.docx re-rendered: its cells' margins only.
- Tests: DocxCellSeatTest; DocxCellPaddingTest, DocxLineSurplusTest and
DocxTablePaintTest read the new margins, rounding and rule widths.
---
CHANGELOG.md | 63 +-
.../examples/word-export-companion.docx | Bin 10223 -> 10221 bytes
.../architecture/backend-capability-matrix.md | 4 +-
docs/recipes/docx-export.md | 4 +-
.../libreoffice-windows-lines.tsv | 1922 ++++++++---------
.../docx-fidelity/libreoffice-windows.tsv | 30 +-
.../docx-fidelity/word-windows-lines.tsv | 1460 ++++++-------
.../resources/docx-fidelity/word-windows.tsv | 30 +-
.../semantic/docx/DocxLayoutMetrics.java | 59 +-
.../semantic/docx/DocxSemanticBackend.java | 159 +-
.../semantic/docx/DocxCellPaddingTest.java | 66 +-
.../semantic/docx/DocxCellSeatTest.java | 268 +++
.../backend/semantic/docx/DocxExports.java | 4 +-
.../semantic/docx/DocxLineSurplusTest.java | 13 +-
.../semantic/docx/DocxTablePaintTest.java | 5 +-
15 files changed, 2279 insertions(+), 1808 deletions(-)
create mode 100644 render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxCellSeatTest.java
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1998a0802..e4c80a3cc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,41 @@ follow semantic versioning; release dates are ISO 8601.
### Public API
+- **A DOCX export stands a table's text cells on the page's baselines, and what follows a
+ paragraph or a ruled table where the page sets it.**
+ - **A row of text cells is moved by its margins.** The page sets a cell's line its face's ascent
+ below the line's top; Word stands an exact line's baseline four fifths of the way down it,
+ whatever the face. A cell's text stood as far off as the two are apart, at the top, the middle
+ or the bottom of the cell: a line of 8pt Poppins 0.58pt low in Word and 0.55pt in LibreOffice,
+ of Helvetica 0.24 and 0.16pt, of Lato 0.24pt high (measured). Both editors give every cell of a
+ row its largest top and bottom margins, so the row's top margin is made smaller and its bottom
+ one as much larger — or the other way — by the least any of its cells calls for, no further
+ than the margin holds: every cell's text moves with its room, and the row keeps its height.
+ Measured, the lines then stood within 0.04pt of the page's in Word and 0.09pt in LibreOffice.
+ What a row's other cells call for beyond its least is left, as is a move under a tenth of a
+ point. Not a row holding a composed cell, whose paragraphs their own writers seat where they
+ can, nor a row the layout did not measure, nor one in a vertical merge or whose cells call for
+ opposite ways.
+ - **A paragraph written at its tallest line owes what its rounding takes.** Its lines are
+ written to the twip, and what that took from the page's height over several lines stood what
+ follows higher: `ModernInvoice`'s address blocks, six lines of 11.475pt written at 11.45,
+ stood the table under them 0.15pt high in both editors. It is owed below the paragraph, as a
+ paragraph written at another height owes what it falls short.
+ - **A table's rules come off its padding as wide as Word draws them**, in eighths of a point: a
+ 0.7pt hairline is drawn 0.75pt wide, and taken off at 0.7 it stood `EditorialProposal`'s tables
+ and all under them a step of Word's grid lower. A rule thinner than Word draws one is written at
+ its thinnest, a quarter point, as a rule elsewhere is.
+
+ In the DOCX fidelity corpus 12 documents stand nearer the page in Word, the sum of the medians
+ 0.93pt nearer — `invoice-classic_long`'s median line from 0.26pt to 0.06pt, `invoice-modern_long`'s
+ from 0.22pt to 0.10pt, `invoice-subscription`'s from 0.56pt to 0.43pt — and 11 in LibreOffice on
+ Windows, `invoice-classic_long`'s from 0.22pt to 0.05pt. `invoice-modern`'s moves from 0.08pt to
+ 0.12pt in Word and from 0.07pt to 0.13pt in LibreOffice: its table's text, set low in its cells,
+ had stood where the page sets it only because its rows stood as much high, and the notes under
+ the table stand 0.1pt lower, where Word leaves more space after a table than the page does.
+ `cv-editorial_blue`'s skills table now stands with the column round it, which LibreOffice sets
+ 0.1 to 0.3pt high: its median there from 0.09pt to 0.14pt. The report names nothing more.
+
- **A DOCX export raises a line Word sets low into the space above it, where both editors keep
it.** Both editors stand an exact line's baseline four fifths of the way down it whatever the
face — measured on the fifteen faces the templates use and JetBrains Mono, 8 to 36pt — and the
@@ -52,10 +87,8 @@ follow semantic versioning; release dates are ISO 8601.
writes as its tallest line's; the page sets each at its own, so a wrapped line after a large
first one stands closer on the page. Lines rounded up to the twip, over enough of them, pass
the page too and hang the same way: `OrangeOps`' achievement lines, a 0.08pt gap between
- them written as a tenth (measured). What rounding takes from a paragraph written at its
- tallest line is not owed: owed, it stood `ModernInvoice`'s lines a step or two of Word's grid
- lower (measured). A tenth of a point or less is left either way: Word sets lines on a grid
- 0.12pt apart.
+ them written as a tenth (measured). A tenth of a point or less is left either way: Word sets
+ lines on a grid 0.12pt apart.
- A paragraph the layout opens a page with, with no top edge of its own to hold there, leaves
what the block above leaves below itself on the page above, as one with an edge does.
@@ -1388,17 +1421,17 @@ follow semantic versioning; release dates are ISO 8601.
moved to the page's baseline (`w:position`) wherever the two stand half a point or more apart,
from the line Word was given — a line pair's from the higher text's top, lines that took their
gaps from the space above from that higher top, several lines at the middle one; a list item's
- and a table text cell's are not moved yet. Lines a container stacks tighter than their face are
- each written to end halfway between their own letters and the next line's, read from the glyphs'
- outlines: Word draws an exact line's text on screen only inside the line, and lines a pitch tall
- cut the title's descenders and capitals there. Where the last layer of a shape container runs
- past its foot, it ends at the foot, or below its letters where they hang past it. Where the page
- sets two lines' letters into each other the edge still falls halfway, so the page does not move;
- a stack whose letters cannot be read, or that holds a picture, keeps each line's own height, and
- a line with space above or below it stays out of a stack. In Word `NorthlineProposal`'s median
- drift falls
- from 8.0pt to 0.8, its cover within 1.5pt of the page throughout, and `EditorialProposal`'s from
- 5.9 to 0.4; across the 62 templates, lines more than 2pt off fall from 1464 to 1341.
+ is not moved yet, and a table text cell's is moved by its row's margins. Lines a container stacks
+ tighter than their face are each written to end halfway between their own letters and the next
+ line's, read from the glyphs' outlines: Word draws an exact line's text on screen only inside the
+ line, and lines a pitch tall cut the title's descenders and capitals there. Where the last layer
+ of a shape container runs past its foot, it ends at the foot, or below its letters where they hang
+ past it. Where the page sets two lines' letters into each other the edge still falls halfway, so
+ the page does not move; a stack whose letters cannot be read, or that holds a picture, keeps each
+ line's own height, and a line with space above or below it stays out of a stack. In Word
+ `NorthlineProposal`'s median drift falls from 8.0pt to 0.8, its cover within 1.5pt of the page
+ throughout, and `EditorialProposal`'s from 5.9 to 0.4; across the 62 templates, lines more than
+ 2pt off fall from 1464 to 1341.
- **A value set from its start keeps its start in Word.** Two texts one layer holds on one line —
a label and its value, a title and its dates — are written as one Word line split by a tab
stop, and the stop was always a right tab at the right text's end. A value aligned left in a
diff --git a/assets/readme/examples/word-export-companion.docx b/assets/readme/examples/word-export-companion.docx
index 944d2de0ebca094c6c01b7d629466fe3b1cd2a98..2ad749e3f75978189bf9261ebc366533b14f0062 100644
GIT binary patch
delta 2431
zcmY+Gdpr|*AIIlTMlM;0+_JN+vejf+wcMIKYqDXAxl>G-`z2&^X~J2^A~JQ{&fGmN
zA-c#Vj$E7TL1^wFk&xs$^E~JE>iPZi`Mkfs*Z24Rnebe0)p#xRfz(Md}S31_V6W42tt2N;2~vV9bKmbNU%cTs}Ewaue3`)*Q@45q
zS~H`lvpia!l?Et&0m=BZ_q{DRB4{476%%DcvC2uG6YTY%*fiM3J7#8j9gnmo=boqd
zK@xEviVB~WS4(cmu-h6Daz;t{_?^^YtsOl69cD?P3+&8W?P56i-IlVYFQmRNMs%F+
zIdvncgy{ldA=g>v>{MeSeowXD+^M=nI=uQyW%}VYmMc(q7mXx9*9?}8q?(axAn@TM
z3TxXxR{Y>kp6cv2829y4g7Sq<7z>%3eeP>RY^Ps93=U-;>3a|wdS4+l?G)OTJo9kC
zW!vH{eeLqCu;A=xQXQY@gJqkE$opLN<#pAh7|Ga2)SNHzkD~m(A%zkUh+3u9N&86~
znp7TSes=@y;Z1AN){71jjSAVyX!!Ar7CUrH)m`dK2N(F>a;R@hik%fDX|OZMwO+zL
z>>u;LJ5k?EvfH#1u^_qfo+`z_ZY^!@en8O$%uK|@l{&d8K>~6BK#U*&@bhP}2;jq2
zMj~Kg`p8AgzvedHmM+?e4QbldScQ`ajmKBD!WH_=*#Xk)@>8KIxi7(ob=C)}=c@dJ
zcXtj2kQeV`OpvxXTb#Zcj;^jPM~r7wGrsf)E(lPtHnZA)#0976-P`c$M!S7w#?I!e
zNa?pw{7R{{XCuCyEe!{8KpdhPXGNNA)6+yxytDV@{%XV1VGySWz_}OOTG+b4Z7U4F
zsVj+*TfzZ)a@-I#{L)QsSt*&VC&UiJ_(I0)p^F
zkMLsFq32>mMrnPp<_3?N{{x5hpPFzih-i(gdS;*}F?^>$CS9_fvr}wReP)7Q!KxqE
z>C?Qsl9xE;o$2OEuJ<^fHlsP~OnzPy6Smtlw;|ar>UnTfcih)=A=&nLS*_9lBz`U8
zT^pv=5#QOJ5;eBsRpC1@{`IXb+UX#YM4oTUc3vf-l&1+2r`65#V(?dyXr9JFT>}H>
z^YNF+feVA7bypaQ)~Y2JiyP@@L}RvYqJBKi_}%!p3>x
zc;N%@iy)Z7stMSqQ$3VadWeq3!*Iw5c>x(bhhSN#YynEN)Qrh$JC~R9io%9Vw3vk`GKVy3u&2J43#}tp(02;+WKqxQCmXJs`e8Nr%IG6~Mpvv;eIF+Iy&D
zkQ4m^2Ye4zZ0{&e$r3CZYuq$n^(cLxvS<>%+UD@0%V%QFE5+qR@n_oELq-nhV(Kqo
zrNXyOaLmk$$=D_Zr)B3iga?W_R+GjOfe}61N?z)VD~ak1U@9
zHiWDKEA@zVvl*e(N?-0Zr&jOITgw3j$jMeRPo|izQ3lA<(2{VPx}M`x;@@Un=U+&z
z^@%+8NW5~qCF--QtduqvvDN;`Sb5=d!-c1B$i<*m9Gy|6^E~WnWv21eQdX)*qDIcq
z6bXa;=_W^awCKx*Hx*+(BE^i2_kq43iJ71*2x>7@B_Sn%Bv1`*hqVj=LgC5i&hE~<1nPM{ijOP_qoXHxTn>u#Z
zW9x)lIsFd{kz4fLh!FFi#+cauIjyKhP#i_n
zg)8`3mgoD=^>xpE$BumE^Ss3Eqr}RyJ=sk7fX;P|?Fc1xo%xMZ*2?4HJ%>yAfcJP*
zKq5UNZ6|PbH{@Dupt1AP$0s%x;gAUB#7UNs*W;BsOZ{`uF4a!Q&S3oM*A;n&^_g<<
z=H|M&SIQE`*rdxXDT|Kkr8P{BAsGcqne^Qw21CoSFMCw$HDO}u%j50t@$hDd
zHr};kR6EkbugLo*@1gg%Y3T1w)ah7FMf#!oqd0XgfvHE+hIR*yUL6lE8TQUlvm%X}
zU02T&?$9zdzt3zG*P#A}New0qp)A^~VjrSd{#YFyH?rB$n3`!Z&|PmKfbVzKHHBk1aLVY_rR2W
zbcg8ghZ+c)FCQQmB-ZP2_WS#l1%v9S@#*L3vOmoO05n*)q3Zm`$53Sf6srNM$%lEU
xvY?YJiza)Rr2+%;E1EE60R{^PJIV*ozrlbN2itEf`Wrs8+F%-@))4;F{{f%$hJ*kB
delta 2435
zcmZ8jXH*l|8cYE~DAGfh5<)D1w9w1qB1J%uDiB0KS|}0)1O;M1Ss(&Z&0=UiGz4@h
zk&YTT2C0IyfJ7-OW$7rG5Ye~cygkSB?w@bIxo777xIbproj09@TpYkWk^p{wegLMb
zLFg6`gsGzD0A;zefC3ukjvHVEZs^>qwy2GN@TWL8JlUmT}bK(Vk#Kz}}<6D#NMcB{tnX^R!#cpKgEehN2+Cnt*!cQDz$vNwqxXf@rl+M^MO#LcU~xarN-#w
z60YBS8{Oy6Rx>l}aPjB;Y>0DUB-#>tvG?{837ikSzwery-~Y{tX7v04fL>fIFWmY?
zD+cirGAjOcZ$|{hz@rEC$$#(nV``PpA<7^=;L;s^yw^mteiAqoIR_eP-qx4o
zj3ZEn%!S;IEg6QnCw|<0I^k*h9PsG=L8s9!#Ki%^|7=mtCl&}01EhfffM5TLs>N%<
zgB$8OTh2JuQWK$wu8Z;ZU3W4Dl4-BkJgjZ8Z;S_>Z!g8&-OoW!4SJ204fjv)Zn_Ny
zQ*1Xhx*}DgR1T7q5AcI_W(e3QY}8V)3PKVN|8tnA`p$b_f0AlEOPtn|)777OyH%PD
zW4wzejFEH4+C#Az?EY8m-y1Z_uErY9j`dR(`qGyWh20m5c^7tpgAx5GrSs{yQn;PgcaC6Foeb7Mx)%w2ASwmA24u(L;xe0Yi>C3eEi>vjK97`+
z>oB9no@h9DIlXR7qMKTB>C2^H+4H$Al@W4o4=tpLH8uPdnpITO|3q@ct1pTQJ!hg&W*>H@Y
z_1;9}K1CZmkmeDFlWKiT6Y+6r;{)@##c0IoXZEIjxxTz9wum%^YffA3)f*tnZN97hP?xlEk9;aG1>!~s1=l#`_490oth&k(-vzt&
z`w;goG+cX~S_h&(G40vT=oE)SFOyZ-
kG$k0#zg7g}5wD8Y41G)YujA9P2430qjzIh4CJHgpjkV8#GZg$-u6JAkJ-d|%n^25c8B#Hliz?j
zss=bqxLJ3mz|>^q=WpI=mguv@iod67TiELyl9Q`rFzSQIAE~{oAx*+T*6=uQVz6+L
z6t1LPq;jQgJ%rjuSYC=F%*L)^PIZ|75%BFunbqVH
zlwqb<=LCy>C-7t{TedFwh!kI^QG`O^uJbFYTkdM=K#e5Fuh||OGJ;-OP3wEYqGu$m
znjaWxztDIX5Yo=8#D1RvH&3}wo-~S>c!-ms#7w4p)p^E`9V0!bx(=PU*0kOk}&eKax^%f0S%uK()+r)F{S65%UB~c%2z*<_T{K(4ub`~g4^@uZH4{mxU~uQ
znz^IM&u_L0L-cFDIc24XOjohMe!($ut&(BYW5U
zk8hbdjH+!qW2Ib8IDZQvt8*?BH$n)uel#)(q5C-m-HFo?s$f#J_hNHpE_g#s*-=ro
z^%?%?nh!tX1AGa7SEQSprnloOJNxpkNSD+;H%^)DE_+l8dFhv6aYcwUWW4mr%Lf(<
zi-q7f8Xht=0h$02@LYq=3hb^g?Q$0@M!U>XjTtx`xT(EXYB@Ob55oNe6(!oE@L_mX
zf6c5A{vy%=^4N@m(7)Nlp6Y6qx97CXUV|8w2MDe>2J+VV+ngb@
zxX@s`P|2PbKPZSMuhG}@{1*1F7FTi{b_;?=*SfybBgtwK3J!8r9mn%nXC?6BQWJXp
zpK5xCjEk%_C_i{dF#`#5g=d0Pphv#_yd1h?@`Uyit?3WhcZ+*<(YpU}f81#f
zJ|;!}yVxLQ<*{=#=mgUyI;=I{s!~3cM|b_z@<+p<1$2wwMAYl7^XnXmhJuxM7?V{Ek^fg1z2x!}X9J$9No)GlUIg-&|$<1asqVnGa+-DF6Ue
zCI4UA{U&(9bf{W*>l?Np0sxe#0RU3J
ziU5HHV5AyXbsVVx`a`9lQbn@B7b(PL!jTHV(*^0sL(}SimM;Z#q$-~ef@| painted;
private final int pageCount;
- // A table's measured cells by name, filled on first use — see cellLineHeightsOf.
- private final Map> cellLineHeights = new IdentityHashMap<>();
+ // A table's measured cells by name, filled on first use — see measuredCellsOf.
+ private final Map> measuredCells = new IdentityHashMap<>();
private final Map>> cellBoxes = new IdentityHashMap<>();
// The rows of a table the layout placed, by index, filled on first use — see placedRowsOf.
private final Map> placedRows = new IdentityHashMap<>();
@@ -216,9 +216,22 @@ boolean isEmpty() {
* @return the measured height, or empty when the layout does not carry one
*/
OptionalDouble cellLineHeight(DocumentNode table, int row, int column) {
+ TableResolvedCell measured = measuredCell(table, row, column);
+ return measured == null ? OptionalDouble.empty() : OptionalDouble.of(measured.lineHeight());
+ }
+
+ /**
+ * A table cell as the layout measured it — its lines' height and the style it drew them in —
+ * found by name as {@link #cellLineHeight} finds it.
+ *
+ * @param table the table node
+ * @param row the cell's logical row
+ * @param column the cell's first column
+ * @return the cell, or {@code null} when the layout does not carry its lines' height
+ */
+ TableResolvedCell measuredCell(DocumentNode table, int row, int column) {
String owner = table.name() == null || table.name().isBlank() ? table.nodeKind() : table.name();
- Double measured = cellLineHeightsOf(table).get(owner + "__row_" + row + "__cell_" + column);
- return measured == null ? OptionalDouble.empty() : OptionalDouble.of(measured);
+ return measuredCellsOf(table).get(owner + "__row_" + row + "__cell_" + column);
}
/**
@@ -229,14 +242,14 @@ OptionalDouble cellLineHeight(DocumentNode table, int row, int column) {
* measured, doubling a 1000-row table's rows took its export from 545ms to 1463ms. One
* pass per table and a lookup per cell keeps it linear.
*/
- private Map cellLineHeightsOf(DocumentNode table) {
- return cellLineHeights.computeIfAbsent(table, node -> {
- Map byName = new HashMap<>();
+ private Map measuredCellsOf(DocumentNode table) {
+ return measuredCells.computeIfAbsent(table, node -> {
+ Map byName = new HashMap<>();
for (PlacedFragment fragment : fragmentsOf(node)) {
if (fragment.payload() instanceof TableRowFragmentPayload payload) {
for (TableResolvedCell cell : payload.cells()) {
if (cell.hasMeasuredLineHeight()) {
- byName.putIfAbsent(cell.name(), cell.lineHeight());
+ byName.putIfAbsent(cell.name(), cell);
}
}
}
@@ -667,26 +680,6 @@ String pathOf(DocumentNode node) {
* @return the line height in points, or empty when the node laid out nothing
*/
OptionalDouble lineHeight(DocumentNode node) {
- return lineHeight(node, true, true);
- }
-
- /**
- * Whether a node's line height is other than its tallest laid-out line ({@link #lineHeight}):
- * the page's distance between its lines, or a line without its prefix. The paragraph, set at
- * that one height, can then come out shorter than the page's; at the tallest line, only by its
- * rounding to the twip.
- *
- * @param node any node that lays its text out as paragraph lines
- * @return whether the height is not the tallest line's
- */
- boolean lineIsNotTheTallest(DocumentNode node) {
- OptionalDouble written = lineHeight(node, true, true);
- OptionalDouble tallest = lineHeight(node, false, false);
- return written.isPresent() && tallest.isPresent()
- && Math.abs(written.getAsDouble() - tallest.getAsDouble()) > 0.01;
- }
-
- private OptionalDouble lineHeight(DocumentNode node, boolean byPitch, boolean withoutPrefix) {
double text = 0;
double style = 0;
double pitches = 0;
@@ -694,13 +687,13 @@ private OptionalDouble lineHeight(DocumentNode node, boolean byPitch, boolean wi
double heights = 0;
int textLines = 0;
// Only lines on one fragment, of more than one line, are written other than at their
- // tallest: what they then fall short of the page is owed below them (linesHeight), and a
- // line of its own is set at its laid-out height where nothing would make up a shorter one
- // (riseIntoItsLine, holdPicturesInTheLine).
+ // tallest — what a paragraph's lines fall short of the page, at whatever height they are
+ // written, is owed below it (linesHeight) — and a line of its own is set at its laid-out
+ // height where nothing would make up a shorter one (riseIntoItsLine, holdPicturesInTheLine).
boolean ownWay = textFragmentsOf(node).size() == 1 && lineCount(node) > 1;
// The layout sets the prefix before the lines its strategy names, and only there.
com.demcha.compose.document.style.DocumentTextIndent strategy =
- withoutPrefix && ownWay && node instanceof ParagraphNode paragraphNode
+ ownWay && node instanceof ParagraphNode paragraphNode
&& !paragraphNode.bulletOffset().isEmpty()
? paragraphNode.indentStrategy()
: com.demcha.compose.document.style.DocumentTextIndent.NONE;
@@ -738,7 +731,7 @@ private OptionalDouble lineHeight(DocumentNode node, boolean byPitch, boolean wi
// the page has them, never below the tallest written line, which would clip it. Nor
// above the lines' mean height: the paragraph would come out taller than the page,
// and a surplus only comes out of the space below it (settleTheLinesWithThePage).
- if (byPitch && ownWay && pairs > 0 && textLines > 0) {
+ if (ownWay && pairs > 0 && textLines > 0) {
double pitch = pitches / pairs - Math.max(0, lineGap(node));
text = Math.max(text, Math.min(pitch, heights / textLines));
}
diff --git a/render-docx/src/main/java/com/demcha/compose/document/backend/semantic/docx/DocxSemanticBackend.java b/render-docx/src/main/java/com/demcha/compose/document/backend/semantic/docx/DocxSemanticBackend.java
index 586582108..fed58faca 100644
--- a/render-docx/src/main/java/com/demcha/compose/document/backend/semantic/docx/DocxSemanticBackend.java
+++ b/render-docx/src/main/java/com/demcha/compose/document/backend/semantic/docx/DocxSemanticBackend.java
@@ -57,6 +57,7 @@
import com.demcha.compose.engine.components.content.text.TextDecoration;
import com.demcha.compose.engine.components.content.text.TextStyle;
import com.demcha.compose.engine.components.content.table.TableCellLayoutStyle;
+import com.demcha.compose.engine.components.content.table.TableResolvedCell;
import com.demcha.compose.document.style.InlineBackground;
import com.demcha.compose.document.table.DocumentTableCell;
import com.demcha.compose.document.table.DocumentTableColumn;
@@ -194,6 +195,12 @@ public final class DocxSemanticBackend implements SemanticBackend {
* a step or nothing.
*/
private static final double LEAST_RAISE_INTO_THE_SPACE_ABOVE = 0.1;
+ /**
+ * The least a row of text cells is moved by its margins, in points ({@link #moveTheRowsText}),
+ * for the same reason: Word sets lines on its 0.12pt grid, and a twip of margin moves a line a
+ * step or nothing.
+ */
+ private static final double LEAST_ROW_TEXT_MOVE = 0.1;
/** How a drawing the page paints is anchored, as the report says it (see DocxDrawingAnchors). */
private static final String ANCHORED_BESIDE_ITS_TEXT = "anchored in the paragraph whose text it stands "
+ "beside, so it moves with that text when the text above is edited, or to the page where it "
@@ -321,6 +328,11 @@ public final class DocxSemanticBackend implements SemanticBackend {
// takeFromTheTopOfItsCell.
private final java.util.Set cellsGivingTheirPadding =
java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>());
+ // The text cells of the table row being written, and how far Word sets each one's lines below
+ // the page's, in points; NaN for a cell with no line to seat. Taken out when the row is moved:
+ // see moveTheRowsText.
+ private final java.util.Map textCellRaises =
+ new java.util.IdentityHashMap<>();
// Icons drawn beside the text they label rather than written: see drawnBesideItsText.
private final java.util.Set picturesDrawnBeside =
java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>());
@@ -818,6 +830,7 @@ private byte[] write(List sections, Path outputFile) throws Exc
stackedLineHeights.clear();
lineTopsTakenIn.clear();
cellsGivingTheirPadding.clear();
+ textCellRaises.clear();
risenLines.clear();
tablesCells.clear();
picturesDrawnBeside.clear();
@@ -8680,11 +8693,10 @@ private boolean applyParagraphProperties(XWPFParagraph target, ParagraphNode sou
* ({@code DocxLayoutMetrics.lineHeight}), and the paragraph comes out short by what its
* first line's top and its last line's foot hold beyond that: {@code EditorialProposal}'s
* terms, whose wrapped lines carry a taller prefix than their first, stood 0.6pt higher
- * with every item. Only a paragraph written at a height other than its tallest laid-out
- * line is made up to the page; one written at its tallest line, to keep its letters whole,
- * falls short only by its line's rounding to the twip, which is not owed: owed, it set
- * {@code ModernInvoice}'s lines a step or two of Word's grid lower (measured, see
- * {@link #LINES_ROUNDING_TOLERANCE}).
+ * with every item. One written at its tallest line, to keep its letters whole, falls short
+ * by its line's rounding to the twip, owed the same way: {@code ModernInvoice}'s address
+ * blocks, six lines of 11.475pt written at 11.45, stood the table under them 0.15pt high in
+ * Word and LibreOffice alike (measured, see {@link #LINES_ROUNDING_TOLERANCE}).
*
* Written at its tallest line, it can come out taller: the page sets a line shorter than
* that, a wrapped line after a large first one, at its own height. Its last line then hangs
@@ -8708,7 +8720,7 @@ private void settleTheLinesWithThePage(XWPFParagraph target, ParagraphNode sourc
double written = layout.lineCount(source) * (line / POINT_TO_TWIP)
- lineTopsTakenIn.getOrDefault(target.getCTP(), 0.0);
double shortBy = page.getAsDouble() - written;
- if (shortBy > LINES_ROUNDING_TOLERANCE && layout.lineIsNotTheTallest(source)) {
+ if (shortBy > LINES_ROUNDING_TOLERANCE) {
owePendingSpacingAfter(shortBy);
} else if (-shortBy > LINES_ROUNDING_TOLERANCE) {
hangingBelow = Math.max(hangingBelow, -shortBy);
@@ -11700,7 +11712,7 @@ private static long borderTwips(org.openxmlformats.schemas.wordprocessingml.x200
if (!drawn(border) || !border.isSetSz() || border.getSz() == null) {
return 0;
}
- return Math.round(border.getSz().doubleValue() * POINT_TO_TWIP / 8.0);
+ return eighthsInTwips(border.getSz().doubleValue());
}
private static long twipsOf(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth width) {
@@ -11794,6 +11806,7 @@ private void writeTableRows(XWPFDocument document, TableNode node) throws Except
}
}
evenTheRowsMargins(row);
+ moveTheRowsText(row);
// The first row's share of the rule under it is the next row's rule, written next.
if (rowIdx > 0 || rowCount == 1) {
holdRowHeight(table, node, rowIdx);
@@ -11918,10 +11931,8 @@ private void applyCellPaint(XWPFTableCell cell, DocumentColor fill, DocumentStro
? properties.getTcBorders()
: properties.addNewTcBorders();
if (stroke.width() > 0) {
- // w:sz counts eighths of a point, and rounds to at least one so a hairline
- // the author asked for stays a line rather than disappearing.
- BigInteger eighths = BigInteger.valueOf(
- Math.max(1, Math.round(stroke.width() * 8.0)));
+ // A hairline the author asked for stays a line, at Word's thinnest.
+ BigInteger eighths = BigInteger.valueOf(ruleEighths(stroke.width()));
String colour = toHexColor(stroke.color().color());
paintEdge(borders.addNewTop(), STBorder.SINGLE, eighths, colour);
paintEdge(borders.addNewBottom(), STBorder.SINGLE, eighths, colour);
@@ -11940,6 +11951,21 @@ private void applyCellPaint(XWPFTableCell cell, DocumentColor fill, DocumentStro
}
}
+ /**
+ * How wide Word draws a cell's rule, in points: the width written in eighths of a point, from
+ * Word's thinnest to its thickest ({@link #ruleEighths(double)}), counted to the twip as a
+ * row's height counts it ({@link #borderTwips}); 0 for none.
+ */
+ private static double writtenRuleWidth(DocumentStroke stroke) {
+ return stroke == null || !(stroke.width() > 0) ? 0
+ : eighthsInTwips(ruleEighths(stroke.width())) / POINT_TO_TWIP;
+ }
+
+ /** A rule's {@code w:sz}, eighths of a point, in whole twips. */
+ private static long eighthsInTwips(double eighths) {
+ return Math.round(eighths * POINT_TO_TWIP / 8.0);
+ }
+
private static void paintEdge(CTBorder edge, STBorder.Enum kind, BigInteger eighths, String colour) {
edge.setVal(kind);
if (eighths != null) {
@@ -11989,9 +12015,12 @@ private static void applyCellPadding(XWPFTableCell cell, DocumentInsets padding)
* room for the lower row's rule: measured, a 1.5pt header over 0.5pt rows stepped as 0.5pt
* rules do, and a 1.5pt row under 0.5pt ones as 1.5pt rules do. So each rule comes off the
* padding where Word puts it; in a table ruled alike throughout, with padding enough, every
- * row then stands where the page sets it. The sides keep their padding, as the columns'
- * widths are fixed. Padding thinner than its share gives what it has, and the row stands
- * that much taller.
+ * row then stands where the page sets it. Each rule comes off as wide as Word draws it, in
+ * eighths of a point ({@link #writtenRuleWidth}): a 0.7pt hairline is drawn 0.75pt wide, and
+ * taken off at 0.7 it stood {@code EditorialProposal}'s tables, and all under them, a step of
+ * Word's grid lower (measured). The sides keep their padding, as the columns' widths are
+ * fixed. Padding thinner than its share gives what it has, and the row stands that much
+ * taller.
*
* @param padding the cell's padding on the page
* @param stroke the cell's own rule
@@ -12002,8 +12031,8 @@ private static void applyCellPadding(XWPFTableCell cell, DocumentInsets padding)
*/
private static DocumentInsets clearOfTheRules(DocumentInsets padding, DocumentStroke stroke,
boolean firstRow, boolean lastRow, DocumentStroke underneath) {
- double rule = strokeWidth(stroke);
- double below = lastRow ? rule : strokeWidth(underneath) / 2;
+ double rule = writtenRuleWidth(stroke);
+ double below = lastRow ? rule : writtenRuleWidth(underneath) / 2;
return new DocumentInsets(Math.max(0, padding.top() - (firstRow ? rule : rule / 2)), padding.right(),
Math.max(0, padding.bottom() - below), padding.left());
}
@@ -12169,6 +12198,104 @@ private void writeCellContent(XWPFTableCell cell, TableGrid.Placement placement,
run.setText(lines.get(i) == null ? "" : lines.get(i), inRun++);
}
styleTheMark(para, textStyle);
+ if (lines.stream().allMatch(line -> line == null || line.isBlank())) {
+ textCellRaises.put(cell.getCTTc(), Double.NaN);
+ } else if (lineHeight.isPresent()) {
+ double below = belowThePage(layout.measuredCell(node, placement.row(), placement.column()),
+ cell.getParagraphs().get(0));
+ if (!Double.isNaN(below)) {
+ textCellRaises.put(cell.getCTTc(), below);
+ }
+ }
+ }
+
+ /**
+ * How far Word sets a text cell's lines below the page's, in points, negative where Word sets
+ * them higher; NaN where the layout did not measure the cell, draws it in a face the measured
+ * fonts do not hold, or the line is not written exact.
+ *
+ * The page sets each of a cell's lines its height less its face's descent below the line's
+ * top, as the PDF backend draws a cell (PdfTableRowFragmentRenderHandler); Word stands an exact
+ * line's baseline four fifths of the way down the line it was given, whatever the face
+ * ({@link DocxTextBands#BASELINE_SHARE}). Measured on cells anchored at the top, the middle and
+ * the bottom, a line of 8pt Helvetica stood 0.24pt low in Word and 0.16 in LibreOffice, Poppins
+ * 0.58 and 0.55, and Lato 0.24 and 0.25 high: as far as the two seats are apart, and nothing
+ * else in the cell moved.
+ *
+ * @param measured the cell as the layout measured it, or {@code null}
+ * @param first the cell's first paragraph, whose exact line its lines are written at
+ */
+ private double belowThePage(TableResolvedCell measured, XWPFParagraph first) {
+ CTPPr properties = first.getCTP().getPPr();
+ CTSpacing spacing = properties != null && properties.isSetSpacing() ? properties.getSpacing() : null;
+ Long line = spacing != null && spacing.isSetLineRule() && spacing.getLineRule() == STLineSpacingRule.EXACT
+ ? writtenTwips(spacing.getLine()) : null;
+ if (measured == null || line == null) {
+ return Double.NaN;
+ }
+ TextStyle face = measured.style().textStyle();
+ try {
+ return measuredFonts().getFont(face.fontName(), com.demcha.compose.engine.render.pdf.PdfFont.class)
+ .map(font -> line / POINT_TO_TWIP * DocxTextBands.BASELINE_SHARE
+ - (measured.lineHeight() - font.verticalMetrics(face).baselineOffsetFromBottom()))
+ .orElse(Double.NaN);
+ } catch (RuntimeException unknownFace) {
+ return Double.NaN;
+ }
+ }
+
+ /**
+ * Moves the text of a row of text cells to where the page sets it, by moving the row's top
+ * and bottom margins together.
+ *
+ * Word sets a text cell's lines lower or higher than the page by the distance between the
+ * two seats ({@link #belowThePage}). Word and LibreOffice give every cell of a row its largest
+ * top margin and its largest bottom margin ({@link #evenTheRowsMargins}), so the margins move
+ * the text of every cell at once: the top made smaller by as much as the bottom is made larger,
+ * each cell's room is moved up that much and keeps its height, and the text in it moves with
+ * it, set at its top, its middle or its bottom; the row keeps its height. Measured, the lines
+ * then stood within 0.04pt of the page's in Word and 0.09pt in LibreOffice, raised or lowered.
+ * Space written above a cell's text would move it too, but LibreOffice sets a vertically
+ * centred cell's content as if its first paragraph had none: 3pt above it stood the line 1.5pt
+ * high there.
+ *
+ * Every cell of the row is moved alike, by the least that any of its cells' lines call
+ * for, so none is moved past where the page sets it, and what the others call for beyond that
+ * is left — no position makes it up, which LibreOffice would move further than it is raised;
+ * no further than the margin the text moves into holds. A row whose cells call for opposite
+ * ways is left as it is, and so is less than {@link #LEAST_ROW_TEXT_MOVE}. Only a row of text
+ * cells the layout measured, in a face the measured fonts hold: a composed cell's paragraphs
+ * are seated by their own writers where they can be, and the margins would move them again.
+ * Not a row in a vertical merge, whose cells' margins are evened apart.
+ */
+ private void moveTheRowsText(XWPFTableRow row) {
+ double least = Double.NaN;
+ boolean moves = true;
+ for (XWPFTableCell cell : row.getTableCells()) {
+ // Taken out as it is read: the row is decided here, once.
+ Double below = textCellRaises.remove(cell.getCTTc());
+ CTTcPr properties = cell.getCTTc().getTcPr();
+ if (below == null || properties != null && properties.isSetVMerge()) {
+ moves = false;
+ } else if (!Double.isNaN(below)) {
+ moves &= Double.isNaN(least) || Math.signum(below) == Math.signum(least);
+ least = Double.isNaN(least) || Math.abs(below) < Math.abs(least) ? below : least;
+ }
+ }
+ if (!moves || !(Math.abs(least) >= LEAST_ROW_TEXT_MOVE)) {
+ return;
+ }
+ long move = Math.round(least * POINT_TO_TWIP);
+ for (XWPFTableCell cell : row.getTableCells()) {
+ move = move > 0 ? Math.min(move, cellMargin(cell, true)) : Math.max(move, -cellMargin(cell, false));
+ }
+ if (Math.abs(move) < Math.round(LEAST_ROW_TEXT_MOVE * POINT_TO_TWIP)) {
+ return;
+ }
+ for (XWPFTableCell cell : row.getTableCells()) {
+ setCellMarginTwips(cell, true, cellMargin(cell, true) - move);
+ setCellMarginTwips(cell, false, cellMargin(cell, false) + move);
+ }
}
/** A paragraph of a text cell: its direction, its alignment and its line height. */
diff --git a/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxCellPaddingTest.java b/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxCellPaddingTest.java
index 61a323873..693f9924a 100644
--- a/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxCellPaddingTest.java
+++ b/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxCellPaddingTest.java
@@ -36,6 +36,12 @@
class DocxCellPaddingTest {
private static final double TWIPS_PER_POINT = 20.0;
+ /**
+ * How far the rows here, of cells in the default face, are moved up through their margins to
+ * stand their text on the page's baselines ({@code DocxCellSeatTest}): their top margin is that
+ * much smaller and their bottom one that much larger than their padding gives.
+ */
+ private static final long SEAT = DocxExports.DEFAULT_LINE_RAISE;
@Test
void aStatedPaddingReachesAllFourSides() throws Exception {
@@ -47,7 +53,7 @@ void aStatedPaddingReachesAllFourSides() throws Exception {
.row("Padded")));
// Above and below, less the engine's default 1pt rule, which Word gives room of its own.
- assertThat(margins(cell)).containsExactly(160L, 140L, 80L, 60L);
+ assertThat(margins(cell)).containsExactly(160L - SEAT, 140L, 80L + SEAT, 60L);
}
@Test
@@ -66,9 +72,42 @@ void aRuledCellGivesItsRulesOutOfItsPaddingWhereWordPutsThem() throws Exception
.row("Second")));
assertThat(margins(table.getRow(0).getCell(0))).as("the rule above the table, half the one between")
- .containsExactly(110L, 140L, 125L, 140L);
+ .containsExactly(110L - SEAT, 140L, 125L + SEAT, 140L);
assertThat(margins(table.getRow(1).getCell(0))).as("half the rule between, the rule below the table")
- .containsExactly(125L, 140L, 110L, 140L);
+ .containsExactly(125L - SEAT, 140L, 110L + SEAT, 140L);
+ }
+
+ @Test
+ void aRuleComesOffThePaddingAsWideAsWordDrawsIt() throws Exception {
+ // Word draws a rule in eighths of a point: a 0.7pt hairline is written 6/8 and drawn 0.75pt
+ // wide. Taken off at 0.7, EditorialProposal's tables and everything under them stood a step
+ // of Word's grid lower (measured).
+ XWPFTableCell cell = firstCell(page -> page.addTable(t -> t
+ .columns(DocumentTableColumn.auto())
+ .defaultCellStyle(DocumentTableStyle.builder()
+ .padding(DocumentInsets.of(7))
+ .stroke(DocumentStroke.of(DocumentColor.BLACK, 0.7))
+ .build())
+ .row("Hairline")));
+
+ assertThat(((Number) cell.getCTTc().getTcPr().getTcBorders().getTop().getSz()).intValue())
+ .as("the premise: written in eighths").isEqualTo(6);
+ assertThat(margins(cell)).containsExactly(140L - 15 - SEAT, 140L, 140L - 15 + SEAT, 140L);
+ }
+
+ @Test
+ void aRuleThinnerThanWordDrawsIsWrittenAndTakenOffAtWordsThinnest() throws Exception {
+ // Word draws no single rule thinner than two eighths of a point.
+ XWPFTableCell cell = firstCell(page -> page.addTable(t -> t
+ .columns(DocumentTableColumn.auto())
+ .defaultCellStyle(DocumentTableStyle.builder()
+ .padding(DocumentInsets.of(7))
+ .stroke(DocumentStroke.of(DocumentColor.BLACK, 0.1))
+ .build())
+ .row("Hairline")));
+
+ assertThat(((Number) cell.getCTTc().getTcPr().getTcBorders().getTop().getSz()).intValue()).isEqualTo(2);
+ assertThat(margins(cell)).containsExactly(140L - 5 - SEAT, 140L, 140L - 5 + SEAT, 140L);
}
@Test
@@ -84,9 +123,9 @@ void betweenRowsRuledDifferentlyTheLowerRowsRuleIsTheOneGivenUp() throws Excepti
.row("Body")));
assertThat(margins(table.getRow(0).getCell(0))).as("its own 1.5pt above, half the body's 0.5pt below")
- .containsExactly(110L, 140L, 135L, 140L);
+ .containsExactly(110L - SEAT, 140L, 135L + SEAT, 140L);
assertThat(margins(table.getRow(1).getCell(0))).as("half its own 0.5pt above, its own below")
- .containsExactly(135L, 140L, 130L, 140L);
+ .containsExactly(135L - SEAT, 140L, 130L + SEAT, 140L);
}
@Test
@@ -115,8 +154,9 @@ void aRuleOfNoWidthGivesUpNothingAndPaddingThinnerThanItsShareGivesWhatItHas() t
.padding(DocumentInsets.of(1)).stroke(DocumentStroke.of(DocumentColor.BLACK, 2)).build())
.row("Thin")));
- assertThat(margins(unruled)).containsExactly(140L, 140L, 140L, 140L);
- assertThat(margins(thin)).as("none left above and below, the sides kept").containsExactly(0L, 20L, 0L, 20L);
+ assertThat(margins(unruled)).containsExactly(140L - SEAT, 140L, 140L + SEAT, 140L);
+ assertThat(margins(thin)).as("none left above and below, the sides kept; none to raise the text into")
+ .containsExactly(0L, 20L, 0L, 20L);
}
@Test
@@ -146,7 +186,7 @@ void aTableThatStatesNothingIsWrittenWithTheEnginesOwnDefault() throws Exception
long four = Math.round(4 * TWIPS_PER_POINT);
long three = Math.round(3 * TWIPS_PER_POINT);
- assertThat(margins(cell)).containsExactly(three, four, three, four);
+ assertThat(margins(cell)).containsExactly(three - SEAT, four, three + SEAT, four);
}
@Test
@@ -176,9 +216,9 @@ void aCellsOwnPaddingBeatsTheRowsAndTheTablesTest() throws Exception {
// The first row's top, less the default 1pt rule above the table: the row's smaller top
// as the cells' margin, the rest of the larger in the cell's first paragraph.
- assertThat(margins(table.getRow(0).getCell(0))[0]).isEqualTo(Math.round(5 * TWIPS_PER_POINT));
+ assertThat(margins(table.getRow(0).getCell(0))[0]).isEqualTo(Math.round(5 * TWIPS_PER_POINT) - SEAT);
assertThat(margins(table.getRow(0).getCell(1))[0] + before(table.getRow(0).getCell(1)))
- .isEqualTo(Math.round(10 * TWIPS_PER_POINT));
+ .isEqualTo(Math.round(10 * TWIPS_PER_POINT) - SEAT);
}
@Test
@@ -197,8 +237,10 @@ void aRowsCellsShareItsSmallestVerticalMarginsTheRestWrittenInTheirParagraphs()
assertThat(margins(loose)[0]).as("top, as the tight cell's").isEqualTo(margins(tight)[0]);
assertThat(margins(loose)[2]).as("bottom, as the tight cell's").isEqualTo(margins(tight)[2]);
- assertThat(margins(loose)[0] + before(loose)).as("its own 8pt above").isEqualTo(Math.round(8 * TWIPS_PER_POINT));
- assertThat(margins(loose)[2] + after(loose)).as("its own 6pt below").isEqualTo(Math.round(6 * TWIPS_PER_POINT));
+ assertThat(margins(loose)[0] + before(loose)).as("its own 8pt above")
+ .isEqualTo(Math.round(8 * TWIPS_PER_POINT) - SEAT);
+ assertThat(margins(loose)[2] + after(loose)).as("its own 6pt below")
+ .isEqualTo(Math.round(6 * TWIPS_PER_POINT) + SEAT);
}
@Test
diff --git a/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxCellSeatTest.java b/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxCellSeatTest.java
new file mode 100644
index 000000000..abc0a4182
--- /dev/null
+++ b/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxCellSeatTest.java
@@ -0,0 +1,268 @@
+package com.demcha.compose.document.backend.semantic.docx;
+
+import com.demcha.compose.document.dsl.ParagraphBuilder;
+import com.demcha.compose.document.style.DocumentColor;
+import com.demcha.compose.document.style.DocumentInsets;
+import com.demcha.compose.document.style.DocumentStroke;
+import com.demcha.compose.document.style.DocumentTextStyle;
+import com.demcha.compose.document.table.DocumentTableCell;
+import com.demcha.compose.document.table.DocumentTableColumn;
+import com.demcha.compose.document.table.DocumentTableStyle;
+import com.demcha.compose.document.table.DocumentTableTextAnchor;
+import com.demcha.compose.font.FontName;
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
+import org.apache.poi.xwpf.usermodel.XWPFTableCell;
+import org.apache.poi.xwpf.usermodel.XWPFTableRow;
+import org.junit.jupiter.api.Test;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcMar;
+
+import java.util.function.Consumer;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * A table text cell's lines stand on the page's baselines in Word, through the row's margins.
+ *
+ * The page sets a cell's line its face's ascent below the line's top; Word stands an exact
+ * line's baseline four fifths of the way down it. Measured, a line of 8pt Poppins stood 0.58pt
+ * low in Word and 0.55 in LibreOffice, of Lato 0.24 high, whatever the cell's anchor. Every cell of
+ * a row takes the row's largest margins, so the margins move every cell's text at once: the top
+ * made smaller by as much as the bottom is made larger, and the row keeps its height.
+ */
+class DocxCellSeatTest {
+
+ /** Poppins' ascent, in ems: 1050 of 1000 units. */
+ private static final double POPPINS_ASCENT = 1.05;
+ /** Lato's ascent, in ems: 1974 of 2000 units. */
+ private static final double LATO_ASCENT = 0.987;
+ /** Helvetica's ascent, in ems: 718 of 1000 units, as its font metrics state it. */
+ private static final double HELVETICA_ASCENT = 0.718;
+ /** Gothic A1's ascent, in ems: 798 of 1000 units, its own line one em. */
+ private static final double GOTHIC_A1_ASCENT = 0.798;
+ /** The padding the tables here are laid out with, in twips: 4pt all round, and no rules. */
+ private static final long PADDING = 80;
+
+ @Test
+ void aRowOfTextCellsSetLowInWordIsRaisedThroughItsMargins() throws Exception {
+ try (XWPFDocument document = export(page -> page.addTable(t -> t
+ .columns(DocumentTableColumn.fixed(100), DocumentTableColumn.fixed(100), DocumentTableColumn.fixed(100))
+ .rowCells(cell("Middle", poppins(8), DocumentTableTextAnchor.CENTER),
+ cell("Top", poppins(8), DocumentTableTextAnchor.TOP_LEFT),
+ cell("Bottom", poppins(8), DocumentTableTextAnchor.BOTTOM_LEFT))))) {
+ XWPFTableRow row = document.getTables().get(0).getRow(0);
+ long raise = Math.round((0.8 * line(row.getCell(0)) - POPPINS_ASCENT * 8) * 20);
+
+ assertThat(raise).as("the premise: Word sets Poppins half a point low").isBetween(10L, 12L);
+ for (XWPFTableCell cell : row.getTableCells()) {
+ assertThat(margins(cell)).as("each cell, whatever its anchor, its room moved up and as tall")
+ .containsExactly(PADDING - raise, PADDING + raise);
+ }
+ }
+ }
+
+ @Test
+ void aRowOfTextCellsSetHighInWordIsLoweredThroughItsMargins() throws Exception {
+ try (XWPFDocument document = export(page -> page.addTable(t -> t
+ .columns(DocumentTableColumn.fixed(100))
+ .rowCells(cell("Lato", lato(8), DocumentTableTextAnchor.CENTER))))) {
+ XWPFTableCell cell = document.getTables().get(0).getRow(0).getCell(0);
+ long raise = Math.round((0.8 * line(cell) - LATO_ASCENT * 8) * 20);
+
+ assertThat(raise).as("the premise: Word sets Lato a quarter point high").isBetween(-5L, -3L);
+ assertThat(margins(cell)).containsExactly(PADDING - raise, PADDING + raise);
+ }
+ }
+
+ @Test
+ void aRowIsMovedByTheLeastItsCellsCallFor() throws Exception {
+ // Helvetica at 14, 7 and 10pt stands 6, 3 and 4 twips low: none is moved past the page's.
+ try (XWPFDocument document = export(page -> page.addTable(t -> t
+ .columns(DocumentTableColumn.fixed(100), DocumentTableColumn.fixed(100), DocumentTableColumn.fixed(100))
+ .rowCells(cell("Large", helvetica(14), DocumentTableTextAnchor.CENTER),
+ cell("Small", helvetica(7), DocumentTableTextAnchor.CENTER),
+ cell("Middle", helvetica(10), DocumentTableTextAnchor.CENTER))))) {
+ XWPFTableRow row = document.getTables().get(0).getRow(0);
+ long large = Math.round((0.8 * line(row.getCell(0)) - HELVETICA_ASCENT * 14) * 20);
+ long small = Math.round((0.8 * line(row.getCell(1)) - HELVETICA_ASCENT * 7) * 20);
+ long middle = Math.round((0.8 * line(row.getCell(2)) - HELVETICA_ASCENT * 10) * 20);
+
+ assertThat(small).as("the premise: the least is the middle cell's, apart from the others")
+ .isLessThan(middle).isLessThan(large).isPositive();
+ assertThat(large).as("the default face's, as a paragraph of it is raised").isEqualTo(DocxExports.DEFAULT_LINE_RAISE);
+ for (XWPFTableCell cell : row.getTableCells()) {
+ assertThat(margins(cell)).containsExactly(PADDING - small, PADDING + small);
+ }
+ }
+ }
+
+ @Test
+ void aCellOfSeveralLinesMovesThemTogetherAndKeepsTheSpaceBetweenThem() throws Exception {
+ // A paragraph a line, the cell's line spacing after each but the last.
+ try (XWPFDocument document = export(page -> page.addTable(t -> t
+ .columns(DocumentTableColumn.fixed(100))
+ .rowCells(DocumentTableCell.lines("One", "Two").withStyle(DocumentTableStyle.builder()
+ .padding(DocumentInsets.of(4)).stroke(DocumentStroke.of(DocumentColor.BLACK, 0))
+ .textStyle(poppins(8)).textAnchor(DocumentTableTextAnchor.BOTTOM_LEFT).lineSpacing(2).build()))))) {
+ XWPFTableCell cell = document.getTables().get(0).getRow(0).getCell(0);
+ long raise = Math.round((0.8 * line(cell) - POPPINS_ASCENT * 8) * 20);
+
+ assertThat(cell.getParagraphs()).as("the premise: a paragraph a line").hasSize(2);
+ assertThat(margins(cell)).containsExactly(PADDING - raise, PADDING + raise);
+ assertThat(DocxTwips.of(cell.getParagraphs().get(0).getCTP().getPPr().getSpacing().getAfter()))
+ .as("the space between the lines").isEqualTo(40);
+ }
+ }
+
+ @Test
+ void eachRowIsMovedOnItsOwn() throws Exception {
+ try (XWPFDocument document = export(page -> page.addTable(t -> t
+ .columns(DocumentTableColumn.fixed(100))
+ .rowCells(cell("Header", lato(8), DocumentTableTextAnchor.CENTER))
+ .rowCells(cell("Body", poppins(8), DocumentTableTextAnchor.CENTER))))) {
+ var table = document.getTables().get(0);
+ long lowered = Math.round((0.8 * line(table.getRow(0).getCell(0)) - LATO_ASCENT * 8) * 20);
+ long raised = Math.round((0.8 * line(table.getRow(1).getCell(0)) - POPPINS_ASCENT * 8) * 20);
+
+ assertThat(margins(table.getRow(0).getCell(0))).containsExactly(PADDING - lowered, PADDING + lowered);
+ assertThat(margins(table.getRow(1).getCell(0))).containsExactly(PADDING - raised, PADDING + raised);
+ }
+ }
+
+ @Test
+ void aTableWithNoLayoutKeepsItsMargins() throws Exception {
+ // Nothing measured the lines: there is no seat of the page's to move them to.
+ try (XWPFDocument document = DocxExports.withoutLayout(400, 600, 20, page -> page.addTable(t -> t
+ .columns(DocumentTableColumn.fixed(100))
+ .rowCells(cell("Poppins", poppins(8), DocumentTableTextAnchor.CENTER))))) {
+ assertThat(margins(document.getTables().get(0).getRow(0).getCell(0))).containsExactly(PADDING, PADDING);
+ }
+ }
+
+ @Test
+ void aRowWhoseCellsCallForOppositeWaysIsLeftAsItWas() throws Exception {
+ try (XWPFDocument document = export(page -> page.addTable(t -> t
+ .columns(DocumentTableColumn.fixed(100), DocumentTableColumn.fixed(100))
+ .rowCells(cell("Low", poppins(8), DocumentTableTextAnchor.CENTER),
+ cell("High", lato(8), DocumentTableTextAnchor.CENTER))))) {
+ for (XWPFTableCell cell : document.getTables().get(0).getRow(0).getTableCells()) {
+ assertThat(margins(cell)).containsExactly(PADDING, PADDING);
+ }
+ }
+ }
+
+ @Test
+ void aBlankCellDoesNotHoldItsRowBack() throws Exception {
+ // In a face Word sets high: measured, it would call for the opposite way and hold the row.
+ try (XWPFDocument document = export(page -> page.addTable(t -> t
+ .columns(DocumentTableColumn.fixed(100), DocumentTableColumn.fixed(100))
+ .rowCells(cell("Text", poppins(8), DocumentTableTextAnchor.CENTER),
+ cell("", lato(8), DocumentTableTextAnchor.CENTER))))) {
+ XWPFTableRow row = document.getTables().get(0).getRow(0);
+ long raise = Math.round((0.8 * line(row.getCell(0)) - POPPINS_ASCENT * 8) * 20);
+
+ for (XWPFTableCell cell : row.getTableCells()) {
+ assertThat(margins(cell)).containsExactly(PADDING - raise, PADDING + raise);
+ }
+ }
+ }
+
+ @Test
+ void aRowHoldingAComposedCellIsLeftAsItWas() throws Exception {
+ // The composed paragraph is seated by its own writer; the margins would move it again.
+ try (XWPFDocument document = export(page -> page.addTable(t -> t
+ .columns(DocumentTableColumn.fixed(100), DocumentTableColumn.fixed(100))
+ .rowCells(cell("Text", poppins(8), DocumentTableTextAnchor.CENTER),
+ DocumentTableCell.node(new ParagraphBuilder().text("Composed").textStyle(poppins(8))
+ .margin(DocumentInsets.zero()).build()).withStyle(style(poppins(8),
+ DocumentTableTextAnchor.CENTER)))))) {
+ assertThat(margins(document.getTables().get(0).getRow(0).getCell(0))).containsExactly(PADDING, PADDING);
+ }
+ }
+
+ @Test
+ void aRowInAVerticalMergeIsLeftAsItWas() throws Exception {
+ try (XWPFDocument document = export(page -> page.addTable(t -> t
+ .columns(DocumentTableColumn.fixed(100), DocumentTableColumn.fixed(100))
+ .rowCells(cell("Spans", poppins(8), DocumentTableTextAnchor.CENTER).rowSpan(2),
+ cell("First", poppins(8), DocumentTableTextAnchor.CENTER))
+ .rowCells(cell("Second", poppins(8), DocumentTableTextAnchor.CENTER))))) {
+ assertThat(margins(document.getTables().get(0).getRow(0).getCell(1))).containsExactly(PADDING, PADDING);
+ }
+ }
+
+ @Test
+ void aRaiseTakesNoMoreThanTheTopMarginHolds() throws Exception {
+ // A quarter point above the text: Poppins calls for more.
+ try (XWPFDocument document = export(page -> page.addTable(t -> t
+ .columns(DocumentTableColumn.fixed(100))
+ .rowCells(DocumentTableCell.text("Tight").withStyle(DocumentTableStyle.builder()
+ .padding(new DocumentInsets(0.25, 4, 4, 4)).stroke(DocumentStroke.of(DocumentColor.BLACK, 0))
+ .textStyle(poppins(8)).textAnchor(DocumentTableTextAnchor.CENTER).build()))))) {
+ assertThat(margins(document.getTables().get(0).getRow(0).getCell(0))).containsExactly(0L, PADDING + 5);
+ }
+ }
+
+ @Test
+ void aLoweringTakesNoMoreThanTheBottomMarginHolds() throws Exception {
+ // A tenth of a point below the text: Lato calls for more.
+ try (XWPFDocument document = export(page -> page.addTable(t -> t
+ .columns(DocumentTableColumn.fixed(100))
+ .rowCells(DocumentTableCell.text("Tight").withStyle(DocumentTableStyle.builder()
+ .padding(new DocumentInsets(4, 4, 0.1, 4)).stroke(DocumentStroke.of(DocumentColor.BLACK, 0))
+ .textStyle(lato(8)).textAnchor(DocumentTableTextAnchor.CENTER).build()))))) {
+ assertThat(margins(document.getTables().get(0).getRow(0).getCell(0))).containsExactly(PADDING + 2, 0L);
+ }
+ }
+
+ @Test
+ void aMoveUnderATenthOfAPointIsLeftAsItWas() throws Exception {
+ // Word sets lines on a grid 0.12pt apart: a twip of margin moves a line a step or nothing.
+ try (XWPFDocument document = export(page -> page.addTable(t -> t
+ .columns(DocumentTableColumn.fixed(100))
+ .rowCells(cell("Gothic", DocumentTextStyle.builder().fontName(FontName.GOTHIC_A1).size(14).build(),
+ DocumentTableTextAnchor.CENTER))))) {
+ XWPFTableCell cell = document.getTables().get(0).getRow(0).getCell(0);
+ double below = 0.8 * line(cell) - GOTHIC_A1_ASCENT * 14;
+
+ assertThat(below).as("the premise: Word sets Gothic A1 low by a twip and more, under a tenth")
+ .isBetween(0.025, 0.1);
+ assertThat(margins(cell)).containsExactly(PADDING, PADDING);
+ }
+ }
+
+ private static DocumentTableCell cell(String text, DocumentTextStyle face, DocumentTableTextAnchor anchor) {
+ return DocumentTableCell.text(text).withStyle(style(face, anchor));
+ }
+
+ private static DocumentTableStyle style(DocumentTextStyle face, DocumentTableTextAnchor anchor) {
+ return DocumentTableStyle.builder().padding(DocumentInsets.of(4)).stroke(DocumentStroke.of(DocumentColor.BLACK, 0))
+ .textStyle(face).textAnchor(anchor).build();
+ }
+
+ private static DocumentTextStyle poppins(double size) {
+ return DocumentTextStyle.builder().fontName(FontName.POPPINS).size(size).build();
+ }
+
+ private static DocumentTextStyle lato(double size) {
+ return DocumentTextStyle.builder().fontName(FontName.LATO).size(size).build();
+ }
+
+ private static DocumentTextStyle helvetica(double size) {
+ return DocumentTextStyle.builder().fontName(FontName.HELVETICA).size(size).build();
+ }
+
+ /** The exact line a cell's first paragraph is written at, in points. */
+ private static double line(XWPFTableCell cell) {
+ return DocxTwips.of(cell.getParagraphs().get(0).getCTP().getPPr().getSpacing().getLine()) / 20.0;
+ }
+
+ /** A cell's top and bottom margins, in twips. */
+ private static long[] margins(XWPFTableCell cell) {
+ CTTcMar mar = cell.getCTTc().getTcPr().getTcMar();
+ return new long[]{DocxTwips.of(mar.getTop().getW()), DocxTwips.of(mar.getBottom().getW())};
+ }
+
+ private static XWPFDocument export(Consumer content) throws Exception {
+ return DocxExports.withLayout(400, 600, 20, content);
+ }
+}
diff --git a/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxExports.java b/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxExports.java
index 11f61e33c..39df7c04e 100644
--- a/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxExports.java
+++ b/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxExports.java
@@ -33,7 +33,9 @@ final class DocxExports {
* above it, in twips: the page seats its baseline 10.05pt down its 12.95pt line, Word four
* fifths of the way down, 0.31pt lower ({@code DocxBaselineSeatTest} holds it to that). A
* test of the space between blocks of default text reads the space above such a line as that
- * much less, and the space below it as that much more.
+ * much less, and the space below it as that much more. A table cell's default face is the same
+ * text, and a row of such cells is moved up as much through its margins
+ * ({@code DocxCellSeatTest}).
*/
static final long DEFAULT_LINE_RAISE = 6;
/** {@link #DEFAULT_LINE_RAISE} for the default face at 7pt, the size tests set small text in. */
diff --git a/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxLineSurplusTest.java b/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxLineSurplusTest.java
index 16180465c..d79bf1fba 100644
--- a/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxLineSurplusTest.java
+++ b/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxLineSurplusTest.java
@@ -113,13 +113,18 @@ void theSpaceBelowAParagraphOfOneSizeTakesWhatItsRoundingAdds() throws Exception
}
@Test
- void aParagraphWrittenAtItsTallestLineOwesNothingForItsRounding() throws Exception {
+ void theSpaceBelowAParagraphOfOneSizeAddsWhatItsRoundingTakes() throws Exception {
// Rounded down to the twip, over enough lines to fall a tenth of a point and more short of
- // the page: owed, that rounding stood ModernInvoice's lines a step of Word's grid lower.
+ // the page: Word sets the lines as written, and what follows stood that much high —
+ // ModernInvoice's address blocks, six lines each, and the table under them 0.15pt.
Exported exported = rounded(surplus -> surplus < -0.15);
+ double line = line(paragraph(exported.document(), "rounded"));
+ double page = exported.heights().get("Rounded");
+ double shortfall = page - Math.round(page / line) * line;
- assertThat(before(paragraph(exported.document(), "After"))).as("the gap alone")
- .isEqualTo(400 - DocxExports.DEFAULT_LINE_RAISE);
+ assertThat(before(paragraph(exported.document(), "After")) / 20.0)
+ .as("the gap and what the lines fall short of the page by")
+ .isCloseTo(20 + shortfall - RAISE, within(0.05));
}
@Test
diff --git a/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxTablePaintTest.java b/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxTablePaintTest.java
index ccce9e1a2..77d5a37b9 100644
--- a/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxTablePaintTest.java
+++ b/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxTablePaintTest.java
@@ -120,9 +120,10 @@ void aHairlineStaysALineRatherThanRoundingAway() throws Exception {
.build());
// 0.05 pt is under an eighth; rounding it to zero would ask Word for a border of no
- // width, which is a border nobody sees.
+ // width, which is a border nobody sees. It is written at Word's thinnest, two eighths,
+ // the width Word draws a thinner one at, and the cell's padding gives up that much.
assertThat(table.getRow(0).getCell(0).getCTTc().getTcPr().getTcBorders().getTop().getSz())
- .isEqualTo(BigInteger.ONE);
+ .isEqualTo(BigInteger.TWO);
}
@Test
From 5c410373608fc471cef045d9e7f886cdaaaaec61 Mon Sep 17 00:00:00 2001
From: DemchaAV
Date: Sun, 11 Oct 2026 11:29:08 +0100
Subject: [PATCH 2/2] fix(docx): move what a row's margins leave of a text
cell's seat by its position, and owe no rounding a picture outgrows
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- What the margins leave of a text cell's call — in a row they do not
move, or move by less — is moved by its text's position where that is
half a point or more, as a paragraph's is; under it, LibreOffice's
overshoot would be more than what is left.
- A paragraph whose pictures make its line taller than written
(makeRoomForPictures) takes back the rounding it owed below it.
- A cell's seat is read off the exact line its first paragraph is written
at; a row's entries are taken out when it is decided.
- A cell's rule is written from two to ninety-six eighths of a point, the
range of a line border's width (ruleEighths(double)), and counted to the
twip through one helper with borderTwips.
- Docs: the CHANGELOG entry names the position, the exclusions and the
floor; the recipe and the capability matrix say a rule between two rows
comes off a twip short where it is odd.
- Fidelity baselines rewritten (Word, LibreOffice on Windows).
- Tests: DocxCellSeatTest (the least of three cells, the position after
the margins, the lowering clamp, a cell of two lines, rows decided on
their own, no layout), DocxCellPaddingTest (a rule under two eighths and
over twelve points), DocxLineSurplusTest (a picture outgrowing the owed
rounding).
---
CHANGELOG.md | 63 ++--
.../architecture/backend-capability-matrix.md | 4 +-
docs/recipes/docx-export.md | 4 +-
.../libreoffice-windows-lines.tsv | 302 +++++++++---------
.../docx-fidelity/libreoffice-windows.tsv | 10 +-
.../docx-fidelity/word-windows-lines.tsv | 274 ++++++++--------
.../resources/docx-fidelity/word-windows.tsv | 4 +-
.../semantic/docx/DocxSemanticBackend.java | 117 +++++--
.../semantic/docx/DocxCellPaddingTest.java | 16 +
.../semantic/docx/DocxCellSeatTest.java | 51 ++-
.../semantic/docx/DocxLineSurplusTest.java | 37 +++
11 files changed, 513 insertions(+), 369 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e4c80a3cc..3affba0be 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,15 +14,17 @@ follow semantic versioning; release dates are ISO 8601.
below the line's top; Word stands an exact line's baseline four fifths of the way down it,
whatever the face. A cell's text stood as far off as the two are apart, at the top, the middle
or the bottom of the cell: a line of 8pt Poppins 0.58pt low in Word and 0.55pt in LibreOffice,
- of Helvetica 0.24 and 0.16pt, of Lato 0.24pt high (measured). Both editors give every cell of a
- row its largest top and bottom margins, so the row's top margin is made smaller and its bottom
- one as much larger — or the other way — by the least any of its cells calls for, no further
- than the margin holds: every cell's text moves with its room, and the row keeps its height.
- Measured, the lines then stood within 0.04pt of the page's in Word and 0.09pt in LibreOffice.
- What a row's other cells call for beyond its least is left, as is a move under a tenth of a
- point. Not a row holding a composed cell, whose paragraphs their own writers seat where they
- can, nor a row the layout did not measure, nor one in a vertical merge or whose cells call for
- opposite ways.
+ of Helvetica 0.24 and 0.16pt, of Lato 0.24 and 0.25pt high (measured). Both editors give every
+ cell of a row its largest top and bottom margins, so the row's top margin is made smaller and
+ its bottom one as much larger — or the other way — by the least any of its cells calls for, no
+ further than the margin holds: every cell's text moves with its room, and the row keeps its
+ height. Measured, the lines then stood within 0.04pt of the page's in Word and 0.09pt in
+ LibreOffice. A row is not moved where its cells call for opposite ways or its least call is
+ under a tenth of a point. Not a row holding a composed cell, whose paragraphs their own writers
+ seat where they can, nor a row the layout did not measure, nor one in a vertical merge. What the
+ margins leave of a cell's call, half a point and more, is moved by its text's position, as a
+ paragraph's is: a cell of 8pt Poppins beside one of Lato, the two called opposite ways, stood
+ 0.58pt low.
- **A paragraph written at its tallest line owes what its rounding takes.** Its lines are
written to the twip, and what that took from the page's height over several lines stood what
follows higher: `ModernInvoice`'s address blocks, six lines of 11.475pt written at 11.45,
@@ -30,18 +32,19 @@ follow semantic versioning; release dates are ISO 8601.
paragraph written at another height owes what it falls short.
- **A table's rules come off its padding as wide as Word draws them**, in eighths of a point: a
0.7pt hairline is drawn 0.75pt wide, and taken off at 0.7 it stood `EditorialProposal`'s tables
- and all under them a step of Word's grid lower. A rule thinner than Word draws one is written at
- its thinnest, a quarter point, as a rule elsewhere is.
+ and all under them a step of Word's grid lower. A cell's rule is written from two to
+ ninety-six eighths, the range of a line border's width, as a paragraph's rule is.
In the DOCX fidelity corpus 12 documents stand nearer the page in Word, the sum of the medians
- 0.93pt nearer — `invoice-classic_long`'s median line from 0.26pt to 0.06pt, `invoice-modern_long`'s
- from 0.22pt to 0.10pt, `invoice-subscription`'s from 0.56pt to 0.43pt — and 11 in LibreOffice on
- Windows, `invoice-classic_long`'s from 0.22pt to 0.05pt. `invoice-modern`'s moves from 0.08pt to
- 0.12pt in Word and from 0.07pt to 0.13pt in LibreOffice: its table's text, set low in its cells,
- had stood where the page sets it only because its rows stood as much high, and the notes under
- the table stand 0.1pt lower, where Word leaves more space after a table than the page does.
- `cv-editorial_blue`'s skills table now stands with the column round it, which LibreOffice sets
- 0.1 to 0.3pt high: its median there from 0.09pt to 0.14pt. The report names nothing more.
+ 1.45pt nearer — `invoice-consulting_long`'s median line from 0.74pt to 0.35pt,
+ `invoice-classic_long`'s from 0.26pt to 0.06pt, `invoice-subscription`'s from 0.56pt to 0.43pt —
+ and 12 in LibreOffice on Windows, 1.38pt, `invoice-consulting_long`'s from 0.69pt to 0.22pt.
+ `invoice-modern`'s moves from 0.08pt to 0.12pt in Word and from 0.07pt to 0.13pt in LibreOffice:
+ its table's text, set low in its cells, had stood where the page sets it only because its rows
+ stood as much high, and the notes under the table stand 0.1pt lower, where Word leaves more space
+ after a table than the page does. `cv-editorial_blue`'s skills table now stands with the column
+ round it, which LibreOffice sets 0.1 to 0.3pt high: its median there from 0.09pt to 0.14pt. The
+ report names nothing more.
- **A DOCX export raises a line Word sets low into the space above it, where both editors keep
it.** Both editors stand an exact line's baseline four fifths of the way down it whatever the
@@ -1421,17 +1424,17 @@ follow semantic versioning; release dates are ISO 8601.
moved to the page's baseline (`w:position`) wherever the two stand half a point or more apart,
from the line Word was given — a line pair's from the higher text's top, lines that took their
gaps from the space above from that higher top, several lines at the middle one; a list item's
- is not moved yet, and a table text cell's is moved by its row's margins. Lines a container stacks
- tighter than their face are each written to end halfway between their own letters and the next
- line's, read from the glyphs' outlines: Word draws an exact line's text on screen only inside the
- line, and lines a pitch tall cut the title's descenders and capitals there. Where the last layer
- of a shape container runs past its foot, it ends at the foot, or below its letters where they hang
- past it. Where the page sets two lines' letters into each other the edge still falls halfway, so
- the page does not move; a stack whose letters cannot be read, or that holds a picture, keeps each
- line's own height, and a line with space above or below it stays out of a stack. In Word
- `NorthlineProposal`'s median drift falls from 8.0pt to 0.8, its cover within 1.5pt of the page
- throughout, and `EditorialProposal`'s from 5.9 to 0.4; across the 62 templates, lines more than
- 2pt off fall from 1464 to 1341.
+ is not moved yet, and a table text cell's is moved by its row's margins where its row allows (see
+ above). Lines a container stacks tighter than their face are each written to end halfway between
+ their own letters and the next line's, read from the glyphs' outlines: Word draws an exact line's
+ text on screen only inside the line, and lines a pitch tall cut the title's descenders and
+ capitals there. Where the last layer of a shape container runs past its foot, it ends at the foot,
+ or below its letters where they hang past it. Where the page sets two lines' letters into each
+ other the edge still falls halfway, so the page does not move; a stack whose letters cannot be
+ read, or that holds a picture, keeps each line's own height, and a line with space above or below
+ it stays out of a stack. In Word `NorthlineProposal`'s median drift falls from 8.0pt to 0.8, its
+ cover within 1.5pt of the page throughout, and `EditorialProposal`'s from 5.9 to 0.4; across the
+ 62 templates, lines more than 2pt off fall from 1464 to 1341.
- **A value set from its start keeps its start in Word.** Two texts one layer holds on one line —
a label and its value, a title and its dates — are written as one Word line split by a tab
stop, and the stop was always a right tab at the right text's end. A value aligned left in a
diff --git a/docs/architecture/backend-capability-matrix.md b/docs/architecture/backend-capability-matrix.md
index cc2349577..a44d6d711 100644
--- a/docs/architecture/backend-capability-matrix.md
+++ b/docs/architecture/backend-capability-matrix.md
@@ -63,7 +63,7 @@ Payload records live in `core` under
| Capability (payload) | PDF (fixed) | PPTX (fixed) | DOCX (semantic) |
|---|---|---|---|
-| Paragraph — pre-wrapped lines, runs, alignment (`ParagraphFragmentPayload`) | ✅ `PdfParagraphFragmentRenderHandler` | ✅ `PptxParagraphFragmentRenderHandler` (one absolute, wrap-disabled frame per measured line) | ⚠️ semantic paragraphs (`DocxSemanticBackend`) — each run keeps its own style, falling back to the paragraph's when it has none; a centred or right-aligned left-to-right line of its own, of text alone and untracked, that Word sets a point or more wider or narrower at its half-point size has its letters spaced by the difference (`w:spacing`) and its room reckoned from the page's width; a `linkTarget` becomes a `w:hyperlink`, with a relationship for an address or `w:anchor` for one of the document's own anchors, and a run's own link wins over the paragraph's; a paragraph seated off its baseline (`TextVerticalAlign`) has its runs raised or lowered in the line (`w:position`) by the PDF backend's own correction (`ParagraphSeating`), one shift for the paragraph where the page seats each line by its own; Word and LibreOffice stand an exact line's baseline four fifths of the way down it whatever the face, where the page sets it the face's ascent down, matched at a paragraph's middle line: a line of its own Word sets a tenth of a point or more low is moved up into the space written above it and that space owed below it, in the flow and in cells, not in an overlay, a paragraph the layout moves to a new page or breaks over one, nor the space a panel's top border takes above its first line; what that space cannot give, and a line Word sets high, is moved in the same position where the two are half a point or more apart — Spectral's, not Lato's — which LibreOffice moves further by the face's height over its em (not yet a list item's; a table text cell's by its row's margins, see the table rows row; a picture among it moves with it in Word and stays on its own baseline in LibreOffice); lines a container stacks over one another tighter than their face each end halfway between their letters and the next line's (Word draws an exact line's text on screen only inside the line; its PDF export does not cut it), and the last layer of a shape container on one page, where its line runs past the foot, ends at the foot or below its letters; letters two lines share are split halfway so the page does not move, and a stack that holds a picture keeps its lines' own heights; a `bulletOffset` of spaces becomes the paragraph's indent (`w:ind` left, hanging or first line, by `indentStrategy`) in the flow and in cells, not yet over the flow, in an overlay's left-and-right pair, as a badge's initials or in a header or footer; one with letters in it is not written, its wrapped lines still set after the spaces that cover it; an auto-sized paragraph's text that takes its style is written at the size the page fits it to, read off the laid-out lines, a run with a style of its own keeping it, on every path that writes a paragraph — at its style's size where the lines do not tell the fitted size (no lines read, lines in sizes that do not say which is the paragraph's, or one paragraph added at more than one place); a paragraph a session reads as markdown — the default, unless `markdown(false)` — is written as the page sets it, read through the page's own parser, one run a piece in the face, family, colour, tracking and size the page's laid-out lines hold (an auto-sized one's read at the size the page fits it to, a heading at its multiple of it), its marks dropped, wherever the lines hold the pieces' letters so; where they are not read, or hold other letters or none (text the parser reads into nothing, which the page sets as nothing), as authored, its marks as letters; a `bookmark(...)` is Word's `HeadingN`, which Word's outline lists by the text of its Word paragraph — an overlay's pair's whole line, one level for both sides — at no level past the ninth. Outside a header or footer, the paragraph's report note (`ParagraphNode`) names each of these where it moves or renames something: the prefix's letters, and the room a path that writes no prefix leaves out where it moves a line; the size an auto-sized paragraph's text is written at, where the size the page fits it to is not measured; the marks of a paragraph the page read as markdown and the file holds as letters, where its laid-out lines hold fewer of them than its text, not measured where its lines are not read; a markdown heading written taller than the line the page sets it in, which Word cuts on screen; an outline title that is not the text Word lists, a level past the ninth that shares it with another, and the right side's entry where the left holds the line's level |
+| Paragraph — pre-wrapped lines, runs, alignment (`ParagraphFragmentPayload`) | ✅ `PdfParagraphFragmentRenderHandler` | ✅ `PptxParagraphFragmentRenderHandler` (one absolute, wrap-disabled frame per measured line) | ⚠️ semantic paragraphs (`DocxSemanticBackend`) — each run keeps its own style, falling back to the paragraph's when it has none; a centred or right-aligned left-to-right line of its own, of text alone and untracked, that Word sets a point or more wider or narrower at its half-point size has its letters spaced by the difference (`w:spacing`) and its room reckoned from the page's width; a `linkTarget` becomes a `w:hyperlink`, with a relationship for an address or `w:anchor` for one of the document's own anchors, and a run's own link wins over the paragraph's; a paragraph seated off its baseline (`TextVerticalAlign`) has its runs raised or lowered in the line (`w:position`) by the PDF backend's own correction (`ParagraphSeating`), one shift for the paragraph where the page seats each line by its own; Word and LibreOffice stand an exact line's baseline four fifths of the way down it whatever the face, where the page sets it the face's ascent down, matched at a paragraph's middle line: a line of its own Word sets a tenth of a point or more low is moved up into the space written above it and that space owed below it, in the flow and in cells, not in an overlay, a paragraph the layout moves to a new page or breaks over one, nor the space a panel's top border takes above its first line; what that space cannot give, and a line Word sets high, is moved in the same position where the two are half a point or more apart — Spectral's, not Lato's — which LibreOffice moves further by the face's height over its em (not yet a list item's; a table text cell's by its row's margins, see Table rows; a picture among it moves with it in Word and stays on its own baseline in LibreOffice); lines a container stacks over one another tighter than their face each end halfway between their letters and the next line's (Word draws an exact line's text on screen only inside the line; its PDF export does not cut it), and the last layer of a shape container on one page, where its line runs past the foot, ends at the foot or below its letters; letters two lines share are split halfway so the page does not move, and a stack that holds a picture keeps its lines' own heights; a `bulletOffset` of spaces becomes the paragraph's indent (`w:ind` left, hanging or first line, by `indentStrategy`) in the flow and in cells, not yet over the flow, in an overlay's left-and-right pair, as a badge's initials or in a header or footer; one with letters in it is not written, its wrapped lines still set after the spaces that cover it; an auto-sized paragraph's text that takes its style is written at the size the page fits it to, read off the laid-out lines, a run with a style of its own keeping it, on every path that writes a paragraph — at its style's size where the lines do not tell the fitted size (no lines read, lines in sizes that do not say which is the paragraph's, or one paragraph added at more than one place); a paragraph a session reads as markdown — the default, unless `markdown(false)` — is written as the page sets it, read through the page's own parser, one run a piece in the face, family, colour, tracking and size the page's laid-out lines hold (an auto-sized one's read at the size the page fits it to, a heading at its multiple of it), its marks dropped, wherever the lines hold the pieces' letters so; where they are not read, or hold other letters or none (text the parser reads into nothing, which the page sets as nothing), as authored, its marks as letters; a `bookmark(...)` is Word's `HeadingN`, which Word's outline lists by the text of its Word paragraph — an overlay's pair's whole line, one level for both sides — at no level past the ninth. Outside a header or footer, the paragraph's report note (`ParagraphNode`) names each of these where it moves or renames something: the prefix's letters, and the room a path that writes no prefix leaves out where it moves a line; the size an auto-sized paragraph's text is written at, where the size the page fits it to is not measured; the marks of a paragraph the page read as markdown and the file holds as letters, where its laid-out lines hold fewer of them than its text, not measured where its lines are not read; a markdown heading written taller than the line the page sets it in, which Word cuts on screen; an outline title that is not the text Word lists, a level past the ninth that shares it with another, and the right side's entry where the left holds the line's level |
| List hanging indent — a marker column and a content column (`ListBuilder.hangingIndent(true)`, `markerGap(...)`) | ✅ marker and content emitted as separate `ParagraphFragmentPayload` fragments at the resolved `markerX` / `contentX` | ✅ the same fragments — the fixed-layout pipeline resolves the geometry before either backend sees it | ⚠️ the top level only. `DocxSemanticBackend` exports a list as a real Word list — `numbering.xml`, `w:numPr` per item, the level carrying the marker — or, with rich items or a drawn marker, as paragraphs; content and nesting are unaffected. With the flag, the top level's marker column is the layout's — the marker's width and `markerGap`, the text and its wrapped lines where the page sets them — where the gap covers what Word may set the marker wider: a picture at its written size, its edges included, or text in the page's face (embedded, or a standard one Word sets in the same widths) grown to its half-point size, half a point clear. A Word list's level then indents and hangs by that column; a list of paragraphs writes the marker, a tab to a stop there, and hangs the item there. Word places content at absolute indents and has no relative-advance primitive, so without the layout's measure the gap could not be honoured; a Word list without the flag that the layout placed and that does not nest takes the page's column too, the spaces the page sets its wrapped lines after, its marker followed by a space (`w:suff`) and an item that wraps measured at Word's half-point size; a list that nests items, a list built as a tree of items (laid out flattened), and a marker the gap does not clear keep the stated column (180 twips, plus 120 per nesting level) — except, in a list of paragraphs, a nested rich item with no marker, which stands where the layout set its text, its measure weighed at Word's half-point sizes, where the layout's items are matched to the list's; a list that nests only such items sets its top level at the page's column too. The report counts, on the list, the items that stand at a stated column, a space past their marker or two spaces a level in, and names a centred or right-aligned list written flush left, a lineSpacing not written where the layout's items are not the list's own and one wraps (in a list composed in a table cell, its wrapping not measured), a continuationIndent not written where an item of a markerless list or a tree of items without the flag wraps or its wrapping is not measured, the rows the page draws as a marker alone for blank items of a flagged list, which are not written, and what items the page reads as markdown lose. An item of plain text the page reads as markdown — the default, unless `markdown(false)` — is written as the page sets it, matched to the lines the page laid it out in and read as the page lays it out (a flat item after the marker the page sets before it; a flagged item as its text alone; an item of a list built as a tree of items without the flag after the indent and marker the page reads with it), one run a piece in the face, family, colour, tracking and size those lines hold, Word or the file drawing the marker where it did (Word draws a tree's bullets regular, as the parser sets the marker it reads), the font table shipping the faces the page sets the pieces in; it is written as authored, its marks as letters, where its list's items are not matched one by one to the layout's (no layout, composed in a table cell, an item run onto the next page, a flagged list with a blank item), where its lines hold other letters, where the parser reads a tree's marker as markdown with the item (`*a*`), and where the parser reads it into nothing, and named where the page drops a mark from it or sets none of its text — not where it changes only its face or letters no mark is made of (`1.`); a markdown heading written taller than its item's line is named |
| Inline code/badge chips (`InlineBackground` on text spans) | ✅ `PdfParagraphFragmentRenderHandler` | ✅ `PptxParagraphFragmentRenderHandler` | ⚠️ `DocxSemanticBackend` — the fill becomes the run's own `w:shd`, in a paragraph and in a list item alike, so a badge still reads as a badge. What Word has no way to say is the shape: shading covers the glyph box, so the corner radius and the padding above and below the letters are not in the file, and the export records them. The padding beside the letters is written as the room it takes (`spaceAfterTheLastLetter`): character spacing after the chip's last letter, shaded with it, and after the letter before the chip, unshaded. A chip opening its line or following a picture has no letter before it, so its left padding is not in the file; no space is written after right-to-left letters or after a symbol or emoji. The export records, chip by chip, how each side was written. LibreOffice sets no spacing after a line's last letter, so it does not apply the right padding of a chip that ends a line. A `w:shd` fill is opaque, so a translucent chip is flattened first against what Word paints underneath it — the paragraph's shading, the cell's, or else the colour the page paints under the paragraph, a page background included — so the chip agrees with the file it is in and shows the colour the PDF shows. It stops being translucent, and that is recorded with the rest |
| Inline images (`ParagraphImageSpan`) | ✅ `PdfParagraphFragmentRenderHandler` | ✅ `PptxParagraphFragmentRenderHandler` | ✅ `DocxSemanticBackend.writeInlinePicture` (a picture in its own run where it sits among the words, at its size, inside the run's or the paragraph's link; raised or lowered by `w:position` to where the page's alignment and `baselineOffset` put it, from the layout's measure of the paragraph's first line — in a list, the list's text on a line as tall as the item's own tallest picture; LibreOffice ignores `w:position` on a picture and stands it on the baseline, so a picture the export draws itself (icon, emoji, shape) that the page raises carries the rise as transparent rows and needs no `w:position`, while one the page lowers stands in LibreOffice higher than on the page by as much as the page lowers it — up to the text's descent for a centred icon as tall as its line; the editor clips a picture to an exact line height, so a paragraph holding a picture that leaves its text — past the ascent or the descent, in Word's placement or on the baseline — has its lines written at least the height the picture reaches, grown by the editor rather than clipped, every line of the paragraph since Word has one line height for it, and each as tall as the editor's font makes it — for 14pt text about 2.5pt taller than the page's in LibreOffice; a picture inside its text in both editors keeps the exact height; a paragraph of one line of text in a Word paragraph of its own, with room above for its pictures' reach, keeps an exact line at the page's height of it, the pictures set in it where the page puts them in Word and what their ink reaches past it taken from the gaps around it, and in LibreOffice a lowered picture there stands higher and loses what passes the line's top; its description is the text it stands for or empty) |
@@ -80,7 +80,7 @@ Payload records live in `core` under
| Gradient strokes | ✅ `PdfPathPainter` (pattern stroking colour) | ✅ `PptxGradientFill` (native `ln`/`gradFill`) | ❌ |
| Image — STRETCH / CONTAIN / COVER fit (`ImageFragmentPayload`) | ✅ `PdfImageFragmentRenderHandler` | ✅ `PptxImageFragmentRenderHandler` (COVER via the picture source crop) | ✅ `DocxSemanticBackend.writeImage` (the box comes from `NodeDefinitionSupport.resolveImageDimensions`, the same rule layout applies to `width` / `height` / `scale` and the content-width clamp; CONTAIN is embedded at its fitted size, COVER via the picture source crop as in PPTX, and the picture type is read from the bytes; its left margin and padding are not written, and a picture drawn beside its text is fitted to its box with its padding in it — each named in the report) |
| Barcode / QR (`BarcodeFragmentPayload`) | ✅ `PdfBarcodeFragmentRenderHandler` (vector: the ZXing bit matrix filled as merged rectangles) | ✅ `PptxBarcodeFragmentRenderHandler` (native freeforms: the same ZXing bit matrix as merged rectangles) | ⚠️ `DocxSemanticBackend.writeBarcode` (a PNG picture of the same ZXing bit matrix through `BarcodeMatrices`, one pixel a cell, in the symbol's two colours with their alpha and at the node's size, its data as the picture's description; it scans, but its data is part of the picture rather than editable, reported `APPROXIMATED`, which also names a link, a transform or its left margin and padding as not carried; an `anchor` is a bookmark on its paragraph; in a page zone it is skipped) |
-| Table rows — resolved cells, row/col spans, two-pass fill/border paint (`TableRowFragmentPayload`) | ✅ `PdfTableRowFragmentRenderHandler` + row grouping in `PdfFixedLayoutBackend` | ✅ `PptxTableRowFragmentRenderHandler` + row grouping in `PptxFixedLayoutBackend` (positioned rectangles, edge lines, and text frames — never native PPTX tables, which re-lay-out content) | ⚠️ `DocxSemanticBackend.writeTable` (a real Word table on the grid `TableGrid` resolves: `colSpan` maps to `w:gridSpan`, `rowSpan` to `w:vMerge`, and the cascaded `DocumentTableStyle` text style reaches the cell's runs; the cell's fill maps to `w:shd` and its stroke to `w:tcBorders` — the engine's default 1pt black rule where the table states none, not Word's thinner grid — its padding to `w:tcMar`, less above and below the room Word makes for the horizontal rules (half of a rule between two rows, the lower row's, to each; the rules above and below the table whole to their row), each as wide as Word draws it, in eighths of a point; a row of text cells moved by its top and bottom margins together, from Word's seat four fifths of the way down an exact line onto the page's baselines, by the least its cells' lines call for and no further than the margins hold — not a row holding a composed cell, one the layout did not measure, one in a vertical merge or whose cells call for opposite ways, nor a move under a tenth of a point; a row's cells at the row's smallest top and bottom margins, since both editors give every cell the row's largest, the rest of each cell's padding as space above its first paragraph and below its last, down to the largest margin a cell opening with a table or in a vertical merge keeps; the cascaded `textAnchor` maps to `w:vAlign` on every cell and to `w:jc` on a text cell's paragraph, with the engine's default — the vertical middle, on the left, or on the right for a right-to-left cell — and `DEFAULT` at the bottom left, as the renderer draws it; a composed cell is written by the same writers that write its node anywhere, so one built from an image, a list or a table carries it — a nested table is a real `w:tbl` taking the width of the column it sits in, less its own margins and padding, which is the column's rather than the one the page gives it, since the layout reports a composed cell's content under the owner's path; the paragraph Word requires after a nested table is hidden where it ends its cell holding nothing and no space; a translucent fill is flattened against the colour the page paints under the cell, and a translucent rule against the cell's fill where it has one, since `w:shd` and `w:tcBorders` are opaque, and the table's report note names it (`translucency`); Word re-paginates, so the export states where the layout breaks: every row the layout placed is `w:cantSplit`, `repeatHeader(n)` rows are `w:tblHeader` and keep with the row under them, and a row of blocks is kept whole the same way; the paragraph Word requires after a document's closing table is an ordinary one where the last page has room for two lines below it, so a reader can type below the table, and otherwise a point tall with its mark hidden, so it opens no blank page, reported `APPROXIMATED` since text typed at the end then goes into the table's last cell) |
+| Table rows — resolved cells, row/col spans, two-pass fill/border paint (`TableRowFragmentPayload`) | ✅ `PdfTableRowFragmentRenderHandler` + row grouping in `PdfFixedLayoutBackend` | ✅ `PptxTableRowFragmentRenderHandler` + row grouping in `PptxFixedLayoutBackend` (positioned rectangles, edge lines, and text frames — never native PPTX tables, which re-lay-out content) | ⚠️ `DocxSemanticBackend.writeTable` (a real Word table on the grid `TableGrid` resolves: `colSpan` maps to `w:gridSpan`, `rowSpan` to `w:vMerge`, and the cascaded `DocumentTableStyle` text style reaches the cell's runs; the cell's fill maps to `w:shd` and its stroke to `w:tcBorders` — the engine's default 1pt black rule where the table states none, not Word's thinner grid — its padding to `w:tcMar`, less above and below the room Word makes for the horizontal rules (half of a rule between two rows, the lower row's, to each; the rules above and below the table whole to their row), each as wide as Word draws it, in eighths of a point (a rule between two rows halved to the twip, an odd one a twip short); a row of text cells moved by its top and bottom margins together, from Word's seat four fifths of the way down an exact line onto the page's baselines, by the least its cells' lines call for and no further than the margins hold — not a row holding a composed cell, one the layout did not measure, one in a vertical merge or whose cells call for opposite ways, nor a least call under a tenth of a point — and what the margins leave of a cell's call, half a point and more, moved by its text's position; a row's cells at the row's smallest top and bottom margins, since both editors give every cell the row's largest, the rest of each cell's padding as space above its first paragraph and below its last, down to the largest margin a cell opening with a table or in a vertical merge keeps; the cascaded `textAnchor` maps to `w:vAlign` on every cell and to `w:jc` on a text cell's paragraph, with the engine's default — the vertical middle, on the left, or on the right for a right-to-left cell — and `DEFAULT` at the bottom left, as the renderer draws it; a composed cell is written by the same writers that write its node anywhere, so one built from an image, a list or a table carries it — a nested table is a real `w:tbl` taking the width of the column it sits in, less its own margins and padding, which is the column's rather than the one the page gives it, since the layout reports a composed cell's content under the owner's path; the paragraph Word requires after a nested table is hidden where it ends its cell holding nothing and no space; a translucent fill is flattened against the colour the page paints under the cell, and a translucent rule against the cell's fill where it has one, since `w:shd` and `w:tcBorders` are opaque, and the table's report note names it (`translucency`); Word re-paginates, so the export states where the layout breaks: every row the layout placed is `w:cantSplit`, `repeatHeader(n)` rows are `w:tblHeader` and keep with the row under them, and a row of blocks is kept whole the same way; the paragraph Word requires after a document's closing table is an ordinary one where the last page has room for two lines below it, so a reader can type below the table, and otherwise a point tall with its mark hidden, so it opens no blank page, reported `APPROXIMATED` since text typed at the end then goes into the table's last cell) |
| Clip region open/close (`ShapeClipBegin/EndPayload`) | ✅ `PdfShapeClipBegin/EndRenderHandler` (CLIP_BOUNDS + CLIP_PATH) | ✅ `PptxClipSafety` + raster fallback in `PptxFixedLayoutBackend` — a provably no-op clip (padded content that cannot be cut) skips the fallback entirely and stays native, editable shapes; a clip that can cut ink renders through the PDF backend into one transparent picture on the clip bounds (pixel-exact, not editable as shapes; run-level link hotspots are not emitted and custom fragment handlers do not apply inside the picture; `Builder.clipRasterFallback(false)` restores unclipped vectors + warning; the raster targets a 2048px long edge, clamped to between native size and 4x, so a region larger than that is rendered at native resolution rather than downscaled — which also means its transient memory grows with the clip instead of stopping at the target (a 3370pt A0-landscape region costs ~45MB while rendering, against ~17MB for anything up to 2048pt); a true vector clip is tracked in [#413](https://github.com/DemchaAV/GraphCompose/issues/413)) | ⚠️ inline fallback + one-time capability warning; the report names a clip that cuts what its layers paint, measured from the layout's fragments by `DocxClipInk` — a clip that cuts nothing (an icon inside its box, a disc's initials, a photo filling its circle) is not named; a picture that fills a container clipped to an ellipse takes the ellipse as its geometry, which both editors crop it to; a badge's glyph — a smaller picture in a painted container that clips it to its outline (`CLIP_PATH`) and holds nothing else but drawing — is drawn by `DocxDrawings` as a floating picture over the outline, where the layout places it, reported `APPROXIMATED` — inside a filled panel the badge and its glyph are drawn in front of the shading; an icon picture beside its text in an unpainted container or a layer stack is drawn the same way; a filled or outlined rectangle or rounded rectangle holding text, composed in a table cell, which has no place in the layout to be drawn at, is written as a panel — a one-cell table in its fill and outline, its corners squared and reported, its row held at least the outline's height less its borders and margins, which keep inside it, and a one-line label the shape centres top to bottom on a line taller than the room Word leaves its content cut alike on both sides to that room, no closer to its letters than three quarters of a point, and seated where the page sets it; the rest of what a composed cell draws (an icon, a tile, a disc) is the table's own drawing and is drawn by `drawCellDrawing` where the layout puts it, anchored as a rectangle is |
| Timeline rail — one logical connector line resolved from marker and entry anchors after layout (`ShapeFragmentPayload` per page) | ✅ `PdfShapeFragmentRenderHandler` — one fragment per page, spliced beneath the markers | ✅ `PptxShapeFragmentRenderHandler` — same payload, same per-page fragments | ⚠️ `DocxDrawings` — the rail is read from the resolved layout's pass fragments and drawn per page as a `line` shape, and the markers as the shapes they are, anchored as a rectangle is: beside an entry's text they move with it when the text above is edited |
| Transform open/close — rotate/scale about fragment centre (`TransformBegin/EndPayload`) | ✅ `PdfTransformBegin/EndRenderHandler` | ✅ `PptxTransformBegin/EndRenderHandler` (group shape; rotation and centre-pivot scaling via the exterior/interior frame ratio) | ⚠️ inline fallback + one-time capability warning; a turned shape container is written upright, and the report names its transform — in its drawn outline's note, or on its own where the outline draws nothing |
diff --git a/docs/recipes/docx-export.md b/docs/recipes/docx-export.md
index cd84ffeca..eec09fce5 100644
--- a/docs/recipes/docx-export.md
+++ b/docs/recipes/docx-export.md
@@ -69,7 +69,7 @@ creation date is real metadata.
|---|---|
| Paragraphs | Word paragraphs with alignment, font, size, colour (a translucent one with its transparency, as Word's text fill — see "Translucent colours"), 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, as a badge's initials, or in a header or footer; the report names a prefix's letters, and the room a prefix sets lines in by where a path that writes none leaves it out and it moves a line — on the paragraph, or in a header or footer on the zone's note. A session reads markdown unless told not to (`markdown(false)`): it sets a paragraph of plain text's emphasis marks as the style of the text they mark, a heading line bold (the first three levels larger), and drops its marks; the export writes the text as the page sets it — read line by line through the page's own parser, one run a piece in the face, family, colour, tracking and size the page sets it in, `**Java**` a bold run reading `Java`, a linked paragraph's pieces in one link, Word's outline listing a heading by the text written — wherever it writes a paragraph, a page zone's and a badge's included (a badge's initials counted as the page sets them, and written in the flow where they stand in two faces or as a heading, as initials in two runs' faces are). The page's laid-out lines decide it: the pieces are written where those lines hold their letters in their faces, families, colours and tracking, at their sizes — an auto-sized paragraph's read at the size the page fits it to, a heading at its multiple of it; a session that reads no markdown has its marks written as they stand, and text the parser changes nothing of, an underscore inside a word, is written as it stands too. A paragraph composed in a table cell takes only lines that set its pieces so. The page sets a markdown heading in a line as tall as the paragraph's own and draws its letters past it; written in that exact line, Word cuts their tops on screen, and the report names a heading written taller than its line. The faces are the page's: where the session reads markdown its parser sets every piece in a face of its own, the paragraph's left aside, so a bold paragraph's `Senior_Engineer` is written regular, as the page sets it. A paragraph whose lines are not read — with no layout, composed in a table cell whose text, as authored or as the page reads it, no line of its table carries, or a page zone's the layout shows none of — or that the page sets in other letters than its text, as Arabic, which the page shapes before it reads the marks, or that the parser reads into nothing — a lone `*`, an empty list item; `***`, a rule; a line set four spaces in, a block of code — which the page sets as nothing, is written as authored, marks and all, and the report names it, saying where the lines are not read that whether the page reads its marks is not measured, where the page's parser drops one. An auto-sized paragraph (`autoSize`) is written at the size the page fits its text to, read off the layout's lines, on every path that writes a paragraph: a run with a style of its own keeps it, as on the page, and a prefix is measured at the fitted size. Where the lines do not tell it — none are read, they are in sizes that do not say which is the paragraph's, or the paragraph is added at more than one place, which the page fits at each apart — the text is written at its style's size, and the report says the fitted size is not measured, on the paragraph or, in a header or footer, on the zone's note. LibreOffice breaks a badge's initials wider than the square inscribed in its disc, at any size, and hides what wraps; an auto-sized badge, which fills its disc, meets this too. A body paragraph the layout moves to a new page keeps the space the layout leaves above its text there — its own top edge, the edges of the containers opening with it, and the gap before it where the gap did not fit at the foot of the page above — as an empty line that tall before it, kept with it, since Word drops a paragraph's space above at the top of a page and keeps a line's height; the rest of the space owed stays above that line, so Word breaks the page where it did, and the gap between the paragraph's lines comes off the line as it would off its space above. A paragraph in a table cell, an overlay or a list is left to its container |
| 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. An item the page reads as markdown is written as the page sets it, as a paragraph is. 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). Each rule comes off as wide as Word draws it, in eighths of a point: a 0.7pt hairline is drawn 0.75pt wide (measured: taken off at 0.7, `EditorialProposal`'s tables and all under them stood a step of Word's grid lower). A row held at the page's height is written less its margins and those rules too — a rule and a half in the first row and the last, two in a table of one row — since both editors read a row's written height as its cells' content (measured: held less one rule, a table ruled at 0.75pt stood 0.46pt taller in its first row and 0.36pt in its last). 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 row of text cells is moved by its margins to stand its text where the page sets it: the page sets a cell's line its face's ascent below the line's top, Word an exact line's baseline four fifths of the way down it, so every cell's top margin is made smaller and its bottom one as much larger — or the other way — by the least any of its cells calls for, no further than the margin holds, and each cell's text moves with its room, set at the top, the middle or the bottom, while the row keeps its height (measured: a line of 8pt Poppins stood 0.58pt low in Word and 0.55pt in LibreOffice, of Lato 0.24pt high; moved, within 0.04pt and 0.09pt). What the row's other cells call for beyond its least is left, and no position makes it up, since LibreOffice moves raised text further than it is raised: a cell of Poppins beside one of Helvetica stays low by the difference between their seats. Not a row holding a composed cell, whose paragraphs their own writers seat where they can, nor a row the layout did not measure, nor one in a vertical merge or whose cells call for opposite ways; less than a tenth of a point is left. LibreOffice sets a vertically centred cell's content as if its first paragraph had no space above it, so a cell padded more above than its row's smallest stands its text up to half that difference higher there (measured: 3pt above it stood the line 1.5pt high). 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 gap the layout carries onto the new page, because it did not fit at the foot of the page above, is not yet held above a table (body paragraphs and spacers: see their rows). A table's margin is its indent and the space round it, and its padding on the sides holds its rows in as the page draws them: its left side is in the indent too, and both are out of the room its columns are given |
+| 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). Each rule comes off as wide as Word draws it, in eighths of a point: a 0.7pt hairline is drawn 0.75pt wide (measured: taken off at 0.7, `EditorialProposal`'s tables and all under them stood a step of Word's grid lower). A cell's rule is written from two to ninety-six eighths of a point, the range of a line border's width. A rule between two rows is halved, each half rounded to the twip with the margin it comes off, so an odd one comes off a twip short and its rows stand a twip taller each (measured: `NorthlineProposal`'s investment table, ruled at 0.7pt, a twentieth of a point lower every row). A row held at the page's height is written less its margins and those rules too — a rule and a half in the first row and the last, two in a table of one row — since both editors read a row's written height as its cells' content (measured: held less one rule, a table ruled at 0.75pt stood 0.46pt taller in its first row and 0.36pt in its last). 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 row of text cells is moved by its margins to stand its text where the page sets it: the page sets a cell's line its face's ascent below the line's top, Word an exact line's baseline four fifths of the way down it, so every cell's top margin is made smaller and its bottom one as much larger — or the other way — by the least any of its cells calls for, no further than the margin holds, and each cell's text moves with its room, set at the top, the middle or the bottom, while the row keeps its height (measured: a line of 8pt Poppins stood 0.58pt low in Word and 0.55pt in LibreOffice, of Lato 0.24 and 0.25pt high; moved, within 0.04pt and 0.09pt). Not a row holding a composed cell, whose paragraphs their own writers seat where they can, nor a row the layout did not measure, nor one in a vertical merge or whose cells call for opposite ways; a least call under a tenth of a point is left. What the margins leave of a cell's call is moved by its text's position where that is half a point or more, as a paragraph's is: LibreOffice moves raised text further than it is raised, by up to half as much again, which from half a point up is less than what is left. LibreOffice sets a vertically centred cell's content as if its first paragraph had no space above it, so a cell padded more above than its row's smallest stands its text up to half that difference higher there (measured: 3pt above it stood the line 1.5pt high). 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 gap the layout carries onto the new page, because it did not fit at the foot of the page above, is not yet held above a table (body paragraphs and spacers: see their rows). A table's margin is its indent and the space round it, and its padding on the sides holds its rows in as the page draws them: its left side is in the indent too, and both are out of the room its columns are given |
| 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, less its own margins and padding — 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. In the flow, the margin and padding above and below are the space round the picture's paragraph; on the left they are not written, and the report names them, as it does a barcode's and a page reference's sides. A picture drawn beside its text is fitted to its box with its padding in it, which the report names too |
@@ -185,7 +185,7 @@ it cannot work out for itself:
| What | Where it lands |
|---|---|
-| Line height | `w:spacing w:lineRule="exact"` on every paragraph, cells and list items included — the height the engine measured, not a multiple Word would measure again against a substituted font. Word has one height for a paragraph's lines: it is the tallest line's text, or, where the page sets lines of different heights further apart than that, the page's mean distance between their baselines, with what a paragraph on one page then falls short of the page owed below it, and what it passes the page by — written at its tallest line, a wrapped line after a large first one, which the page sets at its own height — hung below it, as a line held to its icon is: the space below takes it, and what it cannot take is named (`space above`) (not yet a list item's, or text set over the flow; measured: `CompactMono`'s sidebar, whose skills are two lines a paragraph and each written 0.12pt taller than the page, ended a point low in Word). Lines rounded up to the twip, over enough of them, hang the same way; what rounding takes from a paragraph written at its tallest line is owed below it as well (measured: `ModernInvoice`'s address blocks, six lines of 11.475pt written at 11.45, stood the table under them 0.15pt high in Word and LibreOffice). A tenth of a point or less is left either way: Word sets lines on a grid of its own, 0.12pt apart (measured). In a paragraph of more than one line on one page, the spaces a `bulletOffset` sets before a line, written as an indent, do not count towards that line's text. A paragraph of lines as tall as their text, on one page, opening a table cell takes the gap above its first line from the cell's top padding, no more than steps its lines the page's distance apart — not in a row beside a merged cell or a cell opening with a table, whose margin Word would set the whole row at, nor in a panel. One with no room above it for the gap (opening a column, or a cell padded less) shares the gaps out over all its lines, so its lines stand a little closer than on the page. A paragraph the layout did not measure — one in a composed table cell — is left to the editor, and a line holding a picture above its text is written "at least" that height — except a paragraph of one line of text with room above for its pictures' reach, held exact at the page's height (see "Inline pictures"); in both the paragraph mark is set in the text's size and face, since the mark counts towards the last line's height. A line holding pictures and no text, where they fill the page's line, has its mark and its pictures' runs set at a point instead, so Word makes the line as tall as the pictures and no taller: in the paragraph's own size the mark's depth went under the picture (measured: `SlateOrange`'s skills, a 12.4pt icon beside each label, stood 0.2pt taller each in Word). A smaller picture in a line the page sets at its font's height keeps its mark, and so does a line holding a letter, a break, a tab, a field or a link's text. A paragraph's own line of drawn shapes and no text written at least their reach, which Word grows to the pictures and the transparent frame each keeps around its ink, has that frame taken from the space above the line and above what follows, where it passes the height written: the ink stands where the page draws it, and what follows where the page sets it. Both editors stand the baseline of an exact line four fifths of the way down it whatever the face (measured in Word and LibreOffice on the fifteen faces the templates use and JetBrains Mono, 8 to 36pt), and the page sets it the face's ascent below the line's top, matched at a paragraph's middle line. A line Word sets lower than the page by a tenth of a point or more is moved up into the space written above it, written to the twip, and that space is owed below it, so what follows stays where it was; both editors keep a paragraph's space above as written (by its position alone, Helvetica's lines, which the page seats 0.78 of the way down, stood 0.12 to 0.38pt low in Word). A column's later layer, which measures the space to itself from the page, takes back the raise of the line above it. Not a line pair's shared line, which moved would move its other half; not a line in an overlay — a band, a layer stack, a shape container, a canvas, a text box — whose writers measure what follows them from the page; not a line cut to fit, a container's stacked lines or one held to its pictures; not a paragraph the layout moves to a new page, whose space above Word drops there, or breaks over one; and not into the space above a panel's first line that its top border takes. What that space cannot give, and a line Word sets higher than the page — moved down, it would take its room out of the space below it, not known when it is written — is raised or lowered to the page's baseline by `w:position` where the whole difference is half a point or more, a face with a deep descent, as Spectral's is. A list item's lines are not seated yet; a table text cell's are seated by its row's margins (see "Tables"). LibreOffice moves text by `w:position` further than it is raised, by the face's height over its em — Spectral's 1.53 times, Poppins' 1.49, Volkhov's 1.31 (measured) — so a line raised by its position stands where the page sets it in Word only: Spectral's 24pt line, raised 4pt, stood 2.4pt high in LibreOffice. A picture among such text moves with it in Word; LibreOffice keeps a picture on its own baseline, where it stood before. Lines a container stacks tighter than their face — a title's lines a pitch apart — each end halfway between their letters and the next line's, since Word draws an exact line's text on screen only inside the line, and the last layer of a shape container, where its line runs past the foot, ends at the foot or below its letters |
+| Line height | `w:spacing w:lineRule="exact"` on every paragraph, cells and list items included — the height the engine measured, not a multiple Word would measure again against a substituted font. Word has one height for a paragraph's lines: it is the tallest line's text, or, where the page sets lines of different heights further apart than that, the page's mean distance between their baselines, with what a paragraph on one page then falls short of the page owed below it, and what it passes the page by — written at its tallest line, a wrapped line after a large first one, which the page sets at its own height — hung below it, as a line held to its icon is: the space below takes it, and what it cannot take is named (`space above`) (not yet a list item's, or text set over the flow; measured: `CompactMono`'s sidebar, whose skills are two lines a paragraph and each written 0.12pt taller than the page, ended a point low in Word). Lines rounded up to the twip, over enough of them, hang the same way; what rounding takes from a paragraph written at its tallest line is owed below it as well (measured: `ModernInvoice`'s address blocks, six lines of 11.475pt written at 11.45, stood the table under them 0.15pt high in Word and LibreOffice). A tenth of a point or less is left either way: Word sets lines on a grid of its own, 0.12pt apart (measured). In a paragraph of more than one line on one page, the spaces a `bulletOffset` sets before a line, written as an indent, do not count towards that line's text. A paragraph of lines as tall as their text, on one page, opening a table cell takes the gap above its first line from the cell's top padding, no more than steps its lines the page's distance apart — not in a row beside a merged cell or a cell opening with a table, whose margin Word would set the whole row at, nor in a panel. One with no room above it for the gap (opening a column, or a cell padded less) shares the gaps out over all its lines, so its lines stand a little closer than on the page. A paragraph the layout did not measure — one in a composed table cell — is left to the editor, and a line holding a picture above its text is written "at least" that height — except a paragraph of one line of text with room above for its pictures' reach, held exact at the page's height (see "Inline pictures"); in both the paragraph mark is set in the text's size and face, since the mark counts towards the last line's height. A line holding pictures and no text, where they fill the page's line, has its mark and its pictures' runs set at a point instead, so Word makes the line as tall as the pictures and no taller: in the paragraph's own size the mark's depth went under the picture (measured: `SlateOrange`'s skills, a 12.4pt icon beside each label, stood 0.2pt taller each in Word). A smaller picture in a line the page sets at its font's height keeps its mark, and so does a line holding a letter, a break, a tab, a field or a link's text. A paragraph's own line of drawn shapes and no text written at least their reach, which Word grows to the pictures and the transparent frame each keeps around its ink, has that frame taken from the space above the line and above what follows, where it passes the height written: the ink stands where the page draws it, and what follows where the page sets it. Both editors stand the baseline of an exact line four fifths of the way down it whatever the face (measured in Word and LibreOffice on the fifteen faces the templates use and JetBrains Mono, 8 to 36pt), and the page sets it the face's ascent below the line's top, matched at a paragraph's middle line. A line Word sets lower than the page by a tenth of a point or more is moved up into the space written above it, written to the twip, and that space is owed below it, so what follows stays where it was; both editors keep a paragraph's space above as written (by its position alone, Helvetica's lines, which the page seats 0.78 of the way down, stood 0.12 to 0.38pt low in Word). A column's later layer, which measures the space to itself from the page, takes back the raise of the line above it. Not a line pair's shared line, which moved would move its other half; not a line in an overlay — a band, a layer stack, a shape container, a canvas, a text box — whose writers measure what follows them from the page; not a line cut to fit, a container's stacked lines or one held to its pictures; not a paragraph the layout moves to a new page, whose space above Word drops there, or breaks over one; and not into the space above a panel's first line that its top border takes. What that space cannot give, and a line Word sets higher than the page — moved down, it would take its room out of the space below it, not known when it is written — is raised or lowered to the page's baseline by `w:position` where the whole difference is half a point or more, a face with a deep descent, as Spectral's is. A list item's lines are not seated yet; a table text cell's are seated by its row's margins where its row allows (see "Tables"). LibreOffice moves text by `w:position` further than it is raised, by the face's height over its em — Spectral's 1.53 times, Poppins' 1.49, Volkhov's 1.31 (measured) — so a line raised by its position stands where the page sets it in Word only: Spectral's 24pt line, raised 4pt, stood 2.4pt high in LibreOffice. A picture among such text moves with it in Word; LibreOffice keeps a picture on its own baseline, where it stood before. Lines a container stacks tighter than their face — a title's lines a pitch apart — each end halfway between their letters and the next line's, since Word draws an exact line's text on screen only inside the line, and the last layer of a shape container, where its line runs past the foot, ends at the foot or below its letters |
| Table columns | the resolved cell widths as `w:gridCol`, with `w:tblLayout` fixed so Word does not re-fit them |
| Row columns | where the layout placed each child, with the row's gap and padding folded into the neighbouring column and taken back out as that cell's margin — in a painted row's panel the padding is the panel cell's margins instead, and the columns are without it. A column sized to its content (`DocumentRowColumn.auto()`) gets a point more, taken from the row's weight columns so the row keeps its width, for the reason a table's does: the editor's substitute font would wrap it — a table of contents' labels broke mid-word ("Intr" / "o") in LibreOffice without it. A row with no auto column, no weight column, or no stated columns (weights, an even split) is written as placed |
diff --git a/qa/src/test/resources/docx-fidelity/libreoffice-windows-lines.tsv b/qa/src/test/resources/docx-fidelity/libreoffice-windows-lines.tsv
index ef9486330..32a6a1690 100644
--- a/qa/src/test/resources/docx-fidelity/libreoffice-windows-lines.tsv
+++ b/qa/src/test/resources/docx-fidelity/libreoffice-windows-lines.tsv
@@ -1,4 +1,4 @@
-# libreoffice build bce0998afefd on windows — document, line, drift below the page (pt), drift right of the page (pt), letters
+# libreoffice build bf6ef2662401 on windows — document, line, drift below the page (pt), drift right of the page (pt), letters
cv-blue_banner 0:8f1010120ed6 0.02 1.95 jordanrivera
cv-blue_banner 0:8d7a2cca3060 -0.20 0.24 +442055551000|jordan.rivera@exam
cv-blue_banner 0:b944906ed84c -0.20 -0.38 professionalsummary
@@ -1961,36 +1961,36 @@ invoice-consulting 0:d1062d072acd 0.11 -0.62 unitprice
invoice-consulting 0:3ff0b4a2706b 0.13 -0.45 (aud)
invoice-consulting 0:3ff0b4a2706b#1 0.13 -0.42 (aud)
invoice-consulting 0:cf38d95c9c6b 0.11 -0.55 amount
-invoice-consulting 0:b344321f5471 0.81 0.16 1–10may2025
-invoice-consulting 0:a8994a9020c4 0.81 -0.09 10.00
-invoice-consulting 0:4e9682fa850e 0.82 -0.13 hrs
-invoice-consulting 0:4e9682fa850e#1 0.88 -0.13 hrs
-invoice-consulting 0:aa92f0e23a97 0.81 0.18 250.00
-invoice-consulting 0:e48d9b7a2993 0.81 0.31 2,500.00
+invoice-consulting 0:b344321f5471 0.06 0.16 1–10may2025
+invoice-consulting 0:a8994a9020c4 0.06 -0.09 10.00
+invoice-consulting 0:4e9682fa850e 0.07 -0.13 hrs
+invoice-consulting 0:4e9682fa850e#1 0.13 -0.13 hrs
+invoice-consulting 0:aa92f0e23a97 0.06 0.18 250.00
+invoice-consulting 0:e48d9b7a2993 0.06 0.31 2,500.00
invoice-consulting 0:1bcfde966d94 0.54 -0.21 strategicconsultation
invoice-consulting 0:fd3ca268f319 0.57 -0.21 leadershipalignmentworkshops
-invoice-consulting 0:8d93e0c47a8c 0.83 0.16 1–15may2025
-invoice-consulting 0:cf9dcf6da8a8 0.83 -0.07 1.00
-invoice-consulting 0:cf9dcf6da8a8#1 0.85 -0.07 1.00
-invoice-consulting 0:cf9dcf6da8a8#2 0.89 -0.07 1.00
-invoice-consulting 0:97e47b250054 0.83 0.27 3,500.00
-invoice-consulting 0:97e47b250054#1 0.83 0.32 3,500.00
+invoice-consulting 0:8d93e0c47a8c 0.08 0.16 1–15may2025
+invoice-consulting 0:cf9dcf6da8a8 0.08 -0.07 1.00
+invoice-consulting 0:cf9dcf6da8a8#1 0.10 -0.07 1.00
+invoice-consulting 0:cf9dcf6da8a8#2 0.14 -0.07 1.00
+invoice-consulting 0:97e47b250054 0.08 0.27 3,500.00
+invoice-consulting 0:97e47b250054#1 0.08 0.32 3,500.00
invoice-consulting 0:5581aef375ff 0.56 -0.21 market&competitiveanalysis
invoice-consulting 0:957080ea09d9 0.59 -0.21 researchandanalysisreport
-invoice-consulting 0:47102c31f226 0.85 0.19 5–20may2025
-invoice-consulting 0:ec6305055be9 0.85 0.25 4,800.00
-invoice-consulting 0:ec6305055be9#1 0.85 0.29 4,800.00
+invoice-consulting 0:47102c31f226 0.10 0.19 5–20may2025
+invoice-consulting 0:ec6305055be9 0.10 0.25 4,800.00
+invoice-consulting 0:ec6305055be9#1 0.10 0.29 4,800.00
invoice-consulting 0:53dea97cf116 0.58 -0.21 digitalroadmapdevelopment
invoice-consulting 0:acf357e68297 0.61 -0.21 strategyandroadmapcreation
-invoice-consulting 0:c947fb16eab2 0.87 0.21 15–22may2025
-invoice-consulting 0:017144e2271f 0.87 -0.08 6.00
-invoice-consulting 0:be6012a47af0 0.87 0.18 220.00
-invoice-consulting 0:172c0a785bc7 0.87 0.27 1,320.00
+invoice-consulting 0:c947fb16eab2 0.12 0.21 15–22may2025
+invoice-consulting 0:017144e2271f 0.12 -0.08 6.00
+invoice-consulting 0:be6012a47af0 0.12 0.18 220.00
+invoice-consulting 0:172c0a785bc7 0.12 0.27 1,320.00
invoice-consulting 0:fe04037aa850 0.60 -0.21 stakeholderreviewsessions
invoice-consulting 0:4658a1bff292 0.63 -0.21 facilitationanddocumentation
-invoice-consulting 0:86f73207c794 0.89 0.23 20–25may2025
-invoice-consulting 0:55907ef405f6 0.89 0.22 1,880.00
-invoice-consulting 0:55907ef405f6#1 0.89 0.27 1,880.00
+invoice-consulting 0:86f73207c794 0.14 0.23 20–25may2025
+invoice-consulting 0:55907ef405f6 0.14 0.22 1,880.00
+invoice-consulting 0:55907ef405f6#1 0.14 0.27 1,880.00
invoice-consulting 0:f2e12ad6cc9f 0.62 -0.21 presentation&finalreport
invoice-consulting 0:50de6dc61b80 0.65 -0.21 executivepresentationanddelivery
invoice-consulting 0:d6577e95efba -0.16 0.12 subtotal
@@ -2052,96 +2052,96 @@ invoice-consulting_long 0:d1062d072acd 0.11 -0.62 unitprice
invoice-consulting_long 0:3ff0b4a2706b 0.13 -0.45 (aud)
invoice-consulting_long 0:3ff0b4a2706b#1 0.13 -0.42 (aud)
invoice-consulting_long 0:cf38d95c9c6b 0.11 -0.55 amount
-invoice-consulting_long 0:b344321f5471 0.81 0.16 1–10may2025
-invoice-consulting_long 0:b344321f5471#1 0.91 0.16 1–10may2025
-invoice-consulting_long 0:b344321f5471#2 1.01 0.16 1–10may2025
-invoice-consulting_long 0:a8994a9020c4 0.81 -0.09 10.00
-invoice-consulting_long 0:a8994a9020c4#1 0.91 -0.09 10.00
-invoice-consulting_long 0:a8994a9020c4#2 1.01 -0.09 10.00
-invoice-consulting_long 0:4e9682fa850e 0.82 -0.13 hrs
-invoice-consulting_long 0:4e9682fa850e#1 0.88 -0.13 hrs
-invoice-consulting_long 0:4e9682fa850e#2 0.92 -0.13 hrs
-invoice-consulting_long 0:4e9682fa850e#3 0.98 -0.13 hrs
-invoice-consulting_long 0:4e9682fa850e#4 1.02 -0.13 hrs
-invoice-consulting_long 0:4e9682fa850e#5 1.08 -0.13 hrs
-invoice-consulting_long 0:aa92f0e23a97 0.81 0.18 250.00
-invoice-consulting_long 0:aa92f0e23a97#1 0.91 0.18 250.00
-invoice-consulting_long 0:aa92f0e23a97#2 1.01 0.18 250.00
-invoice-consulting_long 0:e48d9b7a2993 0.81 0.31 2,500.00
-invoice-consulting_long 0:e48d9b7a2993#1 0.91 0.31 2,500.00
-invoice-consulting_long 0:e48d9b7a2993#2 1.01 0.31 2,500.00
+invoice-consulting_long 0:b344321f5471 0.06 0.16 1–10may2025
+invoice-consulting_long 0:b344321f5471#1 0.16 0.16 1–10may2025
+invoice-consulting_long 0:b344321f5471#2 0.26 0.16 1–10may2025
+invoice-consulting_long 0:a8994a9020c4 0.06 -0.09 10.00
+invoice-consulting_long 0:a8994a9020c4#1 0.16 -0.09 10.00
+invoice-consulting_long 0:a8994a9020c4#2 0.26 -0.09 10.00
+invoice-consulting_long 0:4e9682fa850e 0.07 -0.13 hrs
+invoice-consulting_long 0:4e9682fa850e#1 0.13 -0.13 hrs
+invoice-consulting_long 0:4e9682fa850e#2 0.17 -0.13 hrs
+invoice-consulting_long 0:4e9682fa850e#3 0.23 -0.13 hrs
+invoice-consulting_long 0:4e9682fa850e#4 0.27 -0.13 hrs
+invoice-consulting_long 0:4e9682fa850e#5 0.33 -0.13 hrs
+invoice-consulting_long 0:aa92f0e23a97 0.06 0.18 250.00
+invoice-consulting_long 0:aa92f0e23a97#1 0.16 0.18 250.00
+invoice-consulting_long 0:aa92f0e23a97#2 0.26 0.18 250.00
+invoice-consulting_long 0:e48d9b7a2993 0.06 0.31 2,500.00
+invoice-consulting_long 0:e48d9b7a2993#1 0.16 0.31 2,500.00
+invoice-consulting_long 0:e48d9b7a2993#2 0.26 0.31 2,500.00
invoice-consulting_long 0:1bcfde966d94 0.54 -0.21 strategicconsultation
invoice-consulting_long 0:1bcfde966d94#1 0.64 -0.21 strategicconsultation
invoice-consulting_long 0:1bcfde966d94#2 0.74 -0.21 strategicconsultation
invoice-consulting_long 0:fd3ca268f319 0.57 -0.21 leadershipalignmentworkshops
invoice-consulting_long 0:fd3ca268f319#1 0.67 -0.21 leadershipalignmentworkshops
invoice-consulting_long 0:fd3ca268f319#2 0.77 -0.21 leadershipalignmentworkshops
-invoice-consulting_long 0:8d93e0c47a8c 0.83 0.16 1–15may2025
-invoice-consulting_long 0:8d93e0c47a8c#1 0.93 0.16 1–15may2025
-invoice-consulting_long 0:8d93e0c47a8c#2 1.03 0.16 1–15may2025
-invoice-consulting_long 0:cf9dcf6da8a8 0.83 -0.07 1.00
-invoice-consulting_long 0:cf9dcf6da8a8#1 0.85 -0.07 1.00
-invoice-consulting_long 0:cf9dcf6da8a8#2 0.89 -0.07 1.00
-invoice-consulting_long 0:cf9dcf6da8a8#3 0.93 -0.07 1.00
-invoice-consulting_long 0:cf9dcf6da8a8#4 0.95 -0.07 1.00
-invoice-consulting_long 0:cf9dcf6da8a8#5 0.99 -0.07 1.00
-invoice-consulting_long 0:cf9dcf6da8a8#6 1.03 -0.07 1.00
-invoice-consulting_long 0:cf9dcf6da8a8#7 1.05 -0.07 1.00
-invoice-consulting_long 0:cf9dcf6da8a8#8 1.09 -0.07 1.00
-invoice-consulting_long 0:97e47b250054 0.83 0.27 3,500.00
-invoice-consulting_long 0:97e47b250054#1 0.83 0.32 3,500.00
-invoice-consulting_long 0:97e47b250054#2 0.93 0.27 3,500.00
-invoice-consulting_long 0:97e47b250054#3 0.93 0.32 3,500.00
-invoice-consulting_long 0:97e47b250054#4 1.03 0.27 3,500.00
-invoice-consulting_long 0:97e47b250054#5 1.03 0.32 3,500.00
+invoice-consulting_long 0:8d93e0c47a8c 0.08 0.16 1–15may2025
+invoice-consulting_long 0:8d93e0c47a8c#1 0.18 0.16 1–15may2025
+invoice-consulting_long 0:8d93e0c47a8c#2 0.28 0.16 1–15may2025
+invoice-consulting_long 0:cf9dcf6da8a8 0.08 -0.07 1.00
+invoice-consulting_long 0:cf9dcf6da8a8#1 0.10 -0.07 1.00
+invoice-consulting_long 0:cf9dcf6da8a8#2 0.14 -0.07 1.00
+invoice-consulting_long 0:cf9dcf6da8a8#3 0.18 -0.07 1.00
+invoice-consulting_long 0:cf9dcf6da8a8#4 0.20 -0.07 1.00
+invoice-consulting_long 0:cf9dcf6da8a8#5 0.24 -0.07 1.00
+invoice-consulting_long 0:cf9dcf6da8a8#6 0.28 -0.07 1.00
+invoice-consulting_long 0:cf9dcf6da8a8#7 0.30 -0.07 1.00
+invoice-consulting_long 0:cf9dcf6da8a8#8 0.34 -0.07 1.00
+invoice-consulting_long 0:97e47b250054 0.08 0.27 3,500.00
+invoice-consulting_long 0:97e47b250054#1 0.08 0.32 3,500.00
+invoice-consulting_long 0:97e47b250054#2 0.18 0.27 3,500.00
+invoice-consulting_long 0:97e47b250054#3 0.18 0.32 3,500.00
+invoice-consulting_long 0:97e47b250054#4 0.28 0.27 3,500.00
+invoice-consulting_long 0:97e47b250054#5 0.28 0.32 3,500.00
invoice-consulting_long 0:5581aef375ff 0.56 -0.21 market&competitiveanalysis
invoice-consulting_long 0:5581aef375ff#1 0.66 -0.21 market&competitiveanalysis
invoice-consulting_long 0:5581aef375ff#2 0.76 -0.21 market&competitiveanalysis
invoice-consulting_long 0:957080ea09d9 0.59 -0.21 researchandanalysisreport
invoice-consulting_long 0:957080ea09d9#1 0.69 -0.21 researchandanalysisreport
invoice-consulting_long 0:957080ea09d9#2 0.79 -0.21 researchandanalysisreport
-invoice-consulting_long 0:47102c31f226 0.85 0.19 5–20may2025
-invoice-consulting_long 0:47102c31f226#1 0.95 0.19 5–20may2025
-invoice-consulting_long 0:47102c31f226#2 1.05 0.19 5–20may2025
-invoice-consulting_long 0:ec6305055be9 0.85 0.25 4,800.00
-invoice-consulting_long 0:ec6305055be9#1 0.85 0.29 4,800.00
-invoice-consulting_long 0:ec6305055be9#2 0.95 0.25 4,800.00
-invoice-consulting_long 0:ec6305055be9#3 0.95 0.29 4,800.00
-invoice-consulting_long 0:ec6305055be9#4 1.05 0.25 4,800.00
-invoice-consulting_long 0:ec6305055be9#5 1.05 0.29 4,800.00
+invoice-consulting_long 0:47102c31f226 0.10 0.19 5–20may2025
+invoice-consulting_long 0:47102c31f226#1 0.20 0.19 5–20may2025
+invoice-consulting_long 0:47102c31f226#2 0.30 0.19 5–20may2025
+invoice-consulting_long 0:ec6305055be9 0.10 0.25 4,800.00
+invoice-consulting_long 0:ec6305055be9#1 0.10 0.29 4,800.00
+invoice-consulting_long 0:ec6305055be9#2 0.20 0.25 4,800.00
+invoice-consulting_long 0:ec6305055be9#3 0.20 0.29 4,800.00
+invoice-consulting_long 0:ec6305055be9#4 0.30 0.25 4,800.00
+invoice-consulting_long 0:ec6305055be9#5 0.30 0.29 4,800.00
invoice-consulting_long 0:53dea97cf116 0.58 -0.21 digitalroadmapdevelopment
invoice-consulting_long 0:53dea97cf116#1 0.68 -0.21 digitalroadmapdevelopment
invoice-consulting_long 0:53dea97cf116#2 0.78 -0.21 digitalroadmapdevelopment
invoice-consulting_long 0:acf357e68297 0.61 -0.21 strategyandroadmapcreation
invoice-consulting_long 0:acf357e68297#1 0.71 -0.21 strategyandroadmapcreation
invoice-consulting_long 0:acf357e68297#2 0.81 -0.21 strategyandroadmapcreation
-invoice-consulting_long 0:c947fb16eab2 0.87 0.21 15–22may2025
-invoice-consulting_long 0:c947fb16eab2#1 0.97 0.21 15–22may2025
-invoice-consulting_long 0:c947fb16eab2#2 1.07 0.21 15–22may2025
-invoice-consulting_long 0:017144e2271f 0.87 -0.08 6.00
-invoice-consulting_long 0:017144e2271f#1 0.97 -0.08 6.00
-invoice-consulting_long 0:017144e2271f#2 1.07 -0.08 6.00
-invoice-consulting_long 0:be6012a47af0 0.87 0.18 220.00
-invoice-consulting_long 0:be6012a47af0#1 0.97 0.18 220.00
-invoice-consulting_long 0:be6012a47af0#2 1.07 0.18 220.00
-invoice-consulting_long 0:172c0a785bc7 0.87 0.27 1,320.00
-invoice-consulting_long 0:172c0a785bc7#1 0.97 0.27 1,320.00
-invoice-consulting_long 0:172c0a785bc7#2 1.07 0.27 1,320.00
+invoice-consulting_long 0:c947fb16eab2 0.12 0.21 15–22may2025
+invoice-consulting_long 0:c947fb16eab2#1 0.22 0.21 15–22may2025
+invoice-consulting_long 0:c947fb16eab2#2 0.32 0.21 15–22may2025
+invoice-consulting_long 0:017144e2271f 0.12 -0.08 6.00
+invoice-consulting_long 0:017144e2271f#1 0.22 -0.08 6.00
+invoice-consulting_long 0:017144e2271f#2 0.32 -0.08 6.00
+invoice-consulting_long 0:be6012a47af0 0.12 0.18 220.00
+invoice-consulting_long 0:be6012a47af0#1 0.22 0.18 220.00
+invoice-consulting_long 0:be6012a47af0#2 0.32 0.18 220.00
+invoice-consulting_long 0:172c0a785bc7 0.12 0.27 1,320.00
+invoice-consulting_long 0:172c0a785bc7#1 0.22 0.27 1,320.00
+invoice-consulting_long 0:172c0a785bc7#2 0.32 0.27 1,320.00
invoice-consulting_long 0:fe04037aa850 0.60 -0.21 stakeholderreviewsessions
invoice-consulting_long 0:fe04037aa850#1 0.70 -0.21 stakeholderreviewsessions
invoice-consulting_long 0:fe04037aa850#2 0.80 -0.21 stakeholderreviewsessions
invoice-consulting_long 0:4658a1bff292 0.63 -0.21 facilitationanddocumentation
invoice-consulting_long 0:4658a1bff292#1 0.73 -0.21 facilitationanddocumentation
invoice-consulting_long 0:4658a1bff292#2 0.83 -0.21 facilitationanddocumentation
-invoice-consulting_long 0:86f73207c794 0.89 0.23 20–25may2025
-invoice-consulting_long 0:86f73207c794#1 0.99 0.23 20–25may2025
-invoice-consulting_long 0:86f73207c794#2 1.09 0.23 20–25may2025
-invoice-consulting_long 0:55907ef405f6 0.89 0.22 1,880.00
-invoice-consulting_long 0:55907ef405f6#1 0.89 0.27 1,880.00
-invoice-consulting_long 0:55907ef405f6#2 0.99 0.22 1,880.00
-invoice-consulting_long 0:55907ef405f6#3 0.99 0.27 1,880.00
-invoice-consulting_long 0:55907ef405f6#4 1.09 0.22 1,880.00
-invoice-consulting_long 0:55907ef405f6#5 1.09 0.27 1,880.00
+invoice-consulting_long 0:86f73207c794 0.14 0.23 20–25may2025
+invoice-consulting_long 0:86f73207c794#1 0.24 0.23 20–25may2025
+invoice-consulting_long 0:86f73207c794#2 0.34 0.23 20–25may2025
+invoice-consulting_long 0:55907ef405f6 0.14 0.22 1,880.00
+invoice-consulting_long 0:55907ef405f6#1 0.14 0.27 1,880.00
+invoice-consulting_long 0:55907ef405f6#2 0.24 0.22 1,880.00
+invoice-consulting_long 0:55907ef405f6#3 0.24 0.27 1,880.00
+invoice-consulting_long 0:55907ef405f6#4 0.34 0.22 1,880.00
+invoice-consulting_long 0:55907ef405f6#5 0.34 0.27 1,880.00
invoice-consulting_long 0:f2e12ad6cc9f 0.62 -0.21 presentation&finalreport
invoice-consulting_long 0:f2e12ad6cc9f#1 0.72 -0.21 presentation&finalreport
invoice-consulting_long 0:f2e12ad6cc9f#2 0.82 -0.21 presentation&finalreport
@@ -2157,73 +2157,73 @@ invoice-consulting_long 1:d1062d072acd -0.08 -0.62 unitprice
invoice-consulting_long 1:3ff0b4a2706b -0.06 -0.45 (aud)
invoice-consulting_long 1:3ff0b4a2706b#1 -0.06 -0.42 (aud)
invoice-consulting_long 1:cf38d95c9c6b -0.08 -0.55 amount
-invoice-consulting_long 1:b344321f5471 0.52 0.16 1–10may2025
-invoice-consulting_long 1:b344321f5471#1 0.62 0.16 1–10may2025
-invoice-consulting_long 1:b344321f5471#2 0.72 0.16 1–10may2025
-invoice-consulting_long 1:a8994a9020c4 0.52 -0.09 10.00
-invoice-consulting_long 1:a8994a9020c4#1 0.62 -0.09 10.00
-invoice-consulting_long 1:a8994a9020c4#2 0.72 -0.09 10.00
-invoice-consulting_long 1:4e9682fa850e 0.53 -0.13 hrs
-invoice-consulting_long 1:4e9682fa850e#1 0.59 -0.13 hrs
-invoice-consulting_long 1:4e9682fa850e#2 0.63 -0.13 hrs
-invoice-consulting_long 1:4e9682fa850e#3 0.69 -0.13 hrs
-invoice-consulting_long 1:4e9682fa850e#4 0.73 -0.13 hrs
-invoice-consulting_long 1:aa92f0e23a97 0.52 0.18 250.00
-invoice-consulting_long 1:aa92f0e23a97#1 0.62 0.18 250.00
-invoice-consulting_long 1:aa92f0e23a97#2 0.72 0.18 250.00
-invoice-consulting_long 1:e48d9b7a2993 0.52 0.31 2,500.00
-invoice-consulting_long 1:e48d9b7a2993#1 0.62 0.31 2,500.00
-invoice-consulting_long 1:e48d9b7a2993#2 0.72 0.31 2,500.00
+invoice-consulting_long 1:b344321f5471 -0.23 0.16 1–10may2025
+invoice-consulting_long 1:b344321f5471#1 -0.13 0.16 1–10may2025
+invoice-consulting_long 1:b344321f5471#2 -0.03 0.16 1–10may2025
+invoice-consulting_long 1:a8994a9020c4 -0.23 -0.09 10.00
+invoice-consulting_long 1:a8994a9020c4#1 -0.13 -0.09 10.00
+invoice-consulting_long 1:a8994a9020c4#2 -0.03 -0.09 10.00
+invoice-consulting_long 1:4e9682fa850e -0.22 -0.13 hrs
+invoice-consulting_long 1:4e9682fa850e#1 -0.16 -0.13 hrs
+invoice-consulting_long 1:4e9682fa850e#2 -0.12 -0.13 hrs
+invoice-consulting_long 1:4e9682fa850e#3 -0.06 -0.13 hrs
+invoice-consulting_long 1:4e9682fa850e#4 -0.02 -0.13 hrs
+invoice-consulting_long 1:aa92f0e23a97 -0.23 0.18 250.00
+invoice-consulting_long 1:aa92f0e23a97#1 -0.13 0.18 250.00
+invoice-consulting_long 1:aa92f0e23a97#2 -0.03 0.18 250.00
+invoice-consulting_long 1:e48d9b7a2993 -0.23 0.31 2,500.00
+invoice-consulting_long 1:e48d9b7a2993#1 -0.13 0.31 2,500.00
+invoice-consulting_long 1:e48d9b7a2993#2 -0.03 0.31 2,500.00
invoice-consulting_long 1:1bcfde966d94 0.25 -0.21 strategicconsultation
invoice-consulting_long 1:1bcfde966d94#1 0.35 -0.21 strategicconsultation
invoice-consulting_long 1:1bcfde966d94#2 0.45 -0.21 strategicconsultation
invoice-consulting_long 1:fd3ca268f319 0.28 -0.21 leadershipalignmentworkshops
invoice-consulting_long 1:fd3ca268f319#1 0.38 -0.21 leadershipalignmentworkshops
invoice-consulting_long 1:fd3ca268f319#2 0.48 -0.21 leadershipalignmentworkshops
-invoice-consulting_long 1:8d93e0c47a8c 0.54 0.16 1–15may2025
-invoice-consulting_long 1:8d93e0c47a8c#1 0.64 0.16 1–15may2025
-invoice-consulting_long 1:cf9dcf6da8a8 0.54 -0.07 1.00
-invoice-consulting_long 1:cf9dcf6da8a8#1 0.56 -0.07 1.00
-invoice-consulting_long 1:cf9dcf6da8a8#2 0.60 -0.07 1.00
-invoice-consulting_long 1:cf9dcf6da8a8#3 0.64 -0.07 1.00
-invoice-consulting_long 1:cf9dcf6da8a8#4 0.66 -0.07 1.00
-invoice-consulting_long 1:cf9dcf6da8a8#5 0.70 -0.07 1.00
-invoice-consulting_long 1:97e47b250054 0.54 0.27 3,500.00
-invoice-consulting_long 1:97e47b250054#1 0.54 0.32 3,500.00
-invoice-consulting_long 1:97e47b250054#2 0.64 0.27 3,500.00
-invoice-consulting_long 1:97e47b250054#3 0.64 0.32 3,500.00
+invoice-consulting_long 1:8d93e0c47a8c -0.21 0.16 1–15may2025
+invoice-consulting_long 1:8d93e0c47a8c#1 -0.11 0.16 1–15may2025
+invoice-consulting_long 1:cf9dcf6da8a8 -0.21 -0.07 1.00
+invoice-consulting_long 1:cf9dcf6da8a8#1 -0.19 -0.07 1.00
+invoice-consulting_long 1:cf9dcf6da8a8#2 -0.15 -0.07 1.00
+invoice-consulting_long 1:cf9dcf6da8a8#3 -0.11 -0.07 1.00
+invoice-consulting_long 1:cf9dcf6da8a8#4 -0.09 -0.07 1.00
+invoice-consulting_long 1:cf9dcf6da8a8#5 -0.05 -0.07 1.00
+invoice-consulting_long 1:97e47b250054 -0.21 0.27 3,500.00
+invoice-consulting_long 1:97e47b250054#1 -0.21 0.32 3,500.00
+invoice-consulting_long 1:97e47b250054#2 -0.11 0.27 3,500.00
+invoice-consulting_long 1:97e47b250054#3 -0.11 0.32 3,500.00
invoice-consulting_long 1:5581aef375ff 0.27 -0.21 market&competitiveanalysis
invoice-consulting_long 1:5581aef375ff#1 0.37 -0.21 market&competitiveanalysis
invoice-consulting_long 1:957080ea09d9 0.30 -0.21 researchandanalysisreport
invoice-consulting_long 1:957080ea09d9#1 0.40 -0.21 researchandanalysisreport
-invoice-consulting_long 1:47102c31f226 0.56 0.19 5–20may2025
-invoice-consulting_long 1:47102c31f226#1 0.66 0.19 5–20may2025
-invoice-consulting_long 1:ec6305055be9 0.56 0.25 4,800.00
-invoice-consulting_long 1:ec6305055be9#1 0.56 0.29 4,800.00
-invoice-consulting_long 1:ec6305055be9#2 0.66 0.25 4,800.00
-invoice-consulting_long 1:ec6305055be9#3 0.66 0.29 4,800.00
+invoice-consulting_long 1:47102c31f226 -0.19 0.19 5–20may2025
+invoice-consulting_long 1:47102c31f226#1 -0.09 0.19 5–20may2025
+invoice-consulting_long 1:ec6305055be9 -0.19 0.25 4,800.00
+invoice-consulting_long 1:ec6305055be9#1 -0.19 0.29 4,800.00
+invoice-consulting_long 1:ec6305055be9#2 -0.09 0.25 4,800.00
+invoice-consulting_long 1:ec6305055be9#3 -0.09 0.29 4,800.00
invoice-consulting_long 1:53dea97cf116 0.29 -0.21 digitalroadmapdevelopment
invoice-consulting_long 1:53dea97cf116#1 0.39 -0.21 digitalroadmapdevelopment
invoice-consulting_long 1:acf357e68297 0.32 -0.21 strategyandroadmapcreation
invoice-consulting_long 1:acf357e68297#1 0.42 -0.21 strategyandroadmapcreation
-invoice-consulting_long 1:c947fb16eab2 0.58 0.21 15–22may2025
-invoice-consulting_long 1:c947fb16eab2#1 0.68 0.21 15–22may2025
-invoice-consulting_long 1:017144e2271f 0.58 -0.08 6.00
-invoice-consulting_long 1:017144e2271f#1 0.68 -0.08 6.00
-invoice-consulting_long 1:be6012a47af0 0.58 0.18 220.00
-invoice-consulting_long 1:be6012a47af0#1 0.68 0.18 220.00
-invoice-consulting_long 1:172c0a785bc7 0.58 0.27 1,320.00
-invoice-consulting_long 1:172c0a785bc7#1 0.68 0.27 1,320.00
+invoice-consulting_long 1:c947fb16eab2 -0.17 0.21 15–22may2025
+invoice-consulting_long 1:c947fb16eab2#1 -0.07 0.21 15–22may2025
+invoice-consulting_long 1:017144e2271f -0.17 -0.08 6.00
+invoice-consulting_long 1:017144e2271f#1 -0.07 -0.08 6.00
+invoice-consulting_long 1:be6012a47af0 -0.17 0.18 220.00
+invoice-consulting_long 1:be6012a47af0#1 -0.07 0.18 220.00
+invoice-consulting_long 1:172c0a785bc7 -0.17 0.27 1,320.00
+invoice-consulting_long 1:172c0a785bc7#1 -0.07 0.27 1,320.00
invoice-consulting_long 1:fe04037aa850 0.31 -0.21 stakeholderreviewsessions
invoice-consulting_long 1:fe04037aa850#1 0.41 -0.21 stakeholderreviewsessions
invoice-consulting_long 1:4658a1bff292 0.34 -0.21 facilitationanddocumentation
invoice-consulting_long 1:4658a1bff292#1 0.44 -0.21 facilitationanddocumentation
-invoice-consulting_long 1:86f73207c794 0.60 0.23 20–25may2025
-invoice-consulting_long 1:86f73207c794#1 0.70 0.23 20–25may2025
-invoice-consulting_long 1:55907ef405f6 0.60 0.22 1,880.00
-invoice-consulting_long 1:55907ef405f6#1 0.60 0.27 1,880.00
-invoice-consulting_long 1:55907ef405f6#2 0.70 0.22 1,880.00
-invoice-consulting_long 1:55907ef405f6#3 0.70 0.27 1,880.00
+invoice-consulting_long 1:86f73207c794 -0.15 0.23 20–25may2025
+invoice-consulting_long 1:86f73207c794#1 -0.05 0.23 20–25may2025
+invoice-consulting_long 1:55907ef405f6 -0.15 0.22 1,880.00
+invoice-consulting_long 1:55907ef405f6#1 -0.15 0.27 1,880.00
+invoice-consulting_long 1:55907ef405f6#2 -0.05 0.22 1,880.00
+invoice-consulting_long 1:55907ef405f6#3 -0.05 0.27 1,880.00
invoice-consulting_long 1:f2e12ad6cc9f 0.33 -0.21 presentation&finalreport
invoice-consulting_long 1:f2e12ad6cc9f#1 0.43 -0.21 presentation&finalreport
invoice-consulting_long 1:50de6dc61b80 0.36 -0.21 executivepresentationanddelivery
@@ -3012,11 +3012,11 @@ invoice-obsidian 0:eafa82a0eadf 0.46 0.68 £146.00
invoice-obsidian 0:57a66d21eb1b 0.38 0.11 totaldue
invoice-obsidian 0:ad3ba615a506 0.36 -0.54 £876.00
invoice-obsidian 0:ab5aa97074c4 0.57 0.08 notes
-invoice-obsidian 0:0956d8d0441d 1.19 0.08 thankyouforchoosingkestrelbusine
-invoice-obsidian 0:0b4d6f0e8783 1.19 0.08 thisinvoicecoversservicesandfeat
-invoice-obsidian 0:02e483554647 1.20 0.08 toyourbusinessasofthedateofissue
-invoice-obsidian 0:b439106fc5a1 1.21 0.08 ifyouhaveanyquestionsaboutthisin
-invoice-obsidian 0:877ac656a147 1.22 0.08 pleasecontactusatar@kestrel.exam
+invoice-obsidian 0:0956d8d0441d 0.94 0.08 thankyouforchoosingkestrelbusine
+invoice-obsidian 0:0b4d6f0e8783 0.94 0.08 thisinvoicecoversservicesandfeat
+invoice-obsidian 0:02e483554647 0.95 0.08 toyourbusinessasofthedateofissue
+invoice-obsidian 0:b439106fc5a1 0.96 0.08 ifyouhaveanyquestionsaboutthisin
+invoice-obsidian 0:877ac656a147 0.97 0.08 pleasecontactusatar@kestrel.exam
invoice-obsidian 0:3c7ade679fdf 0.57 0.09 paymentdetails
invoice-obsidian 0:473fbeedb47c 0.05 0.11 pleasepaybybanktransfer
invoice-obsidian 0:59f2b74175d7 0.06 0.11 totheaccountbelow.
@@ -3737,9 +3737,9 @@ proposal-indigo 0:f99fb5990e3f 0.16 0.03 proposalfor
proposal-indigo 0:460ebeabf0d7 0.16 0.03 financialinfrastructure
proposal-indigo 0:e0b894e9070f 0.17 0.03 &embeddedfinance
proposal-indigo 0:76f9df77e8af 0.18 0.03 partnership
-proposal-indigo 0:f33b9e206de3 1.06 0.03 empoweringbrightfutureltd.withmo
-proposal-indigo 0:16a14b235896 1.06 0.03 infrastructure,globalcapabilitie
-proposal-indigo 0:2fdd6f092df5 1.05 0.03 experienceforyourcustomers.
+proposal-indigo 0:f33b9e206de3 0.81 0.03 empoweringbrightfutureltd.withmo
+proposal-indigo 0:16a14b235896 0.81 0.03 infrastructure,globalcapabilitie
+proposal-indigo 0:2fdd6f092df5 0.80 0.03 experienceforyourcustomers.
proposal-indigo 0:0e87632cd46b 0.25 0.03 date
proposal-indigo 0:dc9696f61d36 0.24 0.03 27may2026
proposal-indigo 0:621f581e97b4 0.25 -0.04 proposalid
@@ -3749,8 +3749,8 @@ proposal-indigo 0:93059e9a1c07 0.24 0.03 26june2026
proposal-indigo 0:8d6867ab3a4c 0.25 0.01 preparedby
proposal-indigo 0:50910841c2da 0.24 0.01 kestrelbusinessteam
proposal-indigo 0:69cca54632df 0.28 0.08 aboutkestrelbusiness
-proposal-indigo 0:81a3de6caa05 0.26 0.08 kestrelbusinessprovidesmodernfin
-proposal-indigo 0:a999713d90ce 0.26 0.08 forward-thinkingcompanies.frommu
+proposal-indigo 0:81a3de6caa05 0.16 0.08 kestrelbusinessprovidesmodernfin
+proposal-indigo 0:a999713d90ce 0.16 0.08 forward-thinkingcompanies.frommu
proposal-indigo 0:8001c2743965 0.25 0.08 global
proposal-indigo 0:f469802a3144 0.27 0.08 scale
proposal-indigo 0:774cdf08f6a8 0.25 0.06 modern
@@ -3760,9 +3760,9 @@ proposal-indigo 0:b67c263c0379 0.27 0.03 compliant
proposal-indigo 0:88fa0d759f84 0.25 0.01 developer
proposal-indigo 0:962cba9fd476 0.27 0.01 firstapis
proposal-indigo 0:4f30d3328d6f 0.26 0.08 projectoverview
-proposal-indigo 0:a73369734180 0.26 0.08 thisproposaloutlinesatailoredfin
-proposal-indigo 0:19a7c085cb24 0.27 0.08 supportbrightfutureltd.inenablin
-proposal-indigo 0:ff5888ea18e0 0.27 0.08 financialservicesforyourbusiness
+proposal-indigo 0:a73369734180 0.16 0.08 thisproposaloutlinesatailoredfin
+proposal-indigo 0:19a7c085cb24 0.17 0.08 supportbrightfutureltd.inenablin
+proposal-indigo 0:ff5888ea18e0 0.17 0.08 financialservicesforyourbusiness
proposal-indigo 0:2855076f724f 0.28 0.07 multi-currencybusinessaccounts
proposal-indigo 0:4e36c64ccf3a 0.29 0.07 hold,send,receivein30+currencies
proposal-indigo 0:17f85ac3692b 0.37 0.07 corporatecards&expenses
diff --git a/qa/src/test/resources/docx-fidelity/libreoffice-windows.tsv b/qa/src/test/resources/docx-fidelity/libreoffice-windows.tsv
index b62403d85..a6c34429f 100644
--- a/qa/src/test/resources/docx-fidelity/libreoffice-windows.tsv
+++ b/qa/src/test/resources/docx-fidelity/libreoffice-windows.tsv
@@ -1,4 +1,4 @@
-# libreoffice build bce0998afefd on windows
+# libreoffice build bf6ef2662401 on windows
document engine_pages editor_pages lines matched median p90 over2
cv-blue_banner 2 2 54 52 0.13 0.45 0
cv-boxed_sections 2 2 58 58 0.23 0.36 0
@@ -28,15 +28,15 @@ cv-timeline_minimal 2 2 89 87 0.45 0.49 0
cv-violet_grid 1 1 80 78 0.26 0.54 0
invoice-classic 1 1 56 56 0.07 0.15 0
invoice-classic_long 2 2 166 166 0.05 0.10 0
-invoice-consulting 1 1 92 92 0.53 0.96 0
-invoice-consulting_long 2 2 236 236 0.64 0.99 0
+invoice-consulting 1 1 92 92 0.18 0.96 0
+invoice-consulting_long 2 2 236 236 0.22 0.73 0
invoice-luma_studio 1 1 97 97 0.12 0.46 2
invoice-luma_studio_long 3 3 192 192 0.20 0.41 2
invoice-merchant 1 2 94 90 0.07 0.21 0
invoice-metered 1 1 99 99 0.05 0.68 0
invoice-modern 1 1 54 54 0.13 0.20 0
invoice-modern_long 2 2 162 162 0.12 0.15 0
-invoice-obsidian 1 1 81 81 0.34 1.19 0
+invoice-obsidian 1 1 81 81 0.34 0.94 0
invoice-payments 1 1 104 104 0.09 0.23 0
invoice-platform 1 1 111 111 0.27 0.43 0
invoice-subscription 1 1 81 81 0.34 0.51 0
@@ -57,7 +57,7 @@ letter-panel 1 1 13 13 0.17 0.25 0
letter-sidebar_portrait 1 1 12 12 0.41 0.49 0
letter-timeline_minimal 1 1 15 15 0.33 0.53 0
proposal-editorial 2 2 132 129 44.46 45.38 72
-proposal-indigo 1 1 72 70 0.27 0.65 0
+proposal-indigo 1 1 72 70 0.26 0.65 0
proposal-modern 1 1 44 44 0.10 0.20 0
proposal-northline 2 2 132 132 0.27 0.62 0
receipt-modern 1 1 57 57 0.09 0.29 0
diff --git a/qa/src/test/resources/docx-fidelity/word-windows-lines.tsv b/qa/src/test/resources/docx-fidelity/word-windows-lines.tsv
index af18a367f..231ac1fb5 100644
--- a/qa/src/test/resources/docx-fidelity/word-windows-lines.tsv
+++ b/qa/src/test/resources/docx-fidelity/word-windows-lines.tsv
@@ -2059,36 +2059,36 @@ invoice-consulting 0:d1062d072acd 0.15 -0.32 unitprice
invoice-consulting 0:3ff0b4a2706b 0.25 -0.16 (aud)
invoice-consulting 0:3ff0b4a2706b#1 0.25 -0.11 (aud)
invoice-consulting 0:cf38d95c9c6b 0.15 -0.24 amount
-invoice-consulting 0:b344321f5471 0.72 0.40 1–10may2025
-invoice-consulting 0:a8994a9020c4 0.74 0.06 10.00
-invoice-consulting 0:4e9682fa850e 0.71 0.08 hrs
-invoice-consulting 0:4e9682fa850e#1 0.86 0.08 hrs
-invoice-consulting 0:aa92f0e23a97 0.72 0.51 250.00
-invoice-consulting 0:e48d9b7a2993 0.72 0.50 2,500.00
+invoice-consulting 0:b344321f5471 0.24 0.40 1–10may2025
+invoice-consulting 0:a8994a9020c4 0.26 0.06 10.00
+invoice-consulting 0:4e9682fa850e 0.23 0.08 hrs
+invoice-consulting 0:4e9682fa850e#1 0.38 0.08 hrs
+invoice-consulting 0:aa92f0e23a97 0.24 0.51 250.00
+invoice-consulting 0:e48d9b7a2993 0.24 0.50 2,500.00
invoice-consulting 0:1bcfde966d94 0.47 0.09 strategicconsultation
invoice-consulting 0:fd3ca268f319 0.55 0.09 leadershipalignmentworkshops
-invoice-consulting 0:8d93e0c47a8c 0.73 0.40 1–15may2025
-invoice-consulting 0:cf9dcf6da8a8 0.75 0.08 1.00
-invoice-consulting 0:cf9dcf6da8a8#1 0.76 0.08 1.00
-invoice-consulting 0:cf9dcf6da8a8#2 0.92 0.08 1.00
-invoice-consulting 0:97e47b250054 0.73 0.54 3,500.00
-invoice-consulting 0:97e47b250054#1 0.73 0.49 3,500.00
+invoice-consulting 0:8d93e0c47a8c 0.25 0.40 1–15may2025
+invoice-consulting 0:cf9dcf6da8a8 0.27 0.08 1.00
+invoice-consulting 0:cf9dcf6da8a8#1 0.28 0.08 1.00
+invoice-consulting 0:cf9dcf6da8a8#2 0.44 0.08 1.00
+invoice-consulting 0:97e47b250054 0.25 0.54 3,500.00
+invoice-consulting 0:97e47b250054#1 0.25 0.49 3,500.00
invoice-consulting 0:5581aef375ff 0.48 0.09 market&competitiveanalysis
invoice-consulting 0:957080ea09d9 0.56 0.09 researchandanalysisreport
-invoice-consulting 0:47102c31f226 0.74 0.37 5–20may2025
-invoice-consulting 0:ec6305055be9 0.74 0.63 4,800.00
-invoice-consulting 0:ec6305055be9#1 0.74 0.57 4,800.00
+invoice-consulting 0:47102c31f226 0.26 0.37 5–20may2025
+invoice-consulting 0:ec6305055be9 0.26 0.63 4,800.00
+invoice-consulting 0:ec6305055be9#1 0.26 0.57 4,800.00
invoice-consulting 0:53dea97cf116 0.49 0.09 digitalroadmapdevelopment
invoice-consulting 0:acf357e68297 0.57 0.09 strategyandroadmapcreation
-invoice-consulting 0:c947fb16eab2 0.87 0.43 15–22may2025
-invoice-consulting 0:017144e2271f 0.77 0.07 6.00
-invoice-consulting 0:be6012a47af0 0.87 0.47 220.00
-invoice-consulting 0:172c0a785bc7 0.87 0.50 1,320.00
+invoice-consulting 0:c947fb16eab2 0.39 0.43 15–22may2025
+invoice-consulting 0:017144e2271f 0.29 0.07 6.00
+invoice-consulting 0:be6012a47af0 0.39 0.47 220.00
+invoice-consulting 0:172c0a785bc7 0.39 0.50 1,320.00
invoice-consulting 0:fe04037aa850 0.62 0.09 stakeholderreviewsessions
invoice-consulting 0:4658a1bff292 0.58 0.09 facilitationanddocumentation
-invoice-consulting 0:86f73207c794 0.90 0.40 20–25may2025
-invoice-consulting 0:55907ef405f6 0.90 0.58 1,880.00
-invoice-consulting 0:55907ef405f6#1 0.90 0.53 1,880.00
+invoice-consulting 0:86f73207c794 0.42 0.40 20–25may2025
+invoice-consulting 0:55907ef405f6 0.42 0.58 1,880.00
+invoice-consulting 0:55907ef405f6#1 0.42 0.53 1,880.00
invoice-consulting 0:f2e12ad6cc9f 0.65 0.09 presentation&finalreport
invoice-consulting 0:50de6dc61b80 0.61 0.09 executivepresentationanddelivery
invoice-consulting 0:d6577e95efba 0.21 0.09 subtotal
@@ -2150,96 +2150,96 @@ invoice-consulting_long 0:d1062d072acd 0.15 -0.32 unitprice
invoice-consulting_long 0:3ff0b4a2706b 0.25 -0.16 (aud)
invoice-consulting_long 0:3ff0b4a2706b#1 0.25 -0.11 (aud)
invoice-consulting_long 0:cf38d95c9c6b 0.15 -0.24 amount
-invoice-consulting_long 0:b344321f5471 0.72 0.40 1–10may2025
-invoice-consulting_long 0:b344321f5471#1 0.91 0.40 1–10may2025
-invoice-consulting_long 0:b344321f5471#2 0.99 0.40 1–10may2025
-invoice-consulting_long 0:a8994a9020c4 0.74 0.06 10.00
-invoice-consulting_long 0:a8994a9020c4#1 0.93 0.06 10.00
-invoice-consulting_long 0:a8994a9020c4#2 1.01 0.06 10.00
-invoice-consulting_long 0:4e9682fa850e 0.71 0.08 hrs
-invoice-consulting_long 0:4e9682fa850e#1 0.86 0.08 hrs
-invoice-consulting_long 0:4e9682fa850e#2 0.90 0.08 hrs
-invoice-consulting_long 0:4e9682fa850e#3 0.93 0.08 hrs
-invoice-consulting_long 0:4e9682fa850e#4 0.98 0.08 hrs
-invoice-consulting_long 0:4e9682fa850e#5 1.12 0.08 hrs
-invoice-consulting_long 0:aa92f0e23a97 0.72 0.51 250.00
-invoice-consulting_long 0:aa92f0e23a97#1 0.91 0.51 250.00
-invoice-consulting_long 0:aa92f0e23a97#2 0.99 0.51 250.00
-invoice-consulting_long 0:e48d9b7a2993 0.72 0.50 2,500.00
-invoice-consulting_long 0:e48d9b7a2993#1 0.91 0.50 2,500.00
-invoice-consulting_long 0:e48d9b7a2993#2 0.99 0.50 2,500.00
+invoice-consulting_long 0:b344321f5471 0.24 0.40 1–10may2025
+invoice-consulting_long 0:b344321f5471#1 0.43 0.40 1–10may2025
+invoice-consulting_long 0:b344321f5471#2 0.51 0.40 1–10may2025
+invoice-consulting_long 0:a8994a9020c4 0.26 0.06 10.00
+invoice-consulting_long 0:a8994a9020c4#1 0.45 0.06 10.00
+invoice-consulting_long 0:a8994a9020c4#2 0.53 0.06 10.00
+invoice-consulting_long 0:4e9682fa850e 0.23 0.08 hrs
+invoice-consulting_long 0:4e9682fa850e#1 0.38 0.08 hrs
+invoice-consulting_long 0:4e9682fa850e#2 0.42 0.08 hrs
+invoice-consulting_long 0:4e9682fa850e#3 0.45 0.08 hrs
+invoice-consulting_long 0:4e9682fa850e#4 0.50 0.08 hrs
+invoice-consulting_long 0:4e9682fa850e#5 0.64 0.08 hrs
+invoice-consulting_long 0:aa92f0e23a97 0.24 0.51 250.00
+invoice-consulting_long 0:aa92f0e23a97#1 0.43 0.51 250.00
+invoice-consulting_long 0:aa92f0e23a97#2 0.51 0.51 250.00
+invoice-consulting_long 0:e48d9b7a2993 0.24 0.50 2,500.00
+invoice-consulting_long 0:e48d9b7a2993#1 0.43 0.50 2,500.00
+invoice-consulting_long 0:e48d9b7a2993#2 0.51 0.50 2,500.00
invoice-consulting_long 0:1bcfde966d94 0.47 0.09 strategicconsultation
invoice-consulting_long 0:1bcfde966d94#1 0.66 0.09 strategicconsultation
invoice-consulting_long 0:1bcfde966d94#2 0.74 0.09 strategicconsultation
invoice-consulting_long 0:fd3ca268f319 0.55 0.09 leadershipalignmentworkshops
invoice-consulting_long 0:fd3ca268f319#1 0.62 0.09 leadershipalignmentworkshops
invoice-consulting_long 0:fd3ca268f319#2 0.82 0.09 leadershipalignmentworkshops
-invoice-consulting_long 0:8d93e0c47a8c 0.73 0.40 1–15may2025
-invoice-consulting_long 0:8d93e0c47a8c#1 0.92 0.40 1–15may2025
-invoice-consulting_long 0:8d93e0c47a8c#2 1.00 0.40 1–15may2025
-invoice-consulting_long 0:cf9dcf6da8a8 0.75 0.08 1.00
-invoice-consulting_long 0:cf9dcf6da8a8#1 0.76 0.08 1.00
-invoice-consulting_long 0:cf9dcf6da8a8#2 0.92 0.08 1.00
-invoice-consulting_long 0:cf9dcf6da8a8#3 0.94 0.08 1.00
-invoice-consulting_long 0:cf9dcf6da8a8#4 0.95 0.08 1.00
-invoice-consulting_long 0:cf9dcf6da8a8#5 0.97 0.08 1.00
-invoice-consulting_long 0:cf9dcf6da8a8#6 1.02 0.08 1.00
-invoice-consulting_long 0:cf9dcf6da8a8#7 1.03 0.08 1.00
-invoice-consulting_long 0:cf9dcf6da8a8#8 1.04 0.08 1.00
-invoice-consulting_long 0:97e47b250054 0.73 0.54 3,500.00
-invoice-consulting_long 0:97e47b250054#1 0.73 0.49 3,500.00
-invoice-consulting_long 0:97e47b250054#2 0.92 0.54 3,500.00
-invoice-consulting_long 0:97e47b250054#3 0.92 0.49 3,500.00
-invoice-consulting_long 0:97e47b250054#4 1.00 0.54 3,500.00
-invoice-consulting_long 0:97e47b250054#5 1.00 0.49 3,500.00
+invoice-consulting_long 0:8d93e0c47a8c 0.25 0.40 1–15may2025
+invoice-consulting_long 0:8d93e0c47a8c#1 0.44 0.40 1–15may2025
+invoice-consulting_long 0:8d93e0c47a8c#2 0.52 0.40 1–15may2025
+invoice-consulting_long 0:cf9dcf6da8a8 0.27 0.08 1.00
+invoice-consulting_long 0:cf9dcf6da8a8#1 0.28 0.08 1.00
+invoice-consulting_long 0:cf9dcf6da8a8#2 0.44 0.08 1.00
+invoice-consulting_long 0:cf9dcf6da8a8#3 0.46 0.08 1.00
+invoice-consulting_long 0:cf9dcf6da8a8#4 0.47 0.08 1.00
+invoice-consulting_long 0:cf9dcf6da8a8#5 0.49 0.08 1.00
+invoice-consulting_long 0:cf9dcf6da8a8#6 0.54 0.08 1.00
+invoice-consulting_long 0:cf9dcf6da8a8#7 0.55 0.08 1.00
+invoice-consulting_long 0:cf9dcf6da8a8#8 0.56 0.08 1.00
+invoice-consulting_long 0:97e47b250054 0.25 0.54 3,500.00
+invoice-consulting_long 0:97e47b250054#1 0.25 0.49 3,500.00
+invoice-consulting_long 0:97e47b250054#2 0.44 0.54 3,500.00
+invoice-consulting_long 0:97e47b250054#3 0.44 0.49 3,500.00
+invoice-consulting_long 0:97e47b250054#4 0.52 0.54 3,500.00
+invoice-consulting_long 0:97e47b250054#5 0.52 0.49 3,500.00
invoice-consulting_long 0:5581aef375ff 0.48 0.09 market&competitiveanalysis
invoice-consulting_long 0:5581aef375ff#1 0.67 0.09 market&competitiveanalysis
invoice-consulting_long 0:5581aef375ff#2 0.75 0.09 market&competitiveanalysis
invoice-consulting_long 0:957080ea09d9 0.56 0.09 researchandanalysisreport
invoice-consulting_long 0:957080ea09d9#1 0.63 0.09 researchandanalysisreport
invoice-consulting_long 0:957080ea09d9#2 0.83 0.09 researchandanalysisreport
-invoice-consulting_long 0:47102c31f226 0.74 0.37 5–20may2025
-invoice-consulting_long 0:47102c31f226#1 0.93 0.37 5–20may2025
-invoice-consulting_long 0:47102c31f226#2 1.01 0.37 5–20may2025
-invoice-consulting_long 0:ec6305055be9 0.74 0.63 4,800.00
-invoice-consulting_long 0:ec6305055be9#1 0.74 0.57 4,800.00
-invoice-consulting_long 0:ec6305055be9#2 0.93 0.63 4,800.00
-invoice-consulting_long 0:ec6305055be9#3 0.93 0.57 4,800.00
-invoice-consulting_long 0:ec6305055be9#4 1.01 0.63 4,800.00
-invoice-consulting_long 0:ec6305055be9#5 1.01 0.57 4,800.00
+invoice-consulting_long 0:47102c31f226 0.26 0.37 5–20may2025
+invoice-consulting_long 0:47102c31f226#1 0.45 0.37 5–20may2025
+invoice-consulting_long 0:47102c31f226#2 0.53 0.37 5–20may2025
+invoice-consulting_long 0:ec6305055be9 0.26 0.63 4,800.00
+invoice-consulting_long 0:ec6305055be9#1 0.26 0.57 4,800.00
+invoice-consulting_long 0:ec6305055be9#2 0.45 0.63 4,800.00
+invoice-consulting_long 0:ec6305055be9#3 0.45 0.57 4,800.00
+invoice-consulting_long 0:ec6305055be9#4 0.53 0.63 4,800.00
+invoice-consulting_long 0:ec6305055be9#5 0.53 0.57 4,800.00
invoice-consulting_long 0:53dea97cf116 0.49 0.09 digitalroadmapdevelopment
invoice-consulting_long 0:53dea97cf116#1 0.68 0.09 digitalroadmapdevelopment
invoice-consulting_long 0:53dea97cf116#2 0.76 0.09 digitalroadmapdevelopment
invoice-consulting_long 0:acf357e68297 0.57 0.09 strategyandroadmapcreation
invoice-consulting_long 0:acf357e68297#1 0.64 0.09 strategyandroadmapcreation
invoice-consulting_long 0:acf357e68297#2 0.84 0.09 strategyandroadmapcreation
-invoice-consulting_long 0:c947fb16eab2 0.87 0.43 15–22may2025
-invoice-consulting_long 0:c947fb16eab2#1 0.94 0.43 15–22may2025
-invoice-consulting_long 0:c947fb16eab2#2 1.02 0.43 15–22may2025
-invoice-consulting_long 0:017144e2271f 0.77 0.07 6.00
-invoice-consulting_long 0:017144e2271f#1 0.96 0.07 6.00
-invoice-consulting_long 0:017144e2271f#2 1.04 0.07 6.00
-invoice-consulting_long 0:be6012a47af0 0.87 0.47 220.00
-invoice-consulting_long 0:be6012a47af0#1 0.94 0.47 220.00
-invoice-consulting_long 0:be6012a47af0#2 1.02 0.47 220.00
-invoice-consulting_long 0:172c0a785bc7 0.87 0.50 1,320.00
-invoice-consulting_long 0:172c0a785bc7#1 0.94 0.50 1,320.00
-invoice-consulting_long 0:172c0a785bc7#2 1.02 0.50 1,320.00
+invoice-consulting_long 0:c947fb16eab2 0.39 0.43 15–22may2025
+invoice-consulting_long 0:c947fb16eab2#1 0.46 0.43 15–22may2025
+invoice-consulting_long 0:c947fb16eab2#2 0.54 0.43 15–22may2025
+invoice-consulting_long 0:017144e2271f 0.29 0.07 6.00
+invoice-consulting_long 0:017144e2271f#1 0.48 0.07 6.00
+invoice-consulting_long 0:017144e2271f#2 0.56 0.07 6.00
+invoice-consulting_long 0:be6012a47af0 0.39 0.47 220.00
+invoice-consulting_long 0:be6012a47af0#1 0.46 0.47 220.00
+invoice-consulting_long 0:be6012a47af0#2 0.54 0.47 220.00
+invoice-consulting_long 0:172c0a785bc7 0.39 0.50 1,320.00
+invoice-consulting_long 0:172c0a785bc7#1 0.46 0.50 1,320.00
+invoice-consulting_long 0:172c0a785bc7#2 0.54 0.50 1,320.00
invoice-consulting_long 0:fe04037aa850 0.62 0.09 stakeholderreviewsessions
invoice-consulting_long 0:fe04037aa850#1 0.69 0.09 stakeholderreviewsessions
invoice-consulting_long 0:fe04037aa850#2 0.77 0.09 stakeholderreviewsessions
invoice-consulting_long 0:4658a1bff292 0.58 0.09 facilitationanddocumentation
invoice-consulting_long 0:4658a1bff292#1 0.77 0.09 facilitationanddocumentation
invoice-consulting_long 0:4658a1bff292#2 0.84 0.09 facilitationanddocumentation
-invoice-consulting_long 0:86f73207c794 0.90 0.40 20–25may2025
-invoice-consulting_long 0:86f73207c794#1 0.95 0.40 20–25may2025
-invoice-consulting_long 0:86f73207c794#2 1.03 0.40 20–25may2025
-invoice-consulting_long 0:55907ef405f6 0.90 0.58 1,880.00
-invoice-consulting_long 0:55907ef405f6#1 0.90 0.53 1,880.00
-invoice-consulting_long 0:55907ef405f6#2 0.95 0.58 1,880.00
-invoice-consulting_long 0:55907ef405f6#3 0.95 0.53 1,880.00
-invoice-consulting_long 0:55907ef405f6#4 1.03 0.58 1,880.00
-invoice-consulting_long 0:55907ef405f6#5 1.03 0.53 1,880.00
+invoice-consulting_long 0:86f73207c794 0.42 0.40 20–25may2025
+invoice-consulting_long 0:86f73207c794#1 0.47 0.40 20–25may2025
+invoice-consulting_long 0:86f73207c794#2 0.55 0.40 20–25may2025
+invoice-consulting_long 0:55907ef405f6 0.42 0.58 1,880.00
+invoice-consulting_long 0:55907ef405f6#1 0.42 0.53 1,880.00
+invoice-consulting_long 0:55907ef405f6#2 0.47 0.58 1,880.00
+invoice-consulting_long 0:55907ef405f6#3 0.47 0.53 1,880.00
+invoice-consulting_long 0:55907ef405f6#4 0.55 0.58 1,880.00
+invoice-consulting_long 0:55907ef405f6#5 0.55 0.53 1,880.00
invoice-consulting_long 0:f2e12ad6cc9f 0.65 0.09 presentation&finalreport
invoice-consulting_long 0:f2e12ad6cc9f#1 0.70 0.09 presentation&finalreport
invoice-consulting_long 0:f2e12ad6cc9f#2 0.78 0.09 presentation&finalreport
@@ -2255,73 +2255,73 @@ invoice-consulting_long 1:d1062d072acd -0.06 -0.32 unitprice
invoice-consulting_long 1:3ff0b4a2706b -0.08 -0.16 (aud)
invoice-consulting_long 1:3ff0b4a2706b#1 -0.08 -0.11 (aud)
invoice-consulting_long 1:cf38d95c9c6b -0.06 -0.24 amount
-invoice-consulting_long 1:b344321f5471 0.51 0.40 1–10may2025
-invoice-consulting_long 1:b344321f5471#1 0.58 0.40 1–10may2025
-invoice-consulting_long 1:b344321f5471#2 0.78 0.40 1–10may2025
-invoice-consulting_long 1:a8994a9020c4 0.53 0.06 10.00
-invoice-consulting_long 1:a8994a9020c4#1 0.60 0.06 10.00
-invoice-consulting_long 1:a8994a9020c4#2 0.80 0.06 10.00
-invoice-consulting_long 1:4e9682fa850e 0.52 0.08 hrs
-invoice-consulting_long 1:4e9682fa850e#1 0.55 0.08 hrs
-invoice-consulting_long 1:4e9682fa850e#2 0.69 0.08 hrs
-invoice-consulting_long 1:4e9682fa850e#3 0.75 0.08 hrs
-invoice-consulting_long 1:4e9682fa850e#4 0.77 0.08 hrs
-invoice-consulting_long 1:aa92f0e23a97 0.51 0.51 250.00
-invoice-consulting_long 1:aa92f0e23a97#1 0.58 0.51 250.00
-invoice-consulting_long 1:aa92f0e23a97#2 0.78 0.51 250.00
-invoice-consulting_long 1:e48d9b7a2993 0.51 0.50 2,500.00
-invoice-consulting_long 1:e48d9b7a2993#1 0.58 0.50 2,500.00
-invoice-consulting_long 1:e48d9b7a2993#2 0.78 0.50 2,500.00
+invoice-consulting_long 1:b344321f5471 0.03 0.40 1–10may2025
+invoice-consulting_long 1:b344321f5471#1 0.10 0.40 1–10may2025
+invoice-consulting_long 1:b344321f5471#2 0.30 0.40 1–10may2025
+invoice-consulting_long 1:a8994a9020c4 0.05 0.06 10.00
+invoice-consulting_long 1:a8994a9020c4#1 0.12 0.06 10.00
+invoice-consulting_long 1:a8994a9020c4#2 0.32 0.06 10.00
+invoice-consulting_long 1:4e9682fa850e 0.04 0.08 hrs
+invoice-consulting_long 1:4e9682fa850e#1 0.07 0.08 hrs
+invoice-consulting_long 1:4e9682fa850e#2 0.21 0.08 hrs
+invoice-consulting_long 1:4e9682fa850e#3 0.27 0.08 hrs
+invoice-consulting_long 1:4e9682fa850e#4 0.29 0.08 hrs
+invoice-consulting_long 1:aa92f0e23a97 0.03 0.51 250.00
+invoice-consulting_long 1:aa92f0e23a97#1 0.10 0.51 250.00
+invoice-consulting_long 1:aa92f0e23a97#2 0.30 0.51 250.00
+invoice-consulting_long 1:e48d9b7a2993 0.03 0.50 2,500.00
+invoice-consulting_long 1:e48d9b7a2993#1 0.10 0.50 2,500.00
+invoice-consulting_long 1:e48d9b7a2993#2 0.30 0.50 2,500.00
invoice-consulting_long 1:1bcfde966d94 0.26 0.09 strategicconsultation
invoice-consulting_long 1:1bcfde966d94#1 0.33 0.09 strategicconsultation
invoice-consulting_long 1:1bcfde966d94#2 0.53 0.09 strategicconsultation
invoice-consulting_long 1:fd3ca268f319 0.34 0.09 leadershipalignmentworkshops
invoice-consulting_long 1:fd3ca268f319#1 0.41 0.09 leadershipalignmentworkshops
invoice-consulting_long 1:fd3ca268f319#2 0.49 0.09 leadershipalignmentworkshops
-invoice-consulting_long 1:8d93e0c47a8c 0.54 0.40 1–15may2025
-invoice-consulting_long 1:8d93e0c47a8c#1 0.74 0.40 1–15may2025
-invoice-consulting_long 1:cf9dcf6da8a8 0.56 0.08 1.00
-invoice-consulting_long 1:cf9dcf6da8a8#1 0.57 0.08 1.00
-invoice-consulting_long 1:cf9dcf6da8a8#2 0.59 0.08 1.00
-invoice-consulting_long 1:cf9dcf6da8a8#3 0.61 0.08 1.00
-invoice-consulting_long 1:cf9dcf6da8a8#4 0.77 0.08 1.00
-invoice-consulting_long 1:cf9dcf6da8a8#5 0.79 0.08 1.00
-invoice-consulting_long 1:97e47b250054 0.54 0.54 3,500.00
-invoice-consulting_long 1:97e47b250054#1 0.54 0.49 3,500.00
-invoice-consulting_long 1:97e47b250054#2 0.74 0.54 3,500.00
-invoice-consulting_long 1:97e47b250054#3 0.74 0.49 3,500.00
+invoice-consulting_long 1:8d93e0c47a8c 0.06 0.40 1–15may2025
+invoice-consulting_long 1:8d93e0c47a8c#1 0.26 0.40 1–15may2025
+invoice-consulting_long 1:cf9dcf6da8a8 0.08 0.08 1.00
+invoice-consulting_long 1:cf9dcf6da8a8#1 0.09 0.08 1.00
+invoice-consulting_long 1:cf9dcf6da8a8#2 0.11 0.08 1.00
+invoice-consulting_long 1:cf9dcf6da8a8#3 0.13 0.08 1.00
+invoice-consulting_long 1:cf9dcf6da8a8#4 0.29 0.08 1.00
+invoice-consulting_long 1:cf9dcf6da8a8#5 0.31 0.08 1.00
+invoice-consulting_long 1:97e47b250054 0.06 0.54 3,500.00
+invoice-consulting_long 1:97e47b250054#1 0.06 0.49 3,500.00
+invoice-consulting_long 1:97e47b250054#2 0.26 0.54 3,500.00
+invoice-consulting_long 1:97e47b250054#3 0.26 0.49 3,500.00
invoice-consulting_long 1:5581aef375ff 0.29 0.09 market&competitiveanalysis
invoice-consulting_long 1:5581aef375ff#1 0.46 0.09 market&competitiveanalysis
invoice-consulting_long 1:957080ea09d9 0.37 0.09 researchandanalysisreport
invoice-consulting_long 1:957080ea09d9#1 0.45 0.09 researchandanalysisreport
-invoice-consulting_long 1:47102c31f226 0.55 0.37 5–20may2025
-invoice-consulting_long 1:47102c31f226#1 0.75 0.37 5–20may2025
-invoice-consulting_long 1:ec6305055be9 0.55 0.63 4,800.00
-invoice-consulting_long 1:ec6305055be9#1 0.55 0.57 4,800.00
-invoice-consulting_long 1:ec6305055be9#2 0.75 0.63 4,800.00
-invoice-consulting_long 1:ec6305055be9#3 0.75 0.57 4,800.00
+invoice-consulting_long 1:47102c31f226 0.07 0.37 5–20may2025
+invoice-consulting_long 1:47102c31f226#1 0.27 0.37 5–20may2025
+invoice-consulting_long 1:ec6305055be9 0.07 0.63 4,800.00
+invoice-consulting_long 1:ec6305055be9#1 0.07 0.57 4,800.00
+invoice-consulting_long 1:ec6305055be9#2 0.27 0.63 4,800.00
+invoice-consulting_long 1:ec6305055be9#3 0.27 0.57 4,800.00
invoice-consulting_long 1:53dea97cf116 0.30 0.09 digitalroadmapdevelopment
invoice-consulting_long 1:53dea97cf116#1 0.50 0.09 digitalroadmapdevelopment
invoice-consulting_long 1:acf357e68297 0.38 0.09 strategyandroadmapcreation
invoice-consulting_long 1:acf357e68297#1 0.46 0.09 strategyandroadmapcreation
-invoice-consulting_long 1:c947fb16eab2 0.56 0.43 15–22may2025
-invoice-consulting_long 1:c947fb16eab2#1 0.76 0.43 15–22may2025
-invoice-consulting_long 1:017144e2271f 0.58 0.07 6.00
-invoice-consulting_long 1:017144e2271f#1 0.78 0.07 6.00
-invoice-consulting_long 1:be6012a47af0 0.56 0.47 220.00
-invoice-consulting_long 1:be6012a47af0#1 0.76 0.47 220.00
-invoice-consulting_long 1:172c0a785bc7 0.56 0.50 1,320.00
-invoice-consulting_long 1:172c0a785bc7#1 0.76 0.50 1,320.00
+invoice-consulting_long 1:c947fb16eab2 0.08 0.43 15–22may2025
+invoice-consulting_long 1:c947fb16eab2#1 0.28 0.43 15–22may2025
+invoice-consulting_long 1:017144e2271f 0.10 0.07 6.00
+invoice-consulting_long 1:017144e2271f#1 0.30 0.07 6.00
+invoice-consulting_long 1:be6012a47af0 0.08 0.47 220.00
+invoice-consulting_long 1:be6012a47af0#1 0.28 0.47 220.00
+invoice-consulting_long 1:172c0a785bc7 0.08 0.50 1,320.00
+invoice-consulting_long 1:172c0a785bc7#1 0.28 0.50 1,320.00
invoice-consulting_long 1:fe04037aa850 0.31 0.09 stakeholderreviewsessions
invoice-consulting_long 1:fe04037aa850#1 0.51 0.09 stakeholderreviewsessions
invoice-consulting_long 1:4658a1bff292 0.39 0.09 facilitationanddocumentation
invoice-consulting_long 1:4658a1bff292#1 0.47 0.09 facilitationanddocumentation
-invoice-consulting_long 1:86f73207c794 0.57 0.40 20–25may2025
-invoice-consulting_long 1:86f73207c794#1 0.77 0.40 20–25may2025
-invoice-consulting_long 1:55907ef405f6 0.57 0.58 1,880.00
-invoice-consulting_long 1:55907ef405f6#1 0.57 0.53 1,880.00
-invoice-consulting_long 1:55907ef405f6#2 0.77 0.58 1,880.00
-invoice-consulting_long 1:55907ef405f6#3 0.77 0.53 1,880.00
+invoice-consulting_long 1:86f73207c794 0.09 0.40 20–25may2025
+invoice-consulting_long 1:86f73207c794#1 0.29 0.40 20–25may2025
+invoice-consulting_long 1:55907ef405f6 0.09 0.58 1,880.00
+invoice-consulting_long 1:55907ef405f6#1 0.09 0.53 1,880.00
+invoice-consulting_long 1:55907ef405f6#2 0.29 0.58 1,880.00
+invoice-consulting_long 1:55907ef405f6#3 0.29 0.53 1,880.00
invoice-consulting_long 1:f2e12ad6cc9f 0.32 0.09 presentation&finalreport
invoice-consulting_long 1:f2e12ad6cc9f#1 0.52 0.09 presentation&finalreport
invoice-consulting_long 1:50de6dc61b80 0.40 0.09 executivepresentationanddelivery
diff --git a/qa/src/test/resources/docx-fidelity/word-windows.tsv b/qa/src/test/resources/docx-fidelity/word-windows.tsv
index ecb89a643..586c36d77 100644
--- a/qa/src/test/resources/docx-fidelity/word-windows.tsv
+++ b/qa/src/test/resources/docx-fidelity/word-windows.tsv
@@ -28,8 +28,8 @@ cv-timeline_minimal 2 2 89 87 0.36 0.47 0
cv-violet_grid 1 1 80 78 0.23 0.42 0
invoice-classic 1 1 56 56 0.06 0.23 0
invoice-classic_long 2 2 166 166 0.06 0.14 0
-invoice-consulting 1 1 92 92 0.51 1.02 0
-invoice-consulting_long 2 2 236 236 0.64 0.96 0
+invoice-consulting 1 1 92 92 0.28 1.02 0
+invoice-consulting_long 2 2 236 236 0.35 0.70 0
invoice-luma_studio 1 1 97 97 0.14 0.41 0
invoice-luma_studio_long 3 3 192 192 0.21 0.38 0
invoice-merchant 1 1 94 94 0.13 0.22 0
diff --git a/render-docx/src/main/java/com/demcha/compose/document/backend/semantic/docx/DocxSemanticBackend.java b/render-docx/src/main/java/com/demcha/compose/document/backend/semantic/docx/DocxSemanticBackend.java
index fed58faca..50e0b175c 100644
--- a/render-docx/src/main/java/com/demcha/compose/document/backend/semantic/docx/DocxSemanticBackend.java
+++ b/render-docx/src/main/java/com/demcha/compose/document/backend/semantic/docx/DocxSemanticBackend.java
@@ -333,6 +333,10 @@ public final class DocxSemanticBackend implements SemanticBackend {
// see moveTheRowsText.
private final java.util.Map textCellRaises =
new java.util.IdentityHashMap<>();
+ // The paragraph whose lines last fell short of the page and what was owed below it for that:
+ // see settleTheLinesWithThePage, takeBackTheRoundingOwedBy.
+ private org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP roundingOwedBy;
+ private double roundingOwed;
// Icons drawn beside the text they label rather than written: see drawnBesideItsText.
private final java.util.Set picturesDrawnBeside =
java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>());
@@ -831,6 +835,8 @@ private byte[] write(List sections, Path outputFile) throws Exc
lineTopsTakenIn.clear();
cellsGivingTheirPadding.clear();
textCellRaises.clear();
+ roundingOwedBy = null;
+ roundingOwed = 0;
risenLines.clear();
tablesCells.clear();
picturesDrawnBeside.clear();
@@ -8722,11 +8728,25 @@ private void settleTheLinesWithThePage(XWPFParagraph target, ParagraphNode sourc
double shortBy = page.getAsDouble() - written;
if (shortBy > LINES_ROUNDING_TOLERANCE) {
owePendingSpacingAfter(shortBy);
+ roundingOwedBy = target.getCTP();
+ roundingOwed = shortBy;
} else if (-shortBy > LINES_ROUNDING_TOLERANCE) {
hangingBelow = Math.max(hangingBelow, -shortBy);
}
}
+ /**
+ * Takes back what a paragraph's lines were owed below it for falling short of the page
+ * ({@link #settleTheLinesWithThePage}) once its pictures have made its line taller than written
+ * ({@code makeRoomForPictures}): Word grows those lines to the pictures, past what they fell short.
+ */
+ private void takeBackTheRoundingOwedBy(XWPFParagraph para) {
+ if (roundingOwedBy == para.getCTP()) {
+ pendingSpacingAfter -= roundingOwed;
+ roundingOwedBy = null;
+ }
+ }
+
/**
* What a paragraph's lines may fall short of or pass the page by, twips rounding, before it
* is owed below the paragraph or taken out of the space below it: Word sets lines on a grid
@@ -9206,7 +9226,17 @@ private void writeParagraphRuns(XWPFParagraph para, ParagraphNode node, boolean
// A line held to its pictures has their ink within half a point of its edges.
boolean cutToTheInk = !Double.isNaN(heldAbove);
if (Double.isNaN(heldAbove)) {
+ CTSpacing lineSpacing = para.getCTP().isSetPPr() && para.getCTP().getPPr().isSetSpacing()
+ ? para.getCTP().getPPr().getSpacing() : null;
+ Long exactBefore = lineSpacing != null && lineSpacing.isSetLineRule()
+ && lineSpacing.getLineRule() == STLineSpacingRule.EXACT ? writtenTwips(lineSpacing.getLine()) : null;
makeRoomForPictures(para, pictures);
+ if (exactBefore != null && (lineSpacing.getLineRule() != STLineSpacingRule.EXACT
+ || !exactBefore.equals(writtenTwips(lineSpacing.getLine())))) {
+ // Its lines are now as tall as its pictures, not as written: what they fell short
+ // of the page by rounding is not short any more (settleTheLinesWithThePage).
+ takeBackTheRoundingOwedBy(para);
+ }
heldAbove = 0;
}
styleTheMark(para, markStyle);
@@ -11952,13 +11982,13 @@ private void applyCellPaint(XWPFTableCell cell, DocumentColor fill, DocumentStro
}
/**
- * How wide Word draws a cell's rule, in points: the width written in eighths of a point, from
- * Word's thinnest to its thickest ({@link #ruleEighths(double)}), counted to the twip as a
- * row's height counts it ({@link #borderTwips}); 0 for none.
+ * How wide Word draws a cell's rule, in twips: the width written in eighths of a point, from
+ * Word's thinnest to its thickest — the two to ninety-six eighths a line border's {@code w:sz}
+ * runs over (ECMA-376) — ({@link #ruleEighths(double)}), counted to the twip as a row's height
+ * counts it ({@link #borderTwips}); 0 for none.
*/
- private static double writtenRuleWidth(DocumentStroke stroke) {
- return stroke == null || !(stroke.width() > 0) ? 0
- : eighthsInTwips(ruleEighths(stroke.width())) / POINT_TO_TWIP;
+ private static long ruleTwips(DocumentStroke stroke) {
+ return stroke == null || !(stroke.width() > 0) ? 0 : eighthsInTwips(ruleEighths(stroke.width()));
}
/** A rule's {@code w:sz}, eighths of a point, in whole twips. */
@@ -12016,11 +12046,13 @@ private static void applyCellPadding(XWPFTableCell cell, DocumentInsets padding)
* rules do, and a 1.5pt row under 0.5pt ones as 1.5pt rules do. So each rule comes off the
* padding where Word puts it; in a table ruled alike throughout, with padding enough, every
* row then stands where the page sets it. Each rule comes off as wide as Word draws it, in
- * eighths of a point ({@link #writtenRuleWidth}): a 0.7pt hairline is drawn 0.75pt wide, and
- * taken off at 0.7 it stood {@code EditorialProposal}'s tables, and all under them, a step of
- * Word's grid lower (measured). The sides keep their padding, as the columns' widths are
- * fixed. Padding thinner than its share gives what it has, and the row stands that much
- * taller.
+ * eighths of a point ({@link #ruleTwips}): a 0.7pt hairline is drawn 0.75pt wide, and taken
+ * off at 0.7 it stood {@code EditorialProposal}'s tables, and all under them, a step of Word's
+ * grid lower (measured). A rule between two rows is halved, each half rounded to the twip with
+ * the margin it comes off, so an odd rule comes off a twip short: 15 twips came off as 7 and 7,
+ * and every row of {@code NorthlineProposal}'s investment table stood a twip taller. The sides
+ * keep their padding, as the columns' widths are fixed. Padding thinner than its share gives
+ * what it has, and the row stands that much taller.
*
* @param padding the cell's padding on the page
* @param stroke the cell's own rule
@@ -12031,8 +12063,8 @@ private static void applyCellPadding(XWPFTableCell cell, DocumentInsets padding)
*/
private static DocumentInsets clearOfTheRules(DocumentInsets padding, DocumentStroke stroke,
boolean firstRow, boolean lastRow, DocumentStroke underneath) {
- double rule = writtenRuleWidth(stroke);
- double below = lastRow ? rule : writtenRuleWidth(underneath) / 2;
+ double rule = ruleTwips(stroke) / POINT_TO_TWIP;
+ double below = lastRow ? rule : ruleTwips(underneath) / POINT_TO_TWIP / 2;
return new DocumentInsets(Math.max(0, padding.top() - (firstRow ? rule : rule / 2)), padding.right(),
Math.max(0, padding.bottom() - below), padding.left());
}
@@ -12260,21 +12292,31 @@ private double belowThePage(TableResolvedCell measured, XWPFParagraph first) {
* high there.
*
* Every cell of the row is moved alike, by the least that any of its cells' lines call
- * for, so none is moved past where the page sets it, and what the others call for beyond that
- * is left — no position makes it up, which LibreOffice would move further than it is raised;
- * no further than the margin the text moves into holds. A row whose cells call for opposite
- * ways is left as it is, and so is less than {@link #LEAST_ROW_TEXT_MOVE}. Only a row of text
- * cells the layout measured, in a face the measured fonts hold: a composed cell's paragraphs
- * are seated by their own writers where they can be, and the margins would move them again.
- * Not a row in a vertical merge, whose cells' margins are evened apart.
+ * for, so none is moved past where the page sets it, and no further than the margin the text
+ * moves into holds. A row whose cells call for opposite ways is not moved, and nor is one
+ * whose least call is under {@link #LEAST_ROW_TEXT_MOVE}. Only a row of text cells the layout
+ * measured, in a face the measured fonts hold: a composed cell's paragraphs are seated by their
+ * own writers where they can be, and the margins would move them again. Not a row in a
+ * vertical merge, whose cells' margins are evened apart.
+ *
+ * What the margins leave of a text cell's call, in a row they do not move or move by less,
+ * is moved by its text's position where that is half a point or more
+ * ({@link #LEAST_BASELINE_SHIFT_POINTS}), as a paragraph's is: a cell of 8pt Poppins beside one
+ * of Lato, the two called opposite ways, stood 0.58pt low. The position counts in half points,
+ * and LibreOffice moves text further than it is raised, by up to half as much again
+ * ({@link #raiseIntoTheSpaceAbove}); from half a point up that overshoot is less than what is
+ * left, and under it more, so less is left as it is.
*/
private void moveTheRowsText(XWPFTableRow row) {
+ List cells = row.getTableCells();
+ double[] calls = new double[cells.size()];
double least = Double.NaN;
boolean moves = true;
- for (XWPFTableCell cell : row.getTableCells()) {
+ for (int i = 0; i < cells.size(); i++) {
// Taken out as it is read: the row is decided here, once.
- Double below = textCellRaises.remove(cell.getCTTc());
- CTTcPr properties = cell.getCTTc().getTcPr();
+ Double below = textCellRaises.remove(cells.get(i).getCTTc());
+ CTTcPr properties = cells.get(i).getCTTc().getTcPr();
+ calls[i] = below == null ? Double.NaN : below;
if (below == null || properties != null && properties.isSetVMerge()) {
moves = false;
} else if (!Double.isNaN(below)) {
@@ -12282,19 +12324,24 @@ private void moveTheRowsText(XWPFTableRow row) {
least = Double.isNaN(least) || Math.abs(below) < Math.abs(least) ? below : least;
}
}
- if (!moves || !(Math.abs(least) >= LEAST_ROW_TEXT_MOVE)) {
- return;
- }
- long move = Math.round(least * POINT_TO_TWIP);
- for (XWPFTableCell cell : row.getTableCells()) {
- move = move > 0 ? Math.min(move, cellMargin(cell, true)) : Math.max(move, -cellMargin(cell, false));
- }
- if (Math.abs(move) < Math.round(LEAST_ROW_TEXT_MOVE * POINT_TO_TWIP)) {
- return;
+ long move = 0;
+ if (moves && Math.abs(least) >= LEAST_ROW_TEXT_MOVE) {
+ move = Math.round(least * POINT_TO_TWIP);
+ for (XWPFTableCell cell : cells) {
+ move = move > 0 ? Math.min(move, cellMargin(cell, true)) : Math.max(move, -cellMargin(cell, false));
+ }
+ for (XWPFTableCell cell : cells) {
+ setCellMarginTwips(cell, true, cellMargin(cell, true) - move);
+ setCellMarginTwips(cell, false, cellMargin(cell, false) + move);
+ }
}
- for (XWPFTableCell cell : row.getTableCells()) {
- setCellMarginTwips(cell, true, cellMargin(cell, true) - move);
- setCellMarginTwips(cell, false, cellMargin(cell, false) + move);
+ for (int i = 0; i < cells.size(); i++) {
+ double left = calls[i] - move / POINT_TO_TWIP;
+ if (Math.abs(left) >= LEAST_BASELINE_SHIFT_POINTS) {
+ for (XWPFParagraph para : cells.get(i).getParagraphs()) {
+ raiseRunsFrom(para, 0, Math.round(left * HALF_POINTS_PER_POINT));
+ }
+ }
}
}
diff --git a/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxCellPaddingTest.java b/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxCellPaddingTest.java
index 693f9924a..adf03e090 100644
--- a/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxCellPaddingTest.java
+++ b/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxCellPaddingTest.java
@@ -95,6 +95,22 @@ void aRuleComesOffThePaddingAsWideAsWordDrawsIt() throws Exception {
assertThat(margins(cell)).containsExactly(140L - 15 - SEAT, 140L, 140L - 15 + SEAT, 140L);
}
+ @Test
+ void aRuleThickerThanWordDrawsIsWrittenAndTakenOffAtWordsThickest() throws Exception {
+ // A line border's w:sz runs from two to ninety-six eighths of a point.
+ XWPFTableCell cell = firstCell(page -> page.addTable(t -> t
+ .columns(DocumentTableColumn.auto())
+ .defaultCellStyle(DocumentTableStyle.builder()
+ .padding(DocumentInsets.of(20))
+ .stroke(DocumentStroke.of(DocumentColor.BLACK, 13))
+ .build())
+ .row("Heavy")));
+
+ assertThat(((Number) cell.getCTTc().getTcPr().getTcBorders().getTop().getSz()).intValue()).isEqualTo(96);
+ assertThat(margins(cell)).as("12pt off each side, less the row's seat above, more below")
+ .containsExactly(400L - 240 - SEAT, 400L, 400L - 240 + SEAT, 400L);
+ }
+
@Test
void aRuleThinnerThanWordDrawsIsWrittenAndTakenOffAtWordsThinnest() throws Exception {
// Word draws no single rule thinner than two eighths of a point.
diff --git a/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxCellSeatTest.java b/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxCellSeatTest.java
index abc0a4182..805d3df36 100644
--- a/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxCellSeatTest.java
+++ b/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxCellSeatTest.java
@@ -86,7 +86,7 @@ void aRowIsMovedByTheLeastItsCellsCallFor() throws Exception {
long small = Math.round((0.8 * line(row.getCell(1)) - HELVETICA_ASCENT * 7) * 20);
long middle = Math.round((0.8 * line(row.getCell(2)) - HELVETICA_ASCENT * 10) * 20);
- assertThat(small).as("the premise: the least is the middle cell's, apart from the others")
+ assertThat(small).as("the premise: the least is the 7pt cell's, apart from the others")
.isLessThan(middle).isLessThan(large).isPositive();
assertThat(large).as("the default face's, as a paragraph of it is raised").isEqualTo(DocxExports.DEFAULT_LINE_RAISE);
for (XWPFTableCell cell : row.getTableCells()) {
@@ -140,13 +140,39 @@ void aTableWithNoLayoutKeepsItsMargins() throws Exception {
@Test
void aRowWhoseCellsCallForOppositeWaysIsLeftAsItWas() throws Exception {
+ // Its margins are not moved; the cell calling for half a point and more is moved by its
+ // text's position, the other is left.
try (XWPFDocument document = export(page -> page.addTable(t -> t
.columns(DocumentTableColumn.fixed(100), DocumentTableColumn.fixed(100))
.rowCells(cell("Low", poppins(8), DocumentTableTextAnchor.CENTER),
cell("High", lato(8), DocumentTableTextAnchor.CENTER))))) {
- for (XWPFTableCell cell : document.getTables().get(0).getRow(0).getTableCells()) {
+ XWPFTableRow row = document.getTables().get(0).getRow(0);
+ double poppins = 0.8 * line(row.getCell(0)) - POPPINS_ASCENT * 8;
+
+ for (XWPFTableCell cell : row.getTableCells()) {
assertThat(margins(cell)).containsExactly(PADDING, PADDING);
}
+ assertThat(poppins).as("the premise: half a point and more").isGreaterThanOrEqualTo(0.5);
+ assertThat(position(row.getCell(0))).isEqualTo(Math.round(poppins * 2));
+ assertThat(position(row.getCell(1))).as("Lato's quarter point is left").isZero();
+ }
+ }
+
+ @Test
+ void whatTheMarginsLeaveOfHalfAPointAndMoreIsLeftToThePosition() throws Exception {
+ // The row moves by Helvetica's 6 twips; Poppins at 14pt calls for nearly a point.
+ try (XWPFDocument document = export(page -> page.addTable(t -> t
+ .columns(DocumentTableColumn.fixed(100), DocumentTableColumn.fixed(100))
+ .rowCells(cell("Poppins", poppins(14), DocumentTableTextAnchor.CENTER),
+ cell("Helvetica", helvetica(14), DocumentTableTextAnchor.CENTER))))) {
+ XWPFTableRow row = document.getTables().get(0).getRow(0);
+ double left = 0.8 * line(row.getCell(0)) - POPPINS_ASCENT * 14 - DocxExports.DEFAULT_LINE_RAISE / 20.0;
+
+ assertThat(margins(row.getCell(1))).containsExactly(PADDING - DocxExports.DEFAULT_LINE_RAISE,
+ PADDING + DocxExports.DEFAULT_LINE_RAISE);
+ assertThat(left).as("the premise: half a point and more left").isGreaterThanOrEqualTo(0.5);
+ assertThat(position(row.getCell(0))).isEqualTo(Math.round(left * 2));
+ assertThat(position(row.getCell(1))).as("nothing left of Helvetica's").isZero();
}
}
@@ -175,7 +201,11 @@ void aRowHoldingAComposedCellIsLeftAsItWas() throws Exception {
DocumentTableCell.node(new ParagraphBuilder().text("Composed").textStyle(poppins(8))
.margin(DocumentInsets.zero()).build()).withStyle(style(poppins(8),
DocumentTableTextAnchor.CENTER)))))) {
- assertThat(margins(document.getTables().get(0).getRow(0).getCell(0))).containsExactly(PADDING, PADDING);
+ XWPFTableCell text = document.getTables().get(0).getRow(0).getCell(0);
+
+ assertThat(margins(text)).containsExactly(PADDING, PADDING);
+ assertThat(position(text)).as("the text cell moved by its position instead")
+ .isEqualTo(Math.round((0.8 * line(text) - POPPINS_ASCENT * 8) * 2));
}
}
@@ -198,7 +228,10 @@ void aRaiseTakesNoMoreThanTheTopMarginHolds() throws Exception {
.rowCells(DocumentTableCell.text("Tight").withStyle(DocumentTableStyle.builder()
.padding(new DocumentInsets(0.25, 4, 4, 4)).stroke(DocumentStroke.of(DocumentColor.BLACK, 0))
.textStyle(poppins(8)).textAnchor(DocumentTableTextAnchor.CENTER).build()))))) {
- assertThat(margins(document.getTables().get(0).getRow(0).getCell(0))).containsExactly(0L, PADDING + 5);
+ XWPFTableCell cell = document.getTables().get(0).getRow(0).getCell(0);
+
+ assertThat(margins(cell)).containsExactly(0L, PADDING + 5);
+ assertThat(position(cell)).as("the third of a point left is under half a point").isZero();
}
}
@@ -224,7 +257,8 @@ void aMoveUnderATenthOfAPointIsLeftAsItWas() throws Exception {
XWPFTableCell cell = document.getTables().get(0).getRow(0).getCell(0);
double below = 0.8 * line(cell) - GOTHIC_A1_ASCENT * 14;
- assertThat(below).as("the premise: Word sets Gothic A1 low by a twip and more, under a tenth")
+ assertThat(below).as("the premise: Word sets Gothic A1 low by half a twip and more, which rounds to a "
+ + "twip, under a tenth")
.isBetween(0.025, 0.1);
assertThat(margins(cell)).containsExactly(PADDING, PADDING);
}
@@ -256,6 +290,13 @@ private static double line(XWPFTableCell cell) {
return DocxTwips.of(cell.getParagraphs().get(0).getCTP().getPPr().getSpacing().getLine()) / 20.0;
}
+ /** The {@code w:position} of a cell's first run, in half points; 0 for none. */
+ private static long position(XWPFTableCell cell) {
+ var properties = cell.getParagraphs().get(0).getCTP().getRArray(0).getRPr();
+ return properties == null || properties.sizeOfPositionArray() == 0 ? 0
+ : ((Number) properties.getPositionArray(0).getVal()).longValue();
+ }
+
/** A cell's top and bottom margins, in twips. */
private static long[] margins(XWPFTableCell cell) {
CTTcMar mar = cell.getCTTc().getTcPr().getTcMar();
diff --git a/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxLineSurplusTest.java b/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxLineSurplusTest.java
index d79bf1fba..d32622aa1 100644
--- a/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxLineSurplusTest.java
+++ b/render-docx/src/test/java/com/demcha/compose/document/backend/semantic/docx/DocxLineSurplusTest.java
@@ -127,6 +127,43 @@ void theSpaceBelowAParagraphOfOneSizeAddsWhatItsRoundingTakes() throws Exception
.isCloseTo(20 + shortfall - RAISE, within(0.05));
}
+ @Test
+ void aParagraphWhosePicturesGrowItsLinesOwesNothingForItsRounding() throws Exception {
+ // A picture centred on the text rises past its letters: Word is given its lines at least
+ // that tall and grows them, past what their rounding took.
+ String text = "rounded text that wraps onto many lines ".repeat(20);
+ for (double size = 8; size < 12; size += 0.05) {
+ DocumentTextStyle style = DocumentTextStyle.builder().size(size).build();
+ double icon = size * 0.9;
+ Exported exported = export(page -> page.spacing(20)
+ .addParagraph(p -> p.name("Rounded")
+ .inlineImage(com.demcha.compose.document.image.DocumentImageData.fromBytes(png()), icon, icon,
+ com.demcha.compose.document.node.InlineImageAlignment.CENTER, 0, null)
+ .inlineText(text, style))
+ .addParagraph("After"));
+ var spacing = paragraph(exported.document(), "rounded").getCTP().getPPr().getSpacing();
+ double line = DocxTwips.of(spacing.getLine()) / 20.0;
+ double page = exported.heights().get("Rounded");
+ if (spacing.getLineRule() == org.openxmlformats.schemas.wordprocessingml.x2006.main.STLineSpacingRule.AT_LEAST
+ && page - Math.round(page / line) * line > 0.15) {
+ assertThat(before(paragraph(exported.document(), "After"))).as("the gap alone")
+ .isEqualTo(400 - DocxExports.DEFAULT_LINE_RAISE);
+ return;
+ }
+ }
+ throw new AssertionError("the premise: no size from 8 to 12pt grows a rounded paragraph's lines to its picture");
+ }
+
+ private static byte[] png() {
+ try (java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream()) {
+ javax.imageio.ImageIO.write(new java.awt.image.BufferedImage(8, 8,
+ java.awt.image.BufferedImage.TYPE_INT_RGB), "png", out);
+ return out.toByteArray();
+ } catch (java.io.IOException failure) {
+ throw new IllegalStateException(failure);
+ }
+ }
+
@Test
void aSpacerOfNoHeightWithNoSpaceBelowItIsNamed() throws Exception {
Exported exported = export(page -> page.addParagraph("Above")