Examples of XWPFDocument


Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

      assertEquals(p3, doc.getBodyElements().get(0));
      assertEquals(p3, doc.getParagraphs().get(0));
  }
 
  public void testSettings() throws Exception {
     XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("WithGIF.docx");
     assertEquals(120, doc.getZoomPercent());
     assertEquals(false, doc.isEnforcedCommentsProtection());
      assertEquals(false, doc.isEnforcedFillingFormsProtection());
      assertEquals(false, doc.isEnforcedReadonlyProtection());
      assertEquals(false, doc.isEnforcedTrackedChangesProtection());
     
      doc.setZoomPercent(124);
     
      // Only one enforcement allowed, last one wins!
      doc.enforceFillingFormsProtection();
      doc.enforceReadonlyProtection();
     
      doc = XWPFTestDataSamples.writeOutAndReadBack(doc);
     
      assertEquals(124, doc.getZoomPercent());
      assertEquals(false, doc.isEnforcedCommentsProtection());
      assertEquals(false, doc.isEnforcedFillingFormsProtection());
      assertEquals(true, doc.isEnforcedReadonlyProtection());
      assertEquals(false, doc.isEnforcedTrackedChangesProtection());
  }
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

      assertEquals(true, doc.isEnforcedReadonlyProtection());
      assertEquals(false, doc.isEnforcedTrackedChangesProtection());
  }
 
  public void testGIFSupport() throws Exception {
      XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("WithGIF.docx");
      ArrayList<PackagePart> gifParts = doc.getPackage().getPartsByContentType(XWPFRelation.IMAGE_GIF.getContentType());
      assertEquals("Expected exactly one GIF part in package.",1,gifParts.size());
      PackagePart gifPart = gifParts.get(0);
     
      List<POIXMLDocumentPart> relations = doc.getRelations();
      POIXMLDocumentPart gifDocPart = null;
      for (POIXMLDocumentPart docPart : relations)
        {
            if (gifPart == docPart.getPackagePart())
            {
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

    @Override
    public void run() {
        try {
            InputStream isr = new FileInputStream(pathToFile);
            XWPFDocument document = new XWPFDocument(isr);
            XWPFWordExtractor word = new XWPFWordExtractor(document);
            String fileContent = word.getText();

            AddDataToIndex.class.newInstance().doAddData(fileContent,
                    pathToFile, fileName);
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

  public void testWord() throws Exception {
    File f = new File(dirname, "WordWithAttachments.docx");
    assertTrue(f.exists());
   
    POIXMLDocument doc = new XWPFDocument(OPCPackage.open(f.toString()));
    test(doc, 5);
  }
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

  public void testOpen() throws Exception {
    POIXMLDocument.openPackage(sampleFile.toString());
    POIXMLDocument.openPackage(complexFile.toString());
   
    new XWPFDocument(
        POIXMLDocument.openPackage(sampleFile.toString())
    );
    new XWPFDocument(
        POIXMLDocument.openPackage(complexFile.toString())
    );
   
    XWPFDocument xml;
   
    // Simple file
    xml = new XWPFDocument(
        POIXMLDocument.openPackage(sampleFile.toString())
    );
    // Check it has key parts
    assertNotNull(xml.getDocument());
    assertNotNull(xml.getDocument().getBody());
    assertNotNull(xml.getStyle());
   
    // Complex file
    xml = new XWPFDocument(
        POIXMLDocument.openPackage(complexFile.toString())
    );
    assertNotNull(xml.getDocument());
    assertNotNull(xml.getDocument().getBody());
    assertNotNull(xml.getStyle());
  }
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

    assertNotNull(xml.getDocument().getBody());
    assertNotNull(xml.getStyle());
  }
 
  public void testMetadataBasics() throws Exception {
    XWPFDocument xml = new XWPFDocument(
        POIXMLDocument.openPackage(sampleFile.toString())
    );
    assertNotNull(xml.getProperties().getCoreProperties());
    assertNotNull(xml.getProperties().getExtendedProperties());
   
    assertEquals("Microsoft Office Word", xml.getProperties().getExtendedProperties().getUnderlyingProperties().getApplication());
    assertEquals(1315, xml.getProperties().getExtendedProperties().getUnderlyingProperties().getCharacters());
    assertEquals(10, xml.getProperties().getExtendedProperties().getUnderlyingProperties().getLines());
   
    assertEquals(null, xml.getProperties().getCoreProperties().getTitle());
    assertEquals(null, xml.getProperties().getCoreProperties().getUnderlyingProperties().getSubjectProperty().getValue());
  }
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

    assertEquals(null, xml.getProperties().getCoreProperties().getTitle());
    assertEquals(null, xml.getProperties().getCoreProperties().getUnderlyingProperties().getSubjectProperty().getValue());
  }
 
  public void testMetadataComplex() throws Exception {
    XWPFDocument xml = new XWPFDocument(
        POIXMLDocument.openPackage(complexFile.toString())
    );
    assertNotNull(xml.getProperties().getCoreProperties());
    assertNotNull(xml.getProperties().getExtendedProperties());
   
    assertEquals("Microsoft Office Outlook", xml.getProperties().getExtendedProperties().getUnderlyingProperties().getApplication());
    assertEquals(5184, xml.getProperties().getExtendedProperties().getUnderlyingProperties().getCharacters());
    assertEquals(0, xml.getProperties().getExtendedProperties().getUnderlyingProperties().getLines());
   
    assertEquals(" ", xml.getProperties().getCoreProperties().getTitle());
    assertEquals(" ", xml.getProperties().getCoreProperties().getUnderlyingProperties().getSubjectProperty().getValue());
  }
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

public class XWPFWordExtractor extends POIXMLTextExtractor {
  private XWPFDocument document;
  private boolean fetchHyperlinks = false;
 
  public XWPFWordExtractor(OPCPackage container) throws XmlException, OpenXML4JException, IOException {
    this(new XWPFDocument(container));
  }
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

         if (is.available() == 0)
         {
            return "";
         }
        
         XWPFDocument doc;
         try
         {
            doc = new XWPFDocument(is);
         }
         catch (IOException e)
         {
            throw new DocumentReadException("Can't open message.", e);
         }
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

    * @see org.exoplatform.services.document.DocumentReader#getProperties(java.io.InputStream)
    */
   public Properties getProperties(InputStream is) throws IOException, DocumentReadException
   {
      POIPropertiesReader reader = new POIPropertiesReader();
      reader.readDCProperties(new XWPFDocument(is));
      return reader.getProperties();
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.