]> source.dussan.org Git - poi.git/commitdiff
SharedFormula clone patch that was already applied to HEAD
authorDanny Mui <dmui@apache.org>
Sat, 28 Jun 2003 00:21:47 +0000 (00:21 +0000)
committerDanny Mui <dmui@apache.org>
Sat, 28 Jun 2003 00:21:47 +0000 (00:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/branches/REL_2_BRANCH@353171 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/record/FormulaRecord.java
src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java
src/java/org/apache/poi/hssf/record/formula/ExpPtg.java

index ad926be474243613197623e35d6c9321a789ca3b..c1ed74a9d54cf5bff15c37f2a52c8a9044da2843 100644 (file)
@@ -607,8 +607,8 @@ public class FormulaRecord
       if (field_8_parsed_expr != null)
         size = field_8_parsed_expr.size();
       for (int i=0; i< size; i++) {
-        Ptg ptg = (Ptg)((Ptg)field_8_parsed_expr.get(i)).clone();
-        rec.field_8_parsed_expr.set(i, ptg);
+        Ptg ptg = (Ptg)((Ptg)field_8_parsed_expr.get(i)).clone();        
+        rec.field_8_parsed_expr.add(i, ptg);
       }
       rec.all_data = all_data;
       return rec;
index 7d5b0b048d769b98ce01dc78deb3c8d396ede4dd..9a7575c21ee41395179ccf4e2a345d322f375da7 100644 (file)
@@ -82,6 +82,19 @@ public class FormulaRecordAggregate
         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 )
@@ -221,7 +234,10 @@ public class FormulaRecordAggregate
      * @see java.lang.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;
    }
 
+   /* 
+    * 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;
+   }
+
 }
index 576bce331603b9075d9500be036c1bd12b8fd869..b100a1a762a6e2a1cfd34c882af5f4384d3efa9a 100644 (file)
@@ -110,7 +110,10 @@ public class ExpPtg
     public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;}
     
     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);
     }
 
 }