Skip to content

fix(oxml): keep pictures added after add_section in the manifest - #551

Merged
airmang merged 1 commit into
mainfrom
fix/manifest-after-add-section
Oct 23, 2026
Merged

airmang merged 1 commit into
mainfrom
fix/manifest-after-add-section

Conversation

@airmang

@airmang airmang commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Fixes #549.

What was wrong

HwpxOxmlDocument kept the content.hpf tree it read when the document opened. add_image()/add_picture() add their <opf:item> through the package (add_manifest_item → _persist_manifest → set_part), and the package drops its cached tree on every write to content.hpf and reads it again next time. After the first picture the two trees were different objects. Once add_section() had marked the document's tree dirty, saving wrote that older tree over the package's, so every picture item after the first was lost (and a .hwp save kept only the first picture).

Fix

The document no longer holds its own copy: when it comes from a package, _manifest reads package.manifest_tree(), so add_section(), master pages and add_image() all edit the same current tree.

Tests

test_pictures_added_around_add_section_all_reach_the_manifest covers the three cases in the issue plus a save and a validate() between edits; all four fail on main and pass here. The rest of the suite is unchanged against main.

🤖 Generated with Claude Code

The document kept the content.hpf tree it read at open, while add_image
writes its item through the package, which reads the manifest again after
every write. Once add_section had marked the document's tree dirty, saving
wrote that older tree over the package's and dropped every picture item
but the first. The document now reads the package's current manifest tree.

Fixes #549

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@airmang
airmang merged commit c69a69b into main Oct 23, 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.

[Bug] add_section() 뒤에 넣은 그림이 content.hpf 매니페스트에서 빠진다(첫 그림만 등록)

1 participant