From 9a44085684312926612288724d8dab31830f17b7 Mon Sep 17 00:00:00 2001 From: Josh Micich Date: Fri, 31 Oct 2008 01:02:55 +0000 Subject: [PATCH] converted getRecordSize methods to getDataSize git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@709317 13f79535-47bb-0310-9956-ffa450edef68 --- .../dummyrecord/DummyRecordBase.java | 40 ++++++++++++++++ .../dummyrecord/LastCellOfRowDummyRecord.java | 14 +----- .../dummyrecord/MissingCellDummyRecord.java | 15 +----- .../dummyrecord/MissingRowDummyRecord.java | 15 +----- .../record/AbstractEscherHolderRecord.java | 46 ++++--------------- .../poi/hssf/record/AreaFormatRecord.java | 5 +- .../apache/poi/hssf/record/AreaRecord.java | 5 +- .../poi/hssf/record/AxisLineFormatRecord.java | 5 +- .../poi/hssf/record/AxisOptionsRecord.java | 5 +- .../poi/hssf/record/AxisParentRecord.java | 5 +- .../apache/poi/hssf/record/AxisRecord.java | 5 +- .../poi/hssf/record/AxisUsedRecord.java | 5 +- .../org/apache/poi/hssf/record/BOFRecord.java | 5 +- .../apache/poi/hssf/record/BackupRecord.java | 5 +- .../org/apache/poi/hssf/record/BarRecord.java | 5 +- .../apache/poi/hssf/record/BeginRecord.java | 5 +- .../apache/poi/hssf/record/BlankRecord.java | 5 +- .../poi/hssf/record/BookBoolRecord.java | 5 +- .../apache/poi/hssf/record/BoolErrRecord.java | 5 +- .../poi/hssf/record/BottomMarginRecord.java | 7 ++- .../poi/hssf/record/BoundSheetRecord.java | 4 -- .../poi/hssf/record/CFHeaderRecord.java | 4 -- .../apache/poi/hssf/record/CFRuleRecord.java | 7 +-- .../poi/hssf/record/CRNCountRecord.java | 9 ++-- .../org/apache/poi/hssf/record/CRNRecord.java | 4 -- .../poi/hssf/record/CalcCountRecord.java | 5 +- .../poi/hssf/record/CalcModeRecord.java | 5 +- .../hssf/record/CategorySeriesAxisRecord.java | 5 +- .../poi/hssf/record/ChartFormatRecord.java | 5 +- .../apache/poi/hssf/record/ChartRecord.java | 5 +- .../hssf/record/ChartTitleFormatRecord.java | 5 +- .../poi/hssf/record/CodepageRecord.java | 5 +- .../poi/hssf/record/ColumnInfoRecord.java | 5 +- .../poi/hssf/record/ContinueRecord.java | 4 +- .../apache/poi/hssf/record/CountryRecord.java | 5 +- .../apache/poi/hssf/record/DBCellRecord.java | 6 +-- .../org/apache/poi/hssf/record/DSFRecord.java | 5 +- .../apache/poi/hssf/record/DVALRecord.java | 5 +- .../org/apache/poi/hssf/record/DVRecord.java | 4 +- .../org/apache/poi/hssf/record/DatRecord.java | 5 +- .../poi/hssf/record/DataFormatRecord.java | 5 +- .../poi/hssf/record/DateWindow1904Record.java | 5 +- .../hssf/record/DefaultColWidthRecord.java | 5 +- .../DefaultDataLabelTextPropertiesRecord.java | 5 +- .../hssf/record/DefaultRowHeightRecord.java | 5 +- .../apache/poi/hssf/record/DeltaRecord.java | 5 +- .../poi/hssf/record/DimensionsRecord.java | 5 +- .../poi/hssf/record/DrawingGroupRecord.java | 26 ++++------- .../apache/poi/hssf/record/DrawingRecord.java | 27 +++++------ .../record/DrawingRecordForBiffViewer.java | 4 +- .../hssf/record/DrawingSelectionRecord.java | 3 +- .../org/apache/poi/hssf/record/EOFRecord.java | 5 +- .../org/apache/poi/hssf/record/EndRecord.java | 5 +- .../poi/hssf/record/EscherAggregate.java | 6 +-- .../poi/hssf/record/ExtSSTInfoSubRecord.java | 5 +- .../apache/poi/hssf/record/ExtSSTRecord.java | 24 ++++------ .../poi/hssf/record/ExtendedFormatRecord.java | 5 +- .../poi/hssf/record/ExternSheetRecord.java | 4 -- .../poi/hssf/record/ExternalNameRecord.java | 4 -- .../poi/hssf/record/FilePassRecord.java | 5 +- .../poi/hssf/record/FileSharingRecord.java | 6 +-- .../poi/hssf/record/FnGroupCountRecord.java | 5 +- .../poi/hssf/record/FontBasisRecord.java | 5 +- .../poi/hssf/record/FontIndexRecord.java | 5 +- .../apache/poi/hssf/record/FontRecord.java | 17 ++----- .../apache/poi/hssf/record/FooterRecord.java | 11 ++--- .../apache/poi/hssf/record/FormatRecord.java | 16 ++----- .../apache/poi/hssf/record/FormulaRecord.java | 4 -- .../apache/poi/hssf/record/FrameRecord.java | 5 +- .../apache/poi/hssf/record/GridsetRecord.java | 5 +- .../apache/poi/hssf/record/GutsRecord.java | 5 +- .../apache/poi/hssf/record/HCenterRecord.java | 5 +- .../apache/poi/hssf/record/HeaderRecord.java | 21 +++------ .../apache/poi/hssf/record/HideObjRecord.java | 5 +- .../poi/hssf/record/HyperlinkRecord.java | 7 ++- .../apache/poi/hssf/record/IndexRecord.java | 15 ++---- .../poi/hssf/record/InterfaceEndRecord.java | 5 +- .../poi/hssf/record/InterfaceHdrRecord.java | 5 +- .../poi/hssf/record/IterationRecord.java | 5 +- .../apache/poi/hssf/record/LabelRecord.java | 2 +- .../poi/hssf/record/LabelSSTRecord.java | 5 +- .../poi/hssf/record/LeftMarginRecord.java | 6 +-- .../apache/poi/hssf/record/LegendRecord.java | 5 +- .../poi/hssf/record/LineFormatRecord.java | 5 +- .../poi/hssf/record/LinkedDataRecord.java | 5 +- .../org/apache/poi/hssf/record/MMSRecord.java | 5 +- .../poi/hssf/record/MergeCellsRecord.java | 6 +-- .../poi/hssf/record/MulBlankRecord.java | 2 +- .../apache/poi/hssf/record/MulRKRecord.java | 2 +- .../apache/poi/hssf/record/NameRecord.java | 7 ++- .../apache/poi/hssf/record/NoteRecord.java | 13 ++---- .../hssf/record/NumberFormatIndexRecord.java | 5 +- .../apache/poi/hssf/record/NumberRecord.java | 5 +- .../org/apache/poi/hssf/record/ObjRecord.java | 4 -- .../poi/hssf/record/ObjectLinkRecord.java | 5 +- .../poi/hssf/record/ObjectProtectRecord.java | 5 +- .../poi/hssf/record/PageBreakRecord.java | 15 ++---- .../apache/poi/hssf/record/PaletteRecord.java | 5 +- .../apache/poi/hssf/record/PaneRecord.java | 5 +- .../poi/hssf/record/PasswordRecord.java | 4 +- .../poi/hssf/record/PasswordRev4Record.java | 5 +- .../poi/hssf/record/PlotAreaRecord.java | 5 +- .../poi/hssf/record/PlotGrowthRecord.java | 5 +- .../poi/hssf/record/PrecisionRecord.java | 5 +- .../poi/hssf/record/PrintGridlinesRecord.java | 5 +- .../poi/hssf/record/PrintHeadersRecord.java | 5 +- .../poi/hssf/record/PrintSetupRecord.java | 5 +- .../apache/poi/hssf/record/ProtectRecord.java | 5 +- .../poi/hssf/record/ProtectionRev4Record.java | 5 +- .../org/apache/poi/hssf/record/RKRecord.java | 3 +- .../poi/hssf/record/RecalcIdRecord.java | 5 +- .../org/apache/poi/hssf/record/Record.java | 11 ++--- .../apache/poi/hssf/record/RefModeRecord.java | 5 +- .../poi/hssf/record/RefreshAllRecord.java | 5 +- .../poi/hssf/record/RightMarginRecord.java | 6 ++- .../org/apache/poi/hssf/record/RowRecord.java | 5 +- .../org/apache/poi/hssf/record/SCLRecord.java | 5 +- .../org/apache/poi/hssf/record/SSTRecord.java | 15 ++---- .../poi/hssf/record/SaveRecalcRecord.java | 5 +- .../hssf/record/ScenarioProtectRecord.java | 5 +- .../poi/hssf/record/SelectionRecord.java | 4 -- .../record/SeriesChartGroupIndexRecord.java | 5 +- .../poi/hssf/record/SeriesIndexRecord.java | 5 +- .../poi/hssf/record/SeriesLabelsRecord.java | 5 +- .../poi/hssf/record/SeriesListRecord.java | 5 +- .../apache/poi/hssf/record/SeriesRecord.java | 5 +- .../poi/hssf/record/SeriesTextRecord.java | 5 +- .../hssf/record/SeriesToChartGroupRecord.java | 5 +- .../hssf/record/SharedValueRecordBase.java | 4 +- .../hssf/record/SheetPropertiesRecord.java | 5 +- .../apache/poi/hssf/record/StringRecord.java | 5 +- .../apache/poi/hssf/record/StyleRecord.java | 4 -- .../apache/poi/hssf/record/SupBookRecord.java | 4 -- .../apache/poi/hssf/record/TabIdRecord.java | 5 +- .../poi/hssf/record/TextObjectRecord.java | 10 ++-- .../apache/poi/hssf/record/TextRecord.java | 5 +- .../apache/poi/hssf/record/TickRecord.java | 5 +- .../poi/hssf/record/TopMarginRecord.java | 6 ++- .../poi/hssf/record/UncalcedRecord.java | 13 ++---- .../apache/poi/hssf/record/UnitsRecord.java | 5 +- .../apache/poi/hssf/record/UnknownRecord.java | 4 +- .../poi/hssf/record/UseSelFSRecord.java | 5 +- .../apache/poi/hssf/record/VCenterRecord.java | 5 +- .../poi/hssf/record/ValueRangeRecord.java | 5 +- .../apache/poi/hssf/record/WSBoolRecord.java | 5 +- .../poi/hssf/record/WindowOneRecord.java | 5 +- .../poi/hssf/record/WindowProtectRecord.java | 5 +- .../poi/hssf/record/WindowTwoRecord.java | 5 +- .../poi/hssf/record/WriteAccessRecord.java | 4 +- .../poi/hssf/record/WriteProtectRecord.java | 5 +- .../record/aggregates/PageSettingsBlock.java | 9 ++++ .../poi/hssf/usermodel/TestHSSFWorkbook.java | 5 +- 152 files changed, 391 insertions(+), 631 deletions(-) create mode 100644 src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/DummyRecordBase.java diff --git a/src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/DummyRecordBase.java b/src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/DummyRecordBase.java new file mode 100644 index 0000000000..333113487a --- /dev/null +++ b/src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/DummyRecordBase.java @@ -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"); + } +} diff --git a/src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/LastCellOfRowDummyRecord.java b/src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/LastCellOfRowDummyRecord.java index 49e77ebf94..e063593016 100644 --- a/src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/LastCellOfRowDummyRecord.java +++ b/src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/LastCellOfRowDummyRecord.java @@ -17,14 +17,12 @@ package org.apache.poi.hssf.eventusermodel.dummyrecord; -import org.apache.poi.hssf.record.Record; -import org.apache.poi.hssf.record.RecordFormatException; /** * A dummy record to indicate that we've now had the last * cell record for this row. */ -public final class LastCellOfRowDummyRecord extends Record { +public final class LastCellOfRowDummyRecord extends DummyRecordBase { private int row; private int lastColumnNumber; @@ -46,14 +44,4 @@ public final class LastCellOfRowDummyRecord extends Record { * for the row. */ public int getLastColumnNumber() { return lastColumnNumber; } - - public short getSid() { - return -1; - } - public int serialize(int offset, byte[] data) { - throw new RecordFormatException("Cannot serialize a dummy record"); - } - public int getRecordSize() { - throw new RecordFormatException("Cannot serialize a dummy record"); - } } diff --git a/src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/MissingCellDummyRecord.java b/src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/MissingCellDummyRecord.java index c8adb4ae88..393e21f387 100644 --- a/src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/MissingCellDummyRecord.java +++ b/src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/MissingCellDummyRecord.java @@ -17,14 +17,12 @@ package org.apache.poi.hssf.eventusermodel.dummyrecord; -import org.apache.poi.hssf.record.Record; -import org.apache.poi.hssf.record.RecordFormatException; /** * A dummy record for when we're missing a cell in a row, * but still want to trigger something */ -public final class MissingCellDummyRecord extends Record { +public final class MissingCellDummyRecord extends DummyRecordBase { private int row; private int column; @@ -32,17 +30,6 @@ public final class MissingCellDummyRecord extends Record { this.row = row; this.column = column; } - - public short getSid() { - return -1; - } - public int serialize(int offset, byte[] data) { - throw new RecordFormatException("Cannot serialize a dummy record"); - } - public int getRecordSize() { - throw new RecordFormatException("Cannot serialize a dummy record"); - } - public int getRow() { return row; } public int getColumn() { return column; } } diff --git a/src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/MissingRowDummyRecord.java b/src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/MissingRowDummyRecord.java index c268bccfc2..4c128bd004 100644 --- a/src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/MissingRowDummyRecord.java +++ b/src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/MissingRowDummyRecord.java @@ -17,30 +17,17 @@ package org.apache.poi.hssf.eventusermodel.dummyrecord; -import org.apache.poi.hssf.record.Record; -import org.apache.poi.hssf.record.RecordFormatException; /** * A dummy record for when we're missing a row, but still * want to trigger something */ -public final class MissingRowDummyRecord extends Record { +public final class MissingRowDummyRecord extends DummyRecordBase { private int rowNumber; public MissingRowDummyRecord(int rowNumber) { this.rowNumber = rowNumber; } - - public short getSid() { - return -1; - } - public int serialize(int offset, byte[] data) { - throw new RecordFormatException("Cannot serialize a dummy record"); - } - public int getRecordSize() { - throw new RecordFormatException("Cannot serialize a dummy record"); - } - public int getRowNumber() { return rowNumber; } diff --git a/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java b/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java index bd82074181..461817cce1 100644 --- a/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java +++ b/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java @@ -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(); diff --git a/src/java/org/apache/poi/hssf/record/AreaFormatRecord.java b/src/java/org/apache/poi/hssf/record/AreaFormatRecord.java index f6abd9c170..9e3d2ea110 100644 --- a/src/java/org/apache/poi/hssf/record/AreaFormatRecord.java +++ b/src/java/org/apache/poi/hssf/record/AreaFormatRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/AreaRecord.java b/src/java/org/apache/poi/hssf/record/AreaRecord.java index 14a5737f56..85f2ea172b 100644 --- a/src/java/org/apache/poi/hssf/record/AreaRecord.java +++ b/src/java/org/apache/poi/hssf/record/AreaRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/AxisLineFormatRecord.java b/src/java/org/apache/poi/hssf/record/AxisLineFormatRecord.java index 1f6e03dbc1..dbcd14e497 100644 --- a/src/java/org/apache/poi/hssf/record/AxisLineFormatRecord.java +++ b/src/java/org/apache/poi/hssf/record/AxisLineFormatRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/AxisOptionsRecord.java b/src/java/org/apache/poi/hssf/record/AxisOptionsRecord.java index 32656d4709..c630cfe823 100644 --- a/src/java/org/apache/poi/hssf/record/AxisOptionsRecord.java +++ b/src/java/org/apache/poi/hssf/record/AxisOptionsRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/AxisParentRecord.java b/src/java/org/apache/poi/hssf/record/AxisParentRecord.java index 9a92c2e4ac..0f7b8dba31 100644 --- a/src/java/org/apache/poi/hssf/record/AxisParentRecord.java +++ b/src/java/org/apache/poi/hssf/record/AxisParentRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/AxisRecord.java b/src/java/org/apache/poi/hssf/record/AxisRecord.java index 0619027c9b..2c989ce426 100644 --- a/src/java/org/apache/poi/hssf/record/AxisRecord.java +++ b/src/java/org/apache/poi/hssf/record/AxisRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/AxisUsedRecord.java b/src/java/org/apache/poi/hssf/record/AxisUsedRecord.java index c70129d7fb..76e6e65514 100644 --- a/src/java/org/apache/poi/hssf/record/AxisUsedRecord.java +++ b/src/java/org/apache/poi/hssf/record/AxisUsedRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/BOFRecord.java b/src/java/org/apache/poi/hssf/record/BOFRecord.java index 672505f5b0..bd71f53286 100644 --- a/src/java/org/apache/poi/hssf/record/BOFRecord.java +++ b/src/java/org/apache/poi/hssf/record/BOFRecord.java @@ -286,9 +286,8 @@ public class BOFRecord return getRecordSize(); } - public int getRecordSize() - { - return 20; + protected int getDataSize() { + return 16; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/BackupRecord.java b/src/java/org/apache/poi/hssf/record/BackupRecord.java index 2ffbb5ba79..f2ee6ccf14 100644 --- a/src/java/org/apache/poi/hssf/record/BackupRecord.java +++ b/src/java/org/apache/poi/hssf/record/BackupRecord.java @@ -87,9 +87,8 @@ public class BackupRecord return getRecordSize(); } - public int getRecordSize() - { - return 6; + protected int getDataSize() { + return 2; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/BarRecord.java b/src/java/org/apache/poi/hssf/record/BarRecord.java index a9733c5219..7b62e649ee 100644 --- a/src/java/org/apache/poi/hssf/record/BarRecord.java +++ b/src/java/org/apache/poi/hssf/record/BarRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/BeginRecord.java b/src/java/org/apache/poi/hssf/record/BeginRecord.java index c983590bd6..94f78f7f82 100644 --- a/src/java/org/apache/poi/hssf/record/BeginRecord.java +++ b/src/java/org/apache/poi/hssf/record/BeginRecord.java @@ -57,9 +57,8 @@ public class BeginRecord extends Record { return getRecordSize(); } - public int getRecordSize() - { - return 4; + protected int getDataSize() { + return 0; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/BlankRecord.java b/src/java/org/apache/poi/hssf/record/BlankRecord.java index 864cc53c3c..424f66c4c2 100644 --- a/src/java/org/apache/poi/hssf/record/BlankRecord.java +++ b/src/java/org/apache/poi/hssf/record/BlankRecord.java @@ -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() { diff --git a/src/java/org/apache/poi/hssf/record/BookBoolRecord.java b/src/java/org/apache/poi/hssf/record/BookBoolRecord.java index 0ad7a5ac60..072f58bec8 100644 --- a/src/java/org/apache/poi/hssf/record/BookBoolRecord.java +++ b/src/java/org/apache/poi/hssf/record/BookBoolRecord.java @@ -87,9 +87,8 @@ public class BookBoolRecord return getRecordSize(); } - public int getRecordSize() - { - return 6; + protected int getDataSize() { + return 2; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/BoolErrRecord.java b/src/java/org/apache/poi/hssf/record/BoolErrRecord.java index bed162f94c..e0eb26d523 100644 --- a/src/java/org/apache/poi/hssf/record/BoolErrRecord.java +++ b/src/java/org/apache/poi/hssf/record/BoolErrRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/BottomMarginRecord.java b/src/java/org/apache/poi/hssf/record/BottomMarginRecord.java index 15d3174c2c..f0b7f7d2d1 100644 --- a/src/java/org/apache/poi/hssf/record/BottomMarginRecord.java +++ b/src/java/org/apache/poi/hssf/record/BottomMarginRecord.java @@ -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 \ No newline at end of file +} // END OF C \ No newline at end of file diff --git a/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java b/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java index ca369bd8b9..17d337f823 100644 --- a/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java +++ b/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java @@ -179,10 +179,6 @@ public final class BoundSheetRecord extends Record { return 4 + dataSize; } - public int getRecordSize() { - return 4 + getDataSize(); - } - public short getSid() { return sid; } diff --git a/src/java/org/apache/poi/hssf/record/CFHeaderRecord.java b/src/java/org/apache/poi/hssf/record/CFHeaderRecord.java index 8988e06526..f94f78a90d 100644 --- a/src/java/org/apache/poi/hssf/record/CFHeaderRecord.java +++ b/src/java/org/apache/poi/hssf/record/CFHeaderRecord.java @@ -151,10 +151,6 @@ public final class CFHeaderRecord extends Record { return 4 + dataSize; } - public int getRecordSize() { - return 4 + getDataSize(); - } - public short getSid() { return sid; diff --git a/src/java/org/apache/poi/hssf/record/CFRuleRecord.java b/src/java/org/apache/poi/hssf/record/CFRuleRecord.java index 214ebaa299..f9e11dbaf4 100644 --- a/src/java/org/apache/poi/hssf/record/CFRuleRecord.java +++ b/src/java/org/apache/poi/hssf/record/CFRuleRecord.java @@ -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; } diff --git a/src/java/org/apache/poi/hssf/record/CRNCountRecord.java b/src/java/org/apache/poi/hssf/record/CRNCountRecord.java index 5df98bf34e..e04deb79de 100755 --- a/src/java/org/apache/poi/hssf/record/CRNCountRecord.java +++ b/src/java/org/apache/poi/hssf/record/CRNCountRecord.java @@ -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; } /** diff --git a/src/java/org/apache/poi/hssf/record/CRNRecord.java b/src/java/org/apache/poi/hssf/record/CRNRecord.java index fffefe2b45..58be686ad5 100755 --- a/src/java/org/apache/poi/hssf/record/CRNRecord.java +++ b/src/java/org/apache/poi/hssf/record/CRNRecord.java @@ -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. */ diff --git a/src/java/org/apache/poi/hssf/record/CalcCountRecord.java b/src/java/org/apache/poi/hssf/record/CalcCountRecord.java index eb783f3857..d2001f68d0 100644 --- a/src/java/org/apache/poi/hssf/record/CalcCountRecord.java +++ b/src/java/org/apache/poi/hssf/record/CalcCountRecord.java @@ -89,9 +89,8 @@ public class CalcCountRecord return getRecordSize(); } - public int getRecordSize() - { - return 6; + protected int getDataSize() { + return 2; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/CalcModeRecord.java b/src/java/org/apache/poi/hssf/record/CalcModeRecord.java index de8d860fce..73839d82aa 100644 --- a/src/java/org/apache/poi/hssf/record/CalcModeRecord.java +++ b/src/java/org/apache/poi/hssf/record/CalcModeRecord.java @@ -115,9 +115,8 @@ public class CalcModeRecord return getRecordSize(); } - public int getRecordSize() - { - return 6; + protected int getDataSize() { + return 2; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/CategorySeriesAxisRecord.java b/src/java/org/apache/poi/hssf/record/CategorySeriesAxisRecord.java index 2842788c79..ec6a37e51e 100644 --- a/src/java/org/apache/poi/hssf/record/CategorySeriesAxisRecord.java +++ b/src/java/org/apache/poi/hssf/record/CategorySeriesAxisRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/ChartFormatRecord.java b/src/java/org/apache/poi/hssf/record/ChartFormatRecord.java index 490cdd4555..b39759fdc4 100644 --- a/src/java/org/apache/poi/hssf/record/ChartFormatRecord.java +++ b/src/java/org/apache/poi/hssf/record/ChartFormatRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/ChartRecord.java b/src/java/org/apache/poi/hssf/record/ChartRecord.java index 62e02d4faf..e07cda58e8 100644 --- a/src/java/org/apache/poi/hssf/record/ChartRecord.java +++ b/src/java/org/apache/poi/hssf/record/ChartRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/ChartTitleFormatRecord.java b/src/java/org/apache/poi/hssf/record/ChartTitleFormatRecord.java index fd22d5229b..37f539e4a0 100644 --- a/src/java/org/apache/poi/hssf/record/ChartTitleFormatRecord.java +++ b/src/java/org/apache/poi/hssf/record/ChartTitleFormatRecord.java @@ -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() { diff --git a/src/java/org/apache/poi/hssf/record/CodepageRecord.java b/src/java/org/apache/poi/hssf/record/CodepageRecord.java index 4675fe4730..4e61500dbd 100644 --- a/src/java/org/apache/poi/hssf/record/CodepageRecord.java +++ b/src/java/org/apache/poi/hssf/record/CodepageRecord.java @@ -96,9 +96,8 @@ public class CodepageRecord return getRecordSize(); } - public int getRecordSize() - { - return 6; + protected int getDataSize() { + return 2; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/ColumnInfoRecord.java b/src/java/org/apache/poi/hssf/record/ColumnInfoRecord.java index 38d05181c9..1fc0907f96 100644 --- a/src/java/org/apache/poi/hssf/record/ColumnInfoRecord.java +++ b/src/java/org/apache/poi/hssf/record/ColumnInfoRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/ContinueRecord.java b/src/java/org/apache/poi/hssf/record/ContinueRecord.java index c67012aa7c..bed97a4098 100644 --- a/src/java/org/apache/poi/hssf/record/ContinueRecord.java +++ b/src/java/org/apache/poi/hssf/record/ContinueRecord.java @@ -35,8 +35,8 @@ public final class ContinueRecord extends Record { _data = data; } - public int getRecordSize() { - return 4 + _data.length; + protected int getDataSize() { + return _data.length; } public int serialize(int offset, byte[] data) { diff --git a/src/java/org/apache/poi/hssf/record/CountryRecord.java b/src/java/org/apache/poi/hssf/record/CountryRecord.java index 7d739a9b65..c6b3ac454d 100644 --- a/src/java/org/apache/poi/hssf/record/CountryRecord.java +++ b/src/java/org/apache/poi/hssf/record/CountryRecord.java @@ -117,9 +117,8 @@ public class CountryRecord return getRecordSize(); } - public int getRecordSize() - { - return 8; + protected int getDataSize() { + return 4; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/DBCellRecord.java b/src/java/org/apache/poi/hssf/record/DBCellRecord.java index 4085027dd4..fef70667db 100644 --- a/src/java/org/apache/poi/hssf/record/DBCellRecord.java +++ b/src/java/org/apache/poi/hssf/record/DBCellRecord.java @@ -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); } /** diff --git a/src/java/org/apache/poi/hssf/record/DSFRecord.java b/src/java/org/apache/poi/hssf/record/DSFRecord.java index 9d405b3dda..3d2a753aa0 100644 --- a/src/java/org/apache/poi/hssf/record/DSFRecord.java +++ b/src/java/org/apache/poi/hssf/record/DSFRecord.java @@ -85,9 +85,8 @@ public class DSFRecord return getRecordSize(); } - public int getRecordSize() - { - return 6; + protected int getDataSize() { + return 2; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/DVALRecord.java b/src/java/org/apache/poi/hssf/record/DVALRecord.java index 9f051db6eb..69e94deacb 100644 --- a/src/java/org/apache/poi/hssf/record/DVALRecord.java +++ b/src/java/org/apache/poi/hssf/record/DVALRecord.java @@ -164,9 +164,8 @@ public class DVALRecord extends Record return getRecordSize(); } - public int getRecordSize() - { - return 22; + protected int getDataSize() { + return 18; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/DVRecord.java b/src/java/org/apache/poi/hssf/record/DVRecord.java index 4423546768..c486b190d7 100644 --- a/src/java/org/apache/poi/hssf/record/DVRecord.java +++ b/src/java/org/apache/poi/hssf/record/DVRecord.java @@ -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); diff --git a/src/java/org/apache/poi/hssf/record/DatRecord.java b/src/java/org/apache/poi/hssf/record/DatRecord.java index f93efe6226..ef8f2a53da 100644 --- a/src/java/org/apache/poi/hssf/record/DatRecord.java +++ b/src/java/org/apache/poi/hssf/record/DatRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/DataFormatRecord.java b/src/java/org/apache/poi/hssf/record/DataFormatRecord.java index b0a67aefa6..5719ab6d26 100644 --- a/src/java/org/apache/poi/hssf/record/DataFormatRecord.java +++ b/src/java/org/apache/poi/hssf/record/DataFormatRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/DateWindow1904Record.java b/src/java/org/apache/poi/hssf/record/DateWindow1904Record.java index dd023fa803..19c4992810 100644 --- a/src/java/org/apache/poi/hssf/record/DateWindow1904Record.java +++ b/src/java/org/apache/poi/hssf/record/DateWindow1904Record.java @@ -85,9 +85,8 @@ public class DateWindow1904Record return getRecordSize(); } - public int getRecordSize() - { - return 6; + protected int getDataSize() { + return 2; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/DefaultColWidthRecord.java b/src/java/org/apache/poi/hssf/record/DefaultColWidthRecord.java index 8ceb88edfa..a913dc6e76 100644 --- a/src/java/org/apache/poi/hssf/record/DefaultColWidthRecord.java +++ b/src/java/org/apache/poi/hssf/record/DefaultColWidthRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/DefaultDataLabelTextPropertiesRecord.java b/src/java/org/apache/poi/hssf/record/DefaultDataLabelTextPropertiesRecord.java index e970265f21..905616a509 100644 --- a/src/java/org/apache/poi/hssf/record/DefaultDataLabelTextPropertiesRecord.java +++ b/src/java/org/apache/poi/hssf/record/DefaultDataLabelTextPropertiesRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/DefaultRowHeightRecord.java b/src/java/org/apache/poi/hssf/record/DefaultRowHeightRecord.java index ae48ea4b00..9f0a511256 100644 --- a/src/java/org/apache/poi/hssf/record/DefaultRowHeightRecord.java +++ b/src/java/org/apache/poi/hssf/record/DefaultRowHeightRecord.java @@ -110,9 +110,8 @@ public class DefaultRowHeightRecord return getRecordSize(); } - public int getRecordSize() - { - return 8; + protected int getDataSize() { + return 4; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/DeltaRecord.java b/src/java/org/apache/poi/hssf/record/DeltaRecord.java index d02eb2cef7..8cf0df0c4a 100644 --- a/src/java/org/apache/poi/hssf/record/DeltaRecord.java +++ b/src/java/org/apache/poi/hssf/record/DeltaRecord.java @@ -88,9 +88,8 @@ public class DeltaRecord return getRecordSize(); } - public int getRecordSize() - { - return 12; + protected int getDataSize() { + return 8; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/DimensionsRecord.java b/src/java/org/apache/poi/hssf/record/DimensionsRecord.java index fa7477bc79..34422b8afc 100644 --- a/src/java/org/apache/poi/hssf/record/DimensionsRecord.java +++ b/src/java/org/apache/poi/hssf/record/DimensionsRecord.java @@ -165,9 +165,8 @@ public class DimensionsRecord return getRecordSize(); } - public int getRecordSize() - { - return 18; + protected int getDataSize() { + return 14; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java b/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java index 1f149efbb0..fb5b649a10 100644 --- a/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java +++ b/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java @@ -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) diff --git a/src/java/org/apache/poi/hssf/record/DrawingRecord.java b/src/java/org/apache/poi/hssf/record/DrawingRecord.java index c8c54123c9..b0af2c7e6e 100644 --- a/src/java/org/apache/poi/hssf/record/DrawingRecord.java +++ b/src/java/org/apache/poi/hssf/record/DrawingRecord.java @@ -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 ]; diff --git a/src/java/org/apache/poi/hssf/record/DrawingRecordForBiffViewer.java b/src/java/org/apache/poi/hssf/record/DrawingRecordForBiffViewer.java index 4e5536f309..bbbe0b3eef 100644 --- a/src/java/org/apache/poi/hssf/record/DrawingRecordForBiffViewer.java +++ b/src/java/org/apache/poi/hssf/record/DrawingRecordForBiffViewer.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/DrawingSelectionRecord.java b/src/java/org/apache/poi/hssf/record/DrawingSelectionRecord.java index 8b3af07272..687c11314b 100644 --- a/src/java/org/apache/poi/hssf/record/DrawingSelectionRecord.java +++ b/src/java/org/apache/poi/hssf/record/DrawingSelectionRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/EOFRecord.java b/src/java/org/apache/poi/hssf/record/EOFRecord.java index f7495179b4..bf9c39ba93 100644 --- a/src/java/org/apache/poi/hssf/record/EOFRecord.java +++ b/src/java/org/apache/poi/hssf/record/EOFRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/EndRecord.java b/src/java/org/apache/poi/hssf/record/EndRecord.java index 6f91dc3a24..86e336e5cf 100644 --- a/src/java/org/apache/poi/hssf/record/EndRecord.java +++ b/src/java/org/apache/poi/hssf/record/EndRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/EscherAggregate.java b/src/java/org/apache/poi/hssf/record/EscherAggregate.java index 369cf0b14f..4cec5cca4b 100644 --- a/src/java/org/apache/poi/hssf/record/EscherAggregate.java +++ b/src/java/org/apache/poi/hssf/record/EscherAggregate.java @@ -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; } /** diff --git a/src/java/org/apache/poi/hssf/record/ExtSSTInfoSubRecord.java b/src/java/org/apache/poi/hssf/record/ExtSSTInfoSubRecord.java index 278bfd7816..845f95a162 100644 --- a/src/java/org/apache/poi/hssf/record/ExtSSTInfoSubRecord.java +++ b/src/java/org/apache/poi/hssf/record/ExtSSTInfoSubRecord.java @@ -100,9 +100,8 @@ public class ExtSSTInfoSubRecord return getRecordSize(); } - public int getRecordSize() - { - return 8; + protected int getDataSize() { + return 4; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/ExtSSTRecord.java b/src/java/org/apache/poi/hssf/record/ExtSSTRecord.java index 14a849de56..8225f6b76d 100644 --- a/src/java/org/apache/poi/hssf/record/ExtSSTRecord.java +++ b/src/java/org/apache/poi/hssf/record/ExtSSTRecord.java @@ -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

