Aspose::Words::JoinRunsOptions class
Contents
[
Hide
]JoinRunsOptions class
Provides configuration flags for the join runs operation.
class JoinRunsOptions : public System::Object
Methods
| Method | Description |
|---|---|
| JoinRunsOptions() | |
| get_IgnoreInsignificant() const | True indicates that the insignificant attributes of all runs will be ignored when joining runs with same formatting. |
| get_IgnoreRedundant() const | True indicates that the redundant attributes of all runs will be ignored when joining runs with same formatting. |
| get_IgnoreSpacing() const | True indicates that the spacing attributes of all runs will be ignored when joining runs with same formatting. |
| set_IgnoreInsignificant(bool) | True indicates that the insignificant attributes of all runs will be ignored when joining runs with same formatting. |
| set_IgnoreRedundant(bool) | True indicates that the redundant attributes of all runs will be ignored when joining runs with same formatting. |
| set_IgnoreSpacing(bool) | True indicates that the spacing attributes of all runs will be ignored when joining runs with same formatting. |
Examples
Shows how to join runs with the same formatting while ignoring redundant and insignificant attributes.
auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
// Create runs with identical visible formatting but some internal differences.
builder->get_Font()->set_Name(u"Arial");
builder->get_Font()->set_Size(12);
builder->Write(u"Hello ");
builder->Write(u"world");
// Verify runs before join.
ASSERT_EQ(doc->get_FirstSection()->get_Body()->get_FirstParagraph()->get_Runs()->get_Count(), 2);
ASSERT_EQ(doc->get_FirstSection()->get_Body()->get_FirstParagraph()->get_Runs()->idx_get(0)->get_Text(), u"Hello ");
ASSERT_EQ(doc->get_FirstSection()->get_Body()->get_FirstParagraph()->get_Runs()->idx_get(1)->get_Text(), u"world");
// Configure options to ignore redundant and insignificant attributes during join.
auto options = System::MakeObject<Aspose::Words::JoinRunsOptions>();
options->set_IgnoreRedundant(true);
// Ignore redundant run properties that don't affect appearance.
options->set_IgnoreInsignificant(true);
// Ignore insignificant differences like whitespace-only runs.
// Join runs that have the same visible formatting using the extended options.
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->JoinRunsWithSameFormatting(options);
// Verify that runs were successfully joined.
ASSERT_EQ(doc->get_FirstSection()->get_Body()->get_FirstParagraph()->get_Runs()->get_Count(), 1);
ASSERT_EQ(doc->get_FirstSection()->get_Body()->get_FirstParagraph()->get_Runs()->idx_get(0)->get_Text(), u"Hello world");
doc->Save(get_ArtifactsDir() + u"Paragraph.JoinRunsWithSameFormattingWithOptions.docx");
See Also
- Namespace Aspose::Words
- Library Aspose.Words for C++