diff --git a/src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmUncompressor.java b/src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmUncompressor.java index 87547565f..f8fc91f12 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmUncompressor.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmUncompressor.java @@ -148,8 +148,10 @@ public class TableSprmUncompressor for (int x = 0; x < itcMac; x++) { - if(hasTCs) rgtc[x] = TableCellDescriptor.convertBytesToTC(grpprl, - offset + (1 + ( (itcMac + 1) * 2) + (x * 20))); + // Sometimes, the grpprl does not contain data at every offset. I have no idea why this happens. + if(hasTCs && offset + (1 + ( (itcMac + 1) * 2) + (x * 20)) < grpprl.length) + rgtc[x] = TableCellDescriptor.convertBytesToTC(grpprl, + offset + (1 + ( (itcMac + 1) * 2) + (x * 20))); else rgtc[x] = new TableCellDescriptor(); } diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/data/AIOOB-Tap.doc b/src/scratchpad/testcases/org/apache/poi/hwpf/data/AIOOB-Tap.doc new file mode 100644 index 000000000..bfd5906ca Binary files /dev/null and b/src/scratchpad/testcases/org/apache/poi/hwpf/data/AIOOB-Tap.doc differ diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java index 87b9754a6..8e7f47ed9 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java @@ -53,8 +53,25 @@ public class TestProblems extends TestCase { Section s = r.getSection(x); for (int y = 0; y < s.numParagraphs(); y++) { Paragraph paragraph = s.getParagraph(y); - System.out.println(paragraph.getCharacterRun(0).text()); + //System.out.println(paragraph.getCharacterRun(0).text()); } } } + + /** + * AIOOB for TableSprmUncompressor.unCompressTAPOperation + */ + public void testSprmAIOOB() throws Exception { + HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/AIOOB-Tap.doc")); + + Range r = doc.getRange(); + StyleSheet styleSheet = doc.getStyleSheet(); + for (int x = 0; x < r.numSections(); x++) { + Section s = r.getSection(x); + for (int y = 0; y < s.numParagraphs(); y++) { + Paragraph paragraph = s.getParagraph(y); + //System.out.println(paragraph.getCharacterRun(0).text()); + } + } + } }