diff options
author | Nick Burch <nick@apache.org> | 2016-06-22 16:18:36 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2016-06-22 16:18:36 +0000 |
commit | ec07d025c189b003ab835e0a669c422790ebe0fe (patch) | |
tree | 6070f0d792f825511efce7e17c4feda1de72eec4 | |
parent | 5f921159e7ce49662a73d48c33f9f89af668d30b (diff) | |
download | poi-ec07d025c189b003ab835e0a669c422790ebe0fe.tar.gz poi-ec07d025c189b003ab835e0a669c422790ebe0fe.zip |
XSLFPictureData support for TIFF images - patch and tests from bug #59742 from Jens Popp
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1749732 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java | 3 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java | 15 | ||||
-rw-r--r-- | test-data/slideshow/testtiff.tif | bin | 0 -> 12236 bytes |
3 files changed, 18 insertions, 0 deletions
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java index 3431d1c241..9f705e0e04 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java @@ -249,6 +249,8 @@ public final class XSLFPictureData extends POIXMLDocumentPart implements Picture return PictureType.WPG; } else if (XSLFRelation.IMAGE_WDP.getContentType().equals(ct)) { return PictureType.WDP; + } else if (XSLFRelation.IMAGE_TIFF.getContentType().equals(ct)) { + return PictureType.TIFF; } else { return null; } @@ -267,6 +269,7 @@ public final class XSLFPictureData extends POIXMLDocumentPart implements Picture case BMP: return XSLFRelation.IMAGE_BMP; case WPG: return XSLFRelation.IMAGE_WPG; case WDP: return XSLFRelation.IMAGE_WDP; + case TIFF: return XSLFRelation.IMAGE_TIFF; default: return null; } } 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 2d7402f714..95d407a02f 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java @@ -32,6 +32,7 @@ import java.util.Map; import org.apache.poi.POIDataSamples;
import org.apache.poi.sl.usermodel.PictureData.PictureType;
+import org.apache.poi.util.IOUtils;
import org.apache.poi.xslf.XSLFTestDataSamples;
import org.junit.Test;
import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;
@@ -193,4 +194,18 @@ public class TestXSLFPictureShape { assertTrue(ppt2.getPictureData().isEmpty());
ppt2.close();
}
+
+ @Test
+ public void testTiffImageBug59742() throws Exception {
+ XMLSlideShow slideShow = new XMLSlideShow();
+ final InputStream tiffStream = _slTests.openResourceAsStream("testtiff.tif");
+ final byte[] pictureData = IOUtils.toByteArray(tiffStream);
+ IOUtils.closeQuietly(tiffStream);
+
+ XSLFPictureData pic = slideShow.addPicture(pictureData, PictureType.TIFF);
+ assertEquals("image/tiff", pic.getContentType());
+ assertEquals("image1.tiff", pic.getFileName());
+
+ slideShow.close();
+ }
}
\ No newline at end of file diff --git a/test-data/slideshow/testtiff.tif b/test-data/slideshow/testtiff.tif Binary files differnew file mode 100644 index 0000000000..99e6bdeb72 --- /dev/null +++ b/test-data/slideshow/testtiff.tif |