Skip to content

fix(oxml): move a table's height with the rows a structure edit adds or drops - #534

Merged
airmang merged 1 commit into
mainfrom
fix/table-structure-edits-keep-table-height
Oct 20, 2026
Merged

airmang merged 1 commit into
mainfrom
fix/table-structure-edits-keep-table-height

Conversation

@airmang

@airmang airmang commented Oct 20, 2026

Copy link
Copy Markdown
Owner

무엇을 고쳤나

한/글은 표 높이(hp:tbl/hp:sz@height)를 배치한 행 높이의 합으로 저장한다. 그런데 표 객체의 구조 편집(doc.tables.insert_rows·delete_rows·insert_columns·delete_columns·split_cell)은 편집 전 높이를 그대로 남겼다. 행 병합 칸이 있는 표는 칸 문단의 줄 배치 정보가 모두 남아 있으면 쪽 수 추정이 그 저장된 높이를 쓰므로(_inline_table_height), 행을 넣은 표 아래 문단을 넣은 행 높이만큼 위에 두었다.

  • 구조 편집(TableStructureEdits._restructure)이 편집 전후 행 높이(쪽 수 추정의 행 모형 _rows_height)의 차이만큼 hp:sz 높이를 옮긴다. 건드리지 않은 행은 한/글이 준 높이를 그대로 둔다(저장된 높이에 차이만 더한다).
  • 행 모형이 표를 따르지 못하면(추정이 지원하지 않는 표) 높이는 전처럼 둔다.
  • hwpx.table_patch.apply_table_ops(바이트 경로)의 같은 편집은 아직 높이를 옮기지 않는다. 후속으로 남긴다.

시험

  • test_object_edits_make_what_hancom_makes: 한/글이 직접 행·열을 넣고 셀을 나눈 기존 픽스처와 표 높이(hp:sz@height)도 같은지 본다.
  • 새 test_a_row_edit_leaves_the_table_as_tall_as_hancom_lays_it_out: 한/글 저장 픽스처 table_structure_merged_rows_base(합성: 평평한 표, 행 병합 표, 기준 행을 가로지르는 병합, 석 줄 칸, 위아래 배치 표 등 7개)의 표마다 1행 아래(위)에 행을 넣고, 한/글이 같은 편집본을 저장한 table_structure_merged_rows_below1(above1)과 표 높이·본문 줄 위치(쪽 수 추정)가 같은지 본다.
  • 고치기 전에는 9개가 실패한다.
  • 전체 시험 통과(이 PC의 심볼릭 링크·설치 휠 관련 기존 실패만 남음), ruff·mypy·pyright 통과.

CHANGELOG.md [Unreleased]/고침 맨 위에 항목 하나.

🤖 Generated with Claude Code

…or drops

Hancom saves a table's height (hp:sz) as the height of the rows it lays
out. Row and column insertion and deletion and cell splits on the table
object kept the height the table had before the edit, so a table with
merged rows -- whose saved height the page estimate takes while its
cells keep their line caches -- had the paragraphs under it as far up
as the rows inserted.

The edit now moves the saved height by what its rows gained or lost as
the page estimate measures them, the rows left as they were keeping the
height Hancom gave them. Hancom-saved fixtures: seven tables (flat,
merged over rows, a cell of three lines, one placed top and bottom)
before and after a row inserted below and above row 1; the existing
row, column and split fixtures now also match Hancom's table height.
The same edits of apply_table_ops still keep the height.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@airmang
airmang force-pushed the fix/table-structure-edits-keep-table-height branch from 2b7250c to 87dd686 Compare October 20, 2026 08:09
@airmang
airmang merged commit aa57a21 into main Oct 20, 2026
13 checks passed
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