Package org.apache.poi.xwpf.usermodel
Class XWPFSettings
java.lang.Object
org.apache.poi.ooxml.POIXMLDocumentPart
org.apache.poi.xwpf.usermodel.XWPFSettings
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
POIXMLDocumentPart.RelationPart -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcommit()Save the content in the underlying package part.booleanCheck if separate even and odd headings is turned on.booleanCheck if mirrored margins is turned onlongSet zoom.
In the zoom tag inside settings.xml file
it sets the value of zoom
sample snippet from settings.xmlbooleanVerifies the documentProtection tag inside settings.xml file
if the protection is enforced (w:enforcement="1")booleanisEnforcedWith(org.openxmlformats.schemas.wordprocessingml.x2006.main.STDocProtect.Enum editValue) Verifies the documentProtection tag inside settings.xml file
if the protection is enforced (w:enforcement="1")
and if the kind of protection equals to passed (STDocProtect.Enum editValue)booleanCheck if revision tracking is turned on.protected voidFired when a package part is readvoidRemoves protection enforcement.
In the documentProtection tag inside settings.xml file
it sets the value of enforcement to "0" (w:enforcement="0")voidsetEnforcementEditValue(org.openxmlformats.schemas.wordprocessingml.x2006.main.STDocProtect.Enum editValue) Enforces the protection with the option specified by passed editValue.
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 the passed editValue (w:edit="[passed editValue]")
sample snippet from settings.xmlvoidsetEnforcementEditValue(org.openxmlformats.schemas.wordprocessingml.x2006.main.STDocProtect.Enum editValue, String password, HashAlgorithm hashAlgo) Enforces the protection with the option specified by passed editValue and password.
sample snippet from settings.xmlvoidsetEvenAndOddHeadings(boolean enable) Turn separate even-and-odd headings on or offvoidsetMirrorMargins(boolean enable) Turn mirrored margins on or offvoidsetTrackRevisions(boolean enable) Enable or disable revision tracking.voidEnforces fields update on document open (in Word).voidsetZoomPercent(long zoomPercent) Set zoom.
In the zoom tag inside settings.xml file
it sets the value of zoom
sample snippet from settings.xmlbooleanvalidateProtectionPassword(String password) Validates the existing passwordMethods inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommited, onDocumentCreate, onDocumentRemove, onSave, prepareForCommit, read, rebase, removeRelation, removeRelation, removeRelation, setCommited, toString
-
Constructor Details
-
XWPFSettings
- Throws:
IOException- Since:
- POI 3.14-Beta1
-
XWPFSettings
public XWPFSettings()
-
-
Method Details
-
onDocumentRead
Description copied from class:POIXMLDocumentPartFired when a package part is read- Overrides:
onDocumentReadin classPOIXMLDocumentPart- Throws:
IOException- a subclass may throw an IOException when a document is read
-
getZoomPercent
public long getZoomPercent()Set zoom.
In the zoom tag inside settings.xml file
it sets the value of zoom
sample snippet from settings.xml<w:zoom w:percent="50" />- Returns:
- percentage as an integer of zoom level
-
setZoomPercent
public void setZoomPercent(long zoomPercent) Set zoom.
In the zoom tag inside settings.xml file
it sets the value of zoom
sample snippet from settings.xml<w:zoom w:percent="50" /> -
isEnforcedWith
public boolean isEnforcedWith()Verifies the documentProtection tag inside settings.xml file
if the protection is enforced (w:enforcement="1")
sample snippet from settings.xml<w:settings ... > <w:documentProtection w:edit="readOnly" w:enforcement="1"/>- Returns:
- true if documentProtection is enforced with option any
-
isEnforcedWith
public boolean isEnforcedWith(org.openxmlformats.schemas.wordprocessingml.x2006.main.STDocProtect.Enum editValue) Verifies the documentProtection tag inside settings.xml file
if the protection is enforced (w:enforcement="1")
and if the kind of protection equals to passed (STDocProtect.Enum editValue)
sample snippet from settings.xml<w:settings ... > <w:documentProtection w:edit="readOnly" w:enforcement="1"/>- Returns:
- true if documentProtection is enforced with option readOnly
-
setEnforcementEditValue
public void setEnforcementEditValue(org.openxmlformats.schemas.wordprocessingml.x2006.main.STDocProtect.Enum editValue) Enforces the protection with the option specified by passed editValue.
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 the passed editValue (w:edit="[passed editValue]")
sample snippet from settings.xml<w:settings ... > <w:documentProtection w:edit="[passed editValue]" w:enforcement="1"/> -
setEnforcementEditValue
public void setEnforcementEditValue(org.openxmlformats.schemas.wordprocessingml.x2006.main.STDocProtect.Enum editValue, String password, HashAlgorithm hashAlgo) Enforces the protection with the option specified by passed editValue and password.
sample snippet from settings.xml<w:documentProtection w:edit="[passed editValue]" w:enforcement="1" w:cryptProviderType="rsaAES" w:cryptAlgorithmClass="hash" w:cryptAlgorithmType="typeAny" w:cryptAlgorithmSid="14" w:cryptSpinCount="100000" w:hash="..." w:salt="...." />- Parameters:
editValue- the protection typepassword- the plaintext password, if null no password will be appliedhashAlgo- the hash algorithm - only md2, m5, sha1, sha256, sha384 and sha512 are supported. if null, it will default default to sha1
-
validateProtectionPassword
Validates the existing password- Parameters:
password-- Returns:
- true, only if password was set and equals, false otherwise
-
removeEnforcement
public void removeEnforcement()Removes protection enforcement.
In the documentProtection tag inside settings.xml file
it sets the value of enforcement to "0" (w:enforcement="0") -
setUpdateFields
public void setUpdateFields()Enforces fields update on document open (in Word). In the settings.xml file
sets the updateSettings value to true (w:updateSettings w:val="true")NOTICES:
- Causing Word to ask on open: "This document contains fields that may refer to other files. Do you want to update the fields in this document?" (if "Update automatic links at open" is enabled)
- Flag is removed after saving with changes in Word
-
isTrackRevisions
public boolean isTrackRevisions()Check if revision tracking is turned on.- Returns:
trueif revision tracking is turned on
-
setTrackRevisions
public void setTrackRevisions(boolean enable) Enable or disable revision tracking.- Parameters:
enable-trueto turn on revision tracking,falseto turn off revision tracking
-
commit
Description copied from class:POIXMLDocumentPartSave 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:
commitin classPOIXMLDocumentPart- Throws:
IOException- a subclass may throw an IOException if the changes can't be committed
-
getEvenAndOddHeadings
public boolean getEvenAndOddHeadings()Check if separate even and odd headings is turned on.- Returns:
- True if even and odd headings is turned on.
-
setEvenAndOddHeadings
public void setEvenAndOddHeadings(boolean enable) Turn separate even-and-odd headings on or off- Parameters:
enable-trueto turn on separate even and odd headings,falseto turn off even and odd headings.
-
getMirrorMargins
public boolean getMirrorMargins()Check if mirrored margins is turned on- Returns:
- True if mirrored margins is turned on.
-
setMirrorMargins
public void setMirrorMargins(boolean enable) Turn mirrored margins on or off- Parameters:
enable-trueto turn on mirrored margins,falseto turn off mirrored marginss.
-