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
- 屬性
- 實作
範例
以下範例展示了 XML 紙本規範(XPS)文件的部分 <StoryFragment> 。
<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 文件中。 通常它跨越多頁,但有時比雜誌裡的側欄(盒裝故事)短。 故事也可以是不連續的,例如頭版報紙的報導在第四頁繼續。 因此,同一頁可以包含多個故事以及多個故事的部分。 頁首或頁尾也是一種特殊的故事,完全包含在一頁內。
A StoryFragment 代表故事的全部或部分。 它永遠無法跨越超過一頁,但可以佔據整個頁面,或與其他片段共享一頁。 如果一個故事存在於多頁,則每頁的每個部分都是獨立的片段。 雖然故事可以有不連續的片段集合,但沒有任何片段本身是不連續的。
只有元素 StoryFragments 能成為 的父 StoryFragment元素。 元素在 a StoryBreak 中的位置StoryFragment決定故事是否包含於多個片段中,以及這些額外片段是先於或緊隨當前片段。
當 a StoryFragment 在某結構元素中間結束時;例如 a <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 ,將故事傳送到語音合成器。 有些讀取文件的應用程式可能需要合併故事片段的子集。 例如,一個功能能透過三重點擊將整段複製到剪貼簿,當段落跨越分頁時,必須合併,因為這樣的段落會被分成兩個 StoryFragments。
合併時請使用以下演算法:
刪除第一個要合併片段末尾的 ,
</StoryFragment>並刪除<StoryFragment>第二個片段開頭的 。如果第一個片段的最後一個關閉標籤與第二個片段的第一個開啟標籤類型相同(且它們不是
<NamedElement>標籤),則兩者都刪除。重複步驟2,直到兩個片段處於 以下任一 狀態:
- 領先片段的最後一個終點標籤與後方片段的第一個起始標籤之間不再有型別匹配。
- 前方片段的最後一個終點標籤與後方片段的第一個起始標籤皆為
<NamedElement>標籤。
在上述範例中,若產生應用程式未加入空格,合併片段後會產生一個表格,其第一列僅有一個儲存格同時包含「SomeContent」與「MoreContent」參考,而非原本第一列有兩個儲存格,每個儲存格包含一個參考
當整個故事合併時,應對同一故事中每個後續片段重複該演算法。 屬於故事的片段會被索引在元素中 <Story> 。 請參閱 XML 紙本規範(XPS)規範第 9.1.15 節,該規範可於 XPS:規範與授權下載處取得。 故事的最後一個片段會有一個 StoryBreak 元素作為其最後一個子節點。
建構函式
| 名稱 | Description |
|---|---|
| StoryFragment() |
初始化 StoryFragment 類別的新執行個體。 |
屬性
| 名稱 | Description |
|---|---|
| FragmentName |
取得或設定故事片段的名稱。 |
| FragmentType |
取得或設定片段的類型。 |
| StoryName |
要拿到或設定故事的名稱。 |
方法
| 名稱 | Description |
|---|---|
| Add(BlockElement) |
在故事片段中加入一個區塊。 |
| Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
| GetHashCode() |
做為預設哈希函式。 (繼承來源 Object) |
| GetType() |
取得目前實例的 Type。 (繼承來源 Object) |
| MemberwiseClone() |
建立目前 Object的淺層複本。 (繼承來源 Object) |
| ToString() |
傳回表示目前 物件的字串。 (繼承來源 Object) |
明確介面實作
| 名稱 | Description |
|---|---|
| IAddChild.AddChild(Object) |
此成員支援 .NET Framework 基礎架構,並非直接從您的程式碼中使用。 |
| IAddChild.AddText(String) |
將節點的文字內容加入物件。 |
| IEnumerable.GetEnumerator() |
此方法尚未實現。 |
| IEnumerable<BlockElement>.GetEnumerator() |
此方法尚未實現。 |