]> source.dussan.org Git - poi.git/commitdiff
Update FtrHeader and CFHeader clone/create
authorNick Burch <nick@apache.org>
Sun, 12 Jul 2015 18:16:13 +0000 (18:16 +0000)
committerNick Burch <nick@apache.org>
Sun, 12 Jul 2015 18:16:13 +0000 (18:16 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1690500 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/record/CFHeaderRecord.java
src/java/org/apache/poi/hssf/record/common/FtrHeader.java
src/java/org/apache/poi/ss/util/CellRangeAddressBase.java

index 6ceba5723ed50832510b791fa63f13054c97ea11..b12c869f4ea9f1280c48f6f259b690f1771aec0a 100644 (file)
@@ -38,6 +38,7 @@ public class CFHeaderRecord extends StandardRecord {
 
     /** Creates new CFHeaderRecord */
     public CFHeaderRecord() {
+        field_3_enclosing_cell_range = new CellRangeAddress(0, 0, 0, 0);
         field_4_cell_ranges = new CellRangeAddressList();
     }
     public CFHeaderRecord(CellRangeAddress[] regions, int nRules) {
@@ -158,7 +159,7 @@ public class CFHeaderRecord extends StandardRecord {
         CFHeaderRecord result = new CFHeaderRecord();
         result.field_1_numcf = field_1_numcf;
         result.field_2_need_recalculation_and_id = field_2_need_recalculation_and_id;
-        result.field_3_enclosing_cell_range = field_3_enclosing_cell_range;
+        result.field_3_enclosing_cell_range = field_3_enclosing_cell_range.copy();
         result.field_4_cell_ranges = field_4_cell_ranges.copy();
         return result;
     }
index 1df69cfcb91f986fcc75794e5449e902f2f6a9dd..dba24f084a542e43b529a505288e1fdf2628c103 100644 (file)
@@ -18,6 +18,7 @@
 package org.apache.poi.hssf.record.common;
 
 import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.LittleEndianOutput;
 
 /**
@@ -32,19 +33,18 @@ public final class FtrHeader {
     private short recordType;
     /** This is a FrtFlags */
     private short grbitFrt;
-    /** MUST be 8 bytes and all zero TODO Correct this! */
-    private byte[] reserved;
+    /** The range of cells the parent record applies to, or 0 if N/A */
+    private CellRangeAddress associatedRange;
 
     public FtrHeader() {
-        reserved = new byte[8];
+        associatedRange = new CellRangeAddress(0, 0, 0, 0);
     }
 
     public FtrHeader(RecordInputStream in) {
         recordType = in.readShort();
         grbitFrt   = in.readShort();
 
-        reserved = new byte[8];
-        in.read(reserved, 0, 8);
+        associatedRange = new CellRangeAddress(in);
     }
 
     public String toString() {
@@ -59,7 +59,7 @@ public final class FtrHeader {
     public void serialize(LittleEndianOutput out) {
         out.writeShort(recordType);
         out.writeShort(grbitFrt);
-        out.write(reserved);
+        associatedRange.serialize(out);
     }
 
     public static int getDataSize() {
@@ -80,18 +80,18 @@ public final class FtrHeader {
         this.grbitFrt = grbitFrt;
     }
 
-    public byte[] getReserved() {
-        return reserved;
+    public CellRangeAddress getAssociatedRange() {
+        return associatedRange;
     }
-    public void setReserved(byte[] reserved) {
-        this.reserved = reserved;
+    public void setAssociatedRange(CellRangeAddress associatedRange) {
+        this.associatedRange = associatedRange;
     }
 
     public Object clone() {
         FtrHeader result = new FtrHeader();
         result.recordType = recordType;
         result.grbitFrt = grbitFrt;
-        result.reserved = reserved;
+        result.associatedRange = associatedRange.copy();
         return result;
     }
 }
\ No newline at end of file
index 2343226713b1f6ed5a0a63c351d4f1d89939d2d5..4b5b1042444ef635bf4b841b108c551d09d33fe0 100644 (file)
@@ -24,8 +24,6 @@ import org.apache.poi.ss.SpreadsheetVersion;
  * See OOO documentation: excelfileformat.pdf sec 2.5.14 - 'Cell Range Address'<p/>
  *
  * Common subclass of 8-bit and 16-bit versions
- *
- * @author Josh Micich
  */
 public abstract class CellRangeAddressBase {