Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
- 한/글은 공백과 머리표·번호도 글로 본다. 그 줄을 개체 아래에 전체 폭으로 두고, 다음 문단은 그 줄 아래에 둔다.
- 공백도 머리도 없을 때만 줄을 개체 윗선에 폭 0으로 둔다.
- 공백은 본문과 표 칸 모두, 머리표·번호는 본문에서 따른다.
- 공백만 있는 한 줄 문단의 표가 그 자리에서 시작하지 못하면 표 혼자인 문단처럼 놓는다. 표는 다음 쪽 맨
위에서 시작하고, 문단 줄은 제자리에 남으며, 뒤 글은 그 줄 아래에 이어진다. 나누지 않게 둔 표도 같다.
- 쪽 수 추정(실험, `estimate_pages`)이 줄 캐시 없는 표 칸에서 위아래 배치 표 하나가 든 문단을 지원 밖
(`a nested table`)으로 두던 것을 고친다. 이제 그림·도형처럼 칸이 그 표의 아래 끝(행으로 잰 표 높이와 바깥 여백)까지
닿고, 칸의 다음 줄은 그 아래에서 이어진다. 위로 띄운 표는 문단 윗선에 선다. 그런 행이 쪽을 넘어 줄 사이에서
Expand Down
8 changes: 8 additions & 0 deletions src/hwpx/layout/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,9 @@ class _Para:
hides: bool = False
#: its lines are Hancom's own, from the paragraph's valid layout cache
kept: bool = False
#: an object anchored in this paragraph holding nothing else but spaces on one line: a table of it starting
#: on the next page goes there as when the paragraph holds it alone, the paragraph's line staying
spaced: bool = False
#: the top-and-bottom objects stacked in this paragraph, which holds nothing else (see :func:`_stack`)
stack: tuple[_Stacked, ...] = ()
#: a square-wrapped object anchored here and flowing with the text went past the body's foot: Hancom sets
Expand Down Expand Up @@ -1905,6 +1908,8 @@ def _paragraph(measure: _Measure, page: _Page, paragraph: Any, wrap: _Wrap | Non
paragraph.get("pageBreak") == "1",
paragraph.get("columnBreak") == "1", table, notes, cached, anchor, wrap_anchor=around,
hides=page.hide_empty and _holds_nothing(runs))
if anchored is not None and text and not text.strip(" ") and para.lines == 1:
para = replace(para, spaced=True)
if reflow and text:
again = _Reflow(measure, text, tuple(sizes), None if looks is None else tuple(looks), style, shape)
return again.at(para, page.column_width, 0)
Expand Down Expand Up @@ -2779,6 +2784,9 @@ def _anchored(self, index: int, paras: list[_Para], para: _Para, start: int) ->
if anchor.table is not None:
table = anchor.table
later = _starts_later(table, top + table.above, self.body)
if later and para.spaced and not head.lines: # spaces only: as the table alone in its paragraph
self._flow(replace(para, anchor=None, table=table), table, start)
return
if table.mode == "NONE" and not head.lines and top != self.reserved.get(self.frame, 0) + para.prev \
and (later or top + table.above + sum(row.height for row in table.rows) + table.below
+ tail.height(0) > self.body): # set not to split: it goes on with the line below it
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/test_layout_page_estimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@
"pages_picture_alone_in_a_bulleted_paragraph": 1, # a bullet is text: the line under the picture
"pages_picture_alone_in_a_numbered_paragraph": 1, # so is a number
"pages_table_alone_in_a_bulleted_paragraph": 1,
# The same 60762 down (10 pt text spaced 160%), the table (rows 8000, 1282 and 1282 tall) not starting
# there: it starts at the next page's top, the paragraph's line staying, a space after the table or not,
# and the text after goes on under that line.
"pages_table_then_nothing_starting_on_the_next_page": 2,
"pages_table_then_a_space_starting_on_the_next_page": 2,
"pages_table_not_split_then_a_space_starting_on_the_next_page": 2, # set not to split: the same
# A cell of a flowing table, a picture 20000 x 10000 placed top and bottom from a paragraph of it:
"pages_table_cell_picture_first": 1, # alone in the first: the line on its top, the row as tall as it
"pages_table_cell_picture_second": 1, # alone in the second, after a line: from that paragraph's top
Expand Down
Loading