public class XWPFStyles extends POIXMLDocumentPart
XWPFRun
(包含适用于表格/段落/列表等的内置、默认和用户样式的详细信息。具有自定义样式之一的文本具有存储在 XWPFRun 中的样式信息)
POIXMLDocumentPart.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() |
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(java.lang.String styleID)
Get style by a styleID
(通过 styleID 获取样式)
|
XWPFStyle |
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 null
(如果该样式不存在,则获取同名样式,返回null)
|
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
(获取与参数样式相关的样式及其亲属此方法可用于将所有样式从一个文档复制到另一个文档)
|
protected void |
onDocumentRead()
Read document
(阅读文件)
|
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
(在 ctStyles DocDefaults 参数 TODO 上设置默认字体 将其替换为每种类型的特定设置器,可能在 XWPFDefaultRunStyle 上)
|
void |
setEastAsia(java.lang.String strEastAsia)
Sets the default East Asia spelling language on ctStyles DocDefaults parameter
(在 ctStyles DocDefaults 参数上设置默认东亚拼写语言)
|
void |
setSpellingLanguage(java.lang.String strSpellingLanguage)
Sets the default spelling language on ctStyles DocDefaults parameter
(在 ctStyles DocDefaults 参数上设置默认拼写语言)
|
void |
setStyles(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyles styles)
Sets the ctStyles
(设置 ctStyles)
|
boolean |
styleExist(java.lang.String styleID)
checks whether style with styleID exist
(检查带有 styleID 的样式是否存在)
|
_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommitted, onDocumentCreate, onDocumentRemove, onSave, prepareForCommit, read, rebase, removeRelation, removeRelation, removeRelation, setCommitted, toString
public XWPFStyles(PackagePart part)
part
- the package part holding the data of the styles,
(part - 包含样式数据的包部分,)
public XWPFStyles()
protected void onDocumentRead() throws java.io.IOException
onDocumentRead
in class
POIXMLDocumentPart
java.io.IOException
- a subclass may throw an IOException when a document is read
(java.io.IOException - 读取文档时子类可能会抛出 IOException)
protected void commit() throws java.io.IOException
POIXMLDocumentPart
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(); }(将内容保存在底层包部分中。默认实现是空的,这意味着包部分保持不变。子类应覆盖并添加逻辑以将“模型”编组到 Ooxml4J。例如,保存通用 XML 条目的代码可能如下所示: protected void commit() throws IOException { PackagePart part = getPackagePart();输出流输出 = part.getOutputStream(); XmlObject bean = getXmlBean(); //保存内存变化的“模型” bean.save(out, DEFAULT_XML_OPTIONS); out.close(); })
commit
in class
POIXMLDocumentPart
java.io.IOException
- a subclass may throw an IOException if the changes can't be committed
(java.io.IOException - 如果无法提交更改,子类可能会抛出 IOException)
protected void ensureDocDefaults()
public void setStyles(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyles styles)
styles
-
(款式——)
public boolean styleExist(java.lang.String styleID)
styleID
- styleID of the Style in the style-Document
(styleID - style-Document 中 Style 的 styleID)
public void addStyle(XWPFStyle style)
style
-
(风格 -)
java.io.IOException
(java.io.IOException)
public XWPFStyle getStyle(java.lang.String styleID)
styleID
- styleID of the searched style
(styleID - 搜索到的样式的 styleID)
public int getNumberOfStyles()
public java.util.List<XWPFStyle> getUsedStyleList(XWPFStyle style)
style
-
(风格 -)
protected org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLanguage getCTLanguage()
public void setSpellingLanguage(java.lang.String strSpellingLanguage)
strSpellingLanguage
-
(strSpellingLanguage -)
public void setEastAsia(java.lang.String strEastAsia)
strEastAsia
-
(str东亚 -)
public void setDefaultFonts(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts fonts)
public XWPFStyle getStyleWithSameName(XWPFStyle style)
public XWPFDefaultRunStyle getDefaultRunStyle()
public XWPFDefaultParagraphStyle getDefaultParagraphStyle()
public XWPFLatentStyles getLatentStyles()
public XWPFStyle getStyleWithName(java.lang.String styleName)
styleName
- The name of the style to get, e.g., "Heading 1"
(styleName - 要获取的样式名称,例如“标题 1”)
XWPFStyle
with the specified name, or null if not found.
(具有指定名称的 XWPFStyle,如果未找到,则返回 null。)
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.