Aspose::Words::Section Class Referencefinal

Detailed Description

Represents a single section in a document.

Section can have one Body and maximum one HeaderFooter of each 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 Clone. 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.

#include <Aspose.Words.Cpp/Model/Sections/Section.h>

+ Inheritance diagram for Aspose::Words::Section:

Public Member Functions

 Section (SharedPtr< DocumentBase > doc)
 Initializes a new instance of the Section class. More...
 
virtual bool Accept (SharedPtr< DocumentVisitor > visitor)
 Accepts a visitor. More...
 
void AppendContent (SharedPtr< 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...
 
SharedPtr< SectionClone ()
 Creates a duplicate 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...
 
SharedPtr< Bodyget_Body ()
 Returns the Body child node of the section. More...
 
SharedPtr< HeaderFooterCollectionget_HeadersFooters ()
 Provides access to the headers and footers nodes of the section. More...
 
virtual NodeType get_NodeType () const
 Returns NodeType.Section. More...
 
SharedPtr< 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 PrependContent (SharedPtr< Section > sourceSection)
 Inserts a copy of content of the source section at the beginning of this section. More...
 
void set_ProtectedForForms (bool value)
 Setter for get_ProtectedForForms. More...
 
- Public Member Functions inherited from CompositeNode
SharedPtr< NodeAppendChild (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...
 
SharedPtr< CompositeNodeget_Container ()
 
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...
 
virtual bool get_IsComposite ()
 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< NodeGetCurrentNode ()
 
SharedPtr< IEnumerator< SharedPtr< Node > > > GetEnumerator ()
 Provides support for the for each style iteration over the child nodes of this node. More...
 
SharedPtr< NodeGetNextMatchingNode (SharedPtr< Node > curNode)
 
virtual String GetText ()
 Gets the text of this node and of all its children. More...
 
int32_t IndexOf (SharedPtr< Node > child)
 Returns the index of the specified child node in the child node array. More...
 
SharedPtr< NodeInsertAfter (SharedPtr< Node > newChild, SharedPtr< Node > refChild)
 Inserts the specified node immediately after the specified reference node. More...
 
SharedPtr< NodeInsertBefore (SharedPtr< Node > newChild, SharedPtr< Node > refChild)
 Inserts the specified node immediately before the specified reference node. More...
 
SharedPtr< NodePrependChild (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 (SharedPtr< Node > oldChild)
 Removes the specified child node. More...
 
void RemoveSmartTags ()
 Removes all SmartTag descendant nodes of the current node. More...
 
SharedPtr< NodeListSelectNodes (String xpath)
 Selects a list of nodes matching the XPath expression. More...
 
SharedPtr< NodeSelectSingleNode (String xpath)
 Selects the first Node that matches the XPath expression. More...
 
- Public Member Functions inherited from Node
SharedPtr< NodeClone (bool isCloneChildren)
 
virtual SharedPtr< DocumentBaseget_Document ()
 Gets the document to which this node belongs. More...
 
SharedPtr< Nodeget_NextSibling ()
 Gets the node immediately following 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 ()
 
SharedPtr< NodeNextPreOrder (SharedPtr< Node > rootNode)
 Gets next node according to the pre-order tree traversal algorithm. More...
 
SharedPtr< NodePreviousPreOrder (SharedPtr< Node > rootNode)
 Gets the previous node according to the pre-order tree traversal algorithm. More...
 
void Remove ()
 Removes itself from the parent. More...
 
String ToString (SaveFormat saveFormat)
 Exports the content of the node into a string in the specified format. More...
 
String ToString (SharedPtr< SaveOptions > saveOptions)
 Exports the content of the node into a string using the specified save options. More...
 
- Public Member Functions inherited from Object
ASPOSECPP_SHARED_API Object ()
 
ASPOSECPP_SHARED_API Object (Object const &x)
 
virtual ASPOSECPP_SHARED_API ~Object ()
 
virtual ASPOSECPP_SHARED_API bool Equals (ptr obj)
 
Detail::SmartPtrCounter * GetCounter ()
 
virtual ASPOSECPP_SHARED_API int GetHashCode () const
 
virtual ASPOSECPP_SHARED_API const TypeInfoGetType () const
 
virtual ASPOSECPP_SHARED_API bool Is (const TypeInfo &targetType) const
 
ASPOSECPP_SHARED_API void Lock ()
 
virtual ASPOSECPP_SHARED_API ptr MemberwiseClone () const
 
Objectoperator= (Object const &x)
 
bool ReferenceEquals (String const &str, std::nullptr_t)
 
bool ReferenceEquals (String const &str1, String const &str2)
 
int RemovedSharedRefs (int count)
 
virtual ASPOSECPP_SHARED_API void SetTemplateWeakPtr (unsigned int argument)
 
int SharedCount () const
 
ObjectSharedRefAdded ()
 
int SharedRefRemovedSafe ()
 
virtual ASPOSECPP_SHARED_API String ToString () const
 
ASPOSECPP_SHARED_API void Unlock ()
 
Detail::SmartPtrCounter * WeakRefAdded ()
 
void WeakRefRemoved ()
 
- Public Member Functions inherited from System::Collections::Generic::IEnumerable< System::SharedPtr< Aspose::Words::Node > >
EnumeratorBasedIterator< T, IEnumerator< T > > begin () noexcept
 
EnumeratorBasedIterator< T, IEnumerator< T > > cbegin () noexcept
 
EnumeratorBasedIterator< T, IEnumerator< T > > cend () noexcept
 
EnumeratorBasedIterator< T, IEnumerator< T > > end () noexcept
 
bool LINQ_All (std::function< bool(T)> predicate)
 
bool LINQ_Any ()
 
bool LINQ_Any (std::function< bool(T)> predicate)
 
SharedPtr< IEnumerable< ResultType > > LINQ_Cast ()
 
SharedPtr< IEnumerable< Result > > LINQ_Cast ()
 
bool LINQ_Contains (T value)
 
int LINQ_Count ()
 
LINQ_ElementAt (int index)
 
LINQ_First ()
 
LINQ_FirstOrDefault ()
 
LINQ_FirstOrDefault (std::function< bool(T)> predicate)
 
LINQ_Last ()
 
LINQ_LastOrDefault ()
 
SharedPtr< IEnumerable< ResultType > > LINQ_OfType ()
 
SharedPtr< IEnumerable< Result > > LINQ_OfType ()
 
SharedPtr< IEnumerable< Result > > LINQ_Select (const Func< Source, Result > &selector)
 
SharedPtr< IEnumerable< ResultType > > LINQ_Select (const Func< T, ResultType > &selector)
 
ArrayPtr< T > LINQ_ToArray ()
 
SharedPtr< List< T > > LINQ_ToList ()
 
SharedPtr< IEnumerable< T > > LINQ_Where (std::function< bool(T)> predicate)
 

Additional Inherited Members

- Public Types inherited from Object
typedef SmartPtr< Objectptr
 
typedef System::Details::SharedMembersType shared_members_type
 
- Public Types inherited from System::Collections::Generic::IEnumerable< System::SharedPtr< Aspose::Words::Node > >
typedef IEnumerator< T > IEnumeratorType
 
typedef T ValueType
 
- 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 Public Member Functions inherited from Object
bool Equals (double const &objA, double const &objB)
 
bool Equals (float const &objA, float const &objB)
 
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 
static const TypeInfoType ()
 

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 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 Body is cleared, only one empty paragraph is left that represents the section break.

The text of all headers and footers is cleared, but 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 HeaderFooter objects themselves are not removed.

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

◆ 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.

◆ 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.

◆ 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 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)