Aspose::Words::Section Class Referencefinal

Represents a single section in a document. More...

#include "Aspose.Words.Cpp/Model/Sections/Section.h"

Inherits Aspose::Words::CompositeNode, and ISectionAttrSource.

Public Member Functions

virtual Aspose::Words::NodeType get_NodeType () const
 Returns NodeType.Section. More...
 
System::SharedPtr< Aspose::Words::Bodyget_Body ()
 Returns the Body child node of the section. More...
 
System::SharedPtr< Aspose::Words::HeaderFooterCollectionget_HeadersFooters ()
 Provides access to the headers and footers nodes of the section. More...
 
System::SharedPtr< Aspose::Words::PageSetupget_PageSetup ()
 Returns an object that represents page setup and section properties. More...
 
bool get_ProtectedForForms ()
 True if the section is protected for forms. When a section is protected for forms, users can select and modify text only in form fields in Microsoft Word. More...
 
void set_ProtectedForForms (bool value)
 Setter for Aspose::Words::Section::get_ProtectedForForms. More...
 
 Section (System::SharedPtr< Aspose::Words::DocumentBase > doc)
 Initializes a new instance of the Section class. More...
 
System::SharedPtr< Aspose::Words::SectionClone ()
 Creates a duplicate of this section. More...
 
virtual bool Accept (System::SharedPtr< Aspose::Words::DocumentVisitor > visitor)
 Accepts a visitor. More...
 
void PrependContent (System::SharedPtr< Aspose::Words::Section > sourceSection)
 Inserts a copy of content of the source section at the beginning of this section. More...
 
void AppendContent (System::SharedPtr< Aspose::Words::Section > sourceSection)
 Inserts a copy of content of the source section at the end of this section. More...
 
void ClearContent ()
 Clears the section. More...
 
void ClearHeadersFooters ()
 Clears the headers and footers of this section. More...
 
void DeleteHeaderFooterShapes ()
 Deletes all shapes (drawing objects) from the headers and footers of this section. More...
 
void EnsureMinimum ()
 Ensures that the section has Body with one Paragraph. More...
 
System::SharedPtr< System::ObjectGetDirectSectionAttr (int32_t key)
 
System::SharedPtr< System::ObjectFetchInheritedSectionAttr (int32_t key)
 
System::SharedPtr< System::ObjectFetchSectionAttr (int32_t key)
 
void SetSectionAttr (int32_t key, System::SharedPtr< System::Object > value)
 
void ClearSectionAttrs ()
 
- Public Member Functions inherited from Aspose::Words::CompositeNode
virtual bool get_IsComposite ()
 Returns true as this node can have child nodes. More...
 
bool get_HasChildNodes ()
 Returns true if this node has any child nodes. More...
 
System::SharedPtr< Aspose::Words::NodeCollectionget_ChildNodes ()
 Gets all immediate child nodes of this node. More...
 
System::SharedPtr< Aspose::Words::Nodeget_FirstChild () const
 Gets the first child of the node. More...
 
System::SharedPtr< Aspose::Words::Nodeget_LastChild () const
 Gets the last child of the node. More...
 
int32_t get_Count ()
 Gets the number of immediate children of this node. More...
 
System::SharedPtr< Aspose::Words::CompositeNodeget_Container ()
 
virtual ~CompositeNode ()
 
virtual System::String GetText ()
 Gets the text of this node and of all its children. More...
 
System::SharedPtr< Aspose::Words::NodeCollectionGetChildNodes (Aspose::Words::NodeType nodeType, bool isDeep)
 Returns a live collection of child nodes that match the specified type. More...
 
System::SharedPtr< Aspose::Words::NodeGetChild (Aspose::Words::NodeType nodeType, int32_t index, bool isDeep)
 Returns an Nth child node that matches the specified type. More...
 
System::SharedPtr< Aspose::Words::NodeListSelectNodes (System::String xpath)
 Selects a list of nodes matching the XPath expression. More...
 
System::SharedPtr< Aspose::Words::NodeSelectSingleNode (System::String xpath)
 Selects the first Node that matches the XPath expression. More...
 
