com.aspose.slides

Interfaces

Classes

Exceptions

com.aspose.slides

Class SlideCollection

  • java.lang.Object
    • com.aspose.slides.SlideCollection
  • All Implemented Interfaces:
    com.aspose.ms.System.Collections.Generic.IGenericEnumerable<ISlide>, com.aspose.ms.System.Collections.ICollection<ISlide>, com.aspose.ms.System.Collections.IEnumerable<ISlide>, IGenericCollection<ISlide>, ISlideCollection, java.lang.Iterable<ISlide>


    public final class SlideCollection
    extends java.lang.Object
    implements ISlideCollection

    Represents a collection of a slides.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      ISlide addClone(ISlide sourceSlide)
      Adds a copy of a specified slide to the end of the collection.
      ISlide addClone(ISlide sourceSlide, ILayoutSlide destLayout)
      Adds a copy of a specified slide to the end of the collection.
      ISlide addClone(ISlide sourceSlide, IMasterSlide destMaster, boolean allowCloneMissingLayout)
      Adds a copy of a specified source slide to the end of the collection.
      ISlide addClone(ISlide sourceSlide, ISection section)
      Adds a copy of a specified slide to the end of the specified section.
      ISlide addEmptySlide(ILayoutSlide layout)
      Adds a new empty slide to the end of the collection.
      ISlide[] addFromHtml(java.io.InputStream htmlStream)
      Creates slides from HTML text and adds them to the end of the collection.
      ISlide[] addFromHtml(java.io.InputStream htmlStream, IExternalResourceResolver resolver, java.lang.String uri)
      Creates slides from HTML text and adds them to the end of the collection.
      ISlide[] addFromHtml(java.lang.String htmlText)
      Creates slides from HTML text and adds them to the end of the collection.
      ISlide[] addFromHtml(java.lang.String htmlText, IExternalResourceResolver resolver, java.lang.String uri)
      Creates slides from HTML text and adds them to the end of the collection.
      void copyTo(com.aspose.ms.System.Array array, int index)
      Copies all elements from the collection to the specified array.
      ISlide get_Item(int index)
      Gets the element at the specified index.
      com.aspose.slides.IDOMObject getParent_Immediate()
      Returns Parent_Immediate object.
      java.lang.Object getSyncRoot()
      Returns a synchronization root.
      int indexOf(ISlide slide)
      Returns an index of the specified slide in the collection.
      ISlide insertClone(int index, ISlide sourceSlide)
      Inserts a copy of a specified slide to specified position of the collection.
      ISlide insertClone(int index, ISlide sourceSlide, ILayoutSlide destLayout)
      Inserts a copy of a specified slide to specified position of the collection.
      ISlide insertClone(int index, ISlide sourceSlide, IMasterSlide destMaster, boolean allowCloneMissingLayout)
      Inserts a copy of a specified source slide to specified position of the collection.
      ISlide insertEmptySlide(int index, ILayoutSlide layout)
      Inserts a copy of a specified slide to specified position of the collection.
      ISlide[] insertFromHtml(int index, java.io.InputStream htmlStream)
      Creates slides from HTML text and inserts them to the collection at the specified position.
      ISlide[] insertFromHtml(int index, java.io.InputStream htmlStream, IExternalResourceResolver resolver, java.lang.String uri)
      Creates slides from HTML text and inserts them to the collection at the specified position.
      ISlide[] insertFromHtml(int index, java.lang.String htmlText)
      Creates slides from HTML text and inserts them to the collection at the specified position.
      ISlide[] insertFromHtml(int index, java.lang.String htmlText, IExternalResourceResolver resolver, java.lang.String uri)
      Creates slides from HTML text and inserts them to the collection at the specified position.
      boolean isSynchronized()
      Returns a value indicating whether access to the collection is synchronized (thread-safe).
      com.aspose.ms.System.Collections.Generic.IGenericEnumerator<ISlide> iterator()
      Returns an enumerator that iterates through the collection.
      void remove(ISlide value)
      Removes the first occurrence of a specific object from the collection.
      void removeAt(int index)
      Removes the element at the specified index of the collection.
      void reorder(int index, ISlide... slides)
      Moves slides from the collection to the specified position.
      void reorder(int index, ISlide slide)
      Moves slide from the collection to the specified position.
      int size()
      Gets the number of elements actually contained in the collection.
      ISlide[] toArray()
      Creates and returns an array with all slides in it.
      ISlide[] toArray(int startIndex, int count)
      Creates and returns an array with all slides from the specified range in it.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Method Detail

      • size

        public final int size()

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

        Specified by:
        size in interface com.aspose.ms.System.Collections.ICollection<ISlide>
      • addClone

        public final ISlide addClone(ISlide sourceSlide,
                                     ISection section)

        Adds a copy of a specified slide to the end of the specified section.


         
         IPresentation presentation = new Presentation();
         try
         {
             presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 200, 50, 300, 100);
             presentation.getSections().addSection("Section 1", presentation.getSlides().get_Item(0));
             
             ISection section2 = presentation.getSections().appendEmptySection("Section 2");
             presentation.getSlides().addClone(presentation.getSlides().get_Item(0), section2);
             
             // Now the second section contains a copy of the first slide.
         } finally {
             if (presentation != null) presentation.dispose();
         }
         
        Specified by:
        addClone in interface ISlideCollection
        Parameters:
        sourceSlide - Slide to clone.
        section - Section for a new slide.
        Returns:
        New slide.
        Throws:
        com.aspose.ms.System.ArgumentNullException - When sourceSlide or section parameter is null.
        PptxEditException - When section parameter contains wrong or invalid value.
      • insertClone

        public final ISlide insertClone(int index,
                                        ISlide sourceSlide)

        Inserts a copy of a specified slide to specified position of the collection.

        Specified by:
        insertClone in interface ISlideCollection
        Parameters:
        index - Index of new slide.
        sourceSlide - Slide to clone.


        When cloning a slide between different presentations slide's master can be cloned too. Internal registry is used to track automatically cloned masters to prevent creation of multiple clones of the same master slide. Manual cloning of master slides will be neither prevented nor registered. If you need more control over cloning process use insertClone(int,ISlide,ILayoutSlide) or insertClone(int,ISlide,IMasterSlide,boolean) for cloning slides and IMasterSlideCollection.addClone(IMasterSlide) for cloning masters.
        Returns:
        Inserted slide.
      • addEmptySlide

        public final ISlide addEmptySlide(ILayoutSlide layout)

        Adds a new empty slide to the end of the collection.

        Specified by:
        addEmptySlide in interface ISlideCollection
        Parameters:
        layout - Layout for a slide.
        Returns:
        Added slide.
      • insertEmptySlide

        public final ISlide insertEmptySlide(int index,
                                             ILayoutSlide layout)

        Inserts a copy of a specified slide to specified position of the collection.

        Specified by:
        insertEmptySlide in interface ISlideCollection
        Parameters:
        index - Index of a new slide.
        layout - Layout for a slide.
        Returns:
        Inserted slide.
      • addClone

        public final ISlide addClone(ISlide sourceSlide,
                                     ILayoutSlide destLayout)

        Adds a copy of a specified slide to the end of the collection.

        Specified by:
        addClone in interface ISlideCollection
        Parameters:
        sourceSlide - Slide to clone.
        destLayout - Layout slide for a new slide.
        Returns:
        New slide.
      • insertClone

        public final ISlide insertClone(int index,
                                        ISlide sourceSlide,
                                        ILayoutSlide destLayout)

        Inserts a copy of a specified slide to specified position of the collection.

        Specified by:
        insertClone in interface ISlideCollection
        Parameters:
        index - Index of new slide.
        sourceSlide - Slide to clone.
        destLayout - Layout slide for a new slide.
        Returns:
        Inserted slide.
      • addClone

        public final ISlide addClone(ISlide sourceSlide,
                                     IMasterSlide destMaster,
                                     boolean allowCloneMissingLayout)

        Adds a copy of a specified source slide to the end of the collection. Appropriate layout will be selected automatically from the specified master (appropriate layout is the layout with the same Type or Name as of layout of the source slide). If there is no appropriate layout then layout of the source slide will be cloned (if allowCloneMissingLayout is true) or PptxEditException will be thrown (if allowCloneMissingLayout is false).

        Specified by:
        addClone in interface ISlideCollection
        Parameters:
        sourceSlide - Slide to clone.
        destMaster - Master slide for a new slide.
        allowCloneMissingLayout - If there is no appropriate layout in specified master then layout of the source slide will be cloned (if allowCloneMissingLayout is true) or PptxEditException will be thrown (if allowCloneMissingLayout is false).
        Returns:
        New slide.
        Throws:
        PptxEditException - Thrown if there is no appropriate layout in specified master and allowCloneMissingLayout is false.
      • insertClone

        public final ISlide insertClone(int index,
                                        ISlide sourceSlide,
                                        IMasterSlide destMaster,
                                        boolean allowCloneMissingLayout)

        Inserts a copy of a specified source slide to specified position of the collection. Appropriate layout will be selected automatically from the specified master (appropriate layout is the layout with the same Type or Name as of layout of the source slide). If there is no appropriate layout then layout of the source slide will be cloned (if allowCloneMissingLayout is true) or PptxEditException will be thrown (if allowCloneMissingLayout is false).

        Specified by:
        insertClone in interface ISlideCollection
        Parameters:
        index - Index of new slide.
        sourceSlide - Slide to clone.
        destMaster - Master slide for a new slide.
        allowCloneMissingLayout - If there is no appropriate layout in specified master then layout of the source slide will be cloned (if allowCloneMissingLayout is true) or PptxEditException will be thrown (if allowCloneMissingLayout is false).
        Returns:
        Inserted slide.
        Throws:
        PptxEditException - Thrown if there is no appropriate layout in specified master and allowCloneMissingLayout is false.
      • remove

        public final void remove(ISlide value)

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

        Specified by:
        remove in interface ISlideCollection
        Parameters:
        value - The slide to remove from the collection.
      • removeAt

        public final void removeAt(int index)

        Removes the element at the specified index of the collection.

        Specified by:
        removeAt in interface ISlideCollection
        Parameters:
        index - The zero-based index of the element to remove.
        Throws:
        com.aspose.ms.System.ArgumentOutOfRangeException - When index parameter contains wrong section number.
      • iterator

        public final com.aspose.ms.System.Collections.Generic.IGenericEnumerator<ISlide> iterator()

        Returns an enumerator that iterates through the collection.

        Specified by:
        iterator in interface com.aspose.ms.System.Collections.Generic.IGenericEnumerable<ISlide>
        Specified by:
        iterator in interface com.aspose.ms.System.Collections.IEnumerable<ISlide>
        Specified by:
        iterator in interface java.lang.Iterable<ISlide>
        Returns:
        A System.Collections.Generic.IEnumerator`1 that can be used to iterate through the collection.
      • toArray

        public final ISlide[] toArray()

        Creates and returns an array with all slides in it.

        Specified by:
        toArray in interface ISlideCollection
        Returns:
        Array of Slide
      • toArray

        public final ISlide[] toArray(int startIndex,
                                      int count)

        Creates and returns an array with all slides from the specified range in it.

        Specified by:
        toArray in interface ISlideCollection
        Parameters:
        startIndex - An index of a first slide to add.
        count - A number of slides to add.
        Returns:
        Array of Slide
      • reorder

        public final void reorder(int index,
                                  ISlide slide)

        Moves slide from the collection to the specified position.

        Specified by:
        reorder in interface ISlideCollection
        Parameters:
        index - Target index.
        slide - Slide to move.
      • reorder

        public final void reorder(int index,
                                  ISlide... slides)

        Moves slides from the collection to the specified position. Slides will be placed starting from index in order they appear in list.

        Specified by:
        reorder in interface ISlideCollection
        Parameters:
        index - Target index.
        slides - Slides to move.
      • indexOf

        public final int indexOf(ISlide slide)

        Returns an index of the specified slide in the collection.

        Specified by:
        indexOf in interface ISlideCollection
        Parameters:
        slide - Slide to find.
        Returns:
        Index of a slide or -1 if slide not from this collection.
      • addFromHtml

        public final ISlide[] addFromHtml(java.lang.String htmlText,
                                          IExternalResourceResolver resolver,
                                          java.lang.String uri)

        Creates slides from HTML text and adds them to the end of the collection.

        Specified by:
        addFromHtml in interface ISlideCollection
        Parameters:
        htmlText - Html to add.
        resolver - A callback object used to fetch external objects. If this parameter is null all external objects will be ignored.
        uri - An URI of the specified HTML. Used to resolve relative links.
        Returns:
        Added slides.
      • addFromHtml

        public final ISlide[] addFromHtml(java.lang.String htmlText)

        Creates slides from HTML text and adds them to the end of the collection.

        Specified by:
        addFromHtml in interface ISlideCollection
        Parameters:
        htmlText - Html to add.
        Returns:
        Added slides
      • addFromHtml

        public final ISlide[] addFromHtml(java.io.InputStream htmlStream,
                                          IExternalResourceResolver resolver,
                                          java.lang.String uri)

        Creates slides from HTML text and adds them to the end of the collection.

        Specified by:
        addFromHtml in interface ISlideCollection
        Parameters:
        htmlStream - A Stream object which will be used as a source of a HTML file.
        resolver - A callback object used to fetch external objects. If this parameter is null all external objects will be ignored.
        uri - An URI of the specified HTML. Used to resolve relative links.
        Returns:
        Added slides.
      • addFromHtml

        public final ISlide[] addFromHtml(java.io.InputStream htmlStream)

        Creates slides from HTML text and adds them to the end of the collection.

        Specified by:
        addFromHtml in interface ISlideCollection
        Parameters:
        htmlStream - A Stream object which will be used as a source of a HTML file.
        Returns:
        Added slides
      • insertFromHtml

        public final ISlide[] insertFromHtml(int index,
                                             java.lang.String htmlText,
                                             IExternalResourceResolver resolver,
                                             java.lang.String uri)

        Creates slides from HTML text and inserts them to the collection at the specified position.

        Specified by:
        insertFromHtml in interface ISlideCollection
        Parameters:
        index - Position to insert.
        htmlText - Html to add.
        resolver - A callback object used to fetch external objects. If this parameter is null all external objects will be ignored.
        uri - An URI of the specified HTML. Used to resolve relative links.
        Returns:
        Added slides.
      • insertFromHtml

        public final ISlide[] insertFromHtml(int index,
                                             java.lang.String htmlText)

        Creates slides from HTML text and inserts them to the collection at the specified position.

        Specified by:
        insertFromHtml in interface ISlideCollection
        Parameters:
        index - Position to insert.
        htmlText - Html to add.
        Returns:
        Added slides
      • insertFromHtml

        public final ISlide[] insertFromHtml(int index,
                                             java.io.InputStream htmlStream,
                                             IExternalResourceResolver resolver,
                                             java.lang.String uri)

        Creates slides from HTML text and inserts them to the collection at the specified position.

        Specified by:
        insertFromHtml in interface ISlideCollection
        Parameters:
        index - Position to insert.
        htmlStream - A Stream object which will be used as a source of a HTML file.
        resolver - A callback object used to fetch external objects. If this parameter is null all external objects will be ignored.
        uri - An URI of the specified HTML. Used to resolve relative links.
        Returns:
        Added slides.
      • insertFromHtml

        public final ISlide[] insertFromHtml(int index,
                                             java.io.InputStream htmlStream)

        Creates slides from HTML text and inserts them to the collection at the specified position.

        Specified by:
        insertFromHtml in interface ISlideCollection
        Parameters:
        index - Position to insert.
        htmlStream - A Stream object which will be used as a source of a HTML file.
        Returns:
        Added slides
      • copyTo

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

        Copies all elements from the collection to the specified array.

        Specified by:
        copyTo in interface com.aspose.ms.System.Collections.ICollection<ISlide>
        Parameters:
        array - Target array.
        index - Starting 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.

        Specified by:
        isSynchronized in interface com.aspose.ms.System.Collections.ICollection<ISlide>
      • getSyncRoot

        public final java.lang.Object getSyncRoot()

        Returns a synchronization root. Read-only Object.

        Specified by:
        getSyncRoot in interface com.aspose.ms.System.Collections.ICollection<ISlide>
      • getParent_Immediate

        public final com.aspose.slides.IDOMObject getParent_Immediate()

        Returns Parent_Immediate object. Read-only IDOMObject.