Merged revisions 709263-709264,709317 via svnmerge from

https://svn.apache.org/repos/asf/poi/trunk

........
  r709263 | josh | 2008-10-30 15:07:26 -0700 (Thu, 30 Oct 2008) | 1 line
  
  Removed dodgy superlcass implementation of Record.getRecordSize()
........
  r709264 | josh | 2008-10-30 15:13:56 -0700 (Thu, 30 Oct 2008) | 1 line
  
  Introduced Record.getDataSize() method
........
  r709317 | josh | 2008-10-30 18:02:55 -0700 (Thu, 30 Oct 2008) | 1 line
  
  converted getRecordSize methods to getDataSize
........


git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@709526 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2008-10-31 18:37:16 +00:00
parent e1e017ddee
commit 99b3eba292
153 changed files with 468 additions and 768 deletions

View File

@ -0,0 +1,40 @@
/* ====================================================================
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");
}
}

View File

@ -17,13 +17,12 @@
package org.apache.poi.hssf.eventusermodel.dummyrecord; 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 * A dummy record to indicate that we've now had the last
* cell record for this row. * cell record for this row.
*/ */
public class LastCellOfRowDummyRecord extends Record { public final class LastCellOfRowDummyRecord extends DummyRecordBase {
private int row; private int row;
private int lastColumnNumber; private int lastColumnNumber;
@ -45,11 +44,4 @@ public class LastCellOfRowDummyRecord extends Record {
* for the row. * for the row.
*/ */
public int getLastColumnNumber() { return lastColumnNumber; } public int getLastColumnNumber() { return lastColumnNumber; }
public short getSid() {
return -1;
}
public int serialize(int offset, byte[] data) {
return -1;
}
} }

View File

@ -17,13 +17,12 @@
package org.apache.poi.hssf.eventusermodel.dummyrecord; 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, * A dummy record for when we're missing a cell in a row,
* but still want to trigger something * but still want to trigger something
*/ */
public class MissingCellDummyRecord extends Record { public final class MissingCellDummyRecord extends DummyRecordBase {
private int row; private int row;
private int column; private int column;
@ -31,14 +30,6 @@ public class MissingCellDummyRecord extends Record {
this.row = row; this.row = row;
this.column = column; this.column = column;
} }
public short getSid() {
return -1;
}
public int serialize(int offset, byte[] data) {
return -1;
}
public int getRow() { return row; } public int getRow() { return row; }
public int getColumn() { return column; } public int getColumn() { return column; }
} }

View File

@ -17,27 +17,17 @@
package org.apache.poi.hssf.eventusermodel.dummyrecord; 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 * A dummy record for when we're missing a row, but still
* want to trigger something * want to trigger something
*/ */
public class MissingRowDummyRecord extends Record { public final class MissingRowDummyRecord extends DummyRecordBase {
private int rowNumber; private int rowNumber;
public MissingRowDummyRecord(int rowNumber) { public MissingRowDummyRecord(int rowNumber) {
this.rowNumber = rowNumber; this.rowNumber = rowNumber;
} }
public short getSid() {
return -1;
}
public int serialize(int offset, byte[] data) {
return -1;
}
public int getRowNumber() { public int getRowNumber() {
return rowNumber; return rowNumber;
} }

View File

@ -130,48 +130,20 @@ public abstract class AbstractEscherHolderRecord extends Record {
} }
return getRecordSize(); return getRecordSize();
} }
protected int getDataSize() {
public int getRecordSize() if (escherRecords.size() == 0 && rawData != null) {
{ return rawData.length;
if (escherRecords.size() == 0 && rawData != null)
{
return rawData.length + 4;
} }
else int size = 0;
for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
{ {
int size = 4; EscherRecord r = (EscherRecord) iterator.next();
for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); ) size += r.getRecordSize();
{
EscherRecord r = (EscherRecord) iterator.next();
size += r.getRecordSize();
}
return size;
} }
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(); public abstract short getSid();

View File

@ -110,9 +110,8 @@ public final class AreaFormatRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 4 + 4 + 2 + 2 + 2 + 2;
return 4 + 4 + 4 + 2 + 2 + 2 + 2;
} }
public short getSid() public short getSid()

View File

@ -75,9 +75,8 @@ public final class AreaRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 4 + 2;
} }
public short getSid() public short getSid()

View File

@ -70,9 +70,8 @@ public final class AxisLineFormatRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 4 + 2;
} }
public short getSid() public short getSid()

View File

@ -142,9 +142,8 @@ public final class AxisOptionsRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2;
return 4 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2;
} }
public short getSid() public short getSid()

View File

@ -96,9 +96,8 @@ public final class AxisParentRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2 + 4 + 4 + 4 + 4;
return 4 + 2 + 4 + 4 + 4 + 4;
} }
public short getSid() public short getSid()

View File

@ -97,9 +97,8 @@ public final class AxisRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2 + 4 + 4 + 4 + 4;
return 4 + 2 + 4 + 4 + 4 + 4;
} }
public short getSid() public short getSid()

View File

@ -66,9 +66,8 @@ public final class AxisUsedRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 4 + 2;
} }
public short getSid() public short getSid()

View File

@ -286,9 +286,8 @@ public class BOFRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 16;
return 20;
} }
public short getSid() public short getSid()

View File

@ -87,9 +87,8 @@ public class BackupRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 6;
} }
public short getSid() public short getSid()

View File

@ -92,9 +92,8 @@ public final class BarRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2 + 2 + 2;
return 4 + 2 + 2 + 2;
} }
public short getSid() public short getSid()

View File

@ -57,9 +57,8 @@ public class BeginRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 0;
return 4;
} }
public short getSid() public short getSid()

View File

