/**
* <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
public class Break {
public static final int ENCODED_SIZE = 6;
- public int main;
+ public int main;
public int subFrom;
public int subTo;
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);
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();
}
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);
public String toString()
{
StringBuffer retval = new StringBuffer();
-
-
+
+
String label;
String mainLabel;
String subLabel;
-
+
if (getSid() == HorizontalPageBreakRecord.sid) {
label = "HORIZONTALPAGEBREAK";
mainLabel = "row";
mainLabel = "column";
subLabel = "row";
}
-
+
retval.append("["+label+"]").append("\n");
retval.append(" .sid =").append(getSid()).append("\n");
retval.append(" .numbreaks =").append(getNumBreaks()).append("\n");
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");
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);