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 33 34 public class WindowOneRecord 35 extends Record 36 { 37 public final static short sid = 0x3d; 38 39 private short field_1_h_hold; private short field_2_v_hold; private short field_3_width; 43 private short field_4_height; 44 private short field_5_options; 45 static final private BitField hidden = 46 new BitField(0x01); static final private BitField iconic = 48 new BitField(0x02); static final private BitField reserved = new BitField(0x04); static final private BitField hscroll = 51 new BitField(0x08); static final private BitField vscroll = 53 new BitField(0x10); static final private BitField tabs = 55 new BitField(0x20); 57 private short field_6_selected_tab; 59 private short field_7_displayed_tab; 60 private short field_8_num_selected_tabs; 61 private short field_9_tab_width_ratio; 62 63 public WindowOneRecord() 64 { 65 } 66 67 74 75 public WindowOneRecord(short id, short size, byte [] data) 76 { 77 super(id, size, data); 78 } 79 80 87 88 public WindowOneRecord(short id, short size, byte [] data, int offset) 89 { 90 super(id, size, data, offset); 91 } 92 93 protected void validateSid(short id) 94 { 95 if (id != sid) 96 { 97 throw new RecordFormatException("NOT A WINDOW1 RECORD"); 98 } 99 } 100 101 protected void fillFields(byte [] data, short size, int offset) 102 { 103 field_1_h_hold = LittleEndian.getShort(data, 0 + offset); 104 field_2_v_hold = LittleEndian.getShort(data, 2 + offset); 105 field_3_width = LittleEndian.getShort(data, 4 + offset); 106 field_4_height = LittleEndian.getShort(data, 6 + offset); 107 field_5_options = LittleEndian.getShort(data, 8 + offset); 108 field_6_selected_tab = LittleEndian.getShort(data, 10 + offset); 109 field_7_displayed_tab = LittleEndian.getShort(data, 12 + offset); 110 field_8_num_selected_tabs = LittleEndian.getShort(data, 14 + offset); 111 field_9_tab_width_ratio = LittleEndian.getShort(data, 16 + offset); 112 } 113 114 118 119 public void setHorizontalHold(short h) 120 { 121 field_1_h_hold = h; 122 } 123 124 128 129 public void setVerticalHold(short v) 130 { 131 field_2_v_hold = v; 132 } 133 134 138 139 public void setWidth(short w) 140 { 141 field_3_width = w; 142 } 143 144 148 149 public void setHeight(short h) 150 { 151 field_4_height = h; 152 } 153 154 159 160 public void setOptions(short o) 161 { 162 field_5_options = o; 163 } 164 165 167 171 172 public void setHidden(boolean ishidden) 173 { 174 field_5_options = hidden.setShortBoolean(field_5_options, ishidden); 175 } 176 177 181 182 public void setIconic(boolean isiconic) 183 { 184 field_5_options = iconic.setShortBoolean(field_5_options, isiconic); 185 } 186 187 191 192 public void setDisplayHorizonalScrollbar(boolean scroll) 193 { 194 field_5_options = hscroll.setShortBoolean(field_5_options, scroll); 195 } 196 197 201 202 public void setDisplayVerticalScrollbar(boolean scroll) 203 { 204 field_5_options = vscroll.setShortBoolean(field_5_options, scroll); 205 } 206 207 211 212 public void setDisplayTabs(boolean disptabs) 213 { 214 field_5_options = tabs.setShortBoolean(field_5_options, disptabs); 215 } 216 217 219 223 224 public void setSelectedTab(short s) 225 { 226 field_6_selected_tab = s; 227 } 228 229 233 234 public void setDisplayedTab(short t) 235 { 236 field_7_displayed_tab = t; 237 } 238 239 243 244 public void setNumSelectedTabs(short n) 245 { 246 field_8_num_selected_tabs = n; 247 } 248 249 253 254 public void setTabWidthRatio(short r) 255 { 256 field_9_tab_width_ratio = r; 257 } 258 259 263 264 public short getHorizontalHold() 265 { 266 return field_1_h_hold; 267 } 268 269 273 274 public short getVerticalHold() 275 { 276 return field_2_v_hold; 277 } 278 279 283 284 public short getWidth() 285 { 286 return field_3_width; 287 } 288 289 293 294 public short getHeight() 295 { 296 return field_4_height; 297 } 298 299 304 305 public short getOptions() 306 { 307 return field_5_options; 308 } 309 310 312 316 317 public boolean getHidden() 318 { 319 return hidden.isSet(field_5_options); 320 } 321 322 326 327 public boolean getIconic() 328 { 329 return iconic.isSet(field_5_options); 330 } 331 332 336 337 public boolean getDisplayHorizontalScrollbar() 338 { 339 return hscroll.isSet(field_5_options); 340 } 341 342 346 347 public boolean getDisplayVerticalScrollbar() 348 { 349 return vscroll.isSet(field_5_options); 350 } 351 352 356 357 public boolean getDisplayTabs() 358 { 359 return tabs.isSet(field_5_options); 360 } 361 362 364 368 369 public short getSelectedTab() 370 { 371 return field_6_selected_tab; 372 } 373 374 378 379 public short getDisplayedTab() 380 { 381 return field_7_displayed_tab; 382 } 383 384 388 389 public short getNumSelectedTabs() 390 { 391 return field_8_num_selected_tabs; 392 } 393 394 398 399 public short getTabWidthRatio() 400 { 401 return field_9_tab_width_ratio; 402 } 403 404 public String toString() 405 { 406 StringBuffer buffer = new StringBuffer (); 407 408 buffer.append("[WINDOW1]\n"); 409 buffer.append(" .h_hold = ") 410 .append(Integer.toHexString(getHorizontalHold())).append("\n"); 411 buffer.append(" .v_hold = ") 412 .append(Integer.toHexString(getVerticalHold())).append("\n"); 413 buffer.append(" .width = ") 414 .append(Integer.toHexString(getWidth())).append("\n"); 415 buffer.append(" .height = ") 416 .append(Integer.toHexString(getHeight())).append("\n"); 417 buffer.append(" .options = ") 418 .append(Integer.toHexString(getOptions())).append("\n"); 419 buffer.append(" .hidden = ").append(getHidden()) 420 .append("\n"); 421 buffer.append(" .iconic = ").append(getIconic()) 422 .append("\n"); 423 buffer.append(" .hscroll = ") 424 .append(getDisplayHorizontalScrollbar()).append("\n"); 425 buffer.append(" .vscroll = ") 426 .append(getDisplayVerticalScrollbar()).append("\n"); 427 buffer.append(" .tabs = ").append(getDisplayTabs()) 428 .append("\n"); 429 buffer.append(" .selectedtab = ") 430 .append(Integer.toHexString(getSelectedTab())).append("\n"); 431 buffer.append(" .displayedtab = ") 432 .append(Integer.toHexString(getDisplayedTab())).append("\n"); 433 buffer.append(" .numselectedtabs = ") 434 .append(Integer.toHexString(getNumSelectedTabs())).append("\n"); 435 buffer.append(" .tabwidthratio = ") 436 .append(Integer.toHexString(getTabWidthRatio())).append("\n"); 437 buffer.append("[/WINDOW1]\n"); 438 return buffer.toString(); 439 } 440 441 public int serialize(int offset, byte [] data) 442 { 443 LittleEndian.putShort(data, 0 + offset, sid); 444 LittleEndian.putShort(data, 2 + offset, 445 (( short ) 0x12)); LittleEndian.putShort(data, 4 + offset, getHorizontalHold()); 447 LittleEndian.putShort(data, 6 + offset, getVerticalHold()); 448 LittleEndian.putShort(data, 8 + offset, getWidth()); 449 LittleEndian.putShort(data, 10 + offset, getHeight()); 450 LittleEndian.putShort(data, 12 + offset, getOptions()); 451 LittleEndian.putShort(data, 14 + offset, getSelectedTab()); 452 LittleEndian.putShort(data, 16 + offset, getDisplayedTab()); 453 LittleEndian.putShort(data, 18 + offset, getNumSelectedTabs()); 454 LittleEndian.putShort(data, 20 + offset, getTabWidthRatio()); 455 return getRecordSize(); 456 } 457 458 public int getRecordSize() 459 { 460 return 22; 461 } 462 463 public short getSid() 464 { 465 return this.sid; 466 } 467 } 468 | Popular Tags |