@ -144,9 +144,8 @@ public final class BlankRecord extends Record implements CellValueRecordInterfac
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 6;
return 10;
} }
public Object clone() { public Object clone() {

View File

@ -87,9 +87,8 @@ public class BookBoolRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 6;
} }
public short getSid() public short getSid()

View File

@ -34,7 +34,7 @@ public final class BoolErrRecord extends Record implements CellValueRecordInterf
private short field_3_xf_index; private short field_3_xf_index;
private byte field_4_bBoolErr; private byte field_4_bBoolErr;
private byte field_5_fError; private byte field_5_fError;
/** Creates new BoolErrRecord */ /** Creates new BoolErrRecord */
public BoolErrRecord() public BoolErrRecord()
{ {
@ -206,9 +206,8 @@ public final class BoolErrRecord extends Record implements CellValueRecordInterf
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 8;
return 12;
} }
public short getSid() public short getSid()

View File

@ -59,9 +59,8 @@ public final class BottomMarginRecord extends Record implements Margin {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 8;
return 4 + 8;
} }
public short getSid() public short getSid()
@ -92,4 +91,4 @@ public final class BottomMarginRecord extends Record implements Margin {
return rec; return rec;
} }
} // END OF CLA } // END OF C

View File

@ -156,7 +156,7 @@ public final class BoundSheetRecord extends Record {
return buffer.toString(); return buffer.toString();
} }
private int getDataSize() { protected int getDataSize() {
return 8 + field_5_sheetname.length() * (isMultibyte() ? 2 : 1); return 8 + field_5_sheetname.length() * (isMultibyte() ? 2 : 1);
} }
@ -179,10 +179,6 @@ public final class BoundSheetRecord extends Record {
return 4 + dataSize; return 4 + dataSize;
} }
public int getRecordSize() {
return 4 + getDataSize();
}
public short getSid() { public short getSid() {
return sid; return sid;
} }

View File

@ -130,7 +130,7 @@ public final class CFHeaderRecord extends Record {
return buffer.toString(); return buffer.toString();
} }
private int getDataSize() { protected int getDataSize() {
return 4 // 2 short fields return 4 // 2 short fields
+ CellRangeAddress.ENCODED_SIZE + CellRangeAddress.ENCODED_SIZE
+ field_4_cell_ranges.getSize(); + field_4_cell_ranges.getSize();
@ -151,10 +151,6 @@ public final class CFHeaderRecord extends Record {
return 4 + dataSize; return 4 + dataSize;
} }
public int getRecordSize() {
return 4 + getDataSize();
}
public short getSid() public short getSid()
{ {
return sid; return sid;

View File

@ -482,17 +482,14 @@ public final class CFRuleRecord extends Record {
return recordsize; return recordsize;
} }
protected int getDataSize() {
public int getRecordSize() return 12 +
{
int retval =16+
(containsFontFormattingBlock()?fontFormatting.getRawRecord().length:0)+ (containsFontFormattingBlock()?fontFormatting.getRawRecord().length:0)+
(containsBorderFormattingBlock()?8:0)+ (containsBorderFormattingBlock()?8:0)+
(containsPatternFormattingBlock()?4:0)+ (containsPatternFormattingBlock()?4:0)+
getFormulaSize(field_17_formula1)+ getFormulaSize(field_17_formula1)+
getFormulaSize(field_18_formula2) getFormulaSize(field_18_formula2)
; ;
return retval;
} }

View File

@ -28,7 +28,7 @@ import org.apache.poi.util.LittleEndian;
public final class CRNCountRecord extends Record { public final class CRNCountRecord extends Record {
public final static short sid = 0x59; 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; private int field_1_number_crn_records;
@ -65,14 +65,13 @@ public final class CRNCountRecord extends Record {
public int serialize(int offset, byte [] data) { public int serialize(int offset, byte [] data) {
LittleEndian.putShort(data, 0 + offset, sid); 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, 4 + offset, (short)field_1_number_crn_records);
LittleEndian.putShort(data, 6 + offset, (short)field_2_sheet_table_index); LittleEndian.putShort(data, 6 + offset, (short)field_2_sheet_table_index);
return getRecordSize(); return getRecordSize();
} }
protected int getDataSize() {
public int getRecordSize() { return DATA_SIZE;
return BASE_RECORD_SIZE + 4;
} }
/** /**

View File

@ -63,7 +63,7 @@ public final class CRNRecord extends Record {
sb.append("]"); sb.append("]");
return sb.toString(); return sb.toString();
} }
private int getDataSize() { protected int getDataSize() {
return 4 + ConstantValueParser.getEncodedSize(field_4_constant_values); return 4 + ConstantValueParser.getEncodedSize(field_4_constant_values);
} }
@ -80,10 +80,6 @@ public final class CRNRecord extends Record {
return recSize; return recSize;
} }
public int getRecordSize() {
return getDataSize() + 4;
}
/** /**
* return the non static version of the id for this record. * return the non static version of the id for this record.
*/ */

View File

@ -89,9 +89,8 @@ public class CalcCountRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 6;
} }
public short getSid() public short getSid()

View File

@ -115,9 +115,8 @@ public class CalcModeRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 6;
} }
public short getSid() public short getSid()

View File

@ -97,9 +97,8 @@ public final class CategorySeriesAxisRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2 + 2 + 2 + 2;
return 4 + 2 + 2 + 2 + 2;
} }
public short getSid() public short getSid()

View File

@ -85,9 +85,8 @@ public final class ChartFormatRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 18;
return 22;
} }
public short getSid() public short getSid()

View File

@ -86,9 +86,8 @@ public final class ChartRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 4 + 4 + 4 + 4;
return 4 + 4 + 4 + 4 + 4;
} }
public short getSid() public short getSid()

View File

