001: /* ====================================================================
002: Licensed to the Apache Software Foundation (ASF) under one or more
003: contributor license agreements. See the NOTICE file distributed with
004: this work for additional information regarding copyright ownership.
005: The ASF licenses this file to You under the Apache License, Version 2.0
006: (the "License"); you may not use this file except in compliance with
007: the License. You may obtain a copy of the License at
008:
009: http://www.apache.org/licenses/LICENSE-2.0
010:
011: Unless required by applicable law or agreed to in writing, software
012: distributed under the License is distributed on an "AS IS" BASIS,
013: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: See the License for the specific language governing permissions and
015: limitations under the License.
016: ==================================================================== */
017:
018: package org.apache.poi.hssf.record;
019:
020: import org.apache.poi.util.*;
021:
022: /**
023: * The TXO record is used to define the properties of a text box. It is followed
024: by two continue records unless there is no actual text. The first continue record contains
025: the text data and the next continue record contains the formatting runs.
026: * NOTE: This source is automatically generated please do not modify this file. Either subclass or
027: * remove the record in src/records/definitions.
028:
029: * @author Glen Stampoultzis (glens at apache.org)
030: */
031: public class TextObjectBaseRecord extends Record {
032: public final static short sid = 0x1B6;
033: private short field_1_options;
034: private BitField reserved1 = BitFieldFactory.getInstance(0x1);
035: private BitField HorizontalTextAlignment = BitFieldFactory
036: .getInstance(0x000E);
037: public final static short HORIZONTAL_TEXT_ALIGNMENT_LEFT_ALIGNED = 1;
038: public final static short HORIZONTAL_TEXT_ALIGNMENT_CENTERED = 2;
039: public final static short HORIZONTAL_TEXT_ALIGNMENT_RIGHT_ALIGNED = 3;
040: public final static short HORIZONTAL_TEXT_ALIGNMENT_JUSTIFIED = 4;
041: private BitField VerticalTextAlignment = BitFieldFactory
042: .getInstance(0x0070);
043: public final static short VERTICAL_TEXT_ALIGNMENT_TOP = 1;
044: public final static short VERTICAL_TEXT_ALIGNMENT_CENTER = 2;
045: public final static short VERTICAL_TEXT_ALIGNMENT_BOTTOM = 3;
046: public final static short VERTICAL_TEXT_ALIGNMENT_JUSTIFY = 4;
047: private BitField reserved2 = BitFieldFactory.getInstance(0x0180);
048: private BitField textLocked = BitFieldFactory.getInstance(0x200);
049: private BitField reserved3 = BitFieldFactory.getInstance(0xFC00);
050: private short field_2_textOrientation;
051: public final static short TEXT_ORIENTATION_NONE = 0;
052: public final static short TEXT_ORIENTATION_TOP_TO_BOTTOM = 1;
053: public final static short TEXT_ORIENTATION_ROT_RIGHT = 2;
054: public final static short TEXT_ORIENTATION_ROT_LEFT = 3;
055: private short field_3_reserved4;
056: private short field_4_reserved5;
057: private short field_5_reserved6;
058: private short field_6_textLength;
059: private short field_7_formattingRunLength;
060: private int field_8_reserved7;
061:
062: public TextObjectBaseRecord() {
063:
064: }
065:
066: /**
067: * Constructs a TextObjectBase record and sets its fields appropriately.
068: *
069: * @param in the RecordInputstream to read the record from
070: */
071:
072: public TextObjectBaseRecord(RecordInputStream in) {
073: super (in);
074:
075: }
076:
077: /**
078: * Checks the sid matches the expected side for this record
079: *
080: * @param id the expected sid.
081: */
082: protected void validateSid(short id) {
083: if (id != sid) {
084: throw new RecordFormatException(
085: "Not a TextObjectBase record");
086: }
087: }
088:
089: protected void fillFields(RecordInputStream in) {
090: field_1_options = in.readShort();
091: field_2_textOrientation = in.readShort();
092: field_3_reserved4 = in.readShort();
093: field_4_reserved5 = in.readShort();
094: field_5_reserved6 = in.readShort();
095: field_6_textLength = in.readShort();
096: field_7_formattingRunLength = in.readShort();
097: field_8_reserved7 = in.readInt();
098:
099: }
100:
101: public String toString() {
102: StringBuffer buffer = new StringBuffer();
103:
104: buffer.append("[TXO]\n");
105: buffer.append(" .options = ").append("0x")
106: .append(HexDump.toHex(getOptions())).append(" (")
107: .append(getOptions()).append(" )");
108: buffer.append(System.getProperty("line.separator"));
109: buffer.append(" .reserved1 = ").append(
110: isReserved1()).append('\n');
111: buffer.append(" .HorizontalTextAlignment = ")
112: .append(getHorizontalTextAlignment()).append('\n');
113: buffer.append(" .VerticalTextAlignment = ").append(
114: getVerticalTextAlignment()).append('\n');
115: buffer.append(" .reserved2 = ").append(
116: getReserved2()).append('\n');
117: buffer.append(" .textLocked = ").append(
118: isTextLocked()).append('\n');
119: buffer.append(" .reserved3 = ").append(
120: getReserved3()).append('\n');
121: buffer.append(" .textOrientation = ").append("0x")
122: .append(HexDump.toHex(getTextOrientation())).append(
123: " (").append(getTextOrientation()).append(" )");
124: buffer.append(System.getProperty("line.separator"));
125: buffer.append(" .reserved4 = ").append("0x")
126: .append(HexDump.toHex(getReserved4())).append(" (")
127: .append(getReserved4()).append(" )");
128: buffer.append(System.getProperty("line.separator"));
129: buffer.append(" .reserved5 = ").append("0x")
130: .append(HexDump.toHex(getReserved5())).append(" (")
131: .append(getReserved5()).append(" )");
132: buffer.append(System.getProperty("line.separator"));
133: buffer.append(" .reserved6 = ").append("0x")
134: .append(HexDump.toHex(getReserved6())).append(" (")
135: .append(getReserved6()).append(" )");
136: buffer.append(System.getProperty("line.separator"));
137: buffer.append(" .textLength = ").append("0x")
138: .append(HexDump.toHex(getTextLength())).append(" (")
139: .append(getTextLength()).append(" )");
140: buffer.append(System.getProperty("line.separator"));
141: buffer.append(" .formattingRunLength = ").append("0x")
142: .append(HexDump.toHex(getFormattingRunLength()))
143: .append(" (").append(getFormattingRunLength()).append(
144: " )");
145: buffer.append(System.getProperty("line.separator"));
146: buffer.append(" .reserved7 = ").append("0x")
147: .append(HexDump.toHex(getReserved7())).append(" (")
148: .append(getReserved7()).append(" )");
149: buffer.append(System.getProperty("line.separator"));
150:
151: buffer.append("[/TXO]\n");
152: return buffer.toString();
153: }
154:
155: public int serialize(int offset, byte[] data) {
156: int pos = 0;
157:
158: LittleEndian.putShort(data, 0 + offset, sid);
159: LittleEndian.putShort(data, 2 + offset,
160: (short) (getRecordSize() - 4));
161:
162: LittleEndian.putShort(data, 4 + offset + pos, field_1_options);
163: LittleEndian.putShort(data, 6 + offset + pos,
164: field_2_textOrientation);
165: LittleEndian
166: .putShort(data, 8 + offset + pos, field_3_reserved4);
167: LittleEndian.putShort(data, 10 + offset + pos,
168: field_4_reserved5);
169: LittleEndian.putShort(data, 12 + offset + pos,
170: field_5_reserved6);
171: LittleEndian.putShort(data, 14 + offset + pos,
172: field_6_textLength);
173: LittleEndian.putShort(data, 16 + offset + pos,
174: field_7_formattingRunLength);
175: LittleEndian.putInt(data, 18 + offset + pos, field_8_reserved7);
176:
177: return getRecordSize();
178: }
179:
180: /**
181: * Size of record (exluding 4 byte header)
182: */
183: public int getRecordSize() {
184: return 4 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 4;
185: }
186:
187: public short getSid() {
188: return sid;
189: }
190:
191: public Object clone() {
192: TextObjectBaseRecord rec = new TextObjectBaseRecord();
193:
194: rec.field_1_options = field_1_options;
195: rec.field_2_textOrientation = field_2_textOrientation;
196: rec.field_3_reserved4 = field_3_reserved4;
197: rec.field_4_reserved5 = field_4_reserved5;
198: rec.field_5_reserved6 = field_5_reserved6;
199: rec.field_6_textLength = field_6_textLength;
200: rec.field_7_formattingRunLength = field_7_formattingRunLength;
201: rec.field_8_reserved7 = field_8_reserved7;
202: return rec;
203: }
204:
205: /**
206: * Get the options field for the TextObjectBase record.
207: */
208: public short getOptions() {
209: return field_1_options;
210: }
211:
212: /**
213: * Set the options field for the TextObjectBase record.
214: */
215: public void setOptions(short field_1_options) {
216: this .field_1_options = field_1_options;
217: }
218:
219: /**
220: * Get the text orientation field for the TextObjectBase record.
221: *
222: * @return One of
223: * TEXT_ORIENTATION_NONE
224: * TEXT_ORIENTATION_TOP_TO_BOTTOM
225: * TEXT_ORIENTATION_ROT_RIGHT
226: * TEXT_ORIENTATION_ROT_LEFT
227: */
228: public short getTextOrientation() {
229: return field_2_textOrientation;
230: }
231:
232: /**
233: * Set the text orientation field for the TextObjectBase record.
234: *
235: * @param field_2_textOrientation
236: * One of
237: * TEXT_ORIENTATION_NONE
238: * TEXT_ORIENTATION_TOP_TO_BOTTOM
239: * TEXT_ORIENTATION_ROT_RIGHT
240: * TEXT_ORIENTATION_ROT_LEFT
241: */
242: public void setTextOrientation(short field_2_textOrientation) {
243: this .field_2_textOrientation = field_2_textOrientation;
244: }
245:
246: /**
247: * Get the reserved4 field for the TextObjectBase record.
248: */
249: public short getReserved4() {
250: return field_3_reserved4;
251: }
252:
253: /**
254: * Set the reserved4 field for the TextObjectBase record.
255: */
256: public void setReserved4(short field_3_reserved4) {
257: this .field_3_reserved4 = field_3_reserved4;
258: }
259:
260: /**
261: * Get the reserved5 field for the TextObjectBase record.
262: */
263: public short getReserved5() {
264: return field_4_reserved5;
265: }
266:
267: /**
268: * Set the reserved5 field for the TextObjectBase record.
269: */
270: public void setReserved5(short field_4_reserved5) {
271: this .field_4_reserved5 = field_4_reserved5;
272: }
273:
274: /**
275: * Get the reserved6 field for the TextObjectBase record.
276: */
277: public short getReserved6() {
278: return field_5_reserved6;
279: }
280:
281: /**
282: * Set the reserved6 field for the TextObjectBase record.
283: */
284: public void setReserved6(short field_5_reserved6) {
285: this .field_5_reserved6 = field_5_reserved6;
286: }
287:
288: /**
289: * Get the text length field for the TextObjectBase record.
290: */
291: public short getTextLength() {
292: return field_6_textLength;
293: }
294:
295: /**
296: * Set the text length field for the TextObjectBase record.
297: */
298: public void setTextLength(short field_6_textLength) {
299: this .field_6_textLength = field_6_textLength;
300: }
301:
302: /**
303: * Get the formatting run length field for the TextObjectBase record.
304: */
305: public short getFormattingRunLength() {
306: return field_7_formattingRunLength;
307: }
308:
309: /**
310: * Set the formatting run length field for the TextObjectBase record.
311: */
312: public void setFormattingRunLength(short field_7_formattingRunLength) {
313: this .field_7_formattingRunLength = field_7_formattingRunLength;
314: }
315:
316: /**
317: * Get the reserved7 field for the TextObjectBase record.
318: */
319: public int getReserved7() {
320: return field_8_reserved7;
321: }
322:
323: /**
324: * Set the reserved7 field for the TextObjectBase record.
325: */
326: public void setReserved7(int field_8_reserved7) {
327: this .field_8_reserved7 = field_8_reserved7;
328: }
329:
330: /**
331: * Sets the reserved1 field value.
332: * reserved field
333: */
334: public void setReserved1(boolean value) {
335: field_1_options = reserved1.setShortBoolean(field_1_options,
336: value);
337: }
338:
339: /**
340: * reserved field
341: * @return the reserved1 field value.
342: */
343: public boolean isReserved1() {
344: return reserved1.isSet(field_1_options);
345: }
346:
347: /**
348: * Sets the Horizontal text alignment field value.
349: *
350: */
351: public void setHorizontalTextAlignment(short value) {
352: field_1_options = HorizontalTextAlignment.setShortValue(
353: field_1_options, value);
354: }
355:
356: /**
357: *
358: * @return the Horizontal text alignment field value.
359: */
360: public short getHorizontalTextAlignment() {
361: return HorizontalTextAlignment.getShortValue(field_1_options);
362: }
363:
364: /**
365: * Sets the Vertical text alignment field value.
366: *
367: */
368: public void setVerticalTextAlignment(short value) {
369: field_1_options = VerticalTextAlignment.setShortValue(
370: field_1_options, value);
371: }
372:
373: /**
374: *
375: * @return the Vertical text alignment field value.
376: */
377: public short getVerticalTextAlignment() {
378: return VerticalTextAlignment.getShortValue(field_1_options);
379: }
380:
381: /**
382: * Sets the reserved2 field value.
383: *
384: */
385: public void setReserved2(short value) {
386: field_1_options = reserved2.setShortValue(field_1_options,
387: value);
388: }
389:
390: /**
391: *
392: * @return the reserved2 field value.
393: */
394: public short getReserved2() {
395: return reserved2.getShortValue(field_1_options);
396: }
397:
398: /**
399: * Sets the text locked field value.
400: * Text has been locked
401: */
402: public void setTextLocked(boolean value) {
403: field_1_options = textLocked.setShortBoolean(field_1_options,
404: value);
405: }
406:
407: /**
408: * Text has been locked
409: * @return the text locked field value.
410: */
411: public boolean isTextLocked() {
412: return textLocked.isSet(field_1_options);
413: }
414:
415: /**
416: * Sets the reserved3 field value.
417: *
418: */
419: public void setReserved3(short value) {
420: field_1_options = reserved3.setShortValue(field_1_options,
421: value);
422: }
423:
424: /**
425: *
426: * @return the reserved3 field value.
427: */
428: public short getReserved3() {
429: return reserved3.getShortValue(field_1_options);
430: }
431:
432: } // END OF CLASS
|