Aspose::Words::Markup::StructuredDocumentTag Class Reference

Detailed Description

Represents a structured document tag (SDT or content control) in a document.

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::DynamicCast<StructuredDocumentTag>(node);
ASSERT_EQ(StyleIdentifier::Quote, sdt->get_Style()->get_StyleIdentifier());
ASSERT_EQ(u"Quote", sdt->get_StyleName());
}

#include <Aspose.Words.Cpp/Markup/StructuredDocumentTag.h>

+ Inheritance diagram for Aspose::Words::Markup::StructuredDocumentTag:

Public Member Functions

 StructuredDocumentTag (const SharedPtr< DocumentBase > &doc, SdtType type, MarkupLevel level)
 Initializes a new instance of the Structured document tag class. More...
 
bool Accept (SharedPtr< DocumentVisitor > visitor) override
 Accepts a visitor. More...
 
void Clear ()
 Clears contents of this structured document tag and displays a placeholder if it is defined. More...
 
String get_BuildingBlockCategory ()
 Specifies category of building block for this SDT node. Can not be null. More...
 
String get_BuildingBlockGallery ()
 Specifies type of building block for this SDT. Can not be null. More...
 
SdtCalendarType get_CalendarType ()
 Specifies the type of calendar for this SDT. Default is Default More...
 
bool get_Checked ()
 Gets/Sets current state of the Checkbox SDT. Default value for this property is false. More...
 
Color get_Color ()
 Gets or sets the color of the structured document tag. More...
 
SharedPtr< Fontget_ContentsFont ()
 Font formatting that will be applied to text entered into SDT. More...
 
String get_DateDisplayFormat ()
 String that represents the format in which dates are displayed. Can not be null. More...
 
int32_t get_DateDisplayLocale ()
 Allows to set/get the language format for the date displayed in this SDT. More...
 
SdtDateStorageFormat 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 More...
 
SharedPtr< Fontget_EndCharacterFont ()
 Font formatting that will be applied to the last character of text entered into SDT. More...
 
DateTime get_FullDate ()
 Specifies the full date and time last entered into this SDT. More...
 
int32_t get_Id ()
 Specifies a unique read-only persistent numerical Id for this SDT. More...
 
bool get_IsShowingPlaceholderText () const
 Specifies 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. More...
 
bool get_IsTemporary () const
 Specifies whether this SDT shall be removed from the WordProcessingML document when its contents are modified. More...
 
MarkupLevel get_Level () const
 Gets the level at which this SDT occurs in the document tree. More...
 
MarkupLevel get_Level_IMarkupNode () override
 
SharedPtr< SdtListItemCollectionget_ListItems ()
 Gets SdtListItemCollection associated with this SDT. More...
 
bool get_LockContentControl () const
 When set to true, this property will prohibit a user from deleting this SDT. More...
 
bool get_LockContents () const
 When set to true, this property will prohibit a user from editing the contents of this SDT. More...
 
bool get_Multiline ()
 Specifies whether this SDT allows multiple lines of text. More...
 
NodeType get_NodeType () const override
 Returns NodeType.StructuredDocumentTag. More...
 
SharedPtr< BuildingBlockget_Placeholder () const
 Gets 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. More...
 
String get_PlaceholderName () const
 Gets 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. More...
 
SdtType get_SdtType ()
 Gets type of this Structured document tag. More...
 
SharedPtr< Styleget_Style ()
 Gets or sets the Style of the structured document tag. More...
 
String get_StyleName ()
 Gets or sets the name of the style applied to the structured document tag. More...
 
String get_Tag () const
 Specifies a tag associated with the current SDT node. Can not be null. More...
 
String get_Title () const
 Specifies the friendly name associated with this SDT. Can not be null. More...
 
SharedPtr< XmlMappingget_XmlMapping () const
 Gets an object that represents the mapping of this structured document tag to XML data in a custom XML part of the current document. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void RemoveMoveRevisions () override
 
void RemoveSelfOnly ()
 Removes just this SDT node itself, but keeps the content of it inside the document tree. More...
 
void set_BuildingBlockCategory (const String &value)
 Setter for get_BuildingBlockCategory. More...
 
void set_BuildingBlockGallery (const String &value)
 Setter for get_BuildingBlockGallery. More...
 
void set_CalendarType (SdtCalendarType value)
 Setter for get_CalendarType. More...
 
void set_Checked (bool value)
 Setter for get_Checked. More...
 
void set_Color (Color value)
 Setter for get_Color. More...
 
void set_DateDisplayFormat (const String &value)
 Setter for get_DateDisplayFormat. More...
 
void set_DateDisplayLocale (int32_t value)
 Setter for get_DateDisplayLocale. More...
 
void set_DateStorageFormat (SdtDateStorageFormat value)
 Setter for get_DateStorageFormat. More...
 
void set_FullDate (DateTime value)
 Setter for get_FullDate. More...
 
void set_IsShowingPlaceholderText (bool value)
 Setter for get_IsShowingPlaceholderText. More...
 
void set_IsTemporary (bool value)
 Setter for get_IsTemporary. More...
 
void set_LockContentControl (bool value)
 Setter for get_LockContentControl. More...
 
void set_LockContents (bool value)
 Setter for get_LockContents. More...
 
void set_Multiline (bool value)
 Setter for get_Multiline. More...
 
void set_PlaceholderName (const String &value)
 Setter for get_PlaceholderName. More...
 
void set_Style (const SharedPtr< Style > &value)
 Setter for get_Style. More...
 
void set_StyleName (const String &value)
 Setter for get_StyleName. More...
 
void set_Tag (const String &value)
 Setter for get_Tag. More...
 
void set_Title (const String &value)
 Setter for get_Title. More...
 
void SetCheckedSymbol (int32_t characterCode, const String &fontName)
 Sets the symbol used to represent the checked state of a check box content control. More...
 
void SetUncheckedSymbol (int32_t characterCode, const String &fontName)
 Sets the symbol used to represent the unchecked state of a check box content control. More...
 
