ybg163yx opened a new pull request, #981:
URL: https://github.com/apache/poi/pull/981
### What changed
Fixes an inconsistency between `bodyElements` and `paragraphs` caused by
`XWPFDocument#setParagraph`.
### Why
Since **REL_5_5_1**, `setParagraph` updates the underlying XML by copying
paragraph contents via XMLBeans, while the Java-side `paragraphs` list was
updated by directly replacing the element reference.
This mismatch can lead to an inconsistent internal state, causing
`getParagraphPos` to return `-1` and breaking `removeBodyElement`.
### How
- Update the XML representation using `CTBody#setPArray`
- Re-align the `paragraphs` list with the paragraph instance stored in
`bodyElements`, which is created from the updated XML
- Ensure both internal collections remain consistent after calling
`setParagraph`
### Tests
- Verified locally using a DOCX file that fails starting from REL_5_5_1
### Issue
This PR fixes **POI-980**.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]