Aspose::Words::Markup::StructuredDocumentTag class

StructuredDocumentTag class

Represents a structured document tag (SDT or content control) in a document. To learn more, visit the Structured Document Tags or Content Control documentation article.

class StructuredDocumentTag : public Aspose::Words::CompositeNode,
                              public Aspose::Words::Markup::IMarkupNode,
                              public Aspose::Words::Revisions::ITrackableNode,
                              public Aspose::Words::IRunAttrSource,
                              public Aspose::Words::Markup::IStructuredDocumentTag

Methods

MethodDescription
Accept(System::SharedPtr<Aspose::Words::DocumentVisitor>) overrideAccepts a visitor.
AcceptEnd(System::SharedPtr<Aspose::Words::DocumentVisitor>) override
AcceptStart(System::SharedPtr<Aspose::Words::DocumentVisitor>) override
AppendChild(T)
Clear()Clears contents of this structured document tag and displays a placeholder if it is defined.
Clone(bool)Creates a duplicate of the node.
get_Appearance() overrideGets/sets the appearance of a structured document tag.
get_BuildingBlockCategory()Specifies category of building block for this SDT node. Can not be null.
get_BuildingBlockGallery()Specifies type of building block for this SDT. Can not be null.
get_CalendarType()Specifies the type of calendar for this SDT. Default is Default
get_Checked()Gets/Sets current state of the Checkbox SDT. Default value for this property is false.
get_Color() overrideGets or sets the color of the structured document tag.
get_ContentsFont()Font formatting that will be applied to text entered into SDT.
get_Count()Gets the number of immediate children of this node.
get_CustomNodeId() constSpecifies custom node identifier.
get_DateDisplayFormat()String that represents the format in which dates are displayed. Can not be null.
get_DateDisplayLocale()Allows to set/get the language format for the date displayed in this SDT.
get_DateStorageFormat()Gets/sets format in which the date for a date SDT is stored when the SDT is bound to an XML node in the document’s data store. Default value is DateTime
virtual get_Document() constGets the document to which this node belongs.
get_EndCharacterFont()Font formatting that will be applied to the last character of text entered into SDT.
get_FirstChild() constGets the first child of the node.
get_FullDate()Specifies the full date and time last entered into this SDT.
get_HasChildNodes()Returns true if this node has any child nodes.
get_Id() overrideSpecifies a unique read-only persistent numerical Id for this SDT.
get_IsComposite() overrideReturns true as this node can have child nodes.
get_IsShowingPlaceholderText() overrideSpecifies whether the content of this SDT shall be interpreted to contain placeholder text (as opposed to regular text contents within the SDT). if set to true, this state shall be resumed (showing placeholder text) upon opening this document.
get_IsTemporary() constSpecifies whether this SDT shall be removed from the WordProcessingML document when its contents are modified.
get_LastChild() constGets the last child of the node.
get_Level() const overrideGets the level at which this SDT occurs in the document tree.
get_ListItems()Gets SdtListItemCollection associated with this SDT.
get_LockContentControl() overrideWhen set to true, this property will prohibit a user from deleting this SDT.
get_LockContents() overrideWhen set to true, this property will prohibit a user from editing the contents of this SDT.
get_Multiline()Specifies whether this SDT allows multiple lines of text.
get_NextNode() const
get_NextSibling()Gets the node immediately following this node.
get_NodeType() const overrideReturns StructuredDocumentTag.
get_ParentNode()Gets the immediate parent of this node.
get_Placeholder() overrideGets the BuildingBlock containing placeholder text which should be displayed when this SDT run contents are empty, the associated mapped XML element is empty as specified via the XmlMapping element or the IsShowingPlaceholderText element is true.
get_PlaceholderName() overrideGets or sets Name of the BuildingBlock containing placeholder text. BuildingBlock with this name Name has to be present in the GlossaryDocument otherwise InvalidOperationException will occur.
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_SdtType() overrideGets type of this Structured document tag.
get_Style()Gets or sets the Style of the structured document tag.
get_StyleName()Gets or sets the name of the style applied to the structured document tag.
get_Tag() const overrideSpecifies a tag associated with the current SDT node. Can not be null.
get_Title() const overrideSpecifies the friendly name associated with this SDT. Can not be null.
get_WordOpenXML() overrideGets a string that represents the XML contained within the node in the FlatOpc format.
get_WordOpenXMLMinimal()Gets a string that represents the XML contained within the node in the FlatOpc format. Unlike the WordOpenXML property, this method generates a stripped-down document that excludes any non-content-related parts.
get_XmlMapping() overrideGets an object that represents the mapping of this structured document tag to XML data in a custom XML part of the current document.
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) overrideReturns 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)
RemoveSelfOnly() overrideRemoves just this SDT node itself, but keeps the content of it inside the document tree.
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_Appearance(Aspose::Words::Markup::SdtAppearance) overrideSetter for Aspose::Words::Markup::StructuredDocumentTag::get_Appearance.
set_BuildingBlockCategory(const System::String&)Setter for Aspose::Words::Markup::StructuredDocumentTag::get_BuildingBlockCategory.
set_BuildingBlockGallery(const System::String&)Setter for Aspose::Words::Markup::StructuredDocumentTag::get_BuildingBlockGallery.
set_CalendarType(Aspose::Words::Markup::SdtCalendarType)Setter for Aspose::Words::Markup::StructuredDocumentTag::get_CalendarType.
set_Checked(bool)Setter for Aspose::Words::Markup::StructuredDocumentTag::get_Checked.
set_Color(System::Drawing::Color) overrideSetter for Aspose::Words::Markup::StructuredDocumentTag::get_Color.
set_CustomNodeId(int32_t)Setter for Aspose::Words::Node::get_CustomNodeId.
set_DateDisplayFormat(const System::String&)Setter for Aspose::Words::Markup::StructuredDocumentTag::get_DateDisplayFormat.
set_DateDisplayLocale(int32_t)Setter for Aspose::Words::Markup::StructuredDocumentTag::get_DateDisplayLocale.
set_DateStorageFormat(Aspose::Words::Markup::SdtDateStorageFormat)Setter for Aspose::Words::Markup::StructuredDocumentTag::get_DateStorageFormat.
set_FullDate(System::DateTime)Setter for Aspose::Words::Markup::StructuredDocumentTag::get_FullDate.
set_IsShowingPlaceholderText(bool) overrideSetter for Aspose::Words::Markup::StructuredDocumentTag::get_IsShowingPlaceholderText.
set_IsTemporary(bool)Setter for Aspose::Words::Markup::StructuredDocumentTag::get_IsTemporary.
set_LockContentControl(bool) overrideSetter for Aspose::Words::Markup::StructuredDocumentTag::get_LockContentControl.
set_LockContents(bool) overrideSetter for Aspose::Words::Markup::StructuredDocumentTag::get_LockContents.
set_Multiline(bool)Setter for Aspose::Words::Markup::StructuredDocumentTag::get_Multiline.
set_NextNode(const System::SharedPtr<Aspose::Words::Node>&)
set_PlaceholderName(System::String) overrideSetter for Aspose::Words::Markup::StructuredDocumentTag::get_PlaceholderName.
set_PrevNode(const System::SharedPtr<Aspose::Words::Node>&)
set_Style(const System::SharedPtr<Aspose::Words::Style>&)Setter for Aspose::Words::Markup::StructuredDocumentTag::get_Style.
set_StyleName(const System::String&)Setter for Aspose::Words::Markup::StructuredDocumentTag::get_StyleName.
set_Tag(System::String) overrideSetter for Aspose::Words::Markup::StructuredDocumentTag::get_Tag.
set_Title(System::String) overrideSetter for Aspose::Words::Markup::StructuredDocumentTag::get_Title.
SetCheckedSymbol(int32_t, const System::String&)Sets the symbol used to represent the checked state of a check box content control.
SetParent(const System::SharedPtr<Aspose::Words::Node>&)
SetTemplateWeakPtr(uint32_t) override
SetUncheckedSymbol(int32_t, const System::String&)Sets the symbol used to represent the unchecked state of a check box content control.
StructuredDocumentTag(const System::SharedPtr<Aspose::Words::DocumentBase>&, Aspose::Words::Markup::SdtType, Aspose::Words::Markup::MarkupLevel)Initializes a new instance of the Structured document tag class.
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

