1 2 /* ==================================================================== 3 * The Apache Software License, Version 1.1 4 * 5 * Copyright (c) 2002 The Apache Software Foundation. All rights 6 * reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in 17 * the documentation and/or other materials provided with the 18 * distribution. 19 * 20 * 3. The end-user documentation included with the redistribution, 21 * if any, must include the following acknowledgment: 22 * "This product includes software developed by the 23 * Apache Software Foundation (http://www.apache.org/)." 24 * Alternately, this acknowledgment may appear in the software itself, 25 * if and wherever such third-party acknowledgments normally appear. 26 * 27 * 4. The names "Apache" and "Apache Software Foundation" and 28 * "Apache POI" must not be used to endorse or promote products 29 * derived from this software without prior written permission. For 30 * written permission, please contact apache@apache.org. 31 * 32 * 5. Products derived from this software may not be called "Apache", 33 * "Apache POI", nor may "Apache" appear in their name, without 34 * prior written permission of the Apache Software Foundation. 35 * 36 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 37 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 38 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 39 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 42 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 43 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 44 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 45 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 46 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 47 * SUCH DAMAGE. 48 * ==================================================================== 49 * 50 * This software consists of voluntary contributions made by many 51 * individuals on behalf of the Apache Software Foundation. For more 52 * information on the Apache Software Foundation, please see 53 * <http://www.apache.org/>. 54 */ 55 56 57 package org.apache.poi.hssf.record; 58 59 60 61 import org.apache.poi.util.*; 62 63 /** 64 * Describes a chart sheet properties record. 65 * NOTE: This source is automatically generated please do not modify this file. Either subclass or 66 * remove the record in src/records/definitions. 67 68 * @author Glen Stampoultzis (glens at apache.org) 69 */ 70 public class SheetPropertiesRecord 71 extends Record 72 { 73 public final static short sid = 0x1044; 74 private short field_1_flags; 75 private BitField chartTypeManuallyFormatted = new BitField(0x1); 76 private BitField plotVisibleOnly = new BitField(0x2); 77 private BitField doNotSizeWithWindow = new BitField(0x4); 78 private BitField defaultPlotDimensions = new BitField(0x8); 79 private BitField autoPlotArea = new BitField(0x10); 80 private byte field_2_empty; 81 public final static byte EMPTY_NOT_PLOTTED = 0; 82 public final static byte EMPTY_ZERO = 1; 83 public final static byte EMPTY_INTERPOLATED = 2; 84 85 86 public SheetPropertiesRecord() 87 { 88 89 } 90 91 /** 92 * Constructs a SheetProperties record and sets its fields appropriately. 93 * 94 * @param id id must be 0x1044 or an exception 95 * will be throw upon validation 96 * @param size size the size of the data area of the record 97 * @param data data of the record (should not contain sid/len) 98 */ 99 100 public SheetPropertiesRecord(short id, short size, byte [] data) 101 { 102 super(id, size, data); 103 } 104 105 /** 106 * Constructs a SheetProperties record and sets its fields appropriately. 107 * 108 * @param id id must be 0x1044 or an exception 109 * will be throw upon validation 110 * @param size size the size of the data area of the record 111 * @param data data of the record (should not contain sid/len) 112 * @param offset of the record's data 113 */ 114 115 public SheetPropertiesRecord(short id, short size, byte [] data, int offset) 116 { 117 super(id, size, data, offset); 118 } 119 120 /** 121 * Checks the sid matches the expected side for this record 122 * 123 * @param id the expected sid. 124 */ 125 protected void validateSid(short id) 126 { 127 if (id != sid) 128 { 129 throw new RecordFormatException("Not a SheetProperties record"); 130 } 131 } 132 133 protected void fillFields(byte [] data, short size, int offset) 134 { 135 field_1_flags = LittleEndian.getShort(data, 0x0 + offset); 136 field_2_empty = data[ 0x2 + offset ]; 137 138 } 139 140 public String toString() 141 { 142 StringBuffer buffer = new StringBuffer(); 143 144 buffer.append("[SheetProperties]\n"); 145 146 buffer.append(" .flags = ") 147 .append("0x") 148 .append(HexDump.toHex((short)getFlags())) 149 .append(" (").append(getFlags()).append(" )\n"); 150 buffer.append(" .chartTypeManuallyFormatted = ").append(isChartTypeManuallyFormatted()).append('\n'); 151 buffer.append(" .plotVisibleOnly = ").append(isPlotVisibleOnly ()).append('\n'); 152 buffer.append(" .doNotSizeWithWindow = ").append(isDoNotSizeWithWindow ()).append('\n'); 153 buffer.append(" .defaultPlotDimensions = ").append(isDefaultPlotDimensions()).append('\n'); 154 buffer.append(" .autoPlotArea = ").append(isAutoPlotArea ()).append('\n'); 155 156 buffer.append(" .empty = ") 157 .append("0x") 158 .append(HexDump.toHex((byte)getEmpty())) 159 .append(" (").append(getEmpty()).append(" )\n"); 160 161 buffer.append("[/SheetProperties]\n"); 162 return buffer.toString(); 163 } 164 165 public int serialize(int offset, byte[] data) 166 { 167 LittleEndian.putShort(data, 0 + offset, sid); 168 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 169 170 LittleEndian.putShort(data, 4 + offset, field_1_flags); 171 data[ 6 + offset ] = field_2_empty; 172 173 return getRecordSize(); 174 } 175 176 /** 177 * Size of record (exluding 4 byte header) 178 */ 179 public int getRecordSize() 180 { 181 return 4 + 2 + 1; 182 } 183 184 public short getSid() 185 { 186 return this.sid; 187 } 188 189 190 /** 191 * Get the flags field for the SheetProperties record. 192 */ 193 public short getFlags() 194 { 195 return field_1_flags; 196 } 197 198 /** 199 * Set the flags field for the SheetProperties record. 200 */ 201 public void setFlags(short field_1_flags) 202 { 203 this.field_1_flags = field_1_flags; 204 } 205 206 /** 207 * Get the empty field for the SheetProperties record. 208 * 209 * @return One of 210 * EMPTY_NOT_PLOTTED 211 * EMPTY_ZERO 212 * EMPTY_INTERPOLATED 213 */ 214 public byte getEmpty() 215 { 216 return field_2_empty; 217 } 218 219 /** 220 * Set the empty field for the SheetProperties record. 221 * 222 * @param field_2_empty 223 * One of 224 * EMPTY_NOT_PLOTTED 225 * EMPTY_ZERO 226 * EMPTY_INTERPOLATED 227 */ 228 public void setEmpty(byte field_2_empty) 229 { 230 this.field_2_empty = field_2_empty; 231 } 232 233 /** 234 * Sets the chart type manually formatted field value. 235 * Has the chart type been manually formatted? 236 */ 237 public void setChartTypeManuallyFormatted(boolean value) 238 { 239 field_1_flags = chartTypeManuallyFormatted.setShortBoolean(field_1_flags, value); 240 } 241 242 /** 243 * Has the chart type been manually formatted? 244 * @return the chart type manually formatted field value. 245 */ 246 public boolean isChartTypeManuallyFormatted() 247 { 248 return chartTypeManuallyFormatted.isSet(field_1_flags); 249 } 250 251 /** 252 * Sets the plot visible only field value. 253 * Only show visible cells on the chart. 254 */ 255 public void setPlotVisibleOnly(boolean value) 256 { 257 field_1_flags = plotVisibleOnly.setShortBoolean(field_1_flags, value); 258 } 259 260 /** 261 * Only show visible cells on the chart. 262 * @return the plot visible only field value. 263 */ 264 public boolean isPlotVisibleOnly() 265 { 266 return plotVisibleOnly.isSet(field_1_flags); 267 } 268 269 /** 270 * Sets the do not size with window field value. 271 * Do not size the chart when the window changes size 272 */ 273 public void setDoNotSizeWithWindow(boolean value) 274 { 275 field_1_flags = doNotSizeWithWindow.setShortBoolean(field_1_flags, value); 276 } 277 278 /** 279 * Do not size the chart when the window changes size 280 * @return the do not size with window field value. 281 */ 282 public boolean isDoNotSizeWithWindow() 283 { 284 return doNotSizeWithWindow.isSet(field_1_flags); 285 } 286 287 /** 288 * Sets the default plot dimensions field value. 289 * Indicates that the default area dimensions should be used. 290 */ 291 public void setDefaultPlotDimensions(boolean value) 292 { 293 field_1_flags = defaultPlotDimensions.setShortBoolean(field_1_flags, value); 294 } 295 296 /** 297 * Indicates that the default area dimensions should be used. 298 * @return the default plot dimensions field value. 299 */ 300 public boolean isDefaultPlotDimensions() 301 { 302 return defaultPlotDimensions.isSet(field_1_flags); 303 } 304 305 /** 306 * Sets the auto plot area field value. 307 * ?? 308 */ 309 public void setAutoPlotArea(boolean value) 310 { 311 field_1_flags = autoPlotArea.setShortBoolean(field_1_flags, value); 312 } 313 314 /** 315 * ?? 316 * @return the auto plot area field value. 317 */ 318 public boolean isAutoPlotArea() 319 { 320 return autoPlotArea.isSet(field_1_flags); 321 } 322 323 324 } // END OF CLASS 325 326 327 328 329