public class XWPFStyles extends POIXMLDocumentPart
XWPFRunPOIXMLDocumentPart.RelationPart| Constructor and Description |
|---|
XWPFStyles()
Construct XWPFStyles from scratch for a new document.
|
XWPFStyles(PackagePart part)
Construct XWPFStyles from a package part
|
| Modifier and Type | Method and Description |
|---|---|
void |
addStyle(XWPFStyle style)
add a style to the document
|
protected void |
commit()
Save the content in the underlying package part.
|
protected void |
ensureDocDefaults() |
protected org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLanguage |
getCTLanguage() |
org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyles |
getCtStyles()
Gets the underlying CTStyles object for the Styles.
|
XWPFDefaultParagraphStyle |
getDefaultParagraphStyle()
Get the default paragraph style which applies to the document
|
XWPFDefaultRunStyle |
getDefaultRunStyle()
Get the default style which applies text runs in the document
|
XWPFLatentStyles |
getLatentStyles()
Get the definition of all the Latent Styles
|
int |
getNumberOfStyles() |
XWPFStyle |
getStyle(String styleID)
Get style by a styleID
|
List<XWPFStyle> |
getStyles()
Get the list of
XWPFStyle in the Styles part. |
XWPFStyle |
getStyleWithName(String styleName)
Get the style with the specified name, if any.
|
XWPFStyle |
getStyleWithSameName(XWPFStyle style)
get the style with the same name
if this style is not existing, return null
|
List<XWPFStyle> |
getUsedStyleList(XWPFStyle style)
get the styles which are related to the parameter style and their relatives
this method can be used to copy all styles from one document to another document
|
protected void |
onDocumentRead()
Read document
|
boolean |
removeStyle(int pos)
Remove the specified style if present.
|
void |
setDefaultFonts(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts fonts)
Sets the default font on ctStyles DocDefaults parameter
TODO Replace this with specific setters for each type, possibly
on XWPFDefaultRunStyle
|
void |
setEastAsia(String strEastAsia)
Sets the default East Asia spelling language on ctStyles DocDefaults parameter
|
void |
setSpellingLanguage(String strSpellingLanguage)
Sets the default spelling language on ctStyles DocDefaults parameter
|
void |
setStyles(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyles styles)
Sets the ctStyles
|
boolean |
styleExist(String styleID)
checks whether style with styleID exist
|
_invokeOnDocumentRead, addRelation, createHyperlink, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getReferenceRelationship, getReferenceRelationships, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommitted, onDocumentCreate, onDocumentRemove, onSave, prepareForCommit, read, rebase, removeReferenceRelationship, removeRelation, removeRelation, removeRelation, setCommitted, toStringpublic XWPFStyles(PackagePart part)
part - the package part holding the data of the styles,public XWPFStyles()
protected void onDocumentRead()
throws IOException
onDocumentRead in class POIXMLDocumentPartIOException - a subclass may throw an IOException when a document is readprotected void commit()
throws IOException
POIXMLDocumentPartSub-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();
try (OutputStream out = part.getOutputStream()) {
XmlObject bean = getXmlBean(); //the "model" which holds changes in memory
bean.save(out, DEFAULT_XML_OPTIONS);
}
}
commit in class POIXMLDocumentPartIOException - a subclass may throw an IOException if the changes can't be committedprotected void ensureDocDefaults()
public void setStyles(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyles styles)
styles - The CTStyles object to setpublic org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyles getCtStyles()
public List<XWPFStyle> getStyles()
XWPFStyle in the Styles part.public boolean removeStyle(int pos)
pos - Array position of the style to be removedpublic boolean styleExist(String styleID)
styleID - styleID of the Style in the style-Documentpublic void addStyle(XWPFStyle style)
style - The style to addpublic XWPFStyle getStyle(String styleID)
styleID - styleID of the searched stylepublic int getNumberOfStyles()
public List<XWPFStyle> getUsedStyleList(XWPFStyle style)
style - The style to look forprotected org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLanguage getCTLanguage()
public void setSpellingLanguage(String strSpellingLanguage)
strSpellingLanguage - the default spelling language to usepublic void setEastAsia(String strEastAsia)
strEastAsia - The default East Asia spelling language to usepublic void setDefaultFonts(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts fonts)
public XWPFStyle getStyleWithSameName(XWPFStyle style)
public XWPFDefaultRunStyle getDefaultRunStyle()
public XWPFDefaultParagraphStyle getDefaultParagraphStyle()
public XWPFLatentStyles getLatentStyles()