diff options
author | PJ Fanning <fanningpj@apache.org> | 2023-01-13 12:08:02 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2023-01-13 12:08:02 +0000 |
commit | a00cc9ff2bbe1ecf30563a75fcccdbc7716a58c6 (patch) | |
tree | 155a31c23592a8f40a5d13d66cbc9f88cd168ec9 /poi-ooxml | |
parent | 56daedd9ddfb2b32a83685100084152d9a4f6c0d (diff) | |
download | poi-a00cc9ff2bbe1ecf30563a75fcccdbc7716a58c6.tar.gz poi-a00cc9ff2bbe1ecf30563a75fcccdbc7716a58c6.zip |
byte-buddy 1.12.22
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1906653 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r-- | poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFPicture.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFPicture.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFPicture.java index dc5d2bf09d..fdca695437 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFPicture.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFPicture.java @@ -23,13 +23,19 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertSame; import java.io.IOException; +import java.io.InputStream; import java.util.List; +import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream; +import org.apache.poi.POIDataSamples; import org.apache.poi.openxml4j.opc.ZipPackage; import org.apache.poi.ss.usermodel.BaseTestPicture; +import org.apache.poi.ss.usermodel.ClientAnchor; import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType; +import org.apache.poi.ss.usermodel.CreationHelper; import org.apache.poi.ss.usermodel.Drawing; import org.apache.poi.ss.usermodel.Picture; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.util.LocaleUtil; import org.apache.poi.xssf.XSSFITestDataProvider; import org.apache.poi.xssf.XSSFTestDataSamples; @@ -123,6 +129,46 @@ public final class TestXSSFPicture extends BaseTestPicture { multiRelationships(true, true); } + @Test + void resizeWhenAnchorPositionIsZeroed() throws IOException { + try ( + XSSFWorkbook workbook = new XSSFWorkbook(); + UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream() + ) { + XSSFSheet sheet = workbook.createSheet(); + CreationHelper helper = workbook.getCreationHelper(); + Drawing drawing = sheet.createDrawingPatriarch(); + + ClientAnchor anchor = helper.createClientAnchor(); + + final int pictureIndex; + try (InputStream stream = POIDataSamples.getOpenXML4JInstance() + .openResourceAsStream("thumbnail.jpg")) { + pictureIndex = workbook.addPicture(stream, Workbook.PICTURE_TYPE_JPEG); + } + final XSSFPicture pict = (XSSFPicture) drawing.createPicture( anchor, pictureIndex ); + + assertEquals(0, anchor.getCol1()); + assertEquals(0, anchor.getCol2()); + assertEquals(0, anchor.getRow1()); + assertEquals(0, anchor.getRow2()); + + pict.resize(); + pict.resize(0.1,0.1); + + assertEquals(0, anchor.getCol1()); + assertEquals(0, anchor.getCol2()); + assertEquals(0, anchor.getRow1()); + assertEquals(0, anchor.getRow2()); + + workbook.write(bos); + + try (XSSFWorkbook wb2 = new XSSFWorkbook(bos.toInputStream())) { + wb2.getAllPictures(); + } + } + } + private void multiRelationships(boolean tempFileParts, boolean encrypt) throws IOException { final boolean originalTempFileSetting = ZipPackage.useTempFilePackageParts(); final boolean originalEncryptSetting = ZipPackage.encryptTempFilePackageParts(); |