@@ -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) { diff --git a/src/java/org/apache/poi/hssf/record/ExtendedFormatRecord.java b/src/java/org/apache/poi/hssf/record/ExtendedFormatRecord.java index 0bc50ca89e..9d33854520 100644 --- a/src/java/org/apache/poi/hssf/record/ExtendedFormatRecord.java +++ b/src/java/org/apache/poi/hssf/record/ExtendedFormatRecord.java @@ -1787,9 +1787,8 @@ public class ExtendedFormatRecord return getRecordSize(); } - public int getRecordSize() - { - return 24; + protected int getDataSize() { + return 20; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/ExternSheetRecord.java b/src/java/org/apache/poi/hssf/record/ExternSheetRecord.java index baa136c231..cbb287ed15 100644 --- a/src/java/org/apache/poi/hssf/record/ExternSheetRecord.java +++ b/src/java/org/apache/poi/hssf/record/ExternSheetRecord.java @@ -188,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. */ diff --git a/src/java/org/apache/poi/hssf/record/ExternalNameRecord.java b/src/java/org/apache/poi/hssf/record/ExternalNameRecord.java index eb597aeb29..73de9f0bed 100755 --- a/src/java/org/apache/poi/hssf/record/ExternalNameRecord.java +++ b/src/java/org/apache/poi/hssf/record/ExternalNameRecord.java @@ -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(); diff --git a/src/java/org/apache/poi/hssf/record/FilePassRecord.java b/src/java/org/apache/poi/hssf/record/FilePassRecord.java index 3af87278e2..7068874ec6 100644 --- a/src/java/org/apache/poi/hssf/record/FilePassRecord.java +++ b/src/java/org/apache/poi/hssf/record/FilePassRecord.java @@ -68,9 +68,8 @@ public class FilePassRecord return getRecordSize(); } - public int getRecordSize() - { - return 8; + protected int getDataSize() { + return 4; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/FileSharingRecord.java b/src/java/org/apache/poi/hssf/record/FileSharingRecord.java index 3631251995..54d94d9f83 100644 --- a/src/java/org/apache/poi/hssf/record/FileSharingRecord.java +++ b/src/java/org/apache/poi/hssf/record/FileSharingRecord.java @@ -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() { diff --git a/src/java/org/apache/poi/hssf/record/FnGroupCountRecord.java b/src/java/org/apache/poi/hssf/record/FnGroupCountRecord.java index 23de9135af..e92623a3e3 100644 --- a/src/java/org/apache/poi/hssf/record/FnGroupCountRecord.java +++ b/src/java/org/apache/poi/hssf/record/FnGroupCountRecord.java @@ -93,9 +93,8 @@ public class FnGroupCountRecord return getRecordSize(); } - public int getRecordSize() - { - return 6; + protected int getDataSize() { + return 2; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/FontBasisRecord.java b/src/java/org/apache/poi/hssf/record/FontBasisRecord.java index 452a8f9ae4..cbe2ae4fa7 100644 --- a/src/java/org/apache/poi/hssf/record/FontBasisRecord.java +++ b/src/java/org/apache/poi/hssf/record/FontBasisRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/FontIndexRecord.java b/src/java/org/apache/poi/hssf/record/FontIndexRecord.java index 241753bacc..a1ade938ff 100644 --- a/src/java/org/apache/poi/hssf/record/FontIndexRecord.java +++ b/src/java/org/apache/poi/hssf/record/FontIndexRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/FontRecord.java b/src/java/org/apache/poi/hssf/record/FontRecord.java index e1d4219774..890460f9e7 100644 --- a/src/java/org/apache/poi/hssf/record/FontRecord.java +++ b/src/java/org/apache/poi/hssf/record/FontRecord.java @@ -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

* REFERENCE: PG 315 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @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() diff --git a/src/java/org/apache/poi/hssf/record/FooterRecord.java b/src/java/org/apache/poi/hssf/record/FooterRecord.java index 8434792172..0350d3a8cd 100644 --- a/src/java/org/apache/poi/hssf/record/FooterRecord.java +++ b/src/java/org/apache/poi/hssf/record/FooterRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/FormatRecord.java b/src/java/org/apache/poi/hssf/record/FormatRecord.java index b8f4ea22ad..6ea2ce9632 100644 --- a/src/java/org/apache/poi/hssf/record/FormatRecord.java +++ b/src/java/org/apache/poi/hssf/record/FormatRecord.java @@ -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)

* @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() diff --git a/src/java/org/apache/poi/hssf/record/FormulaRecord.java b/src/java/org/apache/poi/hssf/record/FormulaRecord.java index 8c47811966..4e4edcc9a6 100644 --- a/src/java/org/apache/poi/hssf/record/FormulaRecord.java +++ b/src/java/org/apache/poi/hssf/record/FormulaRecord.java @@ -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(); diff --git a/src/java/org/apache/poi/hssf/record/FrameRecord.java b/src/java/org/apache/poi/hssf/record/FrameRecord.java index 357728a0e2..65fcc67d1e 100644 --- a/src/java/org/apache/poi/hssf/record/FrameRecord.java +++ b/src/java/org/apache/poi/hssf/record/FrameRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/GridsetRecord.java b/src/java/org/apache/poi/hssf/record/GridsetRecord.java index ad652ba824..8bf52768e0 100644 --- a/src/java/org/apache/poi/hssf/record/GridsetRecord.java +++ b/src/java/org/apache/poi/hssf/record/GridsetRecord.java @@ -97,9 +97,8 @@ public class GridsetRecord return getRecordSize(); } - public int getRecordSize() - { - return 6; + protected int getDataSize() { + return 2; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/GutsRecord.java b/src/java/org/apache/poi/hssf/record/GutsRecord.java index 0073066ec1..2bc576f26c 100644 --- a/src/java/org/apache/poi/hssf/record/GutsRecord.java +++ b/src/java/org/apache/poi/hssf/record/GutsRecord.java @@ -167,9 +167,8 @@ public class GutsRecord return getRecordSize(); } - public int getRecordSize() - { - return 12; + protected int getDataSize() { + return 8; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/HCenterRecord.java b/src/java/org/apache/poi/hssf/record/HCenterRecord.java index 261431e716..41708a3f2b 100644 --- a/src/java/org/apache/poi/hssf/record/HCenterRecord.java +++ b/src/java/org/apache/poi/hssf/record/HCenterRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/HeaderRecord.java b/src/java/org/apache/poi/hssf/record/HeaderRecord.java index 61ff851306..aea321eaca 100644 --- a/src/java/org/apache/poi/hssf/record/HeaderRecord.java +++ b/src/java/org/apache/poi/hssf/record/HeaderRecord.java @@ -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() diff --git a/src/java/org/apache/poi/hssf/record/HideObjRecord.java b/src/java/org/apache/poi/hssf/record/HideObjRecord.java index 496002618a..c5c5876263 100644 --- a/src/java/org/apache/poi/hssf/record/HideObjRecord.java +++ b/src/java/org/apache/poi/hssf/record/HideObjRecord.java @@ -95,9 +95,8 @@ public class HideObjRecord return getRecordSize(); } - public int getRecordSize() - { - return 6; + protected int getDataSize() { + return 2; } public short getSid() diff --git a/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java b/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java index 6fc5b97163..f7904a1002 100644 --- a/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java +++ b/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java @@ -31,7 +31,7 @@ import org.apache.poi.util.HexDump; * @author Mark Hissink Muller