Package org.apache.poi.hslf.usermodel
Class HSLFSlideShow
java.lang.Object
org.apache.poi.POIDocument
org.apache.poi.hslf.usermodel.HSLFSlideShow
- All Implemented Interfaces:
Closeable,AutoCloseable,GenericRecord,SlideShow<HSLFShape,HSLFTextParagraph>
public final class HSLFSlideShow
extends POIDocument
implements SlideShow<HSLFShape,HSLFTextParagraph>, Closeable, GenericRecord
This class is a friendly wrapper on top of the more scary HSLFSlideShow.
TODO: - figure out how to match notes to their correct sheet (will involve
understanding DocSlideList and DocNotesList) - handle Slide creation cleaner
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new, empty, Powerpoint document.HSLFSlideShow(InputStream inputStream) Constructs a Powerpoint document from an input stream.HSLFSlideShow(InputStream inputStream, char[] password) Constructs a Powerpoint document from an input stream.HSLFSlideShow(HSLFSlideShowImpl hslfSlideShow) Constructs a Powerpoint document from the underlying HSLFSlideShow object.HSLFSlideShow(DirectoryNode root) Constructs a Powerpoint document from an DirectoryNode.HSLFSlideShow(DirectoryNode root, char[] password) Constructs a Powerpoint document from an DirectoryNode.HSLFSlideShow(POIFSFileSystem poifs) Constructs a Powerpoint document from an POIFSFileSystem.HSLFSlideShow(POIFSFileSystem poifs, char[] password) Constructs a Powerpoint document from an POIFSFileSystem. -
Method Summary
Modifier and TypeMethodDescriptionintaddControl(String name, String progId) Add a control in this presentationintaddEmbed(POIFSFileSystem poiData) Add an embedded object to this presentationaddFont(InputStream fontData) Add a font in this presentation and also embed its font dataAdd a font in this presentationintAdd a movie in this presentationaddPicture(byte[] data, PictureData.PictureType format) Adds a picture to the presentation.addPicture(File pict, PictureData.PictureType format) Adds a picture to the presentation.addPicture(InputStream is, PictureData.PictureType format) Adds a picture to the presentation.protected voidClear/unlink the attached directory entryvoidclose()Closes the underlyingPOIFSFileSystemfrom which the document was read, if any.voidWill create whichever of SummaryInformation and DocumentSummaryInformation (HPSF) properties are not already part of your document.Create a blankSlide.findPictureData(byte[] pictureData) check if a picture with this picture data already exists in this presentationgetCoreRecordForRefID(int refID) For a given refID (the internal, 0 based numbering scheme), return the core recordFor a given SlideAtomsSet, return the core record, based on the refID from the SlidePersistAtomHelper method for usermodel and model: Get the document recordFetch the Document Summary Information of the documentReturns the data of all the embedded OLE object in the SlideShowprotected StringgetFont(int idx) Get a font by indexgetFonts()List<? extends GenericRecord>static intRecord[]Returns an array of the most recent version of all the interesting recordsgetNotes()Returns an array of all the normal Notes found in the slideshowReturn Header / Footer settings for notesintget the number of fonts in the presentationReturns the current page sizeReturns all Pictures of this slideshow.protected PropertySetgetPropertySet(String setName) For a given named property entry, either return it or null if if it wasn't foundprotected PropertySetgetPropertySet(String setName, EncryptionInfo encryptionInfo) For a given named property entry, either return it or null if if it wasn't foundReturn Header / Footer settings for slidesReturns an array of all the normal Slide Masters found in the slideshowReturns an array of all the normal Slides found in the slideshowReturns the data of all the embedded sounds in the SlideShowFetch the Summary Information of the documentReturns an array of all the normal Title Masters found in the slideshowprotected booleancheck if we were created by POIFS otherwise create a new dummy POIFS for storing the package datavoidFind, and create objects for, the standard Document Information Properties (HPSF).removeSlide(int index) Removes the slide at the given index (0-based).voidreorderSlide(int oldSlideNumber, int newSlideNumber) Re-orders a slide, to a new position.protected voidreplaceDirectory(DirectoryNode newDirectory) Replaces the attached directory, e.g.static voidsetMaxRecordLength(int length) voidsetOutputPassword(char[] password) Set the password to be used to password protect the slideshow when writing out.voidsetPageSize(Dimension pgsize) Change the current page sizeprotected voidCalled during aPOIDocument.write()to ensure that the Document (and associatedPOIFSFileSystem) was opened in a way compatible with an in-place write.voidwrite()Writes the document out to the currently openFile, via the writeablePOIFSFileSystemit was opened from.voidWrites the document out to the specified newFile.voidwrite(OutputStream out) Writes the document out to the specified output stream.protected voidWrites out the updated standard Document Information Properties (HPSF) into the currently open POIFSFileSystemvoidwriteProperties(POIFSFileSystem outFS) Writes out the standard Document Information Properties (HPSF)protected voidwriteProperties(POIFSFileSystem outFS, List<String> writtenEntries) Writes out the standard Document Information Properties (HPSF)Methods inherited from class org.apache.poi.POIDocument
readPropertiesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.poi.common.usermodel.GenericRecord
getGenericRecordType
-
Field Details
-
POWERPOINT_DOCUMENT
Powerpoint document entry/stream name- See Also:
-
PP97_DOCUMENT
- See Also:
-
PP95_DOCUMENT
- See Also:
-
-
Constructor Details
-
HSLFSlideShow
Constructs a Powerpoint document from the underlying HSLFSlideShow object. Finds the model stuff from this- Parameters:
hslfSlideShow- the HSLFSlideShow to base on
-
HSLFSlideShow
public HSLFSlideShow()Constructs a new, empty, Powerpoint document. -
HSLFSlideShow
Constructs a Powerpoint document from an input stream.- Throws:
IOException- If reading data from the stream failsIllegalStateException- a number of runtime exceptions can be thrown, especially if there are problems with the input format
-
HSLFSlideShow
Constructs a Powerpoint document from an input stream.- Parameters:
inputStream- stream containing ppt datapassword- in char array format (can be null)- Throws:
IOException- If reading data from the stream failsIllegalStateException- a number of runtime exceptions can be thrown, especially if there are problems with the input format- Since:
- 6.0.0
-
HSLFSlideShow
Constructs a Powerpoint document from an POIFSFileSystem.- Throws:
IOException- If reading data from the file-system failsIllegalStateException- a number of runtime exceptions can be thrown, especially if there are problems with the input format
-
HSLFSlideShow
Constructs a Powerpoint document from an POIFSFileSystem.- Parameters:
poifs- POIFSFileSystem containing ppt datapassword- in char array format (can be null)- Throws:
IOException- If reading data from the file-system failsIllegalStateException- a number of runtime exceptions can be thrown, especially if there are problems with the input format- Since:
- 6.0.0
-
HSLFSlideShow
Constructs a Powerpoint document from an DirectoryNode.- Throws:
IOException- If reading data from the DirectoryNode failsIllegalStateException- a number of runtime exceptions can be thrown, especially if there are problems with the input format
-
HSLFSlideShow
Constructs a Powerpoint document from an DirectoryNode.- Parameters:
root- DirectoryNode containing ppt datapassword- in char array format (can be null)- Throws:
IOException- If reading data from the DirectoryNode failsIllegalStateException- a number of runtime exceptions can be thrown, especially if there are problems with the input format- Since:
- 6.0.0
-
-
Method Details
-
setMaxRecordLength
public static void setMaxRecordLength(int length) - Parameters:
length- the max record length allowed for HSLFSlideShow
-
getMaxRecordLength
public static int getMaxRecordLength()- Returns:
- the max record length allowed for HSLFSlideShow
-
getCoreRecordForSAS
For a given SlideAtomsSet, return the core record, based on the refID from the SlidePersistAtom -
getCoreRecordForRefID
For a given refID (the internal, 0 based numbering scheme), return the core record- Parameters:
refID- the refID
-
write
Description copied from class:POIDocumentWrites the document out to the specified output stream. The stream is not closed as part of this operation. Note - if the Document was opened from aFilerather than anInputStream, you must write out usingPOIDocument.write()or to a different File. Overwriting the currently open file via an OutputStream isn't possible. Ifstreamis aFileOutputStreamon a networked drive or has a high cost/latency associated with each written byte, consider wrapping the OutputStream in aBufferedOutputStreamto improve write performance, or usePOIDocument.write()/POIDocument.write(File)if possible.- Specified by:
writein interfaceSlideShow<HSLFShape,HSLFTextParagraph> - Specified by:
writein classPOIDocument- Parameters:
out- The stream to write to.- Throws:
IOException- thrown on errors writing to the stream
-
getMostRecentCoreRecords
Returns an array of the most recent version of all the interesting records -
getSlides
Returns an array of all the normal Slides found in the slideshow- Specified by:
getSlidesin interfaceSlideShow<HSLFShape,HSLFTextParagraph>
-
getNotes
Returns an array of all the normal Notes found in the slideshow -
getSlideMasters
Returns an array of all the normal Slide Masters found in the slideshow- Specified by:
getSlideMastersin interfaceSlideShow<HSLFShape,HSLFTextParagraph>
-
getTitleMasters
Returns an array of all the normal Title Masters found in the slideshow -
getPictureData
Description copied from interface:SlideShowReturns all Pictures of this slideshow. The returnedListis unmodifiable.- Specified by:
getPictureDatain interfaceSlideShow<HSLFShape,HSLFTextParagraph> - Returns:
- a
ListofPictureData.
-
getEmbeddedObjects
Returns the data of all the embedded OLE object in the SlideShow -
getSoundData
Returns the data of all the embedded sounds in the SlideShow -
getPageSize
Description copied from interface:SlideShowReturns the current page size- Specified by:
getPageSizein interfaceSlideShow<HSLFShape,HSLFTextParagraph> - Returns:
- the page size
-
setPageSize
Description copied from interface:SlideShowChange the current page size- Specified by:
setPageSizein interfaceSlideShow<HSLFShape,HSLFTextParagraph> - Parameters:
pgsize- page size (in points)
-
getDocumentRecord
Helper method for usermodel and model: Get the document record -
reorderSlide
public void reorderSlide(int oldSlideNumber, int newSlideNumber) Re-orders a slide, to a new position.- Parameters:
oldSlideNumber- The old slide number (1 based)newSlideNumber- The new slide number (1 based)
-
removeSlide
Removes the slide at the given index (0-based).Shifts any subsequent slides to the left (subtracts one from their slide numbers).
- Parameters:
index- the index of the slide to remove (0-based)- Returns:
- the slide that was removed from the slide show.
-
createSlide
Create a blankSlide.- Specified by:
createSlidein interfaceSlideShow<HSLFShape,HSLFTextParagraph> - Returns:
- the created
Slide
-
addPicture
Description copied from interface:SlideShowAdds a picture to the presentation.- Specified by:
addPicturein interfaceSlideShow<HSLFShape,HSLFTextParagraph> - Parameters:
data- The bytes of the pictureformat- The format of the picture.- Returns:
- the picture data reference.
- Throws:
IOException
-
addPicture
public HSLFPictureData addPicture(InputStream is, PictureData.PictureType format) throws IOException Adds a picture to the presentation.- Specified by:
addPicturein interfaceSlideShow<HSLFShape,HSLFTextParagraph> - Parameters:
is- The stream to read the image fromformat- The format of the picture.- Returns:
- the picture data.
- Throws:
IOException- Since:
- 3.15 beta 2
-
addPicture
Adds a picture to the presentation.- Specified by:
addPicturein interfaceSlideShow<HSLFShape,HSLFTextParagraph> - 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
check if a picture with this picture data already exists in this presentation- Specified by:
findPictureDatain interfaceSlideShow<HSLFShape,HSLFTextParagraph> - Parameters:
pictureData- The picture data to find in the SlideShow- Returns:
nullif picture data is not found in this slideshow- Since:
- 3.15 beta 3
-
addFont
Add a font in this presentation- Parameters:
fontInfo- the font to add- Returns:
- the registered HSLFFontInfo - the font info object is unique based on the typeface
-
addFont
Add a font in this presentation and also embed its font data- Specified by:
addFontin interfaceSlideShow<HSLFShape,HSLFTextParagraph> - Parameters:
fontData- the EOT font data as stream- Returns:
- the registered HSLFFontInfo - the font info object is unique based on the typeface
- Throws:
IOException- if the fontData can't be saved or if the fontData is no EOT font- Since:
- 4.1.0
- See Also:
-
getFont
Get a font by index- Parameters:
idx- 0-based index of the font- Returns:
- of an instance of
PPFontornullif not found
-
getNumberOfFonts
public int getNumberOfFonts()get the number of fonts in the presentation- Returns:
- number of fonts
-
getFonts
- Specified by:
getFontsin interfaceSlideShow<HSLFShape,HSLFTextParagraph> - Returns:
- a list of registered fonts
-
addMovie
Add a movie in this presentation- Parameters:
path- the path or url to the movie- Returns:
- 0-based index of the movie
-
addControl
Add a control in this presentation- Parameters:
name- name of the control, e.g. "Shockwave Flash Object"progId- OLE Programmatic Identifier, e.g. "ShockwaveFlash.ShockwaveFlash.9"- Returns:
- 0-based index of the control
-
addEmbed
Add an embedded object to this presentation- Returns:
- 0-based index of the embedded object
-
getMetadataTextExtractor
- Specified by:
getMetadataTextExtractorin interfaceSlideShow<HSLFShape,HSLFTextParagraph> - Returns:
- an extractor for the slideshow metadata
-
createMasterSheet
- Specified by:
createMasterSheetin interfaceSlideShow<HSLFShape,HSLFTextParagraph>
-
getSlideShowImpl
- Returns:
- the handler class which holds the hslf records
-
close
Description copied from class:POIDocumentCloses the underlyingPOIFSFileSystemfrom which the document was read, if any. Has no effect on documents opened from an InputStream, or newly created ones.Once
close()has been called, no further operations should be called on the document.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classPOIDocument- Throws:
IOException
-
getPersistDocument
- Specified by:
getPersistDocumentin interfaceSlideShow<HSLFShape,HSLFTextParagraph> - Returns:
- the instance which handles the persisting of the slideshow,
which is either a subclass of
POIDocumentor org.apache.poi.ooxml.POIXMLDocument
-
getGenericProperties
- Specified by:
getGenericPropertiesin interfaceGenericRecord
-
getGenericChildren
- Specified by:
getGenericChildrenin interfaceGenericRecord
-
write
Description copied from class:POIDocumentWrites the document out to the currently openFile, via the writeablePOIFSFileSystemit was opened from.This will fail (with an
IllegalStateExceptionif the document was opened read-only, opened from anInputStreaminstead of a File, or if this is not the root document. For those cases, you must usePOIDocument.write(OutputStream)orPOIDocument.write(File)to write to a brand new document.- Specified by:
writein classPOIDocument- Throws:
IOException- thrown on errors writing to the file
-
write
Description copied from class:POIDocumentWrites the document out to the specified newFile. If the file exists, it will be replaced, otherwise a new one will be created- Specified by:
writein classPOIDocument- Parameters:
newFile- The new File to write to.- Throws:
IOException- thrown on errors writing to the file
-
setOutputPassword
public void setOutputPassword(char[] password) Set the password to be used to password protect the slideshow when writing out. Ifnullis passed any password previously set via this method is cleared; in that case the thread-level password fromBiff8EncryptionKey.getCurrentUserPassword()is used (if set), otherwise the output will be unencrypted.The password supplied to the constructor for reading an encrypted file is not automatically used as the output password.
- Parameters:
password- as a char array, ornullto clear- Since:
- 6.0.0
-
getDocumentSummaryInformation
Description copied from class:POIDocumentFetch the Document Summary Information of the document- Overrides:
getDocumentSummaryInformationin classPOIDocument- Returns:
- The Document Summary Information or null if it could not be read for this document.
-
getSummaryInformation
Description copied from class:POIDocumentFetch the Summary Information of the document- Overrides:
getSummaryInformationin classPOIDocument- Returns:
- The Summary information for the document or null if it could not be read for this document.
-
createInformationProperties
public void createInformationProperties()Description copied from class:POIDocumentWill create whichever of SummaryInformation and DocumentSummaryInformation (HPSF) properties are not already part of your document. This is normally useful when creating a new document from scratch. If the information properties are already there, then nothing will happen.- Overrides:
createInformationPropertiesin classPOIDocument
-
readProperties
public void readProperties()Description copied from class:POIDocumentFind, and create objects for, the standard Document Information Properties (HPSF). If a given property set is missing or corrupt, it will remain null;- Overrides:
readPropertiesin classPOIDocument
-
getPropertySet
Description copied from class:POIDocumentFor a given named property entry, either return it or null if if it wasn't found- Overrides:
getPropertySetin classPOIDocument- Parameters:
setName- The property to read- Returns:
- The value of the given property or null if it wasn't found.
- Throws:
IOException- If retrieving properties fails
-
getPropertySet
protected PropertySet getPropertySet(String setName, EncryptionInfo encryptionInfo) throws IOException Description copied from class:POIDocumentFor a given named property entry, either return it or null if if it wasn't found- Overrides:
getPropertySetin classPOIDocument- Parameters:
setName- The property to readencryptionInfo- the encryption descriptor in case of cryptoAPI encryption- Returns:
- The value of the given property or null if it wasn't found.
- Throws:
IOException- If retrieving properties fails
-
writeProperties
Description copied from class:POIDocumentWrites out the updated standard Document Information Properties (HPSF) into the currently open POIFSFileSystem- Overrides:
writePropertiesin classPOIDocument- Throws:
IOException- if an error when writing to the openPOIFSFileSystemoccurs
-
writeProperties
Description copied from class:POIDocumentWrites out the standard Document Information Properties (HPSF)- Overrides:
writePropertiesin classPOIDocument- Parameters:
outFS- the POIFSFileSystem to write the properties into- Throws:
IOException- if an error when writing to thePOIFSFileSystemoccurs
-
writeProperties
protected void writeProperties(POIFSFileSystem outFS, List<String> writtenEntries) throws IOException Description copied from class:POIDocumentWrites out the standard Document Information Properties (HPSF)- Overrides:
writePropertiesin classPOIDocument- Parameters:
outFS- thePOIFSFileSystemto write the properties intowrittenEntries- a list of POIFS entries to add the property names too- Throws:
IOException- if an error when writing to thePOIFSFileSystemoccurs
-
validateInPlaceWritePossible
Description copied from class:POIDocumentCalled during aPOIDocument.write()to ensure that the Document (and associatedPOIFSFileSystem) was opened in a way compatible with an in-place write.- Overrides:
validateInPlaceWritePossiblein classPOIDocument- Throws:
IllegalStateException- if the document was opened suitably
-
getDirectory
- Overrides:
getDirectoryin classPOIDocument
-
clearDirectory
protected void clearDirectory()Description copied from class:POIDocumentClear/unlink the attached directory entry- Overrides:
clearDirectoryin classPOIDocument
-
initDirectory
protected boolean initDirectory()Description copied from class:POIDocumentcheck if we were created by POIFS otherwise create a new dummy POIFS for storing the package data- Overrides:
initDirectoryin classPOIDocument- Returns:
trueif dummy directory was created,falseotherwise
-
replaceDirectory
Description copied from class:POIDocumentReplaces the attached directory, e.g. if this document is written to a new POIFSFileSystem- Overrides:
replaceDirectoryin classPOIDocument- Parameters:
newDirectory- the new directory- Throws:
IOException- if accessing the file-system fails.
-
getEncryptedPropertyStreamName
- Overrides:
getEncryptedPropertyStreamNamein classPOIDocument- Returns:
- the stream name of the property set collection, if the document is encrypted
-
getEncryptionInfo
- Overrides:
getEncryptionInfoin classPOIDocument- Returns:
- the encryption info if the document is encrypted, otherwise
null
-