--- /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;
-import org.apache.poi.hssf.record.RecordFormatException;
/**
* A dummy record to indicate that we've now had the last
* cell record for this row.
*/
-public final 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) {
- throw new RecordFormatException("Cannot serialize a dummy record");
- }
- public int getRecordSize() {
- throw new RecordFormatException("Cannot serialize a dummy record");
- }
}
package org.apache.poi.hssf.eventusermodel.dummyrecord;
-import org.apache.poi.hssf.record.Record;
-import org.apache.poi.hssf.record.RecordFormatException;
/**
* A dummy record for when we're missing a cell in a row,
* but still want to trigger something
*/
-public final 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) {
- throw new RecordFormatException("Cannot serialize a dummy record");
- }
- public int getRecordSize() {
- throw new RecordFormatException("Cannot serialize a dummy record");
- }
-
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.RecordFormatException;
/**
* A dummy record for when we're missing a row, but still
* want to trigger something
*/
-public final 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) {
- throw new RecordFormatException("Cannot serialize a dummy record");
- }
- public int getRecordSize() {
- throw new RecordFormatException("Cannot serialize a dummy record");
- }
-
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()
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 4 + dataSize;
}
- public int getRecordSize() {
- return 4 + getDataSize();
- }
-
public short getSid() {
return sid;
}
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;
}
/**
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()
_data = data;
}
- public int getRecordSize() {
- return 4 + _data.length;
+ 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 (RefSubRecord) _list.get(i);
}
- public int getRecordSize() {
- return 4 + getDataSize();
- }
-
/**
* return the non static version of the id for this record.
*/
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 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()
public int serialize(int offset, byte [] data) {
throw new RecordFormatException("Label Records are supported READ ONLY...convert to LabelSST");
}
- public int getRecordSize() {
+ protected int getDataSize() {
throw new RecordFormatException("Label Records are supported READ ONLY...convert to LabelSST");
}
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;
public int serialize(int offset, byte [] data) {
throw new RecordFormatException( "Sorry, you can't serialize MulBlank in this release");
}
- public int getRecordSize() {
+ protected int getDataSize() {
throw new RecordFormatException( "Sorry, you can't serialize MulBlank in this release");
}
}
public int serialize(int offset, byte [] data) {
throw new RecordFormatException( "Sorry, you can't serialize MulRK in this release");
}
- public int getRecordSize() {
+ protected int getDataSize() {
throw new RecordFormatException( "Sorry, you can't serialize MulRK in this release");
}
}
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 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;
}
+ public boolean isEmpty() {
+ return _breaks.isEmpty();
+ }
protected int getDataSize() {
return 2 + _breaks.size() * Break.ENCODED_SIZE;
}
- public int getRecordSize() {
- int nBreaks = _breaks.size();
- if (!IS_EMPTY_RECORD_WRITTEN && nBreaks < 1) {
- return 0;
- }
- return 4 + getDataSize();
- }
-
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 {
public int serialize(int offset, byte [] data) {
throw new RecordFormatException( "Sorry, you can't serialize RK in this release");
}
- public int getRecordSize() {
+ protected int getDataSize() {
throw new RecordFormatException( "Sorry, you can't serialize RK in this release");
}
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + (getRecalcIdArray().length * 2);
+ protected int getDataSize() {
+ return (getRecalcIdArray().length * 2);
}
public short getSid()
return retval;
}
+ public final int getRecordSize() {
+ return 4 + getDataSize();
+ }
/**
* @return the size of the data portion of this record
* (does not include initial 4 bytes for sid and size)
*/
- protected int getDataSize() {
- // implementation is currently a hack
- // will eventually swap this out
- return getRecordSize() - 4;
- }
+ 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()
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();
}
/**
return 4+dataSize;
}
- public int getRecordSize() {
- return 4 + getDataSize();
- }
-
public short getSid()
{
return sid;
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
*/
- protected 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;
}
}