@ -88,9 +88,8 @@ public class ChartTitleFormatRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2 + (4 * m_formats.size());
return 4 + 2 + (4 * m_formats.size());
} }
public short getSid() { public short getSid() {

View File

@ -96,9 +96,8 @@ public class CodepageRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 6;
} }
public short getSid() public short getSid()

View File

@ -280,9 +280,8 @@ public final class ColumnInfoRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 12;
return 16;
} }
public String toString() public String toString()

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -15,7 +14,6 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -31,20 +29,14 @@ import org.apache.poi.util.LittleEndian;
*/ */
public final class ContinueRecord extends Record { public final class ContinueRecord extends Record {
public final static short sid = 0x003C; public final static short sid = 0x003C;
private byte[] _data; private byte[] _data;
public ContinueRecord(byte[] data) { public ContinueRecord(byte[] data) {
_data = data; _data = data;
} }
/** protected int getDataSize() {
* USE ONLY within "processContinue" return _data.length;
*/
public byte [] serialize()
{
byte[] retval = new byte[ _data.length + 4 ];
serialize(0, retval);
return retval;
} }
public int serialize(int offset, byte[] data) { public int serialize(int offset, byte[] data) {

View File

@ -117,9 +117,8 @@ public class CountryRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 4;
return 8;
} }
public short getSid() public short getSid()

View File

@ -143,10 +143,8 @@ public final class DBCellRecord extends Record {
} }
return getRecordSize(); return getRecordSize();
} }
protected int getDataSize() {
public int getRecordSize() return 4 + (getNumCellOffsets() * 2);
{
return 8 + (getNumCellOffsets() * 2);
} }
/** /**

View File

@ -85,9 +85,8 @@ public class DSFRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 6;
} }
public short getSid() public short getSid()

View File

@ -164,9 +164,8 @@ public class DVALRecord extends Record
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 18;
return 22;
} }
public short getSid() public short getSid()

View File

@ -303,8 +303,8 @@ public final class DVRecord extends Record {
return 3 + str.length() * (StringUtil.hasMultibyte(str) ? 2 : 1); return 3 + str.length() * (StringUtil.hasMultibyte(str) ? 2 : 1);
} }
public int getRecordSize() { protected int getDataSize() {
int size = 4+4+2+2+2+2;//header+options_field+first_formula_size+first_unused+sec_formula_size+sec+unused; int size = 4+2+2+2+2;//options_field+first_formula_size+first_unused+sec_formula_size+sec+unused;
size += getUnicodeStringSize(_promptTitle); size += getUnicodeStringSize(_promptTitle);
size += getUnicodeStringSize(_errorTitle); size += getUnicodeStringSize(_errorTitle);
size += getUnicodeStringSize(_promptText); size += getUnicodeStringSize(_promptText);

View File

@ -78,9 +78,8 @@ public final class DatRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 4 + 2;
} }
public short getSid() public short getSid()

View File

@ -93,9 +93,8 @@ public final class DataFormatRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2 + 2 + 2 + 2;
return 4 + 2 + 2 + 2 + 2;
} }
public short getSid() public short getSid()

View File

@ -85,9 +85,8 @@ public class DateWindow1904Record
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 6;
} }
public short getSid() public short getSid()

View File

@ -80,9 +80,8 @@ public final class DefaultColWidthRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 6;
} }
public short getSid() public short getSid()

View File

@ -69,9 +69,8 @@ public final class DefaultDataLabelTextPropertiesRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 4 + 2;
} }
public short getSid() public short getSid()

View File

@ -110,9 +110,8 @@ public class DefaultRowHeightRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 4;
return 8;
} }
public short getSid() public short getSid()

View File

@ -88,9 +88,8 @@ public class DeltaRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 8;
return 12;
} }
public short getSid() public short getSid()

View File

@ -165,9 +165,8 @@ public class DimensionsRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 14;
return 18;
} }
public short getSid() public short getSid()

View File

@ -26,8 +26,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
public class DrawingGroupRecord extends AbstractEscherHolderRecord public final class DrawingGroupRecord extends AbstractEscherHolderRecord {
{
public static final short sid = 0xEB; public static final short sid = 0xEB;
static final int MAX_RECORD_SIZE = 8228; static final int MAX_RECORD_SIZE = 8228;
@ -82,30 +81,25 @@ public class DrawingGroupRecord extends AbstractEscherHolderRecord
public void processChildRecords() { public void processChildRecords() {
convertRawBytesToEscherRecords(); convertRawBytesToEscherRecords();
} }
protected int getDataSize() {
public int getRecordSize() // TODO - convert this to a RecordAggregate
{ return grossSizeFromDataSize( getRawDataSize() ) - 4;
return grossSizeFromDataSize( getRawDataSize() );
} }
public int getRawDataSize() private int getRawDataSize() {
{
List escherRecords = getEscherRecords(); List escherRecords = getEscherRecords();
byte[] rawData = getRawData(); byte[] rawData = getRawData();
if (escherRecords.size() == 0 && rawData != null) if (escherRecords.size() == 0 && rawData != null)
{ {
return rawData.length; return rawData.length;
} }
else int size = 0;
for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
{ {
int size = 0; EscherRecord r = (EscherRecord) iterator.next();
for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); ) size += r.getRecordSize();
{
EscherRecord r = (EscherRecord) iterator.next();
size += r.getRecordSize();
}
return size;
} }
return size;
} }
static int grossSizeFromDataSize(int dataSize) static int grossSizeFromDataSize(int dataSize)

View File

@ -14,19 +14,21 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
public class DrawingRecord extends Record public final class DrawingRecord extends Record {
{ public static final short sid = 0x00EC;
public static final short sid = 0xEC;
private static final byte[] EMPTY_BYTE_ARRAY = { };
private byte[] recordData; private byte[] recordData;
private byte[] contd; private byte[] contd;
public DrawingRecord() public DrawingRecord() {
{ recordData = EMPTY_BYTE_ARRAY;
} }
public DrawingRecord( RecordInputStream in ) public DrawingRecord( RecordInputStream in )
@ -54,13 +56,10 @@ public class DrawingRecord extends Record
} }
return getRecordSize(); return getRecordSize();
} }
protected int getDataSize() {
int retval = 0;
public int getRecordSize() if (recordData != null) {
{
int retval = 4;
if (recordData != null)
{
retval += recordData.length; retval += recordData.length;
} }
return retval; return retval;
@ -91,10 +90,8 @@ public class DrawingRecord extends Record
public Object clone() { public Object clone() {
DrawingRecord rec = new DrawingRecord(); DrawingRecord rec = new DrawingRecord();
if (recordData != null) { rec.recordData = new byte[ recordData.length ];
rec.recordData = new byte[ recordData.length ]; System.arraycopy(recordData, 0, rec.recordData, 0, recordData.length);
System.arraycopy(recordData, 0, rec.recordData, 0, recordData.length);
}
if (contd != null) { if (contd != null) {
System.arraycopy(contd, 0, rec.contd, 0, contd.length); System.arraycopy(contd, 0, rec.contd, 0, contd.length);
rec.contd = new byte[ contd.length ]; rec.contd = new byte[ contd.length ];

View File

@ -23,9 +23,7 @@ import java.io.ByteArrayInputStream;
* This is purely for the biff viewer. During normal operations we don't want * This is purely for the biff viewer. During normal operations we don't want
* to be seeing this. * to be seeing this.
*/ */
public class DrawingRecordForBiffViewer public final class DrawingRecordForBiffViewer extends AbstractEscherHolderRecord {
extends AbstractEscherHolderRecord
{
public static final short sid = 0xEC; public static final short sid = 0xEC;
public DrawingRecordForBiffViewer() public DrawingRecordForBiffViewer()

View File

@ -17,8 +17,7 @@
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
public class DrawingSelectionRecord extends AbstractEscherHolderRecord public final class DrawingSelectionRecord extends AbstractEscherHolderRecord {
{
public static final short sid = 0xED; public static final short sid = 0xED;
public DrawingSelectionRecord() public DrawingSelectionRecord()

View File

@ -63,9 +63,8 @@ public final class EOFRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return ENCODED_SIZE - 4;
return ENCODED_SIZE;
} }
public short getSid() public short getSid()

View File

@ -58,9 +58,8 @@ public final class EndRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 0;
return 4;
} }
public short getSid() public short getSid()

