openxml的style语法定义,备份

来源:互联网 发布:淘宝虚拟物品类目选择 编辑:程序博客网 时间:2024/06/17 17:44
openxml中的风格定义对应的xml语法定义:


<xsd:complexType name="CT_Style">
3071 <xsd:sequence>
3072 <xsd:element name="name" type="CT_String" minOccurs="0" maxOccurs="1"/>
3073 <xsd:element name="aliases" type="CT_String" minOccurs="0"/>
3074 <xsd:element name="basedOn" type="CT_String" minOccurs="0"/>
3075 <xsd:element name="next" type="CT_String" minOccurs="0"/>
3076 <xsd:element name="link" type="CT_String" minOccurs="0"/>
3077 <xsd:element name="autoRedefine" type="CT_OnOff" minOccurs="0"/>
3078 <xsd:element name="hidden" type="CT_OnOff" minOccurs="0"/>
3079 <xsd:element name="uiPriority" type="CT_DecimalNumber" minOccurs="0"/>
3080 <xsd:element name="semiHidden" type="CT_OnOff" minOccurs="0"/>
3081 <xsd:element name="unhideWhenUsed" type="CT_OnOff" minOccurs="0"/>
3082 <xsd:element name="qFormat" type="CT_OnOff" minOccurs="0"/>
3083 <xsd:element name="locked" type="CT_OnOff" minOccurs="0"/>
3084 <xsd:element name="personal" type="CT_OnOff" minOccurs="0"/>
3085 <xsd:element name="personalCompose" type="CT_OnOff" minOccurs="0"/>
3086 <xsd:element name="personalReply" type="CT_OnOff" minOccurs="0"/>
3087 <xsd:element name="rsid" type="CT_LongHexNumber" minOccurs="0"/>
3088 <xsd:element name="pPr" type="CT_PPrGeneral" minOccurs="0" maxOccurs="1"/>
3089 <xsd:element name="rPr" type="CT_RPr" minOccurs="0" maxOccurs="1"/>
3090 <xsd:element name="tblPr" type="CT_TblPrBase" minOccurs="0" maxOccurs="1"/>
3091 <xsd:element name="trPr" type="CT_TrPr" minOccurs="0" maxOccurs="1"/>
3092 <xsd:element name="tcPr" type="CT_TcPr" minOccurs="0" maxOccurs="1"/>
3093 <xsd:element name="tblStylePr" type="CT_TblStylePr" minOccurs="0" maxOccurs="unbounded"/>
3094 </xsd:sequence>
3095 <xsd:attribute name="type" type="ST_StyleType" use="optional"/>
3096 <xsd:attribute name="styleId" type="s:ST_String" use="optional"/>
3097 <xsd:attribute name="default" type="s:ST_OnOff" use="optional"/>
3098 <xsd:attribute name="customStyle" type="s:ST_OnOff" use="optional"/>
3099 </xsd:complexType>


style的层级覆盖优先关系:

This process can be described as follows:
 First, the document defaults are applied to all runs and paragraphs in the document.

run:是字符一级,paragraph:是段落
对run和paragraph,最优先的是default
而table和listitem根本没有default


 Next, the table style properties are applied to each table in the document, following the conditional
formatting inclusions and exclusions specified per table.

然后,table属性会应用到table,run和paragraph,但是不对listitem生效


 Next, numbered item and paragraph properties are applied to each paragraph formatted with a
numbering style.

然后是编号项目和段落,也许编号项目本身的style不会定义段落格式,所以会使用两个style来描述编号项目


 Next, paragraph and run properties are applied to each paragraph as defined by the paragraph style.
 Next, run properties are applied to each run with a specific character style applied.

对于段落和run,显示paragraph然后是character被用到文字上


 Finally, we apply direct formatting (paragraph or run properties not from styles). If this direct formatting
includes numbering, that numbering + the associated paragraph properties are applied.

最后是直接写在段落和run上属性


If the value of the rFonts element (§17.3.2.26) references a font which is not available, applications determine a
suitable alternative font via a process called font substitution, which is defined in §17.8.2.

最后一段,还有个font substitution


看了一遍,style的有用属性/子元素,只有下面这几个需要关注
type:
貌似也没有分析的必要。word判断一段文字是否能应用这个style的时候,应该会看这个style的type,读取分析过程,应该不用管

styleid

以styleid为主要识别id

name
可能只要在显示错误信息的时候,要用这个值,作为友好信息

basedon:
指定父Style。继承关系的意思。
继承可以多层。
只有相同类型的style之间才能继承。
如:paragraph继承paragraph,如果类型不匹配则ignore


linked:
将两个style链接在一起,作为一个整体应用到段落和文字

 If the parent style is a table style, then this element shall be ignored.
 If the parent style is a paragraph style, then this element’s val attribute must refer to a character style,
or this element shall be ignored.
 If the parent style is a character style, then this element’s val attribute must refer to a paragraph style,
or this element shall be ignored.
 If the parent style is a numbering style, then this element shall be ignored.

paragraph只能link character
character只能link paragraph
table和numbering都要ignore掉link属性


next:
说明应用了这个style的paragraph之后的paragraph,默认使用什么style
如果这个元素在paragraph类的style之外的style中出现,则被ignore
如果这个元素没有出现,则下一paragraph的style使用和上一段相同的style


0 0
原创粉丝点击