StoryFragment 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示 XPS 文档中故事的全部或部分内容。
public ref class StoryFragment
public ref class StoryFragment : System::Collections::Generic::IEnumerable<System::Windows::Documents::DocumentStructures::BlockElement ^>, System::Windows::Markup::IAddChild
public class StoryFragment
[System.Windows.Markup.ContentProperty("BlockElementList")]
public class StoryFragment : System.Collections.Generic.IEnumerable<System.Windows.Documents.DocumentStructures.BlockElement>, System.Windows.Markup.IAddChild
type StoryFragment = class
interface IAddChild
[<System.Windows.Markup.ContentProperty("BlockElementList")>]
type StoryFragment = class
interface IAddChild
interface seq<BlockElement>
interface IEnumerable
[<System.Windows.Markup.ContentProperty("BlockElementList")>]
type StoryFragment = class
interface seq<BlockElement>
interface IEnumerable
interface IAddChild
Public Class StoryFragment
Public Class StoryFragment
Implements IAddChild, IEnumerable(Of BlockElement)
- 继承
-
StoryFragment
- 特性
- 实现
示例
下面的示例演示 <StoryFragment> XML 纸张规范 (XPS) 文档的一部分。
<StoryFragment StoryName="DocumentBody" FragmentType="Content">
<SectionStructure>
<ParagraphStructure>
<NamedElement NameReference="Pg1Heading1" />
</ParagraphStructure>
<ParagraphStructure>
<NamedElement NameReference="Pg1P1" />
</ParagraphStructure>
<ParagraphStructure>
<NamedElement NameReference="Pg1P2" />
</ParagraphStructure>
<ParagraphStructure>
<NamedElement NameReference="Pg1P3" />
</ParagraphStructure>
<ParagraphStructure>
<NamedElement NameReference="Pg1P4" />
</ParagraphStructure>
<ParagraphStructure>
<NamedElement NameReference="Pg1P5" />
</ParagraphStructure>
<ParagraphStructure>
<NamedElement NameReference="Pg1Heading2" />
</ParagraphStructure>
<ParagraphStructure>
<NamedElement NameReference="Pg1P6" />
</ParagraphStructure>
<ParagraphStructure>
<NamedElement NameReference="Pg1P7" />
</ParagraphStructure>
<TableStructure>
<TableRowGroupStructure>
<TableRowStructure>
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="R1C1P1" />
</ParagraphStructure>
</TableCellStructure>
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="R1C2P1" />
</ParagraphStructure>
</TableCellStructure>
</TableRowStructure>
<TableRowStructure>
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="R2C1P1" />
</ParagraphStructure>
</TableCellStructure>
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="R2C2P1" />
</ParagraphStructure>
<ParagraphStructure>
<NamedElement NameReference="R2C2P2" />
</ParagraphStructure>
</TableCellStructure>
</TableRowStructure>
<TableRowStructure>
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="R3C1P1" />
</ParagraphStructure>
</TableCellStructure>
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="R3C2P1" />
</ParagraphStructure>
</TableCellStructure>
</TableRowStructure>
<TableRowStructure>
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="R4C1P1" />
</ParagraphStructure>
</TableCellStructure>
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="R4C2P1" />
</ParagraphStructure>
</TableCellStructure>
</TableRowStructure>
<TableRowStructure>
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="R5C1P1" />
</ParagraphStructure>
</TableCellStructure>
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="R5C2P1" />
</ParagraphStructure>
</TableCellStructure>
</TableRowStructure>
</TableRowGroupStructure>
</TableStructure>
</SectionStructure>
</StoryFragment>
注解
XPS 文档中的 XPS 故事大致类似于报纸或杂志中的故事。 它是文本和图形内容的段落,通常位于单个 XPS 文档中的单个主题上。 通常,它跨越多个页面,但它可能比一个页面短,如边栏 - 装箱的故事 - 在杂志。 故事也可以不连续,就像第四页继续的头版报纸故事一样。 因此,给定的页面可以有多个故事和多个故事的一部分。 页眉或页脚也是一种完全包含在单个页面上的特殊故事。
一个 StoryFragment 表示故事的所有或一部分。 它永远不能跨越多个页面,但它可以占据整个页面或与其他片段共享页面。 如果故事位于多个页面上,则每个页面上的每个部分都是一个单独的片段。 虽然故事可以有不连续的片段集,但任何片段本身都不能不连续。
只有一个 StoryFragments 元素才能是一个 StoryFragment. 的父级。 元素在元素StoryBreak中的位置StoryFragment指示故事是否包含在多个片段中,以及其他片段位于当前片段之前或之后。
当一StoryFragment些结构元素中间的结尾时,例如,<TableRowGroupStructure>XPS 文档生成应用程序必须在标记之前</TableRowGroupStructure>为元素(在本例</StoryFragment>中)插入适当的结束标记,即使结构在后面的片段中仍在继续。 (这是确保元素树内 StoryFragment 有效的 XML 所必需的。延续故事的片段必须以中断结构的开始标记开头。 必须以相同的方式处理中断结构的整个树(下面讨论过一个例外):必须为每个不匹配的起始标记添加中断点上方的结束标记。
当故事中断在标记之后 </TableCellStructure> 立即发生时,则生成应用程序必须在延续故事的片段中的相应点插入一个空表单元格结构(<TableCellStructure></TableCellStructure>)。 这是必需的,因此,使用需要合并给定故事的所有片段的应用程序可以使用简单的算法来执行此操作。
例如,假设应用程序想要将以下材料添加到 XPS 文档:
<SectionStructure>
<TableStructure>
<TableRowGroupStructure>
<TableRowStructure>
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="SomeContent" />
</ParagraphStructure>
</TableCellStructure>
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="MoreContent" />
</ParagraphStructure>
</TableCellStructure>
</TableRowStructure>
<TableRowStructure>
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="EvenMoreContent" />
</ParagraphStructure>
</TableCellStructure>
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="LastContent" />
</ParagraphStructure>
</TableCellStructure>
</TableRowStructure>
</TableRowGroupStructure>
</TableStructure>
</SectionStructure>
如果分页符在“SomeContent”之后 </TableCellStructure> 强制结束片段,则应用程序必须创建拆分,如以下示例所示:
<StoryFragment StoryName="MyStory" FragmentType="Content">
<SectionStructure>
<TableStructure>
<TableRowGroupStructure>
<TableRowStructure>
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="SomeContent" />
</ParagraphStructure>
</TableCellStructure>
<!-- lines from here to end of fragment added by producer-->
</TableRowStructure>
</TableRowGroupStructure>
</TableStructure>
</SectionStructure>
</StoryFragment>
<StoryFragment StoryName="MyStory" FragmentType="Content">
<SectionStructure>
<TableStructure>
<TableRowGroupStructure>
<TableRowStructure>
<TableCellStructure>
<!-- extra cell added by producer-->
</TableCellStructure>
<!-- lines from here to start of fragment added by producer-->
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="MoreContent" />
</ParagraphStructure>
</TableCellStructure>
</TableRowStructure>
<TableRowStructure>
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="EvenMoreContent" />
</ParagraphStructure>
</TableCellStructure>
<TableCellStructure>
<ParagraphStructure>
<NamedElement NameReference="LastContent" />
</ParagraphStructure>
</TableCellStructure>
</TableRowStructure>
</TableRowGroupStructure>
</TableStructure>
</SectionStructure>
</StoryFragment>
读取文档的应用程序可能需要合并此内容。 例如,考虑将 “整个故事复制到剪贴板 ”按钮的 XPS 查看器;或将故事传递到语音合成器 的盲人应用程序的 XPS 。 阅读文档的某些应用程序可能需要合并文章片段的子集。 例如,一项通过三次单击将整个段落复制到剪贴板的功能需要在段落跨越分页符时执行合并,因为这样一个段落将在两 StoryFragment个 s 之间拆分。
若要合并,请使用以下算法:
从
</StoryFragment>要合并的第一个片段的末尾删除并从第二个片段的开头删除<StoryFragment>。如果第一个片段的最后一个结束标记的类型与第二个片段的第一个开始标记相同(而不是
<NamedElement>标记),请删除它们。重复步骤 2,直到这两个片段处于以下 任一 状态:
- 尾随片段的第一个开始标记的最后一个结束标记之间不再存在类型匹配。
- 前导片段的最后一个结束标记是尾随片段的第一个开始标记都是
<NamedElement>标记。
在上面的示例中,如果生成应用程序未添加空单元格,则片段合并将生成一个表,其中第一行只包含一个包含“SomeContent”和“MoreContent”引用的单元格,而不是包含两个单元格的原始第一行,每个单元格包含单个引用
当整个故事被合并时,应针对属于同一故事的每个后续片段重复算法。 属于故事的片段在元素中 <Story> 编制索引。 请参阅可在 XPS 获取的 XML 纸张规范(XPS)规范的第 9.1.15 节 :规范和许可证下载。 给定故事的最后一个片段将有一个元素作为其最后一个 StoryBreak 子元素。
构造函数
| 名称 | 说明 |
|---|---|
| StoryFragment() |
初始化 StoryFragment 类的新实例。 |
属性
| 名称 | 说明 |
|---|---|
| FragmentName |
获取或设置故事片段的名称。 |
| FragmentType |
获取或设置片段的类型。 |
| StoryName |
获取或设置故事的名称。 |
方法
| 名称 | 说明 |
|---|---|
| Add(BlockElement) |
向故事片段添加块。 |
| Equals(Object) |
确定指定的对象是否等于当前对象。 (继承自 Object) |
| GetHashCode() |
用作默认哈希函数。 (继承自 Object) |
| GetType() |
获取当前实例的 Type。 (继承自 Object) |
| MemberwiseClone() |
创建当前 Object的浅表副本。 (继承自 Object) |
| ToString() |
返回一个表示当前对象的字符串。 (继承自 Object) |
显式接口实现
| 名称 | 说明 |
|---|---|
| IAddChild.AddChild(Object) |
此成员支持 .NET Framework 基础结构,不应直接从代码使用。 |
| IAddChild.AddText(String) |
将节点的文本内容添加到对象。 |
| IEnumerable.GetEnumerator() |
此方法尚未实现。 |
| IEnumerable<BlockElement>.GetEnumerator() |
此方法尚未实现。 |