poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From talli...@apache.org
Subject svn commit: r1768048 - in /poi: site/src/documentation/content/xdocs/status.xml trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFSDT.java trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFSDT.java
Date Fri, 04 Nov 2016 15:06:17 GMT
Author: tallison
Date: Fri Nov  4 15:06:17 2016
New Revision: 1768048

URL: http://svn.apache.org/viewvc?rev=1768048&view=rev
Log:
POI-60341: handle missing sdtpr in an sdtbody

Modified:
    poi/site/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFSDT.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFSDT.java

Modified: poi/site/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/status.xml?rev=1768048&r1=1768047&r2=1768048&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.xml (original)
+++ poi/site/src/documentation/content/xdocs/status.xml Fri Nov  4 15:06:17 2016
@@ -63,6 +63,7 @@
         <summary-item>Improve support for reading VBA macros</summary-item>
       </summary>
       <actions>
+        <action dev="PD" type="fix" fixes-bug="60341" module="XWPF">Handle an SdtBody
that has no SdtPr</action>
         <action dev="PD" type="add" module="SS Common">CellStyle support for "Quote
Prefix" aka "123 Prefix"</action>
         <action dev="PD" type="fix" fixes-bug="60320" module="POIFS">Issue opening
password protected xlsx</action>
       	<action dev="PD" type="fix" fixes-bug="57366" breaks-compatibility="true" module="XWPF">Refactor
Header/Footer creation to allow table in header/footer. No longer creates empty paragraph
in header/footer.</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFSDT.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFSDT.java?rev=1768048&r1=1768047&r2=1768048&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFSDT.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFSDT.java Fri Nov  4
15:06:17 2016
@@ -1,18 +1,18 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
 ==================================================================== */
 package org.apache.poi.xwpf.usermodel;
 
@@ -33,18 +33,22 @@ public abstract class AbstractXWPFSDT im
     private final IBody part;
 
     public AbstractXWPFSDT(CTSdtPr pr, IBody part) {
-
-        CTString[] aliases = pr.getAliasArray();
-        if (aliases != null && aliases.length > 0) {
-            title = aliases[0].getVal();
-        } else {
+        if (pr == null) {
             title = "";
-        }
-        CTString[] tags = pr.getTagArray();
-        if (tags != null && tags.length > 0) {
-            tag = tags[0].getVal();
-        } else {
             tag = "";
+        } else {
+            CTString[] aliases = pr.getAliasArray();
+            if (aliases != null && aliases.length > 0) {
+                title = aliases[0].getVal();
+            } else {
+                title = "";
+            }
+            CTString[] tags = pr.getTagArray();
+            if (tags != null && tags.length > 0) {
+                tag = tags[0].getVal();
+            } else {
+                tag = "";
+            }
         }
         this.part = part;
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFSDT.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFSDT.java?rev=1768048&r1=1768047&r2=1768048&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFSDT.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFSDT.java Fri Nov 
4 15:06:17 2016
@@ -17,6 +17,7 @@
 
 package org.apache.poi.xwpf.usermodel;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -131,6 +132,15 @@ public final class TestXWPFSDT extends T
         }
     }
 
+    public void test60341() throws IOException {
+        //handle sdtbody without an sdtpr
+        XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug60341.docx");
+        List<AbstractXWPFSDT> sdts = extractAllSDTs(doc);
+        assertEquals(1, sdts.size());
+        assertEquals("", sdts.get(0).getTag());
+        assertEquals("", sdts.get(0).getTitle());
+    }
+
     private List<AbstractXWPFSDT> extractAllSDTs(XWPFDocument doc) {
 
         List<AbstractXWPFSDT> sdts = new ArrayList<AbstractXWPFSDT>();



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


Mime
View raw message