Search in sources :

Example 96 with HWPFDocument

use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.

the class TestPictures method testFastSaved2.

@Test
public void testFastSaved2() {
    HWPFDocument doc = HWPFTestDataSamples.openSampleFile("o_kurs.doc");
    // just check that we do not throw Exception
    doc.getPicturesTable().getAllPictures();
}
Also used : HWPFDocument(org.apache.poi.hwpf.HWPFDocument) Test(org.junit.Test)

Example 97 with HWPFDocument

use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.

the class TestPictures method testFastSaved.

@Test
public void testFastSaved() {
    HWPFDocument doc = HWPFTestDataSamples.openSampleFile("rasp.doc");
    // just check that we do not throw Exception
    doc.getPicturesTable().getAllPictures();
}
Also used : HWPFDocument(org.apache.poi.hwpf.HWPFDocument) Test(org.junit.Test)

Example 98 with HWPFDocument

use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.

the class TestPictures method testTwoImages.

/**
	 * two jpegs
	 */
@Test
public void testTwoImages() {
    HWPFDocument doc = HWPFTestDataSamples.openSampleFile("two_images.doc");
    List<Picture> pics = doc.getPicturesTable().getAllPictures();
    assertNotNull(pics);
    assertEquals(pics.size(), 2);
    for (int i = 0; i < pics.size(); i++) {
        Picture pic = pics.get(i);
        assertNotNull(pic.suggestFileExtension());
        assertNotNull(pic.suggestFullFileName());
    }
    Picture picA = pics.get(0);
    Picture picB = pics.get(1);
    assertEquals("jpg", picA.suggestFileExtension());
    assertEquals("png", picB.suggestFileExtension());
}
Also used : HWPFDocument(org.apache.poi.hwpf.HWPFDocument) Test(org.junit.Test)

Example 99 with HWPFDocument

use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.

the class TestBugs method testBug51890.

/**
     * [FIXED] Bug 51902 - Picture.fillRawImageContent -
     * ArrayIndexOutOfBoundsException
     */
@Test
public void testBug51890() {
    HWPFDocument doc = HWPFTestDataSamples.openSampleFile("Bug51890.doc");
    for (Picture picture : doc.getPicturesTable().getAllPictures()) {
        PictureType pictureType = picture.suggestPictureType();
        logger.log(POILogger.DEBUG, "Picture at offset " + picture.getStartOffset() + " has type " + pictureType);
    }
}
Also used : HWPFDocument(org.apache.poi.hwpf.HWPFDocument) Test(org.junit.Test)

Example 100 with HWPFDocument

use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.

the class HWPFLister method dumpStyles.

private void dumpStyles() {
    if (_doc instanceof HWPFOldDocument) {
        System.out.println("Word 95 not supported so far");
        return;
    }
    HWPFDocument hwpfDocument = (HWPFDocument) _doc;
    for (int s = 0; s < hwpfDocument.getStyleSheet().numStyles(); s++) {
        StyleDescription styleDescription = hwpfDocument.getStyleSheet().getStyleDescription(s);
        if (styleDescription == null)
            continue;
        System.out.println("=== Style #" + s + " '" + styleDescription.getName() + "' ===");
        System.out.println(styleDescription);
        if (styleDescription.getPAPX() != null)
            dumpSprms(new SprmIterator(styleDescription.getPAPX(), 2), "Style's PAP SPRM: ");
        if (styleDescription.getCHPX() != null)
            dumpSprms(new SprmIterator(styleDescription.getCHPX(), 0), "Style's CHP SPRM: ");
    }
}
Also used : HWPFDocument(org.apache.poi.hwpf.HWPFDocument) HWPFOldDocument(org.apache.poi.hwpf.HWPFOldDocument) SprmIterator(org.apache.poi.hwpf.sprm.SprmIterator) StyleDescription(org.apache.poi.hwpf.model.StyleDescription)

Aggregations

HWPFDocument (org.apache.poi.hwpf.HWPFDocument)126 Test (org.junit.Test)66 InputStream (java.io.InputStream)15 FileInputStream (java.io.FileInputStream)10 Range (org.apache.poi.hwpf.usermodel.Range)9 ByteArrayInputStream (java.io.ByteArrayInputStream)8 HSLFSlideShow (org.apache.poi.hslf.usermodel.HSLFSlideShow)7 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)7 WordExtractor (org.apache.poi.hwpf.extractor.WordExtractor)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 PicturesTable (org.apache.poi.hwpf.model.PicturesTable)6 Bookmark (org.apache.poi.hwpf.usermodel.Bookmark)6 NPOIFSFileSystem (org.apache.poi.poifs.filesystem.NPOIFSFileSystem)6 File (java.io.File)4 FileOutputStream (java.io.FileOutputStream)4 Transformer (javax.xml.transform.Transformer)4 DOMSource (javax.xml.transform.dom.DOMSource)4 Picture (org.apache.poi.hwpf.usermodel.Picture)4 DirectoryNode (org.apache.poi.poifs.filesystem.DirectoryNode)4 POIFSFileSystem (org.apache.poi.poifs.filesystem.POIFSFileSystem)4