Show / Hide Table of Contents

Class CKDocument

Represents a wrapper around a Word document, providing DOM access to tables, sections, headers, footers, and other editable regions of the document.

Inheritance
object
CKDocument
Implements
IDOMObject
IDisposable
Inherited Members
object.ToString()
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetType()
object.MemberwiseClone()
Namespace: CoverageKiller2.DOM
Assembly: CoverageKiller2.dll
Syntax
public class CKDocument : IDOMObject, IDisposable
Remarks

Version: CK2.00.00. 0001

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
public Tracer Tracer
Field Value
Type Description
Tracer

_comDocument

Declaration
protected Document _comDocument
Field Value
Type Description
Document

_fullPath

Declaration
protected readonly string _fullPath
Field Value
Type Description
string

Properties

ActiveWindow

Declaration
[Obsolete]
public Window ActiveWindow { get; }
Property Value
Type Description
Window

Application

The CKApplication instance that owns and opened this document.

Declaration
public CKApplication Application { get; }
Property Value
Type Description
CKApplication

Content

Declaration
public CKRange Content { get; }
Property Value
Type Description
CKRange

Document

Gets the CKDocument that owns this DOM object.

Declaration
public CKDocument Document { get; }
Property Value
Type Description
CKDocument

FileName

Declaration
public string FileName { get; }
Property Value
Type Description
string

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
Type Description
bool
Remarks

Version: CK2.00.01.0003

FullPath

The full file path of the underlying document.

Declaration
public string FullPath { get; }
Property Value
Type Description
string

IsDirty

Indicates whether this DOM object has unsaved changes.

Declaration
public bool IsDirty { get; protected set; }
Property Value
Type Description
bool

IsOrphan

Indicates whether this DOM object is orphaned (e.g., lost its backing COM reference).

Declaration
public bool IsOrphan { get; }
Property Value
Type Description
bool

KeepAlive

Declaration
public bool KeepAlive { get; }
Property Value
Type Description
bool

LogId

Gets a short unique identifier for this document instance, suitable for log tracing.

Declaration
public string LogId { get; }
Property Value
Type Description
string

Paragraphs

Provides access to the document's paragraphs as a CKParagraphs collection.

Declaration
public CKParagraphs Paragraphs { get; }
Property Value
Type Description
CKParagraphs

Parent

Gets the logical parent of this DOM object.

Declaration
public IDOMObject Parent { get; }
Property Value
Type Description
IDOMObject

ReadOnly

Declaration
public bool ReadOnly { get; }
Property Value
Type Description
bool

ReadOnlyRecommended

Declaration
public bool ReadOnlyRecommended { get; set; }
Property Value
Type Description
bool

Saved

Declaration
public bool Saved { get; set; }
Property Value
Type Description
bool

Sections

Provides access to the document's sections as a CKSections collection.

Declaration
public CKSections Sections { get; }
Property Value
Type Description
CKSections

Tables

Provides access to the document's tables as a CKTables collection.

Declaration
public CKTables Tables { get; }
Property Value
Type Description
CKTables

Visible

Declaration
public bool Visible { get; set; }
Property Value
Type Description
bool

Methods

Activate()

Declaration
public void Activate()

CopyFooterTo(CKDocument)

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.

CopyHeaderAndFooterTo(CKDocument)

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.

CopyHeaderTo(CKDocument)

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
Type Condition
ArgumentOutOfRangeException

Thrown if index is outside valid range.

Dispose()

Declaration
public void Dispose()

Dispose(bool)

Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

EnsureLayoutReady()

Declaration
public bool EnsureLayoutReady()
Returns
Type Description
bool

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
Type Description
bool
Remarks

Version: CK2.00.01.0021

Equals(object)

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
object obj
Returns
Type Description
bool
Overrides
object.Equals(object)

GetFooterRange()

Gets the primary footer range of the first section.

Declaration
public Range GetFooterRange()
Returns
Type Description
Range

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
int
Overrides
object.GetHashCode()

GetHeaderRange()

Gets the primary header range of the first section.

Declaration
public Range GetHeaderRange()
Returns
Type Description
Range

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

Version: CK2.00.01.0020

Matches(Document)

Declaration
public bool Matches(Document other)
Parameters
Type Name Description
Document other
Returns
Type Description
bool

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
Type Description
bool

Range()

Gets a wrapper around the entire document range.

Declaration
public CKRange Range()
Returns
Type Description
CKRange

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
Type Description
CKRange

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
Type Description
CKRange

Implements

IDOMObject
IDisposable

Extension Methods

PingService.PingPong<T>(T, string)
PingService.PingPong<T>(T, string, string)
PingService.PingPong<T, TResult>(T, Func<TResult>, string, string)
PingService.Ping<T>(T, string)
PingService.Ping<T>(T, string, string)
PingService.Ping<T>(T, Type[], string)
PingService.Pong<T>(T, string)
PingService.Pong<T>(T, string, string)
PingService.Pong<T>(T, Type, string)
PingService.Pong<T>(T, Type[], string)
PingService.Pong<T, TResult>(T, Func<TResult>, string, string)
In this article
Back to top Generated by DocFX