Aspose::Words::Fields::FieldSeq::set_ResetHeadingLevel method
Contents
[
Hide
]FieldSeq::set_ResetHeadingLevel method
Sets an integer number representing a heading level to reset the sequence number to. Returns -1 if the number is absent.
void Aspose::Words::Fields::FieldSeq::set_ResetHeadingLevel(const System::String & value)
Examples
Shows create numbering using SEQ fields.
auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
// SEQ fields display a count that increments at each SEQ field.
// These fields also maintain separate counts for each unique named sequence
// identified by the SEQ field's "SequenceIdentifier" property.
// Insert a SEQ field that will display the current count value of "MySequence",
// after using the "ResetNumber" property to set it to 100.
builder->Write(u"#");
auto fieldSeq = System::ExplicitCast<Aspose::Words::Fields::FieldSeq>(builder->InsertField(FieldType::FieldSequence, true));
fieldSeq->set_SequenceIdentifier(u"MySequence");
fieldSeq->set_ResetNumber(u"100");
fieldSeq->Update();
ASSERT_EQ(fieldSeq->GetFieldCode(), u" SEQ MySequence \\r 100");
ASSERT_EQ(fieldSeq->get_Result(), u"100");
// Display the next number in this sequence with another SEQ field.
builder->Write(u", #");
fieldSeq = System::ExplicitCast<Aspose::Words::Fields::FieldSeq>(builder->InsertField(FieldType::FieldSequence, true));
fieldSeq->set_SequenceIdentifier(u"MySequence");
fieldSeq->Update();
ASSERT_EQ(fieldSeq->get_Result(), u"101");
// Insert a level 1 heading.
builder->InsertBreak(BreakType::ParagraphBreak);
builder->get_ParagraphFormat()->set_Style(doc->get_Styles()->idx_get(u"Heading 1"));
builder->Writeln(u"This level 1 heading will reset MySequence to 1");
builder->get_ParagraphFormat()->set_Style(doc->get_Styles()->idx_get(u"Normal"));
// Insert another SEQ field from the same sequence and configure it to reset the count at every heading with 1.
builder->Write(u"\n#");
fieldSeq = System::ExplicitCast<Aspose::Words::Fields::FieldSeq>(builder->InsertField(FieldType::FieldSequence, true));
fieldSeq->set_SequenceIdentifier(u"MySequence");
fieldSeq->set_ResetHeadingLevel(u"1");
fieldSeq->Update();
// The above heading is a level 1 heading, so the count for this sequence is reset to 1.
ASSERT_EQ(fieldSeq->GetFieldCode(), u" SEQ MySequence \\s 1");
ASSERT_EQ(fieldSeq->get_Result(), u"1");
// Move to the next number of this sequence.
builder->Write(u", #");
fieldSeq = System::ExplicitCast<Aspose::Words::Fields::FieldSeq>(builder->InsertField(FieldType::FieldSequence, true));
fieldSeq->set_SequenceIdentifier(u"MySequence");
fieldSeq->set_InsertNextNumber(true);
fieldSeq->Update();
ASSERT_EQ(fieldSeq->GetFieldCode(), u" SEQ MySequence \\n");
ASSERT_EQ(fieldSeq->get_Result(), u"2");
doc->UpdateFields();
doc->Save(get_ArtifactsDir() + u"Field.SEQ.ResetNumbering.docx");
See Also
- Class FieldSeq
- Namespace Aspose::Words::Fields
- Library Aspose.Words for C++