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:
java.io.Closeable
,java.lang.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(java.io.InputStream is)
XMLSlideShow(OPCPackage pkg)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description XSLFFontInfo
addFont(java.io.InputStream fontStream)
Add an EOT font to the slideshow.XSLFPictureData
addPicture(byte[] pictureData, PictureData.PictureType format)
Adds a picture to the workbook.XSLFPictureData
addPicture(java.io.File pict, PictureData.PictureType format)
Adds a picture to the presentation.XSLFPictureData
addPicture(java.io.InputStream is, PictureData.PictureType format)
Adds a picture to the slideshow.XSLFChart
createChart()
This method is used to create template for chart XML.XSLFChart
createChart(XSLFSlide slide)
Create a blank chart on the given slide.MasterSheet<XSLFShape,XSLFTextParagraph>
createMasterSheet()
void
createNotesMaster()
Create a notes master.XSLFSlide
createSlide()
Create a blank slide using the default (first) master.XSLFSlide
createSlide(XSLFSlideLayout layout)
Create a slide and initialize it from the specified layout.XSLFSlideLayout
findLayout(java.lang.String name)
Scan the master slides for the first slide layout with the given name.XSLFPictureData
findPictureData(byte[] pictureData)
check if a picture with this picture data already exists in this presentationjava.util.List<PackagePart>
getAllEmbeddedParts()
Get the document's embedded files.java.util.List<XSLFChart>
getCharts()
Return all the charts in the slideshowXSLFCommentAuthors
getCommentAuthors()
Returns the list of comment authors, if there is one.CTPresentation
getCTPresentation()
java.util.List<XSLFFontInfo>
getFonts()
static int
getMaxRecordLength()
POIXMLPropertiesTextExtractor
getMetadataTextExtractor()
XSLFNotesMaster
getNotesMaster()
Return the Notes Master, if there is one.XSLFNotes
getNotesSlide(XSLFSlide slide)
Return notes slide for the specified slide or create new if it does not exist yet.java.awt.Dimension
getPageSize()
Returns the current page sizejava.lang.Object
getPersistDocument()
java.util.List<XSLFPictureData>
getPictureData()
Returns all Pictures of this slideshow.java.util.List<XSLFSlideMaster>
getSlideMasters()
Returns all slide masters.java.util.List<XSLFSlide>
getSlides()
Return all the slides in the slideshowXSLFTableStyles
getTableStyles()
XSLFSlide
removeSlide(int index)
Remove a slide from this presentation.static void
setMaxRecordLength(int length)
void
setPageSize(java.awt.Dimension pgSize)
Change the current page sizevoid
setSlideOrder(XSLFSlide slide, int newIndex)
-
Methods inherited from class org.apache.poi.ooxml.POIXMLDocument
close, getPackage, getProperties, openPackage, write
-
Methods inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, isCommitted, 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 datajava.lang.RuntimeException
- a number of other runtime exceptions can be thrown, especially if there are problems with the input format
-
XMLSlideShow
public XMLSlideShow(java.io.InputStream is) throws java.io.IOException
- Parameters:
is
- InputStream- Throws:
java.io.IOException
- If reading data from the stream failsPOIXMLException
- a RuntimeException that can be caused by invalid OOXML datajava.lang.RuntimeException
- 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
-
getAllEmbeddedParts
public java.util.List<PackagePart> getAllEmbeddedParts()
Get the document's embedded files.- Specified by:
getAllEmbeddedParts
in classPOIXMLDocument
- Returns:
- the document's embedded files
-
getPictureData
public java.util.List<XSLFPictureData> getPictureData()
Description copied from interface:SlideShow
Returns all Pictures of this slideshow. The returnedList
is unmodifiable.- Specified by:
getPictureData
in interfaceSlideShow<XSLFShape,XSLFTextParagraph>
- Returns:
- a
List
ofPictureData
.
-
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:
createSlide
in 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 java.util.List<XSLFSlideMaster> getSlideMasters()
Description copied from interface:SlideShow
Returns all slide masters. This doesn't include notes master and other arbitrary masters.- Specified by:
getSlideMasters
in interfaceSlideShow<XSLFShape,XSLFTextParagraph>
-
getSlides
public java.util.List<XSLFSlide> getSlides()
Return all the slides in the slideshow- Specified by:
getSlides
in interfaceSlideShow<XSLFShape,XSLFTextParagraph>
-
getCharts
public java.util.List<XSLFChart> getCharts()
Return all the charts in the slideshow
-
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:
java.lang.RuntimeException
- a number of runtime exceptions can be thrown, especially if there are problems with the input format
-
getPageSize
public java.awt.Dimension getPageSize()
Description copied from interface:SlideShow
Returns the current page size- Specified by:
getPageSize
in interfaceSlideShow<XSLFShape,XSLFTextParagraph>
- Returns:
- the page size
-
setPageSize
public void setPageSize(java.awt.Dimension pgSize)
Description copied from interface:SlideShow
Change the current page size- Specified by:
setPageSize
in interfaceSlideShow<XSLFShape,XSLFTextParagraph>
- Parameters:
pgSize
- page size (in points)
-
getCTPresentation
@Internal public CTPresentation getCTPresentation()
-
addPicture
public XSLFPictureData addPicture(byte[] pictureData, PictureData.PictureType format)
Adds a picture to the workbook.- Specified by:
addPicture
in interfaceSlideShow<XSLFShape,XSLFTextParagraph>
- Parameters:
pictureData
- The bytes of the pictureformat
- The format of the picture.- Returns:
- the picture data
-
addPicture
public XSLFPictureData addPicture(java.io.InputStream is, PictureData.PictureType format) throws java.io.IOException
Adds a picture to the slideshow.- Specified by:
addPicture
in interfaceSlideShow<XSLFShape,XSLFTextParagraph>
- Parameters:
is
- The stream to read image fromformat
- The format of the picture- Returns:
- the picture data
- Throws:
java.io.IOException
- Since:
- 3.15 beta 2
-
addPicture
public XSLFPictureData addPicture(java.io.File pict, PictureData.PictureType format) throws java.io.IOException
Adds a picture to the presentation.- Specified by:
addPicture
in interfaceSlideShow<XSLFShape,XSLFTextParagraph>
- Parameters:
pict
- The file containing the image to addformat
- The format of the picture.- Returns:
- the picture data
- Throws:
java.io.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:
findPictureData
in interfaceSlideShow<XSLFShape,XSLFTextParagraph>
- Parameters:
pictureData
- The picture data to find in the SlideShow- Returns:
null
if picture data is not found in this slideshow- Since:
- 3.15 beta 2
-
findLayout
public XSLFSlideLayout findLayout(java.lang.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 java.io.IOException
- Specified by:
createMasterSheet
in interfaceSlideShow<XSLFShape,XSLFTextParagraph>
- Throws:
java.io.IOException
-
getMetadataTextExtractor
public POIXMLPropertiesTextExtractor getMetadataTextExtractor()
- Specified by:
getMetadataTextExtractor
in interfaceSlideShow<XSLFShape,XSLFTextParagraph>
- Returns:
- an extractor for the slideshow metadata
-
getPersistDocument
public java.lang.Object getPersistDocument()
- Specified by:
getPersistDocument
in interfaceSlideShow<XSLFShape,XSLFTextParagraph>
- Returns:
- the instance which handles the persisting of the slideshow,
which is either a subclass of
POIDocument
orPOIXMLDocument
-
addFont
public XSLFFontInfo addFont(java.io.InputStream fontStream) throws java.io.IOException
Description copied from interface:SlideShow
Add an EOT font to the slideshow. An EOT or MTX font is a transformed True-Type (.ttf) or Open-Type (.otf) font. To transform a True-Type font use the sfntly library (see "see also" below)(Older?) Powerpoint versions handle embedded fonts by converting them to .ttf files and put them into the Windows fonts directory. If the user is not allowed to install fonts, the slideshow can't be opened. While the slideshow is opened, its possible to copy the extracted .ttfs from the fonts directory. When the slideshow is closed, they will be removed.
- Specified by:
addFont
in interfaceSlideShow<XSLFShape,XSLFTextParagraph>
- Parameters:
fontStream
- the EOT font as stream- Returns:
- the font info object containing the new font data
- Throws:
java.io.IOException
- if the fontData can't be saved or if the fontData is no EOT font- See Also:
- EOT specification, googles sfntly library, Example on how to subset and embed fonts
-
getFonts
public java.util.List<XSLFFontInfo> getFonts()
- Specified by:
getFonts
in interfaceSlideShow<XSLFShape,XSLFTextParagraph>
- Returns:
- a list of registered fonts
-
-