org.apache.poi.xwpf.usermodel
Class XWPFDocument

java.lang.Object
  extended by org.apache.poi.POIXMLDocumentPart
      extended by org.apache.poi.POIXMLDocument
          extended by org.apache.poi.xwpf.usermodel.XWPFDocument

public class XWPFDocument
extends POIXMLDocument

Experimental class to do low level processing of docx files. If you are using these low level classes, then you will almost certainly need to refer to the OOXML specifications from http://www.ecma-international.org/publications/standards/Ecma-376.htm WARNING - APIs expected to change rapidly


Field Summary
protected  java.util.List<XWPFComment> comments
           
protected  java.util.List<XWPFHyperlink> hyperlinks
           
protected  java.util.List<XWPFParagraph> paragraphs
           
protected  java.util.List<XWPFTable> tables
           
 
Fields inherited from class org.apache.poi.POIXMLDocument
CORE_PROPERTIES_REL_TYPE, CUSTOM_PROPERTIES_REL_TYPE, EXTENDED_PROPERTIES_REL_TYPE, OLE_OBJECT_REL_TYPE, PACK_OBJECT_REL_TYPE
 
Fields inherited from class org.apache.poi.POIXMLDocumentPart
DEFAULT_XML_OPTIONS
 
Constructor Summary
XWPFDocument()
           
XWPFDocument(org.openxml4j.opc.Package pkg)
           
 
Method Summary
protected  void commit()
          Save the content in the underlying package part.
 XWPFParagraph createParagraph()
          Appends a new paragraph to this document
 java.util.List<org.openxml4j.opc.PackagePart> getAllEmbedds()
          Get the document's embedded files.
 XWPFComment getCommentByID(java.lang.String id)
           
 XWPFComment[] getComments()
           
 org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocument1 getDocument()
          Returns the low level document base object
 XWPFHeaderFooterPolicy getHeaderFooterPolicy()
          Returns the policy on headers and footers, which also provides a way to get at them.
 XWPFHyperlink getHyperlinkByID(java.lang.String id)
           
 XWPFHyperlink[] getHyperlinks()
           
 XWPFParagraph[] getParagraphs()
           
 java.util.Iterator<XWPFParagraph> getParagraphsIterator()
           
 org.openxml4j.opc.PackagePart getPartById(java.lang.String id)
          Get the document part that's defined as the given relationship of the core document.
 org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyles getStyle()
          Returns the styles object used
 java.util.Iterator<XWPFTable> getTablesIterator()
           
protected static org.openxml4j.opc.Package newPackage()
          Create a new SpreadsheetML package and setup the default minimal content
protected  void onDocumentCreate()
          Create a new CTWorkbook with all values set to default
protected  void onDocumentRead()
          Fired when a package part is read
 
Methods inherited from class org.apache.poi.POIXMLDocument
ensureWriteAccess, getCorePart, getPackage, getProperties, getRelatedByType, getTargetPart, getTargetPart, hasOOXMLHeader, openPackage, write
 
Methods inherited from class org.apache.poi.POIXMLDocumentPart
addRelation, createRelationship, createRelationship, createRelationship, getPackagePart, getPackageRelationship, getParent, getRelations, onSave, read, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

comments

protected java.util.List<XWPFComment> comments

hyperlinks

protected java.util.List<XWPFHyperlink> hyperlinks

paragraphs

protected java.util.List<XWPFParagraph> paragraphs

tables

protected java.util.List<XWPFTable> tables
Constructor Detail

XWPFDocument

public XWPFDocument(org.openxml4j.opc.Package pkg)
             throws java.io.IOException
Throws:
java.io.IOException

XWPFDocument

public XWPFDocument()
Method Detail

onDocumentRead

protected void onDocumentRead()
                       throws java.io.IOException
Description copied from class: POIXMLDocumentPart
Fired when a package part is read

Overrides:
onDocumentRead in class POIXMLDocumentPart
Throws:
java.io.IOException

newPackage

protected static org.openxml4j.opc.Package newPackage()
Create a new SpreadsheetML package and setup the default minimal content


onDocumentCreate

protected void onDocumentCreate()
Create a new CTWorkbook with all values set to default

Overrides:
onDocumentCreate in class POIXMLDocumentPart

getDocument

public org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocument1 getDocument()
Returns the low level document base object


getParagraphsIterator

public java.util.Iterator<XWPFParagraph> getParagraphsIterator()

getParagraphs

public XWPFParagraph[] getParagraphs()

getTablesIterator

public java.util.Iterator<XWPFTable> getTablesIterator()

getHyperlinkByID

public XWPFHyperlink getHyperlinkByID(java.lang.String id)

getHyperlinks

public XWPFHyperlink[] getHyperlinks()

getCommentByID

public XWPFComment getCommentByID(java.lang.String id)

getComments

public XWPFComment[] getComments()

getPartById

public org.openxml4j.opc.PackagePart getPartById(java.lang.String id)
Get the document part that's defined as the given relationship of the core document.


getHeaderFooterPolicy

public XWPFHeaderFooterPolicy getHeaderFooterPolicy()
Returns the policy on headers and footers, which also provides a way to get at them.


getStyle

public org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyles getStyle()
                                                                         throws org.apache.xmlbeans.XmlException,
                                                                                java.io.IOException
Returns the styles object used

Throws:
org.apache.xmlbeans.XmlException
java.io.IOException

getAllEmbedds

public java.util.List<org.openxml4j.opc.PackagePart> getAllEmbedds()
                                                            throws org.openxml4j.exceptions.OpenXML4JException
Get the document's embedded files.

Specified by:
getAllEmbedds in class POIXMLDocument
Throws:
org.openxml4j.exceptions.OpenXML4JException

commit

protected void commit()
               throws java.io.IOException
Description copied from class: POIXMLDocumentPart
Save the content in the underlying package part. Default implementation is empty meaning that the package part is left unmodified. Sub-classes should override and add logic to marshal the "model" into Ooxml4J. For example, the code saving a generic XML entry may look as follows:

 protected void commit() throws IOException {
   PackagePart part = getPackagePart();
   OutputStream out = part.getOutputStream();
   XmlObject bean = getXmlBean(); //the "model" which holds changes in memory
   bean.save(out, DEFAULT_XML_OPTIONS);
   out.close();
 }
  

Overrides:
commit in class POIXMLDocumentPart
Throws:
java.io.IOException

createParagraph

public XWPFParagraph createParagraph()
Appends a new paragraph to this document

Returns:
a new paragraph


Copyright 2008 The Apache Software Foundation or its licensors, as applicable.