KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hssf > record > TextObjectBaseRecord


1
2 /* ====================================================================
3    Copyright 2002-2004 Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16 ==================================================================== */

17         
18
19
20 package org.apache.poi.hssf.record;
21
22
23
24 import org.apache.poi.util.*;
25
26 /**
27  * The TXO record is used to define the properties of a text box. It is followed
28         by two continue records unless there is no actual text. The first continue record contains
29         the text data and the next continue record contains the formatting runs.
30  * NOTE: This source is automatically generated please do not modify this file. Either subclass or
31  * remove the record in src/records/definitions.
32
33  * @author Glen Stampoultzis (glens at apache.org)
34  */

35 public class TextObjectBaseRecord
36     extends Record
37 {
38     public final static short sid = 0x1B6;
39     private short field_1_options;
40     private BitField reserved1 = new BitField(0x1);
41     private BitField HorizontalTextAlignment = new BitField(0x000E);
42     public final static short HORIZONTAL_TEXT_ALIGNMENT_LEFT_ALIGNED = 1;
43     public final static short HORIZONTAL_TEXT_ALIGNMENT_CENTERED = 2;
44     public final static short HORIZONTAL_TEXT_ALIGNMENT_RIGHT_ALIGNED = 3;
45     public final static short HORIZONTAL_TEXT_ALIGNMENT_JUSTIFIED = 4;
46     private BitField VerticalTextAlignment = new BitField(0x0070);
47     public final static short VERTICAL_TEXT_ALIGNMENT_TOP = 1;
48     public final static short VERTICAL_TEXT_ALIGNMENT_CENTER = 2;
49     public final static short VERTICAL_TEXT_ALIGNMENT_BOTTOM = 3;
50     public final static short VERTICAL_TEXT_ALIGNMENT_JUSTIFY = 4;
51     private BitField reserved2 = new BitField(0x0180);
52     private BitField textLocked = new BitField(0x200);
53     private BitField reserved3 = new BitField(0xFC00);
54     private short field_2_textOrientation;
55     public final static short TEXT_ORIENTATION_NONE = 0;
56     public final static short TEXT_ORIENTATION_TOP_TO_BOTTOM = 1;
57     public final static short TEXT_ORIENTATION_ROT_RIGHT = 2;
58     public final static short TEXT_ORIENTATION_ROT_LEFT = 3;
59     private short field_3_reserved4;
60     private short field_4_reserved5;
61     private short field_5_reserved6;
62     private short field_6_textLength;
63     private short field_7_formattingRunLength;
64     private int field_8_reserved7;
65
66
67     public TextObjectBaseRecord()
68     {
69
70     }
71
72     /**
73      * Constructs a TextObjectBase record and sets its fields appropriately.
74      *
75      * @param id id must be 0x1B6 or an exception
76      * will be throw upon validation
77      * @param size size the size of the data area of the record
78      * @param data data of the record (should not contain sid/len)
79      */

80
81     public TextObjectBaseRecord(short id, short size, byte [] data)
82     {
83         super(id, size, data);
84     
85     }
86
87     /**
88      * Constructs a TextObjectBase record and sets its fields appropriately.
89      *
90      * @param id id must be 0x1B6 or an exception
91      * will be throw upon validation
92      * @param size size the size of the data area of the record
93      * @param data data of the record (should not contain sid/len)
94      * @param offset of the record's data
95      */

96
97     public TextObjectBaseRecord(short id, short size, byte [] data, int offset)
98     {
99         super(id, size, data, offset);
100     
101     }
102
103     /**
104      * Checks the sid matches the expected side for this record
105      *
106      * @param id the expected sid.
107      */

108     protected void validateSid(short id)
109     {
110         if (id != sid)
111         {
112             throw new RecordFormatException("Not a TextObjectBase record");
113         }
114     }
115
116     protected void fillFields(byte [] data, short size, int offset)
117     {
118
119         int pos = 0;
120         field_1_options = LittleEndian.getShort(data, pos + 0x0 + offset);
121         field_2_textOrientation = LittleEndian.getShort(data, pos + 0x2 + offset);
122         field_3_reserved4 = LittleEndian.getShort(data, pos + 0x4 + offset);
123         field_4_reserved5 = LittleEndian.getShort(data, pos + 0x6 + offset);
124         field_5_reserved6 = LittleEndian.getShort(data, pos + 0x8 + offset);
125         field_6_textLength = LittleEndian.getShort(data, pos + 0xa + offset);
126         field_7_formattingRunLength = LittleEndian.getShort(data, pos + 0xc + offset);
127         field_8_reserved7 = LittleEndian.getInt(data, pos + 0xe + offset);
128
129     }
130
131     public String JavaDoc toString()
132     {
133         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
134
135         buffer.append("[TXO]\n");
136         buffer.append(" .options = ")
137             .append("0x").append(HexDump.toHex( getOptions ()))
138             .append(" (").append( getOptions() ).append(" )");
139         buffer.append(System.getProperty("line.separator"));
140         buffer.append(" .reserved1 = ").append(isReserved1()).append('\n');
141             buffer.append(" .HorizontalTextAlignment = ").append(getHorizontalTextAlignment()).append('\n');
142             buffer.append(" .VerticalTextAlignment = ").append(getVerticalTextAlignment()).append('\n');
143             buffer.append(" .reserved2 = ").append(getReserved2()).append('\n');
144         buffer.append(" .textLocked = ").append(isTextLocked()).append('\n');
145             buffer.append(" .reserved3 = ").append(getReserved3()).append('\n');
146         buffer.append(" .textOrientation = ")
147             .append("0x").append(HexDump.toHex( getTextOrientation ()))
148             .append(" (").append( getTextOrientation() ).append(" )");
149         buffer.append(System.getProperty("line.separator"));
150         buffer.append(" .reserved4 = ")
151             .append("0x").append(HexDump.toHex( getReserved4 ()))
152             .append(" (").append( getReserved4() ).append(" )");
153         buffer.append(System.getProperty("line.separator"));
154         buffer.append(" .reserved5 = ")
155             .append("0x").append(HexDump.toHex( getReserved5 ()))
156             .append(" (").append( getReserved5() ).append(" )");
157         buffer.append(System.getProperty("line.separator"));
158         buffer.append(" .reserved6 = ")
159             .append("0x").append(HexDump.toHex( getReserved6 ()))
160             .append(" (").append( getReserved6() ).append(" )");
161         buffer.append(System.getProperty("line.separator"));
162         buffer.append(" .textLength = ")
163             .append("0x").append(HexDump.toHex( getTextLength ()))
164             .append(" (").append( getTextLength() ).append(" )");
165         buffer.append(System.getProperty("line.separator"));
166         buffer.append(" .formattingRunLength = ")
167             .append("0x").append(HexDump.toHex( getFormattingRunLength ()))
168             .append(" (").append( getFormattingRunLength() ).append(" )");
169         buffer.append(System.getProperty("line.separator"));
170         buffer.append(" .reserved7 = ")
171             .append("0x").append(HexDump.toHex( getReserved7 ()))
172             .append(" (").append( getReserved7() ).append(" )");
173         buffer.append(System.getProperty("line.separator"));
174
175         buffer.append("[/TXO]\n");
176         return buffer.toString();
177     }
178
179     public int serialize(int offset, byte[] data)
180     {
181         int pos = 0;
182
183         LittleEndian.putShort(data, 0 + offset, sid);
184         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
185
186         LittleEndian.putShort(data, 4 + offset + pos, field_1_options);
187         LittleEndian.putShort(data, 6 + offset + pos, field_2_textOrientation);
188         LittleEndian.putShort(data, 8 + offset + pos, field_3_reserved4);
189         LittleEndian.putShort(data, 10 + offset + pos, field_4_reserved5);
190         LittleEndian.putShort(data, 12 + offset + pos, field_5_reserved6);
191         LittleEndian.putShort(data, 14 + offset + pos, field_6_textLength);
192         LittleEndian.putShort(data, 16 + offset + pos, field_7_formattingRunLength);
193         LittleEndian.putInt(data, 18 + offset + pos, field_8_reserved7);
194
195         return getRecordSize();
196     }
197
198     /**
199      * Size of record (exluding 4 byte header)
200      */

201     public int getRecordSize()
202     {
203         return 4 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 4;
204     }
205
206     public short getSid()
207     {
208         return this.sid;
209     }
210
211     public Object JavaDoc clone() {
212         TextObjectBaseRecord rec = new TextObjectBaseRecord();
213     
214         rec.field_1_options = field_1_options;
215         rec.field_2_textOrientation = field_2_textOrientation;
216         rec.field_3_reserved4 = field_3_reserved4;
217         rec.field_4_reserved5 = field_4_reserved5;
218         rec.field_5_reserved6 = field_5_reserved6;
219         rec.field_6_textLength = field_6_textLength;
220         rec.field_7_formattingRunLength = field_7_formattingRunLength;
221         rec.field_8_reserved7 = field_8_reserved7;
222         return rec;
223     }
224
225
226
227
228     /**
229      * Get the options field for the TextObjectBase record.
230      */

231     public short getOptions()
232     {
233         return field_1_options;
234     }
235
236     /**
237      * Set the options field for the TextObjectBase record.
238      */

239     public void setOptions(short field_1_options)
240     {
241         this.field_1_options = field_1_options;
242     }
243
244     /**
245      * Get the text orientation field for the TextObjectBase record.
246      *
247      * @return One of
248      * TEXT_ORIENTATION_NONE
249      * TEXT_ORIENTATION_TOP_TO_BOTTOM
250      * TEXT_ORIENTATION_ROT_RIGHT
251      * TEXT_ORIENTATION_ROT_LEFT
252      */

253     public short getTextOrientation()
254     {
255         return field_2_textOrientation;
256     }
257
258     /**
259      * Set the text orientation field for the TextObjectBase record.
260      *
261      * @param field_2_textOrientation
262      * One of
263      * TEXT_ORIENTATION_NONE
264      * TEXT_ORIENTATION_TOP_TO_BOTTOM
265      * TEXT_ORIENTATION_ROT_RIGHT
266      * TEXT_ORIENTATION_ROT_LEFT
267      */

268     public void setTextOrientation(short field_2_textOrientation)
269     {
270         this.field_2_textOrientation = field_2_textOrientation;
271     }
272
273     /**
274      * Get the reserved4 field for the TextObjectBase record.
275      */

276     public short getReserved4()
277     {
278         return field_3_reserved4;
279     }
280
281     /**
282      * Set the reserved4 field for the TextObjectBase record.
283      */

284     public void setReserved4(short field_3_reserved4)
285     {
286         this.field_3_reserved4 = field_3_reserved4;
287     }
288
289     /**
290      * Get the reserved5 field for the TextObjectBase record.
291      */

292     public short getReserved5()
293     {
294         return field_4_reserved5;
295     }
296
297     /**
298      * Set the reserved5 field for the TextObjectBase record.
299      */

300     public void setReserved5(short field_4_reserved5)
301     {
302         this.field_4_reserved5 = field_4_reserved5;
303     }
304
305     /**
306      * Get the reserved6 field for the TextObjectBase record.
307      */

308     public short getReserved6()
309     {
310         return field_5_reserved6;
311     }
312
313     /**
314      * Set the reserved6 field for the TextObjectBase record.
315      */

316     public void setReserved6(short field_5_reserved6)
317     {
318         this.field_5_reserved6 = field_5_reserved6;
319     }
320
321     /**
322      * Get the text length field for the TextObjectBase record.
323      */

324     public short getTextLength()
325     {
326         return field_6_textLength;
327     }
328
329     /**
330      * Set the text length field for the TextObjectBase record.
331      */

332     public void setTextLength(short field_6_textLength)
333     {
334         this.field_6_textLength = field_6_textLength;
335     }
336
337     /**
338      * Get the formatting run length field for the TextObjectBase record.
339      */

340     public short getFormattingRunLength()
341     {
342         return field_7_formattingRunLength;
343     }
344
345     /**
346      * Set the formatting run length field for the TextObjectBase record.
347      */

348     public void setFormattingRunLength(short field_7_formattingRunLength)
349     {
350         this.field_7_formattingRunLength = field_7_formattingRunLength;
351     }
352
353     /**
354      * Get the reserved7 field for the TextObjectBase record.
355      */

356     public int getReserved7()
357     {
358         return field_8_reserved7;
359     }
360
361     /**
362      * Set the reserved7 field for the TextObjectBase record.
363      */

364     public void setReserved7(int field_8_reserved7)
365     {
366         this.field_8_reserved7 = field_8_reserved7;
367     }
368
369     /**
370      * Sets the reserved1 field value.
371      * reserved field
372      */

373     public void setReserved1(boolean value)
374     {
375         field_1_options = reserved1.setShortBoolean(field_1_options, value);
376     }
377
378     /**
379      * reserved field
380      * @return the reserved1 field value.
381      */

382     public boolean isReserved1()
383     {
384         return reserved1.isSet(field_1_options);
385     }
386
387     /**
388      * Sets the Horizontal text alignment field value.
389      *
390      */

391     public void setHorizontalTextAlignment(short value)
392     {
393         field_1_options = HorizontalTextAlignment.setShortValue(field_1_options, value);
394     }
395
396     /**
397      *
398      * @return the Horizontal text alignment field value.
399      */

400     public short getHorizontalTextAlignment()
401     {
402         return HorizontalTextAlignment.getShortValue(field_1_options);
403     }
404
405     /**
406      * Sets the Vertical text alignment field value.
407      *
408      */

409     public void setVerticalTextAlignment(short value)
410     {
411         field_1_options = VerticalTextAlignment.setShortValue(field_1_options, value);
412     }
413
414     /**
415      *
416      * @return the Vertical text alignment field value.
417      */

418     public short getVerticalTextAlignment()
419     {
420         return VerticalTextAlignment.getShortValue(field_1_options);
421     }
422
423     /**
424      * Sets the reserved2 field value.
425      *
426      */

427     public void setReserved2(short value)
428     {
429         field_1_options = reserved2.setShortValue(field_1_options, value);
430     }
431
432     /**
433      *
434      * @return the reserved2 field value.
435      */

436     public short getReserved2()
437     {
438         return reserved2.getShortValue(field_1_options);
439     }
440
441     /**
442      * Sets the text locked field value.
443      * Text has been locked
444      */

445     public void setTextLocked(boolean value)
446     {
447         field_1_options = textLocked.setShortBoolean(field_1_options, value);
448     }
449
450     /**
451      * Text has been locked
452      * @return the text locked field value.
453      */

454     public boolean isTextLocked()
455     {
456         return textLocked.isSet(field_1_options);
457     }
458
459     /**
460      * Sets the reserved3 field value.
461      *
462      */

463     public void setReserved3(short value)
464     {
465         field_1_options = reserved3.setShortValue(field_1_options, value);
466     }
467
468     /**
469      *
470      * @return the reserved3 field value.
471      */

472     public short getReserved3()
473     {
474         return reserved3.getShortValue(field_1_options);
475     }
476
477
478 } // END OF CLASS
479

480
481
482
483
Popular Tags