Search in sources :

Example 86 with HWPFDocument

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

the class TestBugs method testCommonCrawlRegression.

@Test
public void testCommonCrawlRegression() throws IOException {
    HWPFDocument document = HWPFTestDataSamples.openSampleFile("ca.kwsymphony.www_education_School_Concert_Seat_Booking_Form_2011-12.doc");
    document.close();
}
Also used : HWPFDocument(org.apache.poi.hwpf.HWPFDocument) Test(org.junit.Test)

Example 87 with HWPFDocument

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

the class TestLists method testUnorderedLists.

public void testUnorderedLists() {
    HWPFDocument doc = HWPFTestDataSamples.openSampleFile("Lists.doc");
    Range r = doc.getRange();
    assertEquals(40, r.numParagraphs());
    // Normal bullet points
    assertEquals("This document has different lists in it for testing\r", r.getParagraph(1).text());
    assertEquals("Unordered list 1\r", r.getParagraph(2).text());
    assertEquals("UL 2\r", r.getParagraph(3).text());
    assertEquals("UL 3\r", r.getParagraph(4).text());
    assertEquals("Next up is an ordered list:\r", r.getParagraph(5).text());
    assertEquals(9, r.getParagraph(1).getLvl());
    assertEquals(9, r.getParagraph(2).getLvl());
    assertEquals(9, r.getParagraph(3).getLvl());
    assertEquals(9, r.getParagraph(4).getLvl());
    assertEquals(9, r.getParagraph(5).getLvl());
    assertEquals(0, r.getParagraph(1).getIlvl());
    assertEquals(0, r.getParagraph(2).getIlvl());
    assertEquals(0, r.getParagraph(3).getIlvl());
    assertEquals(0, r.getParagraph(4).getIlvl());
    assertEquals(0, r.getParagraph(5).getIlvl());
    // Tick bullets
    assertEquals("Now for an un-ordered list with a different bullet style:\r", r.getParagraph(9).text());
    assertEquals("Tick 1\r", r.getParagraph(10).text());
    assertEquals("Tick 2\r", r.getParagraph(11).text());
    assertEquals("Multi-level un-ordered list:\r", r.getParagraph(12).text());
    assertEquals(9, r.getParagraph(9).getLvl());
    assertEquals(9, r.getParagraph(10).getLvl());
    assertEquals(9, r.getParagraph(11).getLvl());
    assertEquals(9, r.getParagraph(12).getLvl());
    assertEquals(0, r.getParagraph(9).getIlvl());
    assertEquals(0, r.getParagraph(10).getIlvl());
    assertEquals(0, r.getParagraph(11).getIlvl());
    assertEquals(0, r.getParagraph(12).getIlvl());
// TODO Test for tick not bullet
}
Also used : HWPFDocument(org.apache.poi.hwpf.HWPFDocument)

Example 88 with HWPFDocument

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

the class TestBugs method test41898.

/**
     * [RESOLVED INVALID] 41898 - Word 2003 pictures cannot be extracted
     */
@Test
public void test41898() throws IOException {
    HWPFDocument doc = HWPFTestDataSamples.openSampleFile("Bug41898.doc");
    List<Picture> pics = doc.getPicturesTable().getAllPictures();
    assertNotNull(pics);
    assertEquals(1, pics.size());
    Picture pic = pics.get(0);
    assertNotNull(pic.suggestFileExtension());
    assertNotNull(pic.suggestFullFileName());
    assertNotNull(pic.getContent());
    assertNotNull(pic.getRawContent());
    /*
         * This is a file with empty EMF image, but present Office Drawing
         * --sergey
         */
    final Collection<OfficeDrawing> officeDrawings = doc.getOfficeDrawingsMain().getOfficeDrawings();
    assertNotNull(officeDrawings);
    assertEquals(1, officeDrawings.size());
    OfficeDrawing officeDrawing = officeDrawings.iterator().next();
    assertNotNull(officeDrawing);
    assertEquals(1044, officeDrawing.getShapeId());
    doc.close();
}
Also used : HWPFDocument(org.apache.poi.hwpf.HWPFDocument) Test(org.junit.Test)

Example 89 with HWPFDocument

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

the class TestWordToTextConverter method testBug52311.

public void testBug52311() throws Exception {
    HWPFDocument doc = HWPFTestDataSamples.openSampleFile("Bug52311.doc");
    String result = WordToTextConverter.getText(doc);
    assertTrue(result.contains("2.1\tHeader 2.1"));
    assertTrue(result.contains("2.2\tHeader 2.2"));
    assertTrue(result.contains("2.3\tHeader 2.3"));
    assertTrue(result.contains("2.3.1\tHeader 2.3.1"));
    assertTrue(result.contains("2.99\tHeader 2.99"));
    assertTrue(result.contains("2.99.1\tHeader 2.99.1"));
    assertTrue(result.contains("2.100\tHeader 2.100"));
    assertTrue(result.contains("2.101\tHeader 2.101"));
}
Also used : HWPFDocument(org.apache.poi.hwpf.HWPFDocument)

Example 90 with HWPFDocument

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

the class TestWordToTextConverter method testBug53380_3.

public void testBug53380_3() throws Exception {
    HWPFDocument doc = HWPFTestDataSamples.openSampleFile("Bug53380_3.doc");
    WordToTextConverter.getText(doc);
}
Also used : HWPFDocument(org.apache.poi.hwpf.HWPFDocument)

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