Class TextMasterDocument
Represents an ODF master text document (ODM). 表示 ODF 主控文字文件(ODM)。
public sealed class TextMasterDocument : TextDocument, IDisposable, IAsyncDisposable
- Inheritance
-
TextMasterDocument
- Implements
- Inherited Members
Constructors
TextMasterDocument(OdfPackage)
Initializes a new instance of the TextMasterDocument class. 初始化 TextMasterDocument 類別的新執行個體。
public TextMasterDocument(OdfPackage package)
Parameters
packageOdfPackageThe ODF package. / ODF 封裝。
Methods
Create()
Creates a new ODM master text document. 建立新的 ODM 主控文字文件。
public static TextMasterDocument Create()
Returns
- TextMasterDocument
A new TextMasterDocument instance. / 新的 TextMasterDocument 執行個體。
GetSubDocumentReferences()
Gets all section references in the document pointing to external sub-documents. 取得文件中所有指向外部子文件的區段參照。
public IReadOnlyList<OdfSubDocumentReference> GetSubDocumentReferences()
Returns
- IReadOnlyList<OdfSubDocumentReference>
The list of sub-document references. / 子文件參照清單。
Load(Stream)
Loads an ODM master text document from the specified stream. 從指定資料流載入 ODM 主控文字文件。
public static TextMasterDocument Load(Stream stream)
Parameters
streamStream
Returns
- TextMasterDocument
The loaded TextMasterDocument instance. / 載入完成的 TextMasterDocument 執行個體。
Load(Stream, string?)
Short overload of Load that accepts stream and fileName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 fileName;其餘可選參數使用預設值並轉呼叫最長 Load 多載。
public static TextMasterDocument Load(Stream stream, string? fileName)
Parameters
Returns
Load(string)
Loads an ODM master text document from the specified path. 從指定路徑載入 ODM 主控文字文件。
public static TextMasterDocument Load(string path)
Parameters
pathstringThe ODM document path. / ODM 文件路徑。
Returns
- TextMasterDocument
The loaded TextMasterDocument instance. / 載入完成的 TextMasterDocument 執行個體。
LoadAsync(Stream)
Asynchronously loads an ODM master text document from the specified stream. 非同步從指定資料流載入 ODM 主控文字文件。
public static Task<TextMasterDocument> LoadAsync(Stream stream)
Parameters
streamStream
Returns
- Task<TextMasterDocument>
A task representing the asynchronous load operation, whose result is the loaded TextMasterDocument. / 代表非同步載入作業的工作,其結果為載入完成的 TextMasterDocument。
LoadAsync(Stream, string?)
Short overload of LoadAsync that accepts stream and fileName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 fileName;其餘可選參數使用預設值並轉呼叫最長 LoadAsync 多載。
public static Task<TextMasterDocument> LoadAsync(Stream stream, string? fileName)
Parameters
Returns
LoadAsync(Stream, string?, CancellationToken)
Short overload of LoadAsync that accepts stream, fileName, and cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream、fileName 與 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 LoadAsync 多載。
public static Task<TextMasterDocument> LoadAsync(Stream stream, string? fileName, CancellationToken cancellationToken)
Parameters
streamStreamfileNamestringcancellationTokenCancellationToken
Returns
LoadAsync(Stream, CancellationToken)
Asynchronously loads the document from a stream with a cancellation token. 以取消語彙基元非同步從資料流載入文件。
public static Task<TextMasterDocument> LoadAsync(Stream stream, CancellationToken cancellationToken)
Parameters
streamStreamThe document stream. / 文件資料流。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task<TextMasterDocument>
A task whose result is the loaded document. / 代表非同步載入作業的工作,其結果為載入完成的文件。
LoadAsync(string)
Asynchronously loads an ODM master text document from the specified path. 非同步從指定路徑載入 ODM 主控文字文件。
public static Task<TextMasterDocument> LoadAsync(string path)
Parameters
pathstring
Returns
- Task<TextMasterDocument>
A task representing the asynchronous load operation, whose result is the loaded TextMasterDocument. / 代表非同步載入作業的工作,其結果為載入完成的 TextMasterDocument。
LoadAsync(string, CancellationToken)
Short overload of LoadAsync that accepts path and cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 path 與 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 LoadAsync 多載。
public static Task<TextMasterDocument> LoadAsync(string path, CancellationToken cancellationToken)
Parameters
pathstringcancellationTokenCancellationToken
Returns
MergeSubDocuments(string)
Short overload of MergeSubDocuments that accepts baseDirectory; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 baseDirectory;其餘可選參數使用預設值並轉呼叫最長 MergeSubDocuments 多載。
public TextDocument MergeSubDocuments(string baseDirectory)
Parameters
baseDirectorystring
Returns
MergeSubDocuments(string, OdfMergeOptions?)
Short overload of MergeSubDocuments that accepts baseDirectory and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 baseDirectory 與 options;其餘可選參數使用預設值並轉呼叫最長 MergeSubDocuments 多載。
public TextDocument MergeSubDocuments(string baseDirectory, OdfMergeOptions? options)
Parameters
baseDirectorystringoptionsOdfMergeOptions
Returns
MergeSubDocuments(string, OdfMergeOptions?, int)
Merges the master document's own content with all external sub-documents, in document order, into a single text document. 將主控文件本身內容與所有外部子文件依文件順序合併為單一文字文件。
public TextDocument MergeSubDocuments(string baseDirectory, OdfMergeOptions? options, int subDocumentOutlineOffset)
Parameters
baseDirectorystringThe base directory used to resolve relative sub-document reference paths. / 解析子文件參照相對路徑時所使用的基準目錄。
optionsOdfMergeOptionsThe merge options; default options are used if null. / 合併設定選項;若為 null 則使用預設選項。
subDocumentOutlineOffsetintThe shift amount applied to each sub-document's heading outline level before merging (see ShiftHeadingOutlineLevels(int)); defaults to
0, meaning no adjustment. 套用至每份子文件標題大綱階層的位移量,套用後再併入(見 ShiftHeadingOutlineLevels(int));預設為0,不調整。
Returns
- TextDocument
The newly merged TextDocument instance. / 合併完成的新 TextDocument 執行個體。
Exceptions
- ArgumentException
Thrown when
baseDirectoryis blank. / 當baseDirectory為空白時擲出。
RemoveSubDocumentReference(string)
Removes the external sub-document section reference with the specified name. 移除指定名稱的外部子文件區段參照。
public bool RemoveSubDocumentReference(string sectionName)
Parameters
sectionNamestringThe section name. / 區段名稱。
Returns
- bool
true if removed successfully; false if no sub-document reference with the given name was found. / 若成功移除則為 true;找不到對應名稱的子文件參照時為 false。
Exceptions
- ArgumentException
Thrown when
sectionNameis blank. / 當sectionName為空白時擲出。
ReorderSubDocumentReferences(IReadOnlyList<string>)
Reorders external sub-document section references according to the specified name order. 依指定名稱順序重新排列外部子文件區段參照。
public void ReorderSubDocumentReferences(IReadOnlyList<string> orderedSectionNames)
Parameters
orderedSectionNamesIReadOnlyList<string>The desired section name order; names not found are ignored. / 期望的區段名稱排列順序。找不到的名稱會被忽略。
Exceptions
- ArgumentNullException
Thrown when
orderedSectionNamesis null. / 當orderedSectionNames為 null 時擲出。- InvalidOperationException
Thrown when the specified sub-document references are scattered across different parent nodes and cannot be reordered. / 當指定的子文件參照分散於不同父節點下,無法重新排序時擲出。
SetSubDocumentLoadOnRequest(string, bool)
Sets the load timing of the external sub-document section reference with the specified name. 設定指定名稱外部子文件區段參照的載入時機。
public bool SetSubDocumentLoadOnRequest(string sectionName, bool loadOnRequest)
Parameters
sectionNamestringThe section name. / 區段名稱。
loadOnRequestbooltrue means deferred loading (
xlink:actuate="onRequest"); false means loaded immediately when the master document is opened (xlink:actuate="onLoad"). true 表示延遲載入(xlink:actuate="onRequest"); false 表示開啟主控文件時立即載入(xlink:actuate="onLoad")。
Returns
- bool
true if set successfully; false if no sub-document reference with the given name was found. / 若成功設定則為 true;找不到對應名稱的子文件參照時為 false。
Exceptions
- ArgumentException
Thrown when
sectionNameis blank. / 當sectionName為空白時擲出。