1 2 17 18 19 package org.apache.poi.hssf.record; 20 21 import org.apache.poi.util.BitField; 22 import org.apache.poi.util.LittleEndian; 23 24 32 33 public class WindowTwoRecord 34 extends Record 35 { 36 public final static short sid = 0x23e; 37 private short field_1_options; 38 39 private BitField displayFormulas = new BitField(0x01); 41 private BitField displayGridlines = new BitField(0x02); 42 private BitField displayRowColHeadings = new BitField(0x04); 43 private BitField freezePanes = new BitField(0x08); 44 private BitField displayZeros = new BitField(0x10); 45 private BitField defaultHeader = 46 new BitField(0x20); 48 private BitField arabic = 51 new BitField(0x40); private BitField displayGuts = new BitField(0x80); 53 private BitField freezePanesNoSplit = new BitField(0x100); 54 private BitField selected = new BitField(0x200); 55 private BitField paged = new BitField(0x400); 56 private BitField savedInPageBreakPreview = new BitField(0x800); 57 58 private short field_2_top_row; 61 private short field_3_left_col; 62 private int field_4_header_color; 63 private short field_5_page_break_zoom; 64 private short field_6_normal_zoom; 65 private int field_7_reserved; 66 67 public WindowTwoRecord() 68 { 69 } 70 71 78 79 public WindowTwoRecord(short id, short size, byte [] data) 80 { 81 super(id, size, data); 82 } 83 84 92 93 public WindowTwoRecord(short id, short size, byte [] data, int offset) 94 { 95 super(id, size, data, offset); 96 } 97 98 protected void validateSid(short id) 99 { 100 if (id != sid) 101 { 102 throw new RecordFormatException("NOT A valid WindowTwo RECORD"); 103 } 104 } 105 106 protected void fillFields(byte [] data, short size, int offset) 107 { 108 field_1_options = LittleEndian.getShort(data, 0 + offset); 109 field_2_top_row = LittleEndian.getShort(data, 2 + offset); 110 field_3_left_col = LittleEndian.getShort(data, 4 + offset); 111 field_4_header_color = LittleEndian.getInt(data, 6 + offset); 112 if (size > 10) 113 { 114 field_5_page_break_zoom = LittleEndian.getShort(data, 115 10 + offset); 116 field_6_normal_zoom = LittleEndian.getShort(data, 117 12 + offset); 118 } 119 if (size > 14) 120 { field_7_reserved = LittleEndian.getInt(data, 14 + offset); 122 } 123 } 124 125 129 130 public void setOptions(short options) 131 { 132 field_1_options = options; 133 } 134 135 137 141 142 public void setDisplayFormulas(boolean formulas) 143 { 144 field_1_options = displayFormulas.setShortBoolean(field_1_options, formulas); 145 } 146 147 151 152 public void setDisplayGridlines(boolean gridlines) 153 { 154 field_1_options = displayGridlines.setShortBoolean(field_1_options, gridlines); 155 } 156 157 161 162 public void setDisplayRowColHeadings(boolean headings) 163 { 164 field_1_options = displayRowColHeadings.setShortBoolean(field_1_options, headings); 165 } 166 167 171 172 public void setFreezePanes(boolean freezepanes) 173 { 174 field_1_options = freezePanes.setShortBoolean(field_1_options, freezepanes); 175 } 176 177 181 182 public void setDisplayZeros(boolean zeros) 183 { 184 field_1_options = displayZeros.setShortBoolean(field_1_options, zeros); 185 } 186 187 191 192 public void setDefaultHeader(boolean header) 193 { 194 field_1_options = defaultHeader.setShortBoolean(field_1_options, header); 195 } 196 197 201 202 public void setArabic(boolean isarabic) 203 { 204 field_1_options = arabic.setShortBoolean(field_1_options, isarabic); 205 } 206 207 211 212 public void setDisplayGuts(boolean guts) 213 { 214 field_1_options = displayGuts.setShortBoolean(field_1_options, guts); 215 } 216 217 221 222 public void setFreezePanesNoSplit(boolean freeze) 223 { 224 field_1_options = freezePanesNoSplit.setShortBoolean(field_1_options, freeze); 225 } 226 227 231 232 public void setSelected(boolean sel) 233 { 234 field_1_options = selected.setShortBoolean(field_1_options, sel); 235 } 236 237 241 242 public void setPaged(boolean p) 243 { 244 field_1_options = paged.setShortBoolean(field_1_options, p); 245 } 246 247 251 252 public void setSavedInPageBreakPreview(boolean p) 253 { 254 field_1_options = savedInPageBreakPreview.setShortBoolean(field_1_options, p); 255 } 256 257 259 263 264 public void setTopRow(short topRow) 265 { 266 field_2_top_row = topRow; 267 } 268 269 273 274 public void setLeftCol(short leftCol) 275 { 276 field_3_left_col = leftCol; 277 } 278 279 283 284 public void setHeaderColor(int color) 285 { 286 field_4_header_color = color; 287 } 288 289 293 294 public void setPageBreakZoom(short zoom) 295 { 296 field_5_page_break_zoom = zoom; 297 } 298 299 303 304 public void setNormalZoom(short zoom) 305 { 306 field_6_normal_zoom = zoom; 307 } 308 309 312 313 public void setReserved(int reserved) 314 { 315 field_7_reserved = reserved; 316 } 317 318 322 323 public short getOptions() 324 { 325 return field_1_options; 326 } 327 328 330 334 335 public boolean getDisplayFormulas() 336 { 337 return displayFormulas.isSet(field_1_options); 338 } 339 340 344 345 public boolean getDisplayGridlines() 346 { 347 return displayGridlines.isSet(field_1_options); 348 } 349 350 354 355 public boolean getDisplayRowColHeadings() 356 { 357 return displayRowColHeadings.isSet(field_1_options); 358 } 359 360 364 365 public boolean getFreezePanes() 366 { 367 return freezePanes.isSet(field_1_options); 368 } 369 370 374 375 public boolean getDisplayZeros() 376 { 377 return displayZeros.isSet(field_1_options); 378 } 379 380 384 385 public boolean getDefaultHeader() 386 { 387 return defaultHeader.isSet(field_1_options); 388 } 389 390 394 395 public boolean getArabic() 396 { 397 return arabic.isSet(field_1_options); 398 } 399 400 404 405 public boolean getDisplayGuts() 406 { 407 return displayGuts.isSet(field_1_options); 408 } 409 410 414 415 public boolean getFreezePanesNoSplit() 416 { 417 return freezePanesNoSplit.isSet(field_1_options); 418 } 419 420 424 425 public boolean getSelected() 426 { 427 return selected.isSet(field_1_options); 428 } 429 430 434 435 public boolean getPaged() 436 { 437 return paged.isSet(field_1_options); 438 } 439 440 444 445 public boolean getSavedInPageBreakPreview() 446 { 447 return savedInPageBreakPreview.isSet(field_1_options); 448 } 449 450 452 456 457 public short getTopRow() 458 { 459 return field_2_top_row; 460 } 461 462 466 467 public short getLeftCol() 468 { 469 return field_3_left_col; 470 } 471 472 476 477 public int getHeaderColor() 478 { 479 return field_4_header_color; 480 } 481 482 486 487 public short getPageBreakZoom() 488 { 489 return field_5_page_break_zoom; 490 } 491 492 496 497 public short getNormalZoom() 498 { 499 return field_6_normal_zoom; 500 } 501 502 506 507 public int getReserved() 508 { 509 return field_7_reserved; 510 } 511 512 public String toString() 513 { 514 StringBuffer buffer = new StringBuffer (); 515 516 buffer.append("[WINDOW2]\n"); 517 buffer.append(" .options = ") 518 .append(Integer.toHexString(getOptions())).append("\n"); 519 buffer.append(" .dispformulas= ").append(getDisplayFormulas()) 520 .append("\n"); 521 buffer.append(" .dispgridlins= ").append(getDisplayGridlines()) 522 .append("\n"); 523 buffer.append(" .disprcheadin= ") 524 .append(getDisplayRowColHeadings()).append("\n"); 525 buffer.append(" .freezepanes = ").append(getFreezePanes()) 526 .append("\n"); 527 buffer.append(" .displayzeros= ").append(getDisplayZeros()) 528 .append("\n"); 529 buffer.append(" .defaultheadr= ").append(getDefaultHeader()) 530 .append("\n"); 531 buffer.append(" .arabic = ").append(getArabic()) 532 .append("\n"); 533 buffer.append(" .displayguts = ").append(getDisplayGuts()) 534 .append("\n"); 535 buffer.append(" .frzpnsnosplt= ") 536 .append(getFreezePanesNoSplit()).append("\n"); 537 buffer.append(" .selected = ").append(getSelected()) 538 .append("\n"); 539 buffer.append(" .paged = ").append(getPaged()) 540 .append("\n"); 541 buffer.append(" .svdinpgbrkpv= ") 542 .append(getSavedInPageBreakPreview()).append("\n"); 543 buffer.append(" .toprow = ") 544 .append(Integer.toHexString(getTopRow())).append("\n"); 545 buffer.append(" .leftcol = ") 546 .append(Integer.toHexString(getLeftCol())).append("\n"); 547 buffer.append(" .headercolor = ") 548 .append(Integer.toHexString(getHeaderColor())).append("\n"); 549 buffer.append(" .pagebreakzoom = ") 550 .append(Integer.toHexString(getPageBreakZoom())).append("\n"); 551 buffer.append(" .normalzoom = ") 552 .append(Integer.toHexString(getNormalZoom())).append("\n"); 553 buffer.append(" .reserved = ") 554 .append(Integer.toHexString(getReserved())).append("\n"); 555 buffer.append("[/WINDOW2]\n"); 556 return buffer.toString(); 557 } 558 559 public int serialize(int offset, byte [] data) 560 { 561 LittleEndian.putShort(data, 0 + offset, sid); 562 LittleEndian.putShort(data, 2 + offset, ( short ) 18); 563 LittleEndian.putShort(data, 4 + offset, getOptions()); 564 LittleEndian.putShort(data, 6 + offset, getTopRow()); 565 LittleEndian.putShort(data, 8 + offset, getLeftCol()); 566 LittleEndian.putInt(data, 10 + offset, getHeaderColor()); 567 LittleEndian.putShort(data, 14 + offset, getPageBreakZoom()); 568 LittleEndian.putShort(data, 16 + offset, getNormalZoom()); 569 LittleEndian.putInt(data, 18 + offset, getReserved()); 570 return getRecordSize(); 571 } 572 573 public int getRecordSize() 574 { 575 return 22; 576 } 577 578 public short getSid() 579 { 580 return this.sid; 581 } 582 583 public Object clone() { 584 WindowTwoRecord rec = new WindowTwoRecord(); 585 rec.field_1_options = field_1_options; 586 rec.field_2_top_row = field_2_top_row; 587 rec.field_3_left_col = field_3_left_col; 588 rec.field_4_header_color = field_4_header_color; 589 rec.field_5_page_break_zoom = field_5_page_break_zoom; 590 rec.field_6_normal_zoom = field_6_normal_zoom; 591 rec.field_7_reserved = field_7_reserved; 592 return rec; 593 } 594 } 595 | Popular Tags |