fix: a DOCX text box keeps the height it declares

The shape body wrote spAutoFit, which LibreOffice reads as min-height 0
and then draws the box's text detached from the shape, over whatever
follows it — measured on a 90px box: the frame collapsed to one line and
its text landed 22pt below it, on the next paragraph. noAutofit is what
LibreOffice writes for the same frame; with it the text sits inside the
box at its declared height. Content taller than that is clipped, DOCX
having no fo:min-height for the ODF leg's auto-grow.
This commit is contained in:
Steffen Becker committed 2026-09-04 19:30:01 +02:00
1 parent 6081a85626
commit 21999afbc6
3 files changed
+22 -3

No files matched your search

+4 -2
View File
@@ -1225,8 +1225,10 @@ function textBoxDrawingXml(box: TextBoxDocx, index: number, parts: TxbxParts): s
? `<a:ln w="${Math.round(box.strokeWidthPt * EMU_PER_PT)}"><a:solidFill><a:srgbClr val="${hexColor(box.stroke) ?? '000000'}"/></a:solidFill>${ends}</a:ln>`
: '<a:ln><a:noFill/></a:ln>';
const inset = Math.round(TEXTBOX_PADDING_CM * EMU_PER_CM);
// Auto-grow only for plain text boxes, matching the ODT export.
const autofit = box.shapeKind === 'textbox' && !box.shapePath ? '<a:spAutoFit/>' : '';
// The box keeps the height it declares — LibreOffice's own DOCX export writes this for
// the same frame, and read as spAutoFit it lays the text out detached from the shape
// (probed: the text lands in the body, over whatever follows).
const autofit = '<a:noAutofit/>';
// A freeform is its own outline: custGeom over the same 0…100 box, in the shape's
// own EMU extent so the path needs no second scale.
const geom = box.shapePath