This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git


The following commit(s) were added to refs/heads/trunk by this push:
     new ebad7593ff Return unmodifiable lists from XWPFRun charts and pictures. 
(#862)
ebad7593ff is described below

commit ebad7593ff17608c94dd8c6ad862c892a0df9302
Author: Jacobo Aragunde PĂ©rez <[email protected]>
AuthorDate: Fri Jul 25 09:48:05 2025 +0200

    Return unmodifiable lists from XWPFRun charts and pictures. (#862)
    
    The operations XWPFRun.getEmbedded[Pictures|Charts]().add() are not
    supported. Users must call XWPFRun.add[Picture|Chart]() instead.
    
    This change will make the fact more explicit, with an error when they
    attempt to use the wrong operation.
---
 poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java 
b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
index 77819ff37e..eb159bfeed 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
@@ -26,6 +26,7 @@ import java.math.BigInteger;
 import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import javax.xml.namespace.QName;
@@ -1418,7 +1419,7 @@ public class XWPFRun implements ISDTContents, 
IRunElement, CharacterRun {
      * embedded picture image such as a .png or .jpg
      */
     public List<XWPFPicture> getEmbeddedPictures() {
-        return pictures;
+        return Collections.unmodifiableList(pictures);
     }
 
     /**
@@ -1842,6 +1843,6 @@ public class XWPFRun implements ISDTContents, 
IRunElement, CharacterRun {
      * @since POI 5.4.2
      */
     public List<XWPFChart> getEmbeddedCharts() {
-        return charts;
+        return Collections.unmodifiableList(charts);
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to