- Public Member Functions inherited from CompositeNode
SharedPtr< NodeAppendChild (const 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 () override
 
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...
 
bool get_IsComposite () override
 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 () override
 
SharedPtr< IEnumerator< SharedPtr< Node > > > GetEnumerator () override
 Provides support for the for each style iteration over the child nodes of this node. More...
 
SharedPtr< NodeGetNextMatchingNode (SharedPtr< Node > curNode) override
 
String GetText () override
 Gets the text of this node and of all its children. More...
 
int32_t IndexOf (const SharedPtr< Node > &child)
 Returns the index of the specified child node in the child node array. More...
 
SharedPtr< NodeInsertAfter (const SharedPtr< Node > &newChild, const SharedPtr< Node > &refChild)
 Inserts the specified node immediately after the specified reference node. More...
 
SharedPtr< NodeInsertBefore (const SharedPtr< Node > &newChild, const SharedPtr< Node > &refChild)
 Inserts the specified node immediately before the specified reference node. More...
 
SharedPtr< NodePrependChild (const 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 (const SharedPtr< Node > &oldChild)
 Removes the specified child node. More...
 
void RemoveSmartTags ()
 Removes all SmartTag descendant nodes of the current node. More...
 
SharedPtr< NodeListSelectNodes (const String &xpath)
 Selects a list of nodes matching the XPath expression. More...
 
SharedPtr< NodeSelectSingleNode (const String &xpath)
 Selects the first Node that matches the XPath expression. More...
 
- Public Member Functions inherited from Node
SharedPtr< NodeClone (bool isCloneChildren)
 Creates a duplicate of the node. More...
 
int32_t get_CustomNodeId () const
 Specifies custom node identifier. More...
 
virtual SharedPtr< DocumentBaseget_Document () const
 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 (const SharedPtr< Node > &rootNode)
 Gets next node according to the pre-order tree traversal algorithm. More...
 
SharedPtr< NodePreviousPreOrder (const SharedPtr< Node > &rootNode)
 Gets the previous node according to the pre-order tree traversal algorithm. More...
 
void Remove ()
 Removes itself from the parent. More...
 
void set_CustomNodeId (int32_t value)
 Setter for get_CustomNodeId. More...
 
String ToString (SaveFormat saveFormat)
 Exports the content of the node into a string in the specified format. More...
 
String ToString (const SharedPtr< SaveOptions > &saveOptions)
 Exports the content of the node into a string using the specified save options. More...
 

Static Public Member Functions

static const TypeInfoType ()
 
- Static Public Member Functions inherited from CompositeNode
static const TypeInfoType ()
 
- 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 const TypeInfoType ()
 

Constructor & Destructor Documentation

◆ StructuredDocumentTag()

Aspose::Words::Markup::StructuredDocumentTag::StructuredDocumentTag ( const System::SharedPtr< Aspose::Words::DocumentBase > &  doc,
Aspose::Words::Markup::SdtType  type,
Aspose::Words::Markup::MarkupLevel  level 
)

Initializes a new instance of the Structured document tag class.

The following types of SDT can be created:

Parameters
docThe owner document.
typeType of SDT node.
levelLevel of SDT node within the document.
Examples

Show how to create a structured document tag in the form of a check box.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto sdtCheckBox = MakeObject<StructuredDocumentTag>(doc, SdtType::Checkbox, MarkupLevel::Inline);
sdtCheckBox->set_Checked(true);
// We can set the symbols used to represent the checked/unchecked state of a checkbox content control.
sdtCheckBox->SetCheckedSymbol(0x00A9, u"Times New Roman");
sdtCheckBox->SetUncheckedSymbol(0x00AE, u"Times New Roman");
builder->InsertNode(sdtCheckBox);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.CheckBox.docx");

Member Function Documentation

◆ Accept()

bool Aspose::Words::Markup::StructuredDocumentTag::Accept ( System::SharedPtr< Aspose::Words::DocumentVisitor visitor)
overridevirtual

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

Shows how to print the node structure of every structured document tag in a document.

void StructuredDocumentTagToText()
{
auto doc = MakeObject<Document>(MyDir + u"DocumentVisitor-compatible features.docx");
auto visitor = MakeObject<ExDocumentVisitor::StructuredDocumentTagNodePrinter>();
// When we get a composite node to accept a document visitor, the visitor visits the accepting node,
// and then traverses all the node's children in a depth-first manner.
// The visitor can read and modify each visited node.
doc->Accept(visitor);
std::cout << visitor->GetText() << std::endl;
}
class StructuredDocumentTagNodePrinter : public DocumentVisitor
{
public:
StructuredDocumentTagNodePrinter() : mVisitorIsInsideStructuredDocumentTag(false), mDocTraversalDepth(0)
{
mBuilder = MakeObject<System::Text::StringBuilder>();
mVisitorIsInsideStructuredDocumentTag = false;
}
String GetText()
{
return mBuilder->ToString();
}
VisitorAction VisitRun(SharedPtr<Run> run) override
{
if (mVisitorIsInsideStructuredDocumentTag)
{
IndentAndAppendLine(String(u"[Run] \"") + run->GetText() + u"\"");
}
}
VisitorAction VisitStructuredDocumentTagStart(SharedPtr<StructuredDocumentTag> sdt) override
{
IndentAndAppendLine(String(u"[StructuredDocumentTag start] Title: ") + sdt->get_Title());
mDocTraversalDepth++;
}
VisitorAction VisitStructuredDocumentTagEnd(SharedPtr<StructuredDocumentTag> sdt) override
{
mDocTraversalDepth--;
IndentAndAppendLine(u"[StructuredDocumentTag end]");
}
private:
bool mVisitorIsInsideStructuredDocumentTag;
int mDocTraversalDepth;
SharedPtr<System::Text::StringBuilder> mBuilder;
void IndentAndAppendLine(String text)
{
for (int i = 0; i < mDocTraversalDepth; i++)
{
mBuilder->Append(u"| ");
}
mBuilder->AppendLine(text);
}
};

Implements Aspose::Words::Node.

◆ Clear()

void Aspose::Words::Markup::StructuredDocumentTag::Clear ( )

Clears contents of this structured document tag and displays a placeholder if it is defined.

It is not possible to clear contents of a structured document tag if it has revisions.

If this structured document tag is mapped to custom XML (with using the XmlMapping property), the referenced XML node is cleared.

Examples

Shows how to delete contents of structured document tag elements.

auto doc = MakeObject<Document>();
// Create a plain text structured document tag, and then append it to the document.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Block);
doc->get_FirstSection()->get_Body()->AppendChild(tag);
// This structured document tag, which is in the form of a text box, already displays placeholder text.
ASSERT_EQ(u"Click here to enter text.", tag->GetText().Trim());
ASSERT_TRUE(tag->get_IsShowingPlaceholderText());
// Create a building block with text contents.
SharedPtr<GlossaryDocument> glossaryDoc = doc->get_GlossaryDocument();
auto substituteBlock = MakeObject<BuildingBlock>(glossaryDoc);
substituteBlock->set_Name(u"My placeholder");
substituteBlock->AppendChild(MakeObject<Section>(glossaryDoc));
substituteBlock->get_FirstSection()->EnsureMinimum();
substituteBlock->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(MakeObject<Run>(glossaryDoc, u"Custom placeholder text."));
glossaryDoc->AppendChild(substituteBlock);
// Set the structured document tag's "PlaceholderName" property to our building block's name to get
// the structured document tag to display the contents of the building block in place of the original default text.
tag->set_PlaceholderName(u"My placeholder");
ASSERT_EQ(u"Custom placeholder text.", tag->GetText().Trim());
ASSERT_TRUE(tag->get_IsShowingPlaceholderText());
// Edit the text of the structured document tag and hide the placeholder text.
auto run = System::DynamicCast<Run>(tag->GetChild(NodeType::Run, 0, true));
run->set_Text(u"New text.");
tag->set_IsShowingPlaceholderText(false);
ASSERT_EQ(u"New text.", tag->GetText().Trim());
// Use the "Clear" method to clear this structured document tag's contents and display the placeholder again.
tag->Clear();
ASSERT_TRUE(tag->get_IsShowingPlaceholderText());
ASSERT_EQ(u"Custom placeholder text.", tag->GetText().Trim());

◆ get_BuildingBlockCategory()

System::String Aspose::Words::Markup::StructuredDocumentTag::get_BuildingBlockCategory ( )

Specifies category of building block for this SDT node. Can not be null.

Accessing this property will only work for BuildingBlockGallery and DocPartObj SDT types. It is read-only for SDT of the document part type.

For all other SDT types exception will occur.

Examples

Shows how to insert a structured document tag as a building block, and set its category and gallery.

auto doc = MakeObject<Document>();
auto buildingBlockSdt = MakeObject<StructuredDocumentTag>(doc, SdtType::BuildingBlockGallery, MarkupLevel::Block);
buildingBlockSdt->set_BuildingBlockCategory(u"Built-in");
buildingBlockSdt->set_BuildingBlockGallery(u"Table of Contents");
doc->get_FirstSection()->get_Body()->AppendChild(buildingBlockSdt);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.BuildingBlockCategories.docx");

◆ get_BuildingBlockGallery()

System::String Aspose::Words::Markup::StructuredDocumentTag::get_BuildingBlockGallery ( )

Specifies type of building block for this SDT. Can not be null.

Accessing this property will only work for BuildingBlockGallery and DocPartObj SDT types. It is read-only for SDT of the document part type.

For all other SDT types exception will occur.

Examples

Shows how to insert a structured document tag as a building block, and set its category and gallery.

auto doc = MakeObject<Document>();
auto buildingBlockSdt = MakeObject<StructuredDocumentTag>(doc, SdtType::BuildingBlockGallery, MarkupLevel::Block);
buildingBlockSdt->set_BuildingBlockCategory(u"Built-in");
buildingBlockSdt->set_BuildingBlockGallery(u"Table of Contents");
doc->get_FirstSection()->get_Body()->AppendChild(buildingBlockSdt);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.BuildingBlockCategories.docx");

◆ get_CalendarType()

Aspose::Words::Markup::SdtCalendarType Aspose::Words::Markup::StructuredDocumentTag::get_CalendarType ( )

Specifies the type of calendar for this SDT. Default is Default

Accessing this property will only work for Date SDT type.

For all other SDT types exception will occur.

Examples

Shows how to prompt the user to enter a date with a structured document tag.

auto doc = MakeObject<Document>();
// Insert a structured document tag that prompts the user to enter a date.
// In Microsoft Word, this element is known as a "Date picker content control".
// When we click on the arrow on the right end of this tag in Microsoft Word,
// we will see a pop up in the form of a clickable calendar.
// We can use that popup to select a date that the tag will display.
auto sdtDate = MakeObject<StructuredDocumentTag>(doc, SdtType::Date, MarkupLevel::Inline);
// Display the date, according to the Saudi Arabian Arabic locale.
sdtDate->set_DateDisplayLocale(System::Globalization::CultureInfo::GetCultureInfo(u"ar-SA")->get_LCID());
// Set the format with which to display the date.
sdtDate->set_DateDisplayFormat(u"dd MMMM, yyyy");
sdtDate->set_DateStorageFormat(SdtDateStorageFormat::DateTime);
// Display the date according to the Hijri calendar.
sdtDate->set_CalendarType(SdtCalendarType::Hijri);
// Before the user chooses a date in Microsoft Word, the tag will display the text "Click here to enter a date.".
// According to the tag's calendar, set the "FullDate" property to get the tag to display a default date.
sdtDate->set_FullDate(System::DateTime(1440, 10, 20));
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertNode(sdtDate);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.Date.docx");

◆ get_Checked()

bool Aspose::Words::Markup::StructuredDocumentTag::get_Checked ( )

Gets/Sets current state of the Checkbox SDT. Default value for this property is false.

Accessing this property will only work for Checkbox SDT types.

For all other SDT types exception will occur.

Examples

Show how to create a structured document tag in the form of a check box.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto sdtCheckBox = MakeObject<StructuredDocumentTag>(doc, SdtType::Checkbox, MarkupLevel::Inline);
sdtCheckBox->set_Checked(true);
// We can set the symbols used to represent the checked/unchecked state of a checkbox content control.
sdtCheckBox->SetCheckedSymbol(0x00A9, u"Times New Roman");
sdtCheckBox->SetUncheckedSymbol(0x00AE, u"Times New Roman");
builder->InsertNode(sdtCheckBox);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.CheckBox.docx");

◆ get_Color()

System::Drawing::Color Aspose::Words::Markup::StructuredDocumentTag::get_Color ( )

Gets or sets the color of the structured document tag.

Examples

Shows how to create a structured document tag in a plain text box and modify its appearance.

auto doc = MakeObject<Document>();
// Create a structured document tag that will contain plain text.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
// Set the title and color of the frame that appears when you mouse over the structured document tag in Microsoft Word.
tag->set_Title(u"My plain text");
// Set a tag for this structured document tag, which is obtainable
// as an XML element named "tag", with the string below in its "@val" attribute.
tag->set_Tag(u"MyPlainTextSDT");
// Every structured document tag has a random unique ID.
ASSERT_GT(tag->get_Id(), 0);
// Set the font for the text inside the structured document tag.
tag->get_ContentsFont()->set_Name(u"Arial");
// Set the font for the text at the end of the structured document tag.
// Any text that we type in the document body after moving out of the tag with arrow keys will use this font.
tag->get_EndCharacterFont()->set_Name(u"Arial Black");
// By default, this is false and pressing enter while inside a structured document tag does nothing.
// When set to true, our structured document tag can have multiple lines.
// Set the "Multiline" property to "false" to only allow the contents
// of this structured document tag to span a single line.
// Set the "Multiline" property to "true" to allow the tag to contain multiple lines of content.
tag->set_Multiline(true);
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertNode(tag);
// Insert a clone of our structured document tag in a new paragraph.
auto tagClone = System::DynamicCast<StructuredDocumentTag>(tag->Clone(true));
builder->InsertParagraph();
builder->InsertNode(tagClone);
// Use the "RemoveSelfOnly" method to remove a structured document tag, while keeping its contents in the document.
tagClone->RemoveSelfOnly();
doc->Save(ArtifactsDir + u"StructuredDocumentTag.PlainText.docx");

◆ get_ContentsFont()

System::SharedPtr<Aspose::Words::Font> Aspose::Words::Markup::StructuredDocumentTag::get_ContentsFont ( )

Font formatting that will be applied to text entered into SDT.

Examples

Shows how to create a structured document tag in a plain text box and modify its appearance.

auto doc = MakeObject<Document>();
// Create a structured document tag that will contain plain text.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
// Set the title and color of the frame that appears when you mouse over the structured document tag in Microsoft Word.
tag->set_Title(u"My plain text");
// Set a tag for this structured document tag, which is obtainable
// as an XML element named "tag", with the string below in its "@val" attribute.
tag->set_Tag(u"MyPlainTextSDT");
// Every structured document tag has a random unique ID.
ASSERT_GT(tag->get_Id(), 0);
// Set the font for the text inside the structured document tag.
tag->get_ContentsFont()->set_Name(u"Arial");
// Set the font for the text at the end of the structured document tag.
// Any text that we type in the document body after moving out of the tag with arrow keys will use this font.
tag->get_EndCharacterFont()->set_Name(u"Arial Black");
// By default, this is false and pressing enter while inside a structured document tag does nothing.
// When set to true, our structured document tag can have multiple lines.
// Set the "Multiline" property to "false" to only allow the contents
// of this structured document tag to span a single line.
// Set the "Multiline" property to "true" to allow the tag to contain multiple lines of content.
tag->set_Multiline(true);
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertNode(tag);
// Insert a clone of our structured document tag in a new paragraph.
auto tagClone = System::DynamicCast<StructuredDocumentTag>(tag->Clone(true));
builder->InsertParagraph();
builder->InsertNode(tagClone);
// Use the "RemoveSelfOnly" method to remove a structured document tag, while keeping its contents in the document.
tagClone->RemoveSelfOnly();
doc->Save(ArtifactsDir + u"StructuredDocumentTag.PlainText.docx");

◆ get_DateDisplayFormat()

System::String Aspose::Words::Markup::StructuredDocumentTag::get_DateDisplayFormat ( )

String that represents the format in which dates are displayed. Can not be null.

Accessing this property will only work for Date SDT type.

For all other SDT types exception will occur.

Examples

Shows how to prompt the user to enter a date with a structured document tag.

auto doc = MakeObject<Document>();
// Insert a structured document tag that prompts the user to enter a date.
// In Microsoft Word, this element is known as a "Date picker content control".
// When we click on the arrow on the right end of this tag in Microsoft Word,
// we will see a pop up in the form of a clickable calendar.
// We can use that popup to select a date that the tag will display.
auto sdtDate = MakeObject<StructuredDocumentTag>(doc, SdtType::Date, MarkupLevel::Inline);
// Display the date, according to the Saudi Arabian Arabic locale.
sdtDate->set_DateDisplayLocale(System::Globalization::CultureInfo::GetCultureInfo(u"ar-SA")->get_LCID());
// Set the format with which to display the date.
sdtDate->set_DateDisplayFormat(u"dd MMMM, yyyy");
sdtDate->set_DateStorageFormat(SdtDateStorageFormat::DateTime);
// Display the date according to the Hijri calendar.
sdtDate->set_CalendarType(SdtCalendarType::Hijri);
// Before the user chooses a date in Microsoft Word, the tag will display the text "Click here to enter a date.".
// According to the tag's calendar, set the "FullDate" property to get the tag to display a default date.
sdtDate->set_FullDate(System::DateTime(1440, 10, 20));
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertNode(sdtDate);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.Date.docx");

◆ get_DateDisplayLocale()

int32_t Aspose::Words::Markup::StructuredDocumentTag::get_DateDisplayLocale ( )

Allows to set/get the language format for the date displayed in this SDT.

Accessing this property will only work for Date SDT type.

For all other SDT types exception will occur.

Examples

Shows how to prompt the user to enter a date with a structured document tag.

auto doc = MakeObject<Document>();
// Insert a structured document tag that prompts the user to enter a date.
// In Microsoft Word, this element is known as a "Date picker content control".
// When we click on the arrow on the right end of this tag in Microsoft Word,
// we will see a pop up in the form of a clickable calendar.
// We can use that popup to select a date that the tag will display.
auto sdtDate = MakeObject<StructuredDocumentTag>(doc, SdtType::Date, MarkupLevel::Inline);
// Display the date, according to the Saudi Arabian Arabic locale.
sdtDate->set_DateDisplayLocale(System::Globalization::CultureInfo::GetCultureInfo(u"ar-SA")->get_LCID());
// Set the format with which to display the date.
sdtDate->set_DateDisplayFormat(u"dd MMMM, yyyy");
sdtDate->set_DateStorageFormat(SdtDateStorageFormat::DateTime);
// Display the date according to the Hijri calendar.
sdtDate->set_CalendarType(SdtCalendarType::Hijri);
// Before the user chooses a date in Microsoft Word, the tag will display the text "Click here to enter a date.".
// According to the tag's calendar, set the "FullDate" property to get the tag to display a default date.
sdtDate->set_FullDate(System::DateTime(1440, 10, 20));
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertNode(sdtDate);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.Date.docx");

◆ get_DateStorageFormat()

Aspose::Words::Markup::SdtDateStorageFormat Aspose::Words::Markup::StructuredDocumentTag::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

Accessing this property will only work for Date SDT type.

For all other SDT types exception will occur.

Examples

Shows how to prompt the user to enter a date with a structured document tag.

auto doc = MakeObject<Document>();
// Insert a structured document tag that prompts the user to enter a date.
// In Microsoft Word, this element is known as a "Date picker content control".
// When we click on the arrow on the right end of this tag in Microsoft Word,
// we will see a pop up in the form of a clickable calendar.
// We can use that popup to select a date that the tag will display.
auto sdtDate = MakeObject<StructuredDocumentTag>(doc, SdtType::Date, MarkupLevel::Inline);
// Display the date, according to the Saudi Arabian Arabic locale.
sdtDate->set_DateDisplayLocale(System::Globalization::CultureInfo::GetCultureInfo(u"ar-SA")->get_LCID());
// Set the format with which to display the date.
sdtDate->set_DateDisplayFormat(u"dd MMMM, yyyy");
sdtDate->set_DateStorageFormat(SdtDateStorageFormat::DateTime);
// Display the date according to the Hijri calendar.
sdtDate->set_CalendarType(SdtCalendarType::Hijri);
// Before the user chooses a date in Microsoft Word, the tag will display the text "Click here to enter a date.".
// According to the tag's calendar, set the "FullDate" property to get the tag to display a default date.
sdtDate->set_FullDate(System::DateTime(1440, 10, 20));
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertNode(sdtDate);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.Date.docx");

◆ get_EndCharacterFont()

System::SharedPtr<Aspose::Words::Font> Aspose::Words::Markup::StructuredDocumentTag::get_EndCharacterFont ( )

Font formatting that will be applied to the last character of text entered into SDT.

Examples

Shows how to create a structured document tag in a plain text box and modify its appearance.

auto doc = MakeObject<Document>();
// Create a structured document tag that will contain plain text.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
// Set the title and color of the frame that appears when you mouse over the structured document tag in Microsoft Word.
tag->set_Title(u"My plain text");
// Set a tag for this structured document tag, which is obtainable
// as an XML element named "tag", with the string below in its "@val" attribute.
tag->set_Tag(u"MyPlainTextSDT");
// Every structured document tag has a random unique ID.
ASSERT_GT(tag->get_Id(), 0);
// Set the font for the text inside the structured document tag.
tag->get_ContentsFont()->set_Name(u"Arial");
// Set the font for the text at the end of the structured document tag.
// Any text that we type in the document body after moving out of the tag with arrow keys will use this font.
tag->get_EndCharacterFont()->set_Name(u"Arial Black");
// By default, this is false and pressing enter while inside a structured document tag does nothing.
// When set to true, our structured document tag can have multiple lines.
// Set the "Multiline" property to "false" to only allow the contents
// of this structured document tag to span a single line.
// Set the "Multiline" property to "true" to allow the tag to contain multiple lines of content.
tag->set_Multiline(true);
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertNode(tag);
// Insert a clone of our structured document tag in a new paragraph.
auto tagClone = System::DynamicCast<StructuredDocumentTag>(tag->Clone(true));
builder->InsertParagraph();
builder->InsertNode(tagClone);
// Use the "RemoveSelfOnly" method to remove a structured document tag, while keeping its contents in the document.
tagClone->RemoveSelfOnly();
doc->Save(ArtifactsDir + u"StructuredDocumentTag.PlainText.docx");

◆ get_FullDate()

System::DateTime Aspose::Words::Markup::StructuredDocumentTag::get_FullDate ( )

Specifies the full date and time last entered into this SDT.

Accessing this property will only work for Date SDT type.

For all other SDT types exception will occur.

Examples

Shows how to prompt the user to enter a date with a structured document tag.

auto doc = MakeObject<Document>();
// Insert a structured document tag that prompts the user to enter a date.
// In Microsoft Word, this element is known as a "Date picker content control".
// When we click on the arrow on the right end of this tag in Microsoft Word,
// we will see a pop up in the form of a clickable calendar.
// We can use that popup to select a date that the tag will display.
auto sdtDate = MakeObject<StructuredDocumentTag>(doc, SdtType::Date, MarkupLevel::Inline);
// Display the date, according to the Saudi Arabian Arabic locale.
sdtDate->set_DateDisplayLocale(System::Globalization::CultureInfo::GetCultureInfo(u"ar-SA")->get_LCID());
// Set the format with which to display the date.
sdtDate->set_DateDisplayFormat(u"dd MMMM, yyyy");
sdtDate->set_DateStorageFormat(SdtDateStorageFormat::DateTime);
// Display the date according to the Hijri calendar.
sdtDate->set_CalendarType(SdtCalendarType::Hijri);
// Before the user chooses a date in Microsoft Word, the tag will display the text "Click here to enter a date.".
// According to the tag's calendar, set the "FullDate" property to get the tag to display a default date.
sdtDate->set_FullDate(System::DateTime(1440, 10, 20));
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertNode(sdtDate);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.Date.docx");

◆ get_Id()

int32_t Aspose::Words::Markup::StructuredDocumentTag::get_Id ( )

Specifies a unique read-only persistent numerical Id for this SDT.

Id attribute shall follow these rules:

  • The document shall retain SDT ids only if the whole document is cloned Clone.
  • During ImportNode() Id shall be retained if import does not cause conflicts with other SDT Ids in the target document.
  • If multiple SDT nodes specify the same decimal number value for the Id attribute, then the first SDT in the document shall maintain this original Id, and all subsequent SDT nodes shall have new identifiers assigned to them when the document is loaded.
  • During standalone SDT Clone() operation new unique ID will be generated for the cloned SDT node.
  • If Id is not specified in the source document, then the SDT node shall have a new unique identifier assigned to it when the document is loaded.
Examples

Shows how to create a structured document tag in a plain text box and modify its appearance.

auto doc = MakeObject<Document>();
// Create a structured document tag that will contain plain text.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
// Set the title and color of the frame that appears when you mouse over the structured document tag in Microsoft Word.
tag->set_Title(u"My plain text");
// Set a tag for this structured document tag, which is obtainable
// as an XML element named "tag", with the string below in its "@val" attribute.
tag->set_Tag(u"MyPlainTextSDT");
// Every structured document tag has a random unique ID.
ASSERT_GT(tag->get_Id(), 0);
// Set the font for the text inside the structured document tag.
tag->get_ContentsFont()->set_Name(u"Arial");
// Set the font for the text at the end of the structured document tag.
// Any text that we type in the document body after moving out of the tag with arrow keys will use this font.
tag->get_EndCharacterFont()->set_Name(u"Arial Black");
// By default, this is false and pressing enter while inside a structured document tag does nothing.
// When set to true, our structured document tag can have multiple lines.
// Set the "Multiline" property to "false" to only allow the contents
// of this structured document tag to span a single line.
// Set the "Multiline" property to "true" to allow the tag to contain multiple lines of content.
tag->set_Multiline(true);
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertNode(tag);
// Insert a clone of our structured document tag in a new paragraph.
auto tagClone = System::DynamicCast<StructuredDocumentTag>(tag->Clone(true));
builder->InsertParagraph();
builder->InsertNode(tagClone);
// Use the "RemoveSelfOnly" method to remove a structured document tag, while keeping its contents in the document.
tagClone->RemoveSelfOnly();
doc->Save(ArtifactsDir + u"StructuredDocumentTag.PlainText.docx");

◆ get_IsShowingPlaceholderText()

bool Aspose::Words::Markup::StructuredDocumentTag::get_IsShowingPlaceholderText ( ) const

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

Examples

Shows how to use a building block's contents as a custom placeholder text for a structured document tag.

auto doc = MakeObject<Document>();
// Insert a plain text structured document tag of the "PlainText" type, which will function as a text box.
// The contents that it will display by default are a "Click here to enter text." prompt.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
// We can get the tag to display the contents of a building block instead of the default text.
// First, add a building block with contents to the glossary document.
SharedPtr<GlossaryDocument> glossaryDoc = doc->get_GlossaryDocument();
auto substituteBlock = MakeObject<BuildingBlock>(glossaryDoc);
substituteBlock->set_Name(u"Custom Placeholder");
substituteBlock->AppendChild(MakeObject<Section>(glossaryDoc));
substituteBlock->get_FirstSection()->AppendChild(MakeObject<Body>(glossaryDoc));
substituteBlock->get_FirstSection()->get_Body()->AppendParagraph(u"Custom placeholder text.");
glossaryDoc->AppendChild(substituteBlock);
// Then, use the structured document tag's "PlaceholderName" property to reference that building block by name.
tag->set_PlaceholderName(u"Custom Placeholder");
// If "PlaceholderName" refers to an existing block in the parent document's glossary document,
// we will be able to verify the building block via the "Placeholder" property.
ASPOSE_ASSERT_EQ(substituteBlock, tag->get_Placeholder());
// Set the "IsShowingPlaceholderText" property to "true" to treat the
// structured document tag's current contents as placeholder text.
// This means that clicking on the text box in Microsoft Word will immediately highlight all the tag's contents.
// Set the "IsShowingPlaceholderText" property to "false" to get the
// structured document tag to treat its contents as text that a user has already entered.
// Clicking on this text in Microsoft Word will place the blinking cursor at the clicked location.
tag->set_IsShowingPlaceholderText(isShowingPlaceholderText);
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertNode(tag);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.PlaceholderBuildingBlock.docx");

◆ get_IsTemporary()

bool Aspose::Words::Markup::StructuredDocumentTag::get_IsTemporary ( ) const

Specifies whether this SDT shall be removed from the WordProcessingML document when its contents are modified.

Examples

Shows how to make single-use controls.

auto doc = MakeObject<Document>();
// Insert a plain text structured document tag,
// which will act as a plain text form that the user may enter text into.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
// Set the "IsTemporary" property to "true" to make the structured document tag disappear and
// assimilate its contents into the document after the user edits it once in Microsoft Word.
// Set the "IsTemporary" property to "false" to allow the user to edit the contents
// of the structured document tag any number of times.
tag->set_IsTemporary(isTemporary);
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Write(u"Please enter text: ");
builder->InsertNode(tag);
// Insert another structured document tag in the form of a check box and set its default state to "checked".
tag = MakeObject<StructuredDocumentTag>(doc, SdtType::Checkbox, MarkupLevel::Inline);
tag->set_Checked(true);
// Set the "IsTemporary" property to "true" to make the check box become a symbol
// once the user clicks on it in Microsoft Word.
// Set the "IsTemporary" property to "false" to allow the user to click on the check box any number of times.
tag->set_IsTemporary(isTemporary);
builder->Write(u"\nPlease click the check box: ");
builder->InsertNode(tag);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.IsTemporary.docx");

◆ get_Level()

Aspose::Words::Markup::MarkupLevel Aspose::Words::Markup::StructuredDocumentTag::get_Level ( ) const

Gets the level at which this SDT occurs in the document tree.

Examples

Shows how to create a structured document tag in a plain text box and modify its appearance.

auto doc = MakeObject<Document>();
// Create a structured document tag that will contain plain text.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
// Set the title and color of the frame that appears when you mouse over the structured document tag in Microsoft Word.
tag->set_Title(u"My plain text");
// Set a tag for this structured document tag, which is obtainable
// as an XML element named "tag", with the string below in its "@val" attribute.
tag->set_Tag(u"MyPlainTextSDT");
// Every structured document tag has a random unique ID.
ASSERT_GT(tag->get_Id(), 0);
// Set the font for the text inside the structured document tag.
tag->get_ContentsFont()->set_Name(u"Arial");
// Set the font for the text at the end of the structured document tag.
// Any text that we type in the document body after moving out of the tag with arrow keys will use this font.
tag->get_EndCharacterFont()->set_Name(u"Arial Black");
// By default, this is false and pressing enter while inside a structured document tag does nothing.
// When set to true, our structured document tag can have multiple lines.
// Set the "Multiline" property to "false" to only allow the contents
// of this structured document tag to span a single line.
// Set the "Multiline" property to "true" to allow the tag to contain multiple lines of content.
tag->set_Multiline(true);
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertNode(tag);
// Insert a clone of our structured document tag in a new paragraph.
auto tagClone = System::DynamicCast<StructuredDocumentTag>(tag->Clone(true));
builder->InsertParagraph();
builder->InsertNode(tagClone);
// Use the "RemoveSelfOnly" method to remove a structured document tag, while keeping its contents in the document.
tagClone->RemoveSelfOnly();
doc->Save(ArtifactsDir + u"StructuredDocumentTag.PlainText.docx");

◆ get_Level_IMarkupNode()

Aspose::Words::Markup::MarkupLevel Aspose::Words::Markup::StructuredDocumentTag::get_Level_IMarkupNode ( )
override

◆ get_ListItems()

System::SharedPtr<Aspose::Words::Markup::SdtListItemCollection> Aspose::Words::Markup::StructuredDocumentTag::get_ListItems ( )

Gets SdtListItemCollection associated with this SDT.

Accessing this property will only work for ComboBox or DropDownList SDT types.

For all other SDT types exception will occur.

Examples

Shows how to work with drop down-list structured document tags.

auto doc = MakeObject<Document>();
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::DropDownList, MarkupLevel::Block);
doc->get_FirstSection()->get_Body()->AppendChild(tag);
// A drop-down list structured document tag is a form that allows the user to
// select an option from a list by left-clicking and opening the form in Microsoft Word.
// The "ListItems" property contains all list items, and each list item is an "SdtListItem".
SharedPtr<SdtListItemCollection> listItems = tag->get_ListItems();
listItems->Add(MakeObject<SdtListItem>(u"Value 1"));
ASSERT_EQ(listItems->idx_get(0)->get_DisplayText(), listItems->idx_get(0)->get_Value());
// Add 3 more list items. Initialize these items using a different constructor to the first item
// to display strings that are different from their values.
listItems->Add(MakeObject<SdtListItem>(u"Item 2", u"Value 2"));
listItems->Add(MakeObject<SdtListItem>(u"Item 3", u"Value 3"));
listItems->Add(MakeObject<SdtListItem>(u"Item 4", u"Value 4"));
ASSERT_EQ(4, listItems->get_Count());
// The drop-down list is displaying the first item. Assign a different list item to the "SelectedValue" to display it.
listItems->set_SelectedValue(listItems->idx_get(3));
ASSERT_EQ(u"Value 4", listItems->get_SelectedValue()->get_Value());
// Enumerate over the collection and print each element.
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<SdtListItem>>> enumerator = listItems->GetEnumerator();
while (enumerator->MoveNext())
{
if (enumerator->get_Current() != nullptr)
{
std::cout << "List item: " << enumerator->get_Current()->get_DisplayText() << ", value: " << enumerator->get_Current()->get_Value()
<< std::endl;
}
}
}
// Remove the last list item.
listItems->RemoveAt(3);
ASSERT_EQ(3, listItems->get_Count());
// Since our drop-down control is set to display the removed item by default, give it an item to display which exists.
listItems->set_SelectedValue(listItems->idx_get(1));
doc->Save(ArtifactsDir + u"StructuredDocumentTag.ListItemCollection.docx");
// Use the "Clear" method to empty the entire drop-down item collection at once.
listItems->Clear();
ASSERT_EQ(0, listItems->get_Count());

