From: Andreas Beeker Date: Mon, 22 Feb 2021 00:18:37 +0000 (+0000) Subject: Use upcoming XmlBeans 5.0.0 (working version 4.0.1) X-Git-Tag: REL_5_1_0~365 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=eb30f2e1c82404b574297472efd7c6a1b52c36df;p=poi.git Use upcoming XmlBeans 5.0.0 (working version 4.0.1) Make batik optional as it doesn't work on the module-path Use sub-components of batik as batik-all references them all again resulting in duplicated entries (maven poms haven't been migrated yet ...) Remove SLF4j dependency git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1886777 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/build.xml b/build.xml index e8461f4df9..dddb2b15f5 100644 --- a/build.xml +++ b/build.xml @@ -288,7 +288,6 @@ under the License. - @@ -300,17 +299,36 @@ under the License. - - - - + + + + + + + + + + + + + + + + + + + + + + - + @@ -433,7 +451,6 @@ under the License. - @@ -461,7 +478,25 @@ under the License. - + + + + + + + + + + + + + + + + + + + @@ -623,12 +658,14 @@ under the License. + + @@ -675,7 +712,6 @@ under the License. - @@ -722,7 +758,6 @@ under the License. - @@ -756,7 +791,25 @@ under the License. - + + + + + + + + + + + + + + + + + + + @@ -775,7 +828,25 @@ under the License. - + + + + + + + + + + + + + + + + + + + @@ -858,9 +929,13 @@ under the License. - + + + + + + + + @@ -1287,6 +1363,10 @@ under the License. + + + + @@ -2579,7 +2659,25 @@ under the License. - + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/apache/poi/sl/draw/DrawPictureShape.java b/src/java/org/apache/poi/sl/draw/DrawPictureShape.java index 71cb1bdd23..764f1f576a 100644 --- a/src/java/org/apache/poi/sl/draw/DrawPictureShape.java +++ b/src/java/org/apache/poi/sl/draw/DrawPictureShape.java @@ -23,9 +23,10 @@ import java.awt.Insets; import java.awt.Paint; import java.awt.geom.Rectangle2D; import java.io.IOException; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.ServiceConfigurationError; import java.util.ServiceLoader; -import java.util.function.Supplier; -import java.util.stream.StreamSupport; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -91,20 +92,26 @@ public class DrawPictureShape extends DrawSimpleShape { return fallback; } - // the fallback is the BitmapImageRenderer, at least it gracefully handles invalid images - final Supplier getFallback = () -> { - LOG.atWarn().log("No suitable image renderer found for content-type '{}' - include " + - "poi-scratchpad (for wmf/emf) or poi-ooxml (for svg) jars!", contentType); - return fallback; - }; - ClassLoader cl = DrawPictureShape.class.getClassLoader(); - return StreamSupport - .stream(ServiceLoader.load(ImageRenderer.class, cl).spliterator(), false) - .filter(ir -> ir.canRender(contentType)) - .findFirst() - .orElseGet(getFallback) - ; + Iterator iter = ServiceLoader.load(ImageRenderer.class, cl).iterator(); + for (;;) { + // Batik / SVGImageRenderer fails when executed on the module-path, hence we try/skip it in that case + try { + ImageRenderer ir = iter.next(); + if (ir.canRender(contentType)) { + return ir; + } + } catch (NoSuchElementException ignored) { + break; + } catch (Exception | ServiceConfigurationError ignored) { + } + } + + // the fallback is the BitmapImageRenderer, at least it gracefully handles invalid images + LOG.atWarn().log("No suitable image renderer found for content-type '{}' - include " + + "poi-scratchpad (for wmf/emf) or poi-ooxml (for svg) jars - " + + "svgs/batik doesn't work on the module-path!", contentType); + return fallback; } @Override diff --git a/src/multimodule/ooxml-lite/java9/module-info.class b/src/multimodule/ooxml-lite/java9/module-info.class index 2a720c718d..5a1a8d9258 100644 Binary files a/src/multimodule/ooxml-lite/java9/module-info.class and b/src/multimodule/ooxml-lite/java9/module-info.class differ diff --git a/src/multimodule/ooxml/java9/module-info.class b/src/multimodule/ooxml/java9/module-info.class index 9d0a03b62f..9f991b0c36 100644 Binary files a/src/multimodule/ooxml/java9/module-info.class and b/src/multimodule/ooxml/java9/module-info.class differ diff --git a/src/multimodule/ooxml/java9/module-info.java b/src/multimodule/ooxml/java9/module-info.java index d8893df5bd..317a9d9ca9 100644 --- a/src/multimodule/ooxml/java9/module-info.java +++ b/src/multimodule/ooxml/java9/module-info.java @@ -89,9 +89,28 @@ module org.apache.poi.ooxml { requires org.bouncycastle.pkix; /* optional dependencies for slideshow rendering via PPTX2PNG */ - requires batik.all; + requires static batik.anim; + requires static batik.awt.util; + requires static batik.bridge; + requires static batik.codec; + requires static batik.constants; + requires static batik.css; + requires static batik.dom; + requires static batik.ext; + requires static batik.gvt; + requires static batik.i18n; + requires static batik.parser; + requires static batik.script; + requires static batik.shared.resources; + requires static batik.svg.dom; + requires static batik.svggen; + requires static batik.svgrasterizer; + requires static batik.transcoder; + requires static batik.util; + requires static batik.xml; + requires static xmlgraphics.commons; + requires org.apache.pdfbox; requires org.apache.fontbox; requires de.rototor.pdfbox.graphics2d; - requires xmlgraphics.commons; } \ No newline at end of file diff --git a/src/multimodule/ooxml/test9/module-info.class b/src/multimodule/ooxml/test9/module-info.class index db5f9a34ca..8fc0ead938 100644 Binary files a/src/multimodule/ooxml/test9/module-info.class and b/src/multimodule/ooxml/test9/module-info.class differ diff --git a/src/multimodule/ooxml/test9/module-info.java b/src/multimodule/ooxml/test9/module-info.java index 09195b1f69..152cab9e5c 100644 --- a/src/multimodule/ooxml/test9/module-info.java +++ b/src/multimodule/ooxml/test9/module-info.java @@ -90,11 +90,30 @@ module org.apache.poi.ooxml { /* optional dependencies for slideshow rendering via PPTX2PNG */ - requires batik.all; + requires static batik.anim; + requires static batik.awt.util; + requires static batik.bridge; + requires static batik.codec; + requires static batik.constants; + requires static batik.css; + requires static batik.dom; + requires static batik.ext; + requires static batik.gvt; + requires static batik.i18n; + requires static batik.parser; + requires static batik.script; + requires static batik.shared.resources; + requires static batik.svg.dom; + requires static batik.svggen; + requires static batik.svgrasterizer; + requires static batik.transcoder; + requires static batik.util; + requires static batik.xml; + requires static xmlgraphics.commons; + requires org.apache.pdfbox; requires org.apache.fontbox; requires de.rototor.pdfbox.graphics2d; - requires xmlgraphics.commons; // test specific exports diff --git a/src/multimodule/poi/java9/module-info.class b/src/multimodule/poi/java9/module-info.class index 3a40124eb2..5d96fed54b 100644 Binary files a/src/multimodule/poi/java9/module-info.class and b/src/multimodule/poi/java9/module-info.class differ 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 33c5703f8b..27f053dc85 100644 --- a/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java +++ b/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java @@ -35,6 +35,8 @@ import java.util.Set; import java.util.regex.Pattern; import java.util.stream.Collectors; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.poi.common.usermodel.GenericRecord; import org.apache.poi.poifs.filesystem.FileMagic; import org.apache.poi.sl.draw.Drawable; @@ -47,6 +49,7 @@ import org.apache.poi.util.LocaleUtil; * An utility to convert slides of a .pptx slide show to a PNG image */ public final class PPTX2PNG { + private static final Logger LOG = LogManager.getLogger(PPTX2PNG.class); private static final String INPUT_PAT_REGEX = "(?[^|]+)\\|(?[^|]+)\\|(?.+)\\.(?[^.]++)"; @@ -350,8 +353,14 @@ public final class PPTX2PNG { private OutputFormat getOutput() { switch (format) { - case "svg": - return new SVGFormat(textAsShapes); + case "svg": { + try { + return new SVGFormat(textAsShapes); + } catch (Exception | NoClassDefFoundError e) { + LOG.atError().withThrowable(e).log("Batik is not not added to/working on the module-path. Use classpath mode instead of JPMS. Fallback to PNG."); + return new BitmapFormat("png"); + } + } case "pdf": return new PDFFormat(textAsShapes,fontDir,fontTtf); case "log": diff --git a/src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java b/src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java index 798b559047..d7fc0b4471 100644 --- a/src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java +++ b/src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java @@ -910,6 +910,8 @@ class TestSignatureInfo { si.setSignatureConfig(sic); // hash > sha1 doesn't work in excel viewer ... si.confirmSignature(); + } catch (java.util.ServiceConfigurationError e) { + assumeFalse(true, "running on module-path / JPMS and batik is \"kaputt\" WRT JPMS"); } XmlDocumentPackageInit reinit = diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java index b4bd226083..0df21b2720 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java @@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeFalse; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; @@ -46,7 +47,7 @@ import org.junit.jupiter.api.Test; import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture; class TestXSLFPictureShape { - private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); + private static final POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); @Test void testCreate() throws Exception { @@ -287,6 +288,8 @@ class TestXSLFPictureShape { } catch (IIOException ignore) { // Ignore all ImageIO related exceptions like "Can't create output stream!" // which fail often in maven builds because of missing/wrong temp directory + } catch (NoClassDefFoundError ignore) { + assumeFalse(true, "Batik doesn't work on th module-path"); } } } \ No newline at end of file