From f9ce576f22148ab604f458a692cd428fbb0158a7 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Thu, 5 May 2016 12:22:31 +0000 Subject: [PATCH] Some general code-fixes found while trying out Java 9 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1742423 13f79535-47bb-0310-9956-ffa450edef68 --- .../poifs/crypt/dsig/KeyInfoKeySelector.java | 2 +- .../dsig/facets/KeyInfoSignatureFacet.java | 3 +- .../org/apache/poi/xslf/util/PPTX2PNG.java | 87 ++++++++++--------- 3 files changed, 47 insertions(+), 45 deletions(-) diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/KeyInfoKeySelector.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/KeyInfoKeySelector.java index ab9de5b1a4..90294105e0 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/KeyInfoKeySelector.java +++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/KeyInfoKeySelector.java @@ -65,7 +65,7 @@ public class KeyInfoKeySelector extends KeySelector implements KeySelectorResult continue; } X509Data x509Data = (X509Data) keyInfoStructure; - List x509DataList = x509Data.getContent(); + List x509DataList = x509Data.getContent(); for (Object x509DataObject : x509DataList) { if (!(x509DataObject instanceof X509Certificate)) { continue; diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/KeyInfoSignatureFacet.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/KeyInfoSignatureFacet.java index 27ea105330..93f0f5b8b6 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/KeyInfoSignatureFacet.java +++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/KeyInfoSignatureFacet.java @@ -32,6 +32,7 @@ import java.util.List; import java.util.Map; import javax.xml.crypto.MarshalException; +import javax.xml.crypto.XMLStructure; import javax.xml.crypto.dom.DOMStructure; import javax.xml.crypto.dsig.dom.DOMSignContext; import javax.xml.crypto.dsig.keyinfo.KeyInfo; @@ -77,7 +78,7 @@ public class KeyInfoSignatureFacet extends SignatureFacet { List x509DataObjects = new ArrayList(); X509Certificate signingCertificate = signatureConfig.getSigningCertificateChain().get(0); - List keyInfoContent = new ArrayList(); + List keyInfoContent = new ArrayList(); if (signatureConfig.isIncludeKeyValue()) { KeyValue keyValue; diff --git a/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java b/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java index 7f2f039688..7fb12eac8d 100644 --- a/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java +++ b/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java @@ -117,56 +117,57 @@ public class PPTX2PNG { System.out.println("Processing " + file); } SlideShow ss = SlideShowFactory.create(file, null, true); - List> slides = ss.getSlides(); + try { + List> slides = ss.getSlides(); - Set slidenum = slideIndexes(slides.size(), slidenumStr); - - if (slidenum.isEmpty()) { - usage("slidenum must be either -1 (for all) or within range: [1.."+slides.size()+"] for "+file); - ss.close(); - return; - } - - Dimension pgsize = ss.getPageSize(); - int width = (int) (pgsize.width * scale); - int height = (int) (pgsize.height * scale); - - for(Integer slideNo : slidenum) { - Slide slide = slides.get(slideNo); - String title = slide.getTitle(); - if (!quiet) { - System.out.println("Rendering slide " + slideNo + (title == null ? "" : ": " + title)); + Set slidenum = slideIndexes(slides.size(), slidenumStr); + + if (slidenum.isEmpty()) { + usage("slidenum must be either -1 (for all) or within range: [1.." + slides.size() + "] for " + file); + return; } - BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - Graphics2D graphics = img.createGraphics(); - DrawFactory.getInstance(graphics).fixFonts(graphics); - - // default rendering options - graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); - graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); - graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); - - graphics.scale(scale, scale); - - // draw stuff - slide.draw(graphics); - - // save the result - if (!"null".equals(format)) { - String outname = file.getName().replaceFirst(".pptx?", ""); - outname = String.format(Locale.ROOT, "%1$s-%2$04d.%3$s", outname, slideNo, format); - File outfile = new File(outdir, outname); - ImageIO.write(img, format, outfile); + Dimension pgsize = ss.getPageSize(); + int width = (int) (pgsize.width * scale); + int height = (int) (pgsize.height * scale); + + for (Integer slideNo : slidenum) { + Slide slide = slides.get(slideNo); + String title = slide.getTitle(); + if (!quiet) { + System.out.println("Rendering slide " + slideNo + (title == null ? "" : ": " + title)); + } + + BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + Graphics2D graphics = img.createGraphics(); + DrawFactory.getInstance(graphics).fixFonts(graphics); + + // default rendering options + graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); + graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); + + graphics.scale(scale, scale); + + // draw stuff + slide.draw(graphics); + + // save the result + if (!"null".equals(format)) { + String outname = file.getName().replaceFirst(".pptx?", ""); + outname = String.format(Locale.ROOT, "%1$s-%2$04d.%3$s", outname, slideNo, format); + File outfile = new File(outdir, outname); + ImageIO.write(img, format, outfile); + } } - } - + } finally { + ss.close(); + } + if (!quiet) { System.out.println("Done"); } - - ss.close(); } private static Set slideIndexes(final int slideCount, String range) { -- 2.39.5