Bug 55732 - PPT can't open, fails with "Couldn't instantiate .... StyleTextProp9Atom : java.lang.ArrayIndexOutOfBoundsException: 56"

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1569984 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2014-02-19 23:45:07 +00:00
parent 56d6f0342a
commit 8afdb7a9ce
3 changed files with 54 additions and 29 deletions

View File

@ -27,8 +27,6 @@ import org.apache.poi.util.LittleEndian;
/**
* The atom record that specifies additional text formatting.
*
* @author Alex Nikiforov [mailto:anikif@gmail.com]
*/
public final class StyleTextProp9Atom extends RecordAtom {
private final TextPFException9[] autoNumberSchemes;
@ -64,11 +62,20 @@ public final class StyleTextProp9Atom extends RecordAtom {
final TextPFException9 item = new TextPFException9(data, i);
schemes.add(item);
i += item.getRecordLength();
//int textCfException9 = LittleEndian.getInt(data, i );
//TODO analyze textCfException when have some test data
if (i >= data.length) {
break;
}
int textCfException9 = LittleEndian.getInt(data, i );
i += 4;
//TODO analyze textCfException when have some test data
if (i >= data.length) {
break;
}
int textSiException = LittleEndian.getInt(data, i );
i += + 4;//TextCFException9 + SIException
i += 4;//TextCFException9 + SIException
if (0 != (textSiException & 0x40)) {
i += 2; //skip fBidi
}

View File

@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
@ -38,6 +39,7 @@ import org.apache.poi.hslf.HSLFTestDataSamples;
import org.apache.poi.hslf.exceptions.OldPowerPointFormatException;
import org.apache.poi.hslf.model.Background;
import org.apache.poi.hslf.model.Fill;
import org.apache.poi.hslf.model.HeadersFooters;
import org.apache.poi.hslf.model.MasterSheet;
import org.apache.poi.hslf.model.Notes;
import org.apache.poi.hslf.model.Picture;
@ -484,4 +486,20 @@ public final class TestBugs {
}
}
@Test
public void bug55732() throws Exception {
File file = _slTests.getFile("bug55732.ppt");
HSLFSlideShow ss = new HSLFSlideShow(file.getAbsolutePath());
SlideShow _show = new SlideShow(ss);
Slide[] _slides = _show.getSlides();
/* Iterate over slides and extract text */
for( Slide slide : _slides ) {
HeadersFooters hf = slide.getHeadersFooters();
boolean visible = hf.isHeaderVisible(); // exception happens here
}
assertTrue("No Exceptions while reading headers", true);
}
}

Binary file not shown.