SharedFormula clone patch that was already applied to HEAD

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/branches/REL_2_BRANCH@353171 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Danny Muid 2003-06-28 00:21:47 +00:00
parent c7f251cdca
commit a6e14b5490
3 changed files with 33 additions and 4 deletions

View File

@ -608,7 +608,7 @@ public class FormulaRecord
size = field_8_parsed_expr.size(); size = field_8_parsed_expr.size();
for (int i=0; i< size; i++) { for (int i=0; i< size; i++) {
Ptg ptg = (Ptg)((Ptg)field_8_parsed_expr.get(i)).clone(); Ptg ptg = (Ptg)((Ptg)field_8_parsed_expr.get(i)).clone();
rec.field_8_parsed_expr.set(i, ptg); rec.field_8_parsed_expr.add(i, ptg);
} }
rec.all_data = all_data; rec.all_data = all_data;
return rec; return rec;

View File

@ -82,6 +82,19 @@ public class FormulaRecordAggregate
this.stringRecord = stringRecord; this.stringRecord = stringRecord;
} }
/**
* Used only in the clone
* @param formulaRecord
* @param stringRecord
* @param sharedRecord
*/
public FormulaRecordAggregate( FormulaRecord formulaRecord, StringRecord stringRecord, SharedFormulaRecord sharedRecord)
{
this.formulaRecord = formulaRecord;
this.stringRecord = stringRecord;
this.sharedFormulaRecord = sharedRecord;
}
protected void validateSid( short id ) protected void validateSid( short id )
@ -221,7 +234,10 @@ public class FormulaRecordAggregate
* @see java.lang.Object#clone() * @see java.lang.Object#clone()
*/ */
public Object clone() { public Object clone() {
return new FormulaRecordAggregate((FormulaRecord) this.formulaRecord.clone(), (StringRecord) this.stringRecord.clone()); StringRecord clonedString = (stringRecord == null) ? null : (StringRecord)stringRecord.clone();
SharedFormulaRecord clonedShared = (sharedFormulaRecord == null) ? null : (SharedFormulaRecord)sharedFormulaRecord.clone();
return new FormulaRecordAggregate((FormulaRecord) this.formulaRecord.clone(), clonedString, clonedShared);
} }
@ -241,4 +257,14 @@ public class FormulaRecordAggregate
this.sharedFormulaRecord = sharedFormulaRecord; this.sharedFormulaRecord = sharedFormulaRecord;
} }
/*
* Setting to true so that this value does not abort the whole ValueAggregation
* (non-Javadoc)
* @see org.apache.poi.hssf.record.Record#isInValueSection()
*/
public boolean isInValueSection() {
return true;
}
} }

View File

@ -110,7 +110,10 @@ public class ExpPtg
public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;} public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;}
public Object clone() { public Object clone() {
throw new RuntimeException("NO IDEA SHARED FORMULA EXP PTG"); //can't clone one that doesnt have data can we??
if (this.existing == null) throw new RuntimeException("NO IDEA SHARED FORMULA EXP PTG");
return new ExpPtg(this.existing, 0);
} }
} }