Browse Source

Patch from Jon Scharff from bug #57820 - Avoid NPE on HSLF Tables with a top position of -1

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1674441 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_3_12_FINAL
Nick Burch 9 years ago
parent
commit
facbded856

+ 1
- 1
src/scratchpad/src/org/apache/poi/hslf/model/Table.java View File

return delta; return delta;
} }
}); });
int y0 = -1;
int y0 = (sh.length > 0) ? sh[0].getAnchor().y - 1 : -1;
int maxrowlen = 0; int maxrowlen = 0;
ArrayList lst = new ArrayList(); ArrayList lst = new ArrayList();
ArrayList row = null; ArrayList row = null;

+ 32
- 0
src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java View File



import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException;


import junit.framework.TestCase; 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.record.TextHeaderAtom;
import org.apache.poi.hslf.usermodel.SlideShow; import org.apache.poi.hslf.usermodel.SlideShow;
import org.junit.Test;


/** /**
* Test <code>Table</code> object. * Test <code>Table</code> object.
* @author Yegor Kozlov * @author Yegor Kozlov
*/ */
public final class TestTable extends TestCase { public final class TestTable extends TestCase {
private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();


/** /**
* Test that ShapeFactory works properly and returns <code>Table</code> * Test that ShapeFactory works properly and returns <code>Table</code>


} }
} }
/**
* 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);
}
} }

BIN
test-data/slideshow/bug57820-initTableNullRefrenceException.ppt View File


Loading…
Cancel
Save