Aspose::Words::Body class
Contents
[
Hide
]Body class
Represents a container for the main text of a section. To learn more, visit the Aspose.Words Document Object Model (DOM) documentation article.
class Body : public Aspose::Words::Story
Methods
Method | Description |
---|---|
Accept(System::SharedPtr<Aspose::Words::DocumentVisitor>) override | Accepts a visitor. |
AcceptEnd(System::SharedPtr<Aspose::Words::DocumentVisitor>) override | Accepts a visitor for visiting the end of the document’s body. |
AcceptStart(System::SharedPtr<Aspose::Words::DocumentVisitor>) override | Accepts a visitor for visiting the start of the document’s body. |
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. |
Body(const System::SharedPtr<Aspose::Words::DocumentBase>&) | Initializes a new instance of the Body class. |
Clone(bool) | Creates a duplicate of the node. |
DeleteShapes() | Deletes all shapes from the text of this story. |
EnsureMinimum() | If the last child is not a paragraph, creates and appends one empty paragraph. |
get_Count() | Gets the number of immediate children of this node. |
get_CustomNodeId() const | Specifies custom node identifier. |
virtual get_Document() const | Gets the document to which this node belongs. |
get_FirstChild() const | Gets the first child of the node. |
get_FirstParagraph() override | Gets the first paragraph in the story. |
get_HasChildNodes() | Returns true if this node has any child nodes. |
get_IsComposite() override | Returns true as this node can have child nodes. |
get_LastChild() const | Gets the last child of the node. |
get_LastParagraph() override | Gets the last paragraph in the story. |
get_NextNode() const | |
get_NextSibling() | Gets the node immediately following this node. |
get_NodeType() const override | Returns Body. |
get_Paragraphs() override | Gets a collection of paragraphs that are immediate children of the story. |
get_ParentNode() | Gets the immediate parent of this node. |
get_ParentSection() | Gets the parent section of this story. |
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() override | Gets the type of this story. |
get_Tables() override | Gets 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() override | Provides support for the for each style iteration over the child nodes of this node. |
GetText() override | Gets 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
Body can contain Paragraph and Table child nodes.
Body is a section-level node and can only be a child of Section. There can only be one Body in a Section.
A minimal valid Body needs to contain at least one Paragraph.
Examples
Shows how to construct an Aspose.Words document by hand.
auto doc = MakeObject<Document>();
// A blank document contains one section, one body and one paragraph.
// Call the "RemoveAllChildren" method to remove all those nodes,
// and end up with a document node with no children.
doc->RemoveAllChildren();
// This document now has no composite child nodes that we can add content to.
// If we wish to edit it, we will need to repopulate its node collection.
// First, create a new section, and then append it as a child to the root document node.
auto section = MakeObject<Section>(doc);
doc->AppendChild(section);
// Set some page setup properties for the section.
section->get_PageSetup()->set_SectionStart(SectionStart::NewPage);
section->get_PageSetup()->set_PaperSize(PaperSize::Letter);
// A section needs a body, which will contain and display all its contents
// on the page between the section's header and footer.
auto body = MakeObject<Body>(doc);
section->AppendChild(body);
// Create a paragraph, set some formatting properties, and then append it as a child to the body.
auto para = MakeObject<Paragraph>(doc);
para->get_ParagraphFormat()->set_StyleName(u"Heading 1");
para->get_ParagraphFormat()->set_Alignment(ParagraphAlignment::Center);
body->AppendChild(para);
// Finally, add some content to do the document. Create a run,
// set its appearance and contents, and then append it as a child to the paragraph.
auto run = MakeObject<Run>(doc);
run->set_Text(u"Hello World!");
run->get_Font()->set_Color(System::Drawing::Color::get_Red());
para->AppendChild(run);
ASSERT_EQ(u"Hello World!", doc->GetText().Trim());
doc->Save(ArtifactsDir + u"Section.CreateManually.docx");
See Also
- Class Story
- Namespace Aspose::Words
- Library Aspose.Words for C++