System::SharedPtr< System::Collections::Generic::IEnumerator< System::SharedPtr< Aspose::Words::Node > > > GetEnumerator ()
 Provides support for the for each style iteration over the child nodes of this node. More...
 
System::SharedPtr< Aspose::Words::NodeAppendChild (System::SharedPtr< Aspose::Words::Node > newChild)
 Adds the specified node to the end of the list of child nodes for this node. More...
 
System::SharedPtr< Aspose::Words::NodePrependChild (System::SharedPtr< Aspose::Words::Node > newChild)
 Adds the specified node to the beginning of the list of child nodes for this node. More...
 
System::SharedPtr< Aspose::Words::NodeInsertAfter (System::SharedPtr< Aspose::Words::Node > newChild, System::SharedPtr< Aspose::Words::Node > refChild)
 Inserts the specified node immediately after the specified reference node. More...
 
System::SharedPtr< Aspose::Words::NodeInsertBefore (System::SharedPtr< Aspose::Words::Node > newChild, System::SharedPtr< Aspose::Words::Node > refChild)
 Inserts the specified node immediately before the specified reference node. More...
 
System::SharedPtr< Aspose::Words::NodeRemoveChild (System::SharedPtr< Aspose::Words::Node > oldChild)
 Removes the specified child node. More...
 
void RemoveAllChildren ()
 Removes all the child nodes of the current node. More...
 
void RemoveSmartTags ()
 Removes all Aspose::Words::Markup::SmartTag descendant nodes of the current node. More...
 
int32_t IndexOf (System::SharedPtr< Aspose::Words::Node > child)
 Returns the index of the specified child node in the child node array. More...
 
System::SharedPtr< Aspose::Words::NodeGetNextMatchingNode (System::SharedPtr< Aspose::Words::Node > &curNode)
 
- Public Member Functions inherited from Aspose::Words::Node
System::SharedPtr< Aspose::Words::CompositeNodeget_ParentNode ()
 Gets the immediate parent of this node. More...
 
System::SharedPtr< Aspose::Words::DocumentBaseget_Document ()
 Gets the document to which this node belongs. More...
 
System::SharedPtr< Aspose::Words::Nodeget_PreviousSibling ()
 Gets the node immediately preceding this node. More...
 
System::SharedPtr< Aspose::Words::Nodeget_NextSibling ()
 Gets the node immediately following this node. More...
 
System::SharedPtr< Aspose::Words::Rangeget_Range ()
 Returns a Range object that represents the portion of a document that is contained in this node. More...
 
System::SharedPtr< Aspose::Words::NodeClone (bool isCloneChildren)
 
template<typename T >
GetAncestorOf ()
 
System::SharedPtr< Aspose::Words::CompositeNodeGetAncestor (Aspose::Words::NodeType ancestorType)
 Gets the first ancestor of the specified Aspose::Words::NodeType. More...
 
void Remove ()
 Removes itself from the parent. More...
 
System::SharedPtr< Aspose::Words::NodeNextPreOrder (System::SharedPtr< Aspose::Words::Node > rootNode)
 Gets next node according to the pre-order tree traversal algorithm. More...
 
System::SharedPtr< Aspose::Words::NodePreviousPreOrder (System::SharedPtr< Aspose::Words::Node > rootNode)
 Gets the previous node according to the pre-order tree traversal algorithm. More...
 
System::String ToString (Aspose::Words::SaveFormat saveFormat)
 Exports the content of the node into a string in the specified format. More...
 
System::String ToString (System::SharedPtr< Aspose::Words::Saving::SaveOptions > saveOptions)
 Exports the content of the node into a string using the specified save options. More...
 
- Public Member Functions inherited from System::Object
 Object ()
 Creates object. Initializes all internal data structures. More...
 
virtual ~Object ()
 Destroys object. Frees all internal data structures. More...
 
 Object (Object const &x)
 Copy constructor. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More...
 
Objectoperator= (Object const &x)
 Assignment operator. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More...
 
ObjectSharedRefAdded ()
 Increments shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
int SharedRefRemovedSafe ()
 Decrements and returns shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
int RemovedSharedRefs (int count)
 Decreases shared reference count by specified value. More...
 
Detail::SmartPtrCounter * WeakRefAdded ()
 Increments weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
void WeakRefRemoved ()
 Decrements weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
