风格¶
Word支持以下定义 styles 允许将一组格式属性轻松且一致地同时应用于段落、排版、表格或编号方案。该机制类似于层叠样式表(Cascading Style Sheet,CSS)处理HTML的方式。
样式在中定义 styles.xml
使用 styleId 字符串。
样式视觉行为¶
排序顺序。 内置样式按其有效值的顺序显示 uiPriority 属性。默认情况下,自定义样式不会收到 uiPriority 属性,使其有效值默认为0。这通常会将自定义样式放在排序顺序的顶部。一组具有相同的风格 uiPriority 值将按字母顺序重新排序。
如果A uiPriority 属性是为自定义样式定义的,该样式根据 uiPriority 值。这个 uiPriority 属性接受有符号整数,并接受负数。注意Word不允许通过其UI使用负整数;相反,它允许 uiPriority 要增加生成所需排序行为的内置类型数。
识别。 样式由其名称标识,而不是由其styleId属性标识。styleId只用于像段落这样的对象与样式的内部链接。styleId可以由应用程序更改,事实上,每次保存时都会按Word进行常规更改,以转换名称。
假设。 Word计算 styleId 从样式名中删除所有空格。
列出成员资格。 “样式”面板中有四个样式列表选项:
推荐。 推荐列表包含所有潜在的和定义的样式 semiHidden =
False
.正在使用的样式。 “使用中的样式”列表包含已应用于文档中内容的所有样式(表示已定义这些样式),并且 semiHidden =
False
.在当前文档中。 “在当前文档中”列表包含文档中定义的所有样式 semiHidden =
False
.所有款式。 “所有样式”列表包含文档中所有潜在和定义的样式。
Definition of built-in style. 将内置样式添加到文档中时(首次使用时),每个 locked , uiPriority 和 qFormat 其潜在样式定义中的属性 latentStyles 属性被任何 lsdException 元素)用于替代插入的样式定义中的相应值,使其不受内置默认值的影响。
每个内置样式都有默认属性,可以通过设置 latentStyles/@count 属性设置为0并在样式管理器中检查样式。这可能包括默认的行为属性。
异常。“无间距”样式不会出现在推荐列表中,即使它的行为属性表明它应该出现。(Google指出这可能是word2003的一种传统风格)。
Word有267种内置样式,如下所示:http://www.thedoctools.com/downloads/DocTools_List_内置_样式_英语_丹麦语_德语_法语.pdf
请注意,至少有一个其他来源的数字是276而不是267。
在样式库中的外观。 在以下情况下,样式将显示在样式库中: semiHidden =
False
和 qFormat =True
术语表¶
- 内置式
一组Word已知的标准样式之一,如“标题1”。无论是否在样式部分实际定义了内置样式,都会在Word的样式面板中显示。
- 潜在风格
在特定文档中没有定义的内置样式称为 潜在风格 在那个文件里。
- 样式定义
A
<w:style>
元素,该元素显式定义样式的属性。- 推荐样式列表
从“列表:”下拉框中选择“推荐”时,将显示在样式工具箱或面板中的样式列表。
言语行为¶
如果在“样式”部分中未定义具有指定样式id的样式,则样式应用程序不起作用。
Word不添加格式定义 (<w:style>
元素)用于内置样式,直到使用为止。
一旦出现在样式部分,如果内置样式定义不再应用于任何内容,Word不会删除它。文档中曾经使用过的每个样式的定义都是在其 styles.xml
.
枚举¶
WdBuiltinStyle
示例XML¶
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<w:styles
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
mc:Ignorable="w14"
>
<w:docDefaults>
<w:rPrDefault>
<w:rPr>
<w:rFonts w:asciiTheme="minorHAnsi" w:eastAsiaTheme="minorEastAsia"
w:hAnsiTheme="minorHAnsi" w:cstheme="minorBidi"/>
<w:sz w:val="24"/>
<w:szCs w:val="24"/>
<w:lang w:val="en-US" w:eastAsia="en-US" w:bidi="ar-SA"/>
</w:rPr>
</w:rPrDefault>
<w:pPrDefault/>
</w:docDefaults>
<w:latentStyles w:defLockedState="0" w:defUIPriority="99" w:defSemiHidden="1"
w:defUnhideWhenUsed="1" w:defQFormat="0" w:count="276">
<w:lsdException w:name="Normal" w:semiHidden="0" w:uiPriority="0"
w:unhideWhenUsed="0" w:qFormat="1"/>
<w:lsdException w:name="heading 1" w:semiHidden="0" w:uiPriority="9"
w:unhideWhenUsed="0" w:qFormat="1"/>
<w:lsdException w:name="heading 2" w:uiPriority="9" w:qFormat="1"/>
<w:lsdException w:name="Default Paragraph Font" w:uiPriority="1"/>
</w:latentStyles>
<w:style w:type="paragraph" w:default="1" w:styleId="Normal">
<w:name w:val="Normal"/>
<w:qFormat/>
</w:style>
<w:style w:type="character" w:default="1" w:styleId="DefaultParagraphFont">
<w:name w:val="Default Paragraph Font"/>
<w:uiPriority w:val="1"/>
<w:semiHidden/>
<w:unhideWhenUsed/>
</w:style>
<w:style w:type="table" w:default="1" w:styleId="TableNormal">
<w:name w:val="Normal Table"/>
<w:uiPriority w:val="99"/>
<w:semiHidden/>
<w:unhideWhenUsed/>
<w:tblPr>
<w:tblInd w:w="0" w:type="dxa"/>
<w:tblCellMar>
<w:top w:w="0" w:type="dxa"/>
<w:left w:w="108" w:type="dxa"/>
<w:bottom w:w="0" w:type="dxa"/>
<w:right w:w="108" w:type="dxa"/>
</w:tblCellMar>
</w:tblPr>
</w:style>
<w:style w:type="numbering" w:default="1" w:styleId="NoList">
<w:name w:val="No List"/>
<w:uiPriority w:val="99"/>
<w:semiHidden/>
<w:unhideWhenUsed/>
</w:style>
<w:style w:type="paragraph" w:customStyle="1" w:styleId="Foobar">
<w:name w:val="Foobar"/>
<w:qFormat/>
<w:rsid w:val="004B54E0"/>
</w:style>
</w:styles>
架构摘要¶
<xsd:complexType name="CT_Styles">
<xsd:sequence>
<xsd:element name="docDefaults" type="CT_DocDefaults" minOccurs="0"/>
<xsd:element name="latentStyles" type="CT_LatentStyles" minOccurs="0"/>
<xsd:element name="style" type="CT_Style" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CT_DocDefaults">
<xsd:sequence>
<xsd:element name="rPrDefault" type="CT_RPrDefault" minOccurs="0"/>
<xsd:element name="pPrDefault" type="CT_PPrDefault" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CT_LatentStyles">
<xsd:sequence>
<xsd:element name="lsdException" type="CT_LsdException" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="defLockedState" type="s:ST_OnOff"/>
<xsd:attribute name="defUIPriority" type="ST_DecimalNumber"/>
<xsd:attribute name="defSemiHidden" type="s:ST_OnOff"/>
<xsd:attribute name="defUnhideWhenUsed" type="s:ST_OnOff"/>
<xsd:attribute name="defQFormat" type="s:ST_OnOff"/>
<xsd:attribute name="count" type="ST_DecimalNumber"/>
</xsd:complexType>
<xsd:complexType name="CT_Style">
<xsd:sequence>
<xsd:element name="name" type="CT_String" minOccurs="0"/>
<xsd:element name="aliases" type="CT_String" minOccurs="0"/>
<xsd:element name="basedOn" type="CT_String" minOccurs="0"/>
<xsd:element name="next" type="CT_String" minOccurs="0"/>
<xsd:element name="link" type="CT_String" minOccurs="0"/>
<xsd:element name="autoRedefine" type="CT_OnOff" minOccurs="0"/>
<xsd:element name="hidden" type="CT_OnOff" minOccurs="0"/>
<xsd:element name="uiPriority" type="CT_DecimalNumber" minOccurs="0"/>
<xsd:element name="semiHidden" type="CT_OnOff" minOccurs="0"/>
<xsd:element name="unhideWhenUsed" type="CT_OnOff" minOccurs="0"/>
<xsd:element name="qFormat" type="CT_OnOff" minOccurs="0"/>
<xsd:element name="locked" type="CT_OnOff" minOccurs="0"/>
<xsd:element name="personal" type="CT_OnOff" minOccurs="0"/>
<xsd:element name="personalCompose" type="CT_OnOff" minOccurs="0"/>
<xsd:element name="personalReply" type="CT_OnOff" minOccurs="0"/>
<xsd:element name="rsid" type="CT_LongHexNumber" minOccurs="0"/>
<xsd:element name="pPr" type="CT_PPrGeneral" minOccurs="0"/>
<xsd:element name="rPr" type="CT_RPr" minOccurs="0"/>
<xsd:element name="tblPr" type="CT_TblPrBase" minOccurs="0"/>
<xsd:element name="trPr" type="CT_TrPr" minOccurs="0"/>
<xsd:element name="tcPr" type="CT_TcPr" minOccurs="0"/>
<xsd:element name="tblStylePr" type="CT_TblStylePr" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="type" type="ST_StyleType"/>
<xsd:attribute name="styleId" type="s:ST_String"/>
<xsd:attribute name="default" type="s:ST_OnOff"/>
<xsd:attribute name="customStyle" type="s:ST_OnOff"/>
</xsd:complexType>
<xsd:complexType name="CT_LsdException">
<xsd:attribute name="name" type="s:ST_String" use="required"/>
<xsd:attribute name="locked" type="s:ST_OnOff"/>
<xsd:attribute name="uiPriority" type="ST_DecimalNumber"/>
<xsd:attribute name="semiHidden" type="s:ST_OnOff"/>
<xsd:attribute name="unhideWhenUsed" type="s:ST_OnOff"/>
<xsd:attribute name="qFormat" type="s:ST_OnOff"/>
</xsd:complexType>
<xsd:complexType name="CT_OnOff">
<xsd:attribute name="val" type="s:ST_OnOff"/>
</xsd:complexType>
<xsd:complexType name="CT_String">
<xsd:attribute name="val" type="s:ST_String" use="required"/>
</xsd:complexType>
<xsd:simpleType name="ST_OnOff">
<xsd:union memberTypes="xsd:boolean ST_OnOff1"/>
</xsd:simpleType>
<xsd:simpleType name="ST_OnOff1">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="on"/>
<xsd:enumeration value="off"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ST_StyleType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="paragraph"/>
<xsd:enumeration value="character"/>
<xsd:enumeration value="table"/>
<xsd:enumeration value="numbering"/>
</xsd:restriction>
</xsd:simpleType>