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-ffa450edef68tags/ooxml_20081107
@@ -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"); | |||
} | |||
} |
@@ -17,13 +17,12 @@ | |||
package org.apache.poi.hssf.eventusermodel.dummyrecord; | |||
import org.apache.poi.hssf.record.Record; | |||
/** | |||
* A dummy record to indicate that we've now had the last | |||
* cell record for this row. | |||
*/ | |||
public class LastCellOfRowDummyRecord extends Record { | |||
public final class LastCellOfRowDummyRecord extends DummyRecordBase { | |||
private int row; | |||
private int lastColumnNumber; | |||
@@ -45,11 +44,4 @@ public class LastCellOfRowDummyRecord extends Record { | |||
* for the row. | |||
*/ | |||
public int getLastColumnNumber() { return lastColumnNumber; } | |||
public short getSid() { | |||
return -1; | |||
} | |||
public int serialize(int offset, byte[] data) { | |||
return -1; | |||
} | |||
} |
@@ -17,13 +17,12 @@ | |||
package org.apache.poi.hssf.eventusermodel.dummyrecord; | |||
import org.apache.poi.hssf.record.Record; | |||
/** | |||
* A dummy record for when we're missing a cell in a row, | |||
* but still want to trigger something | |||
*/ | |||
public class MissingCellDummyRecord extends Record { | |||
public final class MissingCellDummyRecord extends DummyRecordBase { | |||
private int row; | |||
private int column; | |||
@@ -31,14 +30,6 @@ public class MissingCellDummyRecord extends Record { | |||
this.row = row; | |||
this.column = column; | |||
} | |||
public short getSid() { | |||
return -1; | |||
} | |||
public int serialize(int offset, byte[] data) { | |||
return -1; | |||
} | |||
public int getRow() { return row; } | |||
public int getColumn() { return column; } | |||
} |
@@ -17,27 +17,17 @@ | |||
package org.apache.poi.hssf.eventusermodel.dummyrecord; | |||
import org.apache.poi.hssf.record.Record; | |||
import org.apache.poi.hssf.record.RecordInputStream; | |||
/** | |||
* A dummy record for when we're missing a row, but still | |||
* want to trigger something | |||
*/ | |||
public class MissingRowDummyRecord extends Record { | |||
public final class MissingRowDummyRecord extends DummyRecordBase { | |||
private int rowNumber; | |||
public MissingRowDummyRecord(int rowNumber) { | |||
this.rowNumber = rowNumber; | |||
} | |||
public short getSid() { | |||
return -1; | |||
} | |||
public int serialize(int offset, byte[] data) { | |||
return -1; | |||
} | |||
public int getRowNumber() { | |||
return rowNumber; | |||
} |
@@ -130,48 +130,20 @@ public abstract class AbstractEscherHolderRecord extends Record { | |||
} | |||
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(); | |||
@@ -110,9 +110,8 @@ public final class AreaFormatRecord extends Record { | |||
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() |
@@ -75,9 +75,8 @@ public final class AreaRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -70,9 +70,8 @@ public final class AxisLineFormatRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -142,9 +142,8 @@ public final class AxisOptionsRecord extends Record { | |||
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() |
@@ -96,9 +96,8 @@ public final class AxisParentRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2 + 4 + 4 + 4 + 4; | |||
protected int getDataSize() { | |||
return 2 + 4 + 4 + 4 + 4; | |||
} | |||
public short getSid() |
@@ -97,9 +97,8 @@ public final class AxisRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2 + 4 + 4 + 4 + 4; | |||
protected int getDataSize() { | |||
return 2 + 4 + 4 + 4 + 4; | |||
} | |||
public short getSid() |
@@ -66,9 +66,8 @@ public final class AxisUsedRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -286,9 +286,8 @@ public class BOFRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 20; | |||
protected int getDataSize() { | |||
return 16; | |||
} | |||
public short getSid() |
@@ -87,9 +87,8 @@ public class BackupRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 6; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -92,9 +92,8 @@ public final class BarRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2 + 2 + 2; | |||
protected int getDataSize() { | |||
return 2 + 2 + 2; | |||
} | |||
public short getSid() |
@@ -57,9 +57,8 @@ public class BeginRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4; | |||
protected int getDataSize() { | |||
return 0; | |||
} | |||
public short getSid() |
@@ -144,9 +144,8 @@ public final class BlankRecord extends Record implements CellValueRecordInterfac | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 10; | |||
protected int getDataSize() { | |||
return 6; | |||
} | |||
public Object clone() { |
@@ -87,9 +87,8 @@ public class BookBoolRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 6; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -34,7 +34,7 @@ public final class BoolErrRecord extends Record implements CellValueRecordInterf | |||
private short field_3_xf_index; | |||
private byte field_4_bBoolErr; | |||
private byte field_5_fError; | |||
/** Creates new BoolErrRecord */ | |||
public BoolErrRecord() | |||
{ | |||
@@ -206,9 +206,8 @@ public final class BoolErrRecord extends Record implements CellValueRecordInterf | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 12; | |||
protected int getDataSize() { | |||
return 8; | |||
} | |||
public short getSid() |
@@ -59,9 +59,8 @@ public final class BottomMarginRecord extends Record implements Margin { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 8; | |||
protected int getDataSize() { | |||
return 8; | |||
} | |||
public short getSid() | |||
@@ -92,4 +91,4 @@ public final class BottomMarginRecord extends Record implements Margin { | |||
return rec; | |||
} | |||
} // END OF CLA | |||
} // END OF C |
@@ -156,7 +156,7 @@ public final class BoundSheetRecord extends Record { | |||
return buffer.toString(); | |||
} | |||
private int getDataSize() { | |||
protected int getDataSize() { | |||
return 8 + field_5_sheetname.length() * (isMultibyte() ? 2 : 1); | |||
} | |||
@@ -179,10 +179,6 @@ public final class BoundSheetRecord extends Record { | |||
return 4 + dataSize; | |||
} | |||
public int getRecordSize() { | |||
return 4 + getDataSize(); | |||
} | |||
public short getSid() { | |||
return sid; | |||
} |
@@ -130,7 +130,7 @@ public final class CFHeaderRecord extends Record { | |||
return buffer.toString(); | |||
} | |||
private int getDataSize() { | |||
protected int getDataSize() { | |||
return 4 // 2 short fields | |||
+ CellRangeAddress.ENCODED_SIZE | |||
+ field_4_cell_ranges.getSize(); | |||
@@ -151,10 +151,6 @@ public final class CFHeaderRecord extends Record { | |||
return 4 + dataSize; | |||
} | |||
public int getRecordSize() { | |||
return 4 + getDataSize(); | |||
} | |||
public short getSid() | |||
{ | |||
return sid; |
@@ -482,17 +482,14 @@ public final class CFRuleRecord extends Record { | |||
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; | |||
} | |||
@@ -28,7 +28,7 @@ import org.apache.poi.util.LittleEndian; | |||
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; | |||
@@ -65,14 +65,13 @@ public final class CRNCountRecord extends Record { | |||
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; | |||
} | |||
/** |
@@ -63,7 +63,7 @@ public final class CRNRecord extends Record { | |||
sb.append("]"); | |||
return sb.toString(); | |||
} | |||
private int getDataSize() { | |||
protected int getDataSize() { | |||
return 4 + ConstantValueParser.getEncodedSize(field_4_constant_values); | |||
} | |||
@@ -80,10 +80,6 @@ public final class CRNRecord extends Record { | |||
return recSize; | |||
} | |||
public int getRecordSize() { | |||
return getDataSize() + 4; | |||
} | |||
/** | |||
* return the non static version of the id for this record. | |||
*/ |
@@ -89,9 +89,8 @@ public class CalcCountRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 6; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -115,9 +115,8 @@ public class CalcModeRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 6; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -97,9 +97,8 @@ public final class CategorySeriesAxisRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2 + 2 + 2 + 2; | |||
protected int getDataSize() { | |||
return 2 + 2 + 2 + 2; | |||
} | |||
public short getSid() |
@@ -85,9 +85,8 @@ public final class ChartFormatRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 22; | |||
protected int getDataSize() { | |||
return 18; | |||
} | |||
public short getSid() |
@@ -86,9 +86,8 @@ public final class ChartRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 4 + 4 + 4 + 4; | |||
protected int getDataSize() { | |||
return 4 + 4 + 4 + 4; | |||
} | |||
public short getSid() |
@@ -88,9 +88,8 @@ public class ChartTitleFormatRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2 + (4 * m_formats.size()); | |||
protected int getDataSize() { | |||
return 2 + (4 * m_formats.size()); | |||
} | |||
public short getSid() { |
@@ -96,9 +96,8 @@ public class CodepageRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 6; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -280,9 +280,8 @@ public final class ColumnInfoRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 16; | |||
protected int getDataSize() { | |||
return 12; | |||
} | |||
public String toString() |
@@ -1,4 +1,3 @@ | |||
/* ==================================================================== | |||
Licensed to the Apache Software Foundation (ASF) under one or more | |||
contributor license agreements. See the NOTICE file distributed with | |||
@@ -15,7 +14,6 @@ | |||
See the License for the specific language governing permissions and | |||
limitations under the License. | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -31,20 +29,14 @@ import org.apache.poi.util.LittleEndian; | |||
*/ | |||
public final class ContinueRecord extends Record { | |||
public final static short sid = 0x003C; | |||
private byte[] _data; | |||
private byte[] _data; | |||
public ContinueRecord(byte[] data) { | |||
_data = data; | |||
} | |||
/** | |||
* USE ONLY within "processContinue" | |||
*/ | |||
public byte [] serialize() | |||
{ | |||
byte[] retval = new byte[ _data.length + 4 ]; | |||
serialize(0, retval); | |||
return retval; | |||
protected int getDataSize() { | |||
return _data.length; | |||
} | |||
public int serialize(int offset, byte[] data) { |
@@ -117,9 +117,8 @@ public class CountryRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 8; | |||
protected int getDataSize() { | |||
return 4; | |||
} | |||
public short getSid() |
@@ -143,10 +143,8 @@ public final class DBCellRecord extends Record { | |||
} | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 8 + (getNumCellOffsets() * 2); | |||
protected int getDataSize() { | |||
return 4 + (getNumCellOffsets() * 2); | |||
} | |||
/** |
@@ -85,9 +85,8 @@ public class DSFRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 6; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -164,9 +164,8 @@ public class DVALRecord extends Record | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 22; | |||
protected int getDataSize() { | |||
return 18; | |||
} | |||
public short getSid() |
@@ -303,8 +303,8 @@ public final class DVRecord extends Record { | |||
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); |
@@ -78,9 +78,8 @@ public final class DatRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -93,9 +93,8 @@ public final class DataFormatRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2 + 2 + 2 + 2; | |||
protected int getDataSize() { | |||
return 2 + 2 + 2 + 2; | |||
} | |||
public short getSid() |
@@ -85,9 +85,8 @@ public class DateWindow1904Record | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 6; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -80,9 +80,8 @@ public final class DefaultColWidthRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 6; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -69,9 +69,8 @@ public final class DefaultDataLabelTextPropertiesRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -110,9 +110,8 @@ public class DefaultRowHeightRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 8; | |||
protected int getDataSize() { | |||
return 4; | |||
} | |||
public short getSid() |
@@ -88,9 +88,8 @@ public class DeltaRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 12; | |||
protected int getDataSize() { | |||
return 8; | |||
} | |||
public short getSid() |
@@ -165,9 +165,8 @@ public class DimensionsRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 18; | |||
protected int getDataSize() { | |||
return 14; | |||
} | |||
public short getSid() |
@@ -26,8 +26,7 @@ import java.util.Iterator; | |||
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; | |||
@@ -82,30 +81,25 @@ public class DrawingGroupRecord extends AbstractEscherHolderRecord | |||
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) |
@@ -14,19 +14,21 @@ | |||
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 ) | |||
@@ -54,13 +56,10 @@ public class DrawingRecord extends Record | |||
} | |||
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; | |||
@@ -91,10 +90,8 @@ public class DrawingRecord extends Record | |||
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 ]; |
@@ -23,9 +23,7 @@ import java.io.ByteArrayInputStream; | |||
* 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() |
@@ -17,8 +17,7 @@ | |||
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() |
@@ -63,9 +63,8 @@ public final class EOFRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return ENCODED_SIZE; | |||
protected int getDataSize() { | |||
return ENCODED_SIZE - 4; | |||
} | |||
public short getSid() |
@@ -58,9 +58,8 @@ public final class EndRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4; | |||
protected int getDataSize() { | |||
return 0; | |||
} | |||
public short getSid() |
@@ -498,8 +498,8 @@ public class EscherAggregate extends AbstractEscherHolderRecord | |||
return size; | |||
} | |||
public int getRecordSize() | |||
{ | |||
protected int getDataSize() { | |||
// TODO - convert this to RecordAggregate | |||
convertUserModelToRecords(); | |||
List records = getEscherRecords(); | |||
int rawEscherSize = getEscherRecordSize( records ); | |||
@@ -516,7 +516,7 @@ public class EscherAggregate extends AbstractEscherHolderRecord | |||
Record r = (Record) iterator.next(); | |||
tailRecordSize += r.getRecordSize(); | |||
} | |||
return drawingRecordSize + objRecordSize + tailRecordSize; | |||
return drawingRecordSize + objRecordSize + tailRecordSize - 4; | |||
} | |||
/** |
@@ -100,9 +100,8 @@ public class ExtSSTInfoSubRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 8; | |||
protected int getDataSize() { | |||
return 4; | |||
} | |||
public short getSid() |
@@ -1,4 +1,3 @@ | |||
/* ==================================================================== | |||
Licensed to the Apache Software Foundation (ASF) under one or more | |||
contributor license agreements. See the NOTICE file distributed with | |||
@@ -15,13 +14,13 @@ | |||
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> | |||
@@ -35,17 +34,14 @@ import java.util.ArrayList; | |||
* @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() | |||
@@ -128,10 +124,8 @@ public class ExtSSTRecord | |||
} | |||
return pos; | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 6 + 8*getNumInfoRecords(); | |||
protected int getDataSize() { | |||
return 2 + 8*getNumInfoRecords(); | |||
} | |||
public static final int getNumberOfInfoRecsForStrings(int numStrings) { |
@@ -1787,9 +1787,8 @@ public class ExtendedFormatRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 24; | |||
protected int getDataSize() { | |||
return 20; | |||
} | |||
public short getSid() |
@@ -153,8 +153,7 @@ public class ExternSheetRecord extends Record { | |||
return sb.toString(); | |||
} | |||
private int getDataSize() { | |||
protected int getDataSize() { | |||
return 2 + _list.size() * RefSubRecord.ENCODED_SIZE; | |||
} | |||
@@ -189,10 +188,6 @@ public class ExternSheetRecord extends Record { | |||
return (RefSubRecord) _list.get(i); | |||
} | |||
public int getRecordSize() { | |||
return 4 + getDataSize(); | |||
} | |||
/** | |||
* return the non static version of the id for this record. | |||
*/ |
@@ -83,7 +83,7 @@ public final class ExternalNameRecord extends Record { | |||
return field_4_name; | |||
} | |||
private int getDataSize(){ | |||
protected int getDataSize(){ | |||
int result = 3 * 2 // 3 short fields | |||
+ 2 + field_4_name.length(); // nameLen and name | |||
if(hasFormula()) { | |||
@@ -120,10 +120,6 @@ public final class ExternalNameRecord extends Record { | |||
return recSize; | |||
} | |||
public int getRecordSize(){ | |||
return 4 + getDataSize(); | |||
} | |||
public ExternalNameRecord(RecordInputStream in) { | |||
field_1_option_flag = in.readShort(); |
@@ -68,9 +68,8 @@ public class FilePassRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 8; | |||
protected int getDataSize() { | |||
return 4; | |||
} | |||
public short getSid() |
@@ -153,12 +153,12 @@ public final class FileSharingRecord extends Record { | |||
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() { |
@@ -93,9 +93,8 @@ public class FnGroupCountRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 6; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -94,9 +94,8 @@ public final class FontBasisRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2 + 2 + 2 + 2 + 2; | |||
protected int getDataSize() { | |||
return 2 + 2 + 2 + 2 + 2; | |||
} | |||
public short getSid() |
@@ -66,9 +66,8 @@ public final class FontIndexRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -1,4 +1,3 @@ | |||
/* ==================================================================== | |||
Licensed to the Apache Software Foundation (ASF) under one or more | |||
contributor license agreements. See the NOTICE file distributed with | |||
@@ -15,7 +14,6 @@ | |||
See the License for the specific language governing permissions and | |||
limitations under the License. | |||
==================================================================== */ | |||
package org.apache.poi.hssf.record; | |||
@@ -29,14 +27,9 @@ import org.apache.poi.util.BitFieldFactory; | |||
* 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; | |||
@@ -509,12 +502,10 @@ public class FontRecord | |||
} | |||
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() |
@@ -180,16 +180,13 @@ public class FooterRecord | |||
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() |
@@ -1,4 +1,3 @@ | |||
/* ==================================================================== | |||
Licensed to the Apache Software Foundation (ASF) under one or more | |||
contributor license agreements. See the NOTICE file distributed with | |||
@@ -15,7 +14,6 @@ | |||
See the License for the specific language governing permissions and | |||
limitations under the License. | |||
==================================================================== */ | |||
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> | |||
* @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 | |||
@@ -199,10 +193,8 @@ public class FormatRecord | |||
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() |
@@ -353,7 +353,7 @@ public final class FormulaRecord extends Record implements CellValueRecordInterf | |||
return sid; | |||
} | |||
private int getDataSize() { | |||
protected int getDataSize() { | |||
return FIXED_SIZE + field_8_parsed_expr.getEncodedSize(); | |||
} | |||
public int serialize(int offset, byte [] data) { | |||
@@ -380,10 +380,6 @@ public final class FormulaRecord extends Record implements CellValueRecordInterf | |||
return recSize; | |||
} | |||
public int getRecordSize() { | |||
return 4 + getDataSize(); | |||
} | |||
public String toString() { | |||
StringBuffer sb = new StringBuffer(); |
@@ -83,9 +83,8 @@ public final class FrameRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2 + 2; | |||
protected int getDataSize() { | |||
return 2 + 2; | |||
} | |||
public short getSid() |
@@ -97,9 +97,8 @@ public class GridsetRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 6; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -167,9 +167,8 @@ public class GutsRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 12; | |||
protected int getDataSize() { | |||
return 8; | |||
} | |||
public short getSid() |
@@ -86,9 +86,8 @@ public final class HCenterRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 6; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -1,4 +1,3 @@ | |||
/* ==================================================================== | |||
Licensed to the Apache Software Foundation (ASF) under one or more | |||
contributor license agreements. See the NOTICE file distributed with | |||
@@ -15,7 +14,6 @@ | |||
See the License for the specific language governing permissions and | |||
limitations under the License. | |||
==================================================================== */ | |||
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 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; | |||
@@ -180,16 +174,13 @@ public class HeaderRecord | |||
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() |
@@ -95,9 +95,8 @@ public class HideObjRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 6; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -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 Yegor Kozlov (yegor at apache dot org) | |||
*/ | |||
public class HyperlinkRecord extends Record { | |||
public final class HyperlinkRecord extends Record { | |||
/** | |||
* Link flags | |||
*/ | |||
@@ -405,9 +405,8 @@ public class HyperlinkRecord extends Record { | |||
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 |
@@ -1,4 +1,3 @@ | |||
/* ==================================================================== | |||
Licensed to the Apache Software Foundation (ASF) under one or more | |||
contributor license agreements. See the NOTICE file distributed with | |||
@@ -15,7 +14,6 @@ | |||
See the License for the specific language governing permissions and | |||
limitations under the License. | |||
==================================================================== */ | |||
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> | |||
* @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 | |||
@@ -146,9 +140,8 @@ public class IndexRecord | |||
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 |
@@ -58,9 +58,8 @@ public final class InterfaceEndRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4; | |||
protected int getDataSize() { | |||
return 0; | |||
} | |||
public short getSid() |
@@ -94,9 +94,8 @@ public class InterfaceHdrRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 6; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -95,9 +95,8 @@ public class IterationRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 6; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -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!! | |||
*/ | |||
public int serialize(int offset, byte [] data) | |||
{ | |||
throw new RecordFormatException( | |||
"Label Records are supported READ ONLY...convert to LabelSST"); | |||
public int serialize(int offset, byte [] data) { | |||
throw new RecordFormatException("Label Records are supported READ ONLY...convert to LabelSST"); | |||
} | |||
protected int getDataSize() { | |||
throw new RecordFormatException("Label Records are supported READ ONLY...convert to LabelSST"); | |||
} | |||
public short getSid() |
@@ -140,9 +140,8 @@ public final class LabelSSTRecord extends Record implements CellValueRecordInter | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 14; | |||
protected int getDataSize() { | |||
return 10; | |||
} | |||
public short getSid() |
@@ -53,8 +53,8 @@ public class LeftMarginRecord extends Record implements Margin | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() { | |||
return 4 + 8; | |||
protected int getDataSize() { | |||
return 8; | |||
} | |||
public short getSid() { | |||
@@ -82,4 +82,4 @@ public class LeftMarginRecord extends Record implements Margin | |||
rec.field_1_margin = this.field_1_margin; | |||
return rec; | |||
} | |||
} // END OF CLA | |||
} // END OF C |
@@ -133,9 +133,8 @@ public final class LegendRecord extends Record { | |||
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() |
@@ -118,9 +118,8 @@ public final class LineFormatRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 4 + 2 + 2 + 2 + 2; | |||
protected int getDataSize() { | |||
return 4 + 2 + 2 + 2 + 2; | |||
} | |||
public short getSid() |
@@ -108,9 +108,8 @@ public final class LinkedDataRecord extends Record { | |||
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() |
@@ -110,9 +110,8 @@ public class MMSRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 6; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -72,9 +72,9 @@ public final class MergeCellsRecord extends Record { | |||
return _regions[_startIndex + index]; | |||
} | |||
public int getRecordSize() { | |||
return 4 + CellRangeAddressList.getEncodedSize(_numberOfRegions); | |||
} | |||
protected int getDataSize() { | |||
return CellRangeAddressList.getEncodedSize(_numberOfRegions); | |||
} | |||
public short getSid() { | |||
return sid; |
@@ -1,4 +1,3 @@ | |||
/* ==================================================================== | |||
Licensed to the Apache Software Foundation (ASF) under one or more | |||
contributor license agreements. See the NOTICE file distributed with | |||
@@ -15,50 +14,33 @@ | |||
See the License for the specific language governing permissions and | |||
limitations under the License. | |||
==================================================================== */ | |||
/* | |||
* MulBlankRecord.java | |||
* | |||
* Created on December 10, 2001, 12:49 PM | |||
*/ | |||
package org.apache.poi.hssf.record; | |||
/** | |||
* Title: Mulitple Blank cell record <P> | |||
* Title: Multiple Blank cell record(0x00BE) <P/> | |||
* Description: Represents a set of columns in a row with no value but with styling. | |||
* In this release we have read-only support for this record type. | |||
* The RecordFactory converts this to a set of BlankRecord objects.<P> | |||
* REFERENCE: PG 329 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P> | |||
* The RecordFactory converts this to a set of BlankRecord objects.<P/> | |||
* REFERENCE: PG 329 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P/> | |||
* @author Andrew C. Oliver (acoliver at apache dot org) | |||
* @author Glen Stampoultzis (glens at apache.org) | |||
* @version 2.0-pre | |||
* @see org.apache.poi.hssf.record.BlankRecord | |||
* @see BlankRecord | |||
*/ | |||
public class MulBlankRecord | |||
extends Record | |||
{ | |||
public final static short sid = 0xbe; | |||
//private short field_1_row; | |||
private int field_1_row; | |||
public final class MulBlankRecord extends Record { | |||
public final static short sid = 0x00BE; | |||
private int field_1_row; | |||
private short field_2_first_col; | |||
private short[] field_3_xfs; | |||
private short field_4_last_col; | |||
/** Creates new MulBlankRecord */ | |||
public MulBlankRecord() | |||
{ | |||
} | |||
/** | |||
* get the row number of the cells this represents | |||
* | |||
* @return row number | |||
*/ | |||
//public short getRow() | |||
public int getRow() | |||
{ | |||
return field_1_row; | |||
@@ -68,7 +50,6 @@ public class MulBlankRecord | |||
* starting column (first cell this holds in the row) | |||
* @return first column number | |||
*/ | |||
public short getFirstColumn() | |||
{ | |||
return field_2_first_col; | |||
@@ -78,7 +59,6 @@ public class MulBlankRecord | |||
* ending column (last cell this holds in the row) | |||
* @return first column number | |||
*/ | |||
public short getLastColumn() | |||
{ | |||
return field_4_last_col; | |||
@@ -88,7 +68,6 @@ public class MulBlankRecord | |||
* get the number of columns this contains (last-first +1) | |||
* @return number of columns (last - first +1) | |||
*/ | |||
public int getNumColumns() | |||
{ | |||
return field_4_last_col - field_2_first_col + 1; | |||
@@ -99,7 +78,6 @@ public class MulBlankRecord | |||
* @param coffset the column (coffset = column - field_2_first_col) | |||
* @return the XF index for the column | |||
*/ | |||
public short getXFAt(int coffset) | |||
{ | |||
return field_3_xfs[ coffset ]; | |||
@@ -108,16 +86,14 @@ public class MulBlankRecord | |||
/** | |||
* @param in the RecordInputstream to read the record from | |||
*/ | |||
public MulBlankRecord(RecordInputStream in) | |||
{ | |||
//field_1_row = LittleEndian.getShort(data, 0 + offset); | |||
public MulBlankRecord(RecordInputStream in) { | |||
field_1_row = in.readUShort(); | |||
field_2_first_col = in.readShort(); | |||
field_3_xfs = parseXFs(in); | |||
field_4_last_col = in.readShort(); | |||
} | |||
private short [] parseXFs(RecordInputStream in) | |||
private static short [] parseXFs(RecordInputStream in) | |||
{ | |||
short[] retval = new short[ (in.remaining() - 2) / 2 ]; | |||
@@ -128,21 +104,16 @@ public class MulBlankRecord | |||
return retval; | |||
} | |||
public String toString() | |||
{ | |||
public String toString() { | |||
StringBuffer buffer = new StringBuffer(); | |||
buffer.append("[MULBLANK]\n"); | |||
buffer.append("row = ") | |||
.append(Integer.toHexString(getRow())).append("\n"); | |||
buffer.append("firstcol = ") | |||
.append(Integer.toHexString(getFirstColumn())).append("\n"); | |||
buffer.append(" lastcol = ") | |||
.append(Integer.toHexString(getLastColumn())).append("\n"); | |||
for (int k = 0; k < getNumColumns(); k++) | |||
{ | |||
buffer.append("xf").append(k).append(" = ") | |||
.append(Integer.toHexString(getXFAt(k))).append("\n"); | |||
buffer.append("row = ").append(Integer.toHexString(getRow())).append("\n"); | |||
buffer.append("firstcol = ").append(Integer.toHexString(getFirstColumn())).append("\n"); | |||
buffer.append(" lastcol = ").append(Integer.toHexString(getLastColumn())).append("\n"); | |||
for (int k = 0; k < getNumColumns(); k++) { | |||
buffer.append("xf").append(k).append(" = ").append( | |||
Integer.toHexString(getXFAt(k))).append("\n"); | |||
} | |||
buffer.append("[/MULBLANK]\n"); | |||
return buffer.toString(); | |||
@@ -153,9 +124,10 @@ public class MulBlankRecord | |||
return sid; | |||
} | |||
public int serialize(int offset, byte [] data) | |||
{ | |||
throw new RecordFormatException( | |||
"Sorry, you can't serialize a MulBlank in this release"); | |||
public int serialize(int offset, byte [] data) { | |||
throw new RecordFormatException( "Sorry, you can't serialize MulBlank in this release"); | |||
} | |||
protected int getDataSize() { | |||
throw new RecordFormatException( "Sorry, you can't serialize MulBlank in this release"); | |||
} | |||
} |
@@ -113,10 +113,11 @@ public final class MulRKRecord extends Record { | |||
return sid; | |||
} | |||
public int serialize(int offset, byte [] data) | |||
{ | |||
throw new RecordFormatException( | |||
"Sorry, you can't serialize a MulRK in this release"); | |||
public int serialize(int offset, byte [] data) { | |||
throw new RecordFormatException( "Sorry, you can't serialize MulRK in this release"); | |||
} | |||
protected int getDataSize() { | |||
throw new RecordFormatException( "Sorry, you can't serialize MulRK in this release"); | |||
} | |||
private static final class RkRec { |
@@ -408,10 +408,9 @@ public final class NameRecord extends Record { | |||
} | |||
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() |
@@ -24,8 +24,8 @@ import org.apache.poi.util.LittleEndian; | |||
* | |||
* @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) | |||
@@ -100,16 +100,13 @@ public class NoteRecord extends Record { | |||
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() | |||
{ |
@@ -66,9 +66,8 @@ public final class NumberFormatIndexRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -142,9 +142,8 @@ public final class NumberRecord extends Record implements CellValueRecordInterfa | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 18; | |||
protected int getDataSize() { | |||
return 14; | |||
} | |||
public short getSid() |
@@ -119,7 +119,7 @@ public final class ObjRecord extends Record { | |||
return sb.toString(); | |||
} | |||
private int getDataSize() { | |||
protected int getDataSize() { | |||
if (_uninterpretedData != null) { | |||
return _uninterpretedData.length; | |||
} | |||
@@ -165,10 +165,6 @@ public final class ObjRecord extends Record { | |||
return recSize; | |||
} | |||
public int getRecordSize() { | |||
return 4 + getDataSize(); | |||
} | |||
public short getSid() { | |||
return sid; | |||
} |
@@ -86,9 +86,8 @@ public final class ObjectLinkRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2 + 2 + 2; | |||
protected int getDataSize() { | |||
return 2 + 2 + 2; | |||
} | |||
public short getSid() |
@@ -93,9 +93,8 @@ public class ObjectProtectRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 6; | |||
protected int getDataSize() { | |||
return 2; | |||
} | |||
public short getSid() |
@@ -37,7 +37,6 @@ import org.apache.poi.util.LittleEndian; | |||
* @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; | |||
@@ -97,23 +96,15 @@ public abstract class PageBreakRecord extends Record { | |||
} | |||
private int getDataSize() { | |||
return 2 + _breaks.size() * Break.ENCODED_SIZE; | |||
public boolean isEmpty() { | |||
return _breaks.isEmpty(); | |||
} | |||
public int getRecordSize() { | |||
int nBreaks = _breaks.size(); | |||
if (!IS_EMPTY_RECORD_WRITTEN && nBreaks < 1) { | |||
return 0; | |||
} | |||
return 4 + getDataSize(); | |||
protected int getDataSize() { | |||
return 2 + _breaks.size() * Break.ENCODED_SIZE; | |||
} | |||
public final int serialize(int offset, byte data[]) { | |||
int nBreaks = _breaks.size(); | |||
if (!IS_EMPTY_RECORD_WRITTEN && nBreaks < 1) { | |||
return 0; | |||
} | |||
int dataSize = getDataSize(); | |||
LittleEndian.putUShort(data, offset + 0, getSid()); | |||
LittleEndian.putUShort(data, offset + 2, dataSize); |
@@ -96,9 +96,8 @@ public class PaletteRecord | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2 + (field_1_numcolors * 4); | |||
protected int getDataSize() { | |||
return 2 + (field_1_numcolors * 4); | |||
} | |||
public short getSid() |
@@ -102,9 +102,8 @@ public final class PaneRecord extends Record { | |||
return getRecordSize(); | |||
} | |||
public int getRecordSize() | |||
{ | |||
return 4 + 2 + 2 + 2 + 2 + 2; | |||
protected int getDataSize() { | |||
return 2 + 2 + 2 + 2 + 2; | |||
} | |||
public short getSid() |