Skip to content

fix(layout): split rows joined by merged cells again at every page end - #364

Merged
airmang merged 4 commits into
mainfrom
feat/page-estimate-joined-rows-over-several-pages
Oct 1, 2026
Merged

airmang merged 4 commits into
mainfrom
feat/page-estimate-joined-rows-over-several-pages

Conversation

@airmang

@airmang airmang commented Oct 1, 2026

Copy link
Copy Markdown
Owner

바뀐 점

쪽 수 추정(실험, estimate_pages)이 칸 단위로 나누는 흐르는 표(pageBreak="CELL")에서, 병합 칸으로 이어진 행들이 한 번 나눈 뒤에도 한 쪽보다 길면 쪽 끝마다 다시 나눈다.

  • 전에는 그런 행들을 지원 밖(rows merged together taller than a page)으로 두었다.
  • 한/글은 쪽 끝마다 다시 나눈다.
    • 칸마다 그 쪽에 들어가는 줄까지 두고, 나머지는 다음 쪽 머리 행 아래로 넘긴다. 넘긴 부분이 다시 쪽보다 길면 그 쪽 끝에서 또 나눈다.
    • 행들보다 긴 병합 칸은 행이 끝난 뒤에도 혼자 다음 쪽들로 이어진다.
    • 글보다 높게 선언된 칸의 남는 높이는 쪽 끝마다 행처럼 잘려 이어진다. 글을 다 둔 뒤에도 그렇다.
  • 줄 사이에서 나뉜 선언 칸의 다음 쪽 부분은 둘 가운데 큰 쪽이다: 선언 높이의 나머지, 이어지는 줄에 칸 위아래 여백을 더한 높이. 이어지는 줄이 있으면 나머지가 낮아도 버리지 않는다. 전에는 선언 높이의 나머지만 셌고, 줄이 남아 있어도 한 줄 높이 이하의 나머지는 버렸다. 행 하나짜리에서 한/글이 하는 것과 같다.
  • 코드
    • _split_block이 이것을 쪽마다 되풀이한다.
    • _block_rest는 다음 쪽으로 가는 것(행마다 높이, 남은 줄을 가진 칸)을 돌려준다.
    • _cell_rest가 칸 하나의 나머지를 잰다.
  • 어느 쪽에도 한 줄도 들어가지 않는 칸만 전처럼 지원 밖이다.
  • 모듈 설명과 변경 로그를 고친다.

테스트

  • tests/test_layout_page_estimate.py에 한/글 저장본 열을 더한다. 아홉은 HANCOM_PAGES에 넣는다.
    • 쪽보다 긴 묶음 다섯
      • 병합 칸 하나로 묶인 한 줄 행 100개: 3쪽
      • 그런 행 60개와 150줄 병합 칸: 4쪽, 칸이 마지막 두 쪽에 혼자 이어짐
      • 한 줄·세 줄 행이 섞인 묶음: 3쪽, 행 하나가 줄 사이에서 나뉨
      • 80000으로 선언된 병합 칸이 묶은 8행: 3쪽
      • 75000으로 선언된 빈 병합 칸이 묶은 8행: 3쪽
    • 선언 칸이 쪽 끝에서 나뉘는 넷(1~5행을 묶은 4줄 병합 칸)
      • 1행에서 나뉨: 이어지는 줄과 여백이 선언 나머지보다 높음
      • 2행에서 나뉨: 선언 나머지가 더 높음
      • 3행 첫 줄 앞에서 나뉨: 칸이 통째로 다음 쪽
      • 행들이 글 높이만큼일 때 1행에서 나뉨
    • 캐시가 있을 때와 없을 때 모두 줄 위치와 쪽 수가 한/글과 같다.
  • '150000으로 선언된 병합 칸은 지원 밖'이던 기존 테스트를 바꾼다.
    • 같은 문서를 한/글이 배치해 저장한 판(pages_joined_rows_over_pages_declared_150000)을 읽는다.
    • 캐시가 있을 때와 없을 때 모두 4쪽이고, 줄 위치가 한/글과 같은지 본다.
    • 표가 문서 끝이라 마지막 쪽에 본문 줄이 없다. 그래서 HANCOM_PAGES가 아니라 따로 된 테스트로 둔다.
  • 고치기 전 코드에서는 새 테스트 열둘과 바꾼 테스트가 실패한다. 열둘은 앞 다섯과 1행에서 나뉘는 판의 캐시 있음·없음이다. 나머지 세 저장본은 고치기 전에도 결과가 같고, 그 결과를 고정한다.

🤖 Generated with Claude Code

airmang and others added 4 commits October 1, 2026 22:23
In a flowing table split between cell lines, rows joined by a cell
merged over them that stayed taller than a page after one split were
refused. Hancom splits them again at each page end: every cell keeps
the lines that fit on the page and the rest goes on below the next
page's header rows, and a merged cell longer than its rows goes on
alone after they end. The room a cell is declared beyond its text is
cut at each page end like a row's, also once its text is all placed.
_split_block now does that page after page; _block_rest returns what
goes on (each row's height and each cell with the lines it has left)
and _cell_rest measures one cell's rest. Only a cell no line of which
fits a page is still refused.

Five Hancom-saved fixtures: 100 one-line rows joined by a cell merged
down all of them (three pages), 60 rows with a merged cell of 150
lines (four pages, the cell going on alone), rows of one and three
lines (a row split between its lines), and eight rows joined by a cell
declared 80000 tall, and by an empty one declared 75000 tall.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… tall as they are

When rows joined by a merged cell split between their lines and a cell declared taller than its text breaks
at the page end, the part going on was its declared rest alone, and a rest no taller than a line was dropped
even with lines still to go. Hancom makes that part as tall as the larger of the declared rest and the lines
going on with the cell's margins, as it already does for a row of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…om's saved layout

The test of a cell merged over four rows and declared 150000 tall built its document and checked only the page count. It now reads the same document laid out and saved by Hancom, with and without its line caches: four pages, the cell's room cut at each page end, and the lines where Hancom put them. The table ends the document, so no line is on its last page and the HANCOM_PAGES helper does not apply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@airmang
airmang merged commit 1c17ad7 into main Oct 1, 2026
13 checks passed
@airmang
airmang deleted the feat/page-estimate-joined-rows-over-several-pages branch October 1, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant