You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2015/04/18 06:16:28 UTC
svn commit: r1674441 - in /poi/trunk:
src/scratchpad/src/org/apache/poi/hslf/model/Table.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java
test-data/slideshow/bug57820-initTableNullRefrenceException.ppt
Author: nick
Date: Sat Apr 18 04:16:28 2015
New Revision: 1674441
URL: http://svn.apache.org/r1674441
Log:
Patch from Jon Scharff from bug #57820 - Avoid NPE on HSLF Tables with a top position of -1
Added:
poi/trunk/test-data/slideshow/bug57820-initTableNullRefrenceException.ppt (with props)
Modified:
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Table.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Table.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Table.java?rev=1674441&r1=1674440&r2=1674441&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Table.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Table.java Sat Apr 18 04:16:28 2015
@@ -159,7 +159,7 @@ public final class Table extends ShapeGr
return delta;
}
});
- int y0 = -1;
+ int y0 = (sh.length > 0) ? sh[0].getAnchor().y - 1 : -1;
int maxrowlen = 0;
ArrayList lst = new ArrayList();
ArrayList row = null;
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java?rev=1674441&r1=1674440&r2=1674441&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java Sat Apr 18 04:16:28 2015
@@ -19,11 +19,16 @@ package org.apache.poi.hslf.model;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import junit.framework.TestCase;
+import org.apache.poi.POIDataSamples;
+import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.extractor.PowerPointExtractor;
import org.apache.poi.hslf.record.TextHeaderAtom;
import org.apache.poi.hslf.usermodel.SlideShow;
+import org.junit.Test;
/**
* Test <code>Table</code> object.
@@ -31,6 +36,7 @@ import org.apache.poi.hslf.usermodel.Sli
* @author Yegor Kozlov
*/
public final class TestTable extends TestCase {
+ private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
/**
* Test that ShapeFactory works properly and returns <code>Table</code>
@@ -100,4 +106,30 @@ public final class TestTable extends Tes
}
}
+
+ /**
+ * Bug 57820: initTable throws NullPointerException
+ * when the table is positioned with its top at -1
+ */
+ @Test
+ public void test57820() throws Exception {
+ SlideShow ppt = new SlideShow(new HSLFSlideShow(_slTests.openResourceAsStream("bug57820-initTableNullRefrenceException.ppt")));
+
+ Slide[] slides = ppt.getSlides();
+ assertEquals(1, slides.length);
+
+ Shape[] shapes = slides[0].getShapes(); //throws NullPointerException
+
+ Table tbl = null;
+ for(int idx = 0; idx < shapes.length; idx++) {
+ if(shapes[idx] instanceof Table) {
+ tbl = (Table)shapes[idx];
+ break;
+ }
+ }
+
+ assertNotNull(tbl);
+
+ assertEquals(-1, tbl.getAnchor().y);
+ }
}
Added: poi/trunk/test-data/slideshow/bug57820-initTableNullRefrenceException.ppt
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/bug57820-initTableNullRefrenceException.ppt?rev=1674441&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/test-data/slideshow/bug57820-initTableNullRefrenceException.ppt
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org