You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ta...@apache.org on 2018/10/26 19:06:18 UTC
svn commit: r1844920 - in /poi: site/src/documentation/content/xdocs/
trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/
trunk/src/ooxml/testcases/org/apache/poi/sl/
trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/
trunk/test-data/document/
Author: tallison
Date: Fri Oct 26 19:06:18 2018
New Revision: 1844920
URL: http://svn.apache.org/viewvc?rev=1844920&view=rev
Log:
bug 62859 -- fix two potential NPEs when initializing XWPFSDTContent
Added:
poi/trunk/test-data/document/Bug62859.docx (with props)
Modified:
poi/site/src/documentation/content/xdocs/changes.xml
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java
poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFSDT.java
Modified: poi/site/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/changes.xml?rev=1844920&r1=1844919&r2=1844920&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/changes.xml (original)
+++ poi/site/src/documentation/content/xdocs/changes.xml Fri Oct 26 19:06:18 2018
@@ -94,6 +94,7 @@
<summary-item>Improvements for XDDF charts and text manipulation</summary-item>
</summary>
<actions>
+ <action dev="PD" type="fix" fixes-bug="62859" context="XWPF">Rare NPE while creating XWPFSDTContent</action>
<action dev="PD" type="add" fixes-bug="62373" context="SS_Common">Support for FREQUENCY function</action>
<action dev="PD" type="fix" fixes-bug="62831" context="POI_Overall">WorkbookFactory.create support for subclass of File, eg from JFileChooser</action>
<action dev="PD" type="fix" fixes-bug="62815" context="XSSF">XLSB number extraction improvements</action>
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java?rev=1844920&r1=1844919&r2=1844920&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java Fri Oct 26 19:06:18 2018
@@ -47,6 +47,9 @@ public class XWPFSDTContent implements I
private List<ISDTContents> bodyElements = new ArrayList<>();
public XWPFSDTContent(CTSdtContentRun sdtRun, IBody part, IRunBody parent) {
+ if (sdtRun == null) {
+ return;
+ }
for (CTR ctr : sdtRun.getRArray()) {
XWPFRun run = new XWPFRun(ctr, parent);
// runs.add(run);
@@ -55,6 +58,9 @@ public class XWPFSDTContent implements I
}
public XWPFSDTContent(CTSdtContentBlock block, IBody part, IRunBody parent) {
+ if (block == null) {
+ return;
+ }
XmlCursor cursor = block.newCursor();
cursor.selectPath("./*");
while (cursor.toNextSelection()) {
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java?rev=1844920&r1=1844919&r2=1844920&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java Fri Oct 26 19:06:18 2018
@@ -74,7 +74,7 @@ public class TestFonts {
// currently linux and mac return quite different values
private static final int[] expected_sizes = {
304, // windows 10, 1080p, MS Office 2016, system text scaling 100% instead of default 125%
- 306, // Windows 10, 15.6" 3840x2160
+ 306, 308,// Windows 10, 15.6" 3840x2160
311, 312, 313, 318,
348, // Windows 10, 15.6" 3840x2160
362, // Windows 10, 13.3" 1080p high-dpi
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=1844920&r1=1844919&r2=1844920&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 Oct 26 19:06:18 2018
@@ -148,6 +148,19 @@ public final class TestXWPFSDT {
assertEquals("", sdts.get(0).getTitle());
}
+ @Test
+ public void test62859() throws IOException {
+ //this doesn't test the exact code path for this issue, but
+ //it does test for a related issue, and the fix fixes both.
+ //We should try to add the actual triggering document
+ //to our test suite.
+ XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug62859.docx");
+ List<XWPFAbstractSDT> sdts = extractAllSDTs(doc);
+ assertEquals(1, sdts.size());
+ assertEquals("", sdts.get(0).getTag());
+ assertEquals("", sdts.get(0).getTitle());
+ }
+
private List<XWPFAbstractSDT> extractAllSDTs(XWPFDocument doc) {
List<XWPFAbstractSDT> sdts = new ArrayList<>();
Added: poi/trunk/test-data/document/Bug62859.docx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/document/Bug62859.docx?rev=1844920&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/test-data/document/Bug62859.docx
------------------------------------------------------------------------------
--- svn:mime-type (added)
+++ svn:mime-type Fri Oct 26 19:06:18 2018
@@ -0,0 +1 @@
+application/vnd.openxmlformats-officedocument.wordprocessingml.document
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org