Author: fanningpj
Date: Tue Apr 14 09:06:56 2020
New Revision: 1876487

URL: http://svn.apache.org/viewvc?rev=1876487&view=rev
Log:
[bug-64348] partial fix for IndexOutOfBoundsException

Modified:
    
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java

Modified: 
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java?rev=1876487&r1=1876486&r2=1876487&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java 
(original)
+++ 
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java 
Tue Apr 14 09:06:56 2020
@@ -425,8 +425,16 @@ public class XWPFHeaderFooterPolicy {
      */
     private XWPFParagraph getWatermarkParagraph(String text, int idx) {
         CTP p = CTP.Factory.newInstance();
-        byte[] rsidr = doc.getDocument().getBody().getPArray(0).getRsidR();
-        byte[] rsidrdefault = 
doc.getDocument().getBody().getPArray(0).getRsidRDefault();
+        CTBody ctBody = doc.getDocument().getBody();
+        byte[] rsidr = null;
+        byte[] rsidrdefault = null;
+        if (ctBody.sizeOfPArray() == 0) {
+            // TODO generate rsidr and rsidrdefault
+        } else {
+            CTP ctp = ctBody.getPArray(0);
+            rsidr = ctp.getRsidR();
+            rsidrdefault = ctp.getRsidRDefault();
+        }
         p.setRsidP(rsidr);
         p.setRsidRDefault(rsidrdefault);
         CTPPr pPr = p.addNewPPr();



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org
For additional commands, e-mail: commits-h...@poi.apache.org

Reply via email to