1 19 20 package jxl.write.biff; 21 22 23 import jxl.biff.WritableRecordData; 24 import jxl.biff.XFRecord; 25 import jxl.biff.IntegerHelper; 26 import jxl.biff.Type; 27 import jxl.biff.FormattingRecords; 28 import jxl.biff.IndexMapping; 29 30 33 class ColumnInfoRecord extends WritableRecordData 34 { 35 38 private byte[] data; 39 42 private int column; 43 46 private XFRecord style; 47 50 private int xfIndex; 51 52 55 private int width; 56 57 60 private boolean hidden; 61 62 70 public ColumnInfoRecord(int col, int w, XFRecord xf) 71 { 72 super(Type.COLINFO); 73 74 column = col; 75 width = w; 76 style = xf; 77 xfIndex = style.getXFIndex(); 78 hidden = false; 79 } 80 81 88 public ColumnInfoRecord(jxl.read.biff.ColumnInfoRecord cir, 89 int col, 90 FormattingRecords fr) 91 { 92 super(Type.COLINFO); 93 94 column = col; 95 width = cir.getWidth(); 96 xfIndex = cir.getXFIndex(); 97 style = fr.getXFRecord(xfIndex); 98 } 99 100 105 public int getColumn() 106 { 107 return column; 108 } 109 110 114 public void incrementColumn() 115 { 116 column++; 117 } 118 119 123 public void decrementColumn() 124 { 125 column--; 126 } 127 128 133 int getWidth() 134 { 135 return width; 136 } 137 138 143 public byte[] getData() 144 { 145 data = new byte[0x0c]; 146 147 IntegerHelper.getTwoBytes(column, data, 0); 148 IntegerHelper.getTwoBytes(column, data, 2); 149 IntegerHelper.getTwoBytes(width, data, 4); 150 IntegerHelper.getTwoBytes(xfIndex, data, 6); 151 152 int options = 0x6; 154 if (hidden) 155 { 156 options |= 0x1; 157 } 158 IntegerHelper.getTwoBytes(options, data, 8); 159 161 return data; 162 } 163 164 169 public XFRecord getCellFormat() 170 { 171 return style; 172 } 173 174 178 void rationalize(IndexMapping xfmapping) 179 { 180 xfIndex = xfmapping.getNewIndex(xfIndex); 181 } 182 183 188 void setHidden(boolean h) 189 { 190 hidden = h; 191 } 192 193 198 boolean getHidden() 199 { 200 return hidden; 201 } 202 203 208 public boolean equals(Object o) 209 { 210 if (o == this) 211 { 212 return true; 213 } 214 215 if (!(o instanceof ColumnInfoRecord)) 216 { 217 return false; 218 } 219 220 ColumnInfoRecord cir = (ColumnInfoRecord) o; 221 222 int col2 = cir.column; 223 224 if (column != cir.column || 225 xfIndex != cir.xfIndex || 226 width != cir.width || 227 hidden != cir.hidden) 228 { 229 return false; 230 } 231 232 if ((style == null && cir.style != null) || 233 (style != null && cir.style == null)) 234 { 235 return false; 236 } 237 238 return style.equals(cir.style); 239 } 240 241 246 public int hashCode() 247 { 248 int hashValue = 137; 249 int oddPrimeNumber = 79; 250 251 hashValue = hashValue * oddPrimeNumber + column; 252 hashValue = hashValue * oddPrimeNumber + xfIndex; 253 hashValue = hashValue * oddPrimeNumber + width; 254 hashValue = hashValue * oddPrimeNumber + (hidden ? 1:0); 255 256 if (style != null) 257 { 258 hashValue ^= style.hashCode(); 259 } 260 261 return hashValue; 262 } 263 } 264 | Popular Tags |