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 the frozen and unfozen panes. 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 PaneRecord 71 extends Record 72 { 73 public final static short sid = 0x41; 74 private short field_1_x; 75 private short field_2_y; 76 private short field_3_topRow; 77 private short field_4_leftColumn; 78 private short field_5_activePane; 79 public final static short ACTIVE_PANE_LOWER_RIGHT = 0; 80 public final static short ACTIVE_PANE_UPPER_RIGHT = 1; 81 public final static short ACTIVE_PANE_LOWER_LEFT = 2; 82 public final static short ACTIVE_PANE_UPER_LEFT = 3; 83 84 85 public PaneRecord() 86 { 87 88 } 89 90 /** 91 * Constructs a Pane record and sets its fields appropriately. 92 * 93 * @param id id must be 0x41 or an exception 94 * will be throw upon validation 95 * @param size size the size of the data area of the record 96 * @param data data of the record (should not contain sid/len) 97 */ 98 99 public PaneRecord(short id, short size, byte [] data) 100 { 101 super(id, size, data); 102 103 } 104 105 /** 106 * Constructs a Pane record and sets its fields appropriately. 107 * 108 * @param id id must be 0x41 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 PaneRecord(short id, short size, byte [] data, int offset) 116 { 117 super(id, size, data, offset); 118 119 } 120 121 /** 122 * Checks the sid matches the expected side for this record 123 * 124 * @param id the expected sid. 125 */ 126 protected void validateSid(short id) 127 { 128 if (id != sid) 129 { 130 throw new RecordFormatException("Not a Pane record"); 131 } 132 } 133 134 protected void fillFields(byte [] data, short size, int offset) 135 { 136 137 int pos = 0; 138 field_1_x = LittleEndian.getShort(data, pos + 0x0 + offset); 139 field_2_y = LittleEndian.getShort(data, pos + 0x2 + offset); 140 field_3_topRow = LittleEndian.getShort(data, pos + 0x4 + offset); 141 field_4_leftColumn = LittleEndian.getShort(data, pos + 0x6 + offset); 142 field_5_activePane = LittleEndian.getShort(data, pos + 0x8 + offset); 143 144 } 145 146 public String toString() 147 { 148 StringBuffer buffer = new StringBuffer(); 149 150 buffer.append("[PANE]\n"); 151 buffer.append(" .x = ") 152 .append("0x").append(HexDump.toHex( getX ())) 153 .append(" (").append( getX() ).append(" )"); 154 buffer.append(System.getProperty("line.separator")); 155 buffer.append(" .y = ") 156 .append("0x").append(HexDump.toHex( getY ())) 157 .append(" (").append( getY() ).append(" )"); 158 buffer.append(System.getProperty("line.separator")); 159 buffer.append(" .topRow = ") 160 .append("0x").append(HexDump.toHex( getTopRow ())) 161 .append(" (").append( getTopRow() ).append(" )"); 162 buffer.append(System.getProperty("line.separator")); 163 buffer.append(" .leftColumn = ") 164 .append("0x").append(HexDump.toHex( getLeftColumn ())) 165 .append(" (").append( getLeftColumn() ).append(" )"); 166 buffer.append(System.getProperty("line.separator")); 167 buffer.append(" .activePane = ") 168 .append("0x").append(HexDump.toHex( getActivePane ())) 169 .append(" (").append( getActivePane() ).append(" )"); 170 buffer.append(System.getProperty("line.separator")); 171 172 buffer.append("[/PANE]\n"); 173 return buffer.toString(); 174 } 175 176 public int serialize(int offset, byte[] data) 177 { 178 int pos = 0; 179 180 LittleEndian.putShort(data, 0 + offset, sid); 181 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 182 183 LittleEndian.putShort(data, 4 + offset + pos, field_1_x); 184 LittleEndian.putShort(data, 6 + offset + pos, field_2_y); 185 LittleEndian.putShort(data, 8 + offset + pos, field_3_topRow); 186 LittleEndian.putShort(data, 10 + offset + pos, field_4_leftColumn); 187 LittleEndian.putShort(data, 12 + offset + pos, field_5_activePane); 188 189 return getRecordSize(); 190 } 191 192 /** 193 * Size of record (exluding 4 byte header) 194 */ 195 public int getRecordSize() 196 { 197 return 4 + 2 + 2 + 2 + 2 + 2; 198 } 199 200 public short getSid() 201 { 202 return this.sid; 203 } 204 205 public Object clone() { 206 PaneRecord rec = new PaneRecord(); 207 208 rec.field_1_x = field_1_x; 209 rec.field_2_y = field_2_y; 210 rec.field_3_topRow = field_3_topRow; 211 rec.field_4_leftColumn = field_4_leftColumn; 212 rec.field_5_activePane = field_5_activePane; 213 return rec; 214 } 215 216 217 218 219 /** 220 * Get the x field for the Pane record. 221 */ 222 public short getX() 223 { 224 return field_1_x; 225 } 226 227 /** 228 * Set the x field for the Pane record. 229 */ 230 public void setX(short field_1_x) 231 { 232 this.field_1_x = field_1_x; 233 } 234 235 /** 236 * Get the y field for the Pane record. 237 */ 238 public short getY() 239 { 240 return field_2_y; 241 } 242 243 /** 244 * Set the y field for the Pane record. 245 */ 246 public void setY(short field_2_y) 247 { 248 this.field_2_y = field_2_y; 249 } 250 251 /** 252 * Get the top row field for the Pane record. 253 */ 254 public short getTopRow() 255 { 256 return field_3_topRow; 257 } 258 259 /** 260 * Set the top row field for the Pane record. 261 */ 262 public void setTopRow(short field_3_topRow) 263 { 264 this.field_3_topRow = field_3_topRow; 265 } 266 267 /** 268 * Get the left column field for the Pane record. 269 */ 270 public short getLeftColumn() 271 { 272 return field_4_leftColumn; 273 } 274 275 /** 276 * Set the left column field for the Pane record. 277 */ 278 public void setLeftColumn(short field_4_leftColumn) 279 { 280 this.field_4_leftColumn = field_4_leftColumn; 281 } 282 283 /** 284 * Get the active pane field for the Pane record. 285 * 286 * @return One of 287 * ACTIVE_PANE_LOWER_RIGHT 288 * ACTIVE_PANE_UPPER_RIGHT 289 * ACTIVE_PANE_LOWER_LEFT 290 * ACTIVE_PANE_UPER_LEFT 291 */ 292 public short getActivePane() 293 { 294 return field_5_activePane; 295 } 296 297 /** 298 * Set the active pane field for the Pane record. 299 * 300 * @param field_5_activePane 301 * One of 302 * ACTIVE_PANE_LOWER_RIGHT 303 * ACTIVE_PANE_UPPER_RIGHT 304 * ACTIVE_PANE_LOWER_LEFT 305 * ACTIVE_PANE_UPER_LEFT 306 */ 307 public void setActivePane(short field_5_activePane) 308 { 309 this.field_5_activePane = field_5_activePane; 310 } 311 312 313 } // END OF CLASS 314 315 316 317 318