◆ get_LockContentControl()

bool Aspose::Words::Markup::StructuredDocumentTag::get_LockContentControl ( ) const

When set to true, this property will prohibit a user from deleting this SDT.

Examples

Shows how to apply editing restrictions to structured document tags.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a plain text structured document tag, which acts as a text box that prompts the user to fill it in.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
// Set the "LockContents" property to "true" to prohibit the user from editing this text box's contents.
tag->set_LockContents(true);
builder->Write(u"The contents of this structured document tag cannot be edited: ");
builder->InsertNode(tag);
tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
// Set the "LockContentControl" property to "true" to prohibit the user from
// deleting this structured document tag manually in Microsoft Word.
tag->set_LockContentControl(true);
builder->InsertParagraph();
builder->Write(u"This structured document tag cannot be deleted but its contents can be edited: ");
builder->InsertNode(tag);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.Lock.docx");

◆ get_LockContents()

bool Aspose::Words::Markup::StructuredDocumentTag::get_LockContents ( ) const

When set to true, this property will prohibit a user from editing the contents of this SDT.

Examples

Shows how to apply editing restrictions to structured document tags.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a plain text structured document tag, which acts as a text box that prompts the user to fill it in.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
// Set the "LockContents" property to "true" to prohibit the user from editing this text box's contents.
tag->set_LockContents(true);
builder->Write(u"The contents of this structured document tag cannot be edited: ");
builder->InsertNode(tag);
tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
// Set the "LockContentControl" property to "true" to prohibit the user from
// deleting this structured document tag manually in Microsoft Word.
tag->set_LockContentControl(true);
builder->InsertParagraph();
builder->Write(u"This structured document tag cannot be deleted but its contents can be edited: ");
builder->InsertNode(tag);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.Lock.docx");

