Adjusting XSLFDrawing's slide shape tree scan in constructor to prevent shape ID warnings.#1187
Open
dbunner2 wants to merge 2 commits into
Open
Adjusting XSLFDrawing's slide shape tree scan in constructor to prevent shape ID warnings.#1187dbunner2 wants to merge 2 commits into
dbunner2 wants to merge 2 commits into
Conversation
…event it from reregistering every shape id it found. This will restrict the scan to only run when construting the sheet's own top-level drawing. Fixes issue apache#924.
pjfanning
reviewed
Jul 20, 2026
pjfanning
reviewed
Jul 20, 2026
pjfanning
reviewed
Jul 20, 2026
Author
|
Hi @pjfanning - Anything else I can add to this while I have some time? Just let me know. |
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.
Creating a shape directly on an XSLFGroupShape produces a misleading "shape id * has been already used" warning for every shape already on the slide, even though those IDs are valid. This happens because the XSLFDrawing constructor always scans the entire slide and re-registers every shape ID, regardless of whether it's creating the top-level drawing for the slide or a drawing for a nested group.
That extra scan isn't necessary for group drawings. By the time a group drawing is created (through createGroup() or getShapes()), the top-level drawing has already recursively scanned the entire slide, including all nested groups. Scanning again just re-registers the same IDs and causes the false warnings.
This change limits the scan to the top-level drawing only. It also adds a regression test that captures the logged output and verifies no warnings are produced for the reported scenario. Reverting the fix causes the test to fail with the original warnings. I also ran the full org.apache.poi.xslf.* test suite (231 tests) with no regressions.
Fixes #924.