Update FtrHeader and CFHeader clone/create

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1690500 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2015-07-12 18:16:13 +00:00
parent 13144e3301
commit 7359be141e
3 changed files with 13 additions and 14 deletions

View File

@ -38,6 +38,7 @@ public class CFHeaderRecord extends StandardRecord {
/** Creates new CFHeaderRecord */ /** Creates new CFHeaderRecord */
public CFHeaderRecord() { public CFHeaderRecord() {
field_3_enclosing_cell_range = new CellRangeAddress(0, 0, 0, 0);
field_4_cell_ranges = new CellRangeAddressList(); field_4_cell_ranges = new CellRangeAddressList();
} }
public CFHeaderRecord(CellRangeAddress[] regions, int nRules) { public CFHeaderRecord(CellRangeAddress[] regions, int nRules) {
@ -158,7 +159,7 @@ public class CFHeaderRecord extends StandardRecord {
CFHeaderRecord result = new CFHeaderRecord(); CFHeaderRecord result = new CFHeaderRecord();
result.field_1_numcf = field_1_numcf; result.field_1_numcf = field_1_numcf;
result.field_2_need_recalculation_and_id = field_2_need_recalculation_and_id; 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(); result.field_4_cell_ranges = field_4_cell_ranges.copy();
return result; return result;
} }

View File

@ -18,6 +18,7 @@
package org.apache.poi.hssf.record.common; package org.apache.poi.hssf.record.common;
import org.apache.poi.hssf.record.RecordInputStream; import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.LittleEndianOutput; import org.apache.poi.util.LittleEndianOutput;
/** /**
@ -32,19 +33,18 @@ public final class FtrHeader {
private short recordType; private short recordType;
/** This is a FrtFlags */ /** This is a FrtFlags */
private short grbitFrt; private short grbitFrt;
/** MUST be 8 bytes and all zero TODO Correct this! */ /** The range of cells the parent record applies to, or 0 if N/A */
private byte[] reserved; private CellRangeAddress associatedRange;
public FtrHeader() { public FtrHeader() {
reserved = new byte[8]; associatedRange = new CellRangeAddress(0, 0, 0, 0);
} }
public FtrHeader(RecordInputStream in) { public FtrHeader(RecordInputStream in) {
recordType = in.readShort(); recordType = in.readShort();
grbitFrt = in.readShort(); grbitFrt = in.readShort();
reserved = new byte[8]; associatedRange = new CellRangeAddress(in);
in.read(reserved, 0, 8);
} }
public String toString() { public String toString() {
@ -59,7 +59,7 @@ public final class FtrHeader {
public void serialize(LittleEndianOutput out) { public void serialize(LittleEndianOutput out) {
out.writeShort(recordType); out.writeShort(recordType);
out.writeShort(grbitFrt); out.writeShort(grbitFrt);
out.write(reserved); associatedRange.serialize(out);
} }
public static int getDataSize() { public static int getDataSize() {
@ -80,18 +80,18 @@ public final class FtrHeader {
this.grbitFrt = grbitFrt; this.grbitFrt = grbitFrt;
} }
public byte[] getReserved() { public CellRangeAddress getAssociatedRange() {
return reserved; return associatedRange;
} }
public void setReserved(byte[] reserved) { public void setAssociatedRange(CellRangeAddress associatedRange) {
this.reserved = reserved; this.associatedRange = associatedRange;
} }
public Object clone() { public Object clone() {
FtrHeader result = new FtrHeader(); FtrHeader result = new FtrHeader();
result.recordType = recordType; result.recordType = recordType;
result.grbitFrt = grbitFrt; result.grbitFrt = grbitFrt;
result.reserved = reserved; result.associatedRange = associatedRange.copy();
return result; return result;
} }
} }

View File

@ -24,8 +24,6 @@ import org.apache.poi.ss.SpreadsheetVersion;
* See OOO documentation: excelfileformat.pdf sec 2.5.14 - 'Cell Range Address'<p/> * See OOO documentation: excelfileformat.pdf sec 2.5.14 - 'Cell Range Address'<p/>
* *
* Common subclass of 8-bit and 16-bit versions * Common subclass of 8-bit and 16-bit versions
*
* @author Josh Micich
*/ */
public abstract class CellRangeAddressBase { public abstract class CellRangeAddressBase {