MasterSlideCollection

Inheritance: java.lang.Object, com.aspose.slides.DomObject

All Implemented Interfaces: com.aspose.slides.IMasterSlideCollection

public final class MasterSlideCollection extends DomObject<Presentation> implements IMasterSlideCollection

Represents a collection of master slides.

Methods

MethodDescription
size()Gets the number of elements actually contained in the collection.
get_Item(int index)Gets the element at the specified index.
remove(IMasterSlide value)Removes the first occurrence of a specific object from the collection.
removeAt(int index)Removes the element at the specified index of the collection.
removeUnused(boolean ignorePreserveField)Removes unused master slides.
addClone(IMasterSlide sourceMaster)Adds a copy of a specified master slide to the end of the collection.
insertClone(int index, IMasterSlide sourceMaster)Inserts a copy of a specified master slide to specified position of the collection.
copyTo(System.Array array, int index)Copies all elements from the collection to the specified array.
isSynchronized()Returns a value indicating whether access to the collection is synchronized (thread-safe).
getSyncRoot()Returns a synchronization root.
iterator()Returns an enumerator that iterates through the collection.
iteratorJava()Returns a java iterator for the entire collection.

size()

public final int size()

Gets the number of elements actually contained in the collection. Read-only int.

Returns: int

get_Item(int index)

public final IMasterSlide get_Item(int index)

Gets the element at the specified index. Read-only MasterSlide.

Parameters:

ParameterTypeDescription
indexint

Returns: IMasterSlide

remove(IMasterSlide value)

public final void remove(IMasterSlide value)

Removes the first occurrence of a specific object from the collection.

Parameters:

ParameterTypeDescription
valueIMasterSlideThe master slide to remove from the collection.

removeAt(int index)

public final void removeAt(int index)

Removes the element at the specified index of the collection.

Parameters:

ParameterTypeDescription
indexintThe zero-based index of the element to remove.

To avoid throwing of the PptxEditException check master’s HasDependingSlides property before. |

removeUnused(boolean ignorePreserveField)

public final void removeUnused(boolean ignorePreserveField)

Removes unused master slides.

Parameters:

ParameterTypeDescription
ignorePreserveFieldbooleanDetermines, whether this method should remove unused master even if its (MasterSlide.getPreserve/MasterSlide.setPreserve(boolean)) property is set to true.

addClone(IMasterSlide sourceMaster)

public final IMasterSlide addClone(IMasterSlide sourceMaster)

Adds a copy of a specified master slide to the end of the collection. Linked layout slides will be copied too.

Parameters:

ParameterTypeDescription
sourceMasterIMasterSlideSlide to clone.

Returns: IMasterSlide - Added slide.

insertClone(int index, IMasterSlide sourceMaster)

public final IMasterSlide insertClone(int index, IMasterSlide sourceMaster)

Inserts a copy of a specified master slide to specified position of the collection. Linked layout slides will be copied too.


The following example shows how to clone master slide in another PowerPoint Presentation.
 
 // Instantiate Presentation class to load the source presentation file
 Presentation srcPres = new Presentation("CloneToAnotherPresentationWithMaster.pptx");
 try {
     // Instantiate Presentation class for destination presentation (where slide is to be cloned)
     Presentation destPres = new Presentation();
     try {
         // Instantiate ISlide from the collection of slides in source presentation along with
         // Master slide
         ISlide SourceSlide = srcPres.getSlides().get_Item(0);
         IMasterSlide SourceMaster = SourceSlide.getLayoutSlide().getMasterSlide();
         // Get Master Slides of destination presentation
         IMasterSlideCollection masters = destPres.getMasters();
         // Clone the desired master slide from the source presentation to the collection of masters in the
         // Destination presentation
         IMasterSlide iSlide = masters.addClone(SourceMaster);
         // Collection of slides in the destination presentation
         ISlideCollection slds = destPres.getSlides();
         // Clone source slide to destination slides collection.
         slds.addClone(SourceSlide, iSlide, true);
         // Save the destination presentation to disk
         destPres.save("CloneToAnotherPresentationWithMaster_out.pptx", SaveFormat.Pptx);
     } finally {
         if (destPres != null) destPres.dispose();
     }
 } finally {
     if (srcPres != null) srcPres.dispose();
 }

Parameters:

ParameterTypeDescription
indexintIndex of new slide.
sourceMasterIMasterSlideSlide to clone.

Returns: IMasterSlide - Inserted master slide.

copyTo(System.Array array, int index)

public final void copyTo(System.Array array, int index)

Copies all elements from the collection to the specified array.

Parameters:

ParameterTypeDescription
arraycom.aspose.ms.System.ArrayTarget array.
indexintStarting index in the target array.

isSynchronized()

public final boolean isSynchronized()

Returns a value indicating whether access to the collection is synchronized (thread-safe). Read-only boolean.

Returns: boolean

getSyncRoot()

public final Object getSyncRoot()

Returns a synchronization root. Read-only Object.

Returns: java.lang.Object

iterator()

public final System.Collections.Generic.IGenericEnumerator<IMasterSlide> iterator()

Returns an enumerator that iterates through the collection.

Returns: com.aspose.ms.System.Collections.Generic.IGenericEnumerator<com.aspose.slides.IMasterSlide> - A IGenericEnumerator that can be used to iterate through the collection.

iteratorJava()

public final System.Collections.Generic.IGenericEnumerator<IMasterSlide> iteratorJava()

Returns a java iterator for the entire collection.

Returns: com.aspose.ms.System.Collections.Generic.IGenericEnumerator<com.aspose.slides.IMasterSlide> - An java.util.Iterator for the entire collection.