{
int papxOffset = 2 * LittleEndian.getUByte(_fkp, _offset + (((_crun + 1) * FC_SIZE) + (index * BX_SIZE)));
int size = 2 * LittleEndian.getUByte(_fkp, _offset + papxOffset);
- if(size == 0)
- {
+ if(size == 0) {
size = 2 * LittleEndian.getUByte(_fkp, _offset + ++papxOffset);
- }
- else
- {
+ } else {
size--;
}
- byte[] papx = IOUtils.safelyAllocate(size, 512);
- System.arraycopy(_fkp, _offset + ++papxOffset, papx, 0, size);
- return papx;
+ return IOUtils.safelyClone(_fkp, _offset + papxOffset + 1, size, 512);
}
/**
// LittleEndian.putUShort( dataStream, hugeGrpprlOffset,
// grpprl.length - 2 );
- byte[] hugePapx = new byte[grpprl.length - 2];
- System.arraycopy( grpprl, 2, hugePapx, 0, grpprl.length - 2 );
+ byte[] hugePapx = Arrays.copyOfRange(grpprl, 2, grpprl.length);
int dataStreamOffset = dataStream.size();
dataStream.write( hugePapx );
*/
@Test
public void test44431_2() throws IOException {
- assertEqualsIgnoreNewline("File name=FieldsTest.doc\n" +
- "\n" +
- "\n" +
- "STYLEREF test\n" +
- "\n" +
- "\n" +
- "\n" +
- "TEST TABLE OF CONTENTS\n" +
- "\n" +
- "Heading paragraph in next page\t2\n" +
- "Another heading paragraph in further page\t3\n" +
- "Another heading paragraph in further page\t3\n" +
- "\n" +
- "\n" +
- "Heading paragraph in next page\n" +
- "Another heading paragraph in further page\n" +
- "\n" +
- "\n" +
- "\n" +
+ assertEqualsIgnoreNewline("File name=FieldsTest.doc\n" +
+ "\n" +
+ "\n" +
+ "STYLEREF test\n" +
+ "\n" +
+ "\n" +
+ "\n" +
+ "TEST TABLE OF CONTENTS\n" +
+ "\n" +
+ "Heading paragraph in next page\t2\n" +
+ "Another heading paragraph in further page\t3\n" +
+ "Another heading paragraph in further page\t3\n" +
+ "\n" +
+ "\n" +
+ "Heading paragraph in next page\n" +
+ "Another heading paragraph in further page\n" +
+ "\n" +
+ "\n" +
+ "\n" +
"Page 3 of 3", getText("Bug44431.doc"));
}
HWPFDocument hwpfDocument = HWPFTestDataSamples.openSampleFile(filename);
assertNotNull(filename, hwpfDocument.getPicturesTable().getAllPictures());
-
+
hwpfDocument.close();
}
}
public void test51604p3() throws Exception {
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("Bug51604.doc");
- byte[] originalData = new byte[doc.getFileInformationBlock()
- .getLcbDop()];
- System.arraycopy(doc.getTableStream(), doc.getFileInformationBlock()
- .getFcDop(), originalData, 0, originalData.length);
+ FileInformationBlock fib = doc.getFileInformationBlock();
+ byte[] originalData = Arrays.copyOfRange(doc.getTableStream(), fib.getFcDop(), fib.getFcDop()+fib.getLcbDop());
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
doc.getDocProperties().writeTo(outputStream);
public void testBug53380_4() throws Exception {
assertNotNull(getText("Bug53380_4.doc"));
}
-
+
/**
- * java.lang.UnsupportedOperationException: Non-extended character
+ * java.lang.UnsupportedOperationException: Non-extended character
* Pascal strings are not supported right now
- *
+ *
* Disabled pending a fix for the bug
*/
@Test
HWPFTestDataSamples.openSampleFile("56880.doc");
assertEqualsIgnoreNewline("Check Request", doc.getRange().text());
}
-
+
/**
* Bug 61268 - NegativeArraySizeException parsing word 97 document
*/
}
else if(para.text().trim().equals("Section2")) {
assertSection2Margin(section);
-
+
// Change the margin widths
this.section2BottomMargin = (int)(1.5 * AbstractWordUtils.TWIPS_PER_INCH);
this.section2TopMargin = (int)(1.75 * AbstractWordUtils.TWIPS_PER_INCH);
}
}
}
-
+
// Save away and re-read the document to prove the changes are permanent
document = HWPFTestDataSamples.writeOutAndReadBack(document);
overallRange = document.getOverallRange();
hwpfDocument2.close();
hwpfDocument.close();
}
-
- @Test(expected=ArrayIndexOutOfBoundsException.class)
+
+ @Test
public void test57843() throws IOException {
File f = POIDataSamples.getDocumentInstance().getFile("57843.doc");
try (POIFSFileSystem fs = new POIFSFileSystem(f, true)) {