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