Aspose::Words::Story class

Story class

Base class for elements that contain block-level nodes Paragraph and Table. To learn more, visit the Logical Levels of Nodes in a Document documentation article.

class Story : public Aspose::Words::CompositeNode,
              public Aspose::Words::IStory

Methods

MethodDescription
virtual Accept(System::SharedPtr<Aspose::Words::DocumentVisitor>)Accepts a visitor.
virtual AcceptEnd(System::SharedPtr<Aspose::Words::DocumentVisitor>)
virtual AcceptStart(System::SharedPtr<Aspose::Words::DocumentVisitor>)
AppendChild(T)
AppendParagraph(const System::String&)A shortcut method that creates a Paragraph object with optional text and appends it to the end of this object.
Clone(bool)Creates a duplicate of the node.
DeleteShapes()Deletes all shapes from the text of this story.
get_Count()Gets the number of immediate children of this node.
get_CustomNodeId() constSpecifies custom node identifier.
virtual get_Document() constGets the document to which this node belongs.
get_FirstChild() constGets the first child of the node.
get_FirstParagraph() overrideGets the first paragraph in the story.
get_HasChildNodes()Returns true if this node has any child nodes.
get_IsComposite() overrideReturns true as this node can have child nodes.
get_LastChild() constGets the last child of the node.
get_LastParagraph() overrideGets the last paragraph in the story.
get_NextNode() const
get_NextSibling()Gets the node immediately following this node.
virtual get_NodeType() constGets the type of this node.
get_Paragraphs() overrideGets a collection of paragraphs that are immediate children of the story.
get_ParentNode()Gets the immediate parent of this node.
get_PreviousSibling()Gets the node immediately preceding this node.
get_PrevNode() const
get_Range()Returns a Range object that represents the portion of a document that is contained in this node.
get_StoryType() overrideGets the type of this story.
get_Tables() overrideGets a collection of tables that are immediate children of the story.
GetAncestor(Aspose::Words::NodeType)Gets the first ancestor of the specified NodeType.
GetAncestorOf()
GetChild(Aspose::Words::NodeType, int32_t, bool)Returns an Nth child node that matches the specified type.
GetChildNodes(Aspose::Words::NodeType, bool)Returns a live collection of child nodes that match the specified type.
GetEnumerator() overrideProvides support for the for each style iteration over the child nodes of this node.
GetText() overrideGets the text of this node and of all its children.
GetType() const override
IndexOf(const System::SharedPtr<Aspose::Words::Node>&)Returns the index of the specified child node in the child node array.
InsertAfter(T, const System::SharedPtr<Aspose::Words::Node>&)
InsertBefore(T, const System::SharedPtr<Aspose::Words::Node>&)
Is(const System::TypeInfo&) const override
IsAncestorNode(const System::SharedPtr<Aspose::Words::Node>&)
NextPreOrder(const System::SharedPtr<Aspose::Words::Node>&)Gets next node according to the pre-order tree traversal algorithm.
static NodeTypeToString(Aspose::Words::NodeType)A utility method that converts a node type enum value into a user friendly string.
PrependChild(T)
PreviousPreOrder(const System::SharedPtr<Aspose::Words::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)
RemoveSmartTags()Removes all SmartTag descendant nodes of the current node.
SelectNodes(const System::String&)Selects a list of nodes matching the XPath expression.
SelectSingleNode(const System::String&)Selects the first Node that matches the XPath expression.
set_CustomNodeId(int32_t)Setter for Aspose::Words::Node::get_CustomNodeId.
set_NextNode(const System::SharedPtr<Aspose::Words::Node>&)
set_PrevNode(const System::SharedPtr<Aspose::Words::Node>&)
SetParent(const System::SharedPtr<Aspose::Words::Node>&)
SetTemplateWeakPtr(uint32_t) override
ToString(Aspose::Words::SaveFormat)Exports the content of the node into a string in the specified format.
ToString(const System::SharedPtr<Aspose::Words::Saving::SaveOptions>&)Exports the content of the node into a string using the specified save options.
static Type()

Remarks

Text of a Word document is said to consist of several stories. The main text is stored in the main text story represented by Body, each header and footer is stored in a separate story represented by HeaderFooter.

Examples

Shows how to remove all shapes from a node.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);

// Use a DocumentBuilder to insert a shape. This is an inline shape,
// which has a parent Paragraph, which is a child node of the first section's Body.
builder->InsertShape(ShapeType::Cube, 100.0, 100.0);

ASSERT_EQ(1, doc->GetChildNodes(NodeType::Shape, true)->get_Count());

// We can delete all shapes from the child paragraphs of this Body.
ASSERT_EQ(StoryType::MainText, doc->get_FirstSection()->get_Body()->get_StoryType());
doc->get_FirstSection()->get_Body()->DeleteShapes();

ASSERT_EQ(0, doc->GetChildNodes(NodeType::Shape, true)->get_Count());

See Also