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 34 35 public class WSBoolRecord 36 extends Record 37 { 38 public final static short sid = 0x81; 39 private byte field_1_wsbool; private byte field_2_wsbool; 42 static final private BitField autobreaks = 44 new BitField(0x01); 46 static final private BitField dialog = 48 new BitField(0x10); static final private BitField applystyles = 50 new BitField(0x20); static final private BitField rowsumsbelow = new BitField( 52 0x40); static final private BitField rowsumsright = new BitField( 54 0x80); static final private BitField fittopage = 56 new BitField(0x01); 58 static final private BitField displayguts = new BitField( 60 0x06); 62 static final private BitField alternateexpression = new BitField(0x40); 65 static final private BitField alternateformula = new BitField(0x80); 67 68 public WSBoolRecord() 69 { 70 } 71 72 79 80 public WSBoolRecord(short id, short size, byte [] data) 81 { 82 super(id, size, data); 83 } 84 85 92 93 public WSBoolRecord(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 WSBoolRECORD"); 103 } 104 } 105 106 protected void fillFields(byte [] data, short size, int offset) 107 { 108 field_1_wsbool = 109 data[ 1 + offset ]; field_2_wsbool = 111 data[ 0 + offset ]; } 114 120 123 124 public void setWSBool1(byte bool1) 125 { 126 field_1_wsbool = bool1; 127 } 128 129 131 135 136 public void setAutobreaks(boolean ab) 137 { 138 field_1_wsbool = autobreaks.setByteBoolean(field_1_wsbool, ab); 139 } 140 141 145 146 public void setDialog(boolean isDialog) 147 { 148 field_1_wsbool = dialog.setByteBoolean(field_1_wsbool, isDialog); 149 } 150 151 155 156 public void setRowSumsBelow(boolean below) 157 { 158 field_1_wsbool = rowsumsbelow.setByteBoolean(field_1_wsbool, below); 159 } 160 161 165 166 public void setRowSumsRight(boolean right) 167 { 168 field_1_wsbool = rowsumsright.setByteBoolean(field_1_wsbool, right); 169 } 170 171 173 176 177 public void setWSBool2(byte bool2) 178 { 179 field_2_wsbool = field_2_wsbool = bool2; 180 } 181 182 184 188 189 public void setFitToPage(boolean fit2page) 190 { 191 field_2_wsbool = fittopage.setByteBoolean(field_2_wsbool, fit2page); 192 } 193 194 199 200 public void setDisplayGuts(boolean guts) 201 { 202 field_2_wsbool = displayguts.setByteBoolean(field_2_wsbool, guts); 203 } 204 205 209 210 public void setAlternateExpression(boolean altexp) 211 { 212 field_2_wsbool = alternateexpression.setByteBoolean(field_2_wsbool, 213 altexp); 214 } 215 216 220 221 public void setAlternateFormula(boolean formula) 222 { 223 field_2_wsbool = alternateformula.setByteBoolean(field_2_wsbool, 224 formula); 225 } 226 227 229 232 233 public byte getWSBool1() 234 { 235 return field_1_wsbool; 236 } 237 238 240 244 245 public boolean getAutobreaks() 246 { 247 return autobreaks.isSet(field_1_wsbool); 248 } 249 250 254 255 public boolean getDialog() 256 { 257 return dialog.isSet(field_1_wsbool); 258 } 259 260 264 265 public boolean getRowSumsBelow() 266 { 267 return rowsumsbelow.isSet(field_1_wsbool); 268 } 269 270 274 275 public boolean getRowSumsRight() 276 { 277 return rowsumsright.isSet(field_1_wsbool); 278 } 279 280 282 285 286 public byte getWSBool2() 287 { 288 return field_2_wsbool; 289 } 290 291 293 297 298 public boolean getFitToPage() 299 { 300 return fittopage.isSet(field_2_wsbool); 301 } 302 303 308 309 public boolean getDisplayGuts() 310 { 311 return displayguts.isSet(field_2_wsbool); 312 } 313 314 318 319 public boolean getAlternateExpression() 320 { 321 return alternateexpression.isSet(field_2_wsbool); 322 } 323 324 328 329 public boolean getAlternateFormula() 330 { 331 return alternateformula.isSet(field_2_wsbool); 332 } 333 334 public String toString() 336 { 337 StringBuffer buffer = new StringBuffer (); 338 339 buffer.append("[WSBOOL]\n"); 340 buffer.append(" .wsbool1 = ") 341 .append(Integer.toHexString(getWSBool1())).append("\n"); 342 buffer.append(" .autobreaks = ").append(getAutobreaks()) 343 .append("\n"); 344 buffer.append(" .dialog = ").append(getDialog()) 345 .append("\n"); 346 buffer.append(" .rowsumsbelw= ").append(getRowSumsBelow()) 347 .append("\n"); 348 buffer.append(" .rowsumsrigt= ").append(getRowSumsRight()) 349 .append("\n"); 350 buffer.append(" .wsbool2 = ") 351 .append(Integer.toHexString(getWSBool2())).append("\n"); 352 buffer.append(" .fittopage = ").append(getFitToPage()) 353 .append("\n"); 354 buffer.append(" .displayguts= ").append(getDisplayGuts()) 355 .append("\n"); 356 buffer.append(" .alternateex= ") 357 .append(getAlternateExpression()).append("\n"); 358 buffer.append(" .alternatefo= ").append(getAlternateFormula()) 359 .append("\n"); 360 buffer.append("[/WSBOOL]\n"); 361 return buffer.toString(); 362 } 363 364 public int serialize(int offset, byte [] data) 365 { 366 LittleEndian.putShort(data, 0 + offset, sid); 367 LittleEndian.putShort(data, 2 + offset, ( short ) 0x2); 368 data[ 5 + offset ] = getWSBool1(); 369 data[ 4 + offset ] = getWSBool2(); 370 return getRecordSize(); 371 } 372 373 public int getRecordSize() 374 { 375 return 6; 376 } 377 378 public short getSid() 379 { 380 return this.sid; 381 } 382 383 public Object clone() { 384 WSBoolRecord rec = new WSBoolRecord(); 385 rec.field_1_wsbool = field_1_wsbool; 386 rec.field_2_wsbool = field_2_wsbool; 387 return rec; 388 } 389 } 390 | Popular Tags |