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 FrameRecord 34 extends Record 35 { 36 public final static short sid = 0x1032; 37 private short field_1_borderType; 38 public final static short BORDER_TYPE_REGULAR = 0; 39 public final static short BORDER_TYPE_SHADOW = 1; 40 private short field_2_options; 41 private BitField autoSize = new BitField(0x1); 42 private BitField autoPosition = new BitField(0x2); 43 44 45 public FrameRecord() 46 { 47 48 } 49 50 58 59 public FrameRecord(short id, short size, byte [] data) 60 { 61 super(id, size, data); 62 63 } 64 65 74 75 public FrameRecord(short id, short size, byte [] data, int offset) 76 { 77 super(id, size, data, offset); 78 79 } 80 81 86 protected void validateSid(short id) 87 { 88 if (id != sid) 89 { 90 throw new RecordFormatException("Not a Frame record"); 91 } 92 } 93 94 protected void fillFields(byte [] data, short size, int offset) 95 { 96 97 int pos = 0; 98 field_1_borderType = LittleEndian.getShort(data, pos + 0x0 + offset); 99 field_2_options = LittleEndian.getShort(data, pos + 0x2 + offset); 100 101 } 102 103 public String toString() 104 { 105 StringBuffer buffer = new StringBuffer (); 106 107 buffer.append("[FRAME]\n"); 108 buffer.append(" .borderType = ") 109 .append("0x").append(HexDump.toHex( getBorderType ())) 110 .append(" (").append( getBorderType() ).append(" )"); 111 buffer.append(System.getProperty("line.separator")); 112 buffer.append(" .options = ") 113 .append("0x").append(HexDump.toHex( getOptions ())) 114 .append(" (").append( getOptions() ).append(" )"); 115 buffer.append(System.getProperty("line.separator")); 116 buffer.append(" .autoSize = ").append(isAutoSize()).append('\n'); 117 buffer.append(" .autoPosition = ").append(isAutoPosition()).append('\n'); 118 119 buffer.append("[/FRAME]\n"); 120 return buffer.toString(); 121 } 122 123 public int serialize(int offset, byte[] data) 124 { 125 int pos = 0; 126 127 LittleEndian.putShort(data, 0 + offset, sid); 128 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 129 130 LittleEndian.putShort(data, 4 + offset + pos, field_1_borderType); 131 LittleEndian.putShort(data, 6 + offset + pos, field_2_options); 132 133 return getRecordSize(); 134 } 135 136 139 public int getRecordSize() 140 { 141 return 4 + 2 + 2; 142 } 143 144 public short getSid() 145 { 146 return this.sid; 147 } 148 149 public Object clone() { 150 FrameRecord rec = new FrameRecord(); 151 152 rec.field_1_borderType = field_1_borderType; 153 rec.field_2_options = field_2_options; 154 return rec; 155 } 156 157 158 159 160 167 public short getBorderType() 168 { 169 return field_1_borderType; 170 } 171 172 180 public void setBorderType(short field_1_borderType) 181 { 182 this.field_1_borderType = field_1_borderType; 183 } 184 185 188 public short getOptions() 189 { 190 return field_2_options; 191 } 192 193 196 public void setOptions(short field_2_options) 197 { 198 this.field_2_options = field_2_options; 199 } 200 201 205 public void setAutoSize(boolean value) 206 { 207 field_2_options = autoSize.setShortBoolean(field_2_options, value); 208 } 209 210 214 public boolean isAutoSize() 215 { 216 return autoSize.isSet(field_2_options); 217 } 218 219 223 public void setAutoPosition(boolean value) 224 { 225 field_2_options = autoPosition.setShortBoolean(field_2_options, value); 226 } 227 228 232 public boolean isAutoPosition() 233 { 234 return autoPosition.isSet(field_2_options); 235 } 236 237 238 } 240 241 242 243 | Popular Tags |