You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/05/22 20:56:49 UTC
svn commit: r1890120 [11/43] - in /poi/trunk/poi/src:
main/java/org/apache/poi/ main/java/org/apache/poi/ddf/
main/java/org/apache/poi/extractor/ main/java/org/apache/poi/hpsf/
main/java/org/apache/poi/hssf/ main/java/org/apache/poi/hssf/dev/
main/java...
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/CatLabRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/CatLabRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/CatLabRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/CatLabRecord.java Sat May 22 20:56:44 2021
@@ -30,80 +30,80 @@ import org.apache.poi.util.LittleEndianO
* CATLAB - Category Labels (0x0856)
*/
public final class CatLabRecord extends StandardRecord {
- public static final short sid = 0x0856;
+ public static final short sid = 0x0856;
- private short rt;
- private short grbitFrt;
- private short wOffset;
- private short at;
- private short grbit;
- private Short unused;
-
- public CatLabRecord(CatLabRecord other) {
- super(other);
- rt = other.rt;
- grbitFrt = other.grbitFrt;
- wOffset = other.wOffset;
- at = other.at;
- grbit = other.grbit;
- unused = other.unused;
- }
-
- public CatLabRecord(RecordInputStream in) {
- rt = in.readShort();
- grbitFrt = in.readShort();
- wOffset = in.readShort();
- at = in.readShort();
- grbit = in.readShort();
-
- // Often, but not always has an unused short at the end
- if(in.available() == 0) {
- unused = null;
- } else {
- unused = in.readShort();
- }
- }
-
- @Override
- protected int getDataSize() {
- return 2 + 2 + 2 + 2 + 2 + (unused==null? 0:2);
- }
-
- @Override
- public short getSid() {
- return sid;
- }
-
- @Override
- public void serialize(LittleEndianOutput out) {
- out.writeShort(rt);
- out.writeShort(grbitFrt);
- out.writeShort(wOffset);
- out.writeShort(at);
- out.writeShort(grbit);
- if(unused != null)
- out.writeShort(unused);
- }
-
- @Override
- public CatLabRecord copy() {
- return new CatLabRecord(this);
- }
-
- @Override
- public HSSFRecordTypes getGenericRecordType() {
- return HSSFRecordTypes.CAT_LAB;
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties(
- "rt", () -> rt,
- "grbitFrt", () -> grbitFrt,
- "wOffset", () -> wOffset,
- "at", () -> at,
- "grbit", () -> grbit,
- "unused", () -> unused
- );
- }
+ private short rt;
+ private short grbitFrt;
+ private short wOffset;
+ private short at;
+ private short grbit;
+ private Short unused;
+
+ public CatLabRecord(CatLabRecord other) {
+ super(other);
+ rt = other.rt;
+ grbitFrt = other.grbitFrt;
+ wOffset = other.wOffset;
+ at = other.at;
+ grbit = other.grbit;
+ unused = other.unused;
+ }
+
+ public CatLabRecord(RecordInputStream in) {
+ rt = in.readShort();
+ grbitFrt = in.readShort();
+ wOffset = in.readShort();
+ at = in.readShort();
+ grbit = in.readShort();
+
+ // Often, but not always has an unused short at the end
+ if(in.available() == 0) {
+ unused = null;
+ } else {
+ unused = in.readShort();
+ }
+ }
+
+ @Override
+ protected int getDataSize() {
+ return 2 + 2 + 2 + 2 + 2 + (unused==null? 0:2);
+ }
+
+ @Override
+ public short getSid() {
+ return sid;
+ }
+
+ @Override
+ public void serialize(LittleEndianOutput out) {
+ out.writeShort(rt);
+ out.writeShort(grbitFrt);
+ out.writeShort(wOffset);
+ out.writeShort(at);
+ out.writeShort(grbit);
+ if(unused != null)
+ out.writeShort(unused);
+ }
+
+ @Override
+ public CatLabRecord copy() {
+ return new CatLabRecord(this);
+ }
+
+ @Override
+ public HSSFRecordTypes getGenericRecordType() {
+ return HSSFRecordTypes.CAT_LAB;
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "rt", () -> rt,
+ "grbitFrt", () -> grbitFrt,
+ "wOffset", () -> wOffset,
+ "at", () -> at,
+ "grbit", () -> grbit,
+ "unused", () -> unused
+ );
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartEndBlockRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartEndBlockRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartEndBlockRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartEndBlockRecord.java Sat May 22 20:56:44 2021
@@ -30,73 +30,73 @@ import org.apache.poi.util.LittleEndianO
* ENDBLOCK - Chart Future Record Type End Block (0x0853)
*/
public final class ChartEndBlockRecord extends StandardRecord {
- public static final short sid = 0x0853;
+ public static final short sid = 0x0853;
- private short rt;
- private short grbitFrt;
- private short iObjectKind;
- private byte[] unused;
-
- public ChartEndBlockRecord() {}
-
- public ChartEndBlockRecord(ChartEndBlockRecord other) {
- super(other);
- rt = other.rt;
- grbitFrt = other.grbitFrt;
- iObjectKind = other.iObjectKind;
- unused = (other.unused == null) ? null : other.unused.clone();
- }
-
- public ChartEndBlockRecord(RecordInputStream in) {
- rt = in.readShort();
- grbitFrt = in.readShort();
- iObjectKind = in.readShort();
-
- // Often, but not always has 6 unused bytes at the end
- if(in.available() == 0) {
- unused = new byte[0];
- } else {
- unused = new byte[6];
- in.readFully(unused);
- }
- }
-
- @Override
- protected int getDataSize() {
- return 2 + 2 + 2 + unused.length;
- }
-
- @Override
- public short getSid() {
- return sid;
- }
-
- @Override
- public void serialize(LittleEndianOutput out) {
- out.writeShort(rt);
- out.writeShort(grbitFrt);
- out.writeShort(iObjectKind);
- // 6 bytes unused
- out.write(unused);
- }
-
- @Override
- public ChartEndBlockRecord copy() {
- return new ChartEndBlockRecord(this);
- }
-
- @Override
- public HSSFRecordTypes getGenericRecordType() {
- return HSSFRecordTypes.CHART_END_BLOCK;
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties(
- "rt", () -> rt,
- "grbitFrt", () -> grbitFrt,
- "iObjectKind", () -> iObjectKind,
- "unused", () -> unused
- );
- }
+ private short rt;
+ private short grbitFrt;
+ private short iObjectKind;
+ private byte[] unused;
+
+ public ChartEndBlockRecord() {}
+
+ public ChartEndBlockRecord(ChartEndBlockRecord other) {
+ super(other);
+ rt = other.rt;
+ grbitFrt = other.grbitFrt;
+ iObjectKind = other.iObjectKind;
+ unused = (other.unused == null) ? null : other.unused.clone();
+ }
+
+ public ChartEndBlockRecord(RecordInputStream in) {
+ rt = in.readShort();
+ grbitFrt = in.readShort();
+ iObjectKind = in.readShort();
+
+ // Often, but not always has 6 unused bytes at the end
+ if(in.available() == 0) {
+ unused = new byte[0];
+ } else {
+ unused = new byte[6];
+ in.readFully(unused);
+ }
+ }
+
+ @Override
+ protected int getDataSize() {
+ return 2 + 2 + 2 + unused.length;
+ }
+
+ @Override
+ public short getSid() {
+ return sid;
+ }
+
+ @Override
+ public void serialize(LittleEndianOutput out) {
+ out.writeShort(rt);
+ out.writeShort(grbitFrt);
+ out.writeShort(iObjectKind);
+ // 6 bytes unused
+ out.write(unused);
+ }
+
+ @Override
+ public ChartEndBlockRecord copy() {
+ return new ChartEndBlockRecord(this);
+ }
+
+ @Override
+ public HSSFRecordTypes getGenericRecordType() {
+ return HSSFRecordTypes.CHART_END_BLOCK;
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "rt", () -> rt,
+ "grbitFrt", () -> grbitFrt,
+ "iObjectKind", () -> iObjectKind,
+ "unused", () -> unused
+ );
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartEndObjectRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartEndObjectRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartEndObjectRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartEndObjectRecord.java Sat May 22 20:56:44 2021
@@ -30,74 +30,74 @@ import org.apache.poi.util.LittleEndianO
* ENDOBJECT - Chart Future Record Type End Object (0x0855)
*/
public final class ChartEndObjectRecord extends StandardRecord {
- public static final short sid = 0x0855;
+ public static final short sid = 0x0855;
- private short rt;
- private short grbitFrt;
- private short iObjectKind;
- private byte[] reserved;
-
- public ChartEndObjectRecord(ChartEndObjectRecord other) {
- super(other);
- rt = other.rt;
- grbitFrt = other.grbitFrt;
- iObjectKind = other.iObjectKind;
- reserved = (other.reserved == null) ? null : other.reserved.clone();
- }
-
- public ChartEndObjectRecord(RecordInputStream in) {
- rt = in.readShort();
- grbitFrt = in.readShort();
- iObjectKind = in.readShort();
-
- // The spec says that there should be 6 bytes at the
- // end, which must be there and must be zero
- // However, sometimes Excel forgets them...
- reserved = new byte[6];
- if(in.available() == 0) {
- // They've gone missing...
- } else {
- // Read the reserved bytes
- in.readFully(reserved);
- }
- }
-
- @Override
- protected int getDataSize() {
- return 2 + 2 + 2 + 6;
- }
-
- @Override
- public short getSid() {
- return sid;
- }
-
- @Override
- public void serialize(LittleEndianOutput out) {
- out.writeShort(rt);
- out.writeShort(grbitFrt);
- out.writeShort(iObjectKind);
- // 6 bytes unused
- out.write(reserved);
- }
-
- @Override
- public ChartEndObjectRecord copy() {
- return new ChartEndObjectRecord(this);
- }
-
- @Override
- public HSSFRecordTypes getGenericRecordType() {
- return HSSFRecordTypes.CHART_END_OBJECT;
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties(
- "rt", () -> rt,
- "grbitFrt", () -> grbitFrt,
- "iObjectKind", () -> iObjectKind,
- "reserved", () -> reserved
- );
- }
+ private short rt;
+ private short grbitFrt;
+ private short iObjectKind;
+ private byte[] reserved;
+
+ public ChartEndObjectRecord(ChartEndObjectRecord other) {
+ super(other);
+ rt = other.rt;
+ grbitFrt = other.grbitFrt;
+ iObjectKind = other.iObjectKind;
+ reserved = (other.reserved == null) ? null : other.reserved.clone();
+ }
+
+ public ChartEndObjectRecord(RecordInputStream in) {
+ rt = in.readShort();
+ grbitFrt = in.readShort();
+ iObjectKind = in.readShort();
+
+ // The spec says that there should be 6 bytes at the
+ // end, which must be there and must be zero
+ // However, sometimes Excel forgets them...
+ reserved = new byte[6];
+ if(in.available() == 0) {
+ // They've gone missing...
+ } else {
+ // Read the reserved bytes
+ in.readFully(reserved);
+ }
+ }
+
+ @Override
+ protected int getDataSize() {
+ return 2 + 2 + 2 + 6;
+ }
+
+ @Override
+ public short getSid() {
+ return sid;
+ }
+
+ @Override
+ public void serialize(LittleEndianOutput out) {
+ out.writeShort(rt);
+ out.writeShort(grbitFrt);
+ out.writeShort(iObjectKind);
+ // 6 bytes unused
+ out.write(reserved);
+ }
+
+ @Override
+ public ChartEndObjectRecord copy() {
+ return new ChartEndObjectRecord(this);
+ }
+
+ @Override
+ public HSSFRecordTypes getGenericRecordType() {
+ return HSSFRecordTypes.CHART_END_OBJECT;
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "rt", () -> rt,
+ "grbitFrt", () -> grbitFrt,
+ "iObjectKind", () -> iObjectKind,
+ "reserved", () -> reserved
+ );
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartFRTInfoRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartFRTInfoRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartFRTInfoRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartFRTInfoRecord.java Sat May 22 20:56:44 2021
@@ -32,101 +32,101 @@ import org.apache.poi.util.LittleEndianO
* CHARTFRTINFO - Chart Future Record Type Info (0x0850)
*/
public final class ChartFRTInfoRecord extends StandardRecord {
- public static final short sid = 0x850;
+ public static final short sid = 0x850;
- private short rt;
- private short grbitFrt;
- private byte verOriginator;
- private byte verWriter;
- private CFRTID[] rgCFRTID;
-
- private static final class CFRTID {
- public static final int ENCODED_SIZE = 4;
- private int rtFirst;
- private int rtLast;
-
- public CFRTID(CFRTID other) {
- rtFirst = other.rtFirst;
- rtLast = other.rtLast;
- }
-
- public CFRTID(LittleEndianInput in) {
- rtFirst = in.readShort();
- rtLast = in.readShort();
- }
-
- public void serialize(LittleEndianOutput out) {
- out.writeShort(rtFirst);
- out.writeShort(rtLast);
- }
- }
-
- public ChartFRTInfoRecord(ChartFRTInfoRecord other) {
- super(other);
- rt = other.rt;
- grbitFrt = other.grbitFrt;
- verOriginator = other.verOriginator;
- verWriter = other.verWriter;
- if (other.rgCFRTID != null) {
- rgCFRTID = Stream.of(other.rgCFRTID).map(CFRTID::new).toArray(CFRTID[]::new);
- }
- }
-
- public ChartFRTInfoRecord(RecordInputStream in) {
- rt = in.readShort();
- grbitFrt = in.readShort();
- verOriginator = in.readByte();
- verWriter = in.readByte();
- int cCFRTID = in.readShort();
-
- rgCFRTID = new CFRTID[cCFRTID];
- for (int i = 0; i < cCFRTID; i++) {
- rgCFRTID[i] = new CFRTID(in);
- }
- }
-
- @Override
- protected int getDataSize() {
- return 2 + 2 + 1 + 1 + 2 + rgCFRTID.length * CFRTID.ENCODED_SIZE;
- }
-
- @Override
- public short getSid() {
- return sid;
- }
-
- @Override
- public void serialize(LittleEndianOutput out) {
-
- out.writeShort(rt);
- out.writeShort(grbitFrt);
- out.writeByte(verOriginator);
- out.writeByte(verWriter);
- out.writeShort(rgCFRTID.length);
-
- for (CFRTID cfrtid : rgCFRTID) {
- cfrtid.serialize(out);
- }
- }
-
- @Override
- public ChartFRTInfoRecord copy() {
- return new ChartFRTInfoRecord(this);
- }
-
- @Override
- public HSSFRecordTypes getGenericRecordType() {
- return HSSFRecordTypes.CHART_FRT_INFO;
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties(
- "rt", () -> rt,
- "grbitFrt", () -> grbitFrt,
- "verOriginator", () -> verOriginator,
- "verWriter", () -> verWriter,
- "rgCFRTIDs", () -> rgCFRTID
- );
- }
+ private short rt;
+ private short grbitFrt;
+ private byte verOriginator;
+ private byte verWriter;
+ private CFRTID[] rgCFRTID;
+
+ private static final class CFRTID {
+ public static final int ENCODED_SIZE = 4;
+ private int rtFirst;
+ private int rtLast;
+
+ public CFRTID(CFRTID other) {
+ rtFirst = other.rtFirst;
+ rtLast = other.rtLast;
+ }
+
+ public CFRTID(LittleEndianInput in) {
+ rtFirst = in.readShort();
+ rtLast = in.readShort();
+ }
+
+ public void serialize(LittleEndianOutput out) {
+ out.writeShort(rtFirst);
+ out.writeShort(rtLast);
+ }
+ }
+
+ public ChartFRTInfoRecord(ChartFRTInfoRecord other) {
+ super(other);
+ rt = other.rt;
+ grbitFrt = other.grbitFrt;
+ verOriginator = other.verOriginator;
+ verWriter = other.verWriter;
+ if (other.rgCFRTID != null) {
+ rgCFRTID = Stream.of(other.rgCFRTID).map(CFRTID::new).toArray(CFRTID[]::new);
+ }
+ }
+
+ public ChartFRTInfoRecord(RecordInputStream in) {
+ rt = in.readShort();
+ grbitFrt = in.readShort();
+ verOriginator = in.readByte();
+ verWriter = in.readByte();
+ int cCFRTID = in.readShort();
+
+ rgCFRTID = new CFRTID[cCFRTID];
+ for (int i = 0; i < cCFRTID; i++) {
+ rgCFRTID[i] = new CFRTID(in);
+ }
+ }
+
+ @Override
+ protected int getDataSize() {
+ return 2 + 2 + 1 + 1 + 2 + rgCFRTID.length * CFRTID.ENCODED_SIZE;
+ }
+
+ @Override
+ public short getSid() {
+ return sid;
+ }
+
+ @Override
+ public void serialize(LittleEndianOutput out) {
+
+ out.writeShort(rt);
+ out.writeShort(grbitFrt);
+ out.writeByte(verOriginator);
+ out.writeByte(verWriter);
+ out.writeShort(rgCFRTID.length);
+
+ for (CFRTID cfrtid : rgCFRTID) {
+ cfrtid.serialize(out);
+ }
+ }
+
+ @Override
+ public ChartFRTInfoRecord copy() {
+ return new ChartFRTInfoRecord(this);
+ }
+
+ @Override
+ public HSSFRecordTypes getGenericRecordType() {
+ return HSSFRecordTypes.CHART_FRT_INFO;
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "rt", () -> rt,
+ "grbitFrt", () -> grbitFrt,
+ "verOriginator", () -> verOriginator,
+ "verWriter", () -> verWriter,
+ "rgCFRTIDs", () -> rgCFRTID
+ );
+ }
}
\ No newline at end of file
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartStartBlockRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartStartBlockRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartStartBlockRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartStartBlockRecord.java Sat May 22 20:56:44 2021
@@ -30,75 +30,75 @@ import org.apache.poi.util.LittleEndianO
* STARTBLOCK - Chart Future Record Type Start Block (0x0852)
*/
public final class ChartStartBlockRecord extends StandardRecord {
- public static final short sid = 0x0852;
+ public static final short sid = 0x0852;
- private short rt;
- private short grbitFrt;
- private short iObjectKind;
- private short iObjectContext;
- private short iObjectInstance1;
- private short iObjectInstance2;
-
- public ChartStartBlockRecord() {}
-
- public ChartStartBlockRecord(ChartStartBlockRecord other) {
- super(other);
- rt = other.rt;
- grbitFrt = other.grbitFrt;
- iObjectKind = other.iObjectKind;
- iObjectContext = other.iObjectContext;
- iObjectInstance1 = other.iObjectInstance1;
- iObjectInstance2 = other.iObjectInstance2;
- }
-
- public ChartStartBlockRecord(RecordInputStream in) {
- rt = in.readShort();
- grbitFrt = in.readShort();
- iObjectKind = in.readShort();
- iObjectContext = in.readShort();
- iObjectInstance1 = in.readShort();
- iObjectInstance2 = in.readShort();
- }
-
- @Override
- protected int getDataSize() {
- return 2 + 2 + 2 + 2 + 2 + 2;
- }
-
- @Override
- public short getSid() {
- return sid;
- }
-
- @Override
- public void serialize(LittleEndianOutput out) {
- out.writeShort(rt);
- out.writeShort(grbitFrt);
- out.writeShort(iObjectKind);
- out.writeShort(iObjectContext);
- out.writeShort(iObjectInstance1);
- out.writeShort(iObjectInstance2);
- }
-
- @Override
- public ChartStartBlockRecord copy() {
- return new ChartStartBlockRecord(this);
- }
-
- @Override
- public HSSFRecordTypes getGenericRecordType() {
- return HSSFRecordTypes.CHART_START_BLOCK;
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties(
- "rt", () -> rt,
- "grbitFrt", () -> grbitFrt,
- "iObjectKind", () -> iObjectKind,
- "iObjectContext", () -> iObjectContext,
- "iObjectInstance1", () -> iObjectInstance1,
- "iObjectInstance2", () -> iObjectInstance2
- );
- }
+ private short rt;
+ private short grbitFrt;
+ private short iObjectKind;
+ private short iObjectContext;
+ private short iObjectInstance1;
+ private short iObjectInstance2;
+
+ public ChartStartBlockRecord() {}
+
+ public ChartStartBlockRecord(ChartStartBlockRecord other) {
+ super(other);
+ rt = other.rt;
+ grbitFrt = other.grbitFrt;
+ iObjectKind = other.iObjectKind;
+ iObjectContext = other.iObjectContext;
+ iObjectInstance1 = other.iObjectInstance1;
+ iObjectInstance2 = other.iObjectInstance2;
+ }
+
+ public ChartStartBlockRecord(RecordInputStream in) {
+ rt = in.readShort();
+ grbitFrt = in.readShort();
+ iObjectKind = in.readShort();
+ iObjectContext = in.readShort();
+ iObjectInstance1 = in.readShort();
+ iObjectInstance2 = in.readShort();
+ }
+
+ @Override
+ protected int getDataSize() {
+ return 2 + 2 + 2 + 2 + 2 + 2;
+ }
+
+ @Override
+ public short getSid() {
+ return sid;
+ }
+
+ @Override
+ public void serialize(LittleEndianOutput out) {
+ out.writeShort(rt);
+ out.writeShort(grbitFrt);
+ out.writeShort(iObjectKind);
+ out.writeShort(iObjectContext);
+ out.writeShort(iObjectInstance1);
+ out.writeShort(iObjectInstance2);
+ }
+
+ @Override
+ public ChartStartBlockRecord copy() {
+ return new ChartStartBlockRecord(this);
+ }
+
+ @Override
+ public HSSFRecordTypes getGenericRecordType() {
+ return HSSFRecordTypes.CHART_START_BLOCK;
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "rt", () -> rt,
+ "grbitFrt", () -> grbitFrt,
+ "iObjectKind", () -> iObjectKind,
+ "iObjectContext", () -> iObjectContext,
+ "iObjectInstance1", () -> iObjectInstance1,
+ "iObjectInstance2", () -> iObjectInstance2
+ );
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartStartObjectRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartStartObjectRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartStartObjectRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartStartObjectRecord.java Sat May 22 20:56:44 2021
@@ -30,73 +30,73 @@ import org.apache.poi.util.LittleEndianO
* STARTOBJECT - Chart Future Record Type Start Object (0x0854)
*/
public final class ChartStartObjectRecord extends StandardRecord {
- public static final short sid = 0x0854;
+ public static final short sid = 0x0854;
- private short rt;
- private short grbitFrt;
- private short iObjectKind;
- private short iObjectContext;
- private short iObjectInstance1;
- private short iObjectInstance2;
-
- public ChartStartObjectRecord(ChartStartObjectRecord other) {
- super(other);
- rt = other.rt;
- grbitFrt = other.grbitFrt;
- iObjectKind = other.iObjectKind;
- iObjectContext = other.iObjectContext;
- iObjectInstance1 = other.iObjectInstance1;
- iObjectInstance2 = other.iObjectInstance2;
- }
-
- public ChartStartObjectRecord(RecordInputStream in) {
- rt = in.readShort();
- grbitFrt = in.readShort();
- iObjectKind = in.readShort();
- iObjectContext = in.readShort();
- iObjectInstance1 = in.readShort();
- iObjectInstance2 = in.readShort();
- }
-
- @Override
- protected int getDataSize() {
- return 2 + 2 + 2 + 2 + 2 + 2;
- }
-
- @Override
- public short getSid() {
- return sid;
- }
-
- @Override
- public void serialize(LittleEndianOutput out) {
- out.writeShort(rt);
- out.writeShort(grbitFrt);
- out.writeShort(iObjectKind);
- out.writeShort(iObjectContext);
- out.writeShort(iObjectInstance1);
- out.writeShort(iObjectInstance2);
- }
-
- @Override
- public ChartStartObjectRecord copy() {
- return new ChartStartObjectRecord(this);
- }
-
- @Override
- public HSSFRecordTypes getGenericRecordType() {
- return HSSFRecordTypes.CHART_START_OBJECT;
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties(
- "rt", () -> rt,
- "grbitFrt", () -> grbitFrt,
- "iObjectKind", () -> iObjectKind,
- "iObjectContext", () -> iObjectContext,
- "iObjectInstance1", () -> iObjectInstance1,
- "iObjectInstance2", () -> iObjectInstance2
- );
- }
+ private short rt;
+ private short grbitFrt;
+ private short iObjectKind;
+ private short iObjectContext;
+ private short iObjectInstance1;
+ private short iObjectInstance2;
+
+ public ChartStartObjectRecord(ChartStartObjectRecord other) {
+ super(other);
+ rt = other.rt;
+ grbitFrt = other.grbitFrt;
+ iObjectKind = other.iObjectKind;
+ iObjectContext = other.iObjectContext;
+ iObjectInstance1 = other.iObjectInstance1;
+ iObjectInstance2 = other.iObjectInstance2;
+ }
+
+ public ChartStartObjectRecord(RecordInputStream in) {
+ rt = in.readShort();
+ grbitFrt = in.readShort();
+ iObjectKind = in.readShort();
+ iObjectContext = in.readShort();
+ iObjectInstance1 = in.readShort();
+ iObjectInstance2 = in.readShort();
+ }
+
+ @Override
+ protected int getDataSize() {
+ return 2 + 2 + 2 + 2 + 2 + 2;
+ }
+
+ @Override
+ public short getSid() {
+ return sid;
+ }
+
+ @Override
+ public void serialize(LittleEndianOutput out) {
+ out.writeShort(rt);
+ out.writeShort(grbitFrt);
+ out.writeShort(iObjectKind);
+ out.writeShort(iObjectContext);
+ out.writeShort(iObjectInstance1);
+ out.writeShort(iObjectInstance2);
+ }
+
+ @Override
+ public ChartStartObjectRecord copy() {
+ return new ChartStartObjectRecord(this);
+ }
+
+ @Override
+ public HSSFRecordTypes getGenericRecordType() {
+ return HSSFRecordTypes.CHART_START_OBJECT;
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "rt", () -> rt,
+ "grbitFrt", () -> grbitFrt,
+ "iObjectKind", () -> iObjectKind,
+ "iObjectContext", () -> iObjectContext,
+ "iObjectInstance1", () -> iObjectInstance1,
+ "iObjectInstance2", () -> iObjectInstance2
+ );
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartTitleFormatRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartTitleFormatRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartTitleFormatRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartTitleFormatRecord.java Sat May 22 20:56:44 2021
@@ -36,107 +36,107 @@ import org.apache.poi.util.LittleEndianO
* Describes the formatting runs associated with a chart title.
*/
public class ChartTitleFormatRecord extends StandardRecord {
- public static final short sid = 0x1050;
+ public static final short sid = 0x1050;
- private final CTFormat[] _formats;
+ private final CTFormat[] _formats;
- private static final class CTFormat implements GenericRecord {
- public static final int ENCODED_SIZE=4;
- private int _offset;
- private int _fontIndex;
-
- public CTFormat(CTFormat other) {
- _offset = other._offset;
- _fontIndex = other._fontIndex;
- }
-
- public CTFormat(RecordInputStream in) {
- _offset = in.readShort();
- _fontIndex = in.readShort();
- }
-
- public int getOffset(){
- return _offset;
- }
- public void setOffset(int newOff){
- _offset = newOff;
- }
- public int getFontIndex() {
- return _fontIndex;
- }
-
- public void serialize(LittleEndianOutput out) {
- out.writeShort(_offset);
- out.writeShort(_fontIndex);
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties(
- "offset", this::getOffset,
- "fontIndex", this::getFontIndex
- );
- }
- }
-
- public ChartTitleFormatRecord(ChartTitleFormatRecord other) {
- super(other);
- _formats = Stream.of(other._formats).map(CTFormat::new).toArray(CTFormat[]::new);
- }
-
- public ChartTitleFormatRecord(RecordInputStream in) {
- int nRecs = in.readUShort();
- _formats = new CTFormat[nRecs];
-
- for(int i=0;i<nRecs;i++) {
- _formats[i] = new CTFormat(in);
- }
- }
+ private static final class CTFormat implements GenericRecord {
+ public static final int ENCODED_SIZE=4;
+ private int _offset;
+ private int _fontIndex;
+
+ public CTFormat(CTFormat other) {
+ _offset = other._offset;
+ _fontIndex = other._fontIndex;
+ }
+
+ public CTFormat(RecordInputStream in) {
+ _offset = in.readShort();
+ _fontIndex = in.readShort();
+ }
+
+ public int getOffset(){
+ return _offset;
+ }
+ public void setOffset(int newOff){
+ _offset = newOff;
+ }
+ public int getFontIndex() {
+ return _fontIndex;
+ }
+
+ public void serialize(LittleEndianOutput out) {
+ out.writeShort(_offset);
+ out.writeShort(_fontIndex);
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "offset", this::getOffset,
+ "fontIndex", this::getFontIndex
+ );
+ }
+ }
+
+ public ChartTitleFormatRecord(ChartTitleFormatRecord other) {
+ super(other);
+ _formats = Stream.of(other._formats).map(CTFormat::new).toArray(CTFormat[]::new);
+ }
+
+ public ChartTitleFormatRecord(RecordInputStream in) {
+ int nRecs = in.readUShort();
+ _formats = new CTFormat[nRecs];
+
+ for(int i=0;i<nRecs;i++) {
+ _formats[i] = new CTFormat(in);
+ }
+ }
- public void serialize(LittleEndianOutput out) {
+ public void serialize(LittleEndianOutput out) {
out.writeShort(_formats.length);
- for (CTFormat format : _formats) {
- format.serialize(out);
- }
+ for (CTFormat format : _formats) {
+ format.serialize(out);
+ }
}
protected int getDataSize() {
return 2 + CTFormat.ENCODED_SIZE * _formats.length;
}
- public short getSid() {
- return sid;
- }
-
- public int getFormatCount() {
- return _formats.length;
- }
-
- public void modifyFormatRun(short oldPos, short newLen) {
- int shift = 0;
- for(int i=0; i < _formats.length; i++) {
- CTFormat ctf = _formats[i];
- if (shift != 0) {
- ctf.setOffset(ctf.getOffset() + shift);
- } else if (oldPos == ctf.getOffset() && i < _formats.length - 1){
- CTFormat nextCTF = _formats[i + 1];
- shift = newLen - (nextCTF.getOffset() - ctf.getOffset());
- }
- }
- }
-
- @Override
- public ChartTitleFormatRecord copy() {
- return new ChartTitleFormatRecord(this);
- }
-
- @Override
- public HSSFRecordTypes getGenericRecordType() {
- return HSSFRecordTypes.CHART_TITLE_FORMAT;
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties("formats", () -> _formats);
- }
+ public short getSid() {
+ return sid;
+ }
+
+ public int getFormatCount() {
+ return _formats.length;
+ }
+
+ public void modifyFormatRun(short oldPos, short newLen) {
+ int shift = 0;
+ for(int i=0; i < _formats.length; i++) {
+ CTFormat ctf = _formats[i];
+ if (shift != 0) {
+ ctf.setOffset(ctf.getOffset() + shift);
+ } else if (oldPos == ctf.getOffset() && i < _formats.length - 1){
+ CTFormat nextCTF = _formats[i + 1];
+ shift = newLen - (nextCTF.getOffset() - ctf.getOffset());
+ }
+ }
+ }
+
+ @Override
+ public ChartTitleFormatRecord copy() {
+ return new ChartTitleFormatRecord(this);
+ }
+
+ @Override
+ public HSSFRecordTypes getGenericRecordType() {
+ return HSSFRecordTypes.CHART_TITLE_FORMAT;
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties("formats", () -> _formats);
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/DataLabelExtensionRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/DataLabelExtensionRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/DataLabelExtensionRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/DataLabelExtensionRecord.java Sat May 22 20:56:44 2021
@@ -30,58 +30,58 @@ import org.apache.poi.util.LittleEndianO
* DATALABEXT - Chart Data Label Extension (0x086A)
*/
public final class DataLabelExtensionRecord extends StandardRecord {
- public static final short sid = 0x086A;
+ public static final short sid = 0x086A;
- private int rt;
- private int grbitFrt;
- private final byte[] unused = new byte[8];
-
- public DataLabelExtensionRecord(DataLabelExtensionRecord other) {
- super(other);
- rt = other.rt;
- grbitFrt = other.grbitFrt;
- System.arraycopy(other.unused, 0, unused, 0, unused.length);
- }
-
- public DataLabelExtensionRecord(RecordInputStream in) {
- rt = in.readShort();
- grbitFrt = in.readShort();
- in.readFully(unused);
- }
-
- @Override
- protected int getDataSize() {
- return 2 + 2 + 8;
- }
-
- @Override
- public short getSid() {
- return sid;
- }
-
- @Override
- protected void serialize(LittleEndianOutput out) {
- out.writeShort(rt);
- out.writeShort(grbitFrt);
- out.write(unused);
- }
-
- @Override
- public DataLabelExtensionRecord copy() {
- return new DataLabelExtensionRecord(this);
- }
-
- @Override
- public HSSFRecordTypes getGenericRecordType() {
- return HSSFRecordTypes.DATA_LABEL_EXTENSION;
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties(
- "rt", () -> rt,
- "grbitFrt", () -> grbitFrt,
- "unused", () -> unused
- );
- }
+ private int rt;
+ private int grbitFrt;
+ private final byte[] unused = new byte[8];
+
+ public DataLabelExtensionRecord(DataLabelExtensionRecord other) {
+ super(other);
+ rt = other.rt;
+ grbitFrt = other.grbitFrt;
+ System.arraycopy(other.unused, 0, unused, 0, unused.length);
+ }
+
+ public DataLabelExtensionRecord(RecordInputStream in) {
+ rt = in.readShort();
+ grbitFrt = in.readShort();
+ in.readFully(unused);
+ }
+
+ @Override
+ protected int getDataSize() {
+ return 2 + 2 + 8;
+ }
+
+ @Override
+ public short getSid() {
+ return sid;
+ }
+
+ @Override
+ protected void serialize(LittleEndianOutput out) {
+ out.writeShort(rt);
+ out.writeShort(grbitFrt);
+ out.write(unused);
+ }
+
+ @Override
+ public DataLabelExtensionRecord copy() {
+ return new DataLabelExtensionRecord(this);
+ }
+
+ @Override
+ public HSSFRecordTypes getGenericRecordType() {
+ return HSSFRecordTypes.DATA_LABEL_EXTENSION;
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "rt", () -> rt,
+ "grbitFrt", () -> grbitFrt,
+ "unused", () -> unused
+ );
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/SeriesListRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/SeriesListRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/SeriesListRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/SeriesListRecord.java Sat May 22 20:56:44 2021
@@ -44,16 +44,16 @@ public final class SeriesListRecord exte
}
public SeriesListRecord(short[] seriesNumbers) {
- field_1_seriesNumbers = (seriesNumbers == null) ? null : seriesNumbers.clone();
+ field_1_seriesNumbers = (seriesNumbers == null) ? null : seriesNumbers.clone();
}
public SeriesListRecord(RecordInputStream in) {
- int nItems = in.readUShort();
- short[] ss = new short[nItems];
- for (int i = 0; i < nItems; i++) {
- ss[i] = in.readShort();
+ int nItems = in.readUShort();
+ short[] ss = new short[nItems];
+ for (int i = 0; i < nItems; i++) {
+ ss[i] = in.readShort();
- }
+ }
field_1_seriesNumbers = ss;
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/SeriesTextRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/SeriesTextRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/SeriesTextRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/chart/SeriesTextRecord.java Sat May 22 20:56:44 2021
@@ -32,112 +32,112 @@ import org.apache.poi.util.StringUtil;
* Defines a series name
*/
public final class SeriesTextRecord extends StandardRecord {
- public static final short sid = 0x100D;
+ public static final short sid = 0x100D;
- /**
- * the actual text cannot be longer than 255 characters
- */
- private static final int MAX_LEN = 0xFF;
-
- private int field_1_id;
- private boolean is16bit;
- private String field_4_text;
-
- public SeriesTextRecord() {
- field_4_text = "";
- is16bit = false;
- }
-
- public SeriesTextRecord(SeriesTextRecord other) {
- super(other);
- field_1_id = other.field_1_id;
- is16bit = other.is16bit;
- field_4_text = other.field_4_text;
- }
-
- public SeriesTextRecord(RecordInputStream in) {
- field_1_id = in.readUShort();
- int field_2_textLength = in.readUByte();
- is16bit = (in.readUByte() & 0x01) != 0;
- if (is16bit) {
- field_4_text = in.readUnicodeLEString(field_2_textLength);
- } else {
- field_4_text = in.readCompressedUnicode(field_2_textLength);
- }
- }
-
- public void serialize(LittleEndianOutput out) {
-
- out.writeShort(field_1_id);
- out.writeByte(field_4_text.length());
- if (is16bit) {
- // Excel (2007) seems to choose 16bit regardless of whether it is needed
- out.writeByte(0x01);
- StringUtil.putUnicodeLE(field_4_text, out);
- } else {
- // Excel can read this OK
- out.writeByte(0x00);
- StringUtil.putCompressedUnicode(field_4_text, out);
- }
- }
-
- protected int getDataSize() {
- return 2 + 1 + 1 + field_4_text.length() * (is16bit ? 2 : 1);
- }
-
- public short getSid() {
- return sid;
- }
-
- @Override
- public SeriesTextRecord copy() {
- return new SeriesTextRecord(this);
- }
-
- /**
- * Get the id field for the SeriesText record.
- */
- public int getId() {
- return field_1_id;
- }
-
- /**
- * Set the id field for the SeriesText record.
- */
- public void setId(int id) {
- field_1_id = id;
- }
-
- /**
- * Get the text field for the SeriesText record.
- */
- public String getText() {
- return field_4_text;
- }
-
- /**
- * Set the text field for the SeriesText record.
- */
- public void setText(String text) {
- if (text.length() > MAX_LEN) {
- throw new IllegalArgumentException("Text is too long ("
- + text.length() + ">" + MAX_LEN + ")");
- }
- field_4_text = text;
- is16bit = StringUtil.hasMultibyte(text);
- }
-
- @Override
- public HSSFRecordTypes getGenericRecordType() {
- return HSSFRecordTypes.SERIES_TEXT;
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties(
- "id", this::getId,
- "bit16", () -> is16bit,
- "text", this::getText
- );
- }
+ /**
+ * the actual text cannot be longer than 255 characters
+ */
+ private static final int MAX_LEN = 0xFF;
+
+ private int field_1_id;
+ private boolean is16bit;
+ private String field_4_text;
+
+ public SeriesTextRecord() {
+ field_4_text = "";
+ is16bit = false;
+ }
+
+ public SeriesTextRecord(SeriesTextRecord other) {
+ super(other);
+ field_1_id = other.field_1_id;
+ is16bit = other.is16bit;
+ field_4_text = other.field_4_text;
+ }
+
+ public SeriesTextRecord(RecordInputStream in) {
+ field_1_id = in.readUShort();
+ int field_2_textLength = in.readUByte();
+ is16bit = (in.readUByte() & 0x01) != 0;
+ if (is16bit) {
+ field_4_text = in.readUnicodeLEString(field_2_textLength);
+ } else {
+ field_4_text = in.readCompressedUnicode(field_2_textLength);
+ }
+ }
+
+ public void serialize(LittleEndianOutput out) {
+
+ out.writeShort(field_1_id);
+ out.writeByte(field_4_text.length());
+ if (is16bit) {
+ // Excel (2007) seems to choose 16bit regardless of whether it is needed
+ out.writeByte(0x01);
+ StringUtil.putUnicodeLE(field_4_text, out);
+ } else {
+ // Excel can read this OK
+ out.writeByte(0x00);
+ StringUtil.putCompressedUnicode(field_4_text, out);
+ }
+ }
+
+ protected int getDataSize() {
+ return 2 + 1 + 1 + field_4_text.length() * (is16bit ? 2 : 1);
+ }
+
+ public short getSid() {
+ return sid;
+ }
+
+ @Override
+ public SeriesTextRecord copy() {
+ return new SeriesTextRecord(this);
+ }
+
+ /**
+ * Get the id field for the SeriesText record.
+ */
+ public int getId() {
+ return field_1_id;
+ }
+
+ /**
+ * Set the id field for the SeriesText record.
+ */
+ public void setId(int id) {
+ field_1_id = id;
+ }
+
+ /**
+ * Get the text field for the SeriesText record.
+ */
+ public String getText() {
+ return field_4_text;
+ }
+
+ /**
+ * Set the text field for the SeriesText record.
+ */
+ public void setText(String text) {
+ if (text.length() > MAX_LEN) {
+ throw new IllegalArgumentException("Text is too long ("
+ + text.length() + ">" + MAX_LEN + ")");
+ }
+ field_4_text = text;
+ is16bit = StringUtil.hasMultibyte(text);
+ }
+
+ @Override
+ public HSSFRecordTypes getGenericRecordType() {
+ return HSSFRecordTypes.SERIES_TEXT;
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "id", this::getId,
+ "bit16", () -> is16bit,
+ "text", this::getText
+ );
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/FeatFormulaErr2.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/FeatFormulaErr2.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/FeatFormulaErr2.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/FeatFormulaErr2.java Sat May 22 20:56:44 2021
@@ -41,114 +41,114 @@ import org.apache.poi.util.LittleEndianO
* https://msdn.microsoft.com/en-us/library/dd924991%28v=office.12%29.aspx
*/
public final class FeatFormulaErr2 implements SharedFeature {
- private static final BitField CHECK_CALCULATION_ERRORS = BitFieldFactory.getInstance(0x01);
- private static final BitField CHECK_EMPTY_CELL_REF = BitFieldFactory.getInstance(0x02);
- private static final BitField CHECK_NUMBERS_AS_TEXT = BitFieldFactory.getInstance(0x04);
- private static final BitField CHECK_INCONSISTENT_RANGES = BitFieldFactory.getInstance(0x08);
- private static final BitField CHECK_INCONSISTENT_FORMULAS = BitFieldFactory.getInstance(0x10);
- private static final BitField CHECK_DATETIME_FORMATS = BitFieldFactory.getInstance(0x20);
- private static final BitField CHECK_UNPROTECTED_FORMULAS = BitFieldFactory.getInstance(0x40);
- private static final BitField PERFORM_DATA_VALIDATION = BitFieldFactory.getInstance(0x80);
-
- /**
- * What errors we should ignore
- */
- private int errorCheck;
-
-
- public FeatFormulaErr2() {}
-
- public FeatFormulaErr2(FeatFormulaErr2 other) {
- errorCheck = other.errorCheck;
- }
-
- public FeatFormulaErr2(RecordInputStream in) {
- errorCheck = in.readInt();
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties(
- "errorCheck", getBitsAsString(this::_getRawErrorCheckValue,
- new BitField[]{CHECK_CALCULATION_ERRORS, CHECK_EMPTY_CELL_REF, CHECK_NUMBERS_AS_TEXT, CHECK_INCONSISTENT_RANGES, CHECK_INCONSISTENT_FORMULAS, CHECK_DATETIME_FORMATS, CHECK_UNPROTECTED_FORMULAS, PERFORM_DATA_VALIDATION},
- new String[]{"CHECK_CALCULATION_ERRORS", "CHECK_EMPTY_CELL_REF", "CHECK_NUMBERS_AS_TEXT", "CHECK_INCONSISTENT_RANGES", "CHECK_INCONSISTENT_FORMULAS", "CHECK_DATETIME_FORMATS", "CHECK_UNPROTECTED_FORMULAS", "PERFORM_DATA_VALIDATION"})
- );
- }
-
- public String toString() {
- return GenericRecordJsonWriter.marshal(this);
- }
-
- public void serialize(LittleEndianOutput out) {
- out.writeInt(errorCheck);
- }
-
- public int getDataSize() {
- return 4;
- }
-
- public int _getRawErrorCheckValue() {
- return errorCheck;
- }
-
- public boolean getCheckCalculationErrors() {
- return CHECK_CALCULATION_ERRORS.isSet(errorCheck);
- }
- public void setCheckCalculationErrors(boolean checkCalculationErrors) {
- errorCheck = CHECK_CALCULATION_ERRORS.setBoolean(errorCheck, checkCalculationErrors);
- }
-
- public boolean getCheckEmptyCellRef() {
- return CHECK_EMPTY_CELL_REF.isSet(errorCheck);
- }
- public void setCheckEmptyCellRef(boolean checkEmptyCellRef) {
- errorCheck = CHECK_EMPTY_CELL_REF.setBoolean(errorCheck, checkEmptyCellRef);
- }
-
- public boolean getCheckNumbersAsText() {
- return CHECK_NUMBERS_AS_TEXT.isSet(errorCheck);
- }
- public void setCheckNumbersAsText(boolean checkNumbersAsText) {
- errorCheck = CHECK_NUMBERS_AS_TEXT.setBoolean(errorCheck, checkNumbersAsText);
- }
-
- public boolean getCheckInconsistentRanges() {
- return CHECK_INCONSISTENT_RANGES.isSet(errorCheck);
- }
- public void setCheckInconsistentRanges(boolean checkInconsistentRanges) {
- errorCheck = CHECK_INCONSISTENT_RANGES.setBoolean(errorCheck, checkInconsistentRanges);
- }
-
- public boolean getCheckInconsistentFormulas() {
- return CHECK_INCONSISTENT_FORMULAS.isSet(errorCheck);
- }
- public void setCheckInconsistentFormulas(boolean checkInconsistentFormulas) {
- errorCheck = CHECK_INCONSISTENT_FORMULAS.setBoolean(errorCheck, checkInconsistentFormulas);
- }
-
- public boolean getCheckDateTimeFormats() {
- return CHECK_DATETIME_FORMATS.isSet(errorCheck);
- }
- public void setCheckDateTimeFormats(boolean checkDateTimeFormats) {
- errorCheck = CHECK_DATETIME_FORMATS.setBoolean(errorCheck, checkDateTimeFormats);
- }
-
- public boolean getCheckUnprotectedFormulas() {
- return CHECK_UNPROTECTED_FORMULAS.isSet(errorCheck);
- }
- public void setCheckUnprotectedFormulas(boolean checkUnprotectedFormulas) {
- errorCheck = CHECK_UNPROTECTED_FORMULAS.setBoolean(errorCheck, checkUnprotectedFormulas);
- }
-
- public boolean getPerformDataValidation() {
- return PERFORM_DATA_VALIDATION.isSet(errorCheck);
- }
- public void setPerformDataValidation(boolean performDataValidation) {
- errorCheck = PERFORM_DATA_VALIDATION.setBoolean(errorCheck, performDataValidation);
- }
-
- @Override
- public FeatFormulaErr2 copy() {
- return new FeatFormulaErr2(this);
- }
+ private static final BitField CHECK_CALCULATION_ERRORS = BitFieldFactory.getInstance(0x01);
+ private static final BitField CHECK_EMPTY_CELL_REF = BitFieldFactory.getInstance(0x02);
+ private static final BitField CHECK_NUMBERS_AS_TEXT = BitFieldFactory.getInstance(0x04);
+ private static final BitField CHECK_INCONSISTENT_RANGES = BitFieldFactory.getInstance(0x08);
+ private static final BitField CHECK_INCONSISTENT_FORMULAS = BitFieldFactory.getInstance(0x10);
+ private static final BitField CHECK_DATETIME_FORMATS = BitFieldFactory.getInstance(0x20);
+ private static final BitField CHECK_UNPROTECTED_FORMULAS = BitFieldFactory.getInstance(0x40);
+ private static final BitField PERFORM_DATA_VALIDATION = BitFieldFactory.getInstance(0x80);
+
+ /**
+ * What errors we should ignore
+ */
+ private int errorCheck;
+
+
+ public FeatFormulaErr2() {}
+
+ public FeatFormulaErr2(FeatFormulaErr2 other) {
+ errorCheck = other.errorCheck;
+ }
+
+ public FeatFormulaErr2(RecordInputStream in) {
+ errorCheck = in.readInt();
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "errorCheck", getBitsAsString(this::_getRawErrorCheckValue,
+ new BitField[]{CHECK_CALCULATION_ERRORS, CHECK_EMPTY_CELL_REF, CHECK_NUMBERS_AS_TEXT, CHECK_INCONSISTENT_RANGES, CHECK_INCONSISTENT_FORMULAS, CHECK_DATETIME_FORMATS, CHECK_UNPROTECTED_FORMULAS, PERFORM_DATA_VALIDATION},
+ new String[]{"CHECK_CALCULATION_ERRORS", "CHECK_EMPTY_CELL_REF", "CHECK_NUMBERS_AS_TEXT", "CHECK_INCONSISTENT_RANGES", "CHECK_INCONSISTENT_FORMULAS", "CHECK_DATETIME_FORMATS", "CHECK_UNPROTECTED_FORMULAS", "PERFORM_DATA_VALIDATION"})
+ );
+ }
+
+ public String toString() {
+ return GenericRecordJsonWriter.marshal(this);
+ }
+
+ public void serialize(LittleEndianOutput out) {
+ out.writeInt(errorCheck);
+ }
+
+ public int getDataSize() {
+ return 4;
+ }
+
+ public int _getRawErrorCheckValue() {
+ return errorCheck;
+ }
+
+ public boolean getCheckCalculationErrors() {
+ return CHECK_CALCULATION_ERRORS.isSet(errorCheck);
+ }
+ public void setCheckCalculationErrors(boolean checkCalculationErrors) {
+ errorCheck = CHECK_CALCULATION_ERRORS.setBoolean(errorCheck, checkCalculationErrors);
+ }
+
+ public boolean getCheckEmptyCellRef() {
+ return CHECK_EMPTY_CELL_REF.isSet(errorCheck);
+ }
+ public void setCheckEmptyCellRef(boolean checkEmptyCellRef) {
+ errorCheck = CHECK_EMPTY_CELL_REF.setBoolean(errorCheck, checkEmptyCellRef);
+ }
+
+ public boolean getCheckNumbersAsText() {
+ return CHECK_NUMBERS_AS_TEXT.isSet(errorCheck);
+ }
+ public void setCheckNumbersAsText(boolean checkNumbersAsText) {
+ errorCheck = CHECK_NUMBERS_AS_TEXT.setBoolean(errorCheck, checkNumbersAsText);
+ }
+
+ public boolean getCheckInconsistentRanges() {
+ return CHECK_INCONSISTENT_RANGES.isSet(errorCheck);
+ }
+ public void setCheckInconsistentRanges(boolean checkInconsistentRanges) {
+ errorCheck = CHECK_INCONSISTENT_RANGES.setBoolean(errorCheck, checkInconsistentRanges);
+ }
+
+ public boolean getCheckInconsistentFormulas() {
+ return CHECK_INCONSISTENT_FORMULAS.isSet(errorCheck);
+ }
+ public void setCheckInconsistentFormulas(boolean checkInconsistentFormulas) {
+ errorCheck = CHECK_INCONSISTENT_FORMULAS.setBoolean(errorCheck, checkInconsistentFormulas);
+ }
+
+ public boolean getCheckDateTimeFormats() {
+ return CHECK_DATETIME_FORMATS.isSet(errorCheck);
+ }
+ public void setCheckDateTimeFormats(boolean checkDateTimeFormats) {
+ errorCheck = CHECK_DATETIME_FORMATS.setBoolean(errorCheck, checkDateTimeFormats);
+ }
+
+ public boolean getCheckUnprotectedFormulas() {
+ return CHECK_UNPROTECTED_FORMULAS.isSet(errorCheck);
+ }
+ public void setCheckUnprotectedFormulas(boolean checkUnprotectedFormulas) {
+ errorCheck = CHECK_UNPROTECTED_FORMULAS.setBoolean(errorCheck, checkUnprotectedFormulas);
+ }
+
+ public boolean getPerformDataValidation() {
+ return PERFORM_DATA_VALIDATION.isSet(errorCheck);
+ }
+ public void setPerformDataValidation(boolean performDataValidation) {
+ errorCheck = PERFORM_DATA_VALIDATION.setBoolean(errorCheck, performDataValidation);
+ }
+
+ @Override
+ public FeatFormulaErr2 copy() {
+ return new FeatFormulaErr2(this);
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/FeatProtection.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/FeatProtection.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/FeatProtection.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/FeatProtection.java Sat May 22 20:56:44 2021
@@ -36,87 +36,87 @@ import org.apache.poi.util.StringUtil;
* as {@link FeatRecord}
*/
public final class FeatProtection implements SharedFeature {
- @SuppressWarnings("RedundantFieldInitialization")
- public static final long NO_SELF_RELATIVE_SECURITY_FEATURE = 0;
- public static final long HAS_SELF_RELATIVE_SECURITY_FEATURE = 1;
-
- private int fSD;
-
- /**
- * 0 means no password. Otherwise indicates the
- * password verifier algorithm (same kind as
- * {@link PasswordRecord} and
- * {@link PasswordRev4Record})
- */
- private int passwordVerifier;
-
- private String title;
- private byte[] securityDescriptor;
-
- public FeatProtection() {
- securityDescriptor = new byte[0];
- }
-
- public FeatProtection(FeatProtection other) {
- fSD = other.fSD;
- passwordVerifier = other.passwordVerifier;
- title = other.title;
- securityDescriptor = (other.securityDescriptor == null) ? null : other.securityDescriptor.clone();
- }
-
- public FeatProtection(RecordInputStream in) {
- fSD = in.readInt();
- passwordVerifier = in.readInt();
-
- title = StringUtil.readUnicodeString(in);
-
- securityDescriptor = in.readRemainder();
- }
-
- public void serialize(LittleEndianOutput out) {
- out.writeInt(fSD);
- out.writeInt(passwordVerifier);
- StringUtil.writeUnicodeString(out, title);
- out.write(securityDescriptor);
- }
-
- public int getDataSize() {
- return 4 + 4 + StringUtil.getEncodedSize(title) + securityDescriptor.length;
- }
-
- public int getPasswordVerifier() {
- return passwordVerifier;
- }
- public void setPasswordVerifier(int passwordVerifier) {
- this.passwordVerifier = passwordVerifier;
- }
-
- public String getTitle() {
- return title;
- }
- public void setTitle(String title) {
- this.title = title;
- }
-
- /**
- * @return Self Relative
- */
- public int getFSD() {
- return fSD;
- }
-
- @Override
- public FeatProtection copy() {
- return new FeatProtection(this);
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties(
- "FSD", this::getFSD,
- "passwordVerifier", this::getPasswordVerifier,
- "title", this::getTitle,
- "securityDescriptor", () -> securityDescriptor
- );
- }
+ @SuppressWarnings("RedundantFieldInitialization")
+ public static final long NO_SELF_RELATIVE_SECURITY_FEATURE = 0;
+ public static final long HAS_SELF_RELATIVE_SECURITY_FEATURE = 1;
+
+ private int fSD;
+
+ /**
+ * 0 means no password. Otherwise indicates the
+ * password verifier algorithm (same kind as
+ * {@link PasswordRecord} and
+ * {@link PasswordRev4Record})
+ */
+ private int passwordVerifier;
+
+ private String title;
+ private byte[] securityDescriptor;
+
+ public FeatProtection() {
+ securityDescriptor = new byte[0];
+ }
+
+ public FeatProtection(FeatProtection other) {
+ fSD = other.fSD;
+ passwordVerifier = other.passwordVerifier;
+ title = other.title;
+ securityDescriptor = (other.securityDescriptor == null) ? null : other.securityDescriptor.clone();
+ }
+
+ public FeatProtection(RecordInputStream in) {
+ fSD = in.readInt();
+ passwordVerifier = in.readInt();
+
+ title = StringUtil.readUnicodeString(in);
+
+ securityDescriptor = in.readRemainder();
+ }
+
+ public void serialize(LittleEndianOutput out) {
+ out.writeInt(fSD);
+ out.writeInt(passwordVerifier);
+ StringUtil.writeUnicodeString(out, title);
+ out.write(securityDescriptor);
+ }
+
+ public int getDataSize() {
+ return 4 + 4 + StringUtil.getEncodedSize(title) + securityDescriptor.length;
+ }
+
+ public int getPasswordVerifier() {
+ return passwordVerifier;
+ }
+ public void setPasswordVerifier(int passwordVerifier) {
+ this.passwordVerifier = passwordVerifier;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+ * @return Self Relative
+ */
+ public int getFSD() {
+ return fSD;
+ }
+
+ @Override
+ public FeatProtection copy() {
+ return new FeatProtection(this);
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "FSD", this::getFSD,
+ "passwordVerifier", this::getPasswordVerifier,
+ "title", this::getTitle,
+ "securityDescriptor", () -> securityDescriptor
+ );
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/FeatSmartTag.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/FeatSmartTag.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/FeatSmartTag.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/FeatSmartTag.java Sat May 22 20:56:44 2021
@@ -40,40 +40,40 @@ import org.apache.poi.util.LittleEndianO
* format documentation.
*/
public final class FeatSmartTag implements SharedFeature {
- // TODO - process
- private byte[] data;
+ // TODO - process
+ private byte[] data;
- public FeatSmartTag() {
- data = new byte[0];
- }
-
- public FeatSmartTag(FeatSmartTag other) {
- data = (other.data == null) ? null : other.data.clone();
- }
-
- public FeatSmartTag(RecordInputStream in) {
- data = in.readRemainder();
- }
-
- public String toString() {
- return GenericRecordJsonWriter.marshal(this);
- }
-
- public int getDataSize() {
- return data.length;
- }
-
- public void serialize(LittleEndianOutput out) {
- out.write(data);
- }
-
- @Override
- public FeatSmartTag copy() {
- return new FeatSmartTag(this);
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties("data", () -> data);
- }
+ public FeatSmartTag() {
+ data = new byte[0];
+ }
+
+ public FeatSmartTag(FeatSmartTag other) {
+ data = (other.data == null) ? null : other.data.clone();
+ }
+
+ public FeatSmartTag(RecordInputStream in) {
+ data = in.readRemainder();
+ }
+
+ public String toString() {
+ return GenericRecordJsonWriter.marshal(this);
+ }
+
+ public int getDataSize() {
+ return data.length;
+ }
+
+ public void serialize(LittleEndianOutput out) {
+ out.write(data);
+ }
+
+ @Override
+ public FeatSmartTag copy() {
+ return new FeatSmartTag(this);
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties("data", () -> data);
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/SharedFeature.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/SharedFeature.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/SharedFeature.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/SharedFeature.java Sat May 22 20:56:44 2021
@@ -24,8 +24,8 @@ import org.apache.poi.util.LittleEndianO
* Common Interface for all Shared Features
*/
public interface SharedFeature extends GenericRecord {
- String toString();
- void serialize(LittleEndianOutput out);
- int getDataSize();
- SharedFeature copy();
+ String toString();
+ void serialize(LittleEndianOutput out);
+ int getDataSize();
+ SharedFeature copy();
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/UnicodeString.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/UnicodeString.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/UnicodeString.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/common/UnicodeString.java Sat May 22 20:56:44 2021
@@ -177,9 +177,9 @@ public class UnicodeString implements Co
* @return number of characters
*/
public int getCharCount() {
- if(field_1_charCount < 0) {
- return field_1_charCount + 65536;
- }
+ if(field_1_charCount < 0) {
+ return field_1_charCount + 65536;
+ }
return field_1_charCount;
}
@@ -272,11 +272,11 @@ public class UnicodeString implements Co
public FormatRun getFormatRun(int index) {
if (field_4_format_runs == null) {
- return null;
- }
+ return null;
+ }
if (index < 0 || index >= field_4_format_runs.size()) {
- return null;
- }
+ return null;
+ }
return field_4_format_runs.get(index);
}
@@ -300,8 +300,8 @@ public class UnicodeString implements Co
*/
public void addFormatRun(FormatRun r) {
if (field_4_format_runs == null) {
- field_4_format_runs = new ArrayList<>();
- }
+ field_4_format_runs = new ArrayList<>();
+ }
int index = findFormatRunAt(r._character);
if (index != -1) {
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/cont/ContinuableRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/cont/ContinuableRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/cont/ContinuableRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/cont/ContinuableRecord.java Sat May 22 20:56:44 2021
@@ -29,52 +29,52 @@ import org.apache.poi.util.LittleEndianO
*/
public abstract class ContinuableRecord extends Record {
- protected ContinuableRecord() {}
+ protected ContinuableRecord() {}
- protected ContinuableRecord(ContinuableRecord other) {
- super(other);
- }
-
- /**
- * Serializes this record's content to the supplied data output.<p>
- * The standard BIFF header (ushort sid, ushort size) has been handled by the superclass, so
- * only BIFF data should be written by this method. Simple data types can be written with the
- * standard {@link LittleEndianOutput} methods. Methods from {@link ContinuableRecordOutput}
- * can be used to serialize strings (with {@link ContinueRecord}s being written as required).
- * If necessary, implementors can explicitly start {@link ContinueRecord}s (regardless of the
- * amount of remaining space).
- *
- * @param out a data output stream
- */
- protected abstract void serialize(ContinuableRecordOutput out);
-
-
- /**
- * @return the total length of the encoded record(s)
- * (Note - if any {@link ContinueRecord} is required, this result includes the
- * size of those too)
- */
- @Override
- public final int getRecordSize() {
- ContinuableRecordOutput out = ContinuableRecordOutput.createForCountingOnly();
- serialize(out);
- out.terminate();
- return out.getTotalSize();
- }
-
- @Override
- public final int serialize(int offset, byte[] data) {
- int totalSize = 0;
- try (LittleEndianByteArrayOutputStream leo =
- new LittleEndianByteArrayOutputStream(data, offset)) {
- ContinuableRecordOutput out = new ContinuableRecordOutput(leo, getSid());
- serialize(out);
- out.terminate();
- totalSize = out.getTotalSize();
- } catch (IOException ioe) {
- // should never happen in practice
- throw new IllegalStateException(ioe);
- }
- return totalSize;
- }
+ protected ContinuableRecord(ContinuableRecord other) {
+ super(other);
+ }
+
+ /**
+ * Serializes this record's content to the supplied data output.<p>
+ * The standard BIFF header (ushort sid, ushort size) has been handled by the superclass, so
+ * only BIFF data should be written by this method. Simple data types can be written with the
+ * standard {@link LittleEndianOutput} methods. Methods from {@link ContinuableRecordOutput}
+ * can be used to serialize strings (with {@link ContinueRecord}s being written as required).
+ * If necessary, implementors can explicitly start {@link ContinueRecord}s (regardless of the
+ * amount of remaining space).
+ *
+ * @param out a data output stream
+ */
+ protected abstract void serialize(ContinuableRecordOutput out);
+
+
+ /**
+ * @return the total length of the encoded record(s)
+ * (Note - if any {@link ContinueRecord} is required, this result includes the
+ * size of those too)
+ */
+ @Override
+ public final int getRecordSize() {
+ ContinuableRecordOutput out = ContinuableRecordOutput.createForCountingOnly();
+ serialize(out);
+ out.terminate();
+ return out.getTotalSize();
+ }
+
+ @Override
+ public final int serialize(int offset, byte[] data) {
+ int totalSize = 0;
+ try (LittleEndianByteArrayOutputStream leo =
+ new LittleEndianByteArrayOutputStream(data, offset)) {
+ ContinuableRecordOutput out = new ContinuableRecordOutput(leo, getSid());
+ serialize(out);
+ out.terminate();
+ totalSize = out.getTotalSize();
+ } catch (IOException ioe) {
+ // should never happen in practice
+ throw new IllegalStateException(ioe);
+ }
+ return totalSize;
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/cont/ContinuableRecordOutput.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/cont/ContinuableRecordOutput.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/cont/ContinuableRecordOutput.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/cont/ContinuableRecordOutput.java Sat May 22 20:56:44 2021
@@ -29,184 +29,184 @@ import org.apache.poi.util.StringUtil;
*/
public final class ContinuableRecordOutput implements LittleEndianOutput {
- private final LittleEndianOutput _out;
- private UnknownLengthRecordOutput _ulrOutput;
- private int _totalPreviousRecordsSize;
-
- public ContinuableRecordOutput(LittleEndianOutput out, int sid) {
- _ulrOutput = new UnknownLengthRecordOutput(out, sid);
- _out = out;
- _totalPreviousRecordsSize = 0;
- }
-
- public static ContinuableRecordOutput createForCountingOnly() {
- return new ContinuableRecordOutput(NOPOutput, -777); // fake sid
- }
-
- /**
- * @return total number of bytes written so far (including all BIFF headers)
- */
- public int getTotalSize() {
- return _totalPreviousRecordsSize + _ulrOutput.getTotalSize();
- }
- /**
- * Terminates the last record (also updates its 'ushort size' field)
- */
- void terminate() {
- _ulrOutput.terminate();
- }
- /**
- * @return number of remaining bytes of space in current record
- */
- public int getAvailableSpace() {
- return _ulrOutput.getAvailableSpace();
- }
-
- /**
- * Terminates the current record and starts a new {@link ContinueRecord} (regardless
- * of how much space is still available in the current record).
- */
- public void writeContinue() {
- _ulrOutput.terminate();
- _totalPreviousRecordsSize += _ulrOutput.getTotalSize();
- _ulrOutput = new UnknownLengthRecordOutput(_out, ContinueRecord.sid);
- }
- /**
- * Will terminate the current record and start a new {@link ContinueRecord}
- * if there isn't space for the requested number of bytes
- * @param requiredContinuousSize The number of bytes that need to be written
- */
- public void writeContinueIfRequired(int requiredContinuousSize) {
- if (_ulrOutput.getAvailableSpace() < requiredContinuousSize) {
- writeContinue();
- }
- }
-
- /**
- * Writes the 'optionFlags' byte and encoded character data of a unicode string. This includes:
- * <ul>
- * <li>byte optionFlags</li>
- * <li>encoded character data (in "ISO-8859-1" or "UTF-16LE" encoding)</li>
- * </ul>
- *
- * Notes:
- * <ul>
- * <li>The value of the 'is16bitEncoded' flag is determined by the actual character data
- * of {@code text}</li>
- * <li>The string options flag is never separated (by a {@link ContinueRecord}) from the
- * first chunk of character data it refers to.</li>
- * <li>The 'ushort length' field is assumed to have been explicitly written earlier. Hence,
- * there may be an intervening {@link ContinueRecord}</li>
- * </ul>
- */
- public void writeStringData(String text) {
- boolean is16bitEncoded = StringUtil.hasMultibyte(text);
- // calculate total size of the header and first encoded char
- int keepTogetherSize = 1 + 1; // ushort len, at least one character byte
- int optionFlags = 0x00;
- if (is16bitEncoded) {
- optionFlags |= 0x01;
- keepTogetherSize += 1; // one extra byte for first char
- }
- writeContinueIfRequired(keepTogetherSize);
- writeByte(optionFlags);
- writeCharacterData(text, is16bitEncoded);
- }
- /**
- * Writes a unicode string complete with header and character data. This includes:
- * <ul>
- * <li>ushort length</li>
- * <li>byte optionFlags</li>
- * <li>ushort numberOfRichTextRuns (optional)</li>
- * <li>ushort extendedDataSize (optional)</li>
- * <li>encoded character data (in "ISO-8859-1" or "UTF-16LE" encoding)</li>
- * </ul>
- *
- * The following bits of the 'optionFlags' byte will be set as appropriate:
- * <table>
- * <caption>bits of the 'optionFlags'</caption>
- * <tr><th>Mask</th><th>Description</th></tr>
- * <tr><td>0x01</td><td>is16bitEncoded</td></tr>
- * <tr><td>0x04</td><td>hasExtendedData</td></tr>
- * <tr><td>0x08</td><td>isRichText</td></tr>
- * </table>
- * Notes:
- * <ul>
- * <li>The value of the 'is16bitEncoded' flag is determined by the actual character data
- * of {@code text}</li>
- * <li>The string header fields are never separated (by a {@link ContinueRecord}) from the
- * first chunk of character data (i.e. the first character is always encoded in the same
- * record as the string header).</li>
- * </ul>
- */
- public void writeString(String text, int numberOfRichTextRuns, int extendedDataSize) {
- boolean is16bitEncoded = StringUtil.hasMultibyte(text);
- // calculate total size of the header and first encoded char
- int keepTogetherSize = 2 + 1 + 1; // ushort len, byte optionFlags, at least one character byte
- int optionFlags = 0x00;
- if (is16bitEncoded) {
- optionFlags |= 0x01;
- keepTogetherSize += 1; // one extra byte for first char
- }
- if (numberOfRichTextRuns > 0) {
- optionFlags |= 0x08;
- keepTogetherSize += 2;
- }
- if (extendedDataSize > 0) {
- optionFlags |= 0x04;
- keepTogetherSize += 4;
- }
- writeContinueIfRequired(keepTogetherSize);
- writeShort(text.length());
- writeByte(optionFlags);
- if (numberOfRichTextRuns > 0) {
- writeShort(numberOfRichTextRuns);
- }
- if (extendedDataSize > 0) {
- writeInt(extendedDataSize);
- }
- writeCharacterData(text, is16bitEncoded);
- }
-
-
- private void writeCharacterData(String text, boolean is16bitEncoded) {
- int nChars = text.length();
- int i=0;
- if (is16bitEncoded) {
- while(true) {
- int nWritableChars = Math.min(nChars-i, _ulrOutput.getAvailableSpace() / 2);
- for ( ; nWritableChars > 0; nWritableChars--) {
- _ulrOutput.writeShort(text.charAt(i++));
- }
- if (i >= nChars) {
- break;
- }
- writeContinue();
- writeByte(0x01);
- }
- } else {
- while(true) {
- int nWritableChars = Math.min(nChars-i, _ulrOutput.getAvailableSpace());
- for ( ; nWritableChars > 0; nWritableChars--) {
- _ulrOutput.writeByte(text.charAt(i++));
- }
- if (i >= nChars) {
- break;
- }
- writeContinue();
- writeByte(0x00);
- }
- }
- }
-
- @Override
- public void write(byte[] b) {
- writeContinueIfRequired(b.length);
- _ulrOutput.write(b);
- }
+ private final LittleEndianOutput _out;
+ private UnknownLengthRecordOutput _ulrOutput;
+ private int _totalPreviousRecordsSize;
+
+ public ContinuableRecordOutput(LittleEndianOutput out, int sid) {
+ _ulrOutput = new UnknownLengthRecordOutput(out, sid);
+ _out = out;
+ _totalPreviousRecordsSize = 0;
+ }
+
+ public static ContinuableRecordOutput createForCountingOnly() {
+ return new ContinuableRecordOutput(NOPOutput, -777); // fake sid
+ }
+
+ /**
+ * @return total number of bytes written so far (including all BIFF headers)
+ */
+ public int getTotalSize() {
+ return _totalPreviousRecordsSize + _ulrOutput.getTotalSize();
+ }
+ /**
+ * Terminates the last record (also updates its 'ushort size' field)
+ */
+ void terminate() {
+ _ulrOutput.terminate();
+ }
+ /**
+ * @return number of remaining bytes of space in current record
+ */
+ public int getAvailableSpace() {
+ return _ulrOutput.getAvailableSpace();
+ }
+
+ /**
+ * Terminates the current record and starts a new {@link ContinueRecord} (regardless
+ * of how much space is still available in the current record).
+ */
+ public void writeContinue() {
+ _ulrOutput.terminate();
+ _totalPreviousRecordsSize += _ulrOutput.getTotalSize();
+ _ulrOutput = new UnknownLengthRecordOutput(_out, ContinueRecord.sid);
+ }
+ /**
+ * Will terminate the current record and start a new {@link ContinueRecord}
+ * if there isn't space for the requested number of bytes
+ * @param requiredContinuousSize The number of bytes that need to be written
+ */
+ public void writeContinueIfRequired(int requiredContinuousSize) {
+ if (_ulrOutput.getAvailableSpace() < requiredContinuousSize) {
+ writeContinue();
+ }
+ }
+
+ /**
+ * Writes the 'optionFlags' byte and encoded character data of a unicode string. This includes:
+ * <ul>
+ * <li>byte optionFlags</li>
+ * <li>encoded character data (in "ISO-8859-1" or "UTF-16LE" encoding)</li>
+ * </ul>
+ *
+ * Notes:
+ * <ul>
+ * <li>The value of the 'is16bitEncoded' flag is determined by the actual character data
+ * of {@code text}</li>
+ * <li>The string options flag is never separated (by a {@link ContinueRecord}) from the
+ * first chunk of character data it refers to.</li>
+ * <li>The 'ushort length' field is assumed to have been explicitly written earlier. Hence,
+ * there may be an intervening {@link ContinueRecord}</li>
+ * </ul>
+ */
+ public void writeStringData(String text) {
+ boolean is16bitEncoded = StringUtil.hasMultibyte(text);
+ // calculate total size of the header and first encoded char
+ int keepTogetherSize = 1 + 1; // ushort len, at least one character byte
+ int optionFlags = 0x00;
+ if (is16bitEncoded) {
+ optionFlags |= 0x01;
+ keepTogetherSize += 1; // one extra byte for first char
+ }
+ writeContinueIfRequired(keepTogetherSize);
+ writeByte(optionFlags);
+ writeCharacterData(text, is16bitEncoded);
+ }
+ /**
+ * Writes a unicode string complete with header and character data. This includes:
+ * <ul>
+ * <li>ushort length</li>
+ * <li>byte optionFlags</li>
+ * <li>ushort numberOfRichTextRuns (optional)</li>
+ * <li>ushort extendedDataSize (optional)</li>
+ * <li>encoded character data (in "ISO-8859-1" or "UTF-16LE" encoding)</li>
+ * </ul>
+ *
+ * The following bits of the 'optionFlags' byte will be set as appropriate:
+ * <table>
+ * <caption>bits of the 'optionFlags'</caption>
+ * <tr><th>Mask</th><th>Description</th></tr>
+ * <tr><td>0x01</td><td>is16bitEncoded</td></tr>
+ * <tr><td>0x04</td><td>hasExtendedData</td></tr>
+ * <tr><td>0x08</td><td>isRichText</td></tr>
+ * </table>
+ * Notes:
+ * <ul>
+ * <li>The value of the 'is16bitEncoded' flag is determined by the actual character data
+ * of {@code text}</li>
+ * <li>The string header fields are never separated (by a {@link ContinueRecord}) from the
+ * first chunk of character data (i.e. the first character is always encoded in the same
+ * record as the string header).</li>
+ * </ul>
+ */
+ public void writeString(String text, int numberOfRichTextRuns, int extendedDataSize) {
+ boolean is16bitEncoded = StringUtil.hasMultibyte(text);
+ // calculate total size of the header and first encoded char
+ int keepTogetherSize = 2 + 1 + 1; // ushort len, byte optionFlags, at least one character byte
+ int optionFlags = 0x00;
+ if (is16bitEncoded) {
+ optionFlags |= 0x01;
+ keepTogetherSize += 1; // one extra byte for first char
+ }
+ if (numberOfRichTextRuns > 0) {
+ optionFlags |= 0x08;
+ keepTogetherSize += 2;
+ }
+ if (extendedDataSize > 0) {
+ optionFlags |= 0x04;
+ keepTogetherSize += 4;
+ }
+ writeContinueIfRequired(keepTogetherSize);
+ writeShort(text.length());
+ writeByte(optionFlags);
+ if (numberOfRichTextRuns > 0) {
+ writeShort(numberOfRichTextRuns);
+ }
+ if (extendedDataSize > 0) {
+ writeInt(extendedDataSize);
+ }
+ writeCharacterData(text, is16bitEncoded);
+ }
+
+
+ private void writeCharacterData(String text, boolean is16bitEncoded) {
+ int nChars = text.length();
+ int i=0;
+ if (is16bitEncoded) {
+ while(true) {
+ int nWritableChars = Math.min(nChars-i, _ulrOutput.getAvailableSpace() / 2);
+ for ( ; nWritableChars > 0; nWritableChars--) {
+ _ulrOutput.writeShort(text.charAt(i++));
+ }
+ if (i >= nChars) {
+ break;
+ }
+ writeContinue();
+ writeByte(0x01);
+ }
+ } else {
+ while(true) {
+ int nWritableChars = Math.min(nChars-i, _ulrOutput.getAvailableSpace());
+ for ( ; nWritableChars > 0; nWritableChars--) {
+ _ulrOutput.writeByte(text.charAt(i++));
+ }
+ if (i >= nChars) {
+ break;
+ }
+ writeContinue();
+ writeByte(0x00);
+ }
+ }
+ }
- @Override
- public void write(byte[] b, int offset, int len) {
+ @Override
+ public void write(byte[] b) {
+ writeContinueIfRequired(b.length);
+ _ulrOutput.write(b);
+ }
+
+ @Override
+ public void write(byte[] b, int offset, int len) {
int i=0;
while(true) {
@@ -219,70 +219,70 @@ public final class ContinuableRecordOutp
}
writeContinue();
}
- }
+ }
- @Override
- public void writeByte(int v) {
- writeContinueIfRequired(1);
- _ulrOutput.writeByte(v);
- }
- @Override
- public void writeDouble(double v) {
- writeContinueIfRequired(8);
- _ulrOutput.writeDouble(v);
- }
- @Override
- public void writeInt(int v) {
- writeContinueIfRequired(4);
- _ulrOutput.writeInt(v);
- }
- @Override
- public void writeLong(long v) {
- writeContinueIfRequired(8);
- _ulrOutput.writeLong(v);
- }
- @Override
- public void writeShort(int v) {
- writeContinueIfRequired(2);
- _ulrOutput.writeShort(v);
- }
-
- /**
- * Allows optimised usage of {@link ContinuableRecordOutput} for sizing purposes only.
- */
- private static final LittleEndianOutput NOPOutput = new DelayableLittleEndianOutput() {
-
- @Override
- public LittleEndianOutput createDelayedOutput(int size) {
- return this;
- }
- @Override
- public void write(byte[] b) {
- // does nothing
- }
- @Override
- public void write(byte[] b, int offset, int len) {
- // does nothing
- }
- @Override
- public void writeByte(int v) {
- // does nothing
- }
- @Override
- public void writeDouble(double v) {
- // does nothing
- }
- @Override
- public void writeInt(int v) {
- // does nothing
- }
- @Override
- public void writeLong(long v) {
- // does nothing
- }
- @Override
- public void writeShort(int v) {
- // does nothing
- }
- };
+ @Override
+ public void writeByte(int v) {
+ writeContinueIfRequired(1);
+ _ulrOutput.writeByte(v);
+ }
+ @Override
+ public void writeDouble(double v) {
+ writeContinueIfRequired(8);
+ _ulrOutput.writeDouble(v);
+ }
+ @Override
+ public void writeInt(int v) {
+ writeContinueIfRequired(4);
+ _ulrOutput.writeInt(v);
+ }
+ @Override
+ public void writeLong(long v) {
+ writeContinueIfRequired(8);
+ _ulrOutput.writeLong(v);
+ }
+ @Override
+ public void writeShort(int v) {
+ writeContinueIfRequired(2);
+ _ulrOutput.writeShort(v);
+ }
+
+ /**
+ * Allows optimised usage of {@link ContinuableRecordOutput} for sizing purposes only.
+ */
+ private static final LittleEndianOutput NOPOutput = new DelayableLittleEndianOutput() {
+
+ @Override
+ public LittleEndianOutput createDelayedOutput(int size) {
+ return this;
+ }
+ @Override
+ public void write(byte[] b) {
+ // does nothing
+ }
+ @Override
+ public void write(byte[] b, int offset, int len) {
+ // does nothing
+ }
+ @Override
+ public void writeByte(int v) {
+ // does nothing
+ }
+ @Override
+ public void writeDouble(double v) {
+ // does nothing
+ }
+ @Override
+ public void writeInt(int v) {
+ // does nothing
+ }
+ @Override
+ public void writeLong(long v) {
+ // does nothing
+ }
+ @Override
+ public void writeShort(int v) {
+ // does nothing
+ }
+ };
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org