diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2021-02-22 00:18:37 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2021-02-22 00:18:37 +0000 |
commit | eb30f2e1c82404b574297472efd7c6a1b52c36df (patch) | |
tree | 60053bec2eab1e1af35d7a246358d9a70095189a /src/java/org/apache/poi/sl/draw | |
parent | 259c9967efb354a0feff2a861ac8bd20582b6562 (diff) | |
download | poi-eb30f2e1c82404b574297472efd7c6a1b52c36df.tar.gz poi-eb30f2e1c82404b574297472efd7c6a1b52c36df.zip |
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
Diffstat (limited to 'src/java/org/apache/poi/sl/draw')
-rw-r--r-- | src/java/org/apache/poi/sl/draw/DrawPictureShape.java | 37 |
1 files changed, 22 insertions, 15 deletions
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<ImageRenderer> 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<ImageRenderer> 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 |