From 49a07a11e397ecf7018adecac98b64ca1e115e44 Mon Sep 17 00:00:00 2001 From: Evgeniy Berlog Date: Thu, 2 Aug 2012 19:52:47 +0000 Subject: [PATCH] fixed compilation for jdk 1.5 git-svn-id: https://svn.apache.org/repos/asf/poi/branches/gsoc2012@1368670 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hssf/record/EscherAggregate.java | 7 +++++-- .../org/apache/poi/hssf/usermodel/HSSFShapeGroup.java | 3 ++- .../org/apache/poi/hssf/model/TestDrawingShapes.java | 10 ++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/java/org/apache/poi/hssf/record/EscherAggregate.java b/src/java/org/apache/poi/hssf/record/EscherAggregate.java index 12f6b8ae9..a93b655ca 100644 --- a/src/java/org/apache/poi/hssf/record/EscherAggregate.java +++ b/src/java/org/apache/poi/hssf/record/EscherAggregate.java @@ -553,7 +553,9 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { drawing.setData(buf); temp += drawing.serialize(pos + temp, data); } else { - ContinueRecord drawing = new ContinueRecord(Arrays.copyOfRange(drawingData, j, Math.min(j + RecordInputStream.MAX_RECORD_DATA_SIZE, drawingData.length))); + byte[] buf = new byte[Math.min(RecordInputStream.MAX_RECORD_DATA_SIZE, drawingData.length - j)]; + System.arraycopy(drawingData, j, buf, 0, Math.min(RecordInputStream.MAX_RECORD_DATA_SIZE, drawingData.length - j)); + ContinueRecord drawing = new ContinueRecord(buf); temp += drawing.serialize(pos + temp, data); } } @@ -708,7 +710,8 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { public void setMainSpRecordId(int shapeId) { EscherContainerRecord dgContainer = getEscherContainer(); - EscherContainerRecord spContainer = (EscherContainerRecord) dgContainer.getChildById(EscherContainerRecord.SPGR_CONTAINER).getChild(0); + EscherContainerRecord spgrConatiner = (EscherContainerRecord) dgContainer.getChildById(EscherContainerRecord.SPGR_CONTAINER); + EscherContainerRecord spContainer = (EscherContainerRecord) spgrConatiner.getChild(0); EscherSpRecord sp = (EscherSpRecord) spContainer.getChildById(EscherSpRecord.RECORD_ID); sp.setShapeId(shapeId); } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java b/src/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java index f08625a01..4ee699562 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java @@ -346,7 +346,8 @@ public class HSSFShapeGroup extends HSSFShape implements HSSFShapeContainer { spgrContainer.setRecordId(EscherContainerRecord.SPGR_CONTAINER); spgrContainer.setOptions((short) 0x000F); EscherContainerRecord spContainer = new EscherContainerRecord(); - byte [] inSp = getEscherContainer().getChildById(EscherContainerRecord.SP_CONTAINER).serialize(); + EscherContainerRecord cont = getEscherContainer().getChildById(EscherContainerRecord.SP_CONTAINER); + byte [] inSp = cont.serialize(); spContainer.fillFields(inSp, 0, new DefaultEscherRecordFactory()); spgrContainer.addChildRecord(spContainer); diff --git a/src/testcases/org/apache/poi/hssf/model/TestDrawingShapes.java b/src/testcases/org/apache/poi/hssf/model/TestDrawingShapes.java index f9f35ce40..6a1638335 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestDrawingShapes.java +++ b/src/testcases/org/apache/poi/hssf/model/TestDrawingShapes.java @@ -351,13 +351,15 @@ public class TestDrawingShapes extends TestCase { String opt1Str = opt.toXml(); textbox.setFillColor(textbox.getFillColor()); - assertEquals(opt1Str, HSSFTestHelper.getEscherContainer(textbox).getChildById(EscherOptRecord.RECORD_ID).toXml()); + EscherContainerRecord container = HSSFTestHelper.getEscherContainer(textbox); + EscherOptRecord optRecord = container.getChildById(EscherOptRecord.RECORD_ID); + assertEquals(opt1Str, optRecord.toXml()); textbox.setLineStyle(textbox.getLineStyle()); - assertEquals(opt1Str, HSSFTestHelper.getEscherContainer(textbox).getChildById(EscherOptRecord.RECORD_ID).toXml()); + assertEquals(opt1Str, optRecord.toXml()); textbox.setLineWidth(textbox.getLineWidth()); - assertEquals(opt1Str, HSSFTestHelper.getEscherContainer(textbox).getChildById(EscherOptRecord.RECORD_ID).toXml()); + assertEquals(opt1Str, optRecord.toXml()); textbox.setLineStyleColor(textbox.getLineStyleColor()); - assertEquals(opt1Str, HSSFTestHelper.getEscherContainer(textbox).getChildById(EscherOptRecord.RECORD_ID).toXml()); + assertEquals(opt1Str, optRecord.toXml()); } public void testDgRecordNumShapes(){