View File

@ -498,8 +498,8 @@ public class EscherAggregate extends AbstractEscherHolderRecord
return size; return size;
} }
public int getRecordSize() protected int getDataSize() {
{ // TODO - convert this to RecordAggregate
convertUserModelToRecords(); convertUserModelToRecords();
List records = getEscherRecords(); List records = getEscherRecords();
int rawEscherSize = getEscherRecordSize( records ); int rawEscherSize = getEscherRecordSize( records );
@ -516,7 +516,7 @@ public class EscherAggregate extends AbstractEscherHolderRecord
Record r = (Record) iterator.next(); Record r = (Record) iterator.next();
tailRecordSize += r.getRecordSize(); tailRecordSize += r.getRecordSize();
} }
return drawingRecordSize + objRecordSize + tailRecordSize; return drawingRecordSize + objRecordSize + tailRecordSize - 4;
} }
/** /**

View File

@ -100,9 +100,8 @@ public class ExtSSTInfoSubRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 4;
return 8;
} }
public short getSid() public short getSid()

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -15,13 +14,13 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndian;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import org.apache.poi.util.LittleEndian;
/** /**
* Title: Extended Static String Table<P> * Title: Extended Static String Table<P>
@ -35,17 +34,14 @@ import java.util.ArrayList;
* @version 2.0-pre * @version 2.0-pre
* @see org.apache.poi.hssf.record.ExtSSTInfoSubRecord * @see org.apache.poi.hssf.record.ExtSSTInfoSubRecord
*/ */
public final class ExtSSTRecord extends Record {
public class ExtSSTRecord public final static short sid = 0x00FF;
extends Record
{
public static final int DEFAULT_BUCKET_SIZE = 8; 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. //Excel only records the indexes for the first 128 buckets.
public static final int MAX_BUCKETS = 128; public static final int MAX_BUCKETS = 128;
public final static short sid = 0xff;
private short field_1_strings_per_bucket = DEFAULT_BUCKET_SIZE; private short field_1_strings_per_bucket = DEFAULT_BUCKET_SIZE;
private ArrayList field_2_sst_info; private List field_2_sst_info;
public ExtSSTRecord() public ExtSSTRecord()
@ -128,10 +124,8 @@ public class ExtSSTRecord
} }
return pos; return pos;
} }
protected int getDataSize() {
public int getRecordSize() return 2 + 8*getNumInfoRecords();
{
return 6 + 8*getNumInfoRecords();
} }
public static final int getNumberOfInfoRecsForStrings(int numStrings) { public static final int getNumberOfInfoRecsForStrings(int numStrings) {

View File

@ -1787,9 +1787,8 @@ public class ExtendedFormatRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 20;
return 24;
} }
public short getSid() public short getSid()

View File

@ -153,8 +153,7 @@ public class ExternSheetRecord extends Record {
return sb.toString(); return sb.toString();
} }
protected int getDataSize() {
private int getDataSize() {
return 2 + _list.size() * RefSubRecord.ENCODED_SIZE; return 2 + _list.size() * RefSubRecord.ENCODED_SIZE;
} }
@ -189,10 +188,6 @@ public class ExternSheetRecord extends Record {
return (RefSubRecord) _list.get(i); return (RefSubRecord) _list.get(i);
} }
public int getRecordSize() {
return 4 + getDataSize();
}
/** /**
* return the non static version of the id for this record. * return the non static version of the id for this record.
*/ */

