Skip to content

fix(layout): lay a table cell out at its width on the table grid - #392

Merged
airmang merged 1 commit into
mainfrom
fix/page-estimate-cell-width-from-the-table-grid
Oct 2, 2026
Merged

airmang merged 1 commit into
mainfrom
fix/page-estimate-cell-width-from-the-table-grid

Conversation

@airmang

@airmang airmang commented Oct 2, 2026

Copy link
Copy Markdown
Owner

바뀐 점

쪽 수 추정(실험, estimate_pages)이 표 칸의 글을 칸 자신의 폭(hp:cellSz)에서 나누던 것을 고친다. 같은 열의 칸들이 폭이 다르면, 한/글은 칸을 표 격자의 폭으로 놓는다.

  • 열은 왼쪽부터 쌓는다. 열은 그 열에서 끝나는 칸들의 '시작 + 폭' 가운데 가장 먼 곳에서 끝난다. 칸 간격(hp:tbl@cellSpacing)이 있으면 간격도 더한다.
    • 그래서 열은 그 열 낱칸 가운데 가장 넓은 것만큼 넓다.
    • 여러 열을 합친 칸이 그 열들의 합보다 넓으면, 넘침은 범위의 마지막 열에만 붙는다.
  • 칸은 첫 열의 시작부터 마지막 열의 끝까지다(간격 하나를 뺌). 다른 행 때문에 자기 폭보다 넓어질 수 있다.
    • 칸 간격이 있는 표는 간격을 넣어 쌓으면 행들이 맞물리므로, 칸은 자기 폭 그대로다.
  • 코드: _grid_widths가 표마다 칸의 격자 폭을 구한다. _table_rows가 그 폭을 _cell_row에 넘기고, 줄 캐시가 없는 칸의 줄 나눔과 행 높이를 그 폭으로 센다.
  • 변경 로그 항목을 더한다.

테스트

  • tests/test_layout_page_estimate.py의 HANCOM_PAGES에 한/글 저장본 넷을 더한다.
    • 공통 조건: 칸 선언 높이 282라 줄이 행 높이를 정한다. 10pt 함초롬바탕 '가'(972)를 쓰고, 표 뒤에 글 세 줄이 온다.
    • 한 열의 칸이 30000·32000·31000: 첫 칸의 31자가 한 줄이다(32000).
    • 대조로 모두 30000: 두 줄이다.
    • 8000|30000과 7683|30500 두 행: 둘째 칸이 둘 다 30500이라 31자가 한 줄이다. 행마다 따로 재면 두 칸 다 두 줄이 된다.
    • 10000|20000 위에 31000으로 합친 칸: 마지막 열이 21000이라 21자가 한 줄이다.
  • test_a_table_with_cell_spacing_lays_its_cells_out_at_their_own_widths: 칸 간격 198인 표와 간격 없는 대조 저장본이다.
    • 둘째 행 마지막 칸(9800)의 10자가 자기 폭에서 두 줄이다. 간격을 빼고 쌓으면 넓어져 한 줄이 된다.
    • 행 높이 합 + (행 수 + 1) × 간격이 한/글이 저장한 표 높이와 같은지 본다.
  • 고치기 전 코드에서는 앞의 셋(31자·31자·21자 저장본)이 캐시 없이 실패한다.

🤖 Generated with Claude Code

The cells of a column need not be as wide as each other (hp:cellSz). Hancom
lays a cell out on the table's grid: the columns are stacked from the left,
each ending at the farthest of its cells' starts plus their widths (and the
table's cell spacing), so a column is as wide as its widest cell of its own
and a merged cell wider than its columns widens the last of them. A cell
reaches from its first column's start to its last column's end, wider than
its own width when another row pushes those ends apart. Cell lines without
a cache are now broken, and rows measured, at that width.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@airmang
airmang merged commit 2505979 into main Oct 2, 2026
13 checks passed
@airmang
airmang deleted the fix/page-estimate-cell-width-from-the-table-grid branch October 2, 2026 19:42
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