w:rPr 与 w:pPr 在 OOXML (DOCX) 中的用途? [英] Purpose of w:rPr versus w:pPr in OOXML (DOCX)?

查看:1334
本文介绍了w:rPr 与 w:pPr 在 OOXML (DOCX) 中的用途?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Office Open XML 架构感到困惑:w:rPr 标记在 w:pPr 标记内部时似乎不起作用.

<w:pPr><w:rPr><w:b/><w:sz w:val="36"/><w:szCs w:val="36"/></w:rPr></w:pPr><w:r w:rsidRPr="004A77F9"><w:rPr><w:b/><w:sz w:val="36"/><w:szCs w:val="36"/></w:rPr><w:t xml:space="保留">业务</w:t></w:r><w:r w:rsidRPr="004A77F9"><w:t xml:space="保留">计划文件</w:t></w:r></w:p>

第一个 w:r 标签有一个 w:rPr 标签,其中包括粗体 (w:b) 和字体大小 (w:sz) 所以部分样式采用粗体和 docx 输出时的字体大小样式.

最后一个 w:r 标签没有 w:rPr 标签,所以这部分在 docx 输出时没有样式.

那为什么 w:pPr 标签在完全没用的情况下还有 w:rPr 样式?

解决方案

OOXML 字符属性可以应用于段落 (w:p/w:pPr) 或运行 (w:r/w:rPr) 级别.运行级别的属性会覆盖段落级别的属性.

在您的特定示例中,目前没有(一般,但请参阅下面的注释 2)段落级属性和一个运行级属性,它负责 BUSINESS 为粗体.>

注意事项:

  1. 对于任何给定的效果,不能保证字符属性将被规范化为最小表示.

  2. 当一个 w:rPr 元素出现在 一个 w:pPr 中时,

    <w:rPr><w:b/><w:sz w:val="36"/><w:szCs w:val="36"/></w:rPr></w:pPr>

    它仅适用于段落字形 (¶).(是的,这是一个相当深奥的功能.)如果你想格式化段落字形,在那里添加属性;如果您不是特别关心段落字形,您可以移除 w:pPr/w:rPr 包装器并允许其属性应用于段落级别:

    <w:b/><w:sz w:val="36"/><w:szCs w:val="36"/></w:pPr>

I'm confused about Office Open XML architecture: w:rPr tag doesn't seem to be working when inside of a w:pPr tag.

<w:p w:rsidR="00573C57" w:rsidRPr="004A77F9" w:rsidRDefault="00573C57" w:rsidP="006F57C5">
    <w:pPr>
        <w:rPr>
            <w:b />
            <w:sz w:val="36" />
            <w:szCs w:val="36" />
        </w:rPr>
    </w:pPr>
    <w:r w:rsidRPr="004A77F9">
        <w:rPr>
            <w:b />
            <w:sz w:val="36" />
            <w:szCs w:val="36" />
        </w:rPr>
        <w:t xml:space="preserve"> BUSINESS</w:t>
    </w:r>
    <w:r w:rsidRPr="004A77F9">
        <w:t xml:space="preserve"> PLAN FILE</w:t>
    </w:r>
</w:p>

First w:r tag has a w:rPr tag which including bold (w:b) and font-size (w:sz) so section style taking bold and font-size style when docx outputting.

Last w:r tag hasn't w:rPr tag so this section has no style when docx outputting.

Then why w:pPr tag has w:rPr style when totally useless?

解决方案

OOXML character properties can be applied at the paragraph (w:p/w:pPr) or run (w:r/w:rPr) levels. Properties at the run level override those at the paragraph level.

In your particular example, there are currently no (general, but see note #2 below) paragraph-level properties and one run-level property, which is responsible for BUSINESS being bold.

Notes:

  1. There's no guarantee that character properties will be normalized to a minimal representation for any given effect.

  2. When a w:rPr element appears within a w:pPr,

    <w:pPr>
        <w:rPr>
            <w:b />
            <w:sz w:val="36" />
            <w:szCs w:val="36" />
        </w:rPr>
    </w:pPr>
    

    it applies only to the paragraph glyph (¶). (Yes, it's a rather esoteric feature.) If you want to format the paragraph glyph, add properties there; if you do not particularly care about the paragraph glyph, you can remove the w:pPr/w:rPr wrapper and allow its properties to apply at the paragraph level:

    <w:pPr>
        <w:b />
        <w:sz w:val="36" />
        <w:szCs w:val="36" />
    </w:pPr>
    

这篇关于w:rPr 与 w:pPr 在 OOXML (DOCX) 中的用途?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