1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 00:21:15 +03:00

table-break: WIP page-breaks inside tables

This commit is contained in:
Priit Laes 2012-03-16 20:00:02 +02:00
parent b29ada1515
commit 3e2eb91341
2 changed files with 25 additions and 8 deletions

View File

@ -41,8 +41,8 @@ def block_level_layout(document, box, max_position_y, skip_stack,
"""
if isinstance(box, boxes.TableBox):
return table_layout(document, box, max_position_y, containing_block,
device_size, page_is_empty)
return table_layout(document, box, max_position_y, skip_stack,
containing_block, device_size, page_is_empty)
elif isinstance(box, boxes.BlockBox):
if box.is_table_wrapper:
return block_table_wrapper(document, box, max_position_y,

View File

@ -29,8 +29,8 @@ from ..formatting_structure import boxes
from .percentages import resolve_percentages, resolve_one_percentage
def table_layout(document, table, max_position_y, containing_block,
device_size, page_is_empty):
def table_layout(document, table, max_position_y, skip_stack,
containing_block, device_size, page_is_empty):
"""Layout for a table box.
For now only the fixed layout and separate border model are supported.
@ -52,6 +52,13 @@ def table_layout(document, table, max_position_y, containing_block,
position_x += width
rows_width = position_x - rows_x
if skip_stack is None:
skip = 0
else:
skip, skip_stack = skip_stack
resume_at = None
# Layout for row groups, rows and cells
position_y = table.content_box_y() + border_spacing_y
initial_position_y = position_y
@ -64,7 +71,8 @@ def table_layout(document, table, max_position_y, containing_block,
new_group_children = []
# For each rows, cells for which this is the last row (with rowspan)
ending_cells_by_row = [[] for row in group.children]
for row in group.children:
force_page_break = False
for index, row in group.enumerate_skip(skip):
resolve_percentages(row, containing_block=table)
row.position_x = rows_x
row.position_y = position_y
@ -163,7 +171,13 @@ def table_layout(document, table, max_position_y, containing_block,
else:
cell.padding_bottom += extra
position_y += row.height + border_spacing_y
cur_pos_y = position_y + row.height + border_spacing_y
# Check whether we should handle page-break
if cur_pos_y > max_position_y:
force_page_break = True
break
position_y = cur_pos_y
group = group.copy_with_children(new_group_children)
new_table_children.append(group)
@ -182,6 +196,11 @@ def table_layout(document, table, max_position_y, containing_block,
if group.children:
# The last border spacing is outside of the group.
group.height -= border_spacing_y
if force_page_break:
resume_at = (index, row)
break
table = table.copy_with_children(new_table_children)
# If the height property has a bigger value, just add blank space
@ -210,13 +229,11 @@ def table_layout(document, table, max_position_y, containing_block,
group.width = last.position_x + last.width - first.position_x
group.height = columns_height
if ((table.position_y + table.margin_height()) > max_position_y
and not page_is_empty):
# If the table does not fit, put it on the next page.
# (No page break inside tables yet.)
table = None
resume_at = None
next_page = 'any'
adjoining_margins = []
collapsing_through = False