Structured document tags (SDTs) allow to embed customer-defined semantics as well as its behavior and appearance into a document.

In this version Aspose.Words provides a number of public methods and properties to manipulate the behavior and content of StructuredDocumentTag. Mapping of SDT nodes to custom XML packages within a document can be performed with using the XmlMapping property.

StructuredDocumentTag can occur in a document in the following places:

Examples

Shows how to work with styles for content control elements.

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

// Below are two ways to apply a style from the document to a structured document tag.
// 1 -  Apply a style object from the document's style collection:
SharedPtr<Style> quoteStyle = doc->get_Styles()->idx_get(StyleIdentifier::Quote);
auto sdtPlainText = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
sdtPlainText->set_Style(quoteStyle);

// 2 -  Reference a style in the document by name:
auto sdtRichText = MakeObject<StructuredDocumentTag>(doc, SdtType::RichText, MarkupLevel::Inline);
sdtRichText->set_StyleName(u"Quote");

builder->InsertNode(sdtPlainText);
builder->InsertNode(sdtRichText);

ASSERT_EQ(NodeType::StructuredDocumentTag, sdtPlainText->get_NodeType());

SharedPtr<NodeCollection> tags = doc->GetChildNodes(NodeType::StructuredDocumentTag, true);

for (const auto& node : System::IterateOver(tags))
{
    auto sdt = System::ExplicitCast<StructuredDocumentTag>(node);

    ASSERT_EQ(StyleIdentifier::Quote, sdt->get_Style()->get_StyleIdentifier());
    ASSERT_EQ(u"Quote", sdt->get_StyleName());
}

See Also