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.BitField; 62 import org.apache.poi.util.LittleEndian; 63 import org.apache.poi.util.StringUtil; 64 import org.apache.poi.util.HexDump; 65 66 /** 67 * Describes a chart sheet properties record. 68 * NOTE: This source is automatically generated please do not modify this file. Either subclass or 69 * remove the record in src/records/definitions. 70 71 * @author Glen Stampoultzis (glens at apache.org) 72 */ 73 public class SheetPropertiesRecord 74 extends Record 75 { 76 public final static short sid = 0x1044; 77 private short field_1_flags; 78 private BitField chartTypeManuallyFormatted = new BitField(0x1); 79 private BitField plotVisibleOnly = new BitField(0x2); 80 private BitField doNotSizeWithWindow = new BitField(0x4); 81 private BitField defaultPlotDimensions = new BitField(0x8); 82 private BitField autoPlotArea = new BitField(0x10); 83 private byte field_2_empty; 84 public final static byte EMPTY_NOT_PLOTTED = 0; 85 public final static byte EMPTY_ZERO = 1; 86 public final static byte EMPTY_INTERPOLATED = 2; 87 88 89 public SheetPropertiesRecord() 90 { 91 92 } 93 94 /** 95 * Constructs a SheetProperties record and sets its fields appropriately. 96 * 97 * @param id id must be 0x1044 or an exception 98 * will be throw upon validation 99 * @param size size the size of the data area of the record 100 * @param data data of the record (should not contain sid/len) 101 */ 102 103 public SheetPropertiesRecord(short id, short size, byte [] data) 104 { 105 super(id, size, data); 106 } 107 108 /** 109 * Constructs a SheetProperties record and sets its fields appropriately. 110 * 111 * @param id id must be 0x1044 or an exception 112 * will be throw upon validation 113 * @param size size the size of the data area of the record 114 * @param data data of the record (should not contain sid/len) 115 * @param offset of the record's data 116 */ 117 118 public SheetPropertiesRecord(short id, short size, byte [] data, int offset) 119 { 120 super(id, size, data, offset); 121 } 122 123 /** 124 * Checks the sid matches the expected side for this record 125 * 126 * @param id the expected sid. 127 */ 128 protected void validateSid(short id) 129 { 130 if (id != sid) 131 { 132 throw new RecordFormatException("Not a SheetProperties record"); 133 } 134 } 135 136 protected void fillFields(byte [] data, short size, int offset) 137 { 138 field_1_flags = LittleEndian.getShort(data, 0x0 + offset); 139 field_2_empty = data[ 0x2 + offset ]; 140 141 } 142 143 public String toString() 144 { 145 StringBuffer buffer = new StringBuffer(); 146 147 buffer.append("[SheetProperties]\n"); 148 149 buffer.append(" .flags = ") 150 .append("0x") 151 .append(HexDump.toHex((short)getFlags())) 152 .append(" (").append(getFlags()).append(" )\n"); 153 buffer.append(" .chartTypeManuallyFormatted = ").append(isChartTypeManuallyFormatted()).append('\n'); 154 buffer.append(" .plotVisibleOnly = ").append(isPlotVisibleOnly ()).append('\n'); 155 buffer.append(" .doNotSizeWithWindow = ").append(isDoNotSizeWithWindow ()).append('\n'); 156 buffer.append(" .defaultPlotDimensions = ").append(isDefaultPlotDimensions()).append('\n'); 157 buffer.append(" .autoPlotArea = ").append(isAutoPlotArea ()).append('\n'); 158 159 buffer.append(" .empty = ") 160 .append("0x") 161 .append(HexDump.toHex((byte)getEmpty())) 162 .append(" (").append(getEmpty()).append(" )\n"); 163 164 buffer.append("[/SheetProperties]\n"); 165 return buffer.toString(); 166 } 167 168 public int serialize(int offset, byte[] data) 169 { 170 LittleEndian.putShort(data, 0 + offset, sid); 171 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 172 173 LittleEndian.putShort(data, 4 + offset, field_1_flags); 174 data[ 6 + offset ] = field_2_empty; 175 176 return getRecordSize(); 177 } 178 179 /** 180 * Size of record (exluding 4 byte header) 181 */ 182 public int getRecordSize() 183 { 184 return 4 + 2 + 1; 185 } 186 187 public short getSid() 188 { 189 return this.sid; 190 } 191 192 193 /** 194 * Get the flags field for the SheetProperties record. 195 */ 196 public short getFlags() 197 { 198 return field_1_flags; 199 } 200 201 /** 202 * Set the flags field for the SheetProperties record. 203 */ 204 public void setFlags(short field_1_flags) 205 { 206 this.field_1_flags = field_1_flags; 207 } 208 209 /** 210 * Get the empty field for the SheetProperties record. 211 * 212 * @return One of 213 * EMPTY_NOT_PLOTTED 214 * EMPTY_ZERO 215 * EMPTY_INTERPOLATED 216 */ 217 public byte getEmpty() 218 { 219 return field_2_empty; 220 } 221 222 /** 223 * Set the empty field for the SheetProperties record. 224 * 225 * @param field_2_empty 226 * One of 227 * EMPTY_NOT_PLOTTED 228 * EMPTY_ZERO 229 * EMPTY_INTERPOLATED 230 */ 231 public void setEmpty(byte field_2_empty) 232 { 233 this.field_2_empty = field_2_empty; 234 } 235 236 /** 237 * Sets the chart type manually formatted field value. 238 * Has the chart type been manually formatted? 239 */ 240 public void setChartTypeManuallyFormatted(boolean value) 241 { 242 field_1_flags = chartTypeManuallyFormatted.setShortBoolean(field_1_flags, value); 243 } 244 245 /** 246 * Has the chart type been manually formatted? 247 * @return the chart type manually formatted field value. 248 */ 249 public boolean isChartTypeManuallyFormatted() 250 { 251 return chartTypeManuallyFormatted.isSet(field_1_flags); 252 } 253 254 /** 255 * Sets the plot visible only field value. 256 * Only show visible cells on the chart. 257 */ 258 public void setPlotVisibleOnly(boolean value) 259 { 260 field_1_flags = plotVisibleOnly.setShortBoolean(field_1_flags, value); 261 } 262 263 /** 264 * Only show visible cells on the chart. 265 * @return the plot visible only field value. 266 */ 267 public boolean isPlotVisibleOnly() 268 { 269 return plotVisibleOnly.isSet(field_1_flags); 270 } 271 272 /** 273 * Sets the do not size with window field value. 274 * Do not size the chart when the window changes size 275 */ 276 public void setDoNotSizeWithWindow(boolean value) 277 { 278 field_1_flags = doNotSizeWithWindow.setShortBoolean(field_1_flags, value); 279 } 280 281 /** 282 * Do not size the chart when the window changes size 283 * @return the do not size with window field value. 284 */ 285 public boolean isDoNotSizeWithWindow() 286 { 287 return doNotSizeWithWindow.isSet(field_1_flags); 288 } 289 290 /** 291 * Sets the default plot dimensions field value. 292 * Indicates that the default area dimensions should be used. 293 */ 294 public void setDefaultPlotDimensions(boolean value) 295 { 296 field_1_flags = defaultPlotDimensions.setShortBoolean(field_1_flags, value); 297 } 298 299 /** 300 * Indicates that the default area dimensions should be used. 301 * @return the default plot dimensions field value. 302 */ 303 public boolean isDefaultPlotDimensions() 304 { 305 return defaultPlotDimensions.isSet(field_1_flags); 306 } 307 308 /** 309 * Sets the auto plot area field value. 310 * ?? 311 */ 312 public void setAutoPlotArea(boolean value) 313 { 314 field_1_flags = autoPlotArea.setShortBoolean(field_1_flags, value); 315 } 316 317 /** 318 * ?? 319 * @return the auto plot area field value. 320 */ 321 public boolean isAutoPlotArea() 322 { 323 return autoPlotArea.isSet(field_1_flags); 324 } 325 326 327 } // END OF CLASS 328 329 330 331 332