fixed cloning of sheets with charts

git-svn-id: https://svn.apache.org/repos/asf/poi/branches/gsoc2012@1365255 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Evgeniy Berlog 2012-07-24 19:42:28 +00:00
parent 22c5121d98
commit 5e17fbb130
2 changed files with 7 additions and 8 deletions

View File

@ -351,12 +351,7 @@ public final class InternalSheet {
continue; continue;
} }
if (rb instanceof EscherAggregate){ if (rb instanceof EscherAggregate){
// EscherAggregate is used only as a container for SODRAWING and OBJ record combinations rb = new DrawingRecord();
// So, if the container is empty, there is no reason to clone this record
// See https://issues.apache.org/bugzilla/show_bug.cgi?id=49529
// if (0 == rb.getRecordSize()){
continue;
// }
} }
Record rec = (Record) ((Record) rb).clone(); Record rec = (Record) ((Record) rb).clone();
clonedRecords.add(rec); clonedRecords.add(rec);

View File

@ -117,10 +117,14 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
HSSFSheet cloneSheet(HSSFWorkbook workbook) { HSSFSheet cloneSheet(HSSFWorkbook workbook) {
this.getDrawingPatriarch();/**Aggregate drawing records**/ this.getDrawingPatriarch();/**Aggregate drawing records**/
HSSFSheet sheet = new HSSFSheet(workbook, _sheet.cloneSheet()); HSSFSheet sheet = new HSSFSheet(workbook, _sheet.cloneSheet());
int pos = sheet._sheet.findFirstRecordLocBySid(DrawingRecord.sid);
DrawingRecord dr = (DrawingRecord) sheet._sheet.findFirstRecordBySid(DrawingRecord.sid);
if (null != dr){
sheet._sheet.getRecords().remove(dr);
}
if (getDrawingPatriarch() != null){ if (getDrawingPatriarch() != null){
int insertPos = sheet._sheet.findFirstRecordLocBySid(WindowTwoRecord.sid);
HSSFPatriarch patr = HSSFPatriarch.createPatriarch(this.getDrawingPatriarch(), sheet); HSSFPatriarch patr = HSSFPatriarch.createPatriarch(this.getDrawingPatriarch(), sheet);
sheet._sheet.getRecords().add(insertPos, patr._getBoundAggregate()); sheet._sheet.getRecords().add(pos, patr._getBoundAggregate());
sheet._patriarch = patr; sheet._patriarch = patr;
} }
return sheet; return sheet;