Shows how to trim whitespace when loading plaintext documents.
String textDoc = String(u" Line 1 \n") + u" Line 2 \n" + u" Line 3 ";
auto loadOptions = MakeObject<TxtLoadOptions>();
loadOptions->set_LeadingSpacesOptions(txtLeadingSpacesOptions);
loadOptions->set_TrailingSpacesOptions(txtTrailingSpacesOptions);
SharedPtr<ParagraphCollection> paragraphs = doc->get_FirstSection()->get_Body()->get_Paragraphs();
switch (txtLeadingSpacesOptions)
{
ASPOSE_ASSERT_EQ(37.8, paragraphs->idx_get(0)->get_ParagraphFormat()->get_FirstLineIndent());
ASPOSE_ASSERT_EQ(25.2, paragraphs->idx_get(1)->get_ParagraphFormat()->get_FirstLineIndent());
ASPOSE_ASSERT_EQ(6.3, paragraphs->idx_get(2)->get_ParagraphFormat()->get_FirstLineIndent());
ASSERT_TRUE(paragraphs->idx_get(0)->GetText().StartsWith(u"Line 1"));
ASSERT_TRUE(paragraphs->idx_get(1)->GetText().StartsWith(u"Line 2"));
ASSERT_TRUE(paragraphs->idx_get(2)->GetText().StartsWith(u"Line 3"));
break;
ASSERT_TRUE(paragraphs->LINQ_All([](SharedPtr<Node> p)
{ return (System::DynamicCast<Paragraph>(p))->get_ParagraphFormat()->get_FirstLineIndent() == 0.0; }));
ASSERT_TRUE(paragraphs->idx_get(0)->GetText().StartsWith(u" Line 1"));
ASSERT_TRUE(paragraphs->idx_get(1)->GetText().StartsWith(u" Line 2"));
ASSERT_TRUE(paragraphs->idx_get(2)->GetText().StartsWith(u" Line 3"));
break;
ASSERT_TRUE(paragraphs->LINQ_All([](SharedPtr<Node> p)
{ return (System::DynamicCast<Paragraph>(p))->get_ParagraphFormat()->get_FirstLineIndent() == 0.0; }));
ASSERT_TRUE(paragraphs->idx_get(0)->GetText().StartsWith(u"Line 1"));
ASSERT_TRUE(paragraphs->idx_get(1)->GetText().StartsWith(u"Line 2"));
ASSERT_TRUE(paragraphs->idx_get(2)->GetText().StartsWith(u"Line 3"));
break;
}
switch (txtTrailingSpacesOptions)
{
ASSERT_TRUE(paragraphs->idx_get(0)->GetText().EndsWith(u"Line 1 \r"));
ASSERT_TRUE(paragraphs->idx_get(1)->GetText().EndsWith(u"Line 2 \r"));
ASSERT_TRUE(paragraphs->idx_get(2)->GetText().EndsWith(u"Line 3 \f"));
break;
ASSERT_TRUE(paragraphs->idx_get(0)->GetText().EndsWith(u"Line 1\r"));
ASSERT_TRUE(paragraphs->idx_get(1)->GetText().EndsWith(u"Line 2\r"));
ASSERT_TRUE(paragraphs->idx_get(2)->GetText().EndsWith(u"Line 3\f"));
break;
}