◆ get_Multiline()

bool Aspose::Words::Markup::StructuredDocumentTag::get_Multiline ( )

Specifies whether this SDT allows multiple lines of text.

Accessing this property will only work for RichText and PlainText SDT type.

For all other SDT types exception will occur.

Examples

Shows how to create a structured document tag in a plain text box and modify its appearance.

auto doc = MakeObject<Document>();
// Create a structured document tag that will contain plain text.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
// Set the title and color of the frame that appears when you mouse over the structured document tag in Microsoft Word.
tag->set_Title(u"My plain text");
// Set a tag for this structured document tag, which is obtainable
// as an XML element named "tag", with the string below in its "@val" attribute.
tag->set_Tag(u"MyPlainTextSDT");
// Every structured document tag has a random unique ID.
ASSERT_GT(tag->get_Id(), 0);
// Set the font for the text inside the structured document tag.
tag->get_ContentsFont()->set_Name(u"Arial");
// Set the font for the text at the end of the structured document tag.
// Any text that we type in the document body after moving out of the tag with arrow keys will use this font.
tag->get_EndCharacterFont()->set_Name(u"Arial Black");
// By default, this is false and pressing enter while inside a structured document tag does nothing.
// When set to true, our structured document tag can have multiple lines.
// Set the "Multiline" property to "false" to only allow the contents
// of this structured document tag to span a single line.
// Set the "Multiline" property to "true" to allow the tag to contain multiple lines of content.
tag->set_Multiline(true);
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertNode(tag);
// Insert a clone of our structured document tag in a new paragraph.
auto tagClone = System::DynamicCast<StructuredDocumentTag>(tag->Clone(true));
builder->InsertParagraph();
builder->InsertNode(tagClone);
// Use the "RemoveSelfOnly" method to remove a structured document tag, while keeping its contents in the document.
tagClone->RemoveSelfOnly();
doc->Save(ArtifactsDir + u"StructuredDocumentTag.PlainText.docx");

