removed TODO comment and formatted

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@683128 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2008-08-06 06:20:59 +00:00
parent 28313438f6
commit 1459d3eb3b

View File

@ -27,24 +27,24 @@ import org.apache.poi.util.LittleEndian;
/**
* <p>Record that contains the functionality page breaks (horizontal and vertical)</p>
*
*
* <p>The other two classes just specifically set the SIDS for record creation.</p>
*
*
* <p>REFERENCE: Microsoft Excel SDK page 322 and 420</p>
*
*
* @see HorizontalPageBreakRecord
* @see VerticalPageBreakRecord
* @author Danny Mui (dmui at apache dot org)
*/
public abstract class PageBreakRecord extends Record {
private static final boolean IS_EMPTY_RECORD_WRITTEN = false; //TODO - flip
private static final boolean IS_EMPTY_RECORD_WRITTEN = false;
private static final int[] EMPTY_INT_ARRAY = { };
private List _breaks;
private Map _breakMap;
/**
* Since both records store 2byte integers (short), no point in
* Since both records store 2byte integers (short), no point in
* differentiating it in the records.
* <p>
* The subs (rows or columns, don't seem to be able to set but excel sets
@ -53,7 +53,7 @@ public abstract class PageBreakRecord extends Record {
public class Break {
public static final int ENCODED_SIZE = 6;
public int main;
public int main;
public int subFrom;
public int subTo;
@ -63,13 +63,13 @@ public abstract class PageBreakRecord extends Record {
this.subFrom = subFrom;
this.subTo = subTo;
}
public Break(RecordInputStream in) {
main = in.readUShort() - 1;
subFrom = in.readUShort();
subTo = in.readUShort();
main = in.readUShort() - 1;
subFrom = in.readUShort();
subTo = in.readUShort();
}
public int serialize(int offset, byte[] data) {
LittleEndian.putUShort(data, offset + 0, main + 1);
LittleEndian.putUShort(data, offset + 2, subFrom);
@ -92,22 +92,22 @@ public abstract class PageBreakRecord extends Record {
int nBreaks = in.readShort();
_breaks = new ArrayList(nBreaks + 2);
_breakMap = new HashMap();
for(int k = 0; k < nBreaks; k++) {
Break br = new Break(in);
_breaks.add(br);
Break br = new Break(in);
_breaks.add(br);
_breakMap.put(new Integer(br.main), br);
}
}
private int getDataSize() {
return 2 + _breaks.size() * Break.ENCODED_SIZE;
return 2 + _breaks.size() * Break.ENCODED_SIZE;
}
public int getRecordSize() {
int nBreaks = _breaks.size();
if (!IS_EMPTY_RECORD_WRITTEN && nBreaks < 1) {
return 0;
return 0;
}
return 4 + getDataSize();
}
@ -116,9 +116,9 @@ public abstract class PageBreakRecord extends Record {
public final int serialize(int offset, byte data[]) {
int nBreaks = _breaks.size();
if (!IS_EMPTY_RECORD_WRITTEN && nBreaks < 1) {
return 0;
return 0;
}
int dataSize = getDataSize();
int dataSize = getDataSize();
LittleEndian.putUShort(data, offset + 0, getSid());
LittleEndian.putUShort(data, offset + 2, dataSize);
LittleEndian.putUShort(data, offset + 4, nBreaks);
@ -142,12 +142,12 @@ public abstract class PageBreakRecord extends Record {
public String toString()
{
StringBuffer retval = new StringBuffer();
String label;
String mainLabel;
String subLabel;
if (getSid() == HorizontalPageBreakRecord.sid) {
label = "HORIZONTALPAGEBREAK";
mainLabel = "row";
@ -157,7 +157,7 @@ public abstract class PageBreakRecord extends Record {
mainLabel = "column";
subLabel = "row";
}
retval.append("["+label+"]").append("\n");
retval.append(" .sid =").append(getSid()).append("\n");
retval.append(" .numbreaks =").append(getNumBreaks()).append("\n");
@ -165,7 +165,7 @@ public abstract class PageBreakRecord extends Record {
for(int k = 0; k < getNumBreaks(); k++)
{
Break region = (Break)iterator.next();
retval.append(" .").append(mainLabel).append(" (zero-based) =").append(region.main).append("\n");
retval.append(" .").append(subLabel).append("From =").append(region.subFrom).append("\n");
retval.append(" .").append(subLabel).append("To =").append(region.subTo).append("\n");
@ -217,12 +217,11 @@ public abstract class PageBreakRecord extends Record {
return (Break)_breakMap.get(rowKey);
}
public final int[] getBreaks() {
int count = getNumBreaks();
if (count < 1) {
return EMPTY_INT_ARRAY;
}
int count = getNumBreaks();
if (count < 1) {
return EMPTY_INT_ARRAY;
}
int[] result = new int[count];
for (int i=0; i<count; i++) {
Break breakItem = (Break)_breaks.get(i);