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 PaneRecord 34 extends Record 35 { 36 public final static short sid = 0x41; 37 private short field_1_x; 38 private short field_2_y; 39 private short field_3_topRow; 40 private short field_4_leftColumn; 41 private short field_5_activePane; 42 public final static short ACTIVE_PANE_LOWER_RIGHT = 0; 43 public final static short ACTIVE_PANE_UPPER_RIGHT = 1; 44 public final static short ACTIVE_PANE_LOWER_LEFT = 2; 45 public final static short ACTIVE_PANE_UPER_LEFT = 3; 46 47 48 public PaneRecord() 49 { 50 51 } 52 53 61 62 public PaneRecord(short id, short size, byte [] data) 63 { 64 super(id, size, data); 65 66 } 67 68 77 78 public PaneRecord(short id, short size, byte [] data, int offset) 79 { 80 super(id, size, data, offset); 81 82 } 83 84 89 protected void validateSid(short id) 90 { 91 if (id != sid) 92 { 93 throw new RecordFormatException("Not a Pane record"); 94 } 95 } 96 97 protected void fillFields(byte [] data, short size, int offset) 98 { 99 100 int pos = 0; 101 field_1_x = LittleEndian.getShort(data, pos + 0x0 + offset); 102 field_2_y = LittleEndian.getShort(data, pos + 0x2 + offset); 103 field_3_topRow = LittleEndian.getShort(data, pos + 0x4 + offset); 104 field_4_leftColumn = LittleEndian.getShort(data, pos + 0x6 + offset); 105 field_5_activePane = LittleEndian.getShort(data, pos + 0x8 + offset); 106 107 } 108 109 public String toString() 110 { 111 StringBuffer buffer = new StringBuffer (); 112 113 buffer.append("[PANE]\n"); 114 buffer.append(" .x = ") 115 .append("0x").append(HexDump.toHex( getX ())) 116 .append(" (").append( getX() ).append(" )"); 117 buffer.append(System.getProperty("line.separator")); 118 buffer.append(" .y = ") 119 .append("0x").append(HexDump.toHex( getY ())) 120 .append(" (").append( getY() ).append(" )"); 121 buffer.append(System.getProperty("line.separator")); 122 buffer.append(" .topRow = ") 123 .append("0x").append(HexDump.toHex( getTopRow ())) 124 .append(" (").append( getTopRow() ).append(" )"); 125 buffer.append(System.getProperty("line.separator")); 126 buffer.append(" .leftColumn = ") 127 .append("0x").append(HexDump.toHex( getLeftColumn ())) 128 .append(" (").append( getLeftColumn() ).append(" )"); 129 buffer.append(System.getProperty("line.separator")); 130 buffer.append(" .activePane = ") 131 .append("0x").append(HexDump.toHex( getActivePane ())) 132 .append(" (").append( getActivePane() ).append(" )"); 133 buffer.append(System.getProperty("line.separator")); 134 135 buffer.append("[/PANE]\n"); 136 return buffer.toString(); 137 } 138 139 public int serialize(int offset, byte[] data) 140 { 141 int pos = 0; 142 143 LittleEndian.putShort(data, 0 + offset, sid); 144 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 145 146 LittleEndian.putShort(data, 4 + offset + pos, field_1_x); 147 LittleEndian.putShort(data, 6 + offset + pos, field_2_y); 148 LittleEndian.putShort(data, 8 + offset + pos, field_3_topRow); 149 LittleEndian.putShort(data, 10 + offset + pos, field_4_leftColumn); 150 LittleEndian.putShort(data, 12 + offset + pos, field_5_activePane); 151 152 return getRecordSize(); 153 } 154 155 158 public int getRecordSize() 159 { 160 return 4 + 2 + 2 + 2 + 2 + 2; 161 } 162 163 public short getSid() 164 { 165 return this.sid; 166 } 167 168 public Object clone() { 169 PaneRecord rec = new PaneRecord(); 170 171 rec.field_1_x = field_1_x; 172 rec.field_2_y = field_2_y; 173 rec.field_3_topRow = field_3_topRow; 174 rec.field_4_leftColumn = field_4_leftColumn; 175 rec.field_5_activePane = field_5_activePane; 176 return rec; 177 } 178 179 180 181 182 185 public short getX() 186 { 187 return field_1_x; 188 } 189 190 193 public void setX(short field_1_x) 194 { 195 this.field_1_x = field_1_x; 196 } 197 198 201 public short getY() 202 { 203 return field_2_y; 204 } 205 206 209 public void setY(short field_2_y) 210 { 211 this.field_2_y = field_2_y; 212 } 213 214 217 public short getTopRow() 218 { 219 return field_3_topRow; 220 } 221 222 225 public void setTopRow(short field_3_topRow) 226 { 227 this.field_3_topRow = field_3_topRow; 228 } 229 230 233 public short getLeftColumn() 234 { 235 return field_4_leftColumn; 236 } 237 238 241 public void setLeftColumn(short field_4_leftColumn) 242 { 243 this.field_4_leftColumn = field_4_leftColumn; 244 } 245 246 255 public short getActivePane() 256 { 257 return field_5_activePane; 258 } 259 260 270 public void setActivePane(short field_5_activePane) 271 { 272 this.field_5_activePane = field_5_activePane; 273 } 274 275 276 } 278 279 280 281 | Popular Tags |