Package org.apache.poi.xslf.usermodel
Class XMLSlideShow
- java.lang.Object
-
- org.apache.poi.ooxml.POIXMLDocumentPart
-
- org.apache.poi.ooxml.POIXMLDocument
-
- org.apache.poi.xslf.usermodel.XMLSlideShow
-
- All Implemented Interfaces:
Closeable,AutoCloseable,SlideShow<XSLFShape,XSLFTextParagraph>
@Beta public class XMLSlideShow extends POIXMLDocument implements SlideShow<XSLFShape,XSLFTextParagraph>
High level representation of an ooxml slideshow. This is the first object most users will construct whether they are reading or writing a slideshow. It is also the top level object for creating new slides/etc.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
POIXMLDocumentPart.RelationPart
-
-
Field Summary
-
Fields inherited from class org.apache.poi.ooxml.POIXMLDocument
DOCUMENT_CREATOR, OLE_OBJECT_REL_TYPE, PACK_OBJECT_REL_TYPE
-
-
Constructor Summary
Constructors Constructor Description XMLSlideShow()XMLSlideShow(InputStream is)XMLSlideShow(OPCPackage pkg)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description XSLFFontInfoaddFont(InputStream fontStream)XSLFPictureDataaddPicture(byte[] pictureData, PictureData.PictureType format)Adds a picture to the workbook.XSLFPictureDataaddPicture(File pict, PictureData.PictureType format)Adds a picture to the presentation.XSLFPictureDataaddPicture(InputStream is, PictureData.PictureType format)Adds a picture to the slideshow.protected voidcommit()Save the content in the underlying package part.XSLFChartcreateChart()This method is used to create template for chart XML.XSLFChartcreateChart(XSLFSlide slide)Create a blank chart on the given slide.MasterSheet<XSLFShape,XSLFTextParagraph>createMasterSheet()voidcreateNotesMaster()Create a notes master.XSLFSlidecreateSlide()Create a blank slide using the default (first) master.XSLFSlidecreateSlide(XSLFSlideLayout layout)Create a slide and initialize it from the specified layout.XSLFSlideLayoutfindLayout(String name)Scan the master slides for the first slide layout with the given name.XSLFPictureDatafindPictureData(byte[] pictureData)check if a picture with this picture data already exists in this presentationList<PackagePart>getAllEmbeddedParts()Get the document's embedded files.List<XSLFChart>getCharts()Return all the charts in the slideshowXSLFCommentAuthorsgetCommentAuthors()Returns the list of comment authors, if there is one.org.openxmlformats.schemas.presentationml.x2006.main.CTPresentationgetCTPresentation()List<XSLFFontInfo>getFonts()static intgetMaxRecordLength()POIXMLPropertiesTextExtractorgetMetadataTextExtractor()XSLFNotesMastergetNotesMaster()Return the Notes Master, if there is one.XSLFNotesgetNotesSlide(XSLFSlide slide)Return notes slide for the specified slide or create new if it does not exist yet.DimensiongetPageSize()ObjectgetPersistDocument()List<XSLFPictureData>getPictureData()List<XSLFSlideMaster>getSlideMasters()List<XSLFSlide>getSlides()Return all the slides in the slideshowXSLFTableStylesgetTableStyles()protected voidonDocumentRead()Fired when a package part is readXSLFSlideremoveSlide(int index)Remove a slide from this presentation.static voidsetMaxRecordLength(int length)voidsetPageSize(Dimension pgSize)voidsetSlideOrder(XSLFSlide slide, int newIndex)-
Methods inherited from class org.apache.poi.ooxml.POIXMLDocument
close, getCorePart, getPackage, getProperties, getRelatedByType, load, openPackage, write
-
Methods inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommitted, onDocumentCreate, onDocumentRemove, onSave, prepareForCommit, read, rebase, removeRelation, removeRelation, removeRelation, setCommitted, toString
-
-
-
-
Constructor Detail
-
XMLSlideShow
public XMLSlideShow()
-
XMLSlideShow
public XMLSlideShow(OPCPackage pkg)
- Parameters:
pkg- OPC package- Throws:
POIXMLException- a RuntimeException that can be caused by invalid OOXML dataRuntimeException- a number of other runtime exceptions can be thrown, especially if there are problems with the input format
-
XMLSlideShow
public XMLSlideShow(InputStream is) throws IOException
- Parameters:
is- InputStream- Throws:
IOException- If reading data from the stream failsPOIXMLException- a RuntimeException that can be caused by invalid OOXML dataRuntimeException- a number of other runtime exceptions can be thrown, especially if there are problems with the input format
-
-
Method Detail
-
setMaxRecordLength
public static void setMaxRecordLength(int length)
- Parameters:
length- the max record length allowed for XMLSlideShow
-
getMaxRecordLength
public static int getMaxRecordLength()
- Returns:
- the max record length allowed for XMLSlideShow
-
onDocumentRead
protected void onDocumentRead() throws IOExceptionDescription copied from class:POIXMLDocumentPartFired when a package part is read- Overrides:
onDocumentReadin classPOIXMLDocumentPart- Throws:
IOException- a subclass may throw an IOException when a document is read
-
commit
protected void commit() throws IOExceptionDescription copied from class:POIXMLDocumentPartSave the content in the underlying package part. Default implementation is empty meaning that the package part is left unmodified.Sub-classes should override and add logic to marshal the "model" into Ooxml4J.
For example, the code saving a generic XML entry may look as follows:
protected void commit() throws IOException { PackagePart part = getPackagePart(); try (OutputStream out = part.getOutputStream()) { XmlObject bean = getXmlBean(); //the "model" which holds changes in memory bean.save(out, DEFAULT_XML_OPTIONS); } }- Overrides:
commitin classPOIXMLDocumentPart- Throws:
IOException- a subclass may throw an IOException if the changes can't be committed
-
getAllEmbeddedParts
public List<PackagePart> getAllEmbeddedParts()
Get the document's embedded files.- Specified by:
getAllEmbeddedPartsin classPOIXMLDocument- Returns:
- the document's embedded files
-
getPictureData
public List<XSLFPictureData> getPictureData()
- Specified by:
getPictureDatain interfaceSlideShow<XSLFShape,XSLFTextParagraph>
-
createSlide
public XSLFSlide createSlide(XSLFSlideLayout layout)
Create a slide and initialize it from the specified layout.- Parameters:
layout- The layout to use for the new slide.- Returns:
- created slide
-
createSlide
public XSLFSlide createSlide()
Create a blank slide using the default (first) master.- Specified by:
createSlidein interfaceSlideShow<XSLFShape,XSLFTextParagraph>
-
createChart
public XSLFChart createChart()
This method is used to create template for chart XML.- Returns:
- Xslf chart object
- Since:
- POI 4.1.0
-
getNotesSlide
public XSLFNotes getNotesSlide(XSLFSlide slide)
Return notes slide for the specified slide or create new if it does not exist yet.
-
createNotesMaster
public void createNotesMaster()
Create a notes master.
-
getNotesMaster
public XSLFNotesMaster getNotesMaster()
Return the Notes Master, if there is one. (May not be present if no notes exist)
-
getSlideMasters
public List<XSLFSlideMaster> getSlideMasters()
- Specified by:
getSlideMastersin interfaceSlideShow<XSLFShape,XSLFTextParagraph>
-
getSlides
public List<XSLFSlide> getSlides()
Return all the slides in the slideshow- Specified by:
getSlidesin interfaceSlideShow<XSLFShape,XSLFTextParagraph>
-
getCommentAuthors
public XSLFCommentAuthors getCommentAuthors()
Returns the list of comment authors, if there is one. Will only be present if at least one slide has comments on it.
-
setSlideOrder
public void setSlideOrder(XSLFSlide slide, int newIndex)
- Parameters:
newIndex- 0-based index of the slide
-
removeSlide
public XSLFSlide removeSlide(int index)
Remove a slide from this presentation.- Parameters:
index- The slide number to remove.- Returns:
- The slide that was removed.
- Throws:
RuntimeException- a number of runtime exceptions can be thrown, especially if there are problems with the input format
-
getPageSize
public Dimension getPageSize()
- Specified by:
getPageSizein interfaceSlideShow<XSLFShape,XSLFTextParagraph>
-
setPageSize
public void setPageSize(Dimension pgSize)
- Specified by:
setPageSizein interfaceSlideShow<XSLFShape,XSLFTextParagraph>
-
getCTPresentation
@Internal public org.openxmlformats.schemas.presentationml.x2006.main.CTPresentation getCTPresentation()
-
addPicture
public XSLFPictureData addPicture(byte[] pictureData, PictureData.PictureType format)
Adds a picture to the workbook.- Specified by:
addPicturein interfaceSlideShow<XSLFShape,XSLFTextParagraph>- Parameters:
pictureData- The bytes of the pictureformat- The format of the picture.- Returns:
- the picture data
-
addPicture
public XSLFPictureData addPicture(InputStream is, PictureData.PictureType format) throws IOException
Adds a picture to the slideshow.- Specified by:
addPicturein interfaceSlideShow<XSLFShape,XSLFTextParagraph>- Parameters:
is- The stream to read image fromformat- The format of the picture- Returns:
- the picture data
- Throws:
IOException- Since:
- 3.15 beta 2
-
addPicture
public XSLFPictureData addPicture(File pict, PictureData.PictureType format) throws IOException
Adds a picture to the presentation.- Specified by:
addPicturein interfaceSlideShow<XSLFShape,XSLFTextParagraph>- Parameters:
pict- The file containing the image to addformat- The format of the picture.- Returns:
- the picture data
- Throws:
IOException- Since:
- 3.15 beta 2
-
findPictureData
public XSLFPictureData findPictureData(byte[] pictureData)
check if a picture with this picture data already exists in this presentation- Specified by:
findPictureDatain interfaceSlideShow<XSLFShape,XSLFTextParagraph>- Parameters:
pictureData- The picture data to find in the SlideShow- Returns:
nullif picture data is not found in this slideshow- Since:
- 3.15 beta 2
-
findLayout
public XSLFSlideLayout findLayout(String name)
Scan the master slides for the first slide layout with the given name.- Parameters:
name- The layout name (case-insensitive). Cannot be null.- Returns:
- the first layout found or null on failure
-
getTableStyles
public XSLFTableStyles getTableStyles()
-
createMasterSheet
public MasterSheet<XSLFShape,XSLFTextParagraph> createMasterSheet() throws IOException
- Specified by:
createMasterSheetin interfaceSlideShow<XSLFShape,XSLFTextParagraph>- Throws:
IOException
-
getMetadataTextExtractor
public POIXMLPropertiesTextExtractor getMetadataTextExtractor()
- Specified by:
getMetadataTextExtractorin interfaceSlideShow<XSLFShape,XSLFTextParagraph>
-
getPersistDocument
public Object getPersistDocument()
- Specified by:
getPersistDocumentin interfaceSlideShow<XSLFShape,XSLFTextParagraph>
-
addFont
public XSLFFontInfo addFont(InputStream fontStream) throws IOException
- Specified by:
addFontin interfaceSlideShow<XSLFShape,XSLFTextParagraph>- Throws:
IOException
-
getFonts
public List<XSLFFontInfo> getFonts()
- Specified by:
getFontsin interfaceSlideShow<XSLFShape,XSLFTextParagraph>
-
-