Package org.apache.poi.xwpf.usermodel
Class XWPFStyles
java.lang.Object
org.apache.poi.ooxml.POIXMLDocumentPart
org.apache.poi.xwpf.usermodel.XWPFStyles
Holds details of built-in, default and user styles, which
apply to tables / paragraphs / lists etc.
Text within one of those with custom stylings has the style
information stored in the
XWPFRun-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
POIXMLDocumentPart.RelationPart -
Constructor Summary
ConstructorsConstructorDescriptionConstruct XWPFStyles from scratch for a new document.XWPFStyles(PackagePart part) Construct XWPFStyles from a package part -
Method Summary
Modifier and TypeMethodDescriptionvoidadd a style to the documentGet the default paragraph style which applies to the documentGet the default style which applies text runs in the documentGet the definition of all the Latent StylesintGet style by a styleIDgetStyleWithName(String styleName) Get the style with the specified name, if any.getStyleWithSameName(XWPFStyle style) get the style with the same name if this style is not existing, return nullgetUsedStyleList(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 documentvoidsetDefaultFonts(CTFonts fonts) Sets the default font on ctStyles DocDefaults parameter TODO Replace this with specific setters for each type, possibly on XWPFDefaultRunStylevoidsetEastAsia(String strEastAsia) Sets the default East Asia spelling language on ctStyles DocDefaults parametervoidsetSpellingLanguage(String strSpellingLanguage) Sets the default spelling language on ctStyles DocDefaults parametervoidSets the ctStylesbooleanstyleExist(String styleID) checks whether style with styleID existMethods inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, isCommitted, setCommitted, toString
-
Constructor Details
-
XWPFStyles
Construct XWPFStyles from a package part- Parameters:
part- the package part holding the data of the styles,- Since:
- POI 3.14-Beta1
-
XWPFStyles
public XWPFStyles()Construct XWPFStyles from scratch for a new document.
-
-
Method Details
-
setStyles
Sets the ctStyles- Parameters:
styles- The CTStyles object to set
-
styleExist
checks whether style with styleID exist- Parameters:
styleID- styleID of the Style in the style-Document- Returns:
- true if style exist, false if style not exist
-
addStyle
add a style to the document- Parameters:
style- The style to add
-
getStyle
Get style by a styleID- Parameters:
styleID- styleID of the searched style- Returns:
- style
-
getNumberOfStyles
public int getNumberOfStyles() -
getUsedStyleList
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- Parameters:
style- The style to look for- Returns:
- a list of all styles which were used by this method
-
setSpellingLanguage
Sets the default spelling language on ctStyles DocDefaults parameter- Parameters:
strSpellingLanguage- the default spelling language to use
-
setEastAsia
Sets the default East Asia spelling language on ctStyles DocDefaults parameter- Parameters:
strEastAsia- The default East Asia spelling language to use
-
setDefaultFonts
Sets the default font on ctStyles DocDefaults parameter TODO Replace this with specific setters for each type, possibly on XWPFDefaultRunStyle -
getStyleWithSameName
get the style with the same name if this style is not existing, return null -
getDefaultRunStyle
Get the default style which applies text runs in the document -
getDefaultParagraphStyle
Get the default paragraph style which applies to the document -
getLatentStyles
Get the definition of all the Latent Styles -
getStyleWithName
Get the style with the specified name, if any.- Parameters:
styleName- The name of the style to get, e.g., "Heading 1"- Returns:
XWPFStylewith the specified name, or null if not found.
-