InlineStory

InlineStory class

Base class for inline-level nodes that can contain paragraphs and tables.

To learn more, visit the Logical Levels of Nodes in a Document documentation article.

public abstract class InlineStory : CompositeNode

Properties

NameDescription
Count { get; }Gets the number of immediate children of this node.
CustomNodeId { get; set; }Specifies custom node identifier.
virtual Document { get; }Gets the document to which this node belongs.
FirstChild { get; }Gets the first child of the node.
FirstParagraph { get; }Gets the first paragraph in the story.
Font { get; }Provides access to the font formatting of the anchor character of this object.
HasChildNodes { get; }Returns true if this node has any child nodes.
override IsComposite { get; }Returns true as this node can have child nodes.
IsDeleteRevision { get; }Returns true if this object was deleted in Microsoft Word while change tracking was enabled.
IsInsertRevision { get; }Returns true if this object was inserted in Microsoft Word while change tracking was enabled.
IsMoveFromRevision { get; }Returns true if this object was moved (deleted) in Microsoft Word while change tracking was enabled.
IsMoveToRevision { get; }Returns true if this object was moved (inserted) in Microsoft Word while change tracking was enabled.
LastChild { get; }Gets the last child of the node.
LastParagraph { get; }Gets the last paragraph in the story.
NextSibling { get; }Gets the node immediately following this node.
abstract NodeType { get; }Gets the type of this node.
Paragraphs { get; }Gets a collection of paragraphs that are immediate children of the story.
ParentNode { get; }Gets the immediate parent of this node.
ParentParagraph { get; }Retrieves the parent Paragraph of this node.
PreviousSibling { get; }Gets the node immediately preceding this node.
Range { get; }Returns a Range object that represents the portion of a document that is contained in this node.
abstract StoryType { get; }Returns the type of the story.
Tables { get; }Gets a collection of tables that are immediate children of the story.

Methods

NameDescription
abstract Accept(DocumentVisitor)Accepts a visitor.
abstract AcceptEnd(DocumentVisitor)When implemented in a derived class, calls the VisitXXXEnd method of the specified document visitor.
abstract AcceptStart(DocumentVisitor)When implemented in a derived class, calls the VisitXXXStart method of the specified document visitor.
AppendChild<T>(T)Adds the specified node to the end of the list of child nodes for this node.
Clone(bool)Creates a duplicate of the node.
CreateNavigator()Creates navigator which can be used to traverse and read nodes.
EnsureMinimum()If the last child is not a paragraph, creates and appends one empty paragraph.
GetAncestor(NodeType)Gets the first ancestor of the specified NodeType.
GetAncestor(Type)Gets the first ancestor of the specified object type.
GetChild(NodeType, int, bool)Returns an Nth child node that matches the specified type.
GetChildNodes(NodeType, bool)Returns a live collection of child nodes that match the specified type.
GetEnumerator()Provides support for the for each style iteration over the child nodes of this node.
override GetText()Gets the text of this node and of all its children.
IndexOf(Node)Returns the index of the specified child node in the child node array.
InsertAfter<T>(T, Node)Inserts the specified node immediately after the specified reference node.
InsertBefore<T>(T, Node)Inserts the specified node immediately before the specified reference node.
NextPreOrder(Node)Gets next node according to the pre-order tree traversal algorithm.
PrependChild<T>(T)Adds the specified node to the beginning of the list of child nodes for this node.
PreviousPreOrder(Node)Gets the previous node according to the pre-order tree traversal algorithm.
Remove()Removes itself from the parent.
RemoveAllChildren()Removes all the child nodes of the current node.
RemoveChild<T>(T)Removes the specified child node.
RemoveSmartTags()Removes all SmartTag descendant nodes of the current node.
SelectNodes(string)Selects a list of nodes matching the XPath expression.
SelectSingleNode(string)Selects the first Node that matches the XPath expression.
ToString(SaveFormat)Exports the content of the node into a string in the specified format.
ToString(SaveOptions)Exports the content of the node into a string using the specified save options.

Remarks

InlineStory is a container for block-level nodes Paragraph and Table.

The classes that derive from InlineStory are inline-level nodes that can contain their own text (paragraphs and tables). For example, a Comment node contains text of a comment and a Footnote contains text of a footnote.

Examples

Shows how to add a comment to a paragraph.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Write("Hello world!");

Comment comment = new Comment(doc, "John Doe", "JD", DateTime.Today);
builder.CurrentParagraph.AppendChild(comment);
builder.MoveTo(comment.AppendChild(new Paragraph(doc)));
builder.Write("Comment text.");

Assert.AreEqual(DateTime.Today, comment.DateTime);

// In Microsoft Word, we can right-click this comment in the document body to edit it, or reply to it. 
doc.Save(ArtifactsDir + "InlineStory.AddComment.docx");

Shows how to insert and customize footnotes.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Add text, and reference it with a footnote. This footnote will place a small superscript reference
// mark after the text that it references and create an entry below the main body text at the bottom of the page.
// This entry will contain the footnote's reference mark and the reference text,
// which we will pass to the document builder's "InsertFootnote" method.
builder.Write("Main body text.");
Footnote footnote = builder.InsertFootnote(FootnoteType.Footnote, "Footnote text.");

// If this property is set to "true", then our footnote's reference mark
// will be its index among all the section's footnotes.
// This is the first footnote, so the reference mark will be "1".
Assert.True(footnote.IsAuto);

// We can move the document builder inside the footnote to edit its reference text. 
builder.MoveTo(footnote.FirstParagraph);
builder.Write(" More text added by a DocumentBuilder.");
builder.MoveToDocumentEnd();

Assert.AreEqual("\u0002 Footnote text. More text added by a DocumentBuilder.", footnote.GetText().Trim());

builder.Write(" More main body text.");
footnote = builder.InsertFootnote(FootnoteType.Footnote, "Footnote text.");

// We can set a custom reference mark which the footnote will use instead of its index number.
footnote.ReferenceMark = "RefMark";

Assert.False(footnote.IsAuto);

// A bookmark with the "IsAuto" flag set to true will still show its real index
// even if previous bookmarks display custom reference marks, so this bookmark's reference mark will be a "3".
builder.Write(" More main body text.");
footnote = builder.InsertFootnote(FootnoteType.Footnote, "Footnote text.");

Assert.True(footnote.IsAuto);

doc.Save(ArtifactsDir + "InlineStory.AddFootnote.docx");

See Also