use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.
the class TestBugs method test47958.
/**
* Bug 47958 - Exception during Escher walk of pictures
*/
@Test
public void test47958() {
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("Bug47958.doc");
doc.getPicturesTable().getAllPictures();
}
use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.
the class TestPictures method testFastSaved3.
@Test
public void testFastSaved3() {
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("ob_is.doc");
// just check that we do not throw Exception
doc.getPicturesTable().getAllPictures();
}
use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.
the class TestBugs method test51604p3.
/**
* [RESOLVED FIXED] Bug 51604 - replace text fails for doc (poi 3.8 beta
* release from download site )
*/
@Test
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);
HWPFOutputStream outputStream = new HWPFOutputStream();
doc.getDocProperties().writeTo(outputStream);
final byte[] oldData = outputStream.toByteArray();
assertEqualsIgnoreNewline(Arrays.toString(originalData), Arrays.toString(oldData));
Range range = doc.getRange();
int numParagraph = range.numParagraphs();
replaceText(range, numParagraph);
doc = HWPFTestDataSamples.writeOutAndReadBack(doc);
outputStream = new HWPFOutputStream();
doc.getDocProperties().writeTo(outputStream);
final byte[] newData = outputStream.toByteArray();
assertEqualsIgnoreNewline(Arrays.toString(oldData), Arrays.toString(newData));
}
use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.
the class TestPictures method testPicturesInHeader.
@Test
public void testPicturesInHeader() {
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("header_image.doc");
List<Picture> pics = doc.getPicturesTable().getAllPictures();
assertEquals(2, pics.size());
}
use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.
the class TestPictures method testPictureDetectionWithPNG.
@Test
public void testPictureDetectionWithPNG() {
HWPFDocument document = HWPFTestDataSamples.openSampleFile("PngPicture.doc");
PicturesTable pictureTable = document.getPicturesTable();
assertEquals(1, pictureTable.getAllPictures().size());
Picture p = pictureTable.getAllPictures().get(0);
assertEquals(PictureType.PNG, p.suggestPictureType());
assertEquals("png", p.suggestFileExtension());
}
Aggregations