mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
add extra max size config
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1898235 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9563aa92da
commit
60f0c0a7f5
@ -77,8 +77,6 @@ public class XMLSlideShow extends POIXMLDocument
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
|
||||
private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
|
||||
private static final int DEFAULT_MAX_IMAGE_SIZE = 100_000_000;
|
||||
private static int MAX_IMAGE_SIZE = DEFAULT_MAX_IMAGE_SIZE;
|
||||
|
||||
private CTPresentation _presentation;
|
||||
private final List<XSLFSlide> _slides = new ArrayList<>();
|
||||
@ -103,20 +101,6 @@ public class XMLSlideShow extends POIXMLDocument
|
||||
return MAX_RECORD_LENGTH;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param length the max image size allowed for XMLSlideShow
|
||||
*/
|
||||
public static void setMaxImageSize(int length) {
|
||||
MAX_IMAGE_SIZE = length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the max image size allowed for XMLSlideShow
|
||||
*/
|
||||
public static int getMaxImageSize() {
|
||||
return MAX_IMAGE_SIZE;
|
||||
}
|
||||
|
||||
public XMLSlideShow() {
|
||||
this(empty());
|
||||
}
|
||||
@ -572,7 +556,7 @@ public class XMLSlideShow extends POIXMLDocument
|
||||
*/
|
||||
@Override
|
||||
public XSLFPictureData addPicture(InputStream is, PictureType format) throws IOException {
|
||||
return addPicture(IOUtils.toByteArray(is, getMaxImageSize()), format);
|
||||
return addPicture(IOUtils.toByteArray(is, XSLFPictureData.getMaxImageSize()), format);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -43,6 +43,24 @@ import org.apache.poi.util.Units;
|
||||
*/
|
||||
@Beta
|
||||
public final class XSLFPictureData extends POIXMLDocumentPart implements PictureData {
|
||||
|
||||
private static final int DEFAULT_MAX_IMAGE_SIZE = 100_000_000;
|
||||
private static int MAX_IMAGE_SIZE = DEFAULT_MAX_IMAGE_SIZE;
|
||||
|
||||
/**
|
||||
* @param length the max image size allowed for XSLF pictures
|
||||
*/
|
||||
public static void setMaxImageSize(int length) {
|
||||
MAX_IMAGE_SIZE = length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the max image size allowed for XSLF pictures
|
||||
*/
|
||||
public static int getMaxImageSize() {
|
||||
return MAX_IMAGE_SIZE;
|
||||
}
|
||||
|
||||
private Long checksum;
|
||||
|
||||
// original image dimensions (for formats supported by BufferedImage)
|
||||
@ -86,7 +104,7 @@ public final class XSLFPictureData extends POIXMLDocumentPart implements Picture
|
||||
*/
|
||||
public byte[] getData() {
|
||||
try (InputStream stream = getInputStream()) {
|
||||
return IOUtils.toByteArray(stream);
|
||||
return IOUtils.toByteArray(stream, getMaxImageSize());
|
||||
} catch (IOException e) {
|
||||
throw new POIXMLException(e);
|
||||
}
|
||||
|
||||
@ -34,6 +34,23 @@ import org.apache.poi.util.IOUtils;
|
||||
*/
|
||||
public class XSSFPictureData extends POIXMLDocumentPart implements PictureData {
|
||||
|
||||
private static final int DEFAULT_MAX_IMAGE_SIZE = 100_000_000;
|
||||
private static int MAX_IMAGE_SIZE = DEFAULT_MAX_IMAGE_SIZE;
|
||||
|
||||
/**
|
||||
* @param length the max image size allowed for XSSF pictures
|
||||
*/
|
||||
public static void setMaxImageSize(int length) {
|
||||
MAX_IMAGE_SIZE = length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the max image size allowed for XSSF pictures
|
||||
*/
|
||||
public static int getMaxImageSize() {
|
||||
return MAX_IMAGE_SIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationships for each known picture type
|
||||
*/
|
||||
@ -88,7 +105,7 @@ public class XSSFPictureData extends POIXMLDocumentPart implements PictureData {
|
||||
*/
|
||||
public byte[] getData() {
|
||||
try (InputStream inputStream = getPackagePart().getInputStream()) {
|
||||
return IOUtils.toByteArray(inputStream);
|
||||
return IOUtils.toByteArray(inputStream, getMaxImageSize());
|
||||
} catch(IOException e) {
|
||||
throw new POIXMLException(e);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user