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 Modifier and Type Field Description static StringPOWERPOINT_DOCUMENTPowerpoint document entry/stream namestatic StringPP95_DOCUMENTstatic StringPP97_DOCUMENT
-
Constructor Summary
Constructors Constructor Description HSLFSlideShow()Constructs a new, empty, Powerpoint document.HSLFSlideShow(InputStream inputStream)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(POIFSFileSystem poifs)Constructs a Powerpoint document from an POIFSFileSystem.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intaddControl(String name, String progId)Add a control in this presentationintaddEmbed(POIFSFileSystem poiData)Add a embedded object to this presentationHSLFFontInfoaddFont(InputStream fontData)Add a font in this presentation and also embed its font dataHSLFFontInfoaddFont(FontInfo fontInfo)Add a font in this presentationintaddMovie(String path, int type)Add a movie in this presentationHSLFPictureDataaddPicture(byte[] data, PictureData.PictureType format)HSLFPictureDataaddPicture(File pict, PictureData.PictureType format)Adds a picture to the presentation.HSLFPictureDataaddPicture(InputStream is, PictureData.PictureType format)Adds a picture to the presentation.protected voidclearDirectory()voidclose()voidcreateInformationProperties()MasterSheet<HSLFShape,HSLFTextParagraph>createMasterSheet()HSLFSlidecreateSlide()Create a blankSlide.HSLFPictureDatafindPictureData(byte[] pictureData)check if a picture with this picture data already exists in this presentationRecordgetCoreRecordForRefID(int refID)For a given refID (the internal, 0 based numbering scheme), return the core recordRecordgetCoreRecordForSAS(SlideListWithText.SlideAtomsSet sas)For a given SlideAtomsSet, return the core record, based on the refID from the SlidePersistAtomDirectoryNodegetDirectory()DocumentgetDocumentRecord()Helper method for usermodel and model: Get the document recordDocumentSummaryInformationgetDocumentSummaryInformation()HSLFObjectData[]getEmbeddedObjects()Returns the data of all the embedded OLE object in the SlideShowprotected StringgetEncryptedPropertyStreamName()EncryptionInfogetEncryptionInfo()HSLFFontInfogetFont(int idx)Get a font by indexList<HSLFFontInfo>getFonts()List<? extends GenericRecord>getGenericChildren()Map<String,Supplier<?>>getGenericProperties()static intgetMaxRecordLength()HPSFPropertiesExtractorgetMetadataTextExtractor()Record[]getMostRecentCoreRecords()Returns an array of the most recent version of all the interesting recordsList<HSLFNotes>getNotes()Returns an array of all the normal Notes found in the slideshowHeadersFootersgetNotesHeadersFooters()Return Header / Footer settings for notesintgetNumberOfFonts()get the number of fonts in the presentationDimensiongetPageSize()ObjectgetPersistDocument()List<HSLFPictureData>getPictureData()protected PropertySetgetPropertySet(String setName)protected PropertySetgetPropertySet(String setName, EncryptionInfo encryptionInfo)HeadersFootersgetSlideHeadersFooters()Return Header / Footer settings for slidesList<HSLFSlideMaster>getSlideMasters()Returns an array of all the normal Slide Masters found in the slideshowList<HSLFSlide>getSlides()Returns an array of all the normal Slides found in the slideshowHSLFSlideShowImplgetSlideShowImpl()HSLFSoundData[]getSoundData()Returns the data of all the embedded sounds in the SlideShowSummaryInformationgetSummaryInformation()List<HSLFTitleMaster>getTitleMasters()Returns an array of all the normal Title Masters found in the slideshowprotected booleaninitDirectory()voidreadProperties()HSLFSlideremoveSlide(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)static voidsetMaxRecordLength(int length)voidsetPageSize(Dimension pgsize)protected voidvalidateInPlaceWritePossible()voidwrite()voidwrite(File newFile)voidwrite(OutputStream out)protected voidwriteProperties()voidwriteProperties(POIFSFileSystem outFS)protected voidwriteProperties(POIFSFileSystem outFS, List<String> writtenEntries)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.poi.common.usermodel.GenericRecord
getGenericRecordType
-
-
-
-
Field Detail
-
POWERPOINT_DOCUMENT
public static final String POWERPOINT_DOCUMENT
Powerpoint document entry/stream name- See Also:
- Constant Field Values
-
PP97_DOCUMENT
public static final String PP97_DOCUMENT
- See Also:
- Constant Field Values
-
PP95_DOCUMENT
public static final String PP95_DOCUMENT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HSLFSlideShow
public HSLFSlideShow(HSLFSlideShowImpl 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
public HSLFSlideShow(InputStream inputStream) throws IOException
Constructs a Powerpoint document from an input stream.- Throws:
IOException- If reading data from the stream failsRuntimeException- a number of runtime exceptions can be thrown, especially if there are problems with the input format
-
HSLFSlideShow
public HSLFSlideShow(POIFSFileSystem poifs) throws IOException
Constructs a Powerpoint document from an POIFSFileSystem.- Throws:
IOException- If reading data from the file-system failsRuntimeException- a number of runtime exceptions can be thrown, especially if there are problems with the input format
-
HSLFSlideShow
public HSLFSlideShow(DirectoryNode root) throws IOException
Constructs a Powerpoint document from an DirectoryNode.- Throws:
IOException- If reading data from the DirectoryNode failsRuntimeException- a number of 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 HSLFSlideShow
-
getMaxRecordLength
public static int getMaxRecordLength()
- Returns:
- the max record length allowed for HSLFSlideShow
-
getCoreRecordForSAS
public Record getCoreRecordForSAS(SlideListWithText.SlideAtomsSet sas)
For a given SlideAtomsSet, return the core record, based on the refID from the SlidePersistAtom
-
getCoreRecordForRefID
public Record getCoreRecordForRefID(int refID)
For a given refID (the internal, 0 based numbering scheme), return the core record- Parameters:
refID- the refID
-
write
public void write(OutputStream out) throws IOException
- Specified by:
writein interfaceSlideShow<HSLFShape,HSLFTextParagraph>- Specified by:
writein classPOIDocument- Throws:
IOException
-
getMostRecentCoreRecords
public Record[] getMostRecentCoreRecords()
Returns an array of the most recent version of all the interesting records
-
getSlides
public List<HSLFSlide> getSlides()
Returns an array of all the normal Slides found in the slideshow- Specified by:
getSlidesin interfaceSlideShow<HSLFShape,HSLFTextParagraph>
-
getNotes
public List<HSLFNotes> getNotes()
Returns an array of all the normal Notes found in the slideshow
-
getSlideMasters
public List<HSLFSlideMaster> getSlideMasters()
Returns an array of all the normal Slide Masters found in the slideshow- Specified by:
getSlideMastersin interfaceSlideShow<HSLFShape,HSLFTextParagraph>
-
getTitleMasters
public List<HSLFTitleMaster> getTitleMasters()
Returns an array of all the normal Title Masters found in the slideshow
-
getPictureData
public List<HSLFPictureData> getPictureData()
- Specified by:
getPictureDatain interfaceSlideShow<HSLFShape,HSLFTextParagraph>
-
getEmbeddedObjects
public HSLFObjectData[] getEmbeddedObjects()
Returns the data of all the embedded OLE object in the SlideShow
-
getSoundData
public HSLFSoundData[] getSoundData()
Returns the data of all the embedded sounds in the SlideShow
-
getPageSize
public Dimension getPageSize()
- Specified by:
getPageSizein interfaceSlideShow<HSLFShape,HSLFTextParagraph>
-
setPageSize
public void setPageSize(Dimension pgsize)
- Specified by:
setPageSizein interfaceSlideShow<HSLFShape,HSLFTextParagraph>
-
getDocumentRecord
public Document 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
public HSLFSlide removeSlide(int index)
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
public HSLFSlide createSlide()
Create a blankSlide.- Specified by:
createSlidein interfaceSlideShow<HSLFShape,HSLFTextParagraph>- Returns:
- the created
Slide
-
addPicture
public HSLFPictureData addPicture(byte[] data, PictureData.PictureType format) throws IOException
- Specified by:
addPicturein interfaceSlideShow<HSLFShape,HSLFTextParagraph>- 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
public HSLFPictureData addPicture(File pict, PictureData.PictureType format) throws IOException
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
public HSLFPictureData findPictureData(byte[] pictureData)
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
public HSLFFontInfo addFont(FontInfo fontInfo)
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
public HSLFFontInfo addFont(InputStream fontData) throws IOException
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- Since:
- POI 4.1.0
-
getFont
public HSLFFontInfo getFont(int idx)
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
public List<HSLFFontInfo> getFonts()
- Specified by:
getFontsin interfaceSlideShow<HSLFShape,HSLFTextParagraph>
-
getSlideHeadersFooters
public HeadersFooters getSlideHeadersFooters()
Return Header / Footer settings for slides- Returns:
- Header / Footer settings for slides
-
getNotesHeadersFooters
public HeadersFooters getNotesHeadersFooters()
Return Header / Footer settings for notes- Returns:
- Header / Footer settings for notes
-
addMovie
public int addMovie(String path, int type)
Add a movie in this presentation- Parameters:
path- the path or url to the movie- Returns:
- 0-based index of the movie
-
addControl
public int addControl(String name, String progId)
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
public int addEmbed(POIFSFileSystem poiData)
Add a embedded object to this presentation- Returns:
- 0-based index of the embedded object
-
getMetadataTextExtractor
public HPSFPropertiesExtractor getMetadataTextExtractor()
- Specified by:
getMetadataTextExtractorin interfaceSlideShow<HSLFShape,HSLFTextParagraph>
-
createMasterSheet
public MasterSheet<HSLFShape,HSLFTextParagraph> createMasterSheet()
- Specified by:
createMasterSheetin interfaceSlideShow<HSLFShape,HSLFTextParagraph>
-
getSlideShowImpl
@Internal public HSLFSlideShowImpl getSlideShowImpl()
- Returns:
- the handler class which holds the hslf records
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classPOIDocument- Throws:
IOException
-
getPersistDocument
public Object getPersistDocument()
- Specified by:
getPersistDocumentin interfaceSlideShow<HSLFShape,HSLFTextParagraph>
-
getGenericProperties
public Map<String,Supplier<?>> getGenericProperties()
- Specified by:
getGenericPropertiesin interfaceGenericRecord
-
getGenericChildren
public List<? extends GenericRecord> getGenericChildren()
- Specified by:
getGenericChildrenin interfaceGenericRecord
-
write
public void write() throws IOException- Specified by:
writein classPOIDocument- Throws:
IOException
-
write
public void write(File newFile) throws IOException
- Specified by:
writein classPOIDocument- Throws:
IOException
-
getDocumentSummaryInformation
public DocumentSummaryInformation getDocumentSummaryInformation()
- Overrides:
getDocumentSummaryInformationin classPOIDocument
-
getSummaryInformation
public SummaryInformation getSummaryInformation()
- Overrides:
getSummaryInformationin classPOIDocument
-
createInformationProperties
public void createInformationProperties()
- Overrides:
createInformationPropertiesin classPOIDocument
-
readProperties
public void readProperties()
- Overrides:
readPropertiesin classPOIDocument
-
getPropertySet
protected PropertySet getPropertySet(String setName) throws IOException
- Overrides:
getPropertySetin classPOIDocument- Throws:
IOException
-
getPropertySet
protected PropertySet getPropertySet(String setName, EncryptionInfo encryptionInfo) throws IOException
- Overrides:
getPropertySetin classPOIDocument- Throws:
IOException
-
writeProperties
protected void writeProperties() throws IOException- Overrides:
writePropertiesin classPOIDocument- Throws:
IOException
-
writeProperties
public void writeProperties(POIFSFileSystem outFS) throws IOException
- Overrides:
writePropertiesin classPOIDocument- Throws:
IOException
-
writeProperties
protected void writeProperties(POIFSFileSystem outFS, List<String> writtenEntries) throws IOException
- Overrides:
writePropertiesin classPOIDocument- Throws:
IOException
-
validateInPlaceWritePossible
protected void validateInPlaceWritePossible() throws IllegalStateException- Overrides:
validateInPlaceWritePossiblein classPOIDocument- Throws:
IllegalStateException
-
getDirectory
public DirectoryNode getDirectory()
- Overrides:
getDirectoryin classPOIDocument
-
clearDirectory
protected void clearDirectory()
- Overrides:
clearDirectoryin classPOIDocument
-
initDirectory
protected boolean initDirectory()
- Overrides:
initDirectoryin classPOIDocument
-
replaceDirectory
protected void replaceDirectory(DirectoryNode newDirectory) throws IOException
- Overrides:
replaceDirectoryin classPOIDocument- Throws:
IOException
-
getEncryptedPropertyStreamName
protected String getEncryptedPropertyStreamName()
- Overrides:
getEncryptedPropertyStreamNamein classPOIDocument
-
getEncryptionInfo
public EncryptionInfo getEncryptionInfo()
- Overrides:
getEncryptionInfoin classPOIDocument
-
-