◆ get_NodeType()

Aspose::Words::NodeType Aspose::Words::Markup::StructuredDocumentTag::get_NodeType ( ) const
overridevirtual

Returns NodeType.StructuredDocumentTag.

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::DynamicCast<StructuredDocumentTag>(node);
ASSERT_EQ(StyleIdentifier::Quote, sdt->get_Style()->get_StyleIdentifier());
ASSERT_EQ(u"Quote", sdt->get_StyleName());
}

Implements Aspose::Words::Node.

◆ get_Placeholder()

System::SharedPtr<Aspose::Words::BuildingBlocks::BuildingBlock> Aspose::Words::Markup::StructuredDocumentTag::get_Placeholder ( ) const

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

Examples

Shows how to use a building block's contents as a custom placeholder text for a structured document tag.

auto doc = MakeObject<Document>();
// Insert a plain text structured document tag of the "PlainText" type, which will function as a text box.
// The contents that it will display by default are a "Click here to enter text." prompt.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
// We can get the tag to display the contents of a building block instead of the default text.
// First, add a building block with contents to the glossary document.
SharedPtr<GlossaryDocument> glossaryDoc = doc->get_GlossaryDocument();
auto substituteBlock = MakeObject<BuildingBlock>(glossaryDoc);
substituteBlock->set_Name(u"Custom Placeholder");
substituteBlock->AppendChild(MakeObject<Section>(glossaryDoc));
substituteBlock->get_FirstSection()->AppendChild(MakeObject<Body>(glossaryDoc));
substituteBlock->get_FirstSection()->get_Body()->AppendParagraph(u"Custom placeholder text.");
glossaryDoc->AppendChild(substituteBlock);
// Then, use the structured document tag's "PlaceholderName" property to reference that building block by name.
tag->set_PlaceholderName(u"Custom Placeholder");
// If "PlaceholderName" refers to an existing block in the parent document's glossary document,
// we will be able to verify the building block via the "Placeholder" property.
ASPOSE_ASSERT_EQ(substituteBlock, tag->get_Placeholder());
// Set the "IsShowingPlaceholderText" property to "true" to treat the
// structured document tag's current contents as placeholder text.
// This means that clicking on the text box in Microsoft Word will immediately highlight all the tag's contents.
// Set the "IsShowingPlaceholderText" property to "false" to get the
// structured document tag to treat its contents as text that a user has already entered.
// Clicking on this text in Microsoft Word will place the blinking cursor at the clicked location.
tag->set_IsShowingPlaceholderText(isShowingPlaceholderText);
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertNode(tag);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.PlaceholderBuildingBlock.docx");

