Package org.apache.poi.xwpf.usermodel
Class XWPFStyles
- java.lang.Object
-
- org.apache.poi.ooxml.POIXMLDocumentPart
-
- org.apache.poi.xwpf.usermodel.XWPFStyles
-
public class XWPFStyles extends POIXMLDocumentPart
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 theXWPFRun
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
POIXMLDocumentPart.RelationPart
-
-
Constructor Summary
Constructors Constructor Description XWPFStyles()
Construct XWPFStyles from scratch for a new document.XWPFStyles(PackagePart part)
Construct XWPFStyles from a package part
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addStyle(XWPFStyle style)
add a style to the documentXWPFDefaultParagraphStyle
getDefaultParagraphStyle()
Get the default paragraph style which applies to the documentXWPFDefaultRunStyle
getDefaultRunStyle()
Get the default style which applies text runs in the documentXWPFLatentStyles
getLatentStyles()
Get the definition of all the Latent Stylesint
getNumberOfStyles()
XWPFStyle
getStyle(java.lang.String styleID)
Get style by a styleIDXWPFStyle
getStyleWithName(java.lang.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 nulljava.util.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 documentvoid
setDefaultFonts(CTFonts fonts)
Sets the default font on ctStyles DocDefaults parameter TODO Replace this with specific setters for each type, possibly on XWPFDefaultRunStylevoid
setEastAsia(java.lang.String strEastAsia)
Sets the default East Asia spelling language on ctStyles DocDefaults parametervoid
setSpellingLanguage(java.lang.String strSpellingLanguage)
Sets the default spelling language on ctStyles DocDefaults parametervoid
setStyles(CTStyles styles)
Sets the ctStylesboolean
styleExist(java.lang.String styleID)
checks whether style with styleID exist-
Methods inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, isCommited, setCommited, toString
-
-
-
-
Constructor Detail
-
XWPFStyles
public XWPFStyles(PackagePart part) throws java.io.IOException, OpenXML4JException
Construct XWPFStyles from a package part- Parameters:
part
- the package part holding the data of the styles,- Throws:
java.io.IOException
OpenXML4JException
- Since:
- POI 3.14-Beta1
-
XWPFStyles
public XWPFStyles()
Construct XWPFStyles from scratch for a new document.
-
-
Method Detail
-
setStyles
public void setStyles(CTStyles styles)
Sets the ctStyles- Parameters:
styles
-
-
styleExist
public boolean styleExist(java.lang.String styleID)
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
public void addStyle(XWPFStyle style)
add a style to the document- Parameters:
style
-- Throws:
java.io.IOException
-
getStyle
public XWPFStyle getStyle(java.lang.String styleID)
Get style by a styleID- Parameters:
styleID
- styleID of the searched style- Returns:
- style
-
getNumberOfStyles
public int getNumberOfStyles()
-
getUsedStyleList
public java.util.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- Parameters:
style
-- Returns:
- a list of all styles which were used by this method
-
setSpellingLanguage
public void setSpellingLanguage(java.lang.String strSpellingLanguage)
Sets the default spelling language on ctStyles DocDefaults parameter- Parameters:
strSpellingLanguage
-
-
setEastAsia
public void setEastAsia(java.lang.String strEastAsia)
Sets the default East Asia spelling language on ctStyles DocDefaults parameter- Parameters:
strEastAsia
-
-
setDefaultFonts
public void setDefaultFonts(CTFonts fonts)
Sets the default font on ctStyles DocDefaults parameter TODO Replace this with specific setters for each type, possibly on XWPFDefaultRunStyle
-
getStyleWithSameName
public XWPFStyle getStyleWithSameName(XWPFStyle style)
get the style with the same name if this style is not existing, return null
-
getDefaultRunStyle
public XWPFDefaultRunStyle getDefaultRunStyle()
Get the default style which applies text runs in the document
-
getDefaultParagraphStyle
public XWPFDefaultParagraphStyle getDefaultParagraphStyle()
Get the default paragraph style which applies to the document
-
getLatentStyles
public XWPFLatentStyles getLatentStyles()
Get the definition of all the Latent Styles
-
-