View File

@ -83,7 +83,7 @@ public final class ExternalNameRecord extends Record {
return field_4_name; return field_4_name;
} }
private int getDataSize(){ protected int getDataSize(){
int result = 3 * 2 // 3 short fields int result = 3 * 2 // 3 short fields
+ 2 + field_4_name.length(); // nameLen and name + 2 + field_4_name.length(); // nameLen and name
if(hasFormula()) { if(hasFormula()) {
@ -120,10 +120,6 @@ public final class ExternalNameRecord extends Record {
return recSize; return recSize;
} }
public int getRecordSize(){
return 4 + getDataSize();
}
public ExternalNameRecord(RecordInputStream in) { public ExternalNameRecord(RecordInputStream in) {
field_1_option_flag = in.readShort(); field_1_option_flag = in.readShort();

View File

@ -68,9 +68,8 @@ public class FilePassRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 4;
return 8;
} }
public short getSid() public short getSid()

View File

@ -153,12 +153,12 @@ public final class FileSharingRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() { protected int getDataSize() {
short nameLen = getUsernameLength(); short nameLen = getUsernameLength();
if (nameLen < 1) { if (nameLen < 1) {
return 10; return 6;
} }
return 11+nameLen; return 7+nameLen;
} }
public short getSid() { public short getSid() {

View File

@ -93,9 +93,8 @@ public class FnGroupCountRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 6;
} }
public short getSid() public short getSid()

View File

@ -94,9 +94,8 @@ public final class FontBasisRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2 + 2 + 2 + 2 + 2;
return 4 + 2 + 2 + 2 + 2 + 2;
} }
public short getSid() public short getSid()

View File

@ -66,9 +66,8 @@ public final class FontIndexRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 4 + 2;
} }
public short getSid() public short getSid()

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -15,7 +14,6 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -29,14 +27,9 @@ import org.apache.poi.util.BitFieldFactory;
* Description: An element in the Font Table<P> * Description: An element in the Font Table<P>
* REFERENCE: PG 315 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<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) * @author Andrew C. Oliver (acoliver at apache dot org)
* @version 2.0-pre
*/ */
public final class FontRecord extends Record {
public class FontRecord public final static short sid = 0x0031; // docs are wrong (0x231 Microsoft Support site article Q184647)
extends Record
{
public final static short sid =
0x31; // docs are wrong (0x231 Microsoft Support site article Q184647)
public final static short SS_NONE = 0; public final static short SS_NONE = 0;
public final static short SS_SUPER = 1; public final static short SS_SUPER = 1;
public final static short SS_SUB = 2; public final static short SS_SUB = 2;
@ -509,12 +502,10 @@ public class FontRecord
} }
return getRecordSize(); return getRecordSize();
} }
protected int getDataSize() {
public int getRecordSize()
{
// Note - no matter the original, we always // Note - no matter the original, we always
// re-serialise the font name as unicode // re-serialise the font name as unicode
return (getFontNameLength() * 2) + 20; return 16 + getFontNameLength() * 2;
} }
public short getSid() public short getSid()

View File

@ -180,16 +180,13 @@ public class FooterRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ int retval = 0;
int retval = 4;
if (getFooterLength() > 0) if (getFooterLength() > 0) {
{
retval+=3; // [Shawn] Fixed for two null bytes in the length retval+=3; // [Shawn] Fixed for two null bytes in the length
} }
return (isMultibyte() ? return retval + getFooterLength() * (isMultibyte() ? 2 : 1);
(retval + getFooterLength()*2) : (retval + getFooterLength()));
} }
public short getSid() public short getSid()

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -15,7 +14,6 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -29,13 +27,9 @@ import org.apache.poi.util.StringUtil;
* REFERENCE: PG 317 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P> * 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 Andrew C. Oliver (acoliver at apache dot org)
* @author Shawn M. Laubach (slaubach at apache dot org) * @author Shawn M. Laubach (slaubach at apache dot org)
* @version 2.0-pre
*/ */
public final class FormatRecord extends Record {
public class FormatRecord public final static short sid = 0x041E;
extends Record
{
public final static short sid = 0x41e;
private short field_1_index_code; private short field_1_index_code;
private short field_3_unicode_len; // unicode string length private short field_3_unicode_len; // unicode string length
@ -199,10 +193,8 @@ public class FormatRecord
return getRecordSize(); return getRecordSize();
} }
protected int getDataSize() {
public int getRecordSize() return 5 + field_3_unicode_len * (field_3_unicode_flag ? 2 : 1);
{
return 9 + ( ( field_3_unicode_flag ) ? 2 * field_3_unicode_len : field_3_unicode_len );
} }
public short getSid() public short getSid()

View File

@ -353,7 +353,7 @@ public final class FormulaRecord extends Record implements CellValueRecordInterf
return sid; return sid;
} }
private int getDataSize() { protected int getDataSize() {
return FIXED_SIZE + field_8_parsed_expr.getEncodedSize(); return FIXED_SIZE + field_8_parsed_expr.getEncodedSize();
} }
public int serialize(int offset, byte [] data) { public int serialize(int offset, byte [] data) {
@ -380,10 +380,6 @@ public final class FormulaRecord extends Record implements CellValueRecordInterf
return recSize; return recSize;
} }
public int getRecordSize() {
return 4 + getDataSize();
}
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();

View File

@ -83,9 +83,8 @@ public final class FrameRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2 + 2;
return 4 + 2 + 2;
} }
public short getSid() public short getSid()

