Bug 32032 - DrawingRecord.clone()
Summary: DrawingRecord.clone()
Status: RESOLVED DUPLICATE of bug 31795
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.5-FINAL
Hardware: Other other
: P3 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-02 22:30 UTC by Kevin LaVergne
Modified: 2008-01-09 03:06 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin LaVergne 2004-11-02 22:30:42 UTC
When attempting to clone a sheet that had an image on it, I got an Exception 
saying that DrawingRecord must implement a clone() method.  I added this clone() 
method and the image was copied onto the cloned sheets without any problems.

public Object clone()
{
    DrawingRecord rec = new DrawingRecord();
    rec.recordData = recordData;
    return rec;
}
Comment 1 eveloz 2006-09-15 17:17:30 UTC
We are trying to clone a worksheet that has AutoShapes and Pictures in it.  
After placing the clone method in the DrawingRecord class, we encountered a 
different exception as follows:

java.util.ConcurrentModificationException
	at java.util.AbstractList$Itr.checkForComodification
(AbstractList.java:462)
	at java.util.AbstractList$Itr.next(AbstractList.java:433)
	at org.apache.poi.hssf.record.ObjRecord.clone(ObjRecord.java:182)
	at org.apache.poi.hssf.model.Sheet.cloneSheet(Sheet.java(Compiled 
Code))
	at org.apache.poi.hssf.usermodel.HSSFSheet.cloneSheet
(HSSFSheet.java:114)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.cloneSheet
(HSSFWorkbook.java:337)


After debugging through it, we found out that this error happens in the 
ObjectRecord clone method().  We modified the clone method as follows:

public Object clone()
{
        ObjRecord rec = new ObjRecord();
        rec.subrecords = new ArrayList();    	
        List currObj = this.subrecords;
        for ( Iterator iterator = currObj.iterator(); iterator.hasNext(); )
        {
        	rec.subrecords.add(( (Record) iterator.next() ).clone());
        }
        return rec;
}

After doing this, the worksheet was cloned with the AutoShapes and Pictures
Comment 2 Nick Burch 2008-01-09 03:06:10 UTC

*** This bug has been marked as a duplicate of 31795 ***