Table of Contents

Class HyperlinkEditingExtensions

Namespace
DocWright.Dom.Editing
Assembly
DocWright.Dom.dll

Hyperlinks added, inserted, changed and removed as DocumentEdits, as Word's Insert Link, Edit Link and Remove Link do (WQ-0094): each can be undone exactly and names the paragraphs it changed.

public static class HyperlinkEditingExtensions
Inheritance
HyperlinkEditingExtensions
Inherited Members

Remarks

A link is a HyperlinkStart and its HyperlinkEnd in one inline list, written as one w:hyperlink. Its runs take the Hyperlink character style (added to the document, with the theme's hyperlink colour, the first time it is needed) and keep their own direct formatting. Links never nest: a link a new one overlaps is cut back to its parts outside the new one.

A w:hyperlink cannot span paragraphs, so a span across paragraphs gets one link per paragraph, each to the same target; Word writes a HYPERLINK field instead, which this API does not.

Methods

AddHyperlink(WordDocument, DocumentSpan, HyperlinkTarget)

Makes the content a span covers a hyperlink.

ChangeHyperlink(WordDocument, HyperlinkStart, HyperlinkTarget, string?)

Gives a hyperlink a new target and tooltip and, optionally, new text.

FindHyperlink(DocumentPosition)

Finds the hyperlink a position is in: the innermost link whose content contains the position, its two ends included (so the caret just past a link's last character is in it).

GetSpan(HyperlinkStart)

Gets the span of a hyperlink's content, between its two markers.

InsertHyperlink(WordDocument, DocumentPosition, string, HyperlinkTarget)

Inserts link text at a position, as one run in the Hyperlink style, and makes it a hyperlink.

RemoveHyperlink(WordDocument, HyperlinkStart)

Removes a hyperlink, keeping its text: the markers go and the Hyperlink style comes off its runs.