diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2018-12-16 21:02:01 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2018-12-16 21:02:01 +0000 |
commit | 150a00654eaab6ddd58c571da73421beba01f8a3 (patch) | |
tree | 1014505d17a249ecc9265ba9b7ffe33f1a13d9a7 /src/java/org | |
parent | 8e37e0005400b3255a33721c3cd73e746c43f83e (diff) | |
download | poi-150a00654eaab6ddd58c571da73421beba01f8a3.tar.gz poi-150a00654eaab6ddd58c571da73421beba01f8a3.zip |
#62365 - SVG image support in XSLF
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1849046 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
-rw-r--r-- | src/java/org/apache/poi/sl/draw/DrawPictureShape.java | 35 | ||||
-rw-r--r-- | src/java/org/apache/poi/sl/draw/Drawable.java | 9 | ||||
-rw-r--r-- | src/java/org/apache/poi/sl/usermodel/PictureShape.java | 10 |
3 files changed, 39 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 70194bdcd7..84e7c91b33 100644 --- a/src/java/org/apache/poi/sl/draw/DrawPictureShape.java +++ b/src/java/org/apache/poi/sl/draw/DrawPictureShape.java @@ -44,20 +44,29 @@ public class DrawPictureShape extends DrawSimpleShape { @Override public void drawContent(Graphics2D graphics) { - PictureData data = getShape().getPictureData(); - if(data == null) return; - - Rectangle2D anchor = getAnchor(graphics, getShape()); - Insets insets = getShape().getClipping(); - - try { - ImageRenderer renderer = getImageRenderer(graphics, data.getContentType()); - renderer.loadImage(data.getData(), data.getContentType()); - renderer.drawImage(graphics, anchor, insets); - } catch (IOException e) { - LOG.log(POILogger.ERROR, "image can't be loaded/rendered.", e); + PictureShape<?,?> ps = getShape(); + + Rectangle2D anchor = getAnchor(graphics, ps); + Insets insets = ps.getClipping(); + + PictureData[] pics = { ps.getAlternativePictureData(), ps.getPictureData() }; + for (PictureData data : pics) { + if (data == null) { + continue; + } + + try { + ImageRenderer renderer = getImageRenderer(graphics, data.getContentType()); + if (renderer.canRender(data.getContentType())) { + renderer.loadImage(data.getData(), data.getContentType()); + renderer.drawImage(graphics, anchor, insets); + return; + } + } catch (IOException e) { + LOG.log(POILogger.ERROR, "image can't be loaded/rendered.", e); + } } - } + } /** * Returns an ImageRenderer for the PictureData diff --git a/src/java/org/apache/poi/sl/draw/Drawable.java b/src/java/org/apache/poi/sl/draw/Drawable.java index 4ec653ae50..d75b46dc40 100644 --- a/src/java/org/apache/poi/sl/draw/Drawable.java +++ b/src/java/org/apache/poi/sl/draw/Drawable.java @@ -136,8 +136,13 @@ public interface Drawable { * are printed. In this situation we need to have a way to access the current slide */ DrawableHint CURRENT_SLIDE = new DrawableHint(12); - - + + /** + * Stores a reference (WEAK_REFERENCE) to the buffered image, if the rendering is + * based on a buffered image + */ + DrawableHint BUFFERED_IMAGE = new DrawableHint(13); + /** * Apply 2-D transforms before drawing this shape. This includes rotation and flipping. * diff --git a/src/java/org/apache/poi/sl/usermodel/PictureShape.java b/src/java/org/apache/poi/sl/usermodel/PictureShape.java index c7fb629410..03b2f642a4 100644 --- a/src/java/org/apache/poi/sl/usermodel/PictureShape.java +++ b/src/java/org/apache/poi/sl/usermodel/PictureShape.java @@ -31,6 +31,16 @@ public interface PictureShape< PictureData getPictureData(); /** + * Returns an alternative picture data, e.g. an embedded SVG image + * + * @return an alternative picture data + * + * @since POI 4.1.0 + */ + default PictureData getAlternativePictureData() { return null; } + + + /** * Returns the clipping values as percent ratio relatively to the image size. * The clipping are returned as insets converted/scaled to 100000 (=100%). * |