aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2022-09-13 23:38:12 +0000
committerPJ Fanning <fanningpj@apache.org>2022-09-13 23:38:12 +0000
commit34601b5377387e293868937bfa8f7e4cb4d45573 (patch)
tree0808a35acf7ae70b156ae104fce3608f6fa90901 /poi-ooxml
parente694cf4d534bb09d2a706f390db49e6e779dfa2b (diff)
downloadpoi-34601b5377387e293868937bfa8f7e4cb4d45573.tar.gz
poi-34601b5377387e293868937bfa8f7e4cb4d45573.zip
some lgtm issues
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1904048 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java21
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java3
2 files changed, 15 insertions, 9 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
index 5e7633ba2f..53727ef5e8 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
@@ -353,6 +353,10 @@ public class XSLFPictureShape extends XSLFSimpleShape
*/
public static XSLFPictureShape addSvgImage(XSLFSheet sheet, XSLFPictureData svgPic, PictureType previewType, Rectangle2D anchor) throws IOException {
+ if (svgPic == null || svgPic.getType() == null) {
+ throw new IllegalArgumentException("Cannot process svgPic with null type");
+ }
+
SVGImageRenderer renderer = new SVGImageRenderer();
try (InputStream is = svgPic.getInputStream()) {
renderer.loadImage(is, svgPic.getType().contentType);
@@ -368,16 +372,17 @@ public class XSLFPictureShape extends XSLFSimpleShape
}
BufferedImage thmBI = renderer.getImage(dim);
- UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream(100000);
- // use extension instead of enum name, because of "jpeg"
- ImageIO.write(thmBI, pt.extension.substring(1), bos);
+ try (UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream(100000)) {
+ // use extension instead of enum name, because of "jpeg"
+ ImageIO.write(thmBI, pt.extension.substring(1), bos);
- XSLFPictureData pngPic = sheet.getSlideShow().addPicture(bos.toInputStream(), pt);
+ XSLFPictureData pngPic = sheet.getSlideShow().addPicture(bos.toInputStream(), pt);
- XSLFPictureShape shape = sheet.createPicture(pngPic);
- shape.setAnchor(anc);
- shape.setSvgImage(svgPic);
- return shape;
+ XSLFPictureShape shape = sheet.createPicture(pngPic);
+ shape.setAnchor(anc);
+ shape.setSvgImage(svgPic);
+ return shape;
+ }
}
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
index 54457e86ff..560c196f89 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
@@ -1025,8 +1025,9 @@ public class SXSSFWorkbook implements Workbook {
//Substitute the template entries with the generated sheet data files
try (
InputStream is = bos.toInputStream();
+ ZipArchiveInputStream zis = new ZipArchiveInputStream(is);
ZipInputStreamZipEntrySource source = new ZipInputStreamZipEntrySource(
- new ZipArchiveThresholdInputStream(new ZipArchiveInputStream(is)))
+ new ZipArchiveThresholdInputStream(zis))
) {
injectData(source, stream);
}