View File

@ -97,9 +97,8 @@ public class GridsetRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 6;
} }
public short getSid() public short getSid()

View File

@ -167,9 +167,8 @@ public class GutsRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 8;
return 12;
} }
public short getSid() public short getSid()

View File

@ -86,9 +86,8 @@ public final class HCenterRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 6;
} }
public short getSid() public short getSid()

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -15,7 +14,6 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -29,13 +27,9 @@ import org.apache.poi.util.StringUtil;
* @author Andrew C. Oliver (acoliver at apache dot org) * @author Andrew C. Oliver (acoliver at apache dot org)
* @author Shawn Laubach (slaubach at apache dot org) Modified 3/14/02 * @author Shawn Laubach (slaubach at apache dot org) Modified 3/14/02
* @author Jason Height (jheight at chariot dot net dot au) * @author Jason Height (jheight at chariot dot net dot au)
* @version 2.0-pre
*/ */
public final class HeaderRecord extends Record {
public class HeaderRecord public final static short sid = 0x0014;
extends Record
{
public final static short sid = 0x14;
private byte field_1_header_len; private byte field_1_header_len;
private byte field_2_reserved; private byte field_2_reserved;
private byte field_3_unicode_flag; private byte field_3_unicode_flag;
@ -180,16 +174,13 @@ public class HeaderRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ int retval = 0;
int retval = 4;
if (getHeaderLength() != 0) if (getHeaderLength() != 0) {
{
retval+=3; // [Shawn] Fixed for two null bytes in the length retval+=3; // [Shawn] Fixed for two null bytes in the length
} }
return (isMultibyte() ? return retval + getHeaderLength() * (isMultibyte() ? 2 : 1);
(retval + getHeaderLength()*2) : (retval + getHeaderLength()));
} }
public short getSid() public short getSid()

View File

@ -95,9 +95,8 @@ public class HideObjRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 6;
} }
public short getSid() public short getSid()

View File

@ -31,7 +31,7 @@ import org.apache.poi.util.HexDump;
* @author Mark Hissink Muller <a href="mailto:mark@hissinkmuller.nl >mark&064;hissinkmuller.nl</a> * @author Mark Hissink Muller <a href="mailto:mark@hissinkmuller.nl >mark&064;hissinkmuller.nl</a>
* @author Yegor Kozlov (yegor at apache dot org) * @author Yegor Kozlov (yegor at apache dot org)
*/ */
public class HyperlinkRecord extends Record { public final class HyperlinkRecord extends Record {
/** /**
* Link flags * Link flags
*/ */
@ -405,9 +405,8 @@ public class HyperlinkRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ int size = 0;
int size = 4;
size += 2 + 2 + 2 + 2; //rwFirst, rwLast, colFirst, colLast size += 2 + 2 + 2 + 2; //rwFirst, rwLast, colFirst, colLast
size += guid.length; size += guid.length;
size += 4; //label_opts size += 4; //label_opts

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -15,7 +14,6 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
@ -30,13 +28,9 @@ import org.apache.poi.util.LittleEndian;
* REFERENCE: PG 323 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P> * 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 Andrew C. Oliver (acoliver at apache dot org)
* @author Jason Height (jheight at chariot dot net dot au) * @author Jason Height (jheight at chariot dot net dot au)
* @version 2.0-pre
*/ */
public class IndexRecord extends Record {
public class IndexRecord public final static short sid = 0x020B;
extends Record
{
public final static short sid = 0x20B;
public final static int DBCELL_CAPACITY = 30; public final static int DBCELL_CAPACITY = 30;
public int field_1_zero; // reserved must be 0 public int field_1_zero; // reserved must be 0
public int field_2_first_row; // first row on the sheet public int field_2_first_row; // first row on the sheet
@ -146,9 +140,8 @@ public class IndexRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 16 + (getNumDbcells() * 4);
return 20 + (getNumDbcells() * 4);
} }
/** Returns the size of an INdexRecord when it needs to index the specified number of blocks /** Returns the size of an INdexRecord when it needs to index the specified number of blocks

View File

@ -58,9 +58,8 @@ public final class InterfaceEndRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 0;
return 4;
} }
public short getSid() public short getSid()

View File

@ -94,9 +94,8 @@ public class InterfaceHdrRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 6;
} }
public short getSid() public short getSid()

View File

@ -95,9 +95,8 @@ public class IterationRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 6;
} }
public short getSid() public short getSid()

View File

@ -114,10 +114,11 @@ public final class LabelRecord extends Record implements CellValueRecordInterfac
/** /**
* THROWS A RUNTIME EXCEPTION.. USE LABELSSTRecords. YOU HAVE NO REASON to use LABELRecord!! * THROWS A RUNTIME EXCEPTION.. USE LABELSSTRecords. YOU HAVE NO REASON to use LABELRecord!!
*/ */
public int serialize(int offset, byte [] data) public int serialize(int offset, byte [] data) {
{ throw new RecordFormatException("Label Records are supported READ ONLY...convert to LabelSST");
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() public short getSid()

View File

@ -140,9 +140,8 @@ public final class LabelSSTRecord extends Record implements CellValueRecordInter
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 10;
return 14;
} }
public short getSid() public short getSid()

View File

@ -53,8 +53,8 @@ public class LeftMarginRecord extends Record implements Margin
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() { protected int getDataSize() {
return 4 + 8; return 8;
} }
public short getSid() { public short getSid() {
@ -82,4 +82,4 @@ public class LeftMarginRecord extends Record implements Margin
rec.field_1_margin = this.field_1_margin; rec.field_1_margin = this.field_1_margin;
return rec; return rec;
} }
} // END OF CLA } // END OF C

View File

@ -133,9 +133,8 @@ public final class LegendRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 4 + 4 + 4 + 4 + 1 + 1 + 2;
return 4 + 4 + 4 + 4 + 4 + 1 + 1 + 2;
} }
public short getSid() public short getSid()

