aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJosh Micich <josh@apache.org>2008-10-31 18:37:16 +0000
committerJosh Micich <josh@apache.org>2008-10-31 18:37:16 +0000
commit75e352f2a073bdda52a2e3c30df63be6c71ff61d (patch)
tree2a23b0650c1d81060f73d320ddbb5ffc217da5d2 /src
parent0f60f5eba5bfff80c34df7db0a42d9a457dbbc35 (diff)
downloadpoi-75e352f2a073bdda52a2e3c30df63be6c71ff61d.tar.gz
poi-75e352f2a073bdda52a2e3c30df63be6c71ff61d.zip
Merged revisions 709263-709264,709317 via svnmerge from
https://svn.apache.org/repos/asf/poi/trunk ........ r709263 | josh | 2008-10-30 15:07:26 -0700 (Thu, 30 Oct 2008) | 1 line Removed dodgy superlcass implementation of Record.getRecordSize() ........ r709264 | josh | 2008-10-30 15:13:56 -0700 (Thu, 30 Oct 2008) | 1 line Introduced Record.getDataSize() method ........ r709317 | josh | 2008-10-30 18:02:55 -0700 (Thu, 30 Oct 2008) | 1 line converted getRecordSize methods to getDataSize ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@709526 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/DummyRecordBase.java40
-rw-r--r--src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/LastCellOfRowDummyRecord.java10
-rw-r--r--src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/MissingCellDummyRecord.java11
-rw-r--r--src/java/org/apache/poi/hssf/eventusermodel/dummyrecord/MissingRowDummyRecord.java12
-rw-r--r--src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java46
-rw-r--r--src/java/org/apache/poi/hssf/record/AreaFormatRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/AreaRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/AxisLineFormatRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/AxisOptionsRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/AxisParentRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/AxisRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/AxisUsedRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/BOFRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/BackupRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/BarRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/BeginRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/BlankRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/BookBoolRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/BoolErrRecord.java7
-rw-r--r--src/java/org/apache/poi/hssf/record/BottomMarginRecord.java7
-rw-r--r--src/java/org/apache/poi/hssf/record/BoundSheetRecord.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/CFHeaderRecord.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/CFRuleRecord.java7
-rwxr-xr-xsrc/java/org/apache/poi/hssf/record/CRNCountRecord.java9
-rwxr-xr-xsrc/java/org/apache/poi/hssf/record/CRNRecord.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/CalcCountRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/CalcModeRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/CategorySeriesAxisRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/ChartFormatRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/ChartRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/ChartTitleFormatRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/CodepageRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/ColumnInfoRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/ContinueRecord.java14
-rw-r--r--src/java/org/apache/poi/hssf/record/CountryRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/DBCellRecord.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/DSFRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/DVALRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/DVRecord.java4
-rw-r--r--src/java/org/apache/poi/hssf/record/DatRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/DataFormatRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/DateWindow1904Record.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/DefaultColWidthRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/DefaultDataLabelTextPropertiesRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/DefaultRowHeightRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/DeltaRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/DimensionsRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java26
-rw-r--r--src/java/org/apache/poi/hssf/record/DrawingRecord.java27
-rw-r--r--src/java/org/apache/poi/hssf/record/DrawingRecordForBiffViewer.java4
-rw-r--r--src/java/org/apache/poi/hssf/record/DrawingSelectionRecord.java3
-rw-r--r--src/java/org/apache/poi/hssf/record/EOFRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/EndRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/EscherAggregate.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/ExtSSTInfoSubRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/ExtSSTRecord.java24
-rw-r--r--src/java/org/apache/poi/hssf/record/ExtendedFormatRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/ExternSheetRecord.java7
-rwxr-xr-xsrc/java/org/apache/poi/hssf/record/ExternalNameRecord.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/FilePassRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/FileSharingRecord.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/FnGroupCountRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/FontBasisRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/FontIndexRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/FontRecord.java17
-rw-r--r--src/java/org/apache/poi/hssf/record/FooterRecord.java11
-rw-r--r--src/java/org/apache/poi/hssf/record/FormatRecord.java16
-rw-r--r--src/java/org/apache/poi/hssf/record/FormulaRecord.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/FrameRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/GridsetRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/GutsRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/HCenterRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/HeaderRecord.java21
-rw-r--r--src/java/org/apache/poi/hssf/record/HideObjRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/HyperlinkRecord.java7
-rw-r--r--src/java/org/apache/poi/hssf/record/IndexRecord.java15
-rw-r--r--src/java/org/apache/poi/hssf/record/InterfaceEndRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/InterfaceHdrRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/IterationRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/LabelRecord.java9
-rw-r--r--src/java/org/apache/poi/hssf/record/LabelSSTRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/LeftMarginRecord.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/LegendRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/LineFormatRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/LinkedDataRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/MMSRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/MergeCellsRecord.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/MulBlankRecord.java72
-rw-r--r--src/java/org/apache/poi/hssf/record/MulRKRecord.java9
-rw-r--r--src/java/org/apache/poi/hssf/record/NameRecord.java7
-rw-r--r--src/java/org/apache/poi/hssf/record/NoteRecord.java13
-rw-r--r--src/java/org/apache/poi/hssf/record/NumberFormatIndexRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/NumberRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/ObjRecord.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/ObjectLinkRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/ObjectProtectRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/PageBreakRecord.java17
-rw-r--r--src/java/org/apache/poi/hssf/record/PaletteRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/PaneRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/PasswordRecord.java4
-rw-r--r--src/java/org/apache/poi/hssf/record/PasswordRev4Record.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/PlotAreaRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/PlotGrowthRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/PrecisionRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/PrintGridlinesRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/PrintSetupRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/ProtectRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/ProtectionRev4Record.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/RKRecord.java49
-rw-r--r--src/java/org/apache/poi/hssf/record/RecalcIdRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/Record.java23
-rw-r--r--src/java/org/apache/poi/hssf/record/RefModeRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/RefreshAllRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/RightMarginRecord.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/RowRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/SCLRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/SSTRecord.java15
-rw-r--r--src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/ScenarioProtectRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/SelectionRecord.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/SeriesChartGroupIndexRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/SeriesIndexRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/SeriesLabelsRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/SeriesListRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/SeriesRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/SeriesTextRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/SeriesToChartGroupRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/SharedValueRecordBase.java4
-rw-r--r--src/java/org/apache/poi/hssf/record/SheetPropertiesRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/StringRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/StyleRecord.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/SupBookRecord.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/TabIdRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/TextObjectRecord.java10
-rw-r--r--src/java/org/apache/poi/hssf/record/TextRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/TickRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/TopMarginRecord.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/UncalcedRecord.java13
-rw-r--r--src/java/org/apache/poi/hssf/record/UnitsRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/UnknownRecord.java4
-rw-r--r--src/java/org/apache/poi/hssf/record/UseSelFSRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/VCenterRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/ValueRangeRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/WSBoolRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/WindowOneRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/WindowProtectRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/WindowTwoRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/WriteAccessRecord.java4
-rw-r--r--src/java/org/apache/poi/hssf/record/WriteProtectRecord.java5
-rw-r--r--src/java/org/apache/poi/hssf/record/aggregates/PageSettingsBlock.java9
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java5
-rw-r--r--src/testcases/org/apache/poi/hssf/util/TestRKUtil.java48
153 files changed, 468 insertions, 768 deletions
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 670fa99d2a..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,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;
- }
}
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 587ccb6596..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,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; }
}
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 46f76b1d34..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,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;
}
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 5595c4f0dd..e0eb26d523 100644
--- a/src/java/org/apache/poi/hssf/record/BoolErrRecord.java
+++ b/src/java/org/apache/poi/hssf/record/BoolErrRecord.java
@@ -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()
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 036de6b2df..17d337f823 100644
--- a/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java
+++ b/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java
@@ -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;
}
diff --git a/src/java/org/apache/poi/hssf/record/CFHeaderRecord.java b/src/java/org/apache/poi/hssf/record/CFHeaderRecord.java
index 762af3be79..2be58b0d90 100644
--- a/src/java/org/apache/poi/hssf/record/CFHeaderRecord.java
+++ b/src/java/org/apache/poi/hssf/record/CFHeaderRecord.java
@@ -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;
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 050076cca2..58be686ad5 100755
--- a/src/java/org/apache/poi/hssf/record/CRNRecord.java
+++ b/src/java/org/apache/poi/hssf/record/CRNRecord.java
@@ -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.
*/
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 e20c4633c3..bed97a4098 100644
--- a/src/java/org/apache/poi/hssf/record/ContinueRecord.java
+++ b/src/java/org/apache/poi/hssf/record/ContinueRecord.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;
@@ -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) {
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 c2c0c1f6e9..c552a39f20 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<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) {
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 f6266cfa35..cbb287ed15 100644
--- a/src/java/org/apache/poi/hssf/record/ExternSheetRecord.java
+++ b/src/java/org/apache/poi/hssf/record/ExternSheetRecord.java
@@ -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.
*/
diff --git a/src/java/org/apache/poi/hssf/record/ExternalNameRecord.java b/src/java/org/apache/poi/hssf/record/ExternalNameRecord.java
index a3dfe575c1..73de9f0bed 100755
--- a/src/java/org/apache/poi/hssf/record/ExternalNameRecord.java
+++ b/src/java/org/apache/poi/hssf/record/ExternalNameRecord.java
@@ -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();
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<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()
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)<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()
diff --git a/src/java/org/apache/poi/hssf/record/FormulaRecord.java b/src/java/org/apache/poi/hssf/record/FormulaRecord.java
index e51ed77a96..4e4edcc9a6 100644
--- a/src/java/org/apache/poi/hssf/record/FormulaRecord.java
+++ b/src/java/org/apache/poi/hssf/record/FormulaRecord.java
@@ -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();
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 <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
diff --git a/src/java/org/apache/poi/hssf/record/IndexRecord.java b/src/java/org/apache/poi/hssf/record/IndexRecord.java
index c7c3cfbb5a..650d1258c8 100644
--- a/src/java/org/apache/poi/hssf/record/IndexRecord.java
+++ b/src/java/org/apache/poi/hssf/record/IndexRecord.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;
@@ -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
diff --git a/src/java/org/apache/poi/hssf/record/InterfaceEndRecord.java b/src/java/org/apache/poi/hssf/record/InterfaceEndRecord.java
index 2a9de8e563..5f9d8955b2 100644
--- a/src/java/org/apache/poi/hssf/record/InterfaceEndRecord.java
+++ b/src/java/org/apache/poi/hssf/record/InterfaceEndRecord.java
@@ -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()
diff --git a/src/java/org/apache/poi/hssf/record/InterfaceHdrRecord.java b/src/java/org/apache/poi/hssf/record/InterfaceHdrRecord.java
index 617e95855f..592a87b892 100644
--- a/src/java/org/apache/poi/hssf/record/InterfaceHdrRecord.java
+++ b/src/java/org/apache/poi/hssf/record/InterfaceHdrRecord.java
@@ -94,9 +94,8 @@ public class InterfaceHdrRecord
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/IterationRecord.java b/src/java/org/apache/poi/hssf/record/IterationRecord.java
index 400ee0a8c5..f9efca7929 100644
--- a/src/java/org/apache/poi/hssf/record/IterationRecord.java
+++ b/src/java/org/apache/poi/hssf/record/IterationRecord.java
@@ -95,9 +95,8 @@ public class IterationRecord
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/LabelRecord.java b/src/java/org/apache/poi/hssf/record/LabelRecord.java
index f4bbfb85da..95659e8aff 100644
--- a/src/java/org/apache/poi/hssf/record/LabelRecord.java
+++ b/src/java/org/apache/poi/hssf/record/LabelRecord.java
@@ -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()
diff --git a/src/java/org/apache/poi/hssf/record/LabelSSTRecord.java b/src/java/org/apache/poi/hssf/record/LabelSSTRecord.java
index f2eae83deb..93d849b4ec 100644
--- a/src/java/org/apache/poi/hssf/record/LabelSSTRecord.java
+++ b/src/java/org/apache/poi/hssf/record/LabelSSTRecord.java
@@ -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()
diff --git a/src/java/org/apache/poi/hssf/record/LeftMarginRecord.java b/src/java/org/apache/poi/hssf/record/LeftMarginRecord.java
index 1a07530866..7615b0d875 100644
--- a/src/java/org/apache/poi/hssf/record/LeftMarginRecord.java
+++ b/src/java/org/apache/poi/hssf/record/LeftMarginRecord.java
@@ -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 \ 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/LegendRecord.java b/src/java/org/apache/poi/hssf/record/LegendRecord.java
index d4351b72a0..cdd0becf98 100644
--- a/src/java/org/apache/poi/hssf/record/LegendRecord.java
+++ b/src/java/org/apache/poi/hssf/record/LegendRecord.java
@@ -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()
diff --git a/src/java/org/apache/poi/hssf/record/LineFormatRecord.java b/src/java/org/apache/poi/hssf/record/LineFormatRecord.java
index 78142a17ca..da6264f361 100644
--- a/src/java/org/apache/poi/hssf/record/LineFormatRecord.java
+++ b/src/java/org/apache/poi/hssf/record/LineFormatRecord.java
@@ -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()
diff --git a/src/java/org/apache/poi/hssf/record/LinkedDataRecord.java b/src/java/org/apache/poi/hssf/record/LinkedDataRecord.java
index 543418c353..fe5b9002c7 100644
--- a/src/java/org/apache/poi/hssf/record/LinkedDataRecord.java
+++ b/src/java/org/apache/poi/hssf/record/LinkedDataRecord.java
@@ -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()
diff --git a/src/java/org/apache/poi/hssf/record/MMSRecord.java b/src/java/org/apache/poi/hssf/record/MMSRecord.java
index c11e2d510d..0c5564d97b 100644
--- a/src/java/org/apache/poi/hssf/record/MMSRecord.java
+++ b/src/java/org/apache/poi/hssf/record/MMSRecord.java
@@ -110,9 +110,8 @@ public class MMSRecord
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/MergeCellsRecord.java b/src/java/org/apache/poi/hssf/record/MergeCellsRecord.java
index 1b917a7fce..5ecce79aa8 100644
--- a/src/java/org/apache/poi/hssf/record/MergeCellsRecord.java
+++ b/src/java/org/apache/poi/hssf/record/MergeCellsRecord.java
@@ -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;
diff --git a/src/java/org/apache/poi/hssf/record/MulBlankRecord.java b/src/java/org/apache/poi/hssf/record/MulBlankRecord.java
index 8d461fe975..6ecaa20f97 100644
--- a/src/java/org/apache/poi/hssf/record/MulBlankRecord.java
+++ b/src/java/org/apache/poi/hssf/record/MulBlankRecord.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,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");
}
}
diff --git a/src/java/org/apache/poi/hssf/record/MulRKRecord.java b/src/java/org/apache/poi/hssf/record/MulRKRecord.java
index 0419f4921d..dbb41c10f0 100644
--- a/src/java/org/apache/poi/hssf/record/MulRKRecord.java
+++ b/src/java/org/apache/poi/hssf/record/MulRKRecord.java
@@ -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 {
diff --git a/src/java/org/apache/poi/hssf/record/NameRecord.java b/src/java/org/apache/poi/hssf/record/NameRecord.java
index 99e2cddd70..f27fb2d883 100644
--- a/src/java/org/apache/poi/hssf/record/NameRecord.java
+++ b/src/java/org/apache/poi/hssf/record/NameRecord.java
@@ -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()
diff --git a/src/java/org/apache/poi/hssf/record/NoteRecord.java b/src/java/org/apache/poi/hssf/record/NoteRecord.java
index 1a82d56e9d..2888614f42 100644
--- a/src/java/org/apache/poi/hssf/record/NoteRecord.java
+++ b/src/java/org/apache/poi/hssf/record/NoteRecord.java
@@ -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()
{
diff --git a/src/java/org/apache/poi/hssf/record/NumberFormatIndexRecord.java b/src/java/org/apache/poi/hssf/record/NumberFormatIndexRecord.java
index 3f35184ebf..f00f47696a 100644
--- a/src/java/org/apache/poi/hssf/record/NumberFormatIndexRecord.java
+++ b/src/java/org/apache/poi/hssf/record/NumberFormatIndexRecord.java
@@ -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()
diff --git a/src/java/org/apache/poi/hssf/record/NumberRecord.java b/src/java/org/apache/poi/hssf/record/NumberRecord.java
index e4283f0eac..a0c55c6e42 100644
--- a/src/java/org/apache/poi/hssf/record/NumberRecord.java
+++ b/src/java/org/apache/poi/hssf/record/NumberRecord.java
@@ -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()
diff --git a/src/java/org/apache/poi/hssf/record/ObjRecord.java b/src/java/org/apache/poi/hssf/record/ObjRecord.java
index 538b1ae9f1..6addf41eba 100644
--- a/src/java/org/apache/poi/hssf/record/ObjRecord.java
+++ b/src/java/org/apache/poi/hssf/record/ObjRecord.java
@@ -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;
}
diff --git a/src/java/org/apache/poi/hssf/record/ObjectLinkRecord.java b/src/java/org/apache/poi/hssf/record/ObjectLinkRecord.java
index 95fc5ff7f5..b5a78b860d 100644
--- a/src/java/org/apache/poi/hssf/record/ObjectLinkRecord.java
+++ b/src/java/org/apache/poi/hssf/record/ObjectLinkRecord.java
@@ -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()
diff --git a/src/java/org/apache/poi/hssf/record/ObjectProtectRecord.java b/src/java/org/apache/poi/hssf/record/ObjectProtectRecord.java
index cdbb56d873..f0141424ac 100644
--- a/src/java/org/apache/poi/hssf/record/ObjectProtectRecord.java
+++ b/src/java/org/apache/poi/hssf/record/ObjectProtectRecord.java
@@ -93,9 +93,8 @@ public class ObjectProtectRecord
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/PageBreakRecord.java b/src/java/org/apache/poi/hssf/record/PageBreakRecord.java
index 654439f316..a3717f40e0 100644
--- a/src/java/org/apache/poi/hssf/record/PageBreakRecord.java
+++ b/src/java/org/apache/poi/hssf/record/PageBreakRecord.java
@@ -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);
diff --git a/src/java/org/apache/poi/hssf/record/PaletteRecord.java b/src/java/org/apache/poi/hssf/record/PaletteRecord.java
index 0cf7856361..75a13f6ad3 100644
--- a/src/java/org/apache/poi/hssf/record/PaletteRecord.java
+++ b/src/java/org/apache/poi/hssf/record/PaletteRecord.java
@@ -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()
diff --git a/src/java/org/apache/poi/hssf/record/PaneRecord.java b/src/java/org/apache/poi/hssf/record/PaneRecord.java
index f02e517a31..7b16ec442f 100644
--- a/src/java/org/apache/poi/hssf/record/PaneRecord.java
+++ b/src/java/org/apache/poi/hssf/record/PaneRecord.java
@@ -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()
diff --git a/src/java/org/apache/poi/hssf/record/PasswordRecord.java b/src/java/org/apache/poi/hssf/record/PasswordRecord.java
index b7b9d075ab..ff6445ca85 100644
--- a/src/java/org/apache/poi/hssf/record/PasswordRecord.java
+++ b/src/java/org/apache/poi/hssf/record/PasswordRecord.java
@@ -96,8 +96,8 @@ public class PasswordRecord 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/PasswordRev4Record.java b/src/java/org/apache/poi/hssf/record/PasswordRev4Record.java
index 5c5567a86b..7538872fdf 100644
--- a/src/java/org/apache/poi/hssf/record/PasswordRev4Record.java
+++ b/src/java/org/apache/poi/hssf/record/PasswordRev4Record.java
@@ -87,9 +87,8 @@ public class PasswordRev4Record
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/PlotAreaRecord.java b/src/java/org/apache/poi/hssf/record/PlotAreaRecord.java
index 1a50441ff9..d0bba5e673 100644
--- a/src/java/org/apache/poi/hssf/record/PlotAreaRecord.java
+++ b/src/java/org/apache/poi/hssf/record/PlotAreaRecord.java
@@ -60,9 +60,8 @@ public final class PlotAreaRecord 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/PlotGrowthRecord.java b/src/java/org/apache/poi/hssf/record/PlotGrowthRecord.java
index 04a1240809..03cf58a357 100644
--- a/src/java/org/apache/poi/hssf/record/PlotGrowthRecord.java
+++ b/src/java/org/apache/poi/hssf/record/PlotGrowthRecord.java
@@ -74,9 +74,8 @@ public final class PlotGrowthRecord extends Record {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 4 + 4;
+ protected int getDataSize() {
+ return 4 + 4;
}
public short getSid()
diff --git a/src/java/org/apache/poi/hssf/record/PrecisionRecord.java b/src/java/org/apache/poi/hssf/record/PrecisionRecord.java
index a147cfff18..56bb8cbd97 100644
--- a/src/java/org/apache/poi/hssf/record/PrecisionRecord.java
+++ b/src/java/org/apache/poi/hssf/record/PrecisionRecord.java
@@ -94,9 +94,8 @@ public class PrecisionRecord
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/PrintGridlinesRecord.java b/src/java/org/apache/poi/hssf/record/PrintGridlinesRecord.java
index 7b4de7c68e..1ddaed715a 100644
--- a/src/java/org/apache/poi/hssf/record/PrintGridlinesRecord.java
+++ b/src/java/org/apache/poi/hssf/record/PrintGridlinesRecord.java
@@ -93,9 +93,8 @@ public class PrintGridlinesRecord
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/PrintHeadersRecord.java b/src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java
index 61c1cce86e..5f63a5eba6 100644
--- a/src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java
+++ b/src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java
@@ -92,9 +92,8 @@ public class PrintHeadersRecord
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/PrintSetupRecord.java b/src/java/org/apache/poi/hssf/record/PrintSetupRecord.java
index e41f278d54..136fc03f16 100644
--- a/src/java/org/apache/poi/hssf/record/PrintSetupRecord.java
+++ b/src/java/org/apache/poi/hssf/record/PrintSetupRecord.java
@@ -340,9 +340,8 @@ public class PrintSetupRecord extends Record {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 38;
+ protected int getDataSize() {
+ return 34;
}
public short getSid()
diff --git a/src/java/org/apache/poi/hssf/record/ProtectRecord.java b/src/java/org/apache/poi/hssf/record/ProtectRecord.java
index d5425c5523..a0b6bf4889 100644
--- a/src/java/org/apache/poi/hssf/record/ProtectRecord.java
+++ b/src/java/org/apache/poi/hssf/record/ProtectRecord.java
@@ -94,9 +94,8 @@ public class ProtectRecord
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/ProtectionRev4Record.java b/src/java/org/apache/poi/hssf/record/ProtectionRev4Record.java
index b7d2f4323f..ae86f77628 100644
--- a/src/java/org/apache/poi/hssf/record/ProtectionRev4Record.java
+++ b/src/java/org/apache/poi/hssf/record/ProtectionRev4Record.java
@@ -92,9 +92,8 @@ public class ProtectionRev4Record
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/RKRecord.java b/src/java/org/apache/poi/hssf/record/RKRecord.java
index c4b25a5bea..48a8c564f5 100644
--- a/src/java/org/apache/poi/hssf/record/RKRecord.java
+++ b/src/java/org/apache/poi/hssf/record/RKRecord.java
@@ -34,7 +34,6 @@ import org.apache.poi.util.HexDump;
* REFERENCE: PG 376 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
* @author Andrew C. Oliver (acoliver at apache dot org)
* @author Jason Height (jheight at chariot dot net dot au)
- * @version 2.0-pre
* @see org.apache.poi.hssf.record.NumberRecord
*/
public final class RKRecord extends Record implements CellValueRecordInterface {
@@ -134,48 +133,12 @@ public final class RKRecord extends Record implements CellValueRecordInterface {
return sb.toString();
}
-// temporarily just constructs a new number record and returns its value
- public int serialize(int offset, byte [] data)
- {
- NumberRecord rec = new NumberRecord();
-
- rec.setColumn(getColumn());
- rec.setRow(getRow());
- rec.setValue(getRKNumber());
- rec.setXFIndex(getXFIndex());
- return rec.serialize(offset, data);
- }
-
- /**
- * Debugging main()
- * <P>
- * Normally I'd do this in a junit test, but let's face it -- once
- * this algorithm has been tested and it works, we are never ever
- * going to change it. This is driven by the Faceless Enemy's
- * minions, who dare not change the algorithm out from under us.
- *
- * @param ignored_args command line arguments, which we blithely
- * ignore
- */
-
- public static void main(String ignored_args[])
- {
- int[] values =
- {
- 0x3FF00000, 0x405EC001, 0x02F1853A, 0x02F1853B, 0xFCDD699A
- };
- double[] rvalues =
- {
- 1, 1.23, 12345678, 123456.78, -13149594
- };
-
- for (int j = 0; j < values.length; j++)
- {
- System.out.println("input = " + Integer.toHexString(values[ j ])
- + " -> " + rvalues[ j ] + ": "
- + RKUtil.decodeNumber(values[ j ]));
- }
- }
+ public int serialize(int offset, byte [] data) {
+ throw new RecordFormatException( "Sorry, you can't serialize RK in this release");
+ }
+ protected int getDataSize() {
+ throw new RecordFormatException( "Sorry, you can't serialize RK in this release");
+ }
public short getSid()
{
diff --git a/src/java/org/apache/poi/hssf/record/RecalcIdRecord.java b/src/java/org/apache/poi/hssf/record/RecalcIdRecord.java
index c0cab053c9..d66e31089b 100644
--- a/src/java/org/apache/poi/hssf/record/RecalcIdRecord.java
+++ b/src/java/org/apache/poi/hssf/record/RecalcIdRecord.java
@@ -116,9 +116,8 @@ public final class RecalcIdRecord extends Record {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + (getRecalcIdArray().length * 2);
+ protected int getDataSize() {
+ return (getRecalcIdArray().length * 2);
}
public short getSid()
diff --git a/src/java/org/apache/poi/hssf/record/Record.java b/src/java/org/apache/poi/hssf/record/Record.java
index 29c37d7047..5b42e5fcbc 100644
--- a/src/java/org/apache/poi/hssf/record/Record.java
+++ b/src/java/org/apache/poi/hssf/record/Record.java
@@ -28,7 +28,6 @@ import java.io.ByteArrayInputStream;
* @author Andrew C. Oliver
* @author Marc Johnson (mjohnson at apache dot org)
* @author Jason Height (jheight at chariot dot net dot au)
- * @version 2.0-pre
*/
public abstract class Record extends RecordBase {
@@ -48,31 +47,25 @@ public abstract class Record extends RecordBase {
* @return byte array containing instance data
*/
- public byte [] serialize()
- {
+ public final byte[] serialize() {
byte[] retval = new byte[ getRecordSize() ];
serialize(0, retval);
return retval;
}
-
+ public final int getRecordSize() {
+ return 4 + getDataSize();
+ }
/**
- * gives the current serialized size of the record. Should include the sid and reclength (4 bytes).
+ * @return the size of the data portion of this record
+ * (does not include initial 4 bytes for sid and size)
*/
-
- public int getRecordSize()
- {
-
- // this is kind od a stupid way to do it but for now we just serialize
- // the record and return the size of the byte array
- return serialize().length;
- }
-
+ protected abstract int getDataSize();
+
/**
* get a string representation of the record (for biffview/debugging)
*/
-
public String toString()
{
return super.toString();
diff --git a/src/java/org/apache/poi/hssf/record/RefModeRecord.java b/src/java/org/apache/poi/hssf/record/RefModeRecord.java
index f0567509bf..0f20d6ae1b 100644
--- a/src/java/org/apache/poi/hssf/record/RefModeRecord.java
+++ b/src/java/org/apache/poi/hssf/record/RefModeRecord.java
@@ -91,9 +91,8 @@ public class RefModeRecord
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/RefreshAllRecord.java b/src/java/org/apache/poi/hssf/record/RefreshAllRecord.java
index 021a34c69b..41277e6172 100644
--- a/src/java/org/apache/poi/hssf/record/RefreshAllRecord.java
+++ b/src/java/org/apache/poi/hssf/record/RefreshAllRecord.java
@@ -92,9 +92,8 @@ public class RefreshAllRecord
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/RightMarginRecord.java b/src/java/org/apache/poi/hssf/record/RightMarginRecord.java
index 32fb7c8a48..2a4994bd6b 100644
--- a/src/java/org/apache/poi/hssf/record/RightMarginRecord.java
+++ b/src/java/org/apache/poi/hssf/record/RightMarginRecord.java
@@ -52,7 +52,9 @@ public final class RightMarginRecord extends Record implements Margin {
return getRecordSize();
}
- public int getRecordSize() { return 4 + 8; }
+ protected int getDataSize() {
+ return 8;
+ }
public short getSid() { return sid; }
@@ -73,4 +75,4 @@ public final class RightMarginRecord extends Record implements Margin {
rec.field_1_margin = this.field_1_margin;
return rec;
}
-} // END OF CL \ No newline at end of file
+} // END OF \ No newline at end of file
diff --git a/src/java/org/apache/poi/hssf/record/RowRecord.java b/src/java/org/apache/poi/hssf/record/RowRecord.java
index f893bf2831..25adc67f5a 100644
--- a/src/java/org/apache/poi/hssf/record/RowRecord.java
+++ b/src/java/org/apache/poi/hssf/record/RowRecord.java
@@ -351,9 +351,8 @@ public final class RowRecord extends Record {
return ENCODED_SIZE;
}
- 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/SCLRecord.java b/src/java/org/apache/poi/hssf/record/SCLRecord.java
index 09093af6c6..0b30d32e03 100644
--- a/src/java/org/apache/poi/hssf/record/SCLRecord.java
+++ b/src/java/org/apache/poi/hssf/record/SCLRecord.java
@@ -74,9 +74,8 @@ public final class SCLRecord 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/SSTRecord.java b/src/java/org/apache/poi/hssf/record/SSTRecord.java
index ca75af00d4..7c56d955ec 100644
--- a/src/java/org/apache/poi/hssf/record/SSTRecord.java
+++ b/src/java/org/apache/poi/hssf/record/SSTRecord.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;
@@ -39,10 +37,8 @@ import java.util.Iterator;
* @see org.apache.poi.hssf.record.LabelSSTRecord
* @see org.apache.poi.hssf.record.ContinueRecord
*/
-
-public class SSTRecord
- extends Record
-{
+public final class SSTRecord extends Record {
+ public static final short sid = 0x00FC;
private static UnicodeString EMPTY_STRING = new UnicodeString("");
@@ -63,8 +59,6 @@ public class SSTRecord
/** overhead for each string includes the string's character count (a short) and the flag describing its characteristics (a byte) */
static final int STRING_MINIMAL_OVERHEAD = LittleEndianConsts.SHORT_SIZE + LittleEndianConsts.BYTE_SIZE;
- public static final short sid = 0xfc;
-
/** union of strings in the SST and EXTSST */
private int field_1_num_strings;
@@ -375,11 +369,10 @@ public class SSTRecord
}
- public int getRecordSize()
- {
+ protected int getDataSize() {
SSTRecordSizeCalculator calculator = new SSTRecordSizeCalculator(field_3_strings);
int recordSize = calculator.getRecordSize();
- return recordSize;
+ return recordSize-4;
}
SSTDeserializer getDeserializer()
diff --git a/src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java b/src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java
index 9cf008fe18..769f6ac97e 100644
--- a/src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java
+++ b/src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java
@@ -85,9 +85,8 @@ public class SaveRecalcRecord
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/ScenarioProtectRecord.java b/src/java/org/apache/poi/hssf/record/ScenarioProtectRecord.java
index 037eed0206..cf58666eb1 100644
--- a/src/java/org/apache/poi/hssf/record/ScenarioProtectRecord.java
+++ b/src/java/org/apache/poi/hssf/record/ScenarioProtectRecord.java
@@ -94,9 +94,8 @@ public class ScenarioProtectRecord
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/SelectionRecord.java b/src/java/org/apache/poi/hssf/record/SelectionRecord.java
index ca2bf22fc1..2898c8d142 100644
--- a/src/java/org/apache/poi/hssf/record/SelectionRecord.java
+++ b/src/java/org/apache/poi/hssf/record/SelectionRecord.java
@@ -143,7 +143,7 @@ public final class SelectionRecord extends Record {
buffer.append("[/SELECTION]\n");
return buffer.toString();
}
- private int getDataSize() {
+ protected int getDataSize() {
return 9 // 1 byte + 4 shorts
+ CellRangeAddress8Bit.getEncodedSize(field_6_refs.length);
}
@@ -164,10 +164,6 @@ public final class SelectionRecord 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/SeriesChartGroupIndexRecord.java b/src/java/org/apache/poi/hssf/record/SeriesChartGroupIndexRecord.java
index 0f5c193615..0754aa506e 100644
--- a/src/java/org/apache/poi/hssf/record/SeriesChartGroupIndexRecord.java
+++ b/src/java/org/apache/poi/hssf/record/SeriesChartGroupIndexRecord.java
@@ -66,9 +66,8 @@ public final class SeriesChartGroupIndexRecord 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/SeriesIndexRecord.java b/src/java/org/apache/poi/hssf/record/SeriesIndexRecord.java
index 70565c66b1..af75ced7c2 100644
--- a/src/java/org/apache/poi/hssf/record/SeriesIndexRecord.java
+++ b/src/java/org/apache/poi/hssf/record/SeriesIndexRecord.java
@@ -66,9 +66,8 @@ public final class SeriesIndexRecord 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/SeriesLabelsRecord.java b/src/java/org/apache/poi/hssf/record/SeriesLabelsRecord.java
index 868358b0d2..60d971de82 100644
--- a/src/java/org/apache/poi/hssf/record/SeriesLabelsRecord.java
+++ b/src/java/org/apache/poi/hssf/record/SeriesLabelsRecord.java
@@ -81,9 +81,8 @@ public final class SeriesLabelsRecord 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/SeriesListRecord.java b/src/java/org/apache/poi/hssf/record/SeriesListRecord.java
index 4753eae05f..a6ebefd255 100644
--- a/src/java/org/apache/poi/hssf/record/SeriesListRecord.java
+++ b/src/java/org/apache/poi/hssf/record/SeriesListRecord.java
@@ -74,9 +74,8 @@ public final class SeriesListRecord extends Record {
return 4 + dataSize;
}
- public int getRecordSize()
- {
- return 4 + field_1_seriesNumbers.length * 2 + 2;
+ protected int getDataSize() {
+ return field_1_seriesNumbers.length * 2 + 2;
}
public short getSid()
diff --git a/src/java/org/apache/poi/hssf/record/SeriesRecord.java b/src/java/org/apache/poi/hssf/record/SeriesRecord.java
index b2ab88e8c2..ec35521da9 100644
--- a/src/java/org/apache/poi/hssf/record/SeriesRecord.java
+++ b/src/java/org/apache/poi/hssf/record/SeriesRecord.java
@@ -114,9 +114,8 @@ public final class SeriesRecord extends Record {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + 2 + 2 + 2 + 2 + 2;
+ protected int getDataSize() {
+ return 2 + 2 + 2 + 2 + 2 + 2;
}
public short getSid()
diff --git a/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java b/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java
index da0e854eaa..d1ca886ff4 100644
--- a/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java
+++ b/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java
@@ -88,9 +88,8 @@ public final class SeriesTextRecord extends Record {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + 1 + 1 + (field_2_textLength *2);
+ protected int getDataSize() {
+ return 2 + 1 + 1 + (field_2_textLength *2);
}
public short getSid()
diff --git a/src/java/org/apache/poi/hssf/record/SeriesToChartGroupRecord.java b/src/java/org/apache/poi/hssf/record/SeriesToChartGroupRecord.java
index 6b38c40a4a..648a5b1269 100644
--- a/src/java/org/apache/poi/hssf/record/SeriesToChartGroupRecord.java
+++ b/src/java/org/apache/poi/hssf/record/SeriesToChartGroupRecord.java
@@ -68,9 +68,8 @@ public final class SeriesToChartGroupRecord 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/SharedValueRecordBase.java b/src/java/org/apache/poi/hssf/record/SharedValueRecordBase.java
index 3672b881a2..f30c009590 100644
--- a/src/java/org/apache/poi/hssf/record/SharedValueRecordBase.java
+++ b/src/java/org/apache/poi/hssf/record/SharedValueRecordBase.java
@@ -67,8 +67,8 @@ public abstract class SharedValueRecordBase extends Record {
return (short) _range.getLastColumn();
}
- public final int getRecordSize() {
- return 4 + CellRangeAddress8Bit.ENCODED_SIZE + getExtraDataSize();
+ protected int getDataSize() {
+ return CellRangeAddress8Bit.ENCODED_SIZE + getExtraDataSize();
}
protected abstract int getExtraDataSize();
diff --git a/src/java/org/apache/poi/hssf/record/SheetPropertiesRecord.java b/src/java/org/apache/poi/hssf/record/SheetPropertiesRecord.java
index 1f7a5e44e4..ecfc6156c3 100644
--- a/src/java/org/apache/poi/hssf/record/SheetPropertiesRecord.java
+++ b/src/java/org/apache/poi/hssf/record/SheetPropertiesRecord.java
@@ -90,9 +90,8 @@ public final class SheetPropertiesRecord extends Record {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 2 + 1;
+ protected int getDataSize() {
+ return 2 + 1;
}
public short getSid()
diff --git a/src/java/org/apache/poi/hssf/record/StringRecord.java b/src/java/org/apache/poi/hssf/record/StringRecord.java
index d56e105f5f..620a07e093 100644
--- a/src/java/org/apache/poi/hssf/record/StringRecord.java
+++ b/src/java/org/apache/poi/hssf/record/StringRecord.java
@@ -68,9 +68,8 @@ public class StringRecord extends Record {
return isUnCompressedUnicode() ? field_1_string_length * 2 : field_1_string_length;
}
- public int getRecordSize()
- {
- return 4 + 2 + 1 + getStringByteLength();
+ protected int getDataSize() {
+ return 2 + 1 + getStringByteLength();
}
/**
diff --git a/src/java/org/apache/poi/hssf/record/StyleRecord.java b/src/java/org/apache/poi/hssf/record/StyleRecord.java
index ad740e9b2e..af60e69244 100644
--- a/src/java/org/apache/poi/hssf/record/StyleRecord.java
+++ b/src/java/org/apache/poi/hssf/record/StyleRecord.java
@@ -158,7 +158,7 @@ public final class StyleRecord extends Record {
}
- private int getDataSize() {
+ protected int getDataSize() {
if (isBuiltin()) {
return 4; // short, byte, byte
}
@@ -188,10 +188,6 @@ public final class StyleRecord 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/SupBookRecord.java b/src/java/org/apache/poi/hssf/record/SupBookRecord.java
index 78d77c5cbf..a58c5c8c97 100644
--- a/src/java/org/apache/poi/hssf/record/SupBookRecord.java
+++ b/src/java/org/apache/poi/hssf/record/SupBookRecord.java
@@ -138,7 +138,7 @@ public final class SupBookRecord extends Record {
sb.append("]");
return sb.toString();
}
- private int getDataSize() {
+ protected int getDataSize() {
if(!isExternalReferences()) {
return SMALL_RECORD_SIZE;
}
@@ -198,10 +198,6 @@ public final class SupBookRecord extends Record {
return field_1_number_of_sheets;
}
- public int getRecordSize() {
- return getDataSize() + 4;
- }
-
public short getSid()
{
return sid;
diff --git a/src/java/org/apache/poi/hssf/record/TabIdRecord.java b/src/java/org/apache/poi/hssf/record/TabIdRecord.java
index d5aca3e045..9478d008bf 100644
--- a/src/java/org/apache/poi/hssf/record/TabIdRecord.java
+++ b/src/java/org/apache/poi/hssf/record/TabIdRecord.java
@@ -98,9 +98,8 @@ public final class TabIdRecord extends Record {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + (getTabIdArray().length * 2);
+ protected int getDataSize() {
+ return (getTabIdArray().length * 2);
}
public short getSid()
diff --git a/src/java/org/apache/poi/hssf/record/TextObjectRecord.java b/src/java/org/apache/poi/hssf/record/TextObjectRecord.java
index 4bb065e91e..0a50e181b2 100644
--- a/src/java/org/apache/poi/hssf/record/TextObjectRecord.java
+++ b/src/java/org/apache/poi/hssf/record/TextObjectRecord.java
@@ -167,7 +167,7 @@ public final class TextObjectRecord extends Record {
* Only for the current record. does not include any subsequent Continue
* records
*/
- private int getDataSize() {
+ private int getCurrentRecordDataSize() {
int result = 2 + 2 + 2 + 2 + 2 + 2 + 2 + 4;
if (_linkRefPtg != null) {
result += 2 // formula size
@@ -181,7 +181,7 @@ public final class TextObjectRecord extends Record {
}
private int serializeTXORecord(int offset, byte[] data) {
- int dataSize = getDataSize();
+ int dataSize = getCurrentRecordDataSize();
int recSize = dataSize+4;
LittleEndianOutput out = new LittleEndianByteArrayOutputStream(data, offset, recSize);
@@ -272,10 +272,10 @@ public final class TextObjectRecord extends Record {
/**
* Note - this total size includes all potential {@link ContinueRecord}s written
+ * but it is not the "ushort size" value to be written at the start of the first BIFF record
*/
- public int getRecordSize() {
- int baseSize = 4 + getDataSize();
- return baseSize + getTrailingRecordsSize();
+ protected int getDataSize() {
+ return getCurrentRecordDataSize() + getTrailingRecordsSize();
}
diff --git a/src/java/org/apache/poi/hssf/record/TextRecord.java b/src/java/org/apache/poi/hssf/record/TextRecord.java
index aeb9dc89c0..0820e6baf3 100644
--- a/src/java/org/apache/poi/hssf/record/TextRecord.java
+++ b/src/java/org/apache/poi/hssf/record/TextRecord.java
@@ -202,9 +202,8 @@ public final class TextRecord extends Record {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 1 + 1 + 2 + 4 + 4 + 4 + 4 + 4 + 2 + 2 + 2 + 2;
+ protected int getDataSize() {
+ return 1 + 1 + 2 + 4 + 4 + 4 + 4 + 4 + 2 + 2 + 2 + 2;
}
public short getSid()
diff --git a/src/java/org/apache/poi/hssf/record/TickRecord.java b/src/java/org/apache/poi/hssf/record/TickRecord.java
index f24f033eb1..3b662d18bb 100644
--- a/src/java/org/apache/poi/hssf/record/TickRecord.java
+++ b/src/java/org/apache/poi/hssf/record/TickRecord.java
@@ -149,9 +149,8 @@ public final class TickRecord extends Record {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 1 + 1 + 1 + 1 + 4 + 8 + 8 + 2 + 2 + 2;
+ protected int getDataSize() {
+ return 1 + 1 + 1 + 1 + 4 + 8 + 8 + 2 + 2 + 2;
}
public short getSid()
diff --git a/src/java/org/apache/poi/hssf/record/TopMarginRecord.java b/src/java/org/apache/poi/hssf/record/TopMarginRecord.java
index 4d1a19a77b..e52326e5cf 100644
--- a/src/java/org/apache/poi/hssf/record/TopMarginRecord.java
+++ b/src/java/org/apache/poi/hssf/record/TopMarginRecord.java
@@ -55,7 +55,9 @@ public final class TopMarginRecord extends Record implements Margin {
return getRecordSize();
}
- public int getRecordSize() { return 4 + 8; }
+ protected int getDataSize() {
+ return 8;
+ }
public short getSid() { return sid; }
@@ -76,4 +78,4 @@ public final class TopMarginRecord extends Record implements Margin {
rec.field_1_margin = this.field_1_margin;
return rec;
}
-} // END OF CLA \ No newline at end of file
+} // END OF C \ No newline at end of file
diff --git a/src/java/org/apache/poi/hssf/record/UncalcedRecord.java b/src/java/org/apache/poi/hssf/record/UncalcedRecord.java
index adc2cdeb90..01ae71f5af 100644
--- a/src/java/org/apache/poi/hssf/record/UncalcedRecord.java
+++ b/src/java/org/apache/poi/hssf/record/UncalcedRecord.java
@@ -27,14 +27,9 @@ import org.apache.poi.util.LittleEndian;
*
* @author Olivier Leprince
*/
+public final class UncalcedRecord extends Record {
+ public final static short sid = 0x005E;
-public class UncalcedRecord extends Record
-{
- public final static short sid = 0x5E;
-
- /**
- * Default constructor
- */
public UncalcedRecord() {
}
@@ -60,8 +55,8 @@ public class UncalcedRecord extends Record
return getRecordSize();
}
- public int getRecordSize() {
- return UncalcedRecord.getStaticRecordSize();
+ protected int getDataSize() {
+ return 2;
}
public static int getStaticRecordSize() {
diff --git a/src/java/org/apache/poi/hssf/record/UnitsRecord.java b/src/java/org/apache/poi/hssf/record/UnitsRecord.java
index e4464eb790..f09b3cb2da 100644
--- a/src/java/org/apache/poi/hssf/record/UnitsRecord.java
+++ b/src/java/org/apache/poi/hssf/record/UnitsRecord.java
@@ -67,9 +67,8 @@ public final class UnitsRecord 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/UnknownRecord.java b/src/java/org/apache/poi/hssf/record/UnknownRecord.java
index 77de66d9b3..61630357a8 100644
--- a/src/java/org/apache/poi/hssf/record/UnknownRecord.java
+++ b/src/java/org/apache/poi/hssf/record/UnknownRecord.java
@@ -87,8 +87,8 @@ public final class UnknownRecord extends Record {
return 4 + dataSize;
}
- public final int getRecordSize() {
- return 4 + _rawData.length;
+ protected int getDataSize() {
+ return _rawData.length;
}
/**
diff --git a/src/java/org/apache/poi/hssf/record/UseSelFSRecord.java b/src/java/org/apache/poi/hssf/record/UseSelFSRecord.java
index 8e64ef3d4a..e513cc8125 100644
--- a/src/java/org/apache/poi/hssf/record/UseSelFSRecord.java
+++ b/src/java/org/apache/poi/hssf/record/UseSelFSRecord.java
@@ -93,9 +93,8 @@ public class UseSelFSRecord
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/VCenterRecord.java b/src/java/org/apache/poi/hssf/record/VCenterRecord.java
index 7326a32929..6e4c4d03c6 100644
--- a/src/java/org/apache/poi/hssf/record/VCenterRecord.java
+++ b/src/java/org/apache/poi/hssf/record/VCenterRecord.java
@@ -80,9 +80,8 @@ public final class VCenterRecord 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/ValueRangeRecord.java b/src/java/org/apache/poi/hssf/record/ValueRangeRecord.java
index 9caffa73b5..fa13af68ae 100644
--- a/src/java/org/apache/poi/hssf/record/ValueRangeRecord.java
+++ b/src/java/org/apache/poi/hssf/record/ValueRangeRecord.java
@@ -119,9 +119,8 @@ public final class ValueRangeRecord extends Record {
return getRecordSize();
}
- public int getRecordSize()
- {
- return 4 + 8 + 8 + 8 + 8 + 8 + 2;
+ protected int getDataSize() {
+ return 8 + 8 + 8 + 8 + 8 + 2;
}
public short getSid()
diff --git a/src/java/org/apache/poi/hssf/record/WSBoolRecord.java b/src/java/org/apache/poi/hssf/record/WSBoolRecord.java
index bdb1cb4847..d58e26d9d7 100644
--- a/src/java/org/apache/poi/hssf/record/WSBoolRecord.java
+++ b/src/java/org/apache/poi/hssf/record/WSBoolRecord.java
@@ -325,9 +325,8 @@ public final class WSBoolRecord 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/WindowOneRecord.java b/src/java/org/apache/poi/hssf/record/WindowOneRecord.java
index 7afc5fa1f8..8fb0772132 100644
--- a/src/java/org/apache/poi/hssf/record/WindowOneRecord.java
+++ b/src/java/org/apache/poi/hssf/record/WindowOneRecord.java
@@ -439,9 +439,8 @@ public final class WindowOneRecord 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/WindowProtectRecord.java b/src/java/org/apache/poi/hssf/record/WindowProtectRecord.java
index 13d54e9b5e..e61d8611fc 100644
--- a/src/java/org/apache/poi/hssf/record/WindowProtectRecord.java
+++ b/src/java/org/apache/poi/hssf/record/WindowProtectRecord.java
@@ -92,9 +92,8 @@ public class WindowProtectRecord
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/WindowTwoRecord.java b/src/java/org/apache/poi/hssf/record/WindowTwoRecord.java
index 9023d2d692..70cc29166f 100644
--- a/src/java/org/apache/poi/hssf/record/WindowTwoRecord.java
+++ b/src/java/org/apache/poi/hssf/record/WindowTwoRecord.java
@@ -537,9 +537,8 @@ public final class WindowTwoRecord 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/WriteAccessRecord.java b/src/java/org/apache/poi/hssf/record/WriteAccessRecord.java
index 6b005c7f44..5870a9ace4 100644
--- a/src/java/org/apache/poi/hssf/record/WriteAccessRecord.java
+++ b/src/java/org/apache/poi/hssf/record/WriteAccessRecord.java
@@ -133,8 +133,8 @@ public final class WriteAccessRecord extends Record {
return 4 + DATA_SIZE;
}
- public int getRecordSize() {
- return 4 + DATA_SIZE;
+ protected int getDataSize() {
+ return DATA_SIZE;
}
public short getSid() {
diff --git a/src/java/org/apache/poi/hssf/record/WriteProtectRecord.java b/src/java/org/apache/poi/hssf/record/WriteProtectRecord.java
index eb27e0ec12..797f872430 100644
--- a/src/java/org/apache/poi/hssf/record/WriteProtectRecord.java
+++ b/src/java/org/apache/poi/hssf/record/WriteProtectRecord.java
@@ -56,9 +56,8 @@ public final class WriteProtectRecord 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/aggregates/PageSettingsBlock.java b/src/java/org/apache/poi/hssf/record/aggregates/PageSettingsBlock.java
index 819940e12e..c4d1565970 100644
--- a/src/java/org/apache/poi/hssf/record/aggregates/PageSettingsBlock.java
+++ b/src/java/org/apache/poi/hssf/record/aggregates/PageSettingsBlock.java
@@ -210,6 +210,15 @@ public final class PageSettingsBlock extends RecordAggregate {
rv.visitRecord(r);
}
}
+ private static void visitIfPresent(PageBreakRecord r, RecordVisitor rv) {
+ if (r != null) {
+ if (r.isEmpty()) {
+ // its OK to not serialize empty page break records
+ return;
+ }
+ rv.visitRecord(r);
+ }
+ }
/**
* creates the Header Record and sets it to nothing/0 length
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
index 4357c57e3b..4b4dd0af7a 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
@@ -30,7 +30,6 @@ import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.record.NameRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RecordFormatException;
-import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.hssf.record.formula.Area3DPtg;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.TempFile;
@@ -504,8 +503,8 @@ public final class TestHSSFWorkbook extends TestCase {
public int serialize(int offset, byte[] data) {
return 4;
}
- public int getRecordSize() {
- return 8;
+ protected int getDataSize() {
+ return 4;
}
}
diff --git a/src/testcases/org/apache/poi/hssf/util/TestRKUtil.java b/src/testcases/org/apache/poi/hssf/util/TestRKUtil.java
index e158aafc5f..5b845775fe 100644
--- a/src/testcases/org/apache/poi/hssf/util/TestRKUtil.java
+++ b/src/testcases/org/apache/poi/hssf/util/TestRKUtil.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,31 +14,38 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.util;
+import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
/**
- * Tests the RKUtil class.
+ * Tests the {@link RKUtil} class.
*/
-public class TestRKUtil
- extends TestCase
-{
- public TestRKUtil(String s)
- {
- super(s);
- }
-
- /**
- * Check we can decode correctly.
- */
- public void testDecode()
- throws Exception
- {
- assertEquals(3.0, RKUtil.decodeNumber(1074266112), 0.0000001);
- assertEquals(3.3, RKUtil.decodeNumber(1081384961), 0.0000001);
- assertEquals(3.33, RKUtil.decodeNumber(1081397249), 0.0000001);
- }
+public final class TestRKUtil extends TestCase {
+
+ /**
+ * Check we can decode correctly.
+ */
+ public void testDecode() {
+
+ int[] values = { 1074266112, 1081384961, 1081397249,
+ 0x3FF00000, 0x405EC001, 0x02F1853A, 0x02F1853B, 0xFCDD699A,
+ };
+ double[] rvalues = { 3.0, 3.3, 3.33,
+ 1, 1.23, 12345678, 123456.78, -13149594,
+ };
+
+ for (int j = 0; j < values.length; j++) {
+
+ int intBits = values[j];
+ double expectedValue = rvalues[j];
+ double actualValue = RKUtil.decodeNumber(intBits);
+ if (expectedValue != actualValue) {
+ throw new AssertionFailedError("0x" + Integer.toHexString(intBits)
+ + " should decode to " + expectedValue + " but got " + actualValue);
+ }
+ }
+ }
}