StoryFragment StoryFragment StoryFragment StoryFragment Class

定义

表示 XPS 文档中的整篇文章或其中一部分。Represents all or part of a story within an XPS document.

public ref class StoryFragment : System::Collections::Generic::IEnumerable<System::Windows::Documents::DocumentStructures::BlockElement ^>, System::Windows::Markup::IAddChild
[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
    interface seq<BlockElement>
    interface IEnumerable
Public Class StoryFragment
Implements IAddChild, IEnumerable(Of BlockElement)
继承
StoryFragmentStoryFragmentStoryFragmentStoryFragment
属性
实现

示例

下面的示例演示<StoryFragment> XML 纸张规范 (XPS)XML Paper Specification (XPS)文档的部分。The following example shows the <StoryFragment> part of an XML 纸张规范 (XPS)XML Paper Specification (XPS) document.

<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>

注解

XPSXPS文档中的 XPS 故事大致类似于报纸或杂志中的一篇文章。An XPS story in an XPSXPS document is roughly analogous to a story in a newspaper or magazine. 这是一个XPSXPS文档中的文本和图形内容 (通常在单个主题上) 的一部分。It is a passage of text and graphic content, usually on a single topic, within a single XPSXPS document. 通常情况下, 它跨越多个页面, 但它可以比一页 (如边栏-盒式故事) 更短。Typically, it spans multiple pages, but it can be shorter than a page like a sidebar - boxed story - in a magazine. 故事还可以是不连续的, 如页面4上继续的首页新闻报道。A story can also be discontinuous like a front page newspaper story that is continued on page 4. 因此, 给定页可以有多个情景和多个情景的组成部分。Consequently, a given page can have more than one story and parts of more than one story. 页眉或页脚也是一种特殊的故事, 完全包含在单个页面上。A header or footer is also a special kind of story that is entirely contained on a single page.

StoryFragment表示部分或部分内容。A StoryFragment represents all or a portion of a story. 它永远不会跨越多页, 但它可以占用整个页面或与其他片段共享页面。It can never span more than one page, but it can occupy the whole of a page or share a page with other fragments. 如果某个故事在多页上, 则每个页面上的每个部分都是单独的片段。If a story is on more than one page, each part of it on each page is a separate fragment. 尽管故事可以具有不连续的片段集, 但片段本身也不连续。Although stories can have discontinuous sets of fragments, no fragment can itself be discontinuous.

只有元素可以是的父级StoryFragmentStoryFragmentsOnly a StoryFragments element can be a parent of a StoryFragment. 中元素StoryBreak的位置指示该情景是否包含在多个片段中,以及在当前片段StoryFragment之前还是之后。The location of the StoryBreak elements within a StoryFragment indicates if the story is contained in multiple fragments, and if the additional fragments either precede or follow the current fragment.

</TableRowGroupStructure> <TableRowGroupStructure> XPSXPS当在某个结构化元素的中间</StoryFragment>结束时, 如果为, 则生成文档的应用程序必须在标记前为元素 (在本例中为) 插入相应的结束标记, 甚至StoryFragment尽管该结构将在后面的片段中继续进行。When a StoryFragment ends in the middle of some structural element; say a <TableRowGroupStructure>, then XPSXPS document-producing applications must insert an appropriate end tag for the element (in this case </TableRowGroupStructure>) before the </StoryFragment> tag, even though the structure is being continued in a later fragment. (为确保中StoryFragment的元素树是有效的 XML, 这是必需的。)继续执行情景的片段必须以中断的结构的开始标记开头。(This is necessary to ensure that the element tree within the StoryFragment is valid XML.) The fragment that continues the story must begin with an opening tag for the interrupted structure. 必须以相同的方式处理中断结构的整个树 (有一个例外, 如下所述):必须为中断点之上的每个不匹配的开始标记添加结束标记。The entire tree of interrupted structures must be treated the same way (with one exception, discussed below): End tags must be added for every unmatched start tag above the point of interruption.

当情景中断紧接在标记之后时, 生成的</TableCellStructure>应用程序必须将空的表单元结构 (<TableCellStructure></TableCellStructure>) 插入片段中继续执行部分的相应点。The exception applies when the story interruption comes immediately after a </TableCellStructure> tag, then the producing application must insert an empty table cell structure (<TableCellStructure></TableCellStructure>) at the corresponding point in the fragment that continues the story. 这是必需的, 以便需要合并给定情景的所有片段的使用应用程序可以使用简单的算法来执行此操作。This is necessary so that consuming applications that need to merge all fragments of a given story can use a simple algorithm to do this.

例如, 假设应用程序要向XPSXPS文档中添加以下材料:Assume, for example, that an application wanted to add the following material to an XPSXPS document:

<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>的段内某个分页符强制结束, 则该应用程序必须创建 split, 如以下示例中所示:If a page break forces an end to the fragment just after the </TableCellStructure> for "SomeContent", the application must create the split as shown in the following example:

<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>  

读取文档的应用程序可能需要合并此内容。An application that reads the document might need to merge this content. 例如, 请考虑一个 XPS 查看器, 其中包含 "将整个情景复制到剪贴板" 按钮;或将故事传递到语音合成器的盲人应用程序的XPSConsider, for example, an XPS viewer with a Copy Whole Story to Clipboard button; or an XPS for the Blind application that passed stories to a voice synthesizer. 阅读文档的某些应用程序可能需要合并部分段落。Some applications that read the document may need to merge a subset of the fragments of a story. 例如, 通过三次单击将整个段落复制到剪贴板的一项功能是, 只要段落跨越分页符, 就需要进行合并, 因为这样的段落将在两个StoryFragment之间拆分。For example, a feature that copies a whole paragraph to the clipboard by triple-clicking it would need to do a merge whenever the paragraph spanned a page break, because such a paragraph would be split between two StoryFragments.

若要合并, 请使用此算法:To merge use this algorithm:

  1. 删除要合并的第一个片段末尾的, 并<StoryFragment>从第二个片段的开头删除。 </StoryFragment>Delete the </StoryFragment> from the end of the first fragment to be merged and delete the <StoryFragment> from the beginning of the second.

  2. 如果第一个片段的最后一个结束标记的类型与第二个片段的第一个开始标记 (并且它们不<NamedElement>是标记) 的类型相同, 则将其删除。If the last closing tag of the first fragment is of the same type as the first opening tag of the second fragment (and they are not <NamedElement> tags), delete them both.

  3. 重复步骤 2, 直到两个段处于以下任一状态:Repeat step 2 until the two fragments are in either of these states:

    • 在前导片段的最后一个结束标记之间不再有类型匹配尾随片段的第一个开始标记。There is no longer a type match between the last end tag of the leading fragment the first start tag of the trailing fragment.

    • 前导片段的最后一个结束标记, 尾随片段的第一个开始标记是<NamedElement>标记。The last end tag of the leading fragment the first start tag of the trailing fragment are both <NamedElement> tags.

在上面的示例中, 如果生成应用程序尚未添加空单元, 则片段的合并将生成一个表, 该表的第一行只有一个单元格, 其中包含 "SomeContent" 和 "MoreContent" 引用而不是原始的第一个具有两个单元格的行, 每个单元格包含一个引用In the example above, if the empty cell had not been added by the producing application, then a merger of the fragments would produce a table whose first row had only one cell containing both the "SomeContent" and "MoreContent" references instead of the original first row with two cells, each containing a single reference

合并整个情景时, 应对同一情景的每个后续片段重复该算法。When the entire story is being merged, the algorithm should be repeated for each subsequent fragment that is part of the same story. 属于某个情景的片段在<Story>元素中编制了索引。The fragments that belong to a story are indexed in the <Story> element. 请参阅可在 XPS XML 纸张规范 (XPS)XML Paper Specification (XPS)获取的规范的9.1.15 部分:规范和许可证下载See section 9.1.15 of the XML 纸张规范 (XPS)XML Paper Specification (XPS) specification which you can obtain at XPS: Specification and License Downloads. 给定情景的最后一个片段将StoryBreak元素作为其最后一个子级。The last fragment for a given story will have a StoryBreak element as its last child.

构造函数

StoryFragment() StoryFragment() StoryFragment() StoryFragment()

初始化 StoryFragment 类的新实例。Initializes a new instance of the StoryFragment class.

属性

FragmentName FragmentName FragmentName FragmentName

获取或设置文章段落的名称。Gets or sets the name of the story fragment.

FragmentType FragmentType FragmentType FragmentType

获取或设置段落的类型。Gets or sets the type of fragment.

StoryName StoryName StoryName StoryName

获取或设置文章的名称。Gets or sets the name of the story.

方法

Add(BlockElement) Add(BlockElement) Add(BlockElement) Add(BlockElement)

将块添加到文章段落中。Add a block to the story fragment.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

显式界面实现

IAddChild.AddChild(Object) IAddChild.AddChild(Object) IAddChild.AddChild(Object) IAddChild.AddChild(Object)

此成员支持 .NET Framework 结构,不能在代码中直接使用。This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.

IAddChild.AddText(String) IAddChild.AddText(String) IAddChild.AddText(String) IAddChild.AddText(String)

将节点的文本内容添加到对象。Adds the text content of a node to the object.

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

此方法尚未实现。This method has not been implemented.

IEnumerable<BlockElement>.GetEnumerator() IEnumerable<BlockElement>.GetEnumerator() IEnumerable<BlockElement>.GetEnumerator() IEnumerable<BlockElement>.GetEnumerator()

此方法尚未实现。This method has not been implemented.

扩展方法

CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>)

在给定其泛型参数 TDataTable 的输入 DataRow 对象的情况下,返回包含 IEnumerable<T> 对象副本的 DataRowReturns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 IEnumerable<T> 对象复制到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 IEnumerable<T> 对象复制到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>)

返回元素集合,其中包含源集合中每个节点的上级。Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName)

返回经过筛选的元素集合,其中包含源集合中每个节点的上级。Returns a filtered collection of elements that contains the ancestors of every node in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子代节点的集合。Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>)

返回元素集合,其中包含源集合中每个元素和文档的子代元素。Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName)

返回经过筛选的元素集合,其中包含源集合中每个元素和文档的子代元素。Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>)

返回源集合中每个元素和文档的子元素的集合。Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName)

返回源集合中经过筛选的每个元素和文档的子元素集合。Returns a filtered collection of the child elements of every element and document in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>)

返回节点集合(其中包含源集合中的所有节点),并按文档顺序排列。Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子节点集合。Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>)

将源集合中的每个节点从其父节点中移除。Removes every node in the source collection from its parent node.

适用于

另请参阅