From c3f9a6e68274fbcd95a2f4a91a7c3cb70fba9c00 Mon Sep 17 00:00:00 2001 From: Evgeniy Berlog Date: Tue, 14 Aug 2012 21:11:53 +0000 Subject: [PATCH] fixed bug 53432 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1373110 13f79535-47bb-0310-9956-ffa450edef68 --- .../hssf/record/AbstractEscherHolderRecord.java | 6 ++++-- .../org/apache/poi/hssf/usermodel/TestBugs.java | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java b/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java index 78893e1aa..078f0205d 100644 --- a/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java +++ b/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java @@ -257,7 +257,9 @@ public abstract class AbstractEscherHolderRecord extends Record { */ public void decode() { - byte[] rawData = getRawData(); - convertToEscherRecords(0, rawData.length, rawData ); + if (null == escherRecords || 0 == escherRecords.size()){ + byte[] rawData = getRawData(); + convertToEscherRecords(0, rawData.length, rawData ); + } } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 69f0e3425..9c566b05b 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -2268,4 +2268,19 @@ if(1==2) { HSSFSheet sh2 = wb.cloneSheet(0); assertNotNull(sh2.getDrawingPatriarch()); } + + public void test53432(){ + Workbook wb = new HSSFWorkbook(); //or new HSSFWorkbook(); + wb.addPicture(new byte[]{123,22}, Workbook.PICTURE_TYPE_JPEG); + assertEquals(wb.getAllPictures().size(), 1); + + wb = new HSSFWorkbook(); + wb = writeOutAndReadBack((HSSFWorkbook) wb); + assertEquals(wb.getAllPictures().size(), 0); + wb.addPicture(new byte[]{123,22}, Workbook.PICTURE_TYPE_JPEG); + assertEquals(wb.getAllPictures().size(), 1); + + wb = writeOutAndReadBack((HSSFWorkbook) wb); + assertEquals(wb.getAllPictures().size(), 1); + } }