javadocs fixes (jdk8)

eclipse source clean-ups (final members, override annotations, for-each loops)

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1752037 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2016-07-09 18:52:26 +00:00
parent aac75f3f3c
commit 848f056369
25 changed files with 410 additions and 170 deletions

View File

@ -46,8 +46,12 @@ public final class ExtSSTRecord extends ContinuableRecord {
/** unused - supposed to be zero */ /** unused - supposed to be zero */
private short field_3_zero; private short field_3_zero;
/** Creates new ExtSSTInfoSubRecord */ /**
* Creates new ExtSSTInfoSubRecord
*
* @param streamPos stream pointer to the SST record
* @param bucketSstOffset ... don't really understand this yet
*/
public InfoSubRecord(int streamPos, int bucketSstOffset) { public InfoSubRecord(int streamPos, int bucketSstOffset) {
field_1_stream_pos = streamPos; field_1_stream_pos = streamPos;
field_2_bucket_sst_offset = bucketSstOffset; field_2_bucket_sst_offset = bucketSstOffset;
@ -155,7 +159,13 @@ public final class ExtSSTRecord extends ContinuableRecord {
return infoRecs; return infoRecs;
} }
/** Given a number of strings (in the sst), returns the size of the extsst record*/ /**
* Given a number of strings (in the sst), returns the size of the extsst record
*
* @param numStrings the number of strings
*
* @return the size of the extsst record
*/
public static final int getRecordSizeForStrings(int numStrings) { public static final int getRecordSizeForStrings(int numStrings) {
return 4 + 2 + getNumberOfInfoRecsForStrings(numStrings) * 8; return 4 + 2 + getNumberOfInfoRecsForStrings(numStrings) * 8;
} }

View File

@ -29,13 +29,13 @@ import org.apache.poi.util.LittleEndianOutput;
public class ExternSheetRecord extends StandardRecord { public class ExternSheetRecord extends StandardRecord {
public final static short sid = 0x0017; public final static short sid = 0x0017;
private List<RefSubRecord> _list; private final List<RefSubRecord> _list;
private static final class RefSubRecord { private static final class RefSubRecord {
public static final int ENCODED_SIZE = 6; public static final int ENCODED_SIZE = 6;
/** index to External Book Block (which starts with a EXTERNALBOOK record) */ /** index to External Book Block (which starts with a EXTERNALBOOK record) */
private int _extBookIndex; private final int _extBookIndex;
private int _firstSheetIndex; // may be -1 (0xFFFF) private int _firstSheetIndex; // may be -1 (0xFFFF)
private int _lastSheetIndex; // may be -1 (0xFFFF) private int _lastSheetIndex; // may be -1 (0xFFFF)
@ -196,6 +196,8 @@ public class ExternSheetRecord extends StandardRecord {
} }
/** /**
* @param extBookIndex external sheet reference index
*
* @return -1 if not found * @return -1 if not found
*/ */
public int findRefIndexFromExtBookIndex(int extBookIndex) { public int findRefIndexFromExtBookIndex(int extBookIndex) {
@ -212,6 +214,12 @@ public class ExternSheetRecord extends StandardRecord {
* Returns the first sheet that the reference applies to, or * Returns the first sheet that the reference applies to, or
* -1 if the referenced sheet can't be found, or -2 if the * -1 if the referenced sheet can't be found, or -2 if the
* reference is workbook scoped. * reference is workbook scoped.
*
* @param extRefIndex external sheet reference index
*
* @return the first sheet that the reference applies to, or
* -1 if the referenced sheet can't be found, or -2 if the
* reference is workbook scoped
*/ */
public int getFirstSheetIndexFromRefIndex(int extRefIndex) { public int getFirstSheetIndexFromRefIndex(int extRefIndex) {
return getRef(extRefIndex).getFirstSheetIndex(); return getRef(extRefIndex).getFirstSheetIndex();
@ -223,6 +231,12 @@ public class ExternSheetRecord extends StandardRecord {
* reference is workbook scoped. * reference is workbook scoped.
* For a single sheet reference, the first and last should be * For a single sheet reference, the first and last should be
* the same. * the same.
*
* @param extRefIndex external sheet reference index
*
* @return the last sheet that the reference applies to, or
* -1 if the referenced sheet can't be found, or -2 if the
* reference is workbook scoped.
*/ */
public int getLastSheetIndexFromRefIndex(int extRefIndex) { public int getLastSheetIndexFromRefIndex(int extRefIndex) {
return getRef(extRefIndex).getLastSheetIndex(); return getRef(extRefIndex).getLastSheetIndex();
@ -235,25 +249,24 @@ public class ExternSheetRecord extends StandardRecord {
* DDE data source referencing, or OLE data source referencing, * DDE data source referencing, or OLE data source referencing,
* then no scope is specified and this value <em>MUST</em> be -2. Otherwise, * then no scope is specified and this value <em>MUST</em> be -2. Otherwise,
* the scope must be set as follows: * the scope must be set as follows:
* <ol> * <ol>
* <li><code>-2</code> Workbook-level reference that applies to the entire workbook.</li> * <li><code>-2</code> Workbook-level reference that applies to the entire workbook.</li>
* <li><code>-1</code> Sheet-level reference. </li> * <li><code>-1</code> Sheet-level reference. </li>
* <li><code>&gt;=0</code> Sheet-level reference. This specifies the first sheet in the reference. * <li><code>&gt;=0</code> Sheet-level reference. This specifies the first sheet in the reference.
* <p> * <p>If the SupBook type is unused or external workbook referencing,
* If the SupBook type is unused or external workbook referencing,
* then this value specifies the zero-based index of an external sheet name, * then this value specifies the zero-based index of an external sheet name,
* see {@link org.apache.poi.hssf.record.SupBookRecord#getSheetNames()}. * see {@link org.apache.poi.hssf.record.SupBookRecord#getSheetNames()}.
* This referenced string specifies the name of the first sheet within the external workbook that is in scope. * This referenced string specifies the name of the first sheet within the external workbook that is in scope.
* This sheet MUST be a worksheet or macro sheet. * This sheet MUST be a worksheet or macro sheet.</p>
* <p> *
* <p> * <p>If the supporting link type is self-referencing, then this value specifies the zero-based index of a
* If the supporting link type is self-referencing, then this value specifies the zero-based index of a
* {@link org.apache.poi.hssf.record.BoundSheetRecord} record in the workbook stream that specifies * {@link org.apache.poi.hssf.record.BoundSheetRecord} record in the workbook stream that specifies
* the first sheet within the scope of this reference. This sheet MUST be a worksheet or a macro sheet. * the first sheet within the scope of this reference. This sheet MUST be a worksheet or a macro sheet.
* </p> * </p>
* </li> * </li>
* </ol> * </ol>
* *
* @param extBookIndex the external book block index
* @param firstSheetIndex the scope, must be -2 for add-in references * @param firstSheetIndex the scope, must be -2 for add-in references
* @param lastSheetIndex the scope, must be -2 for add-in references * @param lastSheetIndex the scope, must be -2 for add-in references
* @return index of newly added ref * @return index of newly added ref
@ -280,8 +293,7 @@ public class ExternSheetRecord extends StandardRecord {
public static ExternSheetRecord combine(ExternSheetRecord[] esrs) { public static ExternSheetRecord combine(ExternSheetRecord[] esrs) {
ExternSheetRecord result = new ExternSheetRecord(); ExternSheetRecord result = new ExternSheetRecord();
for (int i = 0; i < esrs.length; i++) { for (ExternSheetRecord esr : esrs) {
ExternSheetRecord esr = esrs[i];
int nRefs = esr.getNumOfREFRecords(); int nRefs = esr.getNumOfREFRecords();
for (int j=0; j<nRefs; j++) { for (int j=0; j<nRefs; j++) {
result.addREFRecord(esr.getRef(j)); result.addREFRecord(esr.getRef(j));

View File

@ -421,6 +421,8 @@ public final class FontRecord extends StandardRecord {
* Clones all the font style information from another * Clones all the font style information from another
* FontRecord, onto this one. This * FontRecord, onto this one. This
* will then hold all the same font style options. * will then hold all the same font style options.
*
* @param source the record to clone the properties from
*/ */
public void cloneStyleFrom(FontRecord source) { public void cloneStyleFrom(FontRecord source) {
field_1_font_height = source.field_1_font_height; field_1_font_height = source.field_1_font_height;
@ -462,6 +464,10 @@ public final class FontRecord extends StandardRecord {
* for exact contents, because normally the * for exact contents, because normally the
* font record's position makes a big * font record's position makes a big
* difference too. * difference too.
*
* @param other the record to compare with
*
* @return true, if the properties match
*/ */
public boolean sameProperties(FontRecord other) { public boolean sameProperties(FontRecord other) {
return return

View File

@ -100,8 +100,8 @@ public final class FtPioGrbitSubRecord extends SubRecord implements Cloneable {
/** /**
* Use one of the bitmasks MANUAL_ADVANCE_BIT ... CURSOR_VISIBLE_BIT * Use one of the bitmasks MANUAL_ADVANCE_BIT ... CURSOR_VISIBLE_BIT
* @param bitmask * @param bitmask the bitmask to apply
* @param enabled * @param enabled if true, the bitmask will be or-ed, otherwise the bits set in the mask will be removed from the flags
*/ */
public void setFlagByBit(int bitmask, boolean enabled) { public void setFlagByBit(int bitmask, boolean enabled) {
if (enabled) { if (enabled) {

View File

@ -80,7 +80,9 @@ public final class HyperlinkRecord extends StandardRecord implements Cloneable {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (!(obj instanceof GUID)) return false; if (!(obj instanceof GUID)) {
return false;
}
GUID other = (GUID) obj; GUID other = (GUID) obj;
return _d1 == other._d1 && _d2 == other._d2 return _d1 == other._d1 && _d2 == other._d2
&& _d3 == other._d3 && _d4 == other._d4; && _d3 == other._d3 && _d4 == other._d4;
@ -265,10 +267,12 @@ public final class HyperlinkRecord extends StandardRecord implements Cloneable {
} }
/** /**
* Set the first column (zero-based)of the range that contains this hyperlink * Set the first column (zero-based) of the range that contains this hyperlink
*
* @param firstCol the first column (zero-based)
*/ */
public void setFirstColumn(int col) { public void setFirstColumn(int firstCol) {
_range.setFirstColumn(col); _range.setFirstColumn(firstCol);
} }
/** /**
@ -279,10 +283,12 @@ public final class HyperlinkRecord extends StandardRecord implements Cloneable {
} }
/** /**
* Set the last column (zero-based)of the range that contains this hyperlink * Set the last column (zero-based) of the range that contains this hyperlink
*
* @param lastCol the last column (zero-based)
*/ */
public void setLastColumn(int col) { public void setLastColumn(int lastCol) {
_range.setLastColumn(col); _range.setLastColumn(lastCol);
} }
/** /**
@ -293,10 +299,12 @@ public final class HyperlinkRecord extends StandardRecord implements Cloneable {
} }
/** /**
* Set the first row (zero-based)of the range that contains this hyperlink * Set the first row (zero-based) of the range that contains this hyperlink
*
* @param firstRow the first row (zero-based)
*/ */
public void setFirstRow(int col) { public void setFirstRow(int firstRow) {
_range.setFirstRow(col); _range.setFirstRow(firstRow);
} }
/** /**
@ -307,10 +315,12 @@ public final class HyperlinkRecord extends StandardRecord implements Cloneable {
} }
/** /**
* Set the last row (zero-based)of the range that contains this hyperlink * Set the last row (zero-based) of the range that contains this hyperlink
*
* @param lastRow the last row (zero-based)
*/ */
public void setLastRow(int col) { public void setLastRow(int lastRow) {
_range.setLastRow(col); _range.setLastRow(lastRow);
} }
/** /**
@ -372,12 +382,13 @@ public final class HyperlinkRecord extends StandardRecord implements Cloneable {
* @return the address of this hyperlink * @return the address of this hyperlink
*/ */
public String getAddress() { public String getAddress() {
if ((_linkOpts & HLINK_URL) != 0 && FILE_MONIKER.equals(_moniker)) if ((_linkOpts & HLINK_URL) != 0 && FILE_MONIKER.equals(_moniker)) {
return cleanString(_address != null ? _address : _shortFilename); return cleanString(_address != null ? _address : _shortFilename);
else if((_linkOpts & HLINK_PLACE) != 0) } else if((_linkOpts & HLINK_PLACE) != 0) {
return cleanString(_textMark); return cleanString(_textMark);
else } else {
return cleanString(_address); return cleanString(_address);
}
} }
/** /**
@ -386,12 +397,13 @@ public final class HyperlinkRecord extends StandardRecord implements Cloneable {
* @param address the address of this hyperlink * @param address the address of this hyperlink
*/ */
public void setAddress(String address) { public void setAddress(String address) {
if ((_linkOpts & HLINK_URL) != 0 && FILE_MONIKER.equals(_moniker)) if ((_linkOpts & HLINK_URL) != 0 && FILE_MONIKER.equals(_moniker)) {
_shortFilename = appendNullTerm(address); _shortFilename = appendNullTerm(address);
else if((_linkOpts & HLINK_PLACE) != 0) } else if((_linkOpts & HLINK_PLACE) != 0) {
_textMark = appendNullTerm(address); _textMark = appendNullTerm(address);
else } else {
_address = appendNullTerm(address); _address = appendNullTerm(address);
}
} }
public String getShortFilename() { public String getShortFilename() {
@ -413,20 +425,22 @@ public final class HyperlinkRecord extends StandardRecord implements Cloneable {
/** /**
* Link options. Must be a combination of HLINK_* constants. * Link options. Must be a combination of HLINK_* constants.
* For testing only * For testing only
*
* @return Link options
*/ */
int getLinkOptions(){ int getLinkOptions(){
return _linkOpts; return _linkOpts;
} }
/** /**
* Label options * @return Label options
*/ */
public int getLabelOptions(){ public int getLabelOptions(){
return 2; // always 2 return 2; // always 2
} }
/** /**
* Options for a file link * @return Options for a file link
*/ */
public int getFileOptions(){ public int getFileOptions(){
return _fileOpts; return _fileOpts;
@ -536,6 +550,7 @@ public final class HyperlinkRecord extends StandardRecord implements Cloneable {
} }
} }
@Override
public void serialize(LittleEndianOutput out) { public void serialize(LittleEndianOutput out) {
_range.serialize(out); _range.serialize(out);
@ -590,6 +605,7 @@ public final class HyperlinkRecord extends StandardRecord implements Cloneable {
} }
} }
@Override
protected int getDataSize() { protected int getDataSize() {
int size = 0; int size = 0;
size += 2 + 2 + 2 + 2; //rwFirst, rwLast, colFirst, colLast size += 2 + 2 + 2 + 2; //rwFirst, rwLast, colFirst, colLast
@ -654,11 +670,13 @@ public final class HyperlinkRecord extends StandardRecord implements Cloneable {
out.write(tail); out.write(tail);
} }
@Override
public short getSid() { public short getSid() {
return HyperlinkRecord.sid; return HyperlinkRecord.sid;
} }
@Override
public String toString() { public String toString() {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
@ -683,6 +701,8 @@ public final class HyperlinkRecord extends StandardRecord implements Cloneable {
/** /**
* Based on the link options, is this a url? * Based on the link options, is this a url?
*
* @return true, if this is a url link
*/ */
public boolean isUrlLink() { public boolean isUrlLink() {
return (_linkOpts & HLINK_URL) > 0 return (_linkOpts & HLINK_URL) > 0
@ -690,6 +710,8 @@ public final class HyperlinkRecord extends StandardRecord implements Cloneable {
} }
/** /**
* Based on the link options, is this a file? * Based on the link options, is this a file?
*
* @return true, if this is a file link
*/ */
public boolean isFileLink() { public boolean isFileLink() {
return (_linkOpts & HLINK_URL) > 0 return (_linkOpts & HLINK_URL) > 0
@ -697,6 +719,8 @@ public final class HyperlinkRecord extends StandardRecord implements Cloneable {
} }
/** /**
* Based on the link options, is this a document? * Based on the link options, is this a document?
*
* @return true, if this is a docment link
*/ */
public boolean isDocumentLink() { public boolean isDocumentLink() {
return (_linkOpts & HLINK_PLACE) > 0; return (_linkOpts & HLINK_PLACE) > 0;

View File

@ -103,6 +103,7 @@ public final class IndexRecord extends StandardRecord implements Cloneable {
return field_5_dbcells.get(cellnum); return field_5_dbcells.get(cellnum);
} }
@Override
public String toString() public String toString()
{ {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
@ -120,6 +121,7 @@ public final class IndexRecord extends StandardRecord implements Cloneable {
return buffer.toString(); return buffer.toString();
} }
@Override
public void serialize(LittleEndianOutput out) { public void serialize(LittleEndianOutput out) {
out.writeInt(0); out.writeInt(0);
@ -131,18 +133,21 @@ public final class IndexRecord extends StandardRecord implements Cloneable {
} }
} }
@Override
protected int getDataSize() { protected int getDataSize() {
return 16 // 4 ints return 16 // 4 ints
+ getNumDbcells() * 4; + getNumDbcells() * 4;
} }
/** /**
* @return the size of an INdexRecord when it needs to index the specified number of blocks * @param blockCount the number of blocks to be indexed
* @return the size of an IndexRecord when it needs to index the specified number of blocks
*/ */
public static int getRecordSizeForBlockCount(int blockCount) { public static int getRecordSizeForBlockCount(int blockCount) {
return 20 + 4 * blockCount; return 20 + 4 * blockCount;
} }
@Override
public short getSid() { public short getSid() {
return sid; return sid;
} }

View File

@ -22,9 +22,9 @@ import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
/** /**
* Label Record (0x0204) - read only support for strings stored directly in the cell.. Don't * Label Record (0x0204) - read only support for strings stored directly in the cell...
* use this (except to read), use LabelSST instead <P> * Don't use this (except to read), use LabelSST instead <P>
* REFERENCE: PG 325 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P> * REFERENCE: PG 325 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)
* *
* @see org.apache.poi.hssf.record.LabelSSTRecord * @see org.apache.poi.hssf.record.LabelSSTRecord
*/ */
@ -76,16 +76,19 @@ public final class LabelRecord extends Record implements CellValueRecordInterfac
/* /*
* READ ONLY ACCESS... THIS IS FOR COMPATIBILITY ONLY...USE LABELSST! public * READ ONLY ACCESS... THIS IS FOR COMPATIBILITY ONLY...USE LABELSST! public
*/ */
@Override
public int getRow() public int getRow()
{ {
return field_1_row; return field_1_row;
} }
@Override
public short getColumn() public short getColumn()
{ {
return field_2_column; return field_2_column;
} }
@Override
public short getXFIndex() public short getXFIndex()
{ {
return field_3_xf_index; return field_3_xf_index;
@ -123,18 +126,22 @@ public final class LabelRecord extends Record implements CellValueRecordInterfac
/** /**
* THROWS A RUNTIME EXCEPTION.. USE LABELSSTRecords. YOU HAVE NO REASON to use LABELRecord!! * THROWS A RUNTIME EXCEPTION.. USE LABELSSTRecords. YOU HAVE NO REASON to use LABELRecord!!
*/ */
@Override
public int serialize(int offset, byte [] data) { public int serialize(int offset, byte [] data) {
throw new RecordFormatException("Label Records are supported READ ONLY...convert to LabelSST"); throw new RecordFormatException("Label Records are supported READ ONLY...convert to LabelSST");
} }
@Override
public int getRecordSize() { public int getRecordSize() {
throw new RecordFormatException("Label Records are supported READ ONLY...convert to LabelSST"); throw new RecordFormatException("Label Records are supported READ ONLY...convert to LabelSST");
} }
@Override
public short getSid() public short getSid()
{ {
return sid; return sid;
} }
@Override
public String toString() public String toString()
{ {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
@ -152,6 +159,7 @@ public final class LabelRecord extends Record implements CellValueRecordInterfac
/** /**
* NO-OP! * NO-OP!
*/ */
@Override
public void setColumn(short col) public void setColumn(short col)
{ {
} }
@ -159,6 +167,7 @@ public final class LabelRecord extends Record implements CellValueRecordInterfac
/** /**
* NO-OP! * NO-OP!
*/ */
@Override
public void setRow(int row) public void setRow(int row)
{ {
} }
@ -166,6 +175,7 @@ public final class LabelRecord extends Record implements CellValueRecordInterfac
/** /**
* no op! * no op!
*/ */
@Override
public void setXFIndex(short xf) public void setXFIndex(short xf)
{ {
} }

View File

@ -22,9 +22,8 @@ import org.apache.poi.util.LittleEndianOutput;
/** /**
* Title: Label SST Record<P> * Title: Label SST Record<P>
* Description: Refers to a string in the shared string table and is a column * Description: Refers to a string in the shared string table and is a column value.<P>
* value. <P> * REFERENCE: PG 325 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)
* REFERENCE: PG 325 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
*/ */
public final class LabelSSTRecord extends CellRecord implements Cloneable { public final class LabelSSTRecord extends CellRecord implements Cloneable {
public final static short sid = 0xfd; public final static short sid = 0xfd;
@ -80,6 +79,7 @@ public final class LabelSSTRecord extends CellRecord implements Cloneable {
return 4; return 4;
} }
@Override
public short getSid() { public short getSid() {
return sid; return sid;
} }

View File

@ -270,12 +270,16 @@ public class LbsDataSubRecord extends SubRecord {
sb.append("[ftLbsData]\n"); sb.append("[ftLbsData]\n");
sb.append(" .unknownShort1 =").append(HexDump.shortToHex(_cbFContinued)).append("\n"); sb.append(" .unknownShort1 =").append(HexDump.shortToHex(_cbFContinued)).append("\n");
sb.append(" .formula = ").append('\n'); sb.append(" .formula = ").append('\n');
if(_linkPtg != null) sb.append(_linkPtg.toString()).append(_linkPtg.getRVAType()).append('\n'); if(_linkPtg != null) {
sb.append(_linkPtg.toString()).append(_linkPtg.getRVAType()).append('\n');
}
sb.append(" .nEntryCount =").append(HexDump.shortToHex(_cLines)).append("\n"); sb.append(" .nEntryCount =").append(HexDump.shortToHex(_cLines)).append("\n");
sb.append(" .selEntryIx =").append(HexDump.shortToHex(_iSel)).append("\n"); sb.append(" .selEntryIx =").append(HexDump.shortToHex(_iSel)).append("\n");
sb.append(" .style =").append(HexDump.shortToHex(_flags)).append("\n"); sb.append(" .style =").append(HexDump.shortToHex(_flags)).append("\n");
sb.append(" .unknownShort10=").append(HexDump.shortToHex(_idEdit)).append("\n"); sb.append(" .unknownShort10=").append(HexDump.shortToHex(_idEdit)).append("\n");
if(_dropData != null) sb.append('\n').append(_dropData.toString()); if(_dropData != null) {
sb.append('\n').append(_dropData.toString());
}
sb.append("[/ftLbsData]\n"); sb.append("[/ftLbsData]\n");
return sb.toString(); return sb.toString();
} }
@ -354,14 +358,16 @@ public class LbsDataSubRecord extends SubRecord {
} }
/** /**
* Set the style of this dropdown. * Set the style of this dropdown.<p>
* *
* Possible values: * Possible values:
* <p> * <ul>
* 0 Combo dropdown control * <li>0: Combo dropdown control</li>
* 1 Combo Edit dropdown control * <li>1: Combo Edit dropdown control</li>
* 2 Simple dropdown control (just the dropdown button) * <li>2: Simple dropdown control (just the dropdown button)</li>
* * </ul>
*
* @param style the style - see possible values
*/ */
public void setStyle(int style){ public void setStyle(int style){
_wStyle = style; _wStyle = style;
@ -369,6 +375,8 @@ public class LbsDataSubRecord extends SubRecord {
/** /**
* Set the number of lines to be displayed in the dropdown. * Set the number of lines to be displayed in the dropdown.
*
* @param num the number of lines to be displayed in the dropdown
*/ */
public void setNumLines(int num){ public void setNumLines(int num){
_cLine = num; _cLine = num;
@ -379,13 +387,17 @@ public class LbsDataSubRecord extends SubRecord {
out.writeShort(_cLine); out.writeShort(_cLine);
out.writeShort(_dxMin); out.writeShort(_dxMin);
StringUtil.writeUnicodeString(out, _str); StringUtil.writeUnicodeString(out, _str);
if(_unused != null) out.writeByte(_unused); if(_unused != null) {
out.writeByte(_unused);
}
} }
public int getDataSize() { public int getDataSize() {
int size = 6; int size = 6;
size += StringUtil.getEncodedSize(_str); size += StringUtil.getEncodedSize(_str);
if(_unused != null) size++; if(_unused != null) {
size++;
}
return size; return size;
} }
@ -397,7 +409,9 @@ public class LbsDataSubRecord extends SubRecord {
sb.append(" ._cLine: ").append(_cLine).append('\n'); sb.append(" ._cLine: ").append(_cLine).append('\n');
sb.append(" ._dxMin: ").append(_dxMin).append('\n'); sb.append(" ._dxMin: ").append(_dxMin).append('\n');
sb.append(" ._str: ").append(_str).append('\n'); sb.append(" ._str: ").append(_str).append('\n');
if(_unused != null) sb.append(" ._unused: ").append(_unused).append('\n'); if(_unused != null) {
sb.append(" ._unused: ").append(_unused).append('\n');
}
sb.append("[/LbsDropData]\n"); sb.append("[/LbsDropData]\n");
return sb.toString(); return sb.toString();

View File

@ -29,7 +29,7 @@ import org.apache.poi.util.LittleEndianOutput;
public final class MergeCellsRecord extends StandardRecord implements Cloneable { public final class MergeCellsRecord extends StandardRecord implements Cloneable {
public final static short sid = 0x00E5; public final static short sid = 0x00E5;
/** sometimes the regions array is shared with other MergedCellsRecords */ /** sometimes the regions array is shared with other MergedCellsRecords */
private CellRangeAddress[] _regions; private final CellRangeAddress[] _regions;
private final int _startIndex; private final int _startIndex;
private final int _numberOfRegions; private final int _numberOfRegions;
@ -62,20 +62,25 @@ public final class MergeCellsRecord extends StandardRecord implements Cloneable
} }
/** /**
* @param index the n-th MergedRegion
*
* @return MergedRegion at the given index representing the area that is Merged (r1,c1 - r2,c2) * @return MergedRegion at the given index representing the area that is Merged (r1,c1 - r2,c2)
*/ */
public CellRangeAddress getAreaAt(int index) { public CellRangeAddress getAreaAt(int index) {
return _regions[_startIndex + index]; return _regions[_startIndex + index];
} }
@Override
protected int getDataSize() { protected int getDataSize() {
return CellRangeAddressList.getEncodedSize(_numberOfRegions); return CellRangeAddressList.getEncodedSize(_numberOfRegions);
} }
@Override
public short getSid() { public short getSid() {
return sid; return sid;
} }
@Override
public void serialize(LittleEndianOutput out) { public void serialize(LittleEndianOutput out) {
int nItems = _numberOfRegions; int nItems = _numberOfRegions;
out.writeShort(nItems); out.writeShort(nItems);
@ -84,6 +89,7 @@ public final class MergeCellsRecord extends StandardRecord implements Cloneable
} }
} }
@Override
public String toString() { public String toString() {
StringBuffer retval = new StringBuffer(); StringBuffer retval = new StringBuffer();

View File

@ -33,10 +33,10 @@ import org.apache.poi.util.LittleEndianOutput;
public final class MulRKRecord extends StandardRecord { public final class MulRKRecord extends StandardRecord {
public final static short sid = 0x00BD; public final static short sid = 0x00BD;
private int field_1_row; private final int field_1_row;
private short field_2_first_col; private final short field_2_first_col;
private RkRec[] field_3_rks; private final RkRec[] field_3_rks;
private short field_4_last_col; private final short field_4_last_col;
public int getRow() { public int getRow() {
return field_1_row; return field_1_row;
@ -68,6 +68,9 @@ public final class MulRKRecord extends StandardRecord {
/** /**
* returns the xf index for column (coffset = column - field_2_first_col) * returns the xf index for column (coffset = column - field_2_first_col)
*
* @param coffset the coffset = column - field_2_first_col
*
* @return the XF index for the column * @return the XF index for the column
*/ */
public short getXFAt(int coffset) { public short getXFAt(int coffset) {
@ -76,6 +79,9 @@ public final class MulRKRecord extends StandardRecord {
/** /**
* returns the rk number for column (coffset = column - field_2_first_col) * returns the rk number for column (coffset = column - field_2_first_col)
*
* @param coffset the coffset = column - field_2_first_col
*
* @return the value (decoded into a double) * @return the value (decoded into a double)
*/ */
public double getRKNumberAt(int coffset) { public double getRKNumberAt(int coffset) {
@ -93,7 +99,8 @@ public final class MulRKRecord extends StandardRecord {
} }
public String toString() { @Override
public String toString() {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append("[MULRK]\n"); buffer.append("[MULRK]\n");
@ -109,15 +116,18 @@ public final class MulRKRecord extends StandardRecord {
return buffer.toString(); return buffer.toString();
} }
public short getSid() @Override
public short getSid()
{ {
return sid; return sid;
} }
public void serialize(LittleEndianOutput out) { @Override
public void serialize(LittleEndianOutput out) {
throw new RecordFormatException( "Sorry, you can't serialize MulRK in this release"); throw new RecordFormatException( "Sorry, you can't serialize MulRK in this release");
} }
protected int getDataSize() { @Override
protected int getDataSize() {
throw new RecordFormatException( "Sorry, you can't serialize MulRK in this release"); throw new RecordFormatException( "Sorry, you can't serialize MulRK in this release");
} }

View File

@ -138,6 +138,8 @@ public final class NameCommentRecord extends StandardRecord {
/** /**
* Updates the name we're associated with, normally used * Updates the name we're associated with, normally used
* when renaming that Name * when renaming that Name
*
* @param newName the new name
*/ */
public void setNameText(String newName) { public void setNameText(String newName) {
field_6_name_text = newName; field_6_name_text = newName;

View File

@ -101,13 +101,15 @@ public final class NameRecord extends ContinuableRecord {
/** /**
* Constructor to create a built-in named region * Constructor to create a built-in named region
* @param builtin Built-in byte representation for the name record, use the public constants * @param builtin Built-in byte representation for the name record, use the public constants
* @param sheetNumber the sheet which the name applies to
*/ */
public NameRecord(byte builtin, int sheetNumber) public NameRecord(byte builtin, int sheetNumber)
{ {
this(); this();
field_12_built_in_code = builtin; field_12_built_in_code = builtin;
setOptionFlag((short)(field_1_option_flag | Option.OPT_BUILTIN)); setOptionFlag((short)(field_1_option_flag | Option.OPT_BUILTIN));
field_6_sheetNumber = sheetNumber; //the extern sheets are set through references // the extern sheets are set through references
field_6_sheetNumber = sheetNumber;
} }
/** sets the option flag for the named range /** sets the option flag for the named range
@ -272,7 +274,10 @@ public final class NameRecord extends ContinuableRecord {
return (field_1_option_flag & Option.OPT_COMPLEX) != 0; return (field_1_option_flag & Option.OPT_COMPLEX) != 0;
} }
/**Convenience Function to determine if the name is a built-in name /**
* Convenience Function to determine if the name is a built-in name
*
* @return true, if the name is a built-in name
*/ */
public boolean isBuiltInName() public boolean isBuiltInName()
{ {
@ -341,7 +346,8 @@ public final class NameRecord extends ContinuableRecord {
* *
* @param out a data output stream * @param out a data output stream
*/ */
public void serialize(ContinuableRecordOutput out) { @Override
public void serialize(ContinuableRecordOutput out) {
int field_7_length_custom_menu = field_14_custom_menu_text.length(); int field_7_length_custom_menu = field_14_custom_menu_text.length();
int field_8_length_description_text = field_15_description_text.length(); int field_8_length_description_text = field_15_description_text.length();
@ -473,7 +479,8 @@ public final class NameRecord extends ContinuableRecord {
/** /**
* return the non static version of the id for this record. * return the non static version of the id for this record.
*/ */
public short getSid() { @Override
public short getSid() {
return sid; return sid;
} }
/* /*
@ -527,7 +534,8 @@ public final class NameRecord extends ContinuableRecord {
3B 00 00 07 00 07 00 00 00 FF 00 ] 3B 00 00 07 00 07 00 00 00 FF 00 ]
*/ */
public String toString() { @Override
public String toString() {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append("[NAME]\n"); sb.append("[NAME]\n");
@ -544,8 +552,7 @@ public final class NameRecord extends ContinuableRecord {
sb.append(" .Name (Unicode text) = ").append( getNameText() ).append("\n"); sb.append(" .Name (Unicode text) = ").append( getNameText() ).append("\n");
Ptg[] ptgs = field_13_name_definition.getTokens(); Ptg[] ptgs = field_13_name_definition.getTokens();
sb.append(" .Formula (nTokens=").append(ptgs.length).append("):") .append("\n"); sb.append(" .Formula (nTokens=").append(ptgs.length).append("):") .append("\n");
for (int i = 0; i < ptgs.length; i++) { for (Ptg ptg : ptgs) {
Ptg ptg = ptgs[i];
sb.append(" " + ptg.toString()).append(ptg.getRVAType()).append("\n"); sb.append(" " + ptg.toString()).append(ptg.getRVAType()).append("\n");
} }

View File

@ -73,6 +73,8 @@ public final class NoteRecord extends StandardRecord implements Cloneable {
/** /**
* Read the record data from the supplied <code>RecordInputStream</code> * Read the record data from the supplied <code>RecordInputStream</code>
*
* @param in the RecordInputStream to read from
*/ */
public NoteRecord(RecordInputStream in) { public NoteRecord(RecordInputStream in) {
field_1_row = in.readUShort(); field_1_row = in.readUShort();
@ -195,6 +197,8 @@ public final class NoteRecord extends StandardRecord implements Cloneable {
/** /**
* For unit testing only! * For unit testing only!
*
* @return true, if author element uses multi byte
*/ */
protected boolean authorIsMultibyte() { protected boolean authorIsMultibyte() {
return field_5_hasMultibyte; return field_5_hasMultibyte;
@ -202,6 +206,8 @@ public final class NoteRecord extends StandardRecord implements Cloneable {
/** /**
* Object id for OBJ record that contains the comment * Object id for OBJ record that contains the comment
*
* @return the Object id for OBJ record that contains the comment
*/ */
public int getShapeId() { public int getShapeId() {
return field_4_shapeid; return field_4_shapeid;
@ -209,6 +215,8 @@ public final class NoteRecord extends StandardRecord implements Cloneable {
/** /**
* Object id for OBJ record that contains the comment * Object id for OBJ record that contains the comment
*
* @param id the Object id for OBJ record that contains the comment
*/ */
public void setShapeId(int id) { public void setShapeId(int id) {
field_4_shapeid = id; field_4_shapeid = id;

View File

@ -45,6 +45,9 @@ public final class NoteStructureSubRecord extends SubRecord implements Cloneable
/** /**
* Read the record data from the supplied <code>RecordInputStream</code> * Read the record data from the supplied <code>RecordInputStream</code>
*
* @param in the input to read from
* @param size the provided size - must be 22
*/ */
public NoteStructureSubRecord(LittleEndianInput in, int size) { public NoteStructureSubRecord(LittleEndianInput in, int size) {
if (size != ENCODED_SIZE) { if (size != ENCODED_SIZE) {
@ -60,6 +63,7 @@ public final class NoteStructureSubRecord extends SubRecord implements Cloneable
* Convert this record to string. * Convert this record to string.
* Used by BiffViewer and other utilities. * Used by BiffViewer and other utilities.
*/ */
@Override
public String toString() public String toString()
{ {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
@ -76,13 +80,15 @@ public final class NoteStructureSubRecord extends SubRecord implements Cloneable
* *
* @param out the stream to serialize into * @param out the stream to serialize into
*/ */
@Override
public void serialize(LittleEndianOutput out) { public void serialize(LittleEndianOutput out) {
out.writeShort(sid); out.writeShort(sid);
out.writeShort(reserved.length); out.writeShort(reserved.length);
out.write(reserved); out.write(reserved);
} }
protected int getDataSize() { @Override
protected int getDataSize() {
return reserved.length; return reserved.length;
} }

View File

@ -25,10 +25,10 @@ import org.apache.poi.util.HexDump;
* Subclasses are expected to manage the cell data values (of various types). * Subclasses are expected to manage the cell data values (of various types).
*/ */
public abstract class OldCellRecord { public abstract class OldCellRecord {
private short sid; private final short sid;
private boolean isBiff2; private final boolean isBiff2;
private int field_1_row; private final int field_1_row;
private short field_2_column; private final short field_2_column;
private int field_3_cell_attrs; // Biff 2 private int field_3_cell_attrs; // Biff 2
private short field_3_xf_index; // Biff 3+ private short field_3_xf_index; // Biff 3+
@ -63,6 +63,7 @@ public abstract class OldCellRecord {
public final short getXFIndex() { public final short getXFIndex() {
return field_3_xf_index; return field_3_xf_index;
} }
public int getCellAttrs() public int getCellAttrs()
{ {
return field_3_cell_attrs; return field_3_cell_attrs;
@ -70,10 +71,13 @@ public abstract class OldCellRecord {
/** /**
* Is this a Biff2 record, or newer? * Is this a Biff2 record, or newer?
*
* @return true, if this is a Biff2 record or newer
*/ */
public boolean isBiff2() { public boolean isBiff2() {
return isBiff2; return isBiff2;
} }
public short getSid() { public short getSid() {
return sid; return sid;
} }
@ -101,11 +105,15 @@ public abstract class OldCellRecord {
* Append specific debug info (used by {@link #toString()} for the value * Append specific debug info (used by {@link #toString()} for the value
* contained in this record. Trailing new-line should not be appended * contained in this record. Trailing new-line should not be appended
* (superclass does that). * (superclass does that).
*
* @param sb the StringBuilder to append to
*/ */
protected abstract void appendValueText(StringBuilder sb); protected abstract void appendValueText(StringBuilder sb);
/** /**
* Gets the debug info BIFF record type name (used by {@link #toString()}. * Gets the debug info BIFF record type name (used by {@link #toString()}.
*
* @return the debug info BIFF record type name
*/ */
protected abstract String getRecordName(); protected abstract String getRecordName();
} }

View File

@ -33,7 +33,7 @@ public final class OldLabelRecord extends OldCellRecord {
public final static short biff345_sid = 0x0204; public final static short biff345_sid = 0x0204;
private short field_4_string_len; private short field_4_string_len;
private byte[] field_5_bytes; private final byte[] field_5_bytes;
private CodepageRecord codepage; private CodepageRecord codepage;
/** /**
@ -76,6 +76,8 @@ public final class OldLabelRecord extends OldCellRecord {
/** /**
* Get the String of the cell * Get the String of the cell
*
* @return the String of the cell
*/ */
public String getValue() public String getValue()
{ {
@ -84,19 +86,26 @@ public final class OldLabelRecord extends OldCellRecord {
/** /**
* Not supported * Not supported
*
* @param offset not supported
* @param data not supported
* @return not supported
*/ */
public int serialize(int offset, byte [] data) { public int serialize(int offset, byte [] data) {
throw new RecordFormatException("Old Label Records are supported READ ONLY"); throw new RecordFormatException("Old Label Records are supported READ ONLY");
} }
public int getRecordSize() { public int getRecordSize() {
throw new RecordFormatException("Old Label Records are supported READ ONLY"); throw new RecordFormatException("Old Label Records are supported READ ONLY");
} }
@Override
protected void appendValueText(StringBuilder sb) { protected void appendValueText(StringBuilder sb) {
sb.append(" .string_len= ").append(HexDump.shortToHex(field_4_string_len)).append("\n"); sb.append(" .string_len= ").append(HexDump.shortToHex(field_4_string_len)).append("\n");
sb.append(" .value = ").append(getValue()).append("\n"); sb.append(" .value = ").append(getValue()).append("\n");
} }
@Override
protected String getRecordName() { protected String getRecordName() {
return "OLD LABEL"; return "OLD LABEL";
} }

View File

@ -40,8 +40,8 @@ public final class PaletteRecord extends StandardRecord {
public PaletteRecord() { public PaletteRecord() {
PColor[] defaultPalette = createDefaultPalette(); PColor[] defaultPalette = createDefaultPalette();
_colors = new ArrayList<PColor>(defaultPalette.length); _colors = new ArrayList<PColor>(defaultPalette.length);
for (int i = 0; i < defaultPalette.length; i++) { for (PColor element : defaultPalette) {
_colors.add(defaultPalette[i]); _colors.add(element);
} }
} }
@ -53,6 +53,7 @@ public final class PaletteRecord extends StandardRecord {
} }
} }
@Override
public String toString() { public String toString() {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
@ -68,6 +69,7 @@ public final class PaletteRecord extends StandardRecord {
return buffer.toString(); return buffer.toString();
} }
@Override
public void serialize(LittleEndianOutput out) { public void serialize(LittleEndianOutput out) {
out.writeShort(_colors.size()); out.writeShort(_colors.size());
for (int i = 0; i < _colors.size(); i++) { for (int i = 0; i < _colors.size(); i++) {
@ -75,16 +77,20 @@ public final class PaletteRecord extends StandardRecord {
} }
} }
@Override
protected int getDataSize() { protected int getDataSize() {
return 2 + _colors.size() * PColor.ENCODED_SIZE; return 2 + _colors.size() * PColor.ENCODED_SIZE;
} }
@Override
public short getSid() { public short getSid() {
return sid; return sid;
} }
/** /**
* Returns the color value at a given index * Returns the color value at a given index
*
* @param byteIndex palette index, must be &gt;= 0x8
* *
* @return the RGB triplet for the color, or <code>null</code> if the specified index * @return the RGB triplet for the color, or <code>null</code> if the specified index
* does not exist * does not exist
@ -105,6 +111,9 @@ public final class PaletteRecord extends StandardRecord {
* *
* @param byteIndex the index to set; if this index is less than 0x8 or greater than * @param byteIndex the index to set; if this index is less than 0x8 or greater than
* 0x40, then no modification is made * 0x40, then no modification is made
* @param red the red color part
* @param green the green color part
* @param blue the blue color part
*/ */
public void setColor(short byteIndex, byte red, byte green, byte blue) public void setColor(short byteIndex, byte red, byte green, byte blue)
{ {
@ -195,9 +204,9 @@ public final class PaletteRecord extends StandardRecord {
*/ */
private static final class PColor { private static final class PColor {
public static final short ENCODED_SIZE = 4; public static final short ENCODED_SIZE = 4;
private int _red; private final int _red;
private int _green; private final int _green;
private int _blue; private final int _blue;
public PColor(int red, int green, int blue) { public PColor(int red, int green, int blue) {
_red = red; _red = red;
@ -223,6 +232,7 @@ public final class PaletteRecord extends StandardRecord {
out.writeByte(0); out.writeByte(0);
} }
@Override
public String toString() { public String toString() {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append(" red = ").append(_red & 0xff).append('\n'); buffer.append(" red = ").append(_red & 0xff).append('\n');

View File

@ -51,6 +51,7 @@ public final class PaneRecord extends StandardRecord {
field_5_activePane = in.readShort(); field_5_activePane = in.readShort();
} }
@Override
public String toString() public String toString()
{ {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
@ -81,6 +82,7 @@ public final class PaneRecord extends StandardRecord {
return buffer.toString(); return buffer.toString();
} }
@Override
public void serialize(LittleEndianOutput out) { public void serialize(LittleEndianOutput out) {
out.writeShort(field_1_x); out.writeShort(field_1_x);
out.writeShort(field_2_y); out.writeShort(field_2_y);
@ -89,15 +91,18 @@ public final class PaneRecord extends StandardRecord {
out.writeShort(field_5_activePane); out.writeShort(field_5_activePane);
} }
@Override
protected int getDataSize() { protected int getDataSize() {
return 2 + 2 + 2 + 2 + 2; return 2 + 2 + 2 + 2 + 2;
} }
@Override
public short getSid() public short getSid()
{ {
return sid; return sid;
} }
@Override
public Object clone() { public Object clone() {
PaneRecord rec = new PaneRecord(); PaneRecord rec = new PaneRecord();
@ -109,11 +114,10 @@ public final class PaneRecord extends StandardRecord {
return rec; return rec;
} }
/** /**
* Get the x field for the Pane record. * Get the x field for the Pane record.
*
* @param the x value
*/ */
public short getX() public short getX()
{ {
@ -122,6 +126,8 @@ public final class PaneRecord extends StandardRecord {
/** /**
* Set the x field for the Pane record. * Set the x field for the Pane record.
*
* @param field_1_x the x value
*/ */
public void setX(short field_1_x) public void setX(short field_1_x)
{ {
@ -130,6 +136,8 @@ public final class PaneRecord extends StandardRecord {
/** /**
* Get the y field for the Pane record. * Get the y field for the Pane record.
*
* @return the y value
*/ */
public short getY() public short getY()
{ {
@ -138,6 +146,8 @@ public final class PaneRecord extends StandardRecord {
/** /**
* Set the y field for the Pane record. * Set the y field for the Pane record.
*
* @param field_2_y the y value
*/ */
public void setY(short field_2_y) public void setY(short field_2_y)
{ {
@ -146,6 +156,8 @@ public final class PaneRecord extends StandardRecord {
/** /**
* Get the top row field for the Pane record. * Get the top row field for the Pane record.
*
* @return the top row
*/ */
public short getTopRow() public short getTopRow()
{ {
@ -154,6 +166,8 @@ public final class PaneRecord extends StandardRecord {
/** /**
* Set the top row field for the Pane record. * Set the top row field for the Pane record.
*
* @param field_3_topRow the top row
*/ */
public void setTopRow(short field_3_topRow) public void setTopRow(short field_3_topRow)
{ {
@ -162,6 +176,8 @@ public final class PaneRecord extends StandardRecord {
/** /**
* Get the left column field for the Pane record. * Get the left column field for the Pane record.
*
* @return the left column
*/ */
public short getLeftColumn() public short getLeftColumn()
{ {
@ -170,6 +186,8 @@ public final class PaneRecord extends StandardRecord {
/** /**
* Set the left column field for the Pane record. * Set the left column field for the Pane record.
*
* @param field_4_leftColumn the left column
*/ */
public void setLeftColumn(short field_4_leftColumn) public void setLeftColumn(short field_4_leftColumn)
{ {

View File

@ -26,7 +26,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
@ -78,6 +77,7 @@ public final class RecordFactory {
public ReflectionConstructorRecordCreator(Constructor<? extends Record> c) { public ReflectionConstructorRecordCreator(Constructor<? extends Record> c) {
_c = c; _c = c;
} }
@Override
public Record create(RecordInputStream in) { public Record create(RecordInputStream in) {
Object[] args = { in, }; Object[] args = { in, };
try { try {
@ -99,6 +99,7 @@ public final class RecordFactory {
} }
} }
} }
@Override
public Class<? extends Record> getRecordClass() { public Class<? extends Record> getRecordClass() {
return _c.getDeclaringClass(); return _c.getDeclaringClass();
} }
@ -112,6 +113,7 @@ public final class RecordFactory {
public ReflectionMethodRecordCreator(Method m) { public ReflectionMethodRecordCreator(Method m) {
_m = m; _m = m;
} }
@Override
public Record create(RecordInputStream in) { public Record create(RecordInputStream in) {
Object[] args = { in, }; Object[] args = { in, };
try { try {
@ -124,6 +126,7 @@ public final class RecordFactory {
throw new RecordFormatException("Unable to construct record instance" , e.getTargetException()); throw new RecordFormatException("Unable to construct record instance" , e.getTargetException());
} }
} }
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Class<? extends Record> getRecordClass() { public Class<? extends Record> getRecordClass() {
return (Class<? extends Record>) _m.getDeclaringClass(); return (Class<? extends Record>) _m.getDeclaringClass();
@ -292,9 +295,13 @@ public final class RecordFactory {
/** /**
* Debug / diagnosis method<p> * Debug / diagnosis method<p>
* Gets the POI implementation class for a given {@code sid}. Only a subset of the any BIFF *
* Gets the POI implementation class for a given {@code sid}. Only a subset of the BIFF
* records are actually interpreted by POI. A few others are known but not interpreted * records are actually interpreted by POI. A few others are known but not interpreted
* (see {@link UnknownRecord#getBiffName(int)}). * (see {@link UnknownRecord#getBiffName(int)}).
*
* @param sid the record sid
*
* @return the POI implementation class for the specified record {@code sid}. * @return the POI implementation class for the specified record {@code sid}.
* {@code null} if the specified record is not interpreted by POI. * {@code null} if the specified record is not interpreted by POI.
*/ */
@ -305,9 +312,13 @@ public final class RecordFactory {
} }
return rc.getRecordClass(); return rc.getRecordClass();
} }
/** /**
* create a record, if there are MUL records than multiple records * create a record, if there are MUL records than multiple records
* are returned digested into the non-mul form. * are returned digested into the non-mul form.
*
* @param in the RecordInputStream to read from
* @return the extracted records
*/ */
public static Record [] createRecord(RecordInputStream in) { public static Record [] createRecord(RecordInputStream in) {
Record record = createSingleRecord(in); Record record = createSingleRecord(in);
@ -337,6 +348,9 @@ public final class RecordFactory {
/** /**
* RK record is a slightly smaller alternative to NumberRecord * RK record is a slightly smaller alternative to NumberRecord
* POI likes NumberRecord better * POI likes NumberRecord better
*
* @param the RK record to convert
* @return the NumberRecord
*/ */
public static NumberRecord convertToNumberRecord(RKRecord rk) { public static NumberRecord convertToNumberRecord(RKRecord rk) {
NumberRecord num = new NumberRecord(); NumberRecord num = new NumberRecord();
@ -349,7 +363,10 @@ public final class RecordFactory {
} }
/** /**
* Converts a {@link MulRKRecord} into an equivalent array of {@link NumberRecord}s * Converts a {@link MulRKRecord} into an equivalent array of {@link NumberRecord NumberRecords}
*
* @param mrk the MulRKRecord to convert
* @return the equivalent array of {@link NumberRecord NumberRecords}
*/ */
public static NumberRecord[] convertRKRecords(MulRKRecord mrk) { public static NumberRecord[] convertRKRecords(MulRKRecord mrk) {
NumberRecord[] mulRecs = new NumberRecord[mrk.getNumColumns()]; NumberRecord[] mulRecs = new NumberRecord[mrk.getNumColumns()];
@ -366,7 +383,10 @@ public final class RecordFactory {
} }
/** /**
* Converts a {@link MulBlankRecord} into an equivalent array of {@link BlankRecord}s * Converts a {@link MulBlankRecord} into an equivalent array of {@link BlankRecord BlankRecords}
*
* @param mbk the MulBlankRecord to convert
* @return the equivalent array of {@link BlankRecord BlankRecords}
*/ */
public static BlankRecord[] convertBlankRecords(MulBlankRecord mbk) { public static BlankRecord[] convertBlankRecords(MulBlankRecord mbk) {
BlankRecord[] mulRecs = new BlankRecord[mbk.getNumColumns()]; BlankRecord[] mulRecs = new BlankRecord[mbk.getNumColumns()];
@ -389,9 +409,7 @@ public final class RecordFactory {
short[] results = new short[ _recordCreatorsById.size() ]; short[] results = new short[ _recordCreatorsById.size() ];
int i = 0; int i = 0;
for (Iterator<Integer> iterator = _recordCreatorsById.keySet().iterator(); iterator.hasNext(); ) { for (Integer sid : _recordCreatorsById.keySet()) {
Integer sid = iterator.next();
results[i++] = sid.shortValue(); results[i++] = sid.shortValue();
} }
Arrays.sort(results); Arrays.sort(results);
@ -410,9 +428,7 @@ public final class RecordFactory {
Map<Integer, I_RecordCreator> result = new HashMap<Integer, I_RecordCreator>(); Map<Integer, I_RecordCreator> result = new HashMap<Integer, I_RecordCreator>();
Set<Class<?>> uniqueRecClasses = new HashSet<Class<?>>(records.length * 3 / 2); Set<Class<?>> uniqueRecClasses = new HashSet<Class<?>>(records.length * 3 / 2);
for (int i = 0; i < records.length; i++) { for (Class<? extends Record> recClass : records) {
Class<? extends Record> recClass = records[ i ];
if(!Record.class.isAssignableFrom(recClass)) { if(!Record.class.isAssignableFrom(recClass)) {
throw new RuntimeException("Invalid record sub-class (" + recClass.getName() + ")"); throw new RuntimeException("Invalid record sub-class (" + recClass.getName() + ")");
} }
@ -433,7 +449,7 @@ public final class RecordFactory {
Integer key = Integer.valueOf(sid); Integer key = Integer.valueOf(sid);
if (result.containsKey(key)) { if (result.containsKey(key)) {
Class<?> prevClass = result.get(key).getRecordClass(); Class<?> prevClass = result.get(key).getRecordClass();
throw new RuntimeException("duplicate record sid 0x" + throw new RuntimeException("duplicate record sid 0x" +
Integer.toHexString(sid).toUpperCase(Locale.ROOT) Integer.toHexString(sid).toUpperCase(Locale.ROOT)
+ " for classes (" + recClass.getName() + ") and (" + " for classes (" + recClass.getName() + ") and ("
+ prevClass.getName() + ")"); + prevClass.getName() + ")");

View File

@ -193,6 +193,8 @@ public final class RecordFactoryInputStream {
/** /**
* @param in the InputStream to read from
*
* @param shouldIncludeContinueRecords caller can pass <code>false</code> if loose * @param shouldIncludeContinueRecords caller can pass <code>false</code> if loose
* {@link ContinueRecord}s should be skipped (this is sometimes useful in event based * {@link ContinueRecord}s should be skipped (this is sometimes useful in event based
* processing). * processing).
@ -238,8 +240,7 @@ public final class RecordFactoryInputStream {
} }
/** /**
* Returns the next (complete) record from the * @return the next (complete) record from the stream, or null if there are no more.
* stream, or null if there are no more.
*/ */
public Record nextRecord() { public Record nextRecord() {
Record r; Record r;

View File

@ -25,6 +25,7 @@ import org.apache.poi.hssf.dev.BiffViewer;
import org.apache.poi.hssf.record.crypto.Biff8DecryptingStream; import org.apache.poi.hssf.record.crypto.Biff8DecryptingStream;
import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey; import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.LittleEndianInput; import org.apache.poi.util.LittleEndianInput;
import org.apache.poi.util.LittleEndianInputStream; import org.apache.poi.util.LittleEndianInputStream;
@ -98,13 +99,16 @@ public final class RecordInputStream implements LittleEndianInput {
public SimpleHeaderInput(InputStream in) { public SimpleHeaderInput(InputStream in) {
_lei = getLEI(in); _lei = getLEI(in);
} }
public int available() { @Override
public int available() {
return _lei.available(); return _lei.available();
} }
public int readDataSize() { @Override
public int readDataSize() {
return _lei.readUShort(); return _lei.readUShort();
} }
public int readRecordSID() { @Override
public int readRecordSID() {
return _lei.readUShort(); return _lei.readUShort();
} }
} }
@ -138,7 +142,8 @@ public final class RecordInputStream implements LittleEndianInput {
* @return the number of bytes available in the current BIFF record * @return the number of bytes available in the current BIFF record
* @see #remaining() * @see #remaining()
*/ */
public int available() { @Override
public int available() {
return remaining(); return remaining();
} }
@ -158,6 +163,9 @@ public final class RecordInputStream implements LittleEndianInput {
/** /**
* Note - this method is expected to be called only when completed reading the current BIFF * Note - this method is expected to be called only when completed reading the current BIFF
* record. * record.
*
* @return true, if there's another record in the stream
*
* @throws LeftoverDataException if this method is called before reaching the end of the * @throws LeftoverDataException if this method is called before reaching the end of the
* current record. * current record.
*/ */
@ -230,56 +238,63 @@ public final class RecordInputStream implements LittleEndianInput {
/** /**
* Reads an 8 bit, signed value * Reads an 8 bit, signed value
*/ */
public byte readByte() { @Override
checkRecordPosition(LittleEndian.BYTE_SIZE); public byte readByte() {
_currentDataOffset += LittleEndian.BYTE_SIZE; checkRecordPosition(LittleEndianConsts.BYTE_SIZE);
_currentDataOffset += LittleEndianConsts.BYTE_SIZE;
return _dataInput.readByte(); return _dataInput.readByte();
} }
/** /**
* Reads a 16 bit, signed value * Reads a 16 bit, signed value
*/ */
public short readShort() { @Override
checkRecordPosition(LittleEndian.SHORT_SIZE); public short readShort() {
_currentDataOffset += LittleEndian.SHORT_SIZE; checkRecordPosition(LittleEndianConsts.SHORT_SIZE);
_currentDataOffset += LittleEndianConsts.SHORT_SIZE;
return _dataInput.readShort(); return _dataInput.readShort();
} }
/** /**
* Reads a 32 bit, signed value * Reads a 32 bit, signed value
*/ */
public int readInt() { @Override
checkRecordPosition(LittleEndian.INT_SIZE); public int readInt() {
_currentDataOffset += LittleEndian.INT_SIZE; checkRecordPosition(LittleEndianConsts.INT_SIZE);
_currentDataOffset += LittleEndianConsts.INT_SIZE;
return _dataInput.readInt(); return _dataInput.readInt();
} }
/** /**
* Reads a 64 bit, signed value * Reads a 64 bit, signed value
*/ */
public long readLong() { @Override
checkRecordPosition(LittleEndian.LONG_SIZE); public long readLong() {
_currentDataOffset += LittleEndian.LONG_SIZE; checkRecordPosition(LittleEndianConsts.LONG_SIZE);
_currentDataOffset += LittleEndianConsts.LONG_SIZE;
return _dataInput.readLong(); return _dataInput.readLong();
} }
/** /**
* Reads an 8 bit, unsigned value * Reads an 8 bit, unsigned value
*/ */
public int readUByte() { @Override
public int readUByte() {
return readByte() & 0x00FF; return readByte() & 0x00FF;
} }
/** /**
* Reads a 16 bit, unsigned value. * Reads a 16 bit, unsigned value.
*/ */
public int readUShort() { @Override
checkRecordPosition(LittleEndian.SHORT_SIZE); public int readUShort() {
_currentDataOffset += LittleEndian.SHORT_SIZE; checkRecordPosition(LittleEndianConsts.SHORT_SIZE);
_currentDataOffset += LittleEndianConsts.SHORT_SIZE;
return _dataInput.readUShort(); return _dataInput.readUShort();
} }
public double readDouble() { @Override
public double readDouble() {
long valueLongBits = readLong(); long valueLongBits = readLong();
double result = Double.longBitsToDouble(valueLongBits); double result = Double.longBitsToDouble(valueLongBits);
if (Double.isNaN(result)) { if (Double.isNaN(result)) {
@ -290,11 +305,13 @@ public final class RecordInputStream implements LittleEndianInput {
} }
return result; return result;
} }
public void readFully(byte[] buf) { @Override
public void readFully(byte[] buf) {
readFully(buf, 0, buf.length); readFully(buf, 0, buf.length);
} }
public void readFully(byte[] buf, int off, int len) { @Override
public void readFully(byte[] buf, int off, int len) {
int origLen = len; int origLen = len;
if (buf == null) { if (buf == null) {
throw new NullPointerException(); throw new NullPointerException();
@ -355,7 +372,7 @@ public final class RecordInputStream implements LittleEndianInput {
boolean isCompressedEncoding = pIsCompressedEncoding; boolean isCompressedEncoding = pIsCompressedEncoding;
int curLen = 0; int curLen = 0;
while(true) { while(true) {
int availableChars =isCompressedEncoding ? remaining() : remaining() / LittleEndian.SHORT_SIZE; int availableChars =isCompressedEncoding ? remaining() : remaining() / LittleEndianConsts.SHORT_SIZE;
if (requestedLength - curLen <= availableChars) { if (requestedLength - curLen <= availableChars) {
// enough space in current record, so just read it out // enough space in current record, so just read it out
while(curLen < requestedLength) { while(curLen < requestedLength) {
@ -412,27 +429,30 @@ public final class RecordInputStream implements LittleEndianInput {
return result; return result;
} }
/** Reads all byte data for the current record, including any /**
* that overlaps into any following continue records. * Reads all byte data for the current record, including any that overlaps
* * into any following continue records.
* @deprecated POI 2.0 Best to write a input stream that wraps this one where there is *
* special sub record that may overlap continue records. * @return all byte data for the current record
*/ *
public byte[] readAllContinuedRemainder() { * @deprecated POI 2.0 Best to write a input stream that wraps this one
//Using a ByteArrayOutputStream is just an easy way to get a * where there is special sub record that may overlap continue
//growable array of the data. * records.
ByteArrayOutputStream out = new ByteArrayOutputStream(2*MAX_RECORD_DATA_SIZE); */
@Deprecated
public byte[] readAllContinuedRemainder() {
ByteArrayOutputStream out = new ByteArrayOutputStream(2 * MAX_RECORD_DATA_SIZE);
while (true) { while (true) {
byte[] b = readRemainder(); byte[] b = readRemainder();
out.write(b, 0, b.length); out.write(b, 0, b.length);
if (!isContinueNext()) { if (!isContinueNext()) {
break; break;
} }
nextRecord(); nextRecord();
}
return out.toByteArray();
} }
return out.toByteArray();
}
/** The remaining number of bytes in the <i>current</i> record. /** The remaining number of bytes in the <i>current</i> record.
* *

View File

@ -41,6 +41,7 @@ public final class SCLRecord extends StandardRecord {
field_2_denominator = in.readShort(); field_2_denominator = in.readShort();
} }
@Override
public String toString() public String toString()
{ {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
@ -59,20 +60,24 @@ public final class SCLRecord extends StandardRecord {
return buffer.toString(); return buffer.toString();
} }
@Override
public void serialize(LittleEndianOutput out) { public void serialize(LittleEndianOutput out) {
out.writeShort(field_1_numerator); out.writeShort(field_1_numerator);
out.writeShort(field_2_denominator); out.writeShort(field_2_denominator);
} }
@Override
protected int getDataSize() { protected int getDataSize() {
return 2 + 2; return 2 + 2;
} }
@Override
public short getSid() public short getSid()
{ {
return sid; return sid;
} }
@Override
public Object clone() { public Object clone() {
SCLRecord rec = new SCLRecord(); SCLRecord rec = new SCLRecord();
@ -81,11 +86,10 @@ public final class SCLRecord extends StandardRecord {
return rec; return rec;
} }
/** /**
* Get the numerator field for the SCL record. * Get the numerator field for the SCL record.
*
* @return the numerator
*/ */
public short getNumerator() public short getNumerator()
{ {
@ -94,6 +98,8 @@ public final class SCLRecord extends StandardRecord {
/** /**
* Set the numerator field for the SCL record. * Set the numerator field for the SCL record.
*
* @param field_1_numerator the numerator
*/ */
public void setNumerator(short field_1_numerator) public void setNumerator(short field_1_numerator)
{ {
@ -102,6 +108,8 @@ public final class SCLRecord extends StandardRecord {
/** /**
* Get the denominator field for the SCL record. * Get the denominator field for the SCL record.
*
* @return the denominator
*/ */
public short getDenominator() public short getDenominator()
{ {
@ -110,6 +118,8 @@ public final class SCLRecord extends StandardRecord {
/** /**
* Set the denominator field for the SCL record. * Set the denominator field for the SCL record.
*
* @param field_2_denominator the denominator
*/ */
public void setDenominator(short field_2_denominator) public void setDenominator(short field_2_denominator)
{ {

View File

@ -26,10 +26,7 @@ import org.apache.poi.util.LittleEndianOutput;
* Description: shows the user's selection on the sheet * Description: shows the user's selection on the sheet
* for write set num refs to 0<P> * for write set num refs to 0<P>
* *
* REFERENCE: PG 291 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P> * REFERENCE: PG 291 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)
* @author Andrew C. Oliver (acoliver at apache dot org)
* @author Jason Height (jheight at chariot dot net dot au)
* @author Glen Stampoultzis (glens at apache.org)
*/ */
public final class SelectionRecord extends StandardRecord { public final class SelectionRecord extends StandardRecord {
public final static short sid = 0x001D; public final static short sid = 0x001D;
@ -41,6 +38,9 @@ public final class SelectionRecord extends StandardRecord {
/** /**
* Creates a default selection record (cell A1, in pane ID 3) * Creates a default selection record (cell A1, in pane ID 3)
*
* @param activeCellRow the active cells row index
* @param activeCellCol the active cells column index
*/ */
public SelectionRecord(int activeCellRow, int activeCellCol) { public SelectionRecord(int activeCellRow, int activeCellCol) {
field_1_pane = 3; // pane id 3 is always present. see OOO sec 5.75 'PANE' field_1_pane = 3; // pane id 3 is always present. see OOO sec 5.75 'PANE'
@ -67,6 +67,7 @@ public final class SelectionRecord extends StandardRecord {
/** /**
* set which window pane this is for * set which window pane this is for
* @param pane the window pane
*/ */
public void setPane(byte pane) { public void setPane(byte pane) {
field_1_pane = pane; field_1_pane = pane;
@ -127,6 +128,7 @@ public final class SelectionRecord extends StandardRecord {
return field_4_active_cell_ref_index; return field_4_active_cell_ref_index;
} }
@Override
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
@ -139,10 +141,12 @@ public final class SelectionRecord extends StandardRecord {
sb.append("[/SELECTION]\n"); sb.append("[/SELECTION]\n");
return sb.toString(); return sb.toString();
} }
@Override
protected int getDataSize() { protected int getDataSize() {
return 9 // 1 byte + 4 shorts return 9 // 1 byte + 4 shorts
+ CellRangeAddress8Bit.getEncodedSize(field_6_refs.length); + CellRangeAddress8Bit.getEncodedSize(field_6_refs.length);
} }
@Override
public void serialize(LittleEndianOutput out) { public void serialize(LittleEndianOutput out) {
out.writeByte(getPane()); out.writeByte(getPane());
out.writeShort(getActiveCellRow()); out.writeShort(getActiveCellRow());
@ -150,15 +154,17 @@ public final class SelectionRecord extends StandardRecord {
out.writeShort(getActiveCellRef()); out.writeShort(getActiveCellRef());
int nRefs = field_6_refs.length; int nRefs = field_6_refs.length;
out.writeShort(nRefs); out.writeShort(nRefs);
for (int i = 0; i < field_6_refs.length; i++) { for (CellRangeAddress8Bit field_6_ref : field_6_refs) {
field_6_refs[i].serialize(out); field_6_ref.serialize(out);
} }
} }
@Override
public short getSid() { public short getSid() {
return sid; return sid;
} }
@Override
public Object clone() { public Object clone() {
SelectionRecord rec = new SelectionRecord(field_2_row_active_cell, field_3_col_active_cell); SelectionRecord rec = new SelectionRecord(field_2_row_active_cell, field_3_col_active_cell);
rec.field_1_pane = field_1_pane; rec.field_1_pane = field_1_pane;

View File

@ -66,8 +66,8 @@ public final class PageSettingsBlock extends RecordAggregate {
@Override @Override
public void visitContainedRecords(RecordVisitor rv) { public void visitContainedRecords(RecordVisitor rv) {
rv.visitRecord(_pls); rv.visitRecord(_pls);
for (int i = 0; i < _plsContinues.length; i++) { for (ContinueRecord _plsContinue : _plsContinues) {
rv.visitRecord(_plsContinues[i]); rv.visitRecord(_plsContinue);
} }
} }
} }
@ -93,7 +93,7 @@ public final class PageSettingsBlock extends RecordAggregate {
* The indicator of such records is a non-zero GUID, * The indicator of such records is a non-zero GUID,
* see {@link org.apache.poi.hssf.record.HeaderFooterRecord#getGuid()} * see {@link org.apache.poi.hssf.record.HeaderFooterRecord#getGuid()}
*/ */
private List<HeaderFooterRecord> _sviewHeaderFooters = new ArrayList<HeaderFooterRecord>(); private final List<HeaderFooterRecord> _sviewHeaderFooters = new ArrayList<HeaderFooterRecord>();
private Record _printSize; private Record _printSize;
public PageSettingsBlock(RecordStream rs) { public PageSettingsBlock(RecordStream rs) {
@ -120,6 +120,8 @@ public final class PageSettingsBlock extends RecordAggregate {
} }
/** /**
* @param sid the record sid
*
* @return <code>true</code> if the specified Record sid is one belonging to the * @return <code>true</code> if the specified Record sid is one belonging to the
* 'Page Settings Block'. * 'Page Settings Block'.
*/ */
@ -205,8 +207,9 @@ public final class PageSettingsBlock extends RecordAggregate {
case HeaderFooterRecord.sid: case HeaderFooterRecord.sid:
//there can be multiple HeaderFooterRecord records belonging to different sheet views //there can be multiple HeaderFooterRecord records belonging to different sheet views
HeaderFooterRecord hf = (HeaderFooterRecord)rs.getNext(); HeaderFooterRecord hf = (HeaderFooterRecord)rs.getNext();
if(hf.isCurrentSheet()) _headerFooter = hf; if(hf.isCurrentSheet()) {
else { _headerFooter = hf;
} else {
_sviewHeaderFooters.add(hf); _sviewHeaderFooters.add(hf);
} }
break; break;
@ -242,6 +245,9 @@ public final class PageSettingsBlock extends RecordAggregate {
/** /**
* Sets a page break at the indicated column * Sets a page break at the indicated column
* *
* @param column the column to add page breaks to
* @param fromRow the starting row
* @param toRow the ending row
*/ */
public void setColumnBreak(short column, short fromRow, short toRow) { public void setColumnBreak(short column, short fromRow, short toRow) {
getColumnBreaksRecord().addBreak(column, fromRow, toRow); getColumnBreaksRecord().addBreak(column, fromRow, toRow);
@ -250,6 +256,7 @@ public final class PageSettingsBlock extends RecordAggregate {
/** /**
* Removes a page break at the indicated column * Removes a page break at the indicated column
* *
* @param column the column to check for page breaks
*/ */
public void removeColumnBreak(int column) { public void removeColumnBreak(int column) {
getColumnBreaksRecord().removeBreak(column); getColumnBreaksRecord().removeBreak(column);
@ -258,6 +265,7 @@ public final class PageSettingsBlock extends RecordAggregate {
@Override
public void visitContainedRecords(RecordVisitor rv) { public void visitContainedRecords(RecordVisitor rv) {
// Replicates record order from Excel 2007, though this is not critical // Replicates record order from Excel 2007, though this is not critical
@ -481,8 +489,9 @@ public final class PageSettingsBlock extends RecordAggregate {
int breakLocation = breakItem.main; int breakLocation = breakItem.main;
boolean inStart = (breakLocation >= start); boolean inStart = (breakLocation >= start);
boolean inEnd = (breakLocation <= stop); boolean inEnd = (breakLocation <= stop);
if(inStart && inEnd) if(inStart && inEnd) {
shiftedBreak.add(breakItem); shiftedBreak.add(breakItem);
}
} }
iterator = shiftedBreak.iterator(); iterator = shiftedBreak.iterator();
@ -496,7 +505,9 @@ public final class PageSettingsBlock extends RecordAggregate {
/** /**
* Sets a page break at the indicated row * Sets a page break at the indicated row
* @param row * @param row the row
* @param fromCol the starting column
* @param toCol the ending column
*/ */
public void setRowBreak(int row, short fromCol, short toCol) { public void setRowBreak(int row, short fromCol, short toCol) {
getRowBreaksRecord().addBreak((short)row, fromCol, toCol); getRowBreaksRecord().addBreak((short)row, fromCol, toCol);
@ -504,17 +515,20 @@ public final class PageSettingsBlock extends RecordAggregate {
/** /**
* Removes a page break at the indicated row * Removes a page break at the indicated row
* @param row * @param row the row
*/ */
public void removeRowBreak(int row) { public void removeRowBreak(int row) {
if (getRowBreaksRecord().getBreaks().length < 1) if (getRowBreaksRecord().getBreaks().length < 1) {
throw new IllegalArgumentException("Sheet does not define any row breaks"); throw new IllegalArgumentException("Sheet does not define any row breaks");
}
getRowBreaksRecord().removeBreak((short)row); getRowBreaksRecord().removeBreak((short)row);
} }
/** /**
* Queries if the specified row has a page break * Queries if the specified row has a page break
* @param row *
* @param row the row to check for
*
* @return true if the specified row has a page break * @return true if the specified row has a page break
*/ */
public boolean isRowBroken(int row) { public boolean isRowBroken(int row) {
@ -524,6 +538,8 @@ public final class PageSettingsBlock extends RecordAggregate {
/** /**
* Queries if the specified column has a page break * Queries if the specified column has a page break
*
* @param column the column to check for
* *
* @return <code>true</code> if the specified column has a page break * @return <code>true</code> if the specified column has a page break
*/ */
@ -533,9 +549,9 @@ public final class PageSettingsBlock extends RecordAggregate {
/** /**
* Shifts the horizontal page breaks for the indicated count * Shifts the horizontal page breaks for the indicated count
* @param startingRow * @param startingRow the starting row
* @param endingRow * @param endingRow the ending row
* @param count * @param count the number of rows to shift by
*/ */
public void shiftRowBreaks(int startingRow, int endingRow, int count) { public void shiftRowBreaks(int startingRow, int endingRow, int count) {
shiftBreaks(getRowBreaksRecord(), startingRow, endingRow, count); shiftBreaks(getRowBreaksRecord(), startingRow, endingRow, count);
@ -543,9 +559,9 @@ public final class PageSettingsBlock extends RecordAggregate {
/** /**
* Shifts the vertical page breaks for the indicated count * Shifts the vertical page breaks for the indicated count
* @param startingCol * @param startingCol the starting column
* @param endingCol * @param endingCol the ending column
* @param count * @param count the number of columns to shift by
*/ */
public void shiftColumnBreaks(short startingCol, short endingCol, short count) { public void shiftColumnBreaks(short startingCol, short endingCol, short count) {
shiftBreaks(getColumnBreaksRecord(), startingCol, endingCol, count); shiftBreaks(getColumnBreaksRecord(), startingCol, endingCol, count);
@ -590,6 +606,8 @@ public final class PageSettingsBlock extends RecordAggregate {
/** /**
* HEADERFOOTER is new in 2007. Some apps seem to have scattered this record long after * HEADERFOOTER is new in 2007. Some apps seem to have scattered this record long after
* the {@link PageSettingsBlock} where it belongs. * the {@link PageSettingsBlock} where it belongs.
*
* @param rec the HeaderFooterRecord to set
*/ */
public void addLateHeaderFooter(HeaderFooterRecord rec) { public void addLateHeaderFooter(HeaderFooterRecord rec) {
if (_headerFooter != null) { if (_headerFooter != null) {
@ -604,10 +622,11 @@ public final class PageSettingsBlock extends RecordAggregate {
/** /**
* This method reads PageSettingsBlock records from the supplied RecordStream until the first * This method reads PageSettingsBlock records from the supplied RecordStream until the first
* non-PageSettingsBlock record is encountered. As each record is read, it is incorporated * non-PageSettingsBlock record is encountered. As each record is read, it is incorporated
* into this PageSettingsBlock. * into this PageSettingsBlock.<p>
* <p/> *
* The latest Excel version seems to write the PageSettingsBlock uninterrupted. However there * The latest Excel version seems to write the PageSettingsBlock uninterrupted. However there
* are several examples (that Excel reads OK) where these records are not written together: * are several examples (that Excel reads OK) where these records are not written together:
*
* <ul> * <ul>
* <li><b>HEADER_FOOTER(0x089C) after WINDOW2</b> - This record is new in 2007. Some apps * <li><b>HEADER_FOOTER(0x089C) after WINDOW2</b> - This record is new in 2007. Some apps
* seem to have scattered this record long after the PageSettingsBlock where it belongs * seem to have scattered this record long after the PageSettingsBlock where it belongs
@ -616,16 +635,18 @@ public final class PageSettingsBlock extends RecordAggregate {
* This happens in the test sample file "NoGutsRecords.xls" and "WORKBOOK_in_capitals.xls"</li> * This happens in the test sample file "NoGutsRecords.xls" and "WORKBOOK_in_capitals.xls"</li>
* <li><b>Margins after DIMENSION</b> - All of PSB should be before DIMENSION. (Bug-47199)</li> * <li><b>Margins after DIMENSION</b> - All of PSB should be before DIMENSION. (Bug-47199)</li>
* </ul> * </ul>
*
* These were probably written by other applications (or earlier versions of Excel). It was * These were probably written by other applications (or earlier versions of Excel). It was
* decided to not write specific code for detecting each of these cases. POI now tolerates * decided to not write specific code for detecting each of these cases. POI now tolerates
* PageSettingsBlock records scattered all over the sheet record stream, and in any order, but * PageSettingsBlock records scattered all over the sheet record stream, and in any order, but
* does not allow duplicates of any of those records. * does not allow duplicates of any of those records.<p>
* *
* <p/>
* <b>Note</b> - when POI writes out this PageSettingsBlock, the records will always be written * <b>Note</b> - when POI writes out this PageSettingsBlock, the records will always be written
* in one consolidated block (in the standard ordering) regardless of how scattered the records * in one consolidated block (in the standard ordering) regardless of how scattered the records
* were when they were originally read. * were when they were originally read.
* *
* @param rs the RecordStream to read from
*
* @throws RecordFormatException if any PSB record encountered has the same type (sid) as * @throws RecordFormatException if any PSB record encountered has the same type (sid) as
* a record that is already part of this PageSettingsBlock * a record that is already part of this PageSettingsBlock
*/ */
@ -665,6 +686,7 @@ public final class PageSettingsBlock extends RecordAggregate {
if (rb instanceof CustomViewSettingsRecordAggregate) { if (rb instanceof CustomViewSettingsRecordAggregate) {
final CustomViewSettingsRecordAggregate cv = (CustomViewSettingsRecordAggregate) rb; final CustomViewSettingsRecordAggregate cv = (CustomViewSettingsRecordAggregate) rb;
cv.visitContainedRecords(new RecordVisitor() { cv.visitContainedRecords(new RecordVisitor() {
@Override
public void visitRecord(Record r) { public void visitRecord(Record r) {
if (r.getSid() == UserSViewBegin.sid) { if (r.getSid() == UserSViewBegin.sid) {
String guid = HexDump.toHex(((UserSViewBegin) r).getGuid()); String guid = HexDump.toHex(((UserSViewBegin) r).getGuid());