Aspose::Words::BorderCollection::get_Count method
Contents
[
Hide
]BorderCollection::get_Count method
Gets the number of borders in the collection.
int32_t Aspose::Words::BorderCollection::get_Count()
Examples
Shows how border collections can share elements.
auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
builder->Writeln(u"Paragraph 1.");
builder->Write(u"Paragraph 2.");
// Since we used the same border configuration while creating
// these paragraphs, their border collections share the same elements.
System::SharedPtr<Aspose::Words::BorderCollection> firstParagraphBorders = doc->get_FirstSection()->get_Body()->get_FirstParagraph()->get_ParagraphFormat()->get_Borders();
System::SharedPtr<Aspose::Words::BorderCollection> secondParagraphBorders = builder->get_CurrentParagraph()->get_ParagraphFormat()->get_Borders();
for (int32_t i = 0; i < firstParagraphBorders->get_Count(); i++)
{
ASSERT_TRUE(System::ObjectExt::Equals(firstParagraphBorders->idx_get(i), secondParagraphBorders->idx_get(i)));
ASSERT_EQ(System::ObjectExt::GetHashCode(firstParagraphBorders->idx_get(i)), System::ObjectExt::GetHashCode(secondParagraphBorders->idx_get(i)));
ASSERT_FALSE(firstParagraphBorders->idx_get(i)->get_IsVisible());
}
for (auto&& border : System::IterateOver(secondParagraphBorders))
{
border->set_LineStyle(Aspose::Words::LineStyle::DotDash);
}
// After changing the line style of the borders in just the second paragraph,
// the border collections no longer share the same elements.
for (int32_t i = 0; i < firstParagraphBorders->get_Count(); i++)
{
ASSERT_FALSE(System::ObjectExt::Equals(firstParagraphBorders->idx_get(i), secondParagraphBorders->idx_get(i)));
ASSERT_NE(System::ObjectExt::GetHashCode(firstParagraphBorders->idx_get(i)), System::ObjectExt::GetHashCode(secondParagraphBorders->idx_get(i)));
// Changing the appearance of an empty border makes it visible.
ASSERT_TRUE(secondParagraphBorders->idx_get(i)->get_IsVisible());
}
doc->Save(get_ArtifactsDir() + u"Border.SharedElements.docx");
See Also
- Class BorderCollection
- Namespace Aspose::Words
- Library Aspose.Words for C++