Aspose::Words::Markup::CustomPartCollection class
Contents
[
Hide
]CustomPartCollection class
Represents a collection of CustomPart objects. To learn more, visit the Structured Document Tags or Content Control documentation article.
class CustomPartCollection : public System::Collections::Generic::IEnumerable<System::SharedPtr<Aspose::Words::Markup::CustomPart>>
Methods
Method | Description |
---|---|
Add(const System::SharedPtr<Aspose::Words::Markup::CustomPart>&) | Adds an item to the collection. |
begin() | |
begin() const | |
cbegin() const | |
cend() const | |
Clear() | Removes all elements from the collection. |
Clone() | Makes a deep copy of this collection and its items. |
CustomPartCollection() | |
end() | |
end() const | |
get_Count() | Gets the number of elements contained in the collection. |
GetEnumerator() override | Returns an enumerator object that can be used to iterate over all items in the collection. |
GetType() const override | |
idx_get(int32_t) | Gets or sets an item at the specified index. |
idx_set(int32_t, const System::SharedPtr<Aspose::Words::Markup::CustomPart>&) | Gets or sets an item at the specified index. |
Is(const System::TypeInfo&) const override | |
RemoveAt(int32_t) | Removes an item at the specified index. |
static Type() | |
virtualizeBeginConstIterator() const override | |
virtualizeBeginIterator() override | |
virtualizeEndConstIterator() const override | |
virtualizeEndIterator() override |
Typedefs
Typedef | Description |
---|---|
const_iterator | |
iterator | |
iterator_holder_type | |
virtualized_iterator | |
virtualized_iterator_element |
Remarks
You do not normally need to create instances of this class. You access custom parts related to the OOXML package via the PackageCustomParts property.
Examples
Shows how to access a document’s arbitrary custom parts collection.
auto doc = System::MakeObject<Aspose::Words::Document>(get_MyDir() + u"Custom parts OOXML package.docx");
ASSERT_EQ(2, doc->get_PackageCustomParts()->get_Count());
// Clone the second part, then add the clone to the collection.
System::SharedPtr<Aspose::Words::Markup::CustomPart> clonedPart = doc->get_PackageCustomParts()->idx_get(1)->Clone();
doc->get_PackageCustomParts()->Add(clonedPart);
ASSERT_EQ(3, doc->get_PackageCustomParts()->get_Count());
// Enumerate over the collection and print every part.
{
System::SharedPtr<System::Collections::Generic::IEnumerator<System::SharedPtr<Aspose::Words::Markup::CustomPart>>> enumerator = doc->get_PackageCustomParts()->GetEnumerator();
int32_t index = 0;
while (enumerator->MoveNext())
{
std::cout << System::String::Format(u"Part index {0}:", index) << std::endl;
std::cout << System::String::Format(u"\tName:\t\t\t\t{0}", enumerator->get_Current()->get_Name()) << std::endl;
std::cout << System::String::Format(u"\tContent type:\t\t{0}", enumerator->get_Current()->get_ContentType()) << std::endl;
std::cout << System::String::Format(u"\tRelationship type:\t{0}", enumerator->get_Current()->get_RelationshipType()) << std::endl;
std::cout << (enumerator->get_Current()->get_IsExternal() ? u"\tSourced from outside the document" : System::String::Format(u"\tStored within the document, length: {0} bytes", enumerator->get_Current()->get_Data()->get_Length())) << std::endl;
index++;
}
}
// We can remove elements from this collection individually, or all at once.
doc->get_PackageCustomParts()->RemoveAt(2);
ASSERT_EQ(2, doc->get_PackageCustomParts()->get_Count());
doc->get_PackageCustomParts()->Clear();
ASSERT_EQ(0, doc->get_PackageCustomParts()->get_Count());
See Also
- Namespace Aspose::Words::Markup
- Library Aspose.Words for C++