Modified: poi/trunk/src/java/org/apache/poi/hssf/record/RKRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/RKRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/RKRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/RKRecord.java Sun Dec 22 21:44:45 2019 @@ -19,30 +19,31 @@ package org.apache.poi.hssf.record; import org.apache.poi.hssf.util.RKUtil; import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.Removal; /** - * Title: RK Record (0x027E)<p> - * Description: An internal 32 bit number with the two most significant bits - * storing the type. This is part of a bizarre scheme to save disk - * space and memory (gee look at all the other whole records that - * are in the file just "cause"..,far better to waste processor - * cycles on this then leave on of those "valuable" records out).<p> + * An internal 32 bit number with the two most significant bits storing the type. + * This is part of a bizarre scheme to save disk space and memory (gee look at all the other whole + * records that are in the file just "cause".., far better to waste processor cycles on this then + * leave on of those "valuable" records out). * We support this in READ-ONLY mode. HSSF converts these to NUMBER records<p> * - * REFERENCE: PG 376 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2) - * * @see org.apache.poi.hssf.record.NumberRecord */ public final class RKRecord extends CellRecord { - public final static short sid = 0x027E; - public final static short RK_IEEE_NUMBER = 0; - public final static short RK_IEEE_NUMBER_TIMES_100 = 1; - public final static short RK_INTEGER = 2; - public final static short RK_INTEGER_TIMES_100 = 3; + public static final short sid = 0x027E; + public static final short RK_IEEE_NUMBER = 0; + public static final short RK_IEEE_NUMBER_TIMES_100 = 1; + public static final short RK_INTEGER = 2; + public static final short RK_INTEGER_TIMES_100 = 3; + private int field_4_rk_number; - private RKRecord() { - // fields uninitialised + private RKRecord() {} + + public RKRecord(RKRecord other) { + super(other); + field_4_rk_number = other.field_4_rk_number; } public RKRecord(RecordInputStream in) { @@ -97,10 +98,15 @@ public final class RKRecord extends Cell } @Override - public Object clone() { - RKRecord rec = new RKRecord(); - copyBaseFields(rec); - rec.field_4_rk_number = field_4_rk_number; - return rec; + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public RKRecord clone() { + return copy(); + } + + @Override + public RKRecord copy() { + return new RKRecord(this); } }
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/RecalcIdRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/RecalcIdRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/RecalcIdRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/RecalcIdRecord.java Sun Dec 22 21:44:45 2019 @@ -21,18 +21,16 @@ import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndianOutput; /** - * Title: Recalc Id Record (0x01C1)<p> - * Description: This record contains an ID that marks when a worksheet was last - * recalculated. It's an optimization Excel uses to determine if it - * needs to recalculate the spreadsheet when it's opened. So far, only - * the two engine ids {@code 0x80 0x38 0x01 0x00} - * and {@code 0x60 0x69 0x01 0x00} have been seen. - * A value of {@code 0x00} will cause Excel to recalculate - * all formulas on the next load.<p> - * REFERENCE: http://chicago.sourceforge.net/devel/docs/excel/biff8.html + * This record contains an ID that marks when a worksheet was last recalculated. + * It's an optimization Excel uses to determine if it needs to recalculate the spreadsheet + * when it's opened. So far, only the two engine ids {@code 0x80 0x38 0x01 0x00} and + * {@code 0x60 0x69 0x01 0x00} have been seen. A value of {@code 0x00} will cause Excel + * to recalculate all formulas on the next load. + * + * @see <a href="http://chicago.sourceforge.net/devel/docs/excel/biff8.html">Chicago biff8 docs</a> */ public final class RecalcIdRecord extends StandardRecord { - public final static short sid = 0x01C1; + public static final short sid = 0x01C1; private final int _reserved0; /** @@ -49,6 +47,11 @@ public final class RecalcIdRecord extend _engineId = 0; } + public RecalcIdRecord(RecalcIdRecord other) { + _reserved0 = other._reserved0; + _engineId = other._engineId; + } + public RecalcIdRecord(RecordInputStream in) { in.readUShort(); // field 'rt' should have value 0x01C1, but Excel doesn't care during reading _reserved0 = in.readUShort(); @@ -90,4 +93,9 @@ public final class RecalcIdRecord extend public short getSid() { return sid; } + + @Override + public RecalcIdRecord copy() { + return new RecalcIdRecord(this); + } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/Record.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/Record.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/Record.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/Record.java Sun Dec 22 21:44:45 2019 @@ -19,14 +19,16 @@ package org.apache.poi.hssf.record; import java.io.ByteArrayInputStream; +import org.apache.poi.common.Duplicatable; + /** * All HSSF Records inherit from this class. */ -public abstract class Record extends RecordBase { +public abstract class Record extends RecordBase implements Duplicatable { - protected Record() { - // no fields to initialise - } + protected Record() {} + + protected Record(Record other) {} /** * called by the class that is responsible for writing this sucker. @@ -52,16 +54,11 @@ public abstract class Record extends Rec /** * return the non static version of the id for this record. - * + * * @return he id for this record */ public abstract short getSid(); - @Override - public Object clone() throws CloneNotSupportedException { - throw new CloneNotSupportedException("The class "+getClass().getName()+" needs to define a clone method"); - } - /** * Clone the current record, via a call to serialize * it, and another to create a new record from the @@ -70,7 +67,7 @@ public abstract class Record extends Rec * internal counts / ids in them. For those which * do, a full model-aware cloning is needed, which * allocates new ids / counts as needed. - * + * * @return the cloned current record */ public Record cloneViaReserialise() { @@ -86,4 +83,6 @@ public abstract class Record extends Rec } return r[0]; } + + public abstract Record copy(); } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/RecordBase.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/RecordBase.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/RecordBase.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/RecordBase.java Sun Dec 22 21:44:45 2019 @@ -25,7 +25,7 @@ public abstract class RecordBase { * called by the class that is responsible for writing this sucker. * Subclasses should implement this so that their data is passed back in a * byte array. - * + * * @param offset to begin writing at * @param data byte array containing instance data * @return number of bytes written @@ -35,7 +35,7 @@ public abstract class RecordBase { /** * gives the current serialized size of the record. Should include the sid * and reclength (4 bytes). - * + * * @return the record size */ public abstract int getRecordSize(); Modified: poi/trunk/src/java/org/apache/poi/hssf/record/RecordInputStream.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/RecordInputStream.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/RecordInputStream.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/RecordInputStream.java Sun Dec 22 21:44:45 2019 @@ -41,7 +41,7 @@ public final class RecordInputStream imp /** Maximum size of a single record (minus the 4 byte header) without a continue*/ - public final static short MAX_RECORD_DATA_SIZE = 8224; + public static final short MAX_RECORD_DATA_SIZE = 8224; private static final int INVALID_SID_VALUE = -1; //arbitrarily selected; may need to increase private static final int MAX_RECORD_LENGTH = 100_000; @@ -60,7 +60,7 @@ public final class RecordInputStream imp public static final class LeftoverDataException extends RuntimeException { public LeftoverDataException(int sid, int remainingByteCount) { super("Initialisation of record 0x" + Integer.toHexString(sid).toUpperCase(Locale.ROOT) - + "(" + getRecordName(sid) + ") left " + remainingByteCount + + "(" + getRecordName(sid) + ") left " + remainingByteCount + " bytes remaining still to be read."); } @@ -177,9 +177,9 @@ public final class RecordInputStream imp /** * Note - this method is expected to be called only when completed reading the current BIFF * record. - * + * * @return true, if there's another record in the stream - * + * * @throws LeftoverDataException if this method is called before reaching the end of the * current record. */ @@ -268,7 +268,7 @@ public final class RecordInputStream imp } /** - * Reads a 32 bit, signed value + * Reads a 32 bit, signed value */ @Override public int readInt() { @@ -310,11 +310,11 @@ public final class RecordInputStream imp // YK: Excel doesn't write NaN but instead converts the cell type into {@link CellType#ERROR}. return Double.longBitsToDouble(readLong()); } - + public void readPlain(byte[] buf, int off, int len) { readFully(buf, 0, buf.length, true); } - + @Override public void readFully(byte[] buf) { readFully(buf, 0, buf.length, false); @@ -324,7 +324,7 @@ public final class RecordInputStream imp public void readFully(byte[] buf, int off, int len) { readFully(buf, off, len, false); } - + private void readFully(byte[] buf, int off, int len, boolean isPlain) { int origLen = len; if (buf == null) { @@ -332,7 +332,7 @@ public final class RecordInputStream imp } else if (off < 0 || len < 0 || len > buf.length - off) { throw new IndexOutOfBoundsException(); } - + while (len > 0) { int nextChunk = Math.min(available(),len); if (nextChunk == 0) { @@ -452,7 +452,7 @@ public final class RecordInputStream imp * into any following continue records. * * @return all byte data for the current record - * + * * @deprecated POI 2.0 Best to write a input stream that wraps this one * where there is special sub record that may overlap continue * records. @@ -511,10 +511,10 @@ public final class RecordInputStream imp } /** - * Mark the stream position - experimental function + * Mark the stream position - experimental function * * @param readlimit the read ahead limit - * + * * @see InputStream#mark(int) */ @Internal @@ -522,13 +522,13 @@ public final class RecordInputStream imp ((InputStream)_dataInput).mark(readlimit); _markedDataOffset = _currentDataOffset; } - + /** * Resets the stream position to the previously marked position. * Experimental function - this only works, when nextRecord() wasn't called in the meantime. * * @throws IOException if marking is not supported - * + * * @see InputStream#reset() */ @Internal Modified: poi/trunk/src/java/org/apache/poi/hssf/record/RefModeRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/RefModeRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/RefModeRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/RefModeRecord.java Sun Dec 22 21:44:45 2019 @@ -15,35 +15,32 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - + package org.apache.poi.hssf.record; import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.Removal; /** - * Title: RefMode Record<P> - * Description: Describes which reference mode to use<P> - * REFERENCE: PG 376 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P> - * @author Andrew C. Oliver (acoliver at apache dot org) - * @author Jason Height (jheight at chariot dot net dot au) + * Describes which reference mode to use + * * @version 2.0-pre */ -public final class RefModeRecord - extends StandardRecord -{ - public final static short sid = 0xf; - public final static short USE_A1_MODE = 1; - public final static short USE_R1C1_MODE = 0; +public final class RefModeRecord extends StandardRecord { + public static final short sid = 0xf; + public static final short USE_A1_MODE = 1; + public static final short USE_R1C1_MODE = 0; private short field_1_mode; - public RefModeRecord() - { + public RefModeRecord() {} + + public RefModeRecord(RefModeRecord other) { + field_1_mode = other.field_1_mode; } - public RefModeRecord(RecordInputStream in) - { + public RefModeRecord(RecordInputStream in) { field_1_mode = in.readShort(); } @@ -96,9 +93,16 @@ public final class RefModeRecord return sid; } - public Object clone() { - RefModeRecord rec = new RefModeRecord(); - rec.field_1_mode = field_1_mode; - return rec; + @Override + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public RefModeRecord clone() { + return copy(); + } + + @Override + public RefModeRecord copy() { + return new RefModeRecord(); } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/RefreshAllRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/RefreshAllRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/RefreshAllRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/RefreshAllRecord.java Sun Dec 22 21:44:45 2019 @@ -21,15 +21,14 @@ import org.apache.poi.util.BitField; import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.Removal; /** - * Title: Refresh All Record (0x01B7)<p> - * Description: Flag whether to refresh all external data when loading a sheet. - * (which hssf doesn't support anyhow so who really cares?)<p> - * REFERENCE: PG 376 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2) + * Flag whether to refresh all external data when loading a sheet. + * (which hssf doesn't support anyhow so who really cares?) */ public final class RefreshAllRecord extends StandardRecord { - public final static short sid = 0x01B7; + public static final short sid = 0x01B7; private static final BitField refreshFlag = BitFieldFactory.getInstance(0x0001); @@ -39,6 +38,11 @@ public final class RefreshAllRecord exte _options = options; } + private RefreshAllRecord(RefreshAllRecord other) { + super(other); + _options = other._options; + } + public RefreshAllRecord(RecordInputStream in) { this(in.readUShort()); } @@ -84,8 +88,17 @@ public final class RefreshAllRecord exte public short getSid() { return sid; } + + @Override + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public RefreshAllRecord clone() { + return copy(); + } + @Override - public Object clone() { - return new RefreshAllRecord(_options); + public RefreshAllRecord copy() { + return new RefreshAllRecord(this); } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/RightMarginRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/RightMarginRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/RightMarginRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/RightMarginRecord.java Sun Dec 22 21:44:45 2019 @@ -18,18 +18,23 @@ package org.apache.poi.hssf.record; import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.Removal; /** * Record for the right margin. */ public final class RightMarginRecord extends StandardRecord implements Margin { - public final static short sid = 0x27; + public static final short sid = 0x27; private double field_1_margin; - public RightMarginRecord() { } + public RightMarginRecord() {} - public RightMarginRecord( RecordInputStream in ) - { + public RightMarginRecord(RightMarginRecord other) { + super(other); + field_1_margin = other.field_1_margin; + } + + public RightMarginRecord( RecordInputStream in ) { field_1_margin = in.readDouble(); } @@ -63,10 +68,15 @@ public final class RightMarginRecord ext public void setMargin( double field_1_margin ) { this.field_1_margin = field_1_margin; } - public Object clone() - { - RightMarginRecord rec = new RightMarginRecord(); - rec.field_1_margin = this.field_1_margin; - return rec; + @Override + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public RightMarginRecord clone() { + return copy(); + } + + public RightMarginRecord copy() { + return new RightMarginRecord(this); } -} // END OF \ No newline at end of file +} \ No newline at end of file Modified: poi/trunk/src/java/org/apache/poi/hssf/record/RowRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/RowRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/RowRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/RowRecord.java Sun Dec 22 21:44:45 2019 @@ -21,22 +21,34 @@ import org.apache.poi.util.BitField; import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.Removal; /** - * Title: Row Record (0x0208)<p> - * Description: stores the row information for the sheet.<p> - * REFERENCE: PG 379 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2) - * + * Stores the row information for the sheet. + * * @since 2.0-pre */ public final class RowRecord extends StandardRecord { - public final static short sid = 0x0208; + public static final short sid = 0x0208; public static final int ENCODED_SIZE = 20; - + private static final int OPTION_BITS_ALWAYS_SET = 0x0100; //private static final int DEFAULT_HEIGHT_BIT = 0x8000; + private static final BitField outlineLevel = BitFieldFactory.getInstance(0x07); + // bit 3 reserved + private static final BitField colapsed = BitFieldFactory.getInstance(0x10); + private static final BitField zeroHeight = BitFieldFactory.getInstance(0x20); + private static final BitField badFontHeight = BitFieldFactory.getInstance(0x40); + private static final BitField formatted = BitFieldFactory.getInstance(0x80); + + private static final BitField xfIndex = BitFieldFactory.getInstance(0xFFF); + private static final BitField topBorder = BitFieldFactory.getInstance(0x1000); + private static final BitField bottomBorder = BitFieldFactory.getInstance(0x2000); + private static final BitField phoeneticGuide = BitFieldFactory.getInstance(0x4000); + // bit 15 is unused + private int field_1_row_number; private int field_2_first_col; private int field_3_last_col; // plus 1 @@ -47,20 +59,21 @@ public final class RowRecord extends Sta private short field_6_reserved; /** 16 bit options flags */ private int field_7_option_flags; - private static final BitField outlineLevel = BitFieldFactory.getInstance(0x07); - // bit 3 reserved - private static final BitField colapsed = BitFieldFactory.getInstance(0x10); - private static final BitField zeroHeight = BitFieldFactory.getInstance(0x20); - private static final BitField badFontHeight = BitFieldFactory.getInstance(0x40); - private static final BitField formatted = BitFieldFactory.getInstance(0x80); - /** 16 bit options flags */ private int field_8_option_flags; // only if isFormatted - private static final BitField xfIndex = BitFieldFactory.getInstance(0xFFF); - private static final BitField topBorder = BitFieldFactory.getInstance(0x1000); - private static final BitField bottomBorder = BitFieldFactory.getInstance(0x2000); - private static final BitField phoeneticGuide = BitFieldFactory.getInstance(0x4000); - // bit 15 is unused + + public RowRecord(RowRecord other) { + super(other); + field_1_row_number = other.field_1_row_number; + field_2_first_col = other.field_2_first_col; + field_3_last_col = other.field_3_last_col; + field_4_height = other.field_4_height; + field_5_optimize = other.field_5_optimize; + field_6_reserved = other.field_6_reserved; + field_7_option_flags = other.field_7_option_flags; + field_8_option_flags = other.field_8_option_flags; + } + public RowRecord(int rowNumber) { if(rowNumber < 0) { @@ -91,7 +104,7 @@ public final class RowRecord extends Sta } /** - * Updates the firstCol and lastCol fields to the reserved value (-1) + * Updates the firstCol and lastCol fields to the reserved value (-1) * to signify that this row is empty */ public void setEmpty() { @@ -101,7 +114,7 @@ public final class RowRecord extends Sta public boolean isEmpty() { return (field_2_first_col | field_3_last_col) == 0; } - + /** * set the logical row number for this row (0 based index) * @param row - the row number @@ -202,7 +215,7 @@ public final class RowRecord extends Sta public void setTopBorder(boolean f) { field_8_option_flags = topBorder.setBoolean(field_8_option_flags, f); } - + /** * A bit that specifies whether any cell in the row has a medium or thick * bottom border, or any cell in the row directly below the current row has @@ -212,7 +225,7 @@ public final class RowRecord extends Sta public void setBottomBorder(boolean f) { field_8_option_flags = bottomBorder.setBoolean(field_8_option_flags, f); } - + /** * A bit that specifies whether the phonetic guide feature is enabled for * any cell in this row. @@ -221,7 +234,7 @@ public final class RowRecord extends Sta public void setPhoeneticGuide(boolean f) { field_8_option_flags = phoeneticGuide.setBoolean(field_8_option_flags, f); } - + /** * get the logical row number for this row (0 based index) * @return row - the row number @@ -239,7 +252,7 @@ public final class RowRecord extends Sta } /** - * get the logical col number for the last cell this row (0 based index), plus one + * get the logical col number for the last cell this row (0 based index), plus one * @return col - the last col index + 1 */ public int getLastCol() { @@ -328,7 +341,7 @@ public final class RowRecord extends Sta public short getOptionFlags2() { return (short)field_8_option_flags; } - + /** * if the row is formatted then this is the index to the extended format record * @see org.apache.poi.hssf.record.ExtendedFormatRecord @@ -364,7 +377,7 @@ public final class RowRecord extends Sta public boolean getPhoeneticGuide() { return phoeneticGuide.isSet(field_8_option_flags); } - + public String toString() { StringBuilder sb = new StringBuilder(); @@ -410,15 +423,16 @@ public final class RowRecord extends Sta return sid; } - public Object clone() { - RowRecord rec = new RowRecord(field_1_row_number); - rec.field_2_first_col = field_2_first_col; - rec.field_3_last_col = field_3_last_col; - rec.field_4_height = field_4_height; - rec.field_5_optimize = field_5_optimize; - rec.field_6_reserved = field_6_reserved; - rec.field_7_option_flags = field_7_option_flags; - rec.field_8_option_flags = field_8_option_flags; - return rec; + @Override + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public RowRecord clone() { + return copy(); + } + + @Override + public RowRecord copy() { + return new RowRecord(this); } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/SCLRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/SCLRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/SCLRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/SCLRecord.java Sun Dec 22 21:44:45 2019 @@ -19,24 +19,27 @@ package org.apache.poi.hssf.record; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.Removal; /** * Specifies the window's zoom magnification.<p> * If this record isn't present then the windows zoom is 100%. see p384 Excel Dev Kit */ public final class SCLRecord extends StandardRecord { - public final static short sid = 0x00A0; - private short field_1_numerator; - private short field_2_denominator; + public static final short sid = 0x00A0; + private short field_1_numerator; + private short field_2_denominator; - public SCLRecord() - { + public SCLRecord() {} + public SCLRecord(SCLRecord other) { + super(other); + field_1_numerator = other.field_1_numerator; + field_2_denominator = other.field_2_denominator; } - public SCLRecord(RecordInputStream in) - { + public SCLRecord(RecordInputStream in) { field_1_numerator = in.readShort(); field_2_denominator = in.readShort(); } @@ -50,11 +53,11 @@ public final class SCLRecord extends Sta buffer.append(" .numerator = ") .append("0x").append(HexDump.toHex( getNumerator ())) .append(" (").append( getNumerator() ).append(" )"); - buffer.append(System.getProperty("line.separator")); + buffer.append(System.getProperty("line.separator")); buffer.append(" .denominator = ") .append("0x").append(HexDump.toHex( getDenominator ())) .append(" (").append( getDenominator() ).append(" )"); - buffer.append(System.getProperty("line.separator")); + buffer.append(System.getProperty("line.separator")); buffer.append("[/SCL]\n"); return buffer.toString(); @@ -78,17 +81,21 @@ public final class SCLRecord extends Sta } @Override - public Object clone() { - SCLRecord rec = new SCLRecord(); - - rec.field_1_numerator = field_1_numerator; - rec.field_2_denominator = field_2_denominator; - return rec; + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public SCLRecord clone() { + return copy(); + } + + @Override + public SCLRecord copy() { + return new SCLRecord(this); } /** * Get the numerator field for the SCL record. - * + * * @return the numerator */ public short getNumerator() @@ -98,7 +105,7 @@ public final class SCLRecord extends Sta /** * Set the numerator field for the SCL record. - * + * * @param field_1_numerator the numerator */ public void setNumerator(short field_1_numerator) @@ -108,7 +115,7 @@ public final class SCLRecord extends Sta /** * Get the denominator field for the SCL record. - * + * * @return the denominator */ public short getDenominator() @@ -118,7 +125,7 @@ public final class SCLRecord extends Sta /** * Set the denominator field for the SCL record. - * + * * @param field_2_denominator the denominator */ public void setDenominator(short field_2_denominator) Modified: poi/trunk/src/java/org/apache/poi/hssf/record/SSTRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/SSTRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/SSTRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/SSTRecord.java Sun Dec 22 21:44:45 2019 @@ -23,14 +23,11 @@ import org.apache.poi.hssf.record.common import org.apache.poi.hssf.record.cont.ContinuableRecord; import org.apache.poi.hssf.record.cont.ContinuableRecordOutput; import org.apache.poi.util.IntMapper; -import org.apache.poi.util.LittleEndianConsts; /** - * Title: Static String Table Record (0x00FC)<p> + * Static String Table Record (0x00FC)<p> * - * Description: This holds all the strings for LabelSSTRecords.<p> - * - * REFERENCE: PG 389 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2) + * This holds all the strings for LabelSSTRecords. * * @see org.apache.poi.hssf.record.LabelSSTRecord * @see org.apache.poi.hssf.record.ContinueRecord @@ -40,38 +37,45 @@ public final class SSTRecord extends Con private static final UnicodeString EMPTY_STRING = new UnicodeString(""); - // TODO - move these constants to test class (the only consumer) - /** standard record overhead: two shorts (record id plus data space size)*/ - static final int STD_RECORD_OVERHEAD = 2 * LittleEndianConsts.SHORT_SIZE; - - /** SST overhead: the standard record overhead, plus the number of strings and the number of unique strings -- two ints */ - static final int SST_RECORD_OVERHEAD = STD_RECORD_OVERHEAD + 2 * LittleEndianConsts.INT_SIZE; - - /** how much data can we stuff into an SST record? That would be _max minus the standard SST record overhead */ - static final int MAX_DATA_SPACE = RecordInputStream.MAX_RECORD_DATA_SIZE - 8; - - /** union of strings in the SST and EXTSST */ + /** + * union of strings in the SST and EXTSST + */ private int field_1_num_strings; - /** according to docs ONLY SST */ + /** + * according to docs ONLY SST + */ private int field_2_num_unique_strings; private IntMapper<UnicodeString> field_3_strings; private SSTDeserializer deserializer; - /** Offsets from the beginning of the SST record (even across continuations) */ - int[] bucketAbsoluteOffsets; - /** Offsets relative the start of the current SST or continue record */ - int[] bucketRelativeOffsets; + /** + * Offsets from the beginning of the SST record (even across continuations) + */ + private int[] bucketAbsoluteOffsets; + /** + * Offsets relative the start of the current SST or continue record + */ + private int[] bucketRelativeOffsets; - public SSTRecord() - { + public SSTRecord() { field_1_num_strings = 0; field_2_num_unique_strings = 0; field_3_strings = new IntMapper<>(); deserializer = new SSTDeserializer(field_3_strings); } + public SSTRecord(SSTRecord other) { + super(other); + field_1_num_strings = other.field_1_num_strings; + field_2_num_unique_strings = other.field_2_num_unique_strings; + field_3_strings = other.field_3_strings.copy(); + deserializer = new SSTDeserializer(field_3_strings); + bucketAbsoluteOffsets = (other.bucketAbsoluteOffsets == null) ? null : other.bucketAbsoluteOffsets.clone(); + bucketRelativeOffsets = (other.bucketRelativeOffsets == null) ? null : other.bucketRelativeOffsets.clone(); + } + /** * Add a string. * @@ -242,7 +246,7 @@ public final class SSTRecord extends Con field_1_num_strings = in.readInt(); field_2_num_unique_strings = in.readInt(); field_3_strings = new IntMapper<>(); - + deserializer = new SSTDeserializer(field_3_strings); // Bug 57456: some Excel Sheets send 0 as field=1, but have some random number in field_2, // we should not try to read the strings in this case. @@ -319,4 +323,9 @@ public final class SSTRecord extends Con public int calcExtSSTRecordSize() { return ExtSSTRecord.getRecordSizeForStrings(field_3_strings.size()); } + + @Override + public SSTRecord copy() { + return new SSTRecord(this); + } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java Sun Dec 22 21:44:45 2019 @@ -18,43 +18,44 @@ package org.apache.poi.hssf.record; import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.Removal; /** - * Title: Save Recalc Record <P> - * Description: defines whether to recalculate before saving (set to true)<P> - * REFERENCE: PG 381 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P> - * @author Andrew C. Oliver (acoliver at apache dot org) - * @author Jason Height (jheight at chariot dot net dot au) + * Defines whether to recalculate before saving (set to true) + * * @version 2.0-pre */ -public final class SaveRecalcRecord - extends StandardRecord -{ - public final static short sid = 0x5f; - private short field_1_recalc; +public final class SaveRecalcRecord extends StandardRecord { + public static final short sid = 0x5f; + private short field_1_recalc; public SaveRecalcRecord() { } - public SaveRecalcRecord(RecordInputStream in) - { + public SaveRecalcRecord(SaveRecalcRecord other) { + super(other); + field_1_recalc = other.field_1_recalc; + } + + public SaveRecalcRecord(RecordInputStream in) { field_1_recalc = in.readShort(); } /** * set whether to recalculate formulas/etc before saving or not + * * @param recalc - whether to recalculate or not */ public void setRecalc(boolean recalc) { - field_1_recalc = ( short ) (recalc ? 1 : 0); + field_1_recalc = (short) (recalc ? 1 : 0); } /** * get whether to recalculate formulas/etc before saving or not + * * @return recalc - whether to recalculate or not */ - public boolean getRecalc() - { + public boolean getRecalc() { return (field_1_recalc == 1); } @@ -73,14 +74,20 @@ public final class SaveRecalcRecord return 2; } - public short getSid() - { + public short getSid() { return sid; } - public Object clone() { - SaveRecalcRecord rec = new SaveRecalcRecord(); - rec.field_1_recalc = field_1_recalc; - return rec; + @Override + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public SaveRecalcRecord clone() { + return copy(); + } + + @Override + public SaveRecalcRecord copy() { + return new SaveRecalcRecord(this); } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/ScenarioProtectRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/ScenarioProtectRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/ScenarioProtectRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/ScenarioProtectRecord.java Sun Dec 22 21:44:45 2019 @@ -15,35 +15,30 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - + package org.apache.poi.hssf.record; import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.Removal; /** - * Title: Scenario Protect Record<P> - * Description: I have no idea what a Scenario is or why on would want to - * protect it with the lamest "security" ever invented. However this record tells - * excel "I want to protect my scenarios" (0xAF) with lame security. It appears - * in conjunction with the PASSWORD and PROTECT records as well as its object - * protect cousin.<P> - * REFERENCE: PG 383 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P> - * @author Andrew C. Oliver (acoliver at apache dot org) + * I have no idea what a Scenario is or why on would want to protect it with the lamest "security" ever invented. + * However this record tells excel "I want to protect my scenarios" (0xAF) with lame security. + * It appears in conjunction with the PASSWORD and PROTECT records as well as its object protect cousin. */ +public final class ScenarioProtectRecord extends StandardRecord { + public static final short sid = 0xdd; + private short field_1_protect; -public final class ScenarioProtectRecord - extends StandardRecord -{ - public final static short sid = 0xdd; - private short field_1_protect; + public ScenarioProtectRecord() {} - public ScenarioProtectRecord() - { + public ScenarioProtectRecord(ScenarioProtectRecord other) { + super(other); + field_1_protect = other.field_1_protect; } - public ScenarioProtectRecord(RecordInputStream in) - { + public ScenarioProtectRecord(RecordInputStream in) { field_1_protect = in.readShort(); } @@ -98,9 +93,15 @@ public final class ScenarioProtectRecord return sid; } - public Object clone() { - ScenarioProtectRecord rec = new ScenarioProtectRecord(); - rec.field_1_protect = field_1_protect; - return rec; + @Override + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public ScenarioProtectRecord clone() { + return copy(); + } + + public ScenarioProtectRecord copy() { + return new ScenarioProtectRecord(this); } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/SelectionRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/SelectionRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/SelectionRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/SelectionRecord.java Sun Dec 22 21:44:45 2019 @@ -17,28 +17,39 @@ package org.apache.poi.hssf.record; +import java.util.stream.Stream; + import org.apache.poi.hssf.util.CellRangeAddress8Bit; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.Removal; /** - * Title: Selection Record (0x001D)<P> - * Description: shows the user's selection on the sheet - * for write set num refs to 0<P> - * - * REFERENCE: PG 291 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2) + * Shows the user's selection on the sheet for write set num refs to 0 */ public final class SelectionRecord extends StandardRecord { - public final static short sid = 0x001D; - private byte field_1_pane; - private int field_2_row_active_cell; - private int field_3_col_active_cell; - private int field_4_active_cell_ref_index; + public static final short sid = 0x001D; + + + private byte field_1_pane; + private int field_2_row_active_cell; + private int field_3_col_active_cell; + private int field_4_active_cell_ref_index; private CellRangeAddress8Bit[] field_6_refs; + public SelectionRecord(SelectionRecord other) { + super(other); + field_1_pane = other.field_1_pane; + field_2_row_active_cell = other.field_2_row_active_cell; + field_3_col_active_cell = other.field_3_col_active_cell; + field_4_active_cell_ref_index = other.field_4_active_cell_ref_index; + field_6_refs = (other.field_6_refs == null) ? null + : Stream.of(other.field_6_refs).map(CellRangeAddress8Bit::copy).toArray(CellRangeAddress8Bit[]::new); + } + /** * Creates a default selection record (cell A1, in pane ID 3) - * + * * @param activeCellRow the active cells row index * @param activeCellCol the active cells column index */ @@ -172,11 +183,15 @@ public final class SelectionRecord exten } @Override - public Object clone() { - SelectionRecord rec = new SelectionRecord(field_2_row_active_cell, field_3_col_active_cell); - rec.field_1_pane = field_1_pane; - rec.field_4_active_cell_ref_index = field_4_active_cell_ref_index; - rec.field_6_refs = field_6_refs; - return rec; + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public SelectionRecord clone() { + return copy(); + } + + @Override + public SelectionRecord copy() { + return new SelectionRecord(this); } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java Sun Dec 22 21:44:45 2019 @@ -17,27 +17,26 @@ package org.apache.poi.hssf.record; -import org.apache.poi.ss.formula.ptg.*; import org.apache.poi.hssf.util.CellRangeAddress8Bit; -import org.apache.poi.ss.formula.Formula; import org.apache.poi.ss.SpreadsheetVersion; +import org.apache.poi.ss.formula.Formula; import org.apache.poi.ss.formula.SharedFormula; +import org.apache.poi.ss.formula.ptg.Ptg; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.Removal; /** - * Title: SHAREDFMLA (0x04BC) SharedFormulaRecord - * Description: Primarily used as an excel optimization so that multiple similar formulas - * are not written out too many times. We should recognize this record and - * serialize as is since this is used when reading templates. + * Primarily used as an excel optimization so that multiple similar formulas are not + * written out too many times. We should recognize this record and serialize as is + * since this is used when reading templates. * <p> * Note: the documentation says that the SID is BC where biffviewer reports 4BC. The hex dump shows * that the two byte sid representation to be 'BC 04' that is consistent with the other high byte * record types. - * @author Danny Mui at apache dot org */ public final class SharedFormulaRecord extends SharedValueRecordBase { - public final static short sid = 0x04BC; + public static final short sid = 0x04BC; private int field_5_reserved; private Formula field_7_parsed_expr; @@ -46,6 +45,13 @@ public final class SharedFormulaRecord e public SharedFormulaRecord() { this(new CellRangeAddress8Bit(0,0,0,0)); } + + public SharedFormulaRecord(SharedFormulaRecord other) { + super(other); + field_5_reserved = other.field_5_reserved; + field_7_parsed_expr = (other.field_7_parsed_expr == null) ? null : other.field_7_parsed_expr.copy(); + } + private SharedFormulaRecord(CellRangeAddress8Bit range) { super(range); field_7_parsed_expr = Formula.create(Ptg.EMPTY_PTG_ARRAY); @@ -117,11 +123,17 @@ public final class SharedFormulaRecord e return sf.convertSharedFormulas(field_7_parsed_expr.getTokens(), formulaRow, formulaColumn); } - public Object clone() { - SharedFormulaRecord result = new SharedFormulaRecord(getRange()); - result.field_5_reserved = field_5_reserved; - result.field_7_parsed_expr = field_7_parsed_expr.copy(); - return result; + @Override + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public SharedFormulaRecord clone() { + return copy(); + } + + @Override + public SharedFormulaRecord copy() { + return new SharedFormulaRecord(this); } public boolean isFormulaSame(SharedFormulaRecord other) { return field_7_parsed_expr.isSame(other.field_7_parsed_expr); Modified: poi/trunk/src/java/org/apache/poi/hssf/record/SharedValueRecordBase.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/SharedValueRecordBase.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/SharedValueRecordBase.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/SharedValueRecordBase.java Sun Dec 22 21:44:45 2019 @@ -29,6 +29,11 @@ public abstract class SharedValueRecordB private CellRangeAddress8Bit _range; + protected SharedValueRecordBase(SharedValueRecordBase other) { + super(other); + _range = (other._range == null) ? null : other._range.copy(); + } + protected SharedValueRecordBase(CellRangeAddress8Bit range) { if (range == null) { throw new IllegalArgumentException("range must be supplied."); @@ -88,9 +93,9 @@ public abstract class SharedValueRecordB /** * @param rowIx the row index * @param colIx the column index - * + * * @return {@code true} if (rowIx, colIx) is within the range of this shared value object. - * + * * @see #getRange() */ public final boolean isInRange(int rowIx, int colIx) { Modified: poi/trunk/src/java/org/apache/poi/hssf/record/StandardRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/StandardRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/StandardRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/StandardRecord.java Sun Dec 22 21:44:45 2019 @@ -29,6 +29,10 @@ import org.apache.poi.util.LittleEndianO public abstract class StandardRecord extends Record { protected abstract int getDataSize(); + protected StandardRecord() {} + + protected StandardRecord(StandardRecord other) {} + @Override public final int getRecordSize() { return 4 + getDataSize(); @@ -75,4 +79,6 @@ public abstract class StandardRecord ext * the output object */ protected abstract void serialize(LittleEndianOutput out); + + public abstract StandardRecord copy(); } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/StringRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/StringRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/StringRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/StringRecord.java Sun Dec 22 21:44:45 2019 @@ -19,20 +19,25 @@ package org.apache.poi.hssf.record; import org.apache.poi.hssf.record.cont.ContinuableRecord; import org.apache.poi.hssf.record.cont.ContinuableRecordOutput; +import org.apache.poi.util.Removal; import org.apache.poi.util.StringUtil; /** * STRING (0x0207)<p> - * + * * Stores the cached result of a text formula */ public final class StringRecord extends ContinuableRecord { - public final static short sid = 0x0207; + public static final short sid = 0x0207; private boolean _is16bitUnicode; private String _text; - public StringRecord() { + public StringRecord() {} + + public StringRecord(StringRecord other) { + _is16bitUnicode = other._is16bitUnicode; + _text = other._text; } /** @@ -41,7 +46,7 @@ public final class StringRecord extends public StringRecord( RecordInputStream in) { int field_1_string_length = in.readUShort(); _is16bitUnicode = in.readByte() != 0x00; - + if (_is16bitUnicode){ _text = in.readUnicodeLEString(field_1_string_length); } else { @@ -74,7 +79,7 @@ public final class StringRecord extends */ public void setString(String string) { _text = string; - _is16bitUnicode = StringUtil.hasMultibyte(string); + _is16bitUnicode = StringUtil.hasMultibyte(string); } public String toString() { @@ -82,11 +87,16 @@ public final class StringRecord extends " .string = " + _text + "\n" + "[/STRING]\n"; } - - public Object clone() { - StringRecord rec = new StringRecord(); - rec._is16bitUnicode= _is16bitUnicode; - rec._text = _text; - return rec; + + @Override + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public StringRecord clone() { + return copy(); + } + + public StringRecord copy() { + return new StringRecord(this); } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java Sun Dec 22 21:44:45 2019 @@ -25,12 +25,10 @@ import org.apache.poi.util.RecordFormatE import org.apache.poi.util.StringUtil; /** - * Title: Style Record (0x0293)<p> - * Description: Describes a builtin to the gui or user defined style<p> - * REFERENCE: PG 390 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2) + * Describes a builtin to the gui or user defined style */ public final class StyleRecord extends StandardRecord { - public final static short sid = 0x0293; + public static final short sid = 0x0293; private static final BitField styleIndexMask = BitFieldFactory.getInstance(0x0FFF); private static final BitField isBuiltinFlag = BitFieldFactory.getInstance(0x8000); @@ -53,6 +51,15 @@ public final class StyleRecord extends S field_1_xf_index = isBuiltinFlag.set(0); } + public StyleRecord(StyleRecord other) { + super(other); + field_1_xf_index = other.field_1_xf_index; + field_2_builtin_style = other.field_2_builtin_style; + field_3_outline_style_level = other.field_3_outline_style_level; + field_3_stringHasMultibyte = other.field_3_stringHasMultibyte; + field_4_name = other.field_4_name; + } + public StyleRecord(RecordInputStream in) { field_1_xf_index = in.readShort(); if (isBuiltin()) { @@ -189,4 +196,9 @@ public final class StyleRecord extends S public short getSid() { return sid; } + + @Override + public StyleRecord copy() { + return new StyleRecord(this); + } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/SubRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/SubRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/SubRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/SubRecord.java Sun Dec 22 21:44:45 2019 @@ -17,27 +17,29 @@ package org.apache.poi.hssf.record; +import java.io.ByteArrayOutputStream; + +import org.apache.poi.common.Duplicatable; import org.apache.poi.util.HexDump; import org.apache.poi.util.IOUtils; import org.apache.poi.util.LittleEndianInput; import org.apache.poi.util.LittleEndianOutput; import org.apache.poi.util.LittleEndianOutputStream; - -import java.io.ByteArrayOutputStream; +import org.apache.poi.util.Removal; /** * Subrecords are part of the OBJ class. */ -public abstract class SubRecord { +public abstract class SubRecord implements Duplicatable { //arbitrarily selected; may need to increase private static final int MAX_RECORD_LENGTH = 1_000_000; - protected SubRecord() { - // no fields to initialise - } + protected SubRecord() {} - /** + protected SubRecord(SubRecord other) {} + + /** * read a sub-record from the supplied stream * * @param in the stream to read from @@ -90,8 +92,6 @@ public abstract class SubRecord { public abstract void serialize(LittleEndianOutput out); - @Override - public abstract SubRecord clone(); /** * Whether this record terminates the sub-record stream. @@ -126,8 +126,17 @@ public abstract class SubRecord { out.writeShort(_data.length); out.write(_data); } + @Override + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") public UnknownSubRecord clone() { + return copy(); + } + + @Override + public UnknownSubRecord copy() { return this; } @Override @@ -141,4 +150,13 @@ public abstract class SubRecord { return sb.toString(); } } + + @Override + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public abstract SubRecord clone(); + + @Override + public abstract SubRecord copy(); } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/SupBookRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/SupBookRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/SupBookRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/SupBookRecord.java Sun Dec 22 21:44:45 2019 @@ -23,45 +23,42 @@ import org.apache.poi.util.POILogger; import org.apache.poi.util.StringUtil; /** - * Title: Sup Book - EXTERNALBOOK (0x01AE)<p> - * Description: A External Workbook Description (Supplemental Book) - * Its only a dummy record for making new ExternSheet Record<p> - * REFERENCE: 5.38 + * A External Workbook Description (Supplemental Book). + * Its only a dummy record for making new ExternSheet Record */ public final class SupBookRecord extends StandardRecord { - private final static POILogger logger = POILogFactory.getLogger(SupBookRecord.class); - - public final static short sid = 0x01AE; + private static final POILogger logger = POILogFactory.getLogger(SupBookRecord.class); + + public static final short sid = 0x01AE; private static final short SMALL_RECORD_SIZE = 4; private static final short TAG_INTERNAL_REFERENCES = 0x0401; private static final short TAG_ADD_IN_FUNCTIONS = 0x3A01; + static final char CH_VOLUME = 1; + static final char CH_SAME_VOLUME = 2; + static final char CH_DOWN_DIR = 3; + static final char CH_UP_DIR = 4; + static final char CH_LONG_VOLUME = 5; + static final char CH_STARTUP_DIR = 6; + static final char CH_ALT_STARTUP_DIR = 7; + static final char CH_LIB_DIR = 8; + static final String PATH_SEPERATOR = System.getProperty("file.separator"); + private short field_1_number_of_sheets; private String field_2_encoded_url; private String[] field_3_sheet_names; private boolean _isAddInFunctions; - protected static final char CH_VOLUME = 1; - protected static final char CH_SAME_VOLUME = 2; - protected static final char CH_DOWN_DIR = 3; - protected static final char CH_UP_DIR = 4; - protected static final char CH_LONG_VOLUME = 5; - protected static final char CH_STARTUP_DIR = 6; - protected static final char CH_ALT_STARTUP_DIR = 7; - protected static final char CH_LIB_DIR = 8; - protected static final String PATH_SEPERATOR = System.getProperty("file.separator"); - - public static SupBookRecord createInternalReferences(short numberOfSheets) { - return new SupBookRecord(false, numberOfSheets); - } - public static SupBookRecord createAddInFunctions() { - return new SupBookRecord(true, (short)1 /* this field MUST be 0x0001 for add-in referencing */); - } - public static SupBookRecord createExternalReferences(String url, String[] sheetNames) { - return new SupBookRecord(url, sheetNames); + public SupBookRecord(SupBookRecord other) { + super(other); + field_1_number_of_sheets = other.field_1_number_of_sheets; + field_2_encoded_url = other.field_2_encoded_url; + field_3_sheet_names = other.field_3_sheet_names; + _isAddInFunctions = other._isAddInFunctions; } + private SupBookRecord(boolean isAddInFuncs, short numberOfSheets) { // else not 'External References' field_1_number_of_sheets = numberOfSheets; @@ -69,6 +66,7 @@ public final class SupBookRecord extends field_3_sheet_names = null; _isAddInFunctions = isAddInFuncs; } + public SupBookRecord(String url, String[] sheetNames) { field_1_number_of_sheets = (short) sheetNames.length; field_2_encoded_url = url; @@ -76,6 +74,16 @@ public final class SupBookRecord extends _isAddInFunctions = false; } + public static SupBookRecord createInternalReferences(short numberOfSheets) { + return new SupBookRecord(false, numberOfSheets); + } + public static SupBookRecord createAddInFunctions() { + return new SupBookRecord(true, (short)1 /* this field MUST be 0x0001 for add-in referencing */); + } + public static SupBookRecord createExternalReferences(String url, String[] sheetNames) { + return new SupBookRecord(url, sheetNames); + } + public boolean isExternalReferences() { return field_3_sheet_names != null; } @@ -248,9 +256,14 @@ public final class SupBookRecord extends public String[] getSheetNames() { return field_3_sheet_names.clone(); } - + public void setURL(String pUrl) { //Keep the first marker character! - field_2_encoded_url = field_2_encoded_url.substring(0, 1) + pUrl; + field_2_encoded_url = field_2_encoded_url.substring(0, 1) + pUrl; + } + + @Override + public SupBookRecord copy() { + return new SupBookRecord(this); } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/TabIdRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/TabIdRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/TabIdRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/TabIdRecord.java Sun Dec 22 21:44:45 2019 @@ -20,13 +20,10 @@ package org.apache.poi.hssf.record; import org.apache.poi.util.LittleEndianOutput; /** - * Title: Sheet Tab Index Array Record (0x013D)<p> - * Description: Contains an array of sheet id's. Sheets always keep their ID - * regardless of what their name is.<p> - * REFERENCE: PG 412 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2) + * Contains an array of sheet id's. Sheets always keep their ID regardless of what their name is. */ public final class TabIdRecord extends StandardRecord { - public final static short sid = 0x013D; + public static final short sid = 0x013D; private static final short[] EMPTY_SHORT_ARRAY = { }; public short[] _tabids; @@ -35,6 +32,11 @@ public final class TabIdRecord extends S _tabids = EMPTY_SHORT_ARRAY; } + public TabIdRecord(TabIdRecord other) { + super(other); + _tabids = (other._tabids == null) ? null : other._tabids.clone(); + } + public TabIdRecord(RecordInputStream in) { int nTabs = in.remaining() / 2; _tabids = new short[nTabs]; @@ -64,10 +66,8 @@ public final class TabIdRecord extends S } public void serialize(LittleEndianOutput out) { - short[] tabids = _tabids; - - for (int i = 0; i < tabids.length; i++) { - out.writeShort(tabids[i]); + for (short tabid : _tabids) { + out.writeShort(tabid); } } @@ -78,4 +78,9 @@ public final class TabIdRecord extends S public short getSid() { return sid; } + + @Override + public TabIdRecord copy() { + return new TabIdRecord(this); + } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/TableRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/TableRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/TableRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/TableRecord.java Sun Dec 22 21:44:45 2019 @@ -17,22 +17,17 @@ package org.apache.poi.hssf.record; -import org.apache.poi.ss.formula.ptg.TblPtg; import org.apache.poi.hssf.util.CellRangeAddress8Bit; +import org.apache.poi.ss.formula.ptg.TblPtg; import org.apache.poi.ss.util.CellReference; import org.apache.poi.util.BitField; import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndianOutput; /** - * DATATABLE (0x0236)<p> - * - * TableRecord - The record specifies a data table. - * This record is preceded by a single Formula record that - * defines the first cell in the data table, which should - * only contain a single Ptg, {@link TblPtg}. - * - * See p536 of the June 08 binary docs + * The record specifies a data table.<p> + * This record is preceded by a single Formula record that defines the first cell in the data table, + * which should only contain a single {@link TblPtg Ptg}. */ public final class TableRecord extends SharedValueRecordBase { public static final short sid = 0x0236; @@ -51,6 +46,16 @@ public final class TableRecord extends S private int field_9_rowInputCol; private int field_10_colInputCol; + public TableRecord(TableRecord other) { + super(other); + field_5_flags = other.field_5_flags; + field_6_res = other.field_6_res; + field_7_rowInputRow = other.field_7_rowInputRow; + field_8_colInputRow = other.field_8_colInputRow; + field_9_rowInputCol = other.field_9_rowInputCol; + field_10_colInputCol = other.field_10_colInputCol; + } + public TableRecord(RecordInputStream in) { super(in); field_5_flags = in.readByte(); @@ -142,7 +147,7 @@ public final class TableRecord extends S return sid; } protected int getExtraDataSize() { - return + return 2 // 2 byte fields + 8; // 4 short fields } @@ -170,6 +175,11 @@ public final class TableRecord extends S return buffer.toString(); } + @Override + public TableRecord copy() { + return new TableRecord(this); + } + private static CellReference cr(int rowIx, int colIxAndFlags) { int colIx = colIxAndFlags & 0x00FF; boolean isRowAbs = (colIxAndFlags & 0x8000) == 0; Modified: poi/trunk/src/java/org/apache/poi/hssf/record/TableStylesRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/TableStylesRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/TableStylesRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/TableStylesRecord.java Sun Dec 22 21:44:45 2019 @@ -26,16 +26,26 @@ import org.apache.poi.util.StringUtil; */ public final class TableStylesRecord extends StandardRecord { public static final short sid = 0x088E; - + private int rt; private int grbitFrt; - private byte[] unused = new byte[8]; + private final byte[] unused = new byte[8]; private int cts; - + private String rgchDefListStyle; private String rgchDefPivotStyle; - - + + + public TableStylesRecord(TableStylesRecord other) { + super(other); + rt = other.rt; + grbitFrt = other.grbitFrt; + System.arraycopy(other.unused, 0, unused, 0, unused.length); + cts = other.cts; + rgchDefListStyle = other.rgchDefListStyle; + rgchDefPivotStyle = other.rgchDefPivotStyle; + } + public TableStylesRecord(RecordInputStream in) { rt = in.readUShort(); grbitFrt = in.readUShort(); @@ -43,21 +53,21 @@ public final class TableStylesRecord ext cts = in.readInt(); int cchDefListStyle = in.readUShort(); int cchDefPivotStyle = in.readUShort(); - + rgchDefListStyle = in.readUnicodeLEString(cchDefListStyle); rgchDefPivotStyle = in.readUnicodeLEString(cchDefPivotStyle); } - + @Override protected void serialize(LittleEndianOutput out) { out.writeShort(rt); out.writeShort(grbitFrt); out.write(unused); out.writeInt(cts); - + out.writeShort(rgchDefListStyle.length()); out.writeShort(rgchDefPivotStyle.length()); - + StringUtil.putUnicodeLE(rgchDefListStyle, out); StringUtil.putUnicodeLE(rgchDefPivotStyle, out); } @@ -89,4 +99,9 @@ public final class TableStylesRecord ext buffer.append("[/TABLESTYLES]\n"); return buffer.toString(); } + + @Override + public TableStylesRecord copy() { + return new TableStylesRecord(this); + } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/TextObjectRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/TextObjectRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/TextObjectRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/TextObjectRecord.java Sun Dec 22 21:44:45 2019 @@ -26,6 +26,7 @@ import org.apache.poi.util.BitField; import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.HexDump; import org.apache.poi.util.RecordFormatException; +import org.apache.poi.util.Removal; /** * The TXO record (0x01B6) is used to define the properties of a text box. It is @@ -34,7 +35,7 @@ import org.apache.poi.util.RecordFormatE * contains the formatting runs. */ public final class TextObjectRecord extends ContinuableRecord { - public final static short sid = 0x01B6; + public static final short sid = 0x01B6; private static final int FORMAT_RUN_ENCODED_SIZE = 8; // 2 shorts and 4 bytes reserved @@ -42,19 +43,19 @@ public final class TextObjectRecord exte private static final BitField VerticalTextAlignment = BitFieldFactory.getInstance(0x0070); private static final BitField textLocked = BitFieldFactory.getInstance(0x0200); - public final static short HORIZONTAL_TEXT_ALIGNMENT_LEFT_ALIGNED = 1; - public final static short HORIZONTAL_TEXT_ALIGNMENT_CENTERED = 2; - public final static short HORIZONTAL_TEXT_ALIGNMENT_RIGHT_ALIGNED = 3; - public final static short HORIZONTAL_TEXT_ALIGNMENT_JUSTIFIED = 4; - public final static short VERTICAL_TEXT_ALIGNMENT_TOP = 1; - public final static short VERTICAL_TEXT_ALIGNMENT_CENTER = 2; - public final static short VERTICAL_TEXT_ALIGNMENT_BOTTOM = 3; - public final static short VERTICAL_TEXT_ALIGNMENT_JUSTIFY = 4; - - public final static short TEXT_ORIENTATION_NONE = 0; - public final static short TEXT_ORIENTATION_TOP_TO_BOTTOM = 1; - public final static short TEXT_ORIENTATION_ROT_RIGHT = 2; - public final static short TEXT_ORIENTATION_ROT_LEFT = 3; + public static final short HORIZONTAL_TEXT_ALIGNMENT_LEFT_ALIGNED = 1; + public static final short HORIZONTAL_TEXT_ALIGNMENT_CENTERED = 2; + public static final short HORIZONTAL_TEXT_ALIGNMENT_RIGHT_ALIGNED = 3; + public static final short HORIZONTAL_TEXT_ALIGNMENT_JUSTIFIED = 4; + public static final short VERTICAL_TEXT_ALIGNMENT_TOP = 1; + public static final short VERTICAL_TEXT_ALIGNMENT_CENTER = 2; + public static final short VERTICAL_TEXT_ALIGNMENT_BOTTOM = 3; + public static final short VERTICAL_TEXT_ALIGNMENT_JUSTIFY = 4; + + public static final short TEXT_ORIENTATION_NONE = 0; + public static final short TEXT_ORIENTATION_TOP_TO_BOTTOM = 1; + public static final short TEXT_ORIENTATION_ROT_RIGHT = 2; + public static final short TEXT_ORIENTATION_ROT_LEFT = 3; private int field_1_options; private int field_2_textOrientation; @@ -80,8 +81,24 @@ public final class TextObjectRecord exte * Value is often the same as the earlier firstColumn byte. */ private Byte _unknownPostFormulaByte; - public TextObjectRecord() { - // + public TextObjectRecord() {} + + public TextObjectRecord(TextObjectRecord other) { + super(other); + field_1_options = other.field_1_options; + field_2_textOrientation = other.field_2_textOrientation; + field_3_reserved4 = other.field_3_reserved4; + field_4_reserved5 = other.field_4_reserved5; + field_5_reserved6 = other.field_5_reserved6; + field_8_reserved7 = other.field_8_reserved7; + + _text = other._text; + + if (other._linkRefPtg != null) { + _unknownPreFormulaInt = other._unknownPreFormulaInt; + _linkRefPtg = other._linkRefPtg.copy(); + _unknownPostFormulaByte = other._unknownPostFormulaByte; + } } public TextObjectRecord(RecordInputStream in) { @@ -325,24 +342,16 @@ public final class TextObjectRecord exte return sb.toString(); } - public Object clone() { - - TextObjectRecord rec = new TextObjectRecord(); - - rec.field_1_options = field_1_options; - rec.field_2_textOrientation = field_2_textOrientation; - rec.field_3_reserved4 = field_3_reserved4; - rec.field_4_reserved5 = field_4_reserved5; - rec.field_5_reserved6 = field_5_reserved6; - rec.field_8_reserved7 = field_8_reserved7; - - rec._text = _text; // clone needed? + @Override + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public TextObjectRecord clone() { + return copy(); + } - if (_linkRefPtg != null) { - rec._unknownPreFormulaInt = _unknownPreFormulaInt; - rec._linkRefPtg = _linkRefPtg.copy(); - rec._unknownPostFormulaByte = _unknownPostFormulaByte; - } - return rec; + @Override + public TextObjectRecord copy() { + return new TextObjectRecord(this); } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/TopMarginRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/TopMarginRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/TopMarginRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/TopMarginRecord.java Sun Dec 22 21:44:45 2019 @@ -17,22 +17,28 @@ package org.apache.poi.hssf.record; -import org.apache.poi.util.*; +import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.Removal; /** * Record for the top margin. */ public final class TopMarginRecord extends StandardRecord implements Margin { - public final static short sid = 0x28; + public static final short sid = 0x28; + private double field_1_margin; - public TopMarginRecord() { } + public TopMarginRecord() {} + + public TopMarginRecord(TopMarginRecord other) { + super(other); + field_1_margin = other.field_1_margin; + } /** * @param in the RecordInputstream to read the record from */ - public TopMarginRecord( RecordInputStream in ) - { + public TopMarginRecord( RecordInputStream in ) { field_1_margin = in.readDouble(); } @@ -66,10 +72,16 @@ public final class TopMarginRecord exten public void setMargin( double field_1_margin ) { this.field_1_margin = field_1_margin; } - public Object clone() - { - TopMarginRecord rec = new TopMarginRecord(); - rec.field_1_margin = this.field_1_margin; - return rec; + @Override + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public TopMarginRecord clone() { + return copy(); + } + + @Override + public TopMarginRecord copy() { + return new TopMarginRecord(this); } -} // END OF \ No newline at end of file +} \ No newline at end of file Modified: poi/trunk/src/java/org/apache/poi/hssf/record/UncalcedRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/UncalcedRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/UncalcedRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/UncalcedRecord.java Sun Dec 22 21:44:45 2019 @@ -20,15 +20,11 @@ package org.apache.poi.hssf.record; import org.apache.poi.util.LittleEndianOutput; /** - * Title: Uncalced Record - * <P> - * If this record occurs in the Worksheet Substream, it indicates that the formulas have not + * If this record occurs in the Worksheet Substream, it indicates that the formulas have not * been recalculated before the document was saved. - * - * @author Olivier Leprince */ -public final class UncalcedRecord extends StandardRecord { - public final static short sid = 0x005E; +public final class UncalcedRecord extends StandardRecord { + public static final short sid = 0x005E; private short _reserved; @@ -36,6 +32,11 @@ public final class UncalcedRecord extend _reserved = 0; } + public UncalcedRecord(UncalcedRecord other) { + super(other); + _reserved = other._reserved; + } + public short getSid() { return sid; } @@ -63,4 +64,9 @@ public final class UncalcedRecord extend public static int getStaticRecordSize() { return 6; } + + @Override + public UncalcedRecord copy() { + return new UncalcedRecord(this); + } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/UnknownRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/UnknownRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/UnknownRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/UnknownRecord.java Sun Dec 22 21:44:45 2019 @@ -22,13 +22,12 @@ import java.util.Locale; import org.apache.poi.hssf.record.aggregates.PageSettingsBlock; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.Removal; /** - * Title: Unknown Record (for debugging)<p> - * Description: Unknown record just tells you the sid so you can figure out - * what records you are missing. Also helps us read/modify sheets we - * don't know all the records to. (HSSF leaves these alone!)<p> - * Company: SuperLink Software, Inc. + * Unknown record just tells you the sid so you can figure out what records you are missing. + * Also helps us read/modify sheets we don't know all the records to. + * (HSSF leaves these alone!) */ public final class UnknownRecord extends StandardRecord { @@ -206,7 +205,7 @@ public final class UnknownRecord extends case 0x08A7: return "CRTLAYOUT12A"; case 0x08C8: return "PLV{Mac Excel}"; - + case 0x1001: return "UNITS"; case 0x1006: return "CHARTDATAFORMAT"; case 0x1007: return "CHARTLINEFORMAT"; @@ -286,7 +285,15 @@ public final class UnknownRecord extends } @Override - public Object clone() { + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public UnknownRecord clone() { + return copy(); + } + + @Override + public UnknownRecord copy() { // immutable - OK to return this return this; } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/UseSelFSRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/UseSelFSRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/UseSelFSRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/UseSelFSRecord.java Sun Dec 22 21:44:45 2019 @@ -21,20 +21,23 @@ import org.apache.poi.util.BitField; import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.Removal; /** - * Title: USESELFS (0x0160) - Use Natural Language Formulas Flag <p> - * Description: Tells the GUI if this was written by something that can use - * "natural language" formulas. HSSF can't.<p> - * REFERENCE: PG 420 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2) + * Tells the GUI if this was written by something that can use "natural language" formulas. HSSF can't. */ public final class UseSelFSRecord extends StandardRecord { - public final static short sid = 0x0160; + public static final short sid = 0x0160; private static final BitField useNaturalLanguageFormulasFlag = BitFieldFactory.getInstance(0x0001); private int _options; + private UseSelFSRecord(UseSelFSRecord other) { + super(other); + _options = other._options; + } + private UseSelFSRecord(int options) { _options = options; } @@ -70,7 +73,15 @@ public final class UseSelFSRecord extend } @Override - public Object clone() { - return new UseSelFSRecord(_options); + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public UseSelFSRecord clone() { + return copy(); + } + + @Override + public UseSelFSRecord copy() { + return new UseSelFSRecord(this); } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/UserSViewBegin.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/UserSViewBegin.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/UserSViewBegin.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/UserSViewBegin.java Sun Dec 22 21:44:45 2019 @@ -21,19 +21,24 @@ import java.util.Locale; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.Removal; /** * The UserSViewBegin record specifies settings for a custom view associated with the sheet. * This record also marks the start of custom view records, which save custom view settings. * Records between {@link UserSViewBegin} and {@link UserSViewEnd} contain settings for the custom view, * not settings for the sheet itself. - * - * @author Yegor Kozlov */ public final class UserSViewBegin extends StandardRecord { - public final static short sid = 0x01AA; - private byte[] _rawData; + public static final short sid = 0x01AA; + + private byte[] _rawData; + + public UserSViewBegin(UserSViewBegin other) { + super(other); + _rawData = (other._rawData == null) ? null : other._rawData.clone(); + } public UserSViewBegin(byte[] data) { _rawData = data; @@ -83,9 +88,17 @@ public final class UserSViewBegin extend return sb.toString(); } - //HACK: do a "cheat" clone, see Record.java for more information - public Object clone() { - return cloneViaReserialise(); + @Override + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public UserSViewBegin clone() { + return copy(); } - + + @Override + public UserSViewBegin copy() { + return new UserSViewBegin(this); + } + } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/UserSViewEnd.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/UserSViewEnd.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/UserSViewEnd.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/UserSViewEnd.java Sun Dec 22 21:44:45 2019 @@ -21,15 +21,21 @@ import java.util.Locale; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.Removal; /** * The UserSViewEnd record marks the end of the settings for a custom view associated with the sheet */ public final class UserSViewEnd extends StandardRecord { - public final static short sid = 0x01AB; + public static final short sid = 0x01AB; private byte[] _rawData; + public UserSViewEnd(UserSViewEnd other) { + super(other); + _rawData = (other._rawData == null) ? null : other._rawData.clone(); + } + public UserSViewEnd(byte[] data) { _rawData = data; } @@ -69,10 +75,16 @@ public final class UserSViewEnd extends return sb.toString(); } - //HACK: do a "cheat" clone, see Record.java for more information - public Object clone() { - return cloneViaReserialise(); + @Override + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public UserSViewEnd clone() { + return copy(); } - + @Override + public UserSViewEnd copy() { + return new UserSViewEnd(this); + } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/VCenterRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/VCenterRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/VCenterRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/VCenterRecord.java Sun Dec 22 21:44:45 2019 @@ -18,26 +18,26 @@ package org.apache.poi.hssf.record; import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.Removal; /** - * Title: VCenter record<P> - * Description: tells whether to center the sheet between vertical margins<P> - * REFERENCE: PG 420 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P> - * @author Andrew C. Oliver (acoliver at apache dot org) - * @author Jason Height (jheight at chariot dot net dot au) + * Tells whether to center the sheet between vertical margins + * * @version 2.0-pre */ public final class VCenterRecord extends StandardRecord { - public final static short sid = 0x84; + public static final short sid = 0x84; private int field_1_vcenter; - public VCenterRecord() - { + public VCenterRecord() {} + + public VCenterRecord(VCenterRecord other) { + super(other); + field_1_vcenter = other.field_1_vcenter; } - public VCenterRecord(RecordInputStream in) - { + public VCenterRecord(RecordInputStream in) { field_1_vcenter = in.readShort(); } @@ -85,9 +85,16 @@ public final class VCenterRecord extends return sid; } - public Object clone() { - VCenterRecord rec = new VCenterRecord(); - rec.field_1_vcenter = field_1_vcenter; - return rec; + @Override + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public VCenterRecord clone() { + return copy(); + } + + @Override + public VCenterRecord copy() { + return new VCenterRecord(this); } } Modified: poi/trunk/src/java/org/apache/poi/hssf/record/VerticalPageBreakRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/VerticalPageBreakRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/hssf/record/VerticalPageBreakRecord.java (original) +++ poi/trunk/src/java/org/apache/poi/hssf/record/VerticalPageBreakRecord.java Sun Dec 22 21:44:45 2019 @@ -17,11 +17,11 @@ package org.apache.poi.hssf.record; -import java.util.Iterator; +import org.apache.poi.util.Removal; /** * VerticalPageBreak (0x001A) record that stores page breaks at columns - * + * * @see PageBreakRecord */ public final class VerticalPageBreakRecord extends PageBreakRecord { @@ -31,8 +31,10 @@ public final class VerticalPageBreakReco /** * Creates an empty vertical page break record */ - public VerticalPageBreakRecord() { + public VerticalPageBreakRecord() {} + public VerticalPageBreakRecord(VerticalPageBreakRecord other) { + super(other); } /** @@ -46,13 +48,16 @@ public final class VerticalPageBreakReco return sid; } - public Object clone() { - PageBreakRecord result = new VerticalPageBreakRecord(); - Iterator<Break> iterator = getBreaksIterator(); - while (iterator.hasNext()) { - Break original = iterator.next(); - result.addBreak(original.main, original.subFrom, original.subTo); - } - return result; + @Override + @SuppressWarnings("squid:S2975") + @Deprecated + @Removal(version = "5.0.0") + public VerticalPageBreakRecord clone() { + return copy(); + } + + @Override + public VerticalPageBreakRecord copy() { + return new VerticalPageBreakRecord(this); } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org For additional commands, e-mail: commits-h...@poi.apache.org