Inspired by bug #44958 - Record level support for Data Tables. (No formula parser...
[poi.git] / src / java / org / apache / poi / hssf / record / FontBasisRecord.java
bloba2a45e23c1a75380dd9e7feeae618d5fe45f0e80
2 /* ====================================================================
3 Licensed to the Apache Software Foundation (ASF) under one or more
4 contributor license agreements. See the NOTICE file distributed with
5 this work for additional information regarding copyright ownership.
6 The ASF licenses this file to You under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with
8 the License. You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================== */
20 package org.apache.poi.hssf.record;
24 import org.apache.poi.util.*;
26 /**
27 * The font basis record stores various font metrics.
28 * NOTE: This source is automatically generated please do not modify this file. Either subclass or
29 * remove the record in src/records/definitions.
31 * @author Glen Stampoultzis (glens at apache.org)
33 public class FontBasisRecord
34 extends Record
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;
44 public FontBasisRecord()
49 /**
50 * Constructs a FontBasis record and sets its fields appropriately.
52 * @param in the RecordInputstream to read the record from
55 public FontBasisRecord(RecordInputStream in)
57 super(in);
61 /**
62 * Checks the sid matches the expected side for this record
64 * @param id the expected sid.
66 protected void validateSid(short id)
68 if (id != sid)
70 throw new RecordFormatException("Not a FontBasis record");
74 protected void fillFields(RecordInputStream in)
76 field_1_xBasis = in.readShort();
77 field_2_yBasis = in.readShort();
78 field_3_heightBasis = in.readShort();
79 field_4_scale = in.readShort();
80 field_5_indexToFontTable = in.readShort();
83 public String toString()
85 StringBuffer buffer = new StringBuffer();
87 buffer.append("[FBI]\n");
88 buffer.append(" .xBasis = ")
89 .append("0x").append(HexDump.toHex( getXBasis ()))
90 .append(" (").append( getXBasis() ).append(" )");
91 buffer.append(System.getProperty("line.separator"));
92 buffer.append(" .yBasis = ")
93 .append("0x").append(HexDump.toHex( getYBasis ()))
94 .append(" (").append( getYBasis() ).append(" )");
95 buffer.append(System.getProperty("line.separator"));
96 buffer.append(" .heightBasis = ")
97 .append("0x").append(HexDump.toHex( getHeightBasis ()))
98 .append(" (").append( getHeightBasis() ).append(" )");
99 buffer.append(System.getProperty("line.separator"));
100 buffer.append(" .scale = ")
101 .append("0x").append(HexDump.toHex( getScale ()))
102 .append(" (").append( getScale() ).append(" )");
103 buffer.append(System.getProperty("line.separator"));
104 buffer.append(" .indexToFontTable = ")
105 .append("0x").append(HexDump.toHex( getIndexToFontTable ()))
106 .append(" (").append( getIndexToFontTable() ).append(" )");
107 buffer.append(System.getProperty("line.separator"));
109 buffer.append("[/FBI]\n");
110 return buffer.toString();
113 public int serialize(int offset, byte[] data)
115 int pos = 0;
117 LittleEndian.putShort(data, 0 + offset, sid);
118 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
120 LittleEndian.putShort(data, 4 + offset + pos, field_1_xBasis);
121 LittleEndian.putShort(data, 6 + offset + pos, field_2_yBasis);
122 LittleEndian.putShort(data, 8 + offset + pos, field_3_heightBasis);
123 LittleEndian.putShort(data, 10 + offset + pos, field_4_scale);
124 LittleEndian.putShort(data, 12 + offset + pos, field_5_indexToFontTable);
126 return getRecordSize();
130 * Size of record (exluding 4 byte header)
132 public int getRecordSize()
134 return 4 + 2 + 2 + 2 + 2 + 2;
137 public short getSid()
139 return sid;
142 public Object clone() {
143 FontBasisRecord rec = new FontBasisRecord();
145 rec.field_1_xBasis = field_1_xBasis;
146 rec.field_2_yBasis = field_2_yBasis;
147 rec.field_3_heightBasis = field_3_heightBasis;
148 rec.field_4_scale = field_4_scale;
149 rec.field_5_indexToFontTable = field_5_indexToFontTable;
150 return rec;
157 * Get the x Basis field for the FontBasis record.
159 public short getXBasis()
161 return field_1_xBasis;
165 * Set the x Basis field for the FontBasis record.
167 public void setXBasis(short field_1_xBasis)
169 this.field_1_xBasis = field_1_xBasis;
173 * Get the y Basis field for the FontBasis record.
175 public short getYBasis()
177 return field_2_yBasis;
181 * Set the y Basis field for the FontBasis record.
183 public void setYBasis(short field_2_yBasis)
185 this.field_2_yBasis = field_2_yBasis;
189 * Get the height basis field for the FontBasis record.
191 public short getHeightBasis()
193 return field_3_heightBasis;
197 * Set the height basis field for the FontBasis record.
199 public void setHeightBasis(short field_3_heightBasis)
201 this.field_3_heightBasis = field_3_heightBasis;
205 * Get the scale field for the FontBasis record.
207 public short getScale()
209 return field_4_scale;
213 * Set the scale field for the FontBasis record.
215 public void setScale(short field_4_scale)
217 this.field_4_scale = field_4_scale;
221 * Get the index to font table field for the FontBasis record.
223 public short getIndexToFontTable()
225 return field_5_indexToFontTable;
229 * Set the index to font table field for the FontBasis record.
231 public void setIndexToFontTable(short field_5_indexToFontTable)
233 this.field_5_indexToFontTable = field_5_indexToFontTable;
237 } // END OF CLASS