diff options
author | PJ Fanning <fanningpj@apache.org> | 2021-10-23 12:53:57 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2021-10-23 12:53:57 +0000 |
commit | 9f6f11023ad85c9a13d444164f76759d1ba0d4a3 (patch) | |
tree | b568e972a9699ee64153d56cca223ff4ea46354d | |
parent | 6a12c6cb256c7054c656c657bd056be4a32b030b (diff) | |
download | poi-9f6f11023ad85c9a13d444164f76759d1ba0d4a3.tar.gz poi-9f6f11023ad85c9a13d444164f76759d1ba0d4a3.zip |
fix mime type for pict files (image/x-pict)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894510 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFPictureData.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFPictureData.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFPictureData.java index 9842e9ea58..b42aeba053 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFPictureData.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFPictureData.java @@ -112,6 +112,37 @@ public final class TestXSSFPictureData { wb.close(); } + @Test + void testNewPictFormat() throws IOException { + try (XSSFWorkbook wb = new XSSFWorkbook()) { + XSSFSheet sheet = wb.createSheet(); + XSSFDrawing drawing = sheet.createDrawingPatriarch(); + + byte[] pictData = "test pict data".getBytes(LocaleUtil.CHARSET_1252); + + List<XSSFPictureData> pictures = wb.getAllPictures(); + assertEquals(0, pictures.size()); + + int pictIdx = wb.addPicture(pictData, XSSFWorkbook.PICTURE_TYPE_PICT); + assertEquals(1, pictures.size()); + assertEquals("pict", pictures.get(pictIdx).suggestFileExtension()); + assertArrayEquals(pictData, pictures.get(pictIdx).getData()); + + //TODO finish usermodel API for XSSFPicture + XSSFPicture p1 = drawing.createPicture(new XSSFClientAnchor(), pictIdx); + assertNotNull(p1); + + //check that the added pictures are accessible after write + try (XSSFWorkbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb)) { + List<XSSFPictureData> pictures2 = wbBack.getAllPictures(); + assertEquals(1, pictures2.size()); + + assertEquals("pict", pictures2.get(pictIdx).suggestFileExtension()); + assertArrayEquals(pictData, pictures2.get(pictIdx).getData()); + } + } + } + /** * Bug 53568: XSSFPicture.getPictureData() can return null. */ |