From 78101afee8b1fc97682cb8a69db7aabb0fdcfb69 Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Tue, 9 Sep 2008 06:58:35 +0000 Subject: [PATCH] don't increment the number of shapes when cloning a sheet with drawings git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@693383 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/poi/ddf/EscherContainerRecord.java | 7 ++++--- src/java/org/apache/poi/hssf/model/Workbook.java | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/java/org/apache/poi/ddf/EscherContainerRecord.java b/src/java/org/apache/poi/ddf/EscherContainerRecord.java index bb188d538..9c204226e 100644 --- a/src/java/org/apache/poi/ddf/EscherContainerRecord.java +++ b/src/java/org/apache/poi/ddf/EscherContainerRecord.java @@ -243,10 +243,11 @@ public class EscherContainerRecord extends EscherRecord public void getRecordsById(short recordId, List out){ for(Iterator it = childRecords.iterator(); it.hasNext();) { Object er = it.next(); - if(er instanceof EscherContainerRecord) { - EscherContainerRecord c = (EscherContainerRecord)er; + EscherRecord r = (EscherRecord)er; + if(r instanceof EscherContainerRecord) { + EscherContainerRecord c = (EscherContainerRecord)r; c.getRecordsById(recordId, out ); - } else if (er instanceof EscherSpRecord){ + } else if (r.getRecordId() == recordId){ out.add(er); } } diff --git a/src/java/org/apache/poi/hssf/model/Workbook.java b/src/java/org/apache/poi/hssf/model/Workbook.java index fad9e4d0b..7976588d3 100644 --- a/src/java/org/apache/poi/hssf/model/Workbook.java +++ b/src/java/org/apache/poi/hssf/model/Workbook.java @@ -2493,6 +2493,8 @@ public final class Workbook implements Model { for(Iterator spIt = spRecords.iterator(); spIt.hasNext();) { EscherSpRecord sp = (EscherSpRecord)spIt.next(); int shapeId = drawingManager.allocateShapeId((short)dgId, dg); + //allocateShapeId increments the number of shapes. roll back to the previous value + dg.setNumShapes(dg.getNumShapes()-1); sp.setShapeId(shapeId); } }