--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hssf.eventusermodel.dummyrecord;
+
+import org.apache.poi.hssf.record.Record;
+import org.apache.poi.hssf.record.RecordFormatException;
+
+/**
+ */
+abstract class DummyRecordBase extends Record {
+
+ protected DummyRecordBase() {
+ //
+ }
+
+ public final short getSid() {
+ return -1;
+ }
+ public int serialize(int offset, byte[] data) {
+ throw new RecordFormatException("Cannot serialize a dummy record");
+ }
+ protected final int getDataSize() {
+ throw new RecordFormatException("Cannot serialize a dummy record");
+ }
+}
package org.apache.poi.hssf.eventusermodel.dummyrecord;
-import org.apache.poi.hssf.record.Record;
/**
* A dummy record to indicate that we've now had the last
* cell record for this row.
*/
-public class LastCellOfRowDummyRecord extends Record {
+public final class LastCellOfRowDummyRecord extends DummyRecordBase {
private int row;
private int lastColumnNumber;
* for the row.
*/
public int getLastColumnNumber() { return lastColumnNumber; }
-
- public short getSid() {
- return -1;
- }
- public int serialize(int offset, byte[] data) {
- return -1;
- }
}
package org.apache.poi.hssf.eventusermodel.dummyrecord;
-import org.apache.poi.hssf.record.Record;
/**
* A dummy record for when we're missing a cell in a row,
* but still want to trigger something
*/
-public class MissingCellDummyRecord extends Record {
+public final class MissingCellDummyRecord extends DummyRecordBase {
private int row;
private int column;
this.row = row;
this.column = column;
}
-
- public short getSid() {
- return -1;
- }
- public int serialize(int offset, byte[] data) {
- return -1;
- }
-
public int getRow() { return row; }
public int getColumn() { return column; }
}
package org.apache.poi.hssf.eventusermodel.dummyrecord;
-import org.apache.poi.hssf.record.Record;
-import org.apache.poi.hssf.record.RecordInputStream;
/**
* A dummy record for when we're missing a row, but still
* want to trigger something
*/
-public class MissingRowDummyRecord extends Record {
+public final class MissingRowDummyRecord extends DummyRecordBase {
private int rowNumber;
public MissingRowDummyRecord(int rowNumber) {
this.rowNumber = rowNumber;
}
-
- public short getSid() {
- return -1;
- }
- public int serialize(int offset, byte[] data) {
- return -1;
- }
-
public int getRowNumber() {
return rowNumber;
}
}
return getRecordSize();
}
-
- public int getRecordSize()
- {
- if (escherRecords.size() == 0 && rawData != null)
- {
- return rawData.length + 4;
+ protected int getDataSize() {
+ if (escherRecords.size() == 0 && rawData != null) {
+ return rawData.length;
}
- else
+ int size = 0;
+ for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
{
- int size = 4;
- for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
- {
- EscherRecord r = (EscherRecord) iterator.next();
- size += r.getRecordSize();
- }
- return size;
+ EscherRecord r = (EscherRecord) iterator.next();
+ size += r.getRecordSize();
}
+ return size;
}
-//
-// /**
-// * Size of record (including 4 byte header)
-// */
-// public int getRecordSize()
-// {
-// if (escherRecords.size() == 0 && rawData != null)
-// {
-// return rawData.length;
-// }
-// else
-// {
-// collapseShapeInformation();
-//
-// int size = 4;
-// for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
-// {
-// EscherRecord r = (EscherRecord) iterator.next();
-// size += r.getRecordSize();
-// }
-// return size;
-// }
-// }
+
public abstract short getSid();
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 4 + 4 + 2 + 2 + 2 + 2;
+ protected int getDataSize() {
+ return 4 + 4 + 2 + 2 + 2 + 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2;
+ protected int getDataSize() {
+ return 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + 4 + 4 + 4 + 4;
+ protected int getDataSize() {
+ return 2 + 4 + 4 + 4 + 4;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + 4 + 4 + 4 + 4;
+ protected int getDataSize() {
+ return 2 + 4 + 4 + 4 + 4;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 20;
+ protected int getDataSize() {
+ return 16;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + 2 + 2;
+ protected int getDataSize() {
+ return 2 + 2 + 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4;
+ protected int getDataSize() {
+ return 0;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 10;
+ protected int getDataSize() {
+ return 6;
}
public Object clone() {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
private short field_3_xf_index;
private byte field_4_bBoolErr;
private byte field_5_fError;
-
+
/** Creates new BoolErrRecord */
public BoolErrRecord()
{
return getRecordSize();
}
- public int getRecordSize()
- {
- return 12;
+ protected int getDataSize() {
+ return 8;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 8;
+ protected int getDataSize() {
+ return 8;
}
public short getSid()
return rec;
}
-} // END OF CLA
\ No newline at end of file
+} // END OF C
\ No newline at end of file
return buffer.toString();
}
- private int getDataSize() {
+ protected int getDataSize() {
return 8 + field_5_sheetname.length() * (isMultibyte() ? 2 : 1);
}
return 4 + dataSize;
}
- public int getRecordSize() {
- return 4 + getDataSize();
- }
-
public short getSid() {
return sid;
}
return buffer.toString();
}
- private int getDataSize() {
+ protected int getDataSize() {
return 4 // 2 short fields
+ CellRangeAddress.ENCODED_SIZE
+ field_4_cell_ranges.getSize();
return 4 + dataSize;
}
- public int getRecordSize() {
- return 4 + getDataSize();
- }
-
public short getSid()
{
return sid;
return recordsize;
}
-
- public int getRecordSize()
- {
- int retval =16+
+ protected int getDataSize() {
+ return 12 +
(containsFontFormattingBlock()?fontFormatting.getRawRecord().length:0)+
(containsBorderFormattingBlock()?8:0)+
(containsPatternFormattingBlock()?4:0)+
getFormulaSize(field_17_formula1)+
getFormulaSize(field_18_formula2)
;
- return retval;
}
public final class CRNCountRecord extends Record {
public final static short sid = 0x59;
- private static final short BASE_RECORD_SIZE = 4;
+ private static final short DATA_SIZE = 4;
private int field_1_number_crn_records;
public int serialize(int offset, byte [] data) {
LittleEndian.putShort(data, 0 + offset, sid);
- LittleEndian.putShort(data, 2 + offset, BASE_RECORD_SIZE);
+ LittleEndian.putShort(data, 2 + offset, DATA_SIZE);
LittleEndian.putShort(data, 4 + offset, (short)field_1_number_crn_records);
LittleEndian.putShort(data, 6 + offset, (short)field_2_sheet_table_index);
return getRecordSize();
}
-
- public int getRecordSize() {
- return BASE_RECORD_SIZE + 4;
+ protected int getDataSize() {
+ return DATA_SIZE;
}
/**
sb.append("]");
return sb.toString();
}
- private int getDataSize() {
+ protected int getDataSize() {
return 4 + ConstantValueParser.getEncodedSize(field_4_constant_values);
}
return recSize;
}
- public int getRecordSize() {
- return getDataSize() + 4;
- }
-
/**
* return the non static version of the id for this record.
*/
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + 2 + 2 + 2;
+ protected int getDataSize() {
+ return 2 + 2 + 2 + 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 22;
+ protected int getDataSize() {
+ return 18;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 4 + 4 + 4 + 4;
+ protected int getDataSize() {
+ return 4 + 4 + 4 + 4;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + (4 * m_formats.size());
+ protected int getDataSize() {
+ return 2 + (4 * m_formats.size());
}
public short getSid() {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 16;
+ protected int getDataSize() {
+ return 12;
}
public String toString()
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record;
*/
public final class ContinueRecord extends Record {
public final static short sid = 0x003C;
- private byte[] _data;
+ private byte[] _data;
public ContinueRecord(byte[] data) {
_data = data;
}
- /**
- * USE ONLY within "processContinue"
- */
- public byte [] serialize()
- {
- byte[] retval = new byte[ _data.length + 4 ];
- serialize(0, retval);
- return retval;
+ protected int getDataSize() {
+ return _data.length;
}
public int serialize(int offset, byte[] data) {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 8;
+ protected int getDataSize() {
+ return 4;
}
public short getSid()
}
return getRecordSize();
}
-
- public int getRecordSize()
- {
- return 8 + (getNumCellOffsets() * 2);
+ protected int getDataSize() {
+ return 4 + (getNumCellOffsets() * 2);
}
/**
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 22;
+ protected int getDataSize() {
+ return 18;
}
public short getSid()
return 3 + str.length() * (StringUtil.hasMultibyte(str) ? 2 : 1);
}
- public int getRecordSize() {
- int size = 4+4+2+2+2+2;//header+options_field+first_formula_size+first_unused+sec_formula_size+sec+unused;
+ protected int getDataSize() {
+ int size = 4+2+2+2+2;//options_field+first_formula_size+first_unused+sec_formula_size+sec+unused;
size += getUnicodeStringSize(_promptTitle);
size += getUnicodeStringSize(_errorTitle);
size += getUnicodeStringSize(_promptText);
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + 2 + 2 + 2;
+ protected int getDataSize() {
+ return 2 + 2 + 2 + 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 8;
+ protected int getDataSize() {
+ return 4;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 12;
+ protected int getDataSize() {
+ return 8;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 18;
+ protected int getDataSize() {
+ return 14;
}
public short getSid()
import java.util.List;
-public class DrawingGroupRecord extends AbstractEscherHolderRecord
-{
+public final class DrawingGroupRecord extends AbstractEscherHolderRecord {
public static final short sid = 0xEB;
static final int MAX_RECORD_SIZE = 8228;
public void processChildRecords() {
convertRawBytesToEscherRecords();
}
-
- public int getRecordSize()
- {
- return grossSizeFromDataSize( getRawDataSize() );
+ protected int getDataSize() {
+ // TODO - convert this to a RecordAggregate
+ return grossSizeFromDataSize( getRawDataSize() ) - 4;
}
- public int getRawDataSize()
- {
+ private int getRawDataSize() {
List escherRecords = getEscherRecords();
byte[] rawData = getRawData();
if (escherRecords.size() == 0 && rawData != null)
{
return rawData.length;
}
- else
+ int size = 0;
+ for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
{
- int size = 0;
- for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
- {
- EscherRecord r = (EscherRecord) iterator.next();
- size += r.getRecordSize();
- }
- return size;
+ EscherRecord r = (EscherRecord) iterator.next();
+ size += r.getRecordSize();
}
+ return size;
}
static int grossSizeFromDataSize(int dataSize)
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.LittleEndian;
-public class DrawingRecord extends Record
-{
- public static final short sid = 0xEC;
+public final class DrawingRecord extends Record {
+ public static final short sid = 0x00EC;
+
+ private static final byte[] EMPTY_BYTE_ARRAY = { };
private byte[] recordData;
private byte[] contd;
- public DrawingRecord()
- {
+ public DrawingRecord() {
+ recordData = EMPTY_BYTE_ARRAY;
}
public DrawingRecord( RecordInputStream in )
}
return getRecordSize();
}
+ protected int getDataSize() {
+ int retval = 0;
- public int getRecordSize()
- {
- int retval = 4;
-
- if (recordData != null)
- {
+ if (recordData != null) {
retval += recordData.length;
}
return retval;
public Object clone() {
DrawingRecord rec = new DrawingRecord();
- if (recordData != null) {
- rec.recordData = new byte[ recordData.length ];
- System.arraycopy(recordData, 0, rec.recordData, 0, recordData.length);
- }
+ rec.recordData = new byte[ recordData.length ];
+ System.arraycopy(recordData, 0, rec.recordData, 0, recordData.length);
if (contd != null) {
System.arraycopy(contd, 0, rec.contd, 0, contd.length);
rec.contd = new byte[ contd.length ];
* This is purely for the biff viewer. During normal operations we don't want
* to be seeing this.
*/
-public class DrawingRecordForBiffViewer
- extends AbstractEscherHolderRecord
-{
+public final class DrawingRecordForBiffViewer extends AbstractEscherHolderRecord {
public static final short sid = 0xEC;
public DrawingRecordForBiffViewer()
package org.apache.poi.hssf.record;
-public class DrawingSelectionRecord extends AbstractEscherHolderRecord
-{
+public final class DrawingSelectionRecord extends AbstractEscherHolderRecord {
public static final short sid = 0xED;
public DrawingSelectionRecord()
return getRecordSize();
}
- public int getRecordSize()
- {
- return ENCODED_SIZE;
+ protected int getDataSize() {
+ return ENCODED_SIZE - 4;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4;
+ protected int getDataSize() {
+ return 0;
}
public short getSid()
return size;
}
- public int getRecordSize()
- {
+ protected int getDataSize() {
+ // TODO - convert this to RecordAggregate
convertUserModelToRecords();
List records = getEscherRecords();
int rawEscherSize = getEscherRecordSize( records );
Record r = (Record) iterator.next();
tailRecordSize += r.getRecordSize();
}
- return drawingRecordSize + objRecordSize + tailRecordSize;
+ return drawingRecordSize + objRecordSize + tailRecordSize - 4;
}
/**
return getRecordSize();
}
- public int getRecordSize()
- {
- return 8;
+ protected int getDataSize() {
+ return 4;
}
public short getSid()
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
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.LittleEndian;
-
import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.poi.util.LittleEndian;
/**
* Title: Extended Static String Table<P>
* @version 2.0-pre
* @see org.apache.poi.hssf.record.ExtSSTInfoSubRecord
*/
-
-public class ExtSSTRecord
- extends Record
-{
+public final class ExtSSTRecord extends Record {
+ public final static short sid = 0x00FF;
public static final int DEFAULT_BUCKET_SIZE = 8;
- //Cant seem to find this documented but from the biffviewer it is clear that
+ //Can't seem to find this documented but from the biffviewer it is clear that
//Excel only records the indexes for the first 128 buckets.
public static final int MAX_BUCKETS = 128;
- public final static short sid = 0xff;
private short field_1_strings_per_bucket = DEFAULT_BUCKET_SIZE;
- private ArrayList field_2_sst_info;
+ private List field_2_sst_info;
public ExtSSTRecord()
}
return pos;
}
-
- public int getRecordSize()
- {
- return 6 + 8*getNumInfoRecords();
+ protected int getDataSize() {
+ return 2 + 8*getNumInfoRecords();
}
public static final int getNumberOfInfoRecsForStrings(int numStrings) {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 24;
+ protected int getDataSize() {
+ return 20;
}
public short getSid()
return sb.toString();
}
-
- private int getDataSize() {
+ protected int getDataSize() {
return 2 + _list.size() * RefSubRecord.ENCODED_SIZE;
}
return (RefSubRecord) _list.get(i);
}
- public int getRecordSize() {
- return 4 + getDataSize();
- }
-
/**
* return the non static version of the id for this record.
*/
return field_4_name;
}
- private int getDataSize(){
+ protected int getDataSize(){
int result = 3 * 2 // 3 short fields
+ 2 + field_4_name.length(); // nameLen and name
if(hasFormula()) {
return recSize;
}
- public int getRecordSize(){
- return 4 + getDataSize();
- }
-
public ExternalNameRecord(RecordInputStream in) {
field_1_option_flag = in.readShort();
return getRecordSize();
}
- public int getRecordSize()
- {
- return 8;
+ protected int getDataSize() {
+ return 4;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize() {
+ protected int getDataSize() {
short nameLen = getUsernameLength();
if (nameLen < 1) {
- return 10;
+ return 6;
}
- return 11+nameLen;
+ return 7+nameLen;
}
public short getSid() {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + 2 + 2 + 2 + 2;
+ protected int getDataSize() {
+ return 2 + 2 + 2 + 2 + 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record;
* Description: An element in the Font Table<P>
* REFERENCE: PG 315 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
* @author Andrew C. Oliver (acoliver at apache dot org)
- * @version 2.0-pre
*/
-
-public class FontRecord
- extends Record
-{
- public final static short sid =
- 0x31; // docs are wrong (0x231 Microsoft Support site article Q184647)
+public final class FontRecord extends Record {
+ public final static short sid = 0x0031; // docs are wrong (0x231 Microsoft Support site article Q184647)
public final static short SS_NONE = 0;
public final static short SS_SUPER = 1;
public final static short SS_SUB = 2;
}
return getRecordSize();
}
-
- public int getRecordSize()
- {
+ protected int getDataSize() {
// Note - no matter the original, we always
// re-serialise the font name as unicode
- return (getFontNameLength() * 2) + 20;
+ return 16 + getFontNameLength() * 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- int retval = 4;
+ protected int getDataSize() {
+ int retval = 0;
- if (getFooterLength() > 0)
- {
+ if (getFooterLength() > 0) {
retval+=3; // [Shawn] Fixed for two null bytes in the length
}
- return (isMultibyte() ?
- (retval + getFooterLength()*2) : (retval + getFooterLength()));
+ return retval + getFooterLength() * (isMultibyte() ? 2 : 1);
}
public short getSid()
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record;
* REFERENCE: PG 317 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
* @author Andrew C. Oliver (acoliver at apache dot org)
* @author Shawn M. Laubach (slaubach at apache dot org)
- * @version 2.0-pre
*/
-
-public class FormatRecord
- extends Record
-{
- public final static short sid = 0x41e;
+public final class FormatRecord extends Record {
+ public final static short sid = 0x041E;
private short field_1_index_code;
private short field_3_unicode_len; // unicode string length
return getRecordSize();
}
-
- public int getRecordSize()
- {
- return 9 + ( ( field_3_unicode_flag ) ? 2 * field_3_unicode_len : field_3_unicode_len );
+ protected int getDataSize() {
+ return 5 + field_3_unicode_len * (field_3_unicode_flag ? 2 : 1);
}
public short getSid()
return sid;
}
- private int getDataSize() {
+ protected int getDataSize() {
return FIXED_SIZE + field_8_parsed_expr.getEncodedSize();
}
public int serialize(int offset, byte [] data) {
return recSize;
}
- public int getRecordSize() {
- return 4 + getDataSize();
- }
-
public String toString() {
StringBuffer sb = new StringBuffer();
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + 2;
+ protected int getDataSize() {
+ return 2 + 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 12;
+ protected int getDataSize() {
+ return 8;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record;
* @author Andrew C. Oliver (acoliver at apache dot org)
* @author Shawn Laubach (slaubach at apache dot org) Modified 3/14/02
* @author Jason Height (jheight at chariot dot net dot au)
- * @version 2.0-pre
*/
-
-public class HeaderRecord
- extends Record
-{
- public final static short sid = 0x14;
+public final class HeaderRecord extends Record {
+ public final static short sid = 0x0014;
private byte field_1_header_len;
private byte field_2_reserved;
private byte field_3_unicode_flag;
return getRecordSize();
}
- public int getRecordSize()
- {
- int retval = 4;
+ protected int getDataSize() {
+ int retval = 0;
- if (getHeaderLength() != 0)
- {
+ if (getHeaderLength() != 0) {
retval+=3; // [Shawn] Fixed for two null bytes in the length
}
- return (isMultibyte() ?
- (retval + getHeaderLength()*2) : (retval + getHeaderLength()));
+ return retval + getHeaderLength() * (isMultibyte() ? 2 : 1);
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
* @author Mark Hissink Muller <a href="mailto:mark@hissinkmuller.nl >mark&064;hissinkmuller.nl</a>
* @author Yegor Kozlov (yegor at apache dot org)
*/
-public class HyperlinkRecord extends Record {
+public final class HyperlinkRecord extends Record {
/**
* Link flags
*/
return getRecordSize();
}
- public int getRecordSize()
- {
- int size = 4;
+ protected int getDataSize() {
+ int size = 0;
size += 2 + 2 + 2 + 2; //rwFirst, rwLast, colFirst, colLast
size += guid.length;
size += 4; //label_opts
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record;
* REFERENCE: PG 323 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)
- * @version 2.0-pre
*/
-
-public class IndexRecord
- extends Record
-{
- public final static short sid = 0x20B;
+public class IndexRecord extends Record {
+ public final static short sid = 0x020B;
public final static int DBCELL_CAPACITY = 30;
public int field_1_zero; // reserved must be 0
public int field_2_first_row; // first row on the sheet
return getRecordSize();
}
- public int getRecordSize()
- {
- return 20 + (getNumDbcells() * 4);
+ protected int getDataSize() {
+ return 16 + (getNumDbcells() * 4);
}
/** Returns the size of an INdexRecord when it needs to index the specified number of blocks
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4;
+ protected int getDataSize() {
+ return 0;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
/**
* THROWS A RUNTIME EXCEPTION.. USE LABELSSTRecords. YOU HAVE NO REASON to use LABELRecord!!
*/
- public int serialize(int offset, byte [] data)
- {
- throw new RecordFormatException(
- "Label Records are supported READ ONLY...convert to LabelSST");
+ public int serialize(int offset, byte [] data) {
+ throw new RecordFormatException("Label Records are supported READ ONLY...convert to LabelSST");
+ }
+ protected int getDataSize() {
+ throw new RecordFormatException("Label Records are supported READ ONLY...convert to LabelSST");
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 14;
+ protected int getDataSize() {
+ return 10;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize() {
- return 4 + 8;
+ protected int getDataSize() {
+ return 8;
}
public short getSid() {
rec.field_1_margin = this.field_1_margin;
return rec;
}
-} // END OF CLA
\ No newline at end of file
+} // END OF C
\ No newline at end of file
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 4 + 4 + 4 + 4 + 1 + 1 + 2;
+ protected int getDataSize() {
+ return 4 + 4 + 4 + 4 + 1 + 1 + 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 4 + 2 + 2 + 2 + 2;
+ protected int getDataSize() {
+ return 4 + 2 + 2 + 2 + 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 1 + 1 + 2 + 2 + field_5_formulaOfLink.getSize();
+ protected int getDataSize() {
+ return 1 + 1 + 2 + 2 + field_5_formulaOfLink.getSize();
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return _regions[_startIndex + index];
}
- public int getRecordSize() {
- return 4 + CellRangeAddressList.getEncodedSize(_numberOfRegions);
- }
+ protected int getDataSize() {
+ return CellRangeAddressList.getEncodedSize(_numberOfRegions);
+ }
public short getSid() {
return sid;
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * MulBlankRecord.java
- *
- * Created on December 10, 2001, 12:49 PM
- */
package org.apache.poi.hssf.record;
/**
- * Title: Mulitple Blank cell record <P>
+ * Title: Multiple Blank cell record(0x00BE) <P/>
* Description: Represents a set of columns in a row with no value but with styling.
* In this release we have read-only support for this record type.
- * The RecordFactory converts this to a set of BlankRecord objects.<P>
- * REFERENCE: PG 329 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
+ * The RecordFactory converts this to a set of BlankRecord objects.<P/>
+ * REFERENCE: PG 329 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P/>
* @author Andrew C. Oliver (acoliver at apache dot org)
* @author Glen Stampoultzis (glens at apache.org)
- * @version 2.0-pre
- * @see org.apache.poi.hssf.record.BlankRecord
+ * @see BlankRecord
*/
-
-public class MulBlankRecord
- extends Record
-{
- public final static short sid = 0xbe;
- //private short field_1_row;
- private int field_1_row;
+public final class MulBlankRecord extends Record {
+ public final static short sid = 0x00BE;
+
+ private int field_1_row;
private short field_2_first_col;
private short[] field_3_xfs;
private short field_4_last_col;
- /** Creates new MulBlankRecord */
-
- public MulBlankRecord()
- {
- }
/**
* get the row number of the cells this represents
*
* @return row number
*/
-
- //public short getRow()
public int getRow()
{
return field_1_row;
* starting column (first cell this holds in the row)
* @return first column number
*/
-
public short getFirstColumn()
{
return field_2_first_col;
* ending column (last cell this holds in the row)
* @return first column number
*/
-
public short getLastColumn()
{
return field_4_last_col;
* get the number of columns this contains (last-first +1)
* @return number of columns (last - first +1)
*/
-
public int getNumColumns()
{
return field_4_last_col - field_2_first_col + 1;
* @param coffset the column (coffset = column - field_2_first_col)
* @return the XF index for the column
*/
-
public short getXFAt(int coffset)
{
return field_3_xfs[ coffset ];
/**
* @param in the RecordInputstream to read the record from
*/
- public MulBlankRecord(RecordInputStream in)
- {
- //field_1_row = LittleEndian.getShort(data, 0 + offset);
+ public MulBlankRecord(RecordInputStream in) {
field_1_row = in.readUShort();
field_2_first_col = in.readShort();
field_3_xfs = parseXFs(in);
field_4_last_col = in.readShort();
}
- private short [] parseXFs(RecordInputStream in)
+ private static short [] parseXFs(RecordInputStream in)
{
short[] retval = new short[ (in.remaining() - 2) / 2 ];
return retval;
}
- public String toString()
- {
+ public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("[MULBLANK]\n");
- buffer.append("row = ")
- .append(Integer.toHexString(getRow())).append("\n");
- buffer.append("firstcol = ")
- .append(Integer.toHexString(getFirstColumn())).append("\n");
- buffer.append(" lastcol = ")
- .append(Integer.toHexString(getLastColumn())).append("\n");
- for (int k = 0; k < getNumColumns(); k++)
- {
- buffer.append("xf").append(k).append(" = ")
- .append(Integer.toHexString(getXFAt(k))).append("\n");
+ buffer.append("row = ").append(Integer.toHexString(getRow())).append("\n");
+ buffer.append("firstcol = ").append(Integer.toHexString(getFirstColumn())).append("\n");
+ buffer.append(" lastcol = ").append(Integer.toHexString(getLastColumn())).append("\n");
+ for (int k = 0; k < getNumColumns(); k++) {
+ buffer.append("xf").append(k).append(" = ").append(
+ Integer.toHexString(getXFAt(k))).append("\n");
}
buffer.append("[/MULBLANK]\n");
return buffer.toString();
return sid;
}
- public int serialize(int offset, byte [] data)
- {
- throw new RecordFormatException(
- "Sorry, you can't serialize a MulBlank in this release");
+ public int serialize(int offset, byte [] data) {
+ throw new RecordFormatException( "Sorry, you can't serialize MulBlank in this release");
+ }
+ protected int getDataSize() {
+ throw new RecordFormatException( "Sorry, you can't serialize MulBlank in this release");
}
}
return sid;
}
- public int serialize(int offset, byte [] data)
- {
- throw new RecordFormatException(
- "Sorry, you can't serialize a MulRK in this release");
+ public int serialize(int offset, byte [] data) {
+ throw new RecordFormatException( "Sorry, you can't serialize MulRK in this release");
+ }
+ protected int getDataSize() {
+ throw new RecordFormatException( "Sorry, you can't serialize MulRK in this release");
}
private static final class RkRec {
}
return nChars;
}
-
- public int getRecordSize(){
- return 4 // sid + size
- + 13 // 3 shorts + 7 bytes
+
+ protected int getDataSize() {
+ return 13 // 3 shorts + 7 bytes
+ getNameRawSize()
+ field_14_custom_menu_text.length()
+ field_15_description_text.length()
*
* @author Yegor Kozlov
*/
-public class NoteRecord extends Record {
- public final static short sid = 0x1C;
+public final class NoteRecord extends Record {
+ public final static short sid = 0x001C;
/**
* Flag indicating that the comment is hidden (default)
return getRecordSize();
}
- public int getRecordSize()
- {
- int retval = 4 + 2 + 2 + 2 + 2 + 2 + 1 + field_5_author.length() + 1;
-
- return retval;
+ protected int getDataSize() {
+ return 2 + 2 + 2 + 2 + 2 + 1 + field_5_author.length() + 1;
}
/**
* Convert this record to string.
- * Used by BiffViewer and other utulities.
+ * Used by BiffViewer and other utilities.
*/
public String toString()
{
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 18;
+ protected int getDataSize() {
+ return 14;
}
public short getSid()
return sb.toString();
}
- private int getDataSize() {
+ protected int getDataSize() {
if (_uninterpretedData != null) {
return _uninterpretedData.length;
}
return recSize;
}
- public int getRecordSize() {
- return 4 + getDataSize();
- }
-
public short getSid() {
return sid;
}
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + 2 + 2;
+ protected int getDataSize() {
+ return 2 + 2 + 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
* @author Danny Mui (dmui at apache dot org)
*/
public abstract class PageBreakRecord extends Record {
- private static final boolean IS_EMPTY_RECORD_WRITTEN = false;
private static final int[] EMPTY_INT_ARRAY = { };
private List _breaks;
}
- private int getDataSize() {
- return 2 + _breaks.size() * Break.ENCODED_SIZE;
+ public boolean isEmpty() {
+ return _breaks.isEmpty();
}
- public int getRecordSize() {
- int nBreaks = _breaks.size();
- if (!IS_EMPTY_RECORD_WRITTEN && nBreaks < 1) {
- return 0;
- }
- return 4 + getDataSize();
+ protected int getDataSize() {
+ return 2 + _breaks.size() * Break.ENCODED_SIZE;
}
-
public final int serialize(int offset, byte data[]) {
int nBreaks = _breaks.size();
- if (!IS_EMPTY_RECORD_WRITTEN && nBreaks < 1) {
- return 0;
- }
int dataSize = getDataSize();
LittleEndian.putUShort(data, offset + 0, getSid());
LittleEndian.putUShort(data, offset + 2, dataSize);
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + (field_1_numcolors * 4);
+ protected int getDataSize() {
+ return 2 + (field_1_numcolors * 4);
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + 2 + 2 + 2 + 2;
+ protected int getDataSize() {
+ return 2 + 2 + 2 + 2 + 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize() {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid() {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 ;
+ protected int getDataSize() {
+ return 0;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 4 + 4;
+ protected int getDataSize() {
+ return 4 + 4;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 38;
+ protected int getDataSize() {
+ return 34;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
* 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)
- * @version 2.0-pre
* @see org.apache.poi.hssf.record.NumberRecord
*/
public final class RKRecord extends Record implements CellValueRecordInterface {
return sb.toString();
}
-// temporarily just constructs a new number record and returns its value
- public int serialize(int offset, byte [] data)
- {
- NumberRecord rec = new NumberRecord();
-
- rec.setColumn(getColumn());
- rec.setRow(getRow());
- rec.setValue(getRKNumber());
- rec.setXFIndex(getXFIndex());
- return rec.serialize(offset, data);
- }
-
- /**
- * Debugging main()
- * <P>
- * Normally I'd do this in a junit test, but let's face it -- once
- * this algorithm has been tested and it works, we are never ever
- * going to change it. This is driven by the Faceless Enemy's
- * minions, who dare not change the algorithm out from under us.
- *
- * @param ignored_args command line arguments, which we blithely
- * ignore
- */
-
- public static void main(String ignored_args[])
- {
- int[] values =
- {
- 0x3FF00000, 0x405EC001, 0x02F1853A, 0x02F1853B, 0xFCDD699A
- };
- double[] rvalues =
- {
- 1, 1.23, 12345678, 123456.78, -13149594
- };
-
- for (int j = 0; j < values.length; j++)
- {
- System.out.println("input = " + Integer.toHexString(values[ j ])
- + " -> " + rvalues[ j ] + ": "
- + RKUtil.decodeNumber(values[ j ]));
- }
- }
+ public int serialize(int offset, byte [] data) {
+ throw new RecordFormatException( "Sorry, you can't serialize RK in this release");
+ }
+ protected int getDataSize() {
+ throw new RecordFormatException( "Sorry, you can't serialize RK in this release");
+ }
public short getSid()
{
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + (getRecalcIdArray().length * 2);
+ protected int getDataSize() {
+ return (getRecalcIdArray().length * 2);
}
public short getSid()
* @author Andrew C. Oliver
* @author Marc Johnson (mjohnson at apache dot org)
* @author Jason Height (jheight at chariot dot net dot au)
- * @version 2.0-pre
*/
public abstract class Record extends RecordBase {
* @return byte array containing instance data
*/
- public byte [] serialize()
- {
+ public final byte[] serialize() {
byte[] retval = new byte[ getRecordSize() ];
serialize(0, retval);
return retval;
}
-
+ public final int getRecordSize() {
+ return 4 + getDataSize();
+ }
/**
- * gives the current serialized size of the record. Should include the sid and reclength (4 bytes).
+ * @return the size of the data portion of this record
+ * (does not include initial 4 bytes for sid and size)
*/
-
- public int getRecordSize()
- {
-
- // this is kind od a stupid way to do it but for now we just serialize
- // the record and return the size of the byte array
- return serialize().length;
- }
-
+ protected abstract int getDataSize();
+
/**
* get a string representation of the record (for biffview/debugging)
*/
-
public String toString()
{
return super.toString();
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize() { return 4 + 8; }
+ protected int getDataSize() {
+ return 8;
+ }
public short getSid() { return sid; }
rec.field_1_margin = this.field_1_margin;
return rec;
}
-} // END OF CL
\ No newline at end of file
+} // END OF
\ No newline at end of file
return ENCODED_SIZE;
}
- public int getRecordSize()
- {
- return ENCODED_SIZE;
+ protected int getDataSize() {
+ return ENCODED_SIZE - 4;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + 2;
+ protected int getDataSize() {
+ return 2 + 2;
}
public short getSid()
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record;
* @see org.apache.poi.hssf.record.LabelSSTRecord
* @see org.apache.poi.hssf.record.ContinueRecord
*/
-
-public class SSTRecord
- extends Record
-{
+public final class SSTRecord extends Record {
+ public static final short sid = 0x00FC;
private static UnicodeString EMPTY_STRING = new UnicodeString("");
/** overhead for each string includes the string's character count (a short) and the flag describing its characteristics (a byte) */
static final int STRING_MINIMAL_OVERHEAD = LittleEndianConsts.SHORT_SIZE + LittleEndianConsts.BYTE_SIZE;
- public static final short sid = 0xfc;
-
/** union of strings in the SST and EXTSST */
private int field_1_num_strings;
}
- public int getRecordSize()
- {
+ protected int getDataSize() {
SSTRecordSizeCalculator calculator = new SSTRecordSizeCalculator(field_3_strings);
int recordSize = calculator.getRecordSize();
- return recordSize;
+ return recordSize-4;
}
SSTDeserializer getDeserializer()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
buffer.append("[/SELECTION]\n");
return buffer.toString();
}
- private int getDataSize() {
+ protected int getDataSize() {
return 9 // 1 byte + 4 shorts
+ CellRangeAddress8Bit.getEncodedSize(field_6_refs.length);
}
return 4 + dataSize;
}
- public int getRecordSize() {
- return 4 + getDataSize();
- }
-
public short getSid() {
return sid;
}
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return 4 + dataSize;
}
- public int getRecordSize()
- {
- return 4 + field_1_seriesNumbers.length * 2 + 2;
+ protected int getDataSize() {
+ return field_1_seriesNumbers.length * 2 + 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + 2 + 2 + 2 + 2 + 2;
+ protected int getDataSize() {
+ return 2 + 2 + 2 + 2 + 2 + 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + 1 + 1 + (field_2_textLength *2);
+ protected int getDataSize() {
+ return 2 + 1 + 1 + (field_2_textLength *2);
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return (short) _range.getLastColumn();
}
- public final int getRecordSize() {
- return 4 + CellRangeAddress8Bit.ENCODED_SIZE + getExtraDataSize();
+ protected int getDataSize() {
+ return CellRangeAddress8Bit.ENCODED_SIZE + getExtraDataSize();
}
protected abstract int getExtraDataSize();
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + 1;
+ protected int getDataSize() {
+ return 2 + 1;
}
public short getSid()
return isUnCompressedUnicode() ? field_1_string_length * 2 : field_1_string_length;
}
- public int getRecordSize()
- {
- return 4 + 2 + 1 + getStringByteLength();
+ protected int getDataSize() {
+ return 2 + 1 + getStringByteLength();
}
/**
}
- private int getDataSize() {
+ protected int getDataSize() {
if (isBuiltin()) {
return 4; // short, byte, byte
}
return 4+dataSize;
}
- public int getRecordSize() {
- return 4 + getDataSize();
- }
-
public short getSid()
{
return sid;
sb.append("]");
return sb.toString();
}
- private int getDataSize() {
+ protected int getDataSize() {
if(!isExternalReferences()) {
return SMALL_RECORD_SIZE;
}
return field_1_number_of_sheets;
}
- public int getRecordSize() {
- return getDataSize() + 4;
- }
-
public short getSid()
{
return sid;
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + (getTabIdArray().length * 2);
+ protected int getDataSize() {
+ return (getTabIdArray().length * 2);
}
public short getSid()
* Only for the current record. does not include any subsequent Continue
* records
*/
- private int getDataSize() {
+ private int getCurrentRecordDataSize() {
int result = 2 + 2 + 2 + 2 + 2 + 2 + 2 + 4;
if (_linkRefPtg != null) {
result += 2 // formula size
}
private int serializeTXORecord(int offset, byte[] data) {
- int dataSize = getDataSize();
+ int dataSize = getCurrentRecordDataSize();
int recSize = dataSize+4;
LittleEndianOutput out = new LittleEndianByteArrayOutputStream(data, offset, recSize);
/**
* Note - this total size includes all potential {@link ContinueRecord}s written
+ * but it is not the "ushort size" value to be written at the start of the first BIFF record
*/
- public int getRecordSize() {
- int baseSize = 4 + getDataSize();
- return baseSize + getTrailingRecordsSize();
+ protected int getDataSize() {
+ return getCurrentRecordDataSize() + getTrailingRecordsSize();
}
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 1 + 1 + 2 + 4 + 4 + 4 + 4 + 4 + 2 + 2 + 2 + 2;
+ protected int getDataSize() {
+ return 1 + 1 + 2 + 4 + 4 + 4 + 4 + 4 + 2 + 2 + 2 + 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 1 + 1 + 1 + 1 + 4 + 8 + 8 + 2 + 2 + 2;
+ protected int getDataSize() {
+ return 1 + 1 + 1 + 1 + 4 + 8 + 8 + 2 + 2 + 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize() { return 4 + 8; }
+ protected int getDataSize() {
+ return 8;
+ }
public short getSid() { return sid; }
rec.field_1_margin = this.field_1_margin;
return rec;
}
-} // END OF CLA
\ No newline at end of file
+} // END OF C
\ No newline at end of file
*
* @author Olivier Leprince
*/
+public final class UncalcedRecord extends Record {
+ public final static short sid = 0x005E;
-public class UncalcedRecord extends Record
-{
- public final static short sid = 0x5E;
-
- /**
- * Default constructor
- */
public UncalcedRecord() {
}
return getRecordSize();
}
- public int getRecordSize() {
- return UncalcedRecord.getStaticRecordSize();
+ protected int getDataSize() {
+ return 2;
}
public static int getStaticRecordSize() {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return 4 + dataSize;
}
- public final int getRecordSize() {
- return 4 + _rawData.length;
+ protected int getDataSize() {
+ return _rawData.length;
}
/**
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 8 + 8 + 8 + 8 + 8 + 2;
+ protected int getDataSize() {
+ return 8 + 8 + 8 + 8 + 8 + 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 22;
+ protected int getDataSize() {
+ return 18;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 6;
+ protected int getDataSize() {
+ return 2;
}
public short getSid()
return getRecordSize();
}
- public int getRecordSize()
- {
- return 22;
+ protected int getDataSize() {
+ return 18;
}
public short getSid()
return 4 + DATA_SIZE;
}
- public int getRecordSize() {
- return 4 + DATA_SIZE;
+ protected int getDataSize() {
+ return DATA_SIZE;
}
public short getSid() {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4;
+ protected int getDataSize() {
+ return 0;
}
public short getSid()
rv.visitRecord(r);
}
}
+ private static void visitIfPresent(PageBreakRecord r, RecordVisitor rv) {
+ if (r != null) {
+ if (r.isEmpty()) {
+ // its OK to not serialize empty page break records
+ return;
+ }
+ rv.visitRecord(r);
+ }
+ }
/**
* creates the Header Record and sets it to nothing/0 length
import org.apache.poi.hssf.record.NameRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RecordFormatException;
-import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.hssf.record.formula.Area3DPtg;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.TempFile;
public int serialize(int offset, byte[] data) {
return 4;
}
- public int getRecordSize() {
- return 8;
+ protected int getDataSize() {
+ return 4;
}
}
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.util;
+import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
/**
- * Tests the RKUtil class.
+ * Tests the {@link RKUtil} class.
*/
-public class TestRKUtil
- extends TestCase
-{
- public TestRKUtil(String s)
- {
- super(s);
- }
-
- /**
- * Check we can decode correctly.
- */
- public void testDecode()
- throws Exception
- {
- assertEquals(3.0, RKUtil.decodeNumber(1074266112), 0.0000001);
- assertEquals(3.3, RKUtil.decodeNumber(1081384961), 0.0000001);
- assertEquals(3.33, RKUtil.decodeNumber(1081397249), 0.0000001);
- }
+public final class TestRKUtil extends TestCase {
+
+ /**
+ * Check we can decode correctly.
+ */
+ public void testDecode() {
+
+ int[] values = { 1074266112, 1081384961, 1081397249,
+ 0x3FF00000, 0x405EC001, 0x02F1853A, 0x02F1853B, 0xFCDD699A,
+ };
+ double[] rvalues = { 3.0, 3.3, 3.33,
+ 1, 1.23, 12345678, 123456.78, -13149594,
+ };
+
+ for (int j = 0; j < values.length; j++) {
+
+ int intBits = values[j];
+ double expectedValue = rvalues[j];
+ double actualValue = RKUtil.decodeNumber(intBits);
+ if (expectedValue != actualValue) {
+ throw new AssertionFailedError("0x" + Integer.toHexString(intBits)
+ + " should decode to " + expectedValue + " but got " + actualValue);
+ }
+ }
+ }
}