1 19 20 package jxl.write.biff; 21 22 import java.util.ArrayList ; 23 import java.util.Iterator ; 24 25 import jxl.biff.Type; 26 import jxl.biff.IntegerHelper; 27 import jxl.biff.WritableRecordData; 28 29 33 class DBCellRecord extends WritableRecordData 34 { 35 38 private int rowPos; 39 40 44 private int cellOffset; 45 46 49 private ArrayList cellRowPositions; 50 51 54 private int position; 55 56 61 public DBCellRecord(int rp) 62 { 63 super(Type.DBCELL); 64 rowPos = rp; 65 cellRowPositions = new ArrayList (10); 66 } 67 68 73 void setCellOffset(int pos) 74 { 75 cellOffset = pos; 76 } 77 78 83 void addCellRowPosition(int pos) 84 { 85 cellRowPositions.add(new Integer (pos)); 86 } 87 88 93 void setPosition(int pos) 94 { 95 position = pos; 96 } 97 98 103 protected byte[] getData() 104 { 105 byte[] data = new byte[4 + 2 * cellRowPositions.size()]; 106 107 IntegerHelper.getFourBytes(position - rowPos, data, 0); 109 110 int pos = 4; 112 int lastCellPos = cellOffset; 113 Iterator i = cellRowPositions.iterator(); 114 while (i.hasNext()) 115 { 116 int cellPos = ((Integer ) i.next()).intValue(); 117 IntegerHelper.getTwoBytes(cellPos - lastCellPos, data, pos); 118 lastCellPos = cellPos; 119 pos += 2; 120 } 121 122 return data; 123 } 124 } 125 | Popular Tags |