◆ get_PlaceholderName()

System::String Aspose::Words::Markup::StructuredDocumentTag::get_PlaceholderName ( ) const

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

Examples

Shows how to use a building block's contents as a custom placeholder text for a structured document tag.

auto doc = MakeObject<Document>();
// Insert a plain text structured document tag of the "PlainText" type, which will function as a text box.
// The contents that it will display by default are a "Click here to enter text." prompt.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
// We can get the tag to display the contents of a building block instead of the default text.
// First, add a building block with contents to the glossary document.
SharedPtr<GlossaryDocument> glossaryDoc = doc->get_GlossaryDocument();
auto substituteBlock = MakeObject<BuildingBlock>(glossaryDoc);
substituteBlock->set_Name(u"Custom Placeholder");
substituteBlock->AppendChild(MakeObject<Section>(glossaryDoc));
substituteBlock->get_FirstSection()->AppendChild(MakeObject<Body>(glossaryDoc));
substituteBlock->get_FirstSection()->get_Body()->AppendParagraph(u"Custom placeholder text.");
glossaryDoc->AppendChild(substituteBlock);
// Then, use the structured document tag's "PlaceholderName" property to reference that building block by name.
tag->set_PlaceholderName(u"Custom Placeholder");
// If "PlaceholderName" refers to an existing block in the parent document's glossary document,
// we will be able to verify the building block via the "Placeholder" property.
ASPOSE_ASSERT_EQ(substituteBlock, tag->get_Placeholder());
// Set the "IsShowingPlaceholderText" property to "true" to treat the
// structured document tag's current contents as placeholder text.
// This means that clicking on the text box in Microsoft Word will immediately highlight all the tag's contents.
// Set the "IsShowingPlaceholderText" property to "false" to get the
// structured document tag to treat its contents as text that a user has already entered.
// Clicking on this text in Microsoft Word will place the blinking cursor at the clicked location.
tag->set_IsShowingPlaceholderText(isShowingPlaceholderText);
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertNode(tag);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.PlaceholderBuildingBlock.docx");