Detail::SmartPtrCounter * GetCounter ()
 Gets reference counter data structure associated with the object. More...
 
int SharedCount () const
 Gets current value of shared refernce counter. More...
 
void Lock ()
 Implements C# lock() statement locking. Call directly or use LockContext sentry object. More...
 
void Unlock ()
 Implements C# lock() statement unlocking. Call directly or use LockContext sentry object. More...
 
virtual bool Equals (ptr obj)
 Compares objects using C# Object.Equals semantics. More...
 
virtual int GetHashCode () const
 Analog of C# Object.GetHashCode() method. Enables hashing of custom objects. More...
 
virtual String ToString () ASPOSE_CONST
 Analog of C# Object.ToString() method. Enables converting custom objects to string. More...
 
virtual ptr MemberwiseClone () const
 Analog of C# Object.MemberwiseClone() method. Enables cloning custom types. More...
 
virtual const TypeInfoGetType () const
 Gets actual type of object. Analog of C# System.Object.GetType() call. More...
 
virtual bool Is (const TypeInfo &targetType) const
 Check if object represents an instance of type described by targetType. Analog of C# 'is' operator. More...
 
virtual void SetTemplateWeakPtr (unsigned int argument)
 Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containers to weak mode. More...
 

Additional Inherited Members

- Public Types inherited from System::Object
typedef SmartPtr< Objectptr
 Alias for smart pointer type. More...
 
typedef System::Details::SharedMembersType shared_members_type
 structure to keep list of shared pointers contained in object. More...
 
- Public Types inherited from System::Collections::Generic::IEnumerable< System::SharedPtr< Aspose::Words::Node > >
typedef IEnumerator< System::SharedPtr< Aspose::Words::Node > > IEnumeratorType
 Enumerator type. More...
 
- Static Public Member Functions inherited from Aspose::Words::Node
static System::String NodeTypeToString (Aspose::Words::NodeType nodeType)
 A utility method that converts a node type enum value into a user friendly string. More...
 
- Static Public Member Functions inherited from System::Object
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 Compares objects by reference. More...
 
template<typename T >
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 Compares objects by reference. More...
 
template<typename T >
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 Reference-compares value type object with nullptr. More...
 
template<typename T1 , typename T2 >
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 Compares reference type objects in C# style. More...
 
template<typename T1 , typename T2 >
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 Compares value type objects in C# style. More...
 
static const TypeInfoType ()
 Impleemnts C# typeof(System.Object) construct. More...
 
template<>
bool Equals (float const &objA, float const &objB)
 
template<>
bool Equals (double const &objA, double const &objB)
 
template<>
bool ReferenceEquals (String const &str, std::nullptr_t)
 
template<>
bool ReferenceEquals (String const &str1, String const &str2)
 

Detailed Description

Represents a single section in a document.

Section can have one Aspose::Words::Section::get_Body and maximum one Aspose::Words::HeaderFooter of each Aspose::Words::HeaderFooterType. Body and HeaderFooter nodes can be in any order inside Section.

A minimal valid section needs to have Body with one Paragraph.

Each section has its own set of properties that specify page size, orientation, margins etc.

You can create a copy of a section using Aspose::Words::Node::Clone(bool). The copy can be inserted into the same or different document.

To add, insert or remove a whole section including section break and section properties use methods of the Sections object.

To copy and insert just content of the section excluding the section break and section properties use AppendContent and PrependContent methods.

Constructor & Destructor Documentation

◆ Section()

Aspose::Words::Section::Section ( System::SharedPtr< Aspose::Words::DocumentBase doc)

Initializes a new instance of the Section class.

When the section is created, it belongs to the specified document, but is not yet part of the document and ParentNode is null.

To include Section into a document use Document.InsertAfter, Document.InsertBefore or Sections.Add and Section.Insert methods.

Parameters
docThe owner document.

Member Function Documentation

◆ Accept()

virtual bool Aspose::Words::Section::Accept ( System::SharedPtr< Aspose::Words::DocumentVisitor visitor)
virtual

Accepts a visitor.

Enumerates over this node and all of its children. Each node calls a corresponding method on DocumentVisitor.

For more info see the Visitor design pattern.

