org.apache.poi.xwpf.usermodel
public class XWPFDocument extends POIXMLDocument
Modifier and Type | Field and Description |
---|---|
protected java.util.List<XWPFComment> |
comments |
protected java.util.Map<java.lang.Integer,XWPFFootnote> |
endnotes |
protected java.util.Map<java.lang.Integer,XWPFFootnote> |
footnotes |
protected java.util.List<XWPFHyperlink> |
hyperlinks |
protected java.util.List<XWPFParagraph> |
paragraphs |
protected java.util.List<XWPFTable> |
tables |
CORE_PROPERTIES_REL_TYPE, CUSTOM_PROPERTIES_REL_TYPE, DOCUMENT_CREATOR, EXTENDED_PROPERTIES_REL_TYPE, OLE_OBJECT_REL_TYPE, PACK_OBJECT_REL_TYPE
DEFAULT_XML_OPTIONS
Constructor and Description |
---|
XWPFDocument() |
XWPFDocument(java.io.InputStream is) |
XWPFDocument(OPCPackage pkg) |
Modifier and Type | Method and Description |
---|---|
protected void |
commit()
Save the content in the underlying package part.
|
XWPFParagraph |
createParagraph()
Appends a new paragraph to this document
|
XWPFTable |
createTable()
Create an empty table with one row and one column as default.
|
XWPFTable |
createTable(int rows,
int cols)
Create an empty table with a number of rows and cols specified
|
void |
createTOC() |
void |
enforceCommentsProtection()
Enforce the Comments protection.
In the documentProtection tag inside settings.xml file, it sets the value of enforcement to "1" (w:enforcement="1") and the value of edit to comments (w:edit="comments") sample snippet from settings.xml |
void |
enforceFillingFormsProtection()
Enforce the Filling Forms protection.
In the documentProtection tag inside settings.xml file, it sets the value of enforcement to "1" (w:enforcement="1") and the value of edit to forms (w:edit="forms") sample snippet from settings.xml |
void |
enforceReadonlyProtection()
Enforces the readOnly protection.
In the documentProtection tag inside settings.xml file, it sets the value of enforcement to "1" (w:enforcement="1") and the value of edit to readOnly (w:edit="readOnly") sample snippet from settings.xml |
void |
enforceTrackedChangesProtection()
Enforce the Tracked Changes protection.
In the documentProtection tag inside settings.xml file, it sets the value of enforcement to "1" (w:enforcement="1") and the value of edit to trackedChanges (w:edit="trackedChanges") sample snippet from settings.xml |
java.util.List<PackagePart> |
getAllEmbedds()
Get the document's embedded files.
|
XWPFComment |
getCommentByID(java.lang.String id) |
XWPFComment[] |
getComments() |
CTDocument1 |
getDocument()
Returns the low level document base object
|
XWPFFootnote |
getEndnoteByID(int id) |
XWPFFootnote |
getFootnoteByID(int id) |
java.util.Collection<XWPFFootnote> |
getFootnotes() |
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() |
PackagePart |
getPartById(java.lang.String id)
Get the document part that's defined as the
given relationship of the core document.
|
CTStyles |
getStyle()
Returns the styles object used
|
java.util.Iterator<XWPFTable> |
getTablesIterator() |
boolean |
isEnforcedCommentsProtection()
Verifies that the documentProtection tag in settings.xml file
specifies that the protection is enforced (w:enforcement="1") and that the kind of protection is comments (w:edit="comments") sample snippet from settings.xml |
boolean |
isEnforcedFillingFormsProtection()
Verifies that the documentProtection tag in settings.xml file
specifies that the protection is enforced (w:enforcement="1") and that the kind of protection is forms (w:edit="forms") sample snippet from settings.xml |
boolean |
isEnforcedReadonlyProtection()
Verifies that the documentProtection tag in settings.xml file
specifies that the protection is enforced (w:enforcement="1") and that the kind of protection is readOnly (w:edit="readOnly") sample snippet from settings.xml |
boolean |
isEnforcedTrackedChangesProtection()
Verifies that the documentProtection tag in settings.xml file
specifies that the protection is enforced (w:enforcement="1") and that the kind of protection is trackedChanges (w:edit="trackedChanges") sample snippet from settings.xml |
protected static OPCPackage |
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
|
void |
removeProtectionEnforcement()
Remove protection enforcement.
In the documentProtection tag inside settings.xml file it sets the value of enforcement to "0" (w:enforcement="0") |
ensureWriteAccess, getCorePart, getPackage, getProperties, getRelatedByType, getTargetPart, getTargetPart, hasOOXMLHeader, load, openPackage, write
addRelation, createRelationship, createRelationship, createRelationship, getPackagePart, getPackageRelationship, getParent, getRelations, onSave, read, removeRelation, toString
protected java.util.List<XWPFComment> comments
protected java.util.List<XWPFHyperlink> hyperlinks
protected java.util.List<XWPFParagraph> paragraphs
protected java.util.List<XWPFTable> tables
protected java.util.Map<java.lang.Integer,XWPFFootnote> footnotes
protected java.util.Map<java.lang.Integer,XWPFFootnote> endnotes
public XWPFDocument(OPCPackage pkg) throws java.io.IOException
java.io.IOException
public XWPFDocument(java.io.InputStream is) throws java.io.IOException
java.io.IOException
public XWPFDocument()
protected void onDocumentRead() throws java.io.IOException
POIXMLDocumentPart
onDocumentRead
in class POIXMLDocumentPart
java.io.IOException
protected static OPCPackage newPackage()
protected void onDocumentCreate()
onDocumentCreate
in class POIXMLDocumentPart
@Internal public CTDocument1 getDocument()
public java.util.Iterator<XWPFParagraph> getParagraphsIterator()
public XWPFParagraph[] getParagraphs()
public java.util.Iterator<XWPFTable> getTablesIterator()
public XWPFHyperlink getHyperlinkByID(java.lang.String id)
public XWPFFootnote getFootnoteByID(int id)
public XWPFFootnote getEndnoteByID(int id)
public java.util.Collection<XWPFFootnote> getFootnotes()
public XWPFHyperlink[] getHyperlinks()
public XWPFComment getCommentByID(java.lang.String id)
public XWPFComment[] getComments()
public PackagePart getPartById(java.lang.String id)
public XWPFHeaderFooterPolicy getHeaderFooterPolicy()
@Internal public CTStyles getStyle() throws XmlException, java.io.IOException
XmlException
java.io.IOException
public java.util.List<PackagePart> getAllEmbedds() throws OpenXML4JException
getAllEmbedds
in class POIXMLDocument
OpenXML4JException
protected void commit() throws java.io.IOException
POIXMLDocumentPart
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();
}
commit
in class POIXMLDocumentPart
java.io.IOException
public XWPFParagraph createParagraph()
public XWPFTable createTable()
public XWPFTable createTable(int rows, int cols)
rows
- cols
- public void createTOC()
public boolean isEnforcedReadonlyProtection()
<w:settings ... > <w:documentProtection w:edit="readOnly" w:enforcement="1"/>
public boolean isEnforcedFillingFormsProtection()
<w:settings ... > <w:documentProtection w:edit="forms" w:enforcement="1"/>
public boolean isEnforcedCommentsProtection()
<w:settings ... > <w:documentProtection w:edit="comments" w:enforcement="1"/>
public boolean isEnforcedTrackedChangesProtection()
<w:settings ... > <w:documentProtection w:edit="trackedChanges" w:enforcement="1"/>
public void enforceReadonlyProtection()
<w:settings ... > <w:documentProtection w:edit="readOnly" w:enforcement="1"/>
public void enforceFillingFormsProtection()
<w:settings ... > <w:documentProtection w:edit="forms" w:enforcement="1"/>
public void enforceCommentsProtection()
<w:settings ... > <w:documentProtection w:edit="comments" w:enforcement="1"/>
public void enforceTrackedChangesProtection()
<w:settings ... > <w:documentProtection w:edit="trackedChanges" w:enforcement="1"/>
public void removeProtectionEnforcement()
Copyright 2014 The Apache Software Foundation or its licensors, as applicable.