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 FontBasisRecord 34 extends Record 35 { 36 public final static short sid = 0x1060; 37 private short field_1_xBasis; 38 private short field_2_yBasis; 39 private short field_3_heightBasis; 40 private short field_4_scale; 41 private short field_5_indexToFontTable; 42 43 44 public FontBasisRecord() 45 { 46 47 } 48 49 57 58 public FontBasisRecord(short id, short size, byte [] data) 59 { 60 super(id, size, data); 61 62 } 63 64 73 74 public FontBasisRecord(short id, short size, byte [] data, int offset) 75 { 76 super(id, size, data, offset); 77 78 } 79 80 85 protected void validateSid(short id) 86 { 87 if (id != sid) 88 { 89 throw new RecordFormatException("Not a FontBasis record"); 90 } 91 } 92 93 protected void fillFields(byte [] data, short size, int offset) 94 { 95 96 int pos = 0; 97 field_1_xBasis = LittleEndian.getShort(data, pos + 0x0 + offset); 98 field_2_yBasis = LittleEndian.getShort(data, pos + 0x2 + offset); 99 field_3_heightBasis = LittleEndian.getShort(data, pos + 0x4 + offset); 100 field_4_scale = LittleEndian.getShort(data, pos + 0x6 + offset); 101 field_5_indexToFontTable = LittleEndian.getShort(data, pos + 0x8 + offset); 102 103 } 104 105 public String toString() 106 { 107 StringBuffer buffer = new StringBuffer (); 108 109 buffer.append("[FBI]\n"); 110 buffer.append(" .xBasis = ") 111 .append("0x").append(HexDump.toHex( getXBasis ())) 112 .append(" (").append( getXBasis() ).append(" )"); 113 buffer.append(System.getProperty("line.separator")); 114 buffer.append(" .yBasis = ") 115 .append("0x").append(HexDump.toHex( getYBasis ())) 116 .append(" (").append( getYBasis() ).append(" )"); 117 buffer.append(System.getProperty("line.separator")); 118 buffer.append(" .heightBasis = ") 119 .append("0x").append(HexDump.toHex( getHeightBasis ())) 120 .append(" (").append( getHeightBasis() ).append(" )"); 121 buffer.append(System.getProperty("line.separator")); 122 buffer.append(" .scale = ") 123 .append("0x").append(HexDump.toHex( getScale ())) 124 .append(" (").append( getScale() ).append(" )"); 125 buffer.append(System.getProperty("line.separator")); 126 buffer.append(" .indexToFontTable = ") 127 .append("0x").append(HexDump.toHex( getIndexToFontTable ())) 128 .append(" (").append( getIndexToFontTable() ).append(" )"); 129 buffer.append(System.getProperty("line.separator")); 130 131 buffer.append("[/FBI]\n"); 132 return buffer.toString(); 133 } 134 135 public int serialize(int offset, byte[] data) 136 { 137 int pos = 0; 138 139 LittleEndian.putShort(data, 0 + offset, sid); 140 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 141 142 LittleEndian.putShort(data, 4 + offset + pos, field_1_xBasis); 143 LittleEndian.putShort(data, 6 + offset + pos, field_2_yBasis); 144 LittleEndian.putShort(data, 8 + offset + pos, field_3_heightBasis); 145 LittleEndian.putShort(data, 10 + offset + pos, field_4_scale); 146 LittleEndian.putShort(data, 12 + offset + pos, field_5_indexToFontTable); 147 148 return getRecordSize(); 149 } 150 151 154 public int getRecordSize() 155 { 156 return 4 + 2 + 2 + 2 + 2 + 2; 157 } 158 159 public short getSid() 160 { 161 return this.sid; 162 } 163 164 public Object clone() { 165 FontBasisRecord rec = new FontBasisRecord(); 166 167 rec.field_1_xBasis = field_1_xBasis; 168 rec.field_2_yBasis = field_2_yBasis; 169 rec.field_3_heightBasis = field_3_heightBasis; 170 rec.field_4_scale = field_4_scale; 171 rec.field_5_indexToFontTable = field_5_indexToFontTable; 172 return rec; 173 } 174 175 176 177 178 181 public short getXBasis() 182 { 183 return field_1_xBasis; 184 } 185 186 189 public void setXBasis(short field_1_xBasis) 190 { 191 this.field_1_xBasis = field_1_xBasis; 192 } 193 194 197 public short getYBasis() 198 { 199 return field_2_yBasis; 200 } 201 202 205 public void setYBasis(short field_2_yBasis) 206 { 207 this.field_2_yBasis = field_2_yBasis; 208 } 209 210 213 public short getHeightBasis() 214 { 215 return field_3_heightBasis; 216 } 217 218 221 public void setHeightBasis(short field_3_heightBasis) 222 { 223 this.field_3_heightBasis = field_3_heightBasis; 224 } 225 226 229 public short getScale() 230 { 231 return field_4_scale; 232 } 233 234 237 public void setScale(short field_4_scale) 238 { 239 this.field_4_scale = field_4_scale; 240 } 241 242 245 public short getIndexToFontTable() 246 { 247 return field_5_indexToFontTable; 248 } 249 250 253 public void setIndexToFontTable(short field_5_indexToFontTable) 254 { 255 this.field_5_indexToFontTable = field_5_indexToFontTable; 256 } 257 258 259 } 261 262 263 264 | Popular Tags |