Parameters
visitorThe visitor that will visit the nodes.
Returns
True if all nodes were visited; false if DocumentVisitor stopped the operation before visiting all nodes.

Calls DocumentVisitor.VisitSectionStart, then calls Accept for all child nodes of the section and calls DocumentVisitor.VisitSectionEnd at the end.

Implements Aspose::Words::Node.

◆ AppendContent()

void Aspose::Words::Section::AppendContent ( System::SharedPtr< Aspose::Words::Section sourceSection)

Inserts a copy of content of the source section at the end of this section.

Only content of Aspose::Words::Section::get_Body of the source section is copied, page setup, headers and footers are not copied.

The nodes are automatically imported if the source section belongs to a different document.

No new section is created in the destination document.

Parameters
sourceSectionThe section to copy content from.

◆ ClearContent()

void Aspose::Words::Section::ClearContent ( )

Clears the section.

The text of Aspose::Words::Section::get_Body is cleared, only one empty paragraph is left that represents the section break.

The text of all headers and footers is cleared, but Aspose::Words::HeaderFooter objects themselves are not removed.

◆ ClearHeadersFooters()

void Aspose::Words::Section::ClearHeadersFooters ( )

Clears the headers and footers of this section.

The text of all headers and footers is cleared, but Aspose::Words::HeaderFooter objects themselves are not removed.

This makes headers and footers of this section linked to headers and footers of the previous section.

◆ ClearSectionAttrs()

void Aspose::Words::Section::ClearSectionAttrs ( )

◆ Clone()

System::SharedPtr<Aspose::Words::Section> Aspose::Words::Section::Clone ( )

Creates a duplicate of this section.

◆ DeleteHeaderFooterShapes()

void Aspose::Words::Section::DeleteHeaderFooterShapes ( )

Deletes all shapes (drawing objects) from the headers and footers of this section.

◆ EnsureMinimum()

void Aspose::Words::Section::EnsureMinimum ( )

Ensures that the section has Body with one Paragraph.

◆ FetchInheritedSectionAttr()

System::SharedPtr<System::Object> Aspose::Words::Section::FetchInheritedSectionAttr ( int32_t  key)

◆ FetchSectionAttr()

System::SharedPtr<System::Object> Aspose::Words::Section::FetchSectionAttr ( int32_t  key)

◆ get_Body()

System::SharedPtr<Aspose::Words::Body> Aspose::Words::Section::get_Body ( )

Returns the Body child node of the section.

Body contains main text of the section.

Returns null if the section does not have a Body node among its children.

◆ get_HeadersFooters()

System::SharedPtr<Aspose::Words::HeaderFooterCollection> Aspose::Words::Section::get_HeadersFooters ( )

Provides access to the headers and footers nodes of the section.

◆ get_NodeType()

virtual Aspose::Words::NodeType Aspose::Words::Section::get_NodeType ( ) const
virtual

Returns NodeType.Section.

Implements Aspose::Words::Node.

◆ get_PageSetup()

System::SharedPtr<Aspose::Words::PageSetup> Aspose::Words::Section::get_PageSetup ( )

Returns an object that represents page setup and section properties.

◆ get_ProtectedForForms()

bool Aspose::Words::Section::get_ProtectedForForms ( )

True if the section is protected for forms. When a section is protected for forms, users can select and modify text only in form fields in Microsoft Word.

◆ GetDirectSectionAttr()

System::SharedPtr<System::Object> Aspose::Words::Section::GetDirectSectionAttr ( int32_t  key)

◆ PrependContent()

void Aspose::Words::Section::PrependContent ( System::SharedPtr< Aspose::Words::Section sourceSection)

Inserts a copy of content of the source section at the beginning of this section.

Only content of Aspose::Words::Section::get_Body of the source section is copied, page setup, headers and footers are not copied.

The nodes are automatically imported if the source section belongs to a different document.

No new section is created in the destination document.

Parameters
sourceSectionThe section to copy content from.

◆ set_ProtectedForForms()

void Aspose::Words::Section::set_ProtectedForForms ( bool  value)

◆ SetSectionAttr()

void Aspose::Words::Section::SetSectionAttr ( int32_t  key,
System::SharedPtr< System::Object value 
)