View File

@ -118,9 +118,8 @@ public final class LineFormatRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 4 + 2 + 2 + 2 + 2;
return 4 + 4 + 2 + 2 + 2 + 2;
} }
public short getSid() public short getSid()

View File

@ -108,9 +108,8 @@ public final class LinkedDataRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 1 + 1 + 2 + 2 + field_5_formulaOfLink.getSize();
return 4 + 1 + 1 + 2 + 2 + field_5_formulaOfLink.getSize();
} }
public short getSid() public short getSid()

View File

@ -110,9 +110,8 @@ public class MMSRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 6;
} }
public short getSid() public short getSid()

View File

@ -72,9 +72,9 @@ public final class MergeCellsRecord extends Record {
return _regions[_startIndex + index]; return _regions[_startIndex + index];
} }
public int getRecordSize() { protected int getDataSize() {
return 4 + CellRangeAddressList.getEncodedSize(_numberOfRegions); return CellRangeAddressList.getEncodedSize(_numberOfRegions);
} }
public short getSid() { public short getSid() {
return sid; return sid;

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -15,50 +14,33 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
/*
* MulBlankRecord.java
*
* Created on December 10, 2001, 12:49 PM
*/
package org.apache.poi.hssf.record; 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. * 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. * In this release we have read-only support for this record type.
* The RecordFactory converts this to a set of BlankRecord objects.<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> * 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 Andrew C. Oliver (acoliver at apache dot org)
* @author Glen Stampoultzis (glens at apache.org) * @author Glen Stampoultzis (glens at apache.org)
* @version 2.0-pre * @see BlankRecord
* @see org.apache.poi.hssf.record.BlankRecord
*/ */
public final class MulBlankRecord extends Record {
public class MulBlankRecord public final static short sid = 0x00BE;
extends Record
{ private int field_1_row;
public final static short sid = 0xbe;
//private short field_1_row;
private int field_1_row;
private short field_2_first_col; private short field_2_first_col;
private short[] field_3_xfs; private short[] field_3_xfs;
private short field_4_last_col; private short field_4_last_col;
/** Creates new MulBlankRecord */
public MulBlankRecord()
{
}
/** /**
* get the row number of the cells this represents * get the row number of the cells this represents
* *
* @return row number * @return row number
*/ */
//public short getRow()
public int getRow() public int getRow()
{ {
return field_1_row; return field_1_row;
@ -68,7 +50,6 @@ public class MulBlankRecord
* starting column (first cell this holds in the row) * starting column (first cell this holds in the row)
* @return first column number * @return first column number
*/ */
public short getFirstColumn() public short getFirstColumn()
{ {
return field_2_first_col; return field_2_first_col;
@ -78,7 +59,6 @@ public class MulBlankRecord
* ending column (last cell this holds in the row) * ending column (last cell this holds in the row)
* @return first column number * @return first column number
*/ */
public short getLastColumn() public short getLastColumn()
{ {
return field_4_last_col; return field_4_last_col;
@ -88,7 +68,6 @@ public class MulBlankRecord
* get the number of columns this contains (last-first +1) * get the number of columns this contains (last-first +1)
* @return number of columns (last - first +1) * @return number of columns (last - first +1)
*/ */
public int getNumColumns() public int getNumColumns()
{ {
return field_4_last_col - field_2_first_col + 1; return field_4_last_col - field_2_first_col + 1;
@ -99,7 +78,6 @@ public class MulBlankRecord
* @param coffset the column (coffset = column - field_2_first_col) * @param coffset the column (coffset = column - field_2_first_col)
* @return the XF index for the column * @return the XF index for the column
*/ */
public short getXFAt(int coffset) public short getXFAt(int coffset)
{ {
return field_3_xfs[ coffset ]; return field_3_xfs[ coffset ];
@ -108,16 +86,14 @@ public class MulBlankRecord
/** /**
* @param in the RecordInputstream to read the record from * @param in the RecordInputstream to read the record from
*/ */
public MulBlankRecord(RecordInputStream in) public MulBlankRecord(RecordInputStream in) {
{
//field_1_row = LittleEndian.getShort(data, 0 + offset);
field_1_row = in.readUShort(); field_1_row = in.readUShort();
field_2_first_col = in.readShort(); field_2_first_col = in.readShort();
field_3_xfs = parseXFs(in); field_3_xfs = parseXFs(in);
field_4_last_col = in.readShort(); 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 ]; short[] retval = new short[ (in.remaining() - 2) / 2 ];
@ -128,21 +104,16 @@ public class MulBlankRecord
return retval; return retval;
} }
public String toString() public String toString() {
{
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append("[MULBLANK]\n"); buffer.append("[MULBLANK]\n");
buffer.append("row = ") buffer.append("row = ").append(Integer.toHexString(getRow())).append("\n");
.append(Integer.toHexString(getRow())).append("\n"); buffer.append("firstcol = ").append(Integer.toHexString(getFirstColumn())).append("\n");
buffer.append("firstcol = ") buffer.append(" lastcol = ").append(Integer.toHexString(getLastColumn())).append("\n");
.append(Integer.toHexString(getFirstColumn())).append("\n"); for (int k = 0; k < getNumColumns(); k++) {
buffer.append(" lastcol = ") buffer.append("xf").append(k).append(" = ").append(
.append(Integer.toHexString(getLastColumn())).append("\n"); Integer.toHexString(getXFAt(k))).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"); buffer.append("[/MULBLANK]\n");
return buffer.toString(); return buffer.toString();
@ -153,9 +124,10 @@ public class MulBlankRecord
return sid; return sid;
} }
public int serialize(int offset, byte [] data) public int serialize(int offset, byte [] data) {
{ throw new RecordFormatException( "Sorry, you can't serialize MulBlank in this release");
throw new RecordFormatException( }
"Sorry, you can't serialize a MulBlank in this release"); protected int getDataSize() {
throw new RecordFormatException( "Sorry, you can't serialize MulBlank in this release");
} }
} }

View File

@ -113,10 +113,11 @@ public final class MulRKRecord extends Record {
return sid; return sid;
} }
public int serialize(int offset, byte [] data) public int serialize(int offset, byte [] data) {
{ throw new RecordFormatException( "Sorry, you can't serialize MulRK in this release");
throw new RecordFormatException( }
"Sorry, you can't serialize a MulRK in this release"); protected int getDataSize() {
throw new RecordFormatException( "Sorry, you can't serialize MulRK in this release");
} }
private static final class RkRec { private static final class RkRec {

View File

@ -408,10 +408,9 @@ public final class NameRecord extends Record {
} }
return nChars; return nChars;
} }
public int getRecordSize(){ protected int getDataSize() {
return 4 // sid + size return 13 // 3 shorts + 7 bytes
+ 13 // 3 shorts + 7 bytes
+ getNameRawSize() + getNameRawSize()
+ field_14_custom_menu_text.length() + field_14_custom_menu_text.length()
+ field_15_description_text.length() + field_15_description_text.length()

View File

@ -24,8 +24,8 @@ import org.apache.poi.util.LittleEndian;
* *
* @author Yegor Kozlov * @author Yegor Kozlov
*/ */
public class NoteRecord extends Record { public final class NoteRecord extends Record {
public final static short sid = 0x1C; public final static short sid = 0x001C;
/** /**
* Flag indicating that the comment is hidden (default) * Flag indicating that the comment is hidden (default)
@ -100,16 +100,13 @@ public class NoteRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2 + 2 + 2 + 2 + 2 + 1 + field_5_author.length() + 1;
int retval = 4 + 2 + 2 + 2 + 2 + 2 + 1 + field_5_author.length() + 1;
return retval;
} }
/** /**
* Convert this record to string. * Convert this record to string.
* Used by BiffViewer and other utulities. * Used by BiffViewer and other utilities.
*/ */
public String toString() public String toString()
{ {

View File

@ -66,9 +66,8 @@ public final class NumberFormatIndexRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 4 + 2;
} }
public short getSid() public short getSid()

View File

@ -142,9 +142,8 @@ public final class NumberRecord extends Record implements CellValueRecordInterfa
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 14;
return 18;
} }
public short getSid() public short getSid()

View File

@ -119,7 +119,7 @@ public final class ObjRecord extends Record {
return sb.toString(); return sb.toString();
} }
private int getDataSize() { protected int getDataSize() {
if (_uninterpretedData != null) { if (_uninterpretedData != null) {
return _uninterpretedData.length; return _uninterpretedData.length;
} }
@ -165,10 +165,6 @@ public final class ObjRecord extends Record {
return recSize; return recSize;
} }
public int getRecordSize() {
return 4 + getDataSize();
}
public short getSid() { public short getSid() {
return sid; return sid;
} }

View File

@ -86,9 +86,8 @@ public final class ObjectLinkRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2 + 2 + 2;
return 4 + 2 + 2 + 2;
} }
public short getSid() public short getSid()

View File

@ -93,9 +93,8 @@ public class ObjectProtectRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2;
return 6;
} }
public short getSid() public short getSid()

View File

@ -37,7 +37,6 @@ import org.apache.poi.util.LittleEndian;
* @author Danny Mui (dmui at apache dot org) * @author Danny Mui (dmui at apache dot org)
*/ */
public abstract class PageBreakRecord extends Record { public abstract class PageBreakRecord extends Record {
private static final boolean IS_EMPTY_RECORD_WRITTEN = false;
private static final int[] EMPTY_INT_ARRAY = { }; private static final int[] EMPTY_INT_ARRAY = { };
private List _breaks; private List _breaks;
@ -97,23 +96,15 @@ public abstract class PageBreakRecord extends Record {
} }
private int getDataSize() { public boolean isEmpty() {
return _breaks.isEmpty();
}
protected int getDataSize() {
return 2 + _breaks.size() * Break.ENCODED_SIZE; 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[]) { public final int serialize(int offset, byte data[]) {
int nBreaks = _breaks.size(); int nBreaks = _breaks.size();
if (!IS_EMPTY_RECORD_WRITTEN && nBreaks < 1) {
return 0;
}
int dataSize = getDataSize(); int dataSize = getDataSize();
LittleEndian.putUShort(data, offset + 0, getSid()); LittleEndian.putUShort(data, offset + 0, getSid());
LittleEndian.putUShort(data, offset + 2, dataSize); LittleEndian.putUShort(data, offset + 2, dataSize);

View File

@ -96,9 +96,8 @@ public class PaletteRecord
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2 + (field_1_numcolors * 4);
return 4 + 2 + (field_1_numcolors * 4);
} }
public short getSid() public short getSid()

View File

@ -102,9 +102,8 @@ public final class PaneRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() protected int getDataSize() {
{ return 2 + 2 + 2 + 2 + 2;
return 4 + 2 + 2 + 2 + 2 + 2;
} }
public short getSid() public short getSid()

View File

@ -96,8 +96,8 @@ public class PasswordRecord extends Record {
return getRecordSize(); return getRecordSize();
} }
public int getRecordSize() { protected int getDataSize() {
return 6; return 2;
} }
public short getSid() { public short getSid() {

Some files were not shown because too many files have changed in this diff Show More