📄 textobjectbaserecord.java
字号:
/* ==================================================================== Copyright 2002-2004 Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.==================================================================== */ package org.apache.poi.hssf.record;import org.apache.poi.util.*;/** * The TXO record is used to define the properties of a text box. It is followed by two continue records unless there is no actual text. The first continue record contains the text data and the next continue record contains the formatting runs. * NOTE: This source is automatically generated please do not modify this file. Either subclass or * remove the record in src/records/definitions. * @author Glen Stampoultzis (glens at apache.org) */public class TextObjectBaseRecord extends Record{ public final static short sid = 0x1B6; private short field_1_options; private BitField reserved1 = new BitField(0x1); private BitField HorizontalTextAlignment = new BitField(0x000E); public final static short HORIZONTAL_TEXT_ALIGNMENT_LEFT_ALIGNED = 1; public final static short HORIZONTAL_TEXT_ALIGNMENT_CENTERED = 2; public final static short HORIZONTAL_TEXT_ALIGNMENT_RIGHT_ALIGNED = 3; public final static short HORIZONTAL_TEXT_ALIGNMENT_JUSTIFIED = 4; private BitField VerticalTextAlignment = new BitField(0x0070); public final static short VERTICAL_TEXT_ALIGNMENT_TOP = 1; public final static short VERTICAL_TEXT_ALIGNMENT_CENTER = 2; public final static short VERTICAL_TEXT_ALIGNMENT_BOTTOM = 3; public final static short VERTICAL_TEXT_ALIGNMENT_JUSTIFY = 4; private BitField reserved2 = new BitField(0x0180); private BitField textLocked = new BitField(0x200); private BitField reserved3 = new BitField(0xFC00); private short field_2_textOrientation; public final static short TEXT_ORIENTATION_NONE = 0; public final static short TEXT_ORIENTATION_TOP_TO_BOTTOM = 1; public final static short TEXT_ORIENTATION_ROT_RIGHT = 2; public final static short TEXT_ORIENTATION_ROT_LEFT = 3; private short field_3_reserved4; private short field_4_reserved5; private short field_5_reserved6; private short field_6_textLength; private short field_7_formattingRunLength; private int field_8_reserved7; public TextObjectBaseRecord() { } /** * Constructs a TextObjectBase record and sets its fields appropriately. * * @param id id must be 0x1B6 or an exception * will be throw upon validation * @param size size the size of the data area of the record * @param data data of the record (should not contain sid/len) */ public TextObjectBaseRecord(short id, short size, byte [] data) { super(id, size, data); } /** * Constructs a TextObjectBase record and sets its fields appropriately. * * @param id id must be 0x1B6 or an exception * will be throw upon validation * @param size size the size of the data area of the record * @param data data of the record (should not contain sid/len) * @param offset of the record's data */ public TextObjectBaseRecord(short id, short size, byte [] data, int offset) { super(id, size, data, offset); } /** * Checks the sid matches the expected side for this record * * @param id the expected sid. */ protected void validateSid(short id) { if (id != sid) { throw new RecordFormatException("Not a TextObjectBase record"); } } protected void fillFields(byte [] data, short size, int offset) { int pos = 0; field_1_options = LittleEndian.getShort(data, pos + 0x0 + offset); field_2_textOrientation = LittleEndian.getShort(data, pos + 0x2 + offset); field_3_reserved4 = LittleEndian.getShort(data, pos + 0x4 + offset); field_4_reserved5 = LittleEndian.getShort(data, pos + 0x6 + offset); field_5_reserved6 = LittleEndian.getShort(data, pos + 0x8 + offset); field_6_textLength = LittleEndian.getShort(data, pos + 0xa + offset); field_7_formattingRunLength = LittleEndian.getShort(data, pos + 0xc + offset); field_8_reserved7 = LittleEndian.getInt(data, pos + 0xe + offset); } public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("[TXO]\n"); buffer.append(" .options = ") .append("0x").append(HexDump.toHex( getOptions ())) .append(" (").append( getOptions() ).append(" )"); buffer.append(System.getProperty("line.separator")); buffer.append(" .reserved1 = ").append(isReserved1()).append('\n'); buffer.append(" .HorizontalTextAlignment = ").append(getHorizontalTextAlignment()).append('\n'); buffer.append(" .VerticalTextAlignment = ").append(getVerticalTextAlignment()).append('\n'); buffer.append(" .reserved2 = ").append(getReserved2()).append('\n'); buffer.append(" .textLocked = ").append(isTextLocked()).append('\n'); buffer.append(" .reserved3 = ").append(getReserved3()).append('\n'); buffer.append(" .textOrientation = ") .append("0x").append(HexDump.toHex( getTextOrientation ())) .append(" (").append( getTextOrientation() ).append(" )"); buffer.append(System.getProperty("line.separator")); buffer.append(" .reserved4 = ") .append("0x").append(HexDump.toHex( getReserved4 ())) .append(" (").append( getReserved4() ).append(" )"); buffer.append(System.getProperty("line.separator")); buffer.append(" .reserved5 = ") .append("0x").append(HexDump.toHex( getReserved5 ())) .append(" (").append( getReserved5() ).append(" )"); buffer.append(System.getProperty("line.separator")); buffer.append(" .reserved6 = ") .append("0x").append(HexDump.toHex( getReserved6 ())) .append(" (").append( getReserved6() ).append(" )"); buffer.append(System.getProperty("line.separator")); buffer.append(" .textLength = ") .append("0x").append(HexDump.toHex( getTextLength ())) .append(" (").append( getTextLength() ).append(" )"); buffer.append(System.getProperty("line.separator")); buffer.append(" .formattingRunLength = ") .append("0x").append(HexDump.toHex( getFormattingRunLength ())) .append(" (").append( getFormattingRunLength() ).append(" )"); buffer.append(System.getProperty("line.separator")); buffer.append(" .reserved7 = ") .append("0x").append(HexDump.toHex( getReserved7 ())) .append(" (").append( getReserved7() ).append(" )"); buffer.append(System.getProperty("line.separator")); buffer.append("[/TXO]\n"); return buffer.toString(); } public int serialize(int offset, byte[] data) { int pos = 0; LittleEndian.putShort(data, 0 + offset, sid); LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); LittleEndian.putShort(data, 4 + offset + pos, field_1_options); LittleEndian.putShort(data, 6 + offset + pos, field_2_textOrientation); LittleEndian.putShort(data, 8 + offset + pos, field_3_reserved4); LittleEndian.putShort(data, 10 + offset + pos, field_4_reserved5); LittleEndian.putShort(data, 12 + offset + pos, field_5_reserved6); LittleEndian.putShort(data, 14 + offset + pos, field_6_textLength); LittleEndian.putShort(data, 16 + offset + pos, field_7_formattingRunLength); LittleEndian.putInt(data, 18 + offset + pos, field_8_reserved7); return getRecordSize(); } /** * Size of record (exluding 4 byte header) */ public int getRecordSize() { return 4 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 4; } public short getSid() { return this.sid; } public Object clone() { TextObjectBaseRecord rec = new TextObjectBaseRecord(); rec.field_1_options = field_1_options; rec.field_2_textOrientation = field_2_textOrientation; rec.field_3_reserved4 = field_3_reserved4; rec.field_4_reserved5 = field_4_reserved5; rec.field_5_reserved6 = field_5_reserved6; rec.field_6_textLength = field_6_textLength; rec.field_7_formattingRunLength = field_7_formattingRunLength; rec.field_8_reserved7 = field_8_reserved7; return rec; } /** * Get the options field for the TextObjectBase record. */ public short getOptions() { return field_1_options; } /** * Set the options field for the TextObjectBase record. */ public void setOptions(short field_1_options) { this.field_1_options = field_1_options; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -