Aspose::Words::InlineStory Class Referenceabstract

Detailed Description

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

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 insert and customize footnotes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<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(u"Main body text.");
SharedPtr<Footnote> footnote = builder->InsertFootnote(FootnoteType::Footnote, u"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->get_IsAuto());
// We can move the document builder inside the footnote to edit its reference text.
builder->MoveTo(footnote->get_FirstParagraph());
builder->Write(u" More text added by a DocumentBuilder.");
builder->MoveToDocumentEnd();
ASSERT_EQ(u"\u0002 Footnote text. More text added by a DocumentBuilder.", footnote->GetText().Trim());
builder->Write(u" More main body text.");
footnote = builder->InsertFootnote(FootnoteType::Footnote, u"Footnote text.");
// We can set a custom reference mark which the footnote will use instead of its index number.
footnote->set_ReferenceMark(u"RefMark");
ASSERT_FALSE(footnote->get_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(u" More main body text.");
footnote = builder->InsertFootnote(FootnoteType::Footnote, u"Footnote text.");
ASSERT_TRUE(footnote->get_IsAuto());
doc->Save(ArtifactsDir + u"InlineStory.AddFootnote.docx");

Shows how to add a comment to a paragraph.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Write(u"Hello world!");
auto comment = MakeObject<Comment>(doc, u"John Doe", u"JD", System::DateTime::get_Today());
builder->get_CurrentParagraph()->AppendChild(comment);
builder->MoveTo(comment->AppendChild(MakeObject<Paragraph>(doc)));
builder->Write(u"Comment text.");
ASSERT_EQ(System::DateTime::get_Today(), comment->get_DateTime());
// In Microsoft Word, we can right-click this comment in the document body to edit it, or reply to it.
doc->Save(ArtifactsDir + u"InlineStory.AddComment.docx");

#include <Aspose.Words.Cpp/InlineStory.h>

+ Inheritance diagram for Aspose::Words::InlineStory:

Public Member Functions

void EnsureMinimum ()
 If the last child is not a paragraph, creates and appends one empty paragraph. More...
 
SharedPtr< Paragraphget_FirstParagraph ()
 Gets the first paragraph in the story. More...
 
SharedPtr< Fontget_Font ()
 Provides access to the font formatting of the anchor character of this object. More...
 
bool get_IsDeleteRevision ()
 Returns true if this object was deleted in Microsoft Word while change tracking was enabled. More...
 
bool get_IsInsertRevision ()
 Returns true if this object was inserted in Microsoft Word while change tracking was enabled. More...
 
bool get_IsMoveFromRevision ()
 Returns true if this object was moved (deleted) in Microsoft Word while change tracking was enabled. More...
 
bool get_IsMoveToRevision ()
 Returns true if this object was moved (inserted) in Microsoft Word while change tracking was enabled. More...
 
SharedPtr< Paragraphget_LastParagraph ()
 Gets the last paragraph in the story. More...
 
SharedPtr< ParagraphCollectionget_Paragraphs ()
 Gets a collection of paragraphs that are immediate children of the story. More...
 
SharedPtr< Paragraphget_ParentParagraph ()
 Retrieves the parent Paragraph of this node. More...
 
virtual StoryType get_StoryType ()=0
 Returns the type of the story. More...
 
SharedPtr< TableCollectionget_Tables ()
 Gets a collection of tables that are immediate children of the story. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
- Public Member Functions inherited from CompositeNode
SharedPtr< NodeAppendChild (const SharedPtr< Node > &newChild)
 Adds the specified node to the end of the list of child nodes for this node. More...
 
SharedPtr< NodeCollectionget_ChildNodes ()
 Gets all immediate child nodes of this node. More...
 
int32_t get_Count ()
 Gets the number of immediate children of this node. More...
 
SharedPtr< Nodeget_FirstChild () const
 Gets the first child of the node. More...
 
bool get_HasChildNodes ()
 Returns true if this node has any child nodes. More...
 
bool get_IsComposite () override
 Returns true as this node can have child nodes. More...
 
SharedPtr< Nodeget_LastChild () const
 Gets the last child of the node. More...
 
SharedPtr< NodeGetChild (NodeType nodeType, int32_t index, bool isDeep)
 Returns an Nth child node that matches the specified type. More...
 
SharedPtr< NodeCollectionGetChildNodes (NodeType nodeType, bool isDeep)
 Returns a live collection of child nodes that match the specified type. More...
 
SharedPtr< IEnumerator< SharedPtr< Node > > > GetEnumerator () override
 Provides support for the for each style iteration over the child nodes of this node. More...
 
String GetText () override
 Gets the text of this node and of all its children. More...
 
virtual const TypeInfoGetType () const override
 
int32_t IndexOf (const SharedPtr< Node > &child)
 Returns the index of the specified child node in the child node array. More...
 
SharedPtr< NodeInsertAfter (const SharedPtr< Node > &newChild, const SharedPtr< Node > &refChild)
 Inserts the specified node immediately after the specified reference node. More...
 
SharedPtr< NodeInsertBefore (const SharedPtr< Node > &newChild, const SharedPtr< Node > &refChild)
 Inserts the specified node immediately before the specified reference node. More...
 
virtual bool Is (const TypeInfo &target) const override
 
SharedPtr< NodePrependChild (const SharedPtr< Node > &newChild)
 Adds the specified node to the beginning of the list of child nodes for this node. More...
 
void RemoveAllChildren ()
 Removes all the child nodes of the current node. More...
 
SharedPtr< NodeRemoveChild (const SharedPtr< Node > &oldChild)
 Removes the specified child node. More...
 
void RemoveSmartTags ()
 Removes all SmartTag descendant nodes of the current node. More...
 
SharedPtr< NodeListSelectNodes (const String &xpath)
 Selects a list of nodes matching the XPath expression. More...
 
SharedPtr< NodeSelectSingleNode (const String &xpath)
 Selects the first Node that matches the XPath expression. More...
 
void SetTemplateWeakPtr (uint32_t argument) override
 
- Public Member Functions inherited from Node
virtual bool Accept (SharedPtr< DocumentVisitor > visitor)=0
 Accepts a visitor. More...
 
SharedPtr< NodeClone (bool isCloneChildren)
 Creates a duplicate of the node. More...
 
int32_t get_CustomNodeId () const
 Specifies custom node identifier. More...
 
virtual SharedPtr< DocumentBaseget_Document () const
 Gets the document to which this node belongs. More...
 
virtual bool get_IsComposite ()
 Returns true if this node can contain other nodes. More...
 
SharedPtr< Nodeget_NextSibling ()
 Gets the node immediately following this node. More...
 
virtual NodeType get_NodeType () const =0
 Gets the type of this node. More...
 
SharedPtr< CompositeNodeget_ParentNode ()
 Gets the immediate parent of this node. More...
 
SharedPtr< Nodeget_PreviousSibling ()
 Gets the node immediately preceding this node. More...
 
SharedPtr< Rangeget_Range ()
 Returns a Range object that represents the portion of a document that is contained in this node. More...
 
SharedPtr< CompositeNodeGetAncestor (NodeType ancestorType)
 Gets the first ancestor of the specified NodeType. More...
 
template<typename T >
GetAncestorOf ()
 
virtual String GetText ()
 Gets the text of this node and of all its children. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
SharedPtr< NodeNextPreOrder (const SharedPtr< Node > &rootNode)
 Gets next node according to the pre-order tree traversal algorithm. More...
 
SharedPtr< NodePreviousPreOrder (const SharedPtr< Node > &rootNode)
 Gets the previous node according to the pre-order tree traversal algorithm. More...
 
void Remove ()
 Removes itself from the parent. More...
 
void set_CustomNodeId (int32_t value)
 Setter for get_CustomNodeId. More...
 
String ToString (SaveFormat saveFormat)
 Exports the content of the node into a string in the specified format. More...
 
String ToString (const SharedPtr< SaveOptions > &saveOptions)
 Exports the content of the node into a string using the specified save options. More...
 

Static Public Member Functions

static const TypeInfoType ()
 
- Static Public Member Functions inherited from CompositeNode
static const TypeInfoType ()
 
- Static Public Member Functions inherited from Node
static String NodeTypeToString (NodeType nodeType)
 A utility method that converts a node type enum value into a user friendly string. More...
 
static const TypeInfoType ()
 

Member Function Documentation

◆ EnsureMinimum()

void Aspose::Words::InlineStory::EnsureMinimum ( )

If the last child is not a paragraph, creates and appends one empty paragraph.

Examples

Shows how to insert InlineStory nodes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Footnote> footnote = builder->InsertFootnote(FootnoteType::Footnote, nullptr);
// Table nodes have an "EnsureMinimum()" method that makes sure the table has at least one cell.
auto table = MakeObject<Table>(doc);
table->EnsureMinimum();
// We can place a table inside a footnote, which will make it appear at the referencing page's footer.
ASSERT_EQ(0, footnote->get_Tables()->get_Count());
footnote->AppendChild(table);
ASSERT_EQ(1, footnote->get_Tables()->get_Count());
ASSERT_EQ(NodeType::Table, footnote->get_LastChild()->get_NodeType());
// An InlineStory has an "EnsureMinimum()" method as well, but in this case,
// it makes sure the last child of the node is a paragraph,
// for us to be able to click and write text easily in Microsoft Word.
footnote->EnsureMinimum();
ASSERT_EQ(NodeType::Paragraph, footnote->get_LastChild()->get_NodeType());
// Edit the appearance of the anchor, which is the small superscript number
// in the main text that points to the footnote.
footnote->get_Font()->set_Name(u"Arial");
footnote->get_Font()->set_Color(System::Drawing::Color::get_Green());
// All inline story nodes have their respective story types.
ASSERT_EQ(StoryType::Footnotes, footnote->get_StoryType());
// A comment is another type of inline story.
auto comment = System::DynamicCast<Comment>(
builder->get_CurrentParagraph()->AppendChild(MakeObject<Comment>(doc, u"John Doe", u"J. D.", System::DateTime::get_Now())));
// The parent paragraph of an inline story node will be the one from the main document body.
ASPOSE_ASSERT_EQ(doc->get_FirstSection()->get_Body()->get_FirstParagraph(), comment->get_ParentParagraph());
// However, the last paragraph is the one from the comment text contents,
// which will be outside the main document body in a speech bubble.
// A comment will not have any child nodes by default,
// so we can apply the EnsureMinimum() method to place a paragraph here as well.
ASSERT_TRUE(comment->get_LastParagraph() == nullptr);
comment->EnsureMinimum();
ASSERT_EQ(NodeType::Paragraph, comment->get_LastChild()->get_NodeType());
// Once we have a paragraph, we can move the builder to do it and write our comment.
builder->MoveTo(comment->get_LastParagraph());
builder->Write(u"My comment.");
ASSERT_EQ(StoryType::Comments, comment->get_StoryType());
doc->Save(ArtifactsDir + u"InlineStory.InsertInlineStoryNodes.docx");

◆ get_FirstParagraph()

System::SharedPtr< Aspose::Words::Paragraph > Aspose::Words::InlineStory::get_FirstParagraph ( )

Gets the first paragraph in the story.

Examples

Shows how to insert and customize footnotes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<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(u"Main body text.");
SharedPtr<Footnote> footnote = builder->InsertFootnote(FootnoteType::Footnote, u"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->get_IsAuto());
// We can move the document builder inside the footnote to edit its reference text.
builder->MoveTo(footnote->get_FirstParagraph());
builder->Write(u" More text added by a DocumentBuilder.");
builder->MoveToDocumentEnd();
ASSERT_EQ(u"\u0002 Footnote text. More text added by a DocumentBuilder.", footnote->GetText().Trim());
builder->Write(u" More main body text.");
footnote = builder->InsertFootnote(FootnoteType::Footnote, u"Footnote text.");
// We can set a custom reference mark which the footnote will use instead of its index number.
footnote->set_ReferenceMark(u"RefMark");
ASSERT_FALSE(footnote->get_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(u" More main body text.");
footnote = builder->InsertFootnote(FootnoteType::Footnote, u"Footnote text.");
ASSERT_TRUE(footnote->get_IsAuto());
doc->Save(ArtifactsDir + u"InlineStory.AddFootnote.docx");

Shows how to add a comment to a paragraph.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Write(u"Hello world!");
auto comment = MakeObject<Comment>(doc, u"John Doe", u"JD", System::DateTime::get_Today());
builder->get_CurrentParagraph()->AppendChild(comment);
builder->MoveTo(comment->AppendChild(MakeObject<Paragraph>(doc)));
builder->Write(u"Comment text.");
ASSERT_EQ(System::DateTime::get_Today(), comment->get_DateTime());
// In Microsoft Word, we can right-click this comment in the document body to edit it, or reply to it.
doc->Save(ArtifactsDir + u"InlineStory.AddComment.docx");

◆ get_Font()

System::SharedPtr< Aspose::Words::Font > Aspose::Words::InlineStory::get_Font ( )

Provides access to the font formatting of the anchor character of this object.

Examples

Shows how to insert InlineStory nodes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Footnote> footnote = builder->InsertFootnote(FootnoteType::Footnote, nullptr);
// Table nodes have an "EnsureMinimum()" method that makes sure the table has at least one cell.
auto table = MakeObject<Table>(doc);
table->EnsureMinimum();
// We can place a table inside a footnote, which will make it appear at the referencing page's footer.
ASSERT_EQ(0, footnote->get_Tables()->get_Count());
footnote->AppendChild(table);
ASSERT_EQ(1, footnote->get_Tables()->get_Count());
ASSERT_EQ(NodeType::Table, footnote->get_LastChild()->get_NodeType());
// An InlineStory has an "EnsureMinimum()" method as well, but in this case,
// it makes sure the last child of the node is a paragraph,
// for us to be able to click and write text easily in Microsoft Word.
footnote->EnsureMinimum();
ASSERT_EQ(NodeType::Paragraph, footnote->get_LastChild()->get_NodeType());
// Edit the appearance of the anchor, which is the small superscript number
// in the main text that points to the footnote.
footnote->get_Font()->set_Name(u"Arial");
footnote->get_Font()->set_Color(System::Drawing::Color::get_Green());
// All inline story nodes have their respective story types.
ASSERT_EQ(StoryType::Footnotes, footnote->get_StoryType());
// A comment is another type of inline story.
auto comment = System::DynamicCast<Comment>(
builder->get_CurrentParagraph()->AppendChild(MakeObject<Comment>(doc, u"John Doe", u"J. D.", System::DateTime::get_Now())));
// The parent paragraph of an inline story node will be the one from the main document body.
ASPOSE_ASSERT_EQ(doc->get_FirstSection()->get_Body()->get_FirstParagraph(), comment->get_ParentParagraph());
// However, the last paragraph is the one from the comment text contents,
// which will be outside the main document body in a speech bubble.
// A comment will not have any child nodes by default,
// so we can apply the EnsureMinimum() method to place a paragraph here as well.
ASSERT_TRUE(comment->get_LastParagraph() == nullptr);
comment->EnsureMinimum();
ASSERT_EQ(NodeType::Paragraph, comment->get_LastChild()->get_NodeType());
// Once we have a paragraph, we can move the builder to do it and write our comment.
builder->MoveTo(comment->get_LastParagraph());
builder->Write(u"My comment.");
ASSERT_EQ(StoryType::Comments, comment->get_StoryType());
doc->Save(ArtifactsDir + u"InlineStory.InsertInlineStoryNodes.docx");

◆ get_IsDeleteRevision()

bool Aspose::Words::InlineStory::get_IsDeleteRevision ( )

Returns true if this object was deleted in Microsoft Word while change tracking was enabled.

Examples

Shows how to view revision-related properties of InlineStory nodes.

auto doc = MakeObject<Document>(MyDir + u"Revision footnotes.docx");
// When we edit the document while the "Track Changes" option, found in via Review -> Tracking,
// is turned on in Microsoft Word, the changes we apply count as revisions.
// When editing a document using Aspose.Words, we can begin tracking revisions by
// invoking the document's "StartTrackRevisions" method and stop tracking by using the "StopTrackRevisions" method.
// We can either accept revisions to assimilate them into the document
// or reject them to undo and discard the proposed change.
ASSERT_TRUE(doc->get_HasRevisions());
SharedPtr<System::Collections::Generic::List<SharedPtr<Footnote>>> footnotes =
doc->GetChildNodes(NodeType::Footnote, true)->LINQ_Cast<SharedPtr<Footnote>>()->LINQ_ToList();
ASSERT_EQ(5, footnotes->get_Count());
// Below are five types of revisions that can flag an InlineStory node.
// 1 - An "insert" revision:
// This revision occurs when we insert text while tracking changes.
ASSERT_TRUE(footnotes->idx_get(2)->get_IsInsertRevision());
// 2 - A "move from" revision:
// When we highlight text in Microsoft Word, and then drag it to a different place in the document
// while tracking changes, two revisions appear.
// The "move from" revision is a copy of the text originally before we moved it.
ASSERT_TRUE(footnotes->idx_get(4)->get_IsMoveFromRevision());
// 3 - A "move to" revision:
// The "move to" revision is the text that we moved in its new position in the document.
// "Move from" and "move to" revisions appear in pairs for every move revision we carry out.
// Accepting a move revision deletes the "move from" revision and its text,
// and keeps the text from the "move to" revision.
// Rejecting a move revision conversely keeps the "move from" revision and deletes the "move to" revision.
ASSERT_TRUE(footnotes->idx_get(1)->get_IsMoveToRevision());
// 4 - A "delete" revision:
// This revision occurs when we delete text while tracking changes. When we delete text like this,
// it will stay in the document as a revision until we either accept the revision,
// which will delete the text for good, or reject the revision, which will keep the text we deleted where it was.
ASSERT_TRUE(footnotes->idx_get(3)->get_IsDeleteRevision());

◆ get_IsInsertRevision()

bool Aspose::Words::InlineStory::get_IsInsertRevision ( )

Returns true if this object was inserted in Microsoft Word while change tracking was enabled.

Examples

Shows how to view revision-related properties of InlineStory nodes.

auto doc = MakeObject<Document>(MyDir + u"Revision footnotes.docx");
// When we edit the document while the "Track Changes" option, found in via Review -> Tracking,
// is turned on in Microsoft Word, the changes we apply count as revisions.
// When editing a document using Aspose.Words, we can begin tracking revisions by
// invoking the document's "StartTrackRevisions" method and stop tracking by using the "StopTrackRevisions" method.
// We can either accept revisions to assimilate them into the document
// or reject them to undo and discard the proposed change.
ASSERT_TRUE(doc->get_HasRevisions());
SharedPtr<System::Collections::Generic::List<SharedPtr<Footnote>>> footnotes =
doc->GetChildNodes(NodeType::Footnote, true)->LINQ_Cast<SharedPtr<Footnote>>()->LINQ_ToList();
ASSERT_EQ(5, footnotes->get_Count());
// Below are five types of revisions that can flag an InlineStory node.
// 1 - An "insert" revision:
// This revision occurs when we insert text while tracking changes.
ASSERT_TRUE(footnotes->idx_get(2)->get_IsInsertRevision());
// 2 - A "move from" revision:
// When we highlight text in Microsoft Word, and then drag it to a different place in the document
// while tracking changes, two revisions appear.
// The "move from" revision is a copy of the text originally before we moved it.
ASSERT_TRUE(footnotes->idx_get(4)->get_IsMoveFromRevision());
// 3 - A "move to" revision:
// The "move to" revision is the text that we moved in its new position in the document.
// "Move from" and "move to" revisions appear in pairs for every move revision we carry out.
// Accepting a move revision deletes the "move from" revision and its text,
// and keeps the text from the "move to" revision.
// Rejecting a move revision conversely keeps the "move from" revision and deletes the "move to" revision.
ASSERT_TRUE(footnotes->idx_get(1)->get_IsMoveToRevision());
// 4 - A "delete" revision:
// This revision occurs when we delete text while tracking changes. When we delete text like this,
// it will stay in the document as a revision until we either accept the revision,
// which will delete the text for good, or reject the revision, which will keep the text we deleted where it was.
ASSERT_TRUE(footnotes->idx_get(3)->get_IsDeleteRevision());

◆ get_IsMoveFromRevision()

bool Aspose::Words::InlineStory::get_IsMoveFromRevision ( )

Returns true if this object was moved (deleted) in Microsoft Word while change tracking was enabled.

Examples

Shows how to view revision-related properties of InlineStory nodes.

auto doc = MakeObject<Document>(MyDir + u"Revision footnotes.docx");
// When we edit the document while the "Track Changes" option, found in via Review -> Tracking,
// is turned on in Microsoft Word, the changes we apply count as revisions.
// When editing a document using Aspose.Words, we can begin tracking revisions by
// invoking the document's "StartTrackRevisions" method and stop tracking by using the "StopTrackRevisions" method.
// We can either accept revisions to assimilate them into the document
// or reject them to undo and discard the proposed change.
ASSERT_TRUE(doc->get_HasRevisions());
SharedPtr<System::Collections::Generic::List<SharedPtr<Footnote>>> footnotes =
doc->GetChildNodes(NodeType::Footnote, true)->LINQ_Cast<SharedPtr<Footnote>>()->LINQ_ToList();
ASSERT_EQ(5, footnotes->get_Count());
// Below are five types of revisions that can flag an InlineStory node.
// 1 - An "insert" revision:
// This revision occurs when we insert text while tracking changes.
ASSERT_TRUE(footnotes->idx_get(2)->get_IsInsertRevision());
// 2 - A "move from" revision:
// When we highlight text in Microsoft Word, and then drag it to a different place in the document
// while tracking changes, two revisions appear.
// The "move from" revision is a copy of the text originally before we moved it.
ASSERT_TRUE(footnotes->idx_get(4)->get_IsMoveFromRevision());
// 3 - A "move to" revision:
// The "move to" revision is the text that we moved in its new position in the document.
// "Move from" and "move to" revisions appear in pairs for every move revision we carry out.
// Accepting a move revision deletes the "move from" revision and its text,
// and keeps the text from the "move to" revision.
// Rejecting a move revision conversely keeps the "move from" revision and deletes the "move to" revision.
ASSERT_TRUE(footnotes->idx_get(1)->get_IsMoveToRevision());
// 4 - A "delete" revision:
// This revision occurs when we delete text while tracking changes. When we delete text like this,
// it will stay in the document as a revision until we either accept the revision,
// which will delete the text for good, or reject the revision, which will keep the text we deleted where it was.
ASSERT_TRUE(footnotes->idx_get(3)->get_IsDeleteRevision());

◆ get_IsMoveToRevision()

bool Aspose::Words::InlineStory::get_IsMoveToRevision ( )

Returns true if this object was moved (inserted) in Microsoft Word while change tracking was enabled.

Examples

Shows how to view revision-related properties of InlineStory nodes.

auto doc = MakeObject<Document>(MyDir + u"Revision footnotes.docx");
// When we edit the document while the "Track Changes" option, found in via Review -> Tracking,
// is turned on in Microsoft Word, the changes we apply count as revisions.
// When editing a document using Aspose.Words, we can begin tracking revisions by
// invoking the document's "StartTrackRevisions" method and stop tracking by using the "StopTrackRevisions" method.
// We can either accept revisions to assimilate them into the document
// or reject them to undo and discard the proposed change.
ASSERT_TRUE(doc->get_HasRevisions());
SharedPtr<System::Collections::Generic::List<SharedPtr<Footnote>>> footnotes =
doc->GetChildNodes(NodeType::Footnote, true)->LINQ_Cast<SharedPtr<Footnote>>()->LINQ_ToList();
ASSERT_EQ(5, footnotes->get_Count());
// Below are five types of revisions that can flag an InlineStory node.
// 1 - An "insert" revision:
// This revision occurs when we insert text while tracking changes.
ASSERT_TRUE(footnotes->idx_get(2)->get_IsInsertRevision());
// 2 - A "move from" revision:
// When we highlight text in Microsoft Word, and then drag it to a different place in the document
// while tracking changes, two revisions appear.
// The "move from" revision is a copy of the text originally before we moved it.
ASSERT_TRUE(footnotes->idx_get(4)->get_IsMoveFromRevision());
// 3 - A "move to" revision:
// The "move to" revision is the text that we moved in its new position in the document.
// "Move from" and "move to" revisions appear in pairs for every move revision we carry out.
// Accepting a move revision deletes the "move from" revision and its text,
// and keeps the text from the "move to" revision.
// Rejecting a move revision conversely keeps the "move from" revision and deletes the "move to" revision.
ASSERT_TRUE(footnotes->idx_get(1)->get_IsMoveToRevision());
// 4 - A "delete" revision:
// This revision occurs when we delete text while tracking changes. When we delete text like this,
// it will stay in the document as a revision until we either accept the revision,
// which will delete the text for good, or reject the revision, which will keep the text we deleted where it was.
ASSERT_TRUE(footnotes->idx_get(3)->get_IsDeleteRevision());

◆ get_LastParagraph()

System::SharedPtr< Aspose::Words::Paragraph > Aspose::Words::InlineStory::get_LastParagraph ( )

Gets the last paragraph in the story.

Examples

Shows how to insert InlineStory nodes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Footnote> footnote = builder->InsertFootnote(FootnoteType::Footnote, nullptr);
// Table nodes have an "EnsureMinimum()" method that makes sure the table has at least one cell.
auto table = MakeObject<Table>(doc);
table->EnsureMinimum();
// We can place a table inside a footnote, which will make it appear at the referencing page's footer.
ASSERT_EQ(0, footnote->get_Tables()->get_Count());
footnote->AppendChild(table);
ASSERT_EQ(1, footnote->get_Tables()->get_Count());
ASSERT_EQ(NodeType::Table, footnote->get_LastChild()->get_NodeType());
// An InlineStory has an "EnsureMinimum()" method as well, but in this case,
// it makes sure the last child of the node is a paragraph,
// for us to be able to click and write text easily in Microsoft Word.
footnote->EnsureMinimum();
ASSERT_EQ(NodeType::Paragraph, footnote->get_LastChild()->get_NodeType());
// Edit the appearance of the anchor, which is the small superscript number
// in the main text that points to the footnote.
footnote->get_Font()->set_Name(u"Arial");
footnote->get_Font()->set_Color(System::Drawing::Color::get_Green());
// All inline story nodes have their respective story types.
ASSERT_EQ(StoryType::Footnotes, footnote->get_StoryType());
// A comment is another type of inline story.
auto comment = System::DynamicCast<Comment>(
builder->get_CurrentParagraph()->AppendChild(MakeObject<Comment>(doc, u"John Doe", u"J. D.", System::DateTime::get_Now())));
// The parent paragraph of an inline story node will be the one from the main document body.
ASPOSE_ASSERT_EQ(doc->get_FirstSection()->get_Body()->get_FirstParagraph(), comment->get_ParentParagraph());
// However, the last paragraph is the one from the comment text contents,
// which will be outside the main document body in a speech bubble.
// A comment will not have any child nodes by default,
// so we can apply the EnsureMinimum() method to place a paragraph here as well.
ASSERT_TRUE(comment->get_LastParagraph() == nullptr);
comment->EnsureMinimum();
ASSERT_EQ(NodeType::Paragraph, comment->get_LastChild()->get_NodeType());
// Once we have a paragraph, we can move the builder to do it and write our comment.
builder->MoveTo(comment->get_LastParagraph());
builder->Write(u"My comment.");
ASSERT_EQ(StoryType::Comments, comment->get_StoryType());
doc->Save(ArtifactsDir + u"InlineStory.InsertInlineStoryNodes.docx");

◆ get_Paragraphs()

System::SharedPtr< Aspose::Words::ParagraphCollection > Aspose::Words::InlineStory::get_Paragraphs ( )

Gets a collection of paragraphs that are immediate children of the story.

Examples

Shows how to insert and customize footnotes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<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(u"Main body text.");
SharedPtr<Footnote> footnote = builder->InsertFootnote(FootnoteType::Footnote, u"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->get_IsAuto());
// We can move the document builder inside the footnote to edit its reference text.
builder->MoveTo(footnote->get_FirstParagraph());
builder->Write(u" More text added by a DocumentBuilder.");
builder->MoveToDocumentEnd();
ASSERT_EQ(u"\u0002 Footnote text. More text added by a DocumentBuilder.", footnote->GetText().Trim());
builder->Write(u" More main body text.");
footnote = builder->InsertFootnote(FootnoteType::Footnote, u"Footnote text.");
// We can set a custom reference mark which the footnote will use instead of its index number.
footnote->set_ReferenceMark(u"RefMark");
ASSERT_FALSE(footnote->get_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(u" More main body text.");
footnote = builder->InsertFootnote(FootnoteType::Footnote, u"Footnote text.");
ASSERT_TRUE(footnote->get_IsAuto());
doc->Save(ArtifactsDir + u"InlineStory.AddFootnote.docx");

Shows how to add a comment to a paragraph.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Write(u"Hello world!");
auto comment = MakeObject<Comment>(doc, u"John Doe", u"JD", System::DateTime::get_Today());
builder->get_CurrentParagraph()->AppendChild(comment);
builder->MoveTo(comment->AppendChild(MakeObject<Paragraph>(doc)));
builder->Write(u"Comment text.");
ASSERT_EQ(System::DateTime::get_Today(), comment->get_DateTime());
// In Microsoft Word, we can right-click this comment in the document body to edit it, or reply to it.
doc->Save(ArtifactsDir + u"InlineStory.AddComment.docx");

◆ get_ParentParagraph()

System::SharedPtr< Aspose::Words::Paragraph > Aspose::Words::InlineStory::get_ParentParagraph ( )

Retrieves the parent Paragraph of this node.

Examples

Shows how to insert InlineStory nodes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Footnote> footnote = builder->InsertFootnote(FootnoteType::Footnote, nullptr);
// Table nodes have an "EnsureMinimum()" method that makes sure the table has at least one cell.
auto table = MakeObject<Table>(doc);
table->EnsureMinimum();
// We can place a table inside a footnote, which will make it appear at the referencing page's footer.
ASSERT_EQ(0, footnote->get_Tables()->get_Count());
footnote->AppendChild(table);
ASSERT_EQ(1, footnote->get_Tables()->get_Count());
ASSERT_EQ(NodeType::Table, footnote->get_LastChild()->get_NodeType());
// An InlineStory has an "EnsureMinimum()" method as well, but in this case,
// it makes sure the last child of the node is a paragraph,
// for us to be able to click and write text easily in Microsoft Word.
footnote->EnsureMinimum();
ASSERT_EQ(NodeType::Paragraph, footnote->get_LastChild()->get_NodeType());
// Edit the appearance of the anchor, which is the small superscript number
// in the main text that points to the footnote.
footnote->get_Font()->set_Name(u"Arial");
footnote->get_Font()->set_Color(System::Drawing::Color::get_Green());
// All inline story nodes have their respective story types.
ASSERT_EQ(StoryType::Footnotes, footnote->get_StoryType());
// A comment is another type of inline story.
auto comment = System::DynamicCast<Comment>(
builder->get_CurrentParagraph()->AppendChild(MakeObject<Comment>(doc, u"John Doe", u"J. D.", System::DateTime::get_Now())));
// The parent paragraph of an inline story node will be the one from the main document body.
ASPOSE_ASSERT_EQ(doc->get_FirstSection()->get_Body()->get_FirstParagraph(), comment->get_ParentParagraph());
// However, the last paragraph is the one from the comment text contents,
// which will be outside the main document body in a speech bubble.
// A comment will not have any child nodes by default,
// so we can apply the EnsureMinimum() method to place a paragraph here as well.
ASSERT_TRUE(comment->get_LastParagraph() == nullptr);
comment->EnsureMinimum();
ASSERT_EQ(NodeType::Paragraph, comment->get_LastChild()->get_NodeType());
// Once we have a paragraph, we can move the builder to do it and write our comment.
builder->MoveTo(comment->get_LastParagraph());
builder->Write(u"My comment.");
ASSERT_EQ(StoryType::Comments, comment->get_StoryType());
doc->Save(ArtifactsDir + u"InlineStory.InsertInlineStoryNodes.docx");

◆ get_StoryType()

virtual Aspose::Words::StoryType Aspose::Words::InlineStory::get_StoryType ( )
pure virtual

Returns the type of the story.

Examples

Shows how to insert InlineStory nodes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Footnote> footnote = builder->InsertFootnote(FootnoteType::Footnote, nullptr);
// Table nodes have an "EnsureMinimum()" method that makes sure the table has at least one cell.
auto table = MakeObject<Table>(doc);
table->EnsureMinimum();
// We can place a table inside a footnote, which will make it appear at the referencing page's footer.
ASSERT_EQ(0, footnote->get_Tables()->get_Count());
footnote->AppendChild(table);
ASSERT_EQ(1, footnote->get_Tables()->get_Count());
ASSERT_EQ(NodeType::Table, footnote->get_LastChild()->get_NodeType());
// An InlineStory has an "EnsureMinimum()" method as well, but in this case,
// it makes sure the last child of the node is a paragraph,
// for us to be able to click and write text easily in Microsoft Word.
footnote->EnsureMinimum();
ASSERT_EQ(NodeType::Paragraph, footnote->get_LastChild()->get_NodeType());
// Edit the appearance of the anchor, which is the small superscript number
// in the main text that points to the footnote.
footnote->get_Font()->set_Name(u"Arial");
footnote->get_Font()->set_Color(System::Drawing::Color::get_Green());
// All inline story nodes have their respective story types.
ASSERT_EQ(StoryType::Footnotes, footnote->get_StoryType());
// A comment is another type of inline story.
auto comment = System::DynamicCast<Comment>(
builder->get_CurrentParagraph()->AppendChild(MakeObject<Comment>(doc, u"John Doe", u"J. D.", System::DateTime::get_Now())));
// The parent paragraph of an inline story node will be the one from the main document body.
ASPOSE_ASSERT_EQ(doc->get_FirstSection()->get_Body()->get_FirstParagraph(), comment->get_ParentParagraph());
// However, the last paragraph is the one from the comment text contents,
// which will be outside the main document body in a speech bubble.
// A comment will not have any child nodes by default,
// so we can apply the EnsureMinimum() method to place a paragraph here as well.
ASSERT_TRUE(comment->get_LastParagraph() == nullptr);
comment->EnsureMinimum();
ASSERT_EQ(NodeType::Paragraph, comment->get_LastChild()->get_NodeType());
// Once we have a paragraph, we can move the builder to do it and write our comment.
builder->MoveTo(comment->get_LastParagraph());
builder->Write(u"My comment.");
ASSERT_EQ(StoryType::Comments, comment->get_StoryType());
doc->Save(ArtifactsDir + u"InlineStory.InsertInlineStoryNodes.docx");

Implemented in Aspose::Words::Comment, and Aspose::Words::Notes::Footnote.

◆ get_Tables()

System::SharedPtr< Aspose::Words::Tables::TableCollection > Aspose::Words::InlineStory::get_Tables ( )

Gets a collection of tables that are immediate children of the story.

Examples

Shows how to insert InlineStory nodes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Footnote> footnote = builder->InsertFootnote(FootnoteType::Footnote, nullptr);
// Table nodes have an "EnsureMinimum()" method that makes sure the table has at least one cell.
auto table = MakeObject<Table>(doc);
table->EnsureMinimum();
// We can place a table inside a footnote, which will make it appear at the referencing page's footer.
ASSERT_EQ(0, footnote->get_Tables()->get_Count());
footnote->AppendChild(table);
ASSERT_EQ(1, footnote->get_Tables()->get_Count());
ASSERT_EQ(NodeType::Table, footnote->get_LastChild()->get_NodeType());
// An InlineStory has an "EnsureMinimum()" method as well, but in this case,
// it makes sure the last child of the node is a paragraph,
// for us to be able to click and write text easily in Microsoft Word.
footnote->EnsureMinimum();
ASSERT_EQ(NodeType::Paragraph, footnote->get_LastChild()->get_NodeType());
// Edit the appearance of the anchor, which is the small superscript number
// in the main text that points to the footnote.
footnote->get_Font()->set_Name(u"Arial");
footnote->get_Font()->set_Color(System::Drawing::Color::get_Green());
// All inline story nodes have their respective story types.
ASSERT_EQ(StoryType::Footnotes, footnote->get_StoryType());
// A comment is another type of inline story.
auto comment = System::DynamicCast<Comment>(
builder->get_CurrentParagraph()->AppendChild(MakeObject<Comment>(doc, u"John Doe", u"J. D.", System::DateTime::get_Now())));
// The parent paragraph of an inline story node will be the one from the main document body.
ASPOSE_ASSERT_EQ(doc->get_FirstSection()->get_Body()->get_FirstParagraph(), comment->get_ParentParagraph());
// However, the last paragraph is the one from the comment text contents,
// which will be outside the main document body in a speech bubble.
// A comment will not have any child nodes by default,
// so we can apply the EnsureMinimum() method to place a paragraph here as well.
ASSERT_TRUE(comment->get_LastParagraph() == nullptr);
comment->EnsureMinimum();
ASSERT_EQ(NodeType::Paragraph, comment->get_LastChild()->get_NodeType());
// Once we have a paragraph, we can move the builder to do it and write our comment.
builder->MoveTo(comment->get_LastParagraph());
builder->Write(u"My comment.");
ASSERT_EQ(StoryType::Comments, comment->get_StoryType());
doc->Save(ArtifactsDir + u"InlineStory.InsertInlineStoryNodes.docx");

◆ GetType()

virtual const System::TypeInfo & Aspose::Words::InlineStory::GetType ( ) const
overridevirtual

◆ Is()

virtual bool Aspose::Words::InlineStory::Is ( const System::TypeInfo target) const
overridevirtual

◆ Type()

static const System::TypeInfo & Aspose::Words::InlineStory::Type ( )
static