Place bottom tables at the page bottom
This commit is contained in:
1 parent
6658a155fc
commit
e7bcdf6c53
5 files changed
+117
-12
No files matched your search
@@ -1927,6 +1927,77 @@ pub(super) fn build_positioned_pages(
|
||||
let total_height = caption_height
|
||||
.saturating_add(caption_gap)
|
||||
.saturating_add(table_height);
|
||||
let table_bottom = placement.contains('b')
|
||||
&& !placement.contains('h')
|
||||
&& !placement.contains('t')
|
||||
&& !placement.contains('p')
|
||||
&& pages.last().is_some_and(|page| !page.items.is_empty())
|
||||
&& total_height <= page_goal;
|
||||
if table_bottom {
|
||||
let Some(table) = table else {
|
||||
return None;
|
||||
};
|
||||
let mut y = page_goal.saturating_sub(total_height);
|
||||
for line in caption_lines {
|
||||
pages
|
||||
.last_mut()
|
||||
.expect("the page list starts with one page")
|
||||
.items
|
||||
.push(PositionedPageItem::Line(PositionedLine {
|
||||
anchor: PageAnchor {
|
||||
block: block_index,
|
||||
line: 0,
|
||||
},
|
||||
content: line.content,
|
||||
y,
|
||||
x: 0,
|
||||
centered: true,
|
||||
ragged: false,
|
||||
}));
|
||||
y = y.saturating_add(line.height);
|
||||
}
|
||||
if caption_height > 0 {
|
||||
y = y.saturating_add(caption_gap);
|
||||
}
|
||||
let PositionedTable {
|
||||
rows: table_rows,
|
||||
column_count,
|
||||
rules: table_rules,
|
||||
..
|
||||
} = table;
|
||||
for (row_index, row) in table_rows.into_iter().enumerate() {
|
||||
let row_height = row.height;
|
||||
let mut row_rules = HashSet::new();
|
||||
if row_index == 0 && table_rules.contains(&0) {
|
||||
row_rules.insert(0);
|
||||
}
|
||||
if table_rules.contains(&(row_index + 1)) {
|
||||
row_rules.insert(1);
|
||||
}
|
||||
pages
|
||||
.last_mut()
|
||||
.expect("the page list starts with one page")
|
||||
.items
|
||||
.push(PositionedPageItem::Table {
|
||||
anchor: PageAnchor {
|
||||
block: block_index,
|
||||
line: 0,
|
||||
},
|
||||
element: PositionedTable {
|
||||
rows: vec![row],
|
||||
column_count,
|
||||
rules: row_rules,
|
||||
height: row_height,
|
||||
},
|
||||
y,
|
||||
});
|
||||
y = y.saturating_add(row_height);
|
||||
}
|
||||
cursor = page_goal;
|
||||
pending_gap = paragraph_gap + (normal_line_height as f64 * 0.15).round() as i64;
|
||||
has_previous_block = true;
|
||||
continue;
|
||||
}
|
||||
let table_top = placement.contains('t')
|
||||
&& !placement.contains('h')
|
||||
&& !placement.contains('p')
|
||||
|
||||
Reference in new issue
Block a user