◆ get_SdtType()

Aspose::Words::Markup::SdtType Aspose::Words::Markup::StructuredDocumentTag::get_SdtType ( )

Gets type of this Structured document tag.

Examples

Shows how to get the type of a structured document tag.

auto doc = MakeObject<Document>(MyDir + u"Structured document tags.docx");
SharedPtr<System::Collections::Generic::List<SharedPtr<StructuredDocumentTag>>> sdTags =
doc->GetChildNodes(NodeType::StructuredDocumentTag, true)->LINQ_OfType<SharedPtr<StructuredDocumentTag>>()->LINQ_ToList();
ASSERT_EQ(SdtType::RepeatingSection, sdTags->idx_get(0)->get_SdtType());
ASSERT_EQ(SdtType::RepeatingSectionItem, sdTags->idx_get(1)->get_SdtType());
ASSERT_EQ(SdtType::RichText, sdTags->idx_get(2)->get_SdtType());

◆ get_Style()

System::SharedPtr<Aspose::Words::Style> Aspose::Words::Markup::StructuredDocumentTag::get_Style ( )

Gets or sets the Style of the structured document tag.

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::DynamicCast<StructuredDocumentTag>(node);
ASSERT_EQ(StyleIdentifier::Quote, sdt->get_Style()->get_StyleIdentifier());
ASSERT_EQ(u"Quote", sdt->get_StyleName());
}

◆ get_StyleName()

System::String Aspose::Words::Markup::StructuredDocumentTag::get_StyleName ( )

Gets or sets the name of the style applied to the structured document tag.

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::DynamicCast<StructuredDocumentTag>(node);
ASSERT_EQ(StyleIdentifier::Quote, sdt->get_Style()->get_StyleIdentifier());
ASSERT_EQ(u"Quote", sdt->get_StyleName());
}

◆ get_Tag()

System::String Aspose::Words::Markup::StructuredDocumentTag::get_Tag ( ) const

Specifies a tag associated with the current SDT node. Can not be null.

Examples

Shows how to create a structured document tag in a plain text box and modify its appearance.

auto doc = MakeObject<Document>();
// Create a structured document tag that will contain plain text.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
// Set the title and color of the frame that appears when you mouse over the structured document tag in Microsoft Word.
tag->set_Title(u"My plain text");
// Set a tag for this structured document tag, which is obtainable
// as an XML element named "tag", with the string below in its "@val" attribute.
tag->set_Tag(u"MyPlainTextSDT");
// Every structured document tag has a random unique ID.
ASSERT_GT(tag->get_Id(), 0);
// Set the font for the text inside the structured document tag.
tag->get_ContentsFont()->set_Name(u"Arial");
// Set the font for the text at the end of the structured document tag.
// Any text that we type in the document body after moving out of the tag with arrow keys will use this font.
tag->get_EndCharacterFont()->set_Name(u"Arial Black");
// By default, this is false and pressing enter while inside a structured document tag does nothing.
// When set to true, our structured document tag can have multiple lines.
// Set the "Multiline" property to "false" to only allow the contents
// of this structured document tag to span a single line.
// Set the "Multiline" property to "true" to allow the tag to contain multiple lines of content.
tag->set_Multiline(true);
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertNode(tag);
// Insert a clone of our structured document tag in a new paragraph.
auto tagClone = System::DynamicCast<StructuredDocumentTag>(tag->Clone(true));
builder->InsertParagraph();
builder->InsertNode(tagClone);
// Use the "RemoveSelfOnly" method to remove a structured document tag, while keeping its contents in the document.
tagClone->RemoveSelfOnly();
doc->Save(ArtifactsDir + u"StructuredDocumentTag.PlainText.docx");

◆ get_Title()

System::String Aspose::Words::Markup::StructuredDocumentTag::get_Title ( ) const

Specifies the friendly name associated with this SDT. Can not be null.

Examples

Shows how to create a structured document tag in a plain text box and modify its appearance.

auto doc = MakeObject<Document>();
// Create a structured document tag that will contain plain text.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
// Set the title and color of the frame that appears when you mouse over the structured document tag in Microsoft Word.
tag->set_Title(u"My plain text");
// Set a tag for this structured document tag, which is obtainable
// as an XML element named "tag", with the string below in its "@val" attribute.
tag->set_Tag(u"MyPlainTextSDT");
// Every structured document tag has a random unique ID.
ASSERT_GT(tag->get_Id(), 0);
// Set the font for the text inside the structured document tag.
tag->get_ContentsFont()->set_Name(u"Arial");
// Set the font for the text at the end of the structured document tag.
// Any text that we type in the document body after moving out of the tag with arrow keys will use this font.
tag->get_EndCharacterFont()->set_Name(u"Arial Black");
// By default, this is false and pressing enter while inside a structured document tag does nothing.
// When set to true, our structured document tag can have multiple lines.
// Set the "Multiline" property to "false" to only allow the contents
// of this structured document tag to span a single line.
// Set the "Multiline" property to "true" to allow the tag to contain multiple lines of content.
tag->set_Multiline(true);
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertNode(tag);
// Insert a clone of our structured document tag in a new paragraph.
auto tagClone = System::DynamicCast<StructuredDocumentTag>(tag->Clone(true));
builder->InsertParagraph();
builder->InsertNode(tagClone);
// Use the "RemoveSelfOnly" method to remove a structured document tag, while keeping its contents in the document.
tagClone->RemoveSelfOnly();
doc->Save(ArtifactsDir + u"StructuredDocumentTag.PlainText.docx");

◆ get_XmlMapping()

System::SharedPtr<Aspose::Words::Markup::XmlMapping> Aspose::Words::Markup::StructuredDocumentTag::get_XmlMapping ( ) const

Gets an object that represents the mapping of this structured document tag to XML data in a custom XML part of the current document.

Examples

Shows how to create a structured document tag with custom XML data.

auto doc = MakeObject<Document>();
// Construct an XML part that contains data and add it to the document's collection.
// If we enable the "Developer" tab in Microsoft Word,
// we can find elements from this collection in the "XML Mapping Pane", along with a few default elements.
String xmlPartId = System::Guid::NewGuid().ToString(u"B");
String xmlPartContent = u"<root><text>Hello world!</text></root>";
SharedPtr<CustomXmlPart> xmlPart = doc->get_CustomXmlParts()->Add(xmlPartId, xmlPartContent);
ASPOSE_ASSERT_EQ(System::Text::Encoding::get_ASCII()->GetBytes(xmlPartContent), xmlPart->get_Data());
ASSERT_EQ(xmlPartId, xmlPart->get_Id());
// Below are two ways to refer to XML parts.
// 1 - By an index in the custom XML part collection:
ASPOSE_ASSERT_EQ(xmlPart, doc->get_CustomXmlParts()->idx_get(0));
// 2 - By GUID:
ASPOSE_ASSERT_EQ(xmlPart, doc->get_CustomXmlParts()->GetById(xmlPartId));
// Add an XML schema association.
xmlPart->get_Schemas()->Add(u"http://www.w3.org/2001/XMLSchema");
// Clone a part, and then insert it into the collection.
SharedPtr<CustomXmlPart> xmlPartClone = xmlPart->Clone();
xmlPartClone->set_Id(System::Guid::NewGuid().ToString(u"B"));
doc->get_CustomXmlParts()->Add(xmlPartClone);
ASSERT_EQ(2, doc->get_CustomXmlParts()->get_Count());
// Iterate through the collection and print the contents of each part.
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<CustomXmlPart>>> enumerator = doc->get_CustomXmlParts()->GetEnumerator();
int index = 0;
while (enumerator->MoveNext())
{
std::cout << "XML part index " << index << ", ID: " << enumerator->get_Current()->get_Id() << std::endl;
std::cout << "\tContent: " << System::Text::Encoding::get_UTF8()->GetString(enumerator->get_Current()->get_Data()) << std::endl;
index++;
}
}
// Use the "RemoveAt" method to remove the cloned part by index.
doc->get_CustomXmlParts()->RemoveAt(1);
ASSERT_EQ(1, doc->get_CustomXmlParts()->get_Count());
// Clone the XML parts collection, and then use the "Clear" method to remove all its elements at once.
SharedPtr<CustomXmlPartCollection> customXmlParts = doc->get_CustomXmlParts()->Clone();
customXmlParts->Clear();
// Create a structured document tag that will display our part's contents and insert it into the document body.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Block);
tag->get_XmlMapping()->SetMapping(xmlPart, u"/root[1]/text[1]", String::Empty);
doc->get_FirstSection()->get_Body()->AppendChild(tag);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.CustomXml.docx");

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Markup::StructuredDocumentTag::GetType ( ) const
overridevirtual

Reimplemented from Aspose::Words::CompositeNode.

◆ Is()

virtual bool Aspose::Words::Markup::StructuredDocumentTag::Is ( const System::TypeInfo target) const
overridevirtual

Reimplemented from Aspose::Words::CompositeNode.

◆ RemoveMoveRevisions()

void Aspose::Words::Markup::StructuredDocumentTag::RemoveMoveRevisions ( )
override

◆ RemoveSelfOnly()

void Aspose::Words::Markup::StructuredDocumentTag::RemoveSelfOnly ( )

Removes just this SDT node itself, but keeps the content of it inside the document tree.

Examples

Shows how to create a structured document tag in a plain text box and modify its appearance.

auto doc = MakeObject<Document>();
// Create a structured document tag that will contain plain text.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Inline);
// Set the title and color of the frame that appears when you mouse over the structured document tag in Microsoft Word.
tag->set_Title(u"My plain text");
// Set a tag for this structured document tag, which is obtainable
// as an XML element named "tag", with the string below in its "@val" attribute.
tag->set_Tag(u"MyPlainTextSDT");
// Every structured document tag has a random unique ID.
ASSERT_GT(tag->get_Id(), 0);
// Set the font for the text inside the structured document tag.
tag->get_ContentsFont()->set_Name(u"Arial");
// Set the font for the text at the end of the structured document tag.
// Any text that we type in the document body after moving out of the tag with arrow keys will use this font.
tag->get_EndCharacterFont()->set_Name(u"Arial Black");
// By default, this is false and pressing enter while inside a structured document tag does nothing.
// When set to true, our structured document tag can have multiple lines.
// Set the "Multiline" property to "false" to only allow the contents
// of this structured document tag to span a single line.
// Set the "Multiline" property to "true" to allow the tag to contain multiple lines of content.
tag->set_Multiline(true);
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertNode(tag);
// Insert a clone of our structured document tag in a new paragraph.
auto tagClone = System::DynamicCast<StructuredDocumentTag>(tag->Clone(true));
builder->InsertParagraph();
builder->InsertNode(tagClone);
// Use the "RemoveSelfOnly" method to remove a structured document tag, while keeping its contents in the document.
tagClone->RemoveSelfOnly();
doc->Save(ArtifactsDir + u"StructuredDocumentTag.PlainText.docx");

◆ set_BuildingBlockCategory()

void Aspose::Words::Markup::StructuredDocumentTag::set_BuildingBlockCategory ( const System::String value)

◆ set_BuildingBlockGallery()

void Aspose::Words::Markup::StructuredDocumentTag::set_BuildingBlockGallery ( const System::String value)

◆ set_CalendarType()

void Aspose::Words::Markup::StructuredDocumentTag::set_CalendarType ( Aspose::Words::Markup::SdtCalendarType  value)

◆ set_Checked()

void Aspose::Words::Markup::StructuredDocumentTag::set_Checked ( bool  value)

◆ set_Color()

void Aspose::Words::Markup::StructuredDocumentTag::set_Color ( System::Drawing::Color  value)

◆ set_DateDisplayFormat()

void Aspose::Words::Markup::StructuredDocumentTag::set_DateDisplayFormat ( const System::String value)

◆ set_DateDisplayLocale()

void Aspose::Words::Markup::StructuredDocumentTag::set_DateDisplayLocale ( int32_t  value)

◆ set_DateStorageFormat()

void Aspose::Words::Markup::StructuredDocumentTag::set_DateStorageFormat ( Aspose::Words::Markup::SdtDateStorageFormat  value)

◆ set_FullDate()

void Aspose::Words::Markup::StructuredDocumentTag::set_FullDate ( System::DateTime  value)

◆ set_IsShowingPlaceholderText()

void Aspose::Words::Markup::StructuredDocumentTag::set_IsShowingPlaceholderText ( bool  value)

◆ set_IsTemporary()

void Aspose::Words::Markup::StructuredDocumentTag::set_IsTemporary ( bool  value)

◆ set_LockContentControl()

void Aspose::Words::Markup::StructuredDocumentTag::set_LockContentControl ( bool  value)

◆ set_LockContents()

void Aspose::Words::Markup::StructuredDocumentTag::set_LockContents ( bool  value)

◆ set_Multiline()

void Aspose::Words::Markup::StructuredDocumentTag::set_Multiline ( bool  value)

◆ set_PlaceholderName()

void Aspose::Words::Markup::StructuredDocumentTag::set_PlaceholderName ( const System::String value)

◆ set_Style()

void Aspose::Words::Markup::StructuredDocumentTag::set_Style ( const System::SharedPtr< Aspose::Words::Style > &  value)

◆ set_StyleName()

void Aspose::Words::Markup::StructuredDocumentTag::set_StyleName ( const System::String value)

◆ set_Tag()

void Aspose::Words::Markup::StructuredDocumentTag::set_Tag ( const System::String value)

◆ set_Title()

void Aspose::Words::Markup::StructuredDocumentTag::set_Title ( const System::String value)

◆ SetCheckedSymbol()

void Aspose::Words::Markup::StructuredDocumentTag::SetCheckedSymbol ( int32_t  characterCode,
const System::String fontName 
)

Sets the symbol used to represent the checked state of a check box content control.

Accessing this method will only work for Checkbox SDT types.

For all other SDT types exception will occur.

Parameters
characterCodeThe character code for the specified symbol.
fontNameThe name of the font that contains the symbol.
Examples

Show how to create a structured document tag in the form of a check box.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto sdtCheckBox = MakeObject<StructuredDocumentTag>(doc, SdtType::Checkbox, MarkupLevel::Inline);
sdtCheckBox->set_Checked(true);
// We can set the symbols used to represent the checked/unchecked state of a checkbox content control.
sdtCheckBox->SetCheckedSymbol(0x00A9, u"Times New Roman");
sdtCheckBox->SetUncheckedSymbol(0x00AE, u"Times New Roman");
builder->InsertNode(sdtCheckBox);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.CheckBox.docx");

◆ SetUncheckedSymbol()

void Aspose::Words::Markup::StructuredDocumentTag::SetUncheckedSymbol ( int32_t  characterCode,
const System::String fontName 
)

Sets the symbol used to represent the unchecked state of a check box content control.

Accessing this method will only work for Checkbox SDT types.

For all other SDT types exception will occur.

Parameters
characterCodeThe character code for the specified symbol.
fontNameThe name of the font that contains the symbol.
Examples

Show how to create a structured document tag in the form of a check box.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto sdtCheckBox = MakeObject<StructuredDocumentTag>(doc, SdtType::Checkbox, MarkupLevel::Inline);
sdtCheckBox->set_Checked(true);
// We can set the symbols used to represent the checked/unchecked state of a checkbox content control.
sdtCheckBox->SetCheckedSymbol(0x00A9, u"Times New Roman");
sdtCheckBox->SetUncheckedSymbol(0x00AE, u"Times New Roman");
builder->InsertNode(sdtCheckBox);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.CheckBox.docx");

◆ Type()

static const System::TypeInfo& Aspose::Words::Markup::StructuredDocumentTag::Type ( )
static