Repository navigation
fix(oxml): keep pictures added after add_section in the manifest - #551
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #549.
What was wrong
HwpxOxmlDocumentkept thecontent.hpftree 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 tocontent.hpfand reads it again next time. After the first picture the two trees were different objects. Onceadd_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.hwpsave kept only the first picture).Fix
The document no longer holds its own copy: when it comes from a package,
_manifestreadspackage.manifest_tree(), soadd_section(), master pages andadd_image()all edit the same current tree.Tests
test_pictures_added_around_add_section_all_reach_the_manifestcovers the three cases in the issue plus a save and avalidate()between edits; all four fail onmainand pass here. The rest of the suite is unchanged againstmain.🤖 Generated with Claude Code