fix: a table aligned to the margins fills the text width
ODF's table:align="margins" means the table spans between its own margins, and style:width is then the width the producing page had. Read as a left-aligned table, the undeclared right margin was derived from that width against ours and the table came out narrow — measured 12.4cm on a 14.7cm text width, its column rule 10.4mm left of where LibreOffice draws it.
This commit is contained in:
1 parent
ab8b887889
commit
784dd5e06f
2 files changed
+61
-1
No files matched your search
@@ -2881,8 +2881,12 @@ function tableMargins(el: Element, ctx: Ctx): { marginLeft?: number; marginRight
|
||||
|
||||
let left = lengthToCm(props['fo:margin-left']);
|
||||
let right = lengthToCm(props['fo:margin-right']);
|
||||
const align = props['table:align'];
|
||||
// "margins" is ODF for a table filling the space between its own: the side it does
|
||||
// not declare is 0, and style:width is the width the producer's page had, not one to
|
||||
// measure a margin against.
|
||||
if (align === 'margins') { left ??= 0; right ??= 0; }
|
||||
if (left == null && width != null) {
|
||||
const align = props['table:align'];
|
||||
left = align === 'center' ? (content - width) / 2 : align === 'right' ? content - width : 0;
|
||||
}
|
||||
left = left ?? 0; // negative is real: a table may hang into the page margin
|
||||
|
||||
Reference in new issue
Block a user