[PR] Bug 919: Ensure clearText() produces valid XML by a dding default empty paragraph [poi]

waterWang (via GitHub) <[email protected]> Tue, 28 Jul 2026 09:07:13 -0000
Newsgroups gmane.comp.jakarta.poi.devel
Message-ID <[email protected]>
waterWang opened a new pull request, #1192:
URL: https://github.com/apache/poi/pull/1192

   ## Description
   
   When `clearText()` is called on a text shape (e.g., `XSLFTextBox`), it removes all paragraphs from the `CTTextBody`. If the shape is saved without adding new content, the resulting OOXML document is invalid because the OOXML spec requires at least one paragraph in a text body.
   
   ## Fix
   
   After clearing all paragraphs, add a default empty paragraph to ensure the XML remains valid. This allows `clearText()` to be used safely without immediately adding new content.
   
   ## Test
   
   Added `testClearTextWithEmptyParagraph()` that:
   1. Creates a slide with a text box
   2. Calls `clearText()`
   3. Saves and re-reads the presentation
   4. Verifies the shape has at least one empty paragraph
   5. Verifies the text is empty string
   
   Fixes #919


-- 
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]