1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 24 import org.apache.poi.util.*; 25 26 33 public class SheetPropertiesRecord 34 extends Record 35 { 36 public final static short sid = 0x1044; 37 private short field_1_flags; 38 private BitField chartTypeManuallyFormatted = new BitField(0x1); 39 private BitField plotVisibleOnly = new BitField(0x2); 40 private BitField doNotSizeWithWindow = new BitField(0x4); 41 private BitField defaultPlotDimensions = new BitField(0x8); 42 private BitField autoPlotArea = new BitField(0x10); 43 private byte field_2_empty; 44 public final static byte EMPTY_NOT_PLOTTED = 0; 45 public final static byte EMPTY_ZERO = 1; 46 public final static byte EMPTY_INTERPOLATED = 2; 47 48 49 public SheetPropertiesRecord() 50 { 51 52 } 53 54 62 63 public SheetPropertiesRecord(short id, short size, byte [] data) 64 { 65 super(id, size, data); 66 67 } 68 69 78 79 public SheetPropertiesRecord(short id, short size, byte [] data, int offset) 80 { 81 super(id, size, data, offset); 82 83 } 84 85 90 protected void validateSid(short id) 91 { 92 if (id != sid) 93 { 94 throw new RecordFormatException("Not a SheetProperties record"); 95 } 96 } 97 98 protected void fillFields(byte [] data, short size, int offset) 99 { 100 101 int pos = 0; 102 field_1_flags = LittleEndian.getShort(data, pos + 0x0 + offset); 103 field_2_empty = data[ pos + 0x2 + offset ]; 104 105 } 106 107 public String toString() 108 { 109 StringBuffer buffer = new StringBuffer (); 110 111 buffer.append("[SHTPROPS]\n"); 112 buffer.append(" .flags = ") 113 .append("0x").append(HexDump.toHex( getFlags ())) 114 .append(" (").append( getFlags() ).append(" )"); 115 buffer.append(System.getProperty("line.separator")); 116 buffer.append(" .chartTypeManuallyFormatted = ").append(isChartTypeManuallyFormatted()).append('\n'); 117 buffer.append(" .plotVisibleOnly = ").append(isPlotVisibleOnly()).append('\n'); 118 buffer.append(" .doNotSizeWithWindow = ").append(isDoNotSizeWithWindow()).append('\n'); 119 buffer.append(" .defaultPlotDimensions = ").append(isDefaultPlotDimensions()).append('\n'); 120 buffer.append(" .autoPlotArea = ").append(isAutoPlotArea()).append('\n'); 121 buffer.append(" .empty = ") 122 .append("0x").append(HexDump.toHex( getEmpty ())) 123 .append(" (").append( getEmpty() ).append(" )"); 124 buffer.append(System.getProperty("line.separator")); 125 126 buffer.append("[/SHTPROPS]\n"); 127 return buffer.toString(); 128 } 129 130 public int serialize(int offset, byte[] data) 131 { 132 int pos = 0; 133 134 LittleEndian.putShort(data, 0 + offset, sid); 135 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 136 137 LittleEndian.putShort(data, 4 + offset + pos, field_1_flags); 138 data[ 6 + offset + pos ] = field_2_empty; 139 140 return getRecordSize(); 141 } 142 143 146 public int getRecordSize() 147 { 148 return 4 + 2 + 1; 149 } 150 151 public short getSid() 152 { 153 return this.sid; 154 } 155 156 public Object clone() { 157 SheetPropertiesRecord rec = new SheetPropertiesRecord(); 158 159 rec.field_1_flags = field_1_flags; 160 rec.field_2_empty = field_2_empty; 161 return rec; 162 } 163 164 165 166 167 170 public short getFlags() 171 { 172 return field_1_flags; 173 } 174 175 178 public void setFlags(short field_1_flags) 179 { 180 this.field_1_flags = field_1_flags; 181 } 182 183 191 public byte getEmpty() 192 { 193 return field_2_empty; 194 } 195 196 205 public void setEmpty(byte field_2_empty) 206 { 207 this.field_2_empty = field_2_empty; 208 } 209 210 214 public void setChartTypeManuallyFormatted(boolean value) 215 { 216 field_1_flags = chartTypeManuallyFormatted.setShortBoolean(field_1_flags, value); 217 } 218 219 223 public boolean isChartTypeManuallyFormatted() 224 { 225 return chartTypeManuallyFormatted.isSet(field_1_flags); 226 } 227 228 232 public void setPlotVisibleOnly(boolean value) 233 { 234 field_1_flags = plotVisibleOnly.setShortBoolean(field_1_flags, value); 235 } 236 237 241 public boolean isPlotVisibleOnly() 242 { 243 return plotVisibleOnly.isSet(field_1_flags); 244 } 245 246 250 public void setDoNotSizeWithWindow(boolean value) 251 { 252 field_1_flags = doNotSizeWithWindow.setShortBoolean(field_1_flags, value); 253 } 254 255 259 public boolean isDoNotSizeWithWindow() 260 { 261 return doNotSizeWithWindow.isSet(field_1_flags); 262 } 263 264 268 public void setDefaultPlotDimensions(boolean value) 269 { 270 field_1_flags = defaultPlotDimensions.setShortBoolean(field_1_flags, value); 271 } 272 273 277 public boolean isDefaultPlotDimensions() 278 { 279 return defaultPlotDimensions.isSet(field_1_flags); 280 } 281 282 286 public void setAutoPlotArea(boolean value) 287 { 288 field_1_flags = autoPlotArea.setShortBoolean(field_1_flags, value); 289 } 290 291 295 public boolean isAutoPlotArea() 296 { 297 return autoPlotArea.isSet(field_1_flags); 298 } 299 300 301 } 303 304 305 306 | Popular Tags |