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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@

### 고침

- 쪽 수 추정(실험, `estimate_pages`)이 글과 함께 움직이는 어울림(SQUARE) 그림·도형이 본문 바닥을 넘을 때, 줄 캐시가
없으면 지원 밖으로 두던 것을 고친다.
- 한/글은 그 개체를 띄움과 상관없이 다음 쪽 본문 맨 위로 옮긴다. 개체가 있던 쪽의 줄은 모두 전체 폭이다. 다음
쪽에서 줄 위가 개체 아래 끝보다 위인 줄은 개체 곁으로 간다.
- 이제 그 쪽들을 다시 놓는다. 개체 문단과 뒤 문단을 전체 폭으로 나누고, 다음 쪽 맨 위의 개체 곁에서 줄을 다시
나눈다. 그 자리에 개체·각주가 든 문단이나 표가 오면 지원 밖이다.
- 나누지 않게 둔 어울림 표도 그렇게 옮겨 간다. 나뉘는 어울림 표는 쪽 끝에서 나뉘므로 전처럼 캐시가 있을 때만
따른다.
- 문단 줄 아래로 띄워 위아래로 둔 그림·도형도, 문단이 놓인 자리에서 개체 발이 바닥을 넘으면 다음 쪽 맨 위로
옮겨 간다. 문단 줄은 제자리에 남고, 다음 쪽에서 개체에 닿는 줄은 그 아래로 간다. 캐시가 있을 때도 전에는
문단째 다음 쪽으로 보냈다.
- 양옆에 글이 가는 개체 곁의 줄은, 글이 첫 조각에서 끝나거나 글이 없어도 두 조각이다(둘째는 빈 조각). 캐시
없는 추정도 이제 그렇게 센다.
- 문단 첫 줄을 그림 아래로 밀어낸 위아래 그림은, 밀린 줄 자리에 그림 높이를 한 번 더 더해 바닥을 넘는다고 보아
지원 밖으로 두었다. 이제 밀리기 전 줄 자리에서 잰다.
- 쪽 수 추정(실험, `estimate_pages`)이 세로쓰기 칸(`hp:subList@textDirection="VERTICAL"`)의 글을 가로 글처럼
칸 폭에서 나누어 행을 키우던 것을 고친다.
- 한/글은 세로쓰기 칸의 줄을 칸 높이를 따라 세로로 놓고 옆으로 늘어놓는다. 넘치는 글은 잘리고, 행은 선언
Expand Down
203 changes: 186 additions & 17 deletions src/hwpx/layout/pages.py

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
50 changes: 39 additions & 11 deletions tests/test_layout_page_estimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,30 @@
"pages_square_band_table_as_character_among_text": 2, # a table 47058 wide
"pages_square_band_narrow_table_as_character_among_text": 1, # 5000 wide
"pages_square_band_picture_as_character_among_text": 1, # a picture 47058 x 5000
# A picture 20000 x 27112 wrapped square in the middle of the column (10 pt text spaced 160%), flowing with
# the text, its band past the body's foot: Hancom sets it alone at the next page's body top, whatever its
# offset, the lines of its own page the whole width and the lines on the next page whose top is above its
# foot beside it, in two pieces:
"pages_square_picture_moved_to_the_next_page": 2, # short lines beside it there, each ending in its first
# piece: the second one empty
"pages_square_picture_moved_text_going_on_beside_it": 3, # a paragraph going on to the next page
"pages_square_picture_moved_at_the_left": 3, # at the column's left: the lines one piece on its right
"pages_square_picture_moved_its_paragraph_going_on": 2, # its own paragraph going on beside it
"pages_square_picture_moved_from_8000_down": 3, # placed 8000 down from its paragraph: at the top too
"pages_square_table_not_split_moved_to_the_next_page": 3, # a table of six rows at the column's left,
# set not to split: the same
"pages_picture_1319_down_moved_to_the_next_page": 3, # a picture 8000 tall placed top and bottom 1319
# below its empty paragraph's line: alone at the
# next page's top, the line staying, the lines
# there reaching it below it
"pages_picture_pushing_its_first_line_above_the_foot": 2, # a picture 30000 tall 1319 below a paragraph of
# 14 pt text: its line goes below the picture,
# which ends above the foot, and stays there
"pages_square_picture_above_the_foot_short_lines_beside_it": 2, # its band above the foot: short lines
# beside it in two pieces
"pages_square_picture_staying_short_lines_beside_it": 2, # not flowing with the text, it stays on its
# page: the empty line of its paragraph and
# short lines beside it, in two pieces
"pages_square_band_table_as_character_below_a_short_band": 1, # the picture 5000 tall: the table's line
# comes after the band anyway
"pages_fixed_width_spaces": 2, # rows of a syllable and a fixed-width space: a quarter em that hangs
Expand Down Expand Up @@ -1173,23 +1197,27 @@ def test_a_page_break_in_a_row_holding_a_table_beside_a_taller_cell_is_unsupport


@pytest.mark.parametrize(
"name",
("name", "followed"),
[
"pages_picture_square_past_the_page_foot", # its paragraph's three lines the page's last
"pages_picture_square_past_the_page_foot_mid_paragraph", # its paragraph's first line the page's last
"pages_table_square_past_the_page_foot", # a table wrapped square alone in its paragraph
("pages_picture_square_past_the_page_foot", True), # its paragraph's three lines the page's last
("pages_picture_square_past_the_page_foot_mid_paragraph", True), # its first line the page's last
("pages_table_square_past_the_page_foot", False), # a table wrapped square alone in its paragraph
],
)
def test_a_square_object_past_the_page_foot_moves_no_line_keeping_its_cache(name: str) -> None:
# A picture or table wrapped square from its paragraph's top, 8000 tall, its band past the body's
# foot: Hancom sets it alone at the next page's top, the lines beside it there narrower and the lines
# left above the foot as wide as the column. It takes no line's height, so the lines keeping their
# caches stay where the caches put them; without the caches, where each line breaks is not followed.
def test_a_square_object_past_the_page_foot_goes_on_at_the_next_page(name: str, followed: bool) -> None:
# A picture wrapped square from its paragraph's top, 8000 tall, its band past the body's foot: Hancom
# sets it alone at the next page's top, the lines beside it there narrower and the lines left above the
# foot as wide as the column. With the caches the lines stay where the caches put them; without them
# they are broken again beside it there. A table wrapped square is split over the page end instead, its
# band going on at the next page's top: not followed without the caches.
data = (FIXTURES / f"{name}.hwpx").read_bytes()

_assert_like_hancom(estimate_pages(data), data, 2)
assert estimate_pages(_without_caches(data)).unsupported == (
"section 0: a square-wrapped or offset top-and-bottom object past the page foot",)
if followed:
_assert_like_hancom(estimate_pages(_without_caches(data)), data, 2)
else:
assert estimate_pages(_without_caches(data)).unsupported == (
"section 0: a square-wrapped or offset top-and-bottom object past the page foot",)


def test_a_top_and_bottom_table_not_split_offset_past_the_page_foot_is_unsupported() -> None:
Expand Down
Loading