Class CKDocument
Represents a wrapper around a Word document, providing DOM access to tables, sections,
headers, footers, and other editable regions of the document.
Assembly: CoverageKiller2.dll
Syntax
public class CKDocument : IDOMObject, IDisposable
Constructors
CKDocument(Document, CKApplication)
Initializes a new instance of the CKDocument class from an existing Word.Document.
Declaration
public CKDocument(Document wordDoc, CKApplication app = null)
Parameters
Type |
Name |
Description |
Document |
wordDoc |
The COM document to wrap.
|
CKApplication |
app |
The owning CKApplication (optional).
|
Fields
Tracer
Declaration
Field Value
_comDocument
Declaration
protected Document _comDocument
Field Value
_fullPath
Declaration
protected readonly string _fullPath
Field Value
Properties
ActiveWindow
Declaration
[Obsolete]
public Window ActiveWindow { get; }
Property Value
Application
The CKApplication instance that owns and opened this document.
Declaration
public CKApplication Application { get; }
Property Value
Content
Declaration
public CKRange Content { get; }
Property Value
Document
Gets the CKDocument that owns this DOM object.
Declaration
public CKDocument Document { get; }
Property Value
FileName
Declaration
public string FileName { get; }
Property Value
Final
Gets or sets whether this document is marked as Final (read-only UI state).
Only valid when this document is the active document and Word has at least one document open.
Declaration
public bool Final { get; set; }
Property Value
FullPath
The full file path of the underlying document.
Declaration
public string FullPath { get; }
Property Value
IsDirty
Indicates whether this DOM object has unsaved changes.
Declaration
public bool IsDirty { get; protected set; }
Property Value
IsOrphan
Indicates whether this DOM object is orphaned (e.g., lost its backing COM reference).
Declaration
public bool IsOrphan { get; }
Property Value
KeepAlive
Declaration
public bool KeepAlive { get; }
Property Value
LogId
Gets a short unique identifier for this document instance, suitable for log tracing.
Declaration
public string LogId { get; }
Property Value
Paragraphs
Provides access to the document's paragraphs as a CKParagraphs collection.
Declaration
public CKParagraphs Paragraphs { get; }
Property Value
Parent
Gets the logical parent of this DOM object.
Declaration
public IDOMObject Parent { get; }
Property Value
ReadOnly
Declaration
public bool ReadOnly { get; }
Property Value
ReadOnlyRecommended
Declaration
public bool ReadOnlyRecommended { get; set; }
Property Value
Saved
Declaration
public bool Saved { get; set; }
Property Value
Sections
Provides access to the document's sections as a CKSections collection.
Declaration
public CKSections Sections { get; }
Property Value
Tables
Provides access to the document's tables as a CKTables collection.
Declaration
public CKTables Tables { get; }
Property Value
Visible
Declaration
public bool Visible { get; set; }
Property Value
Methods
Activate()
Declaration
Copies the footer from this document into the target document.
Declaration
public void CopyFooterTo(CKDocument targetDocument)
Parameters
Type |
Name |
Description |
CKDocument |
targetDocument |
The document to receive the footer content.
|
Copies both header and footer from this document to the target document.
Declaration
public void CopyHeaderAndFooterTo(CKDocument targetDocument)
Parameters
Type |
Name |
Description |
CKDocument |
targetDocument |
The document to receive the content.
|
Copies the header from this document into the target document.
Declaration
public void CopyHeaderTo(CKDocument targetDocument)
Parameters
Type |
Name |
Description |
CKDocument |
targetDocument |
The document to receive the header content.
|
DeleteSection(int)
Deletes the section at the specified 1-based index, including its section break.
Declaration
public void DeleteSection(int sectionIndex)
Parameters
Type |
Name |
Description |
int |
sectionIndex |
The 1-based index of the section to delete.
|
Exceptions
Dispose()
Declaration
Dispose(bool)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type |
Name |
Description |
bool |
disposing |
|
EnsureLayoutReady()
Declaration
public bool EnsureLayoutReady()
Returns
EnsureLayoutReady(Document)
Forces Word to complete document layout and rendering to ensure safe access to Ranges, Tables, and other elements.
Declaration
public static bool EnsureLayoutReady(Document comDocument)
Parameters
Type |
Name |
Description |
Document |
comDocument |
|
Returns
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
object |
obj |
|
Returns
Overrides
Gets the primary footer range of the first section.
Declaration
public Range GetFooterRange()
Returns
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Overrides
Gets the primary header range of the first section.
Declaration
public Range GetHeaderRange()
Returns
GiveMeCOMDocumentIWillOwnItAndPromiseToCleanUpAfterMyself()
Returns a duplicated COM reference to the underlying Word.Document.
Caller is responsible for releasing it via ReleaseComObject(object).
Declaration
public Document GiveMeCOMDocumentIWillOwnItAndPromiseToCleanUpAfterMyself()
Returns
Type |
Description |
Document |
A new RCW to the internal Word.Document.
|
Remarks
Matches(Document)
Declaration
public bool Matches(Document other)
Parameters
Returns
Matches(object)
Check if object has a refernce to the same Word.Document.
Declaration
public bool Matches(object other)
Parameters
Type |
Name |
Description |
object |
other |
|
Returns
Range()
Gets a wrapper around the entire document range.
Declaration
Returns
Range(Range)
Wraps an existing Word.Range as a CKRange.
Declaration
public CKRange Range(Range range)
Parameters
Type |
Name |
Description |
Range |
range |
The Word.Range to wrap.
|
Returns
Range(int, int)
Gets a wrapper around a specific sub-range of the document.
Declaration
public CKRange Range(int start, int end)
Parameters
Type |
Name |
Description |
int |
start |
Start position (inclusive).
|
int |
end |
End position (inclusive).
|
Returns
Implements
Extension Methods