Package org.apache.poi.xslf.usermodel
Class XSLFPictureData
- java.lang.Object
-
- org.apache.poi.ooxml.POIXMLDocumentPart
-
- org.apache.poi.xslf.usermodel.XSLFPictureData
-
- All Implemented Interfaces:
PictureData
@Beta public final class XSLFPictureData extends POIXMLDocumentPart implements PictureData
Instantiates sub-classes of POIXMLDocumentPart depending on their relationship type
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
POIXMLDocumentPart.RelationPart
-
Nested classes/interfaces inherited from interface org.apache.poi.sl.usermodel.PictureData
PictureData.PictureType
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedXSLFPictureData()Create a new XSLFGraphicData nodeXSLFPictureData(PackagePart part)Construct XSLFPictureData from a package part
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcacheProperties()Determine and cache image propertiesbyte[]getChecksum()StringgetContentType()byte[]getData()Gets the picture data as a byte array.StringgetFileName()Returns the file name of the image, eg image7.jpg .DimensiongetImageDimension()DimensiongetImageDimensionInPixels()intgetIndex()InputStreamgetInputStream()An InputStream to read the picture data directly from the underlying package partstatic intgetMaxImageSize()PictureData.PictureTypegetType()protected voidprepareForCommit()*PictureData objects store the actual content in the part directly without keeping a copy like all others therefore we need to handle them differently.voidsetData(byte[] data)voidsetIndex(int index)static voidsetMaxImageSize(int length)StringsuggestFileExtension()Suggests a file extension for this image.-
Methods inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
_invokeOnDocumentRead, addRelation, commit, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommitted, onDocumentCreate, onDocumentRead, onDocumentRemove, onSave, read, rebase, removeRelation, removeRelation, removeRelation, setCommitted, toString
-
-
-
-
Constructor Detail
-
XSLFPictureData
protected XSLFPictureData()
Create a new XSLFGraphicData node
-
XSLFPictureData
public XSLFPictureData(PackagePart part)
Construct XSLFPictureData from a package part- Parameters:
part- the package part holding the drawing data- Since:
- POI 3.14-Beta1
-
-
Method Detail
-
setMaxImageSize
public static void setMaxImageSize(int length)
- Parameters:
length- the max image size allowed for XSLF pictures
-
getMaxImageSize
public static int getMaxImageSize()
- Returns:
- the max image size allowed for XSLF pictures
-
getInputStream
public InputStream getInputStream() throws IOException
An InputStream to read the picture data directly from the underlying package part- Returns:
- InputStream
- Throws:
IOException
-
getData
public byte[] getData()
Gets the picture data as a byte array. You can grab the picture data directly from the underlying package part with thegetInputStream()method- Specified by:
getDatain interfacePictureData- Returns:
- the Picture data.
-
getFileName
public String getFileName()
Returns the file name of the image, eg image7.jpg . The original filename isn't always available, but if it can be found it's likely to be in the CTDrawing
-
suggestFileExtension
public String suggestFileExtension()
Suggests a file extension for this image.- Returns:
- the file extension.
-
getChecksum
public byte[] getChecksum()
- Specified by:
getChecksumin interfacePictureData
-
getImageDimension
public Dimension getImageDimension()
- Specified by:
getImageDimensionin interfacePictureData
-
getImageDimensionInPixels
public Dimension getImageDimensionInPixels()
- Specified by:
getImageDimensionInPixelsin interfacePictureData
-
cacheProperties
protected void cacheProperties()
Determine and cache image properties
-
prepareForCommit
protected void prepareForCommit()
*PictureData objects store the actual content in the part directly without keeping a copy like all others therefore we need to handle them differently.- Overrides:
prepareForCommitin classPOIXMLDocumentPart
-
getContentType
public String getContentType()
- Specified by:
getContentTypein interfacePictureData
-
setData
public void setData(byte[] data) throws IOException- Specified by:
setDatain interfacePictureData- Throws:
IOException
-
getType
public PictureData.PictureType getType()
- Specified by:
getTypein interfacePictureData
-
getIndex
public int getIndex()
- Returns:
- the 0-based index of this pictures within the picture parts
-
setIndex
public void setIndex(int index)
- Parameters:
index- sets the 0-based index of this pictures within the picture parts
-
-