KickJava   Java API By Example, From Geeks To Geeks.

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


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 common object data record is used to store all common preferences for an excel object.
28  * NOTE: This source is automatically generated please do not modify this file. Either subclass or
29  * remove the record in src/records/definitions.
30
31  * @author Glen Stampoultzis (glens at apache.org)
32  */

33 public class CommonObjectDataSubRecord
34     extends SubRecord
35 {
36     public final static short sid = 0x15;
37     private short field_1_objectType;
38     public final static short OBJECT_TYPE_GROUP = 0;
39     public final static short OBJECT_TYPE_LINE = 1;
40     public final static short OBJECT_TYPE_RECTANGLE = 2;
41     public final static short OBJECT_TYPE_OVAL = 3;
42     public final static short OBJECT_TYPE_ARC = 4;
43     public final static short OBJECT_TYPE_CHART = 5;
44     public final static short OBJECT_TYPE_TEXT = 6;
45     public final static short OBJECT_TYPE_BUTTON = 7;
46     public final static short OBJECT_TYPE_PICTURE = 8;
47     public final static short OBJECT_TYPE_POLYGON = 9;
48     public final static short OBJECT_TYPE_RESERVED1 = 10;
49     public final static short OBJECT_TYPE_CHECKBOX = 11;
50     public final static short OBJECT_TYPE_OPTION_BUTTON = 12;
51     public final static short OBJECT_TYPE_EDIT_BOX = 13;
52     public final static short OBJECT_TYPE_LABEL = 14;
53     public final static short OBJECT_TYPE_DIALOG_BOX = 15;
54     public final static short OBJECT_TYPE_SPINNER = 16;
55     public final static short OBJECT_TYPE_SCROLL_BAR = 17;
56     public final static short OBJECT_TYPE_LIST_BOX = 18;
57     public final static short OBJECT_TYPE_GROUP_BOX = 19;
58     public final static short OBJECT_TYPE_COMBO_BOX = 20;
59     public final static short OBJECT_TYPE_RESERVED2 = 21;
60     public final static short OBJECT_TYPE_RESERVED3 = 22;
61     public final static short OBJECT_TYPE_RESERVED4 = 23;
62     public final static short OBJECT_TYPE_RESERVED5 = 24;
63     public final static short OBJECT_TYPE_COMMENT = 25;
64     public final static short OBJECT_TYPE_RESERVED6 = 26;
65     public final static short OBJECT_TYPE_RESERVED7 = 27;
66     public final static short OBJECT_TYPE_RESERVED8 = 28;
67     public final static short OBJECT_TYPE_RESERVED9 = 29;
68     public final static short OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING = 30;
69     private short field_2_objectId;
70     private short field_3_option;
71     private BitField locked = new BitField(0x1);
72     private BitField printable = new BitField(0x10);
73     private BitField autofill = new BitField(0x2000);
74     private BitField autoline = new BitField(0x4000);
75     private int field_4_reserved1;
76     private int field_5_reserved2;
77     private int field_6_reserved3;
78
79
80     public CommonObjectDataSubRecord()
81     {
82
83     }
84
85     /**
86      * Constructs a CommonObjectData record and sets its fields appropriately.
87      *
88      * @param id id must be 0x15 or an exception
89      * will be throw upon validation
90      * @param size size the size of the data area of the record
91      * @param data data of the record (should not contain sid/len)
92      */

93
94     public CommonObjectDataSubRecord(short id, short size, byte [] data)
95     {
96         super(id, size, data);
97     
98     }
99
100     /**
101      * Constructs a CommonObjectData record and sets its fields appropriately.
102      *
103      * @param id id must be 0x15 or an exception
104      * will be throw upon validation
105      * @param size size the size of the data area of the record
106      * @param data data of the record (should not contain sid/len)
107      * @param offset of the record's data
108      */

109
110     public CommonObjectDataSubRecord(short id, short size, byte [] data, int offset)
111     {
112         super(id, size, data, offset);
113     
114     }
115
116     /**
117      * Checks the sid matches the expected side for this record
118      *
119      * @param id the expected sid.
120      */

121     protected void validateSid(short id)
122     {
123         if (id != sid)
124         {
125             throw new RecordFormatException("Not a CommonObjectData record");
126         }
127     }
128
129     protected void fillFields(byte [] data, short size, int offset)
130     {
131
132         int pos = 0;
133         field_1_objectType = LittleEndian.getShort(data, pos + 0x0 + offset);
134         field_2_objectId = LittleEndian.getShort(data, pos + 0x2 + offset);
135         field_3_option = LittleEndian.getShort(data, pos + 0x4 + offset);
136         field_4_reserved1 = LittleEndian.getInt(data, pos + 0x6 + offset);
137         field_5_reserved2 = LittleEndian.getInt(data, pos + 0xa + offset);
138         field_6_reserved3 = LittleEndian.getInt(data, pos + 0xe + offset);
139
140     }
141
142     public String JavaDoc toString()
143     {
144         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
145
146         buffer.append("[ftCmo]\n");
147         buffer.append(" .objectType = ")
148             .append("0x").append(HexDump.toHex( getObjectType ()))
149             .append(" (").append( getObjectType() ).append(" )");
150         buffer.append(System.getProperty("line.separator"));
151         buffer.append(" .objectId = ")
152             .append("0x").append(HexDump.toHex( getObjectId ()))
153             .append(" (").append( getObjectId() ).append(" )");
154         buffer.append(System.getProperty("line.separator"));
155         buffer.append(" .option = ")
156             .append("0x").append(HexDump.toHex( getOption ()))
157             .append(" (").append( getOption() ).append(" )");
158         buffer.append(System.getProperty("line.separator"));
159         buffer.append(" .locked = ").append(isLocked()).append('\n');
160         buffer.append(" .printable = ").append(isPrintable()).append('\n');
161         buffer.append(" .autofill = ").append(isAutofill()).append('\n');
162         buffer.append(" .autoline = ").append(isAutoline()).append('\n');
163         buffer.append(" .reserved1 = ")
164             .append("0x").append(HexDump.toHex( getReserved1 ()))
165             .append(" (").append( getReserved1() ).append(" )");
166         buffer.append(System.getProperty("line.separator"));
167         buffer.append(" .reserved2 = ")
168             .append("0x").append(HexDump.toHex( getReserved2 ()))
169             .append(" (").append( getReserved2() ).append(" )");
170         buffer.append(System.getProperty("line.separator"));
171         buffer.append(" .reserved3 = ")
172             .append("0x").append(HexDump.toHex( getReserved3 ()))
173             .append(" (").append( getReserved3() ).append(" )");
174         buffer.append(System.getProperty("line.separator"));
175
176         buffer.append("[/ftCmo]\n");
177         return buffer.toString();
178     }
179
180     public int serialize(int offset, byte[] data)
181     {
182         int pos = 0;
183
184         LittleEndian.putShort(data, 0 + offset, sid);
185         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
186
187         LittleEndian.putShort(data, 4 + offset + pos, field_1_objectType);
188         LittleEndian.putShort(data, 6 + offset + pos, field_2_objectId);
189         LittleEndian.putShort(data, 8 + offset + pos, field_3_option);
190         LittleEndian.putInt(data, 10 + offset + pos, field_4_reserved1);
191         LittleEndian.putInt(data, 14 + offset + pos, field_5_reserved2);
192         LittleEndian.putInt(data, 18 + offset + pos, field_6_reserved3);
193
194         return getRecordSize();
195     }
196
197     /**
198      * Size of record (exluding 4 byte header)
199      */

200     public int getRecordSize()
201     {
202         return 4 + 2 + 2 + 2 + 4 + 4 + 4;
203     }
204
205     public short getSid()
206     {
207         return this.sid;
208     }
209
210     public Object JavaDoc clone() {
211         CommonObjectDataSubRecord rec = new CommonObjectDataSubRecord();
212     
213         rec.field_1_objectType = field_1_objectType;
214         rec.field_2_objectId = field_2_objectId;
215         rec.field_3_option = field_3_option;
216         rec.field_4_reserved1 = field_4_reserved1;
217         rec.field_5_reserved2 = field_5_reserved2;
218         rec.field_6_reserved3 = field_6_reserved3;
219         return rec;
220     }
221
222
223     /**
224      * Get the object type field for the CommonObjectData record.
225      *
226      * @return One of
227      * OBJECT_TYPE_GROUP
228      * OBJECT_TYPE_LINE
229      * OBJECT_TYPE_RECTANGLE
230      * OBJECT_TYPE_OVAL
231      * OBJECT_TYPE_ARC
232      * OBJECT_TYPE_CHART
233      * OBJECT_TYPE_TEXT
234      * OBJECT_TYPE_BUTTON
235      * OBJECT_TYPE_PICTURE
236      * OBJECT_TYPE_POLYGON
237      * OBJECT_TYPE_RESERVED1
238      * OBJECT_TYPE_CHECKBOX
239      * OBJECT_TYPE_OPTION_BUTTON
240      * OBJECT_TYPE_EDIT_BOX
241      * OBJECT_TYPE_LABEL
242      * OBJECT_TYPE_DIALOG_BOX
243      * OBJECT_TYPE_SPINNER
244      * OBJECT_TYPE_SCROLL_BAR
245      * OBJECT_TYPE_LIST_BOX
246      * OBJECT_TYPE_GROUP_BOX
247      * OBJECT_TYPE_COMBO_BOX
248      * OBJECT_TYPE_RESERVED2
249      * OBJECT_TYPE_RESERVED3
250      * OBJECT_TYPE_RESERVED4
251      * OBJECT_TYPE_RESERVED5
252      * OBJECT_TYPE_COMMENT
253      * OBJECT_TYPE_RESERVED6
254      * OBJECT_TYPE_RESERVED7
255      * OBJECT_TYPE_RESERVED8
256      * OBJECT_TYPE_RESERVED9
257      * OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING
258      */

259     public short getObjectType()
260     {
261         return field_1_objectType;
262     }
263
264     /**
265      * Set the object type field for the CommonObjectData record.
266      *
267      * @param field_1_objectType
268      * One of
269      * OBJECT_TYPE_GROUP
270      * OBJECT_TYPE_LINE
271      * OBJECT_TYPE_RECTANGLE
272      * OBJECT_TYPE_OVAL
273      * OBJECT_TYPE_ARC
274      * OBJECT_TYPE_CHART
275      * OBJECT_TYPE_TEXT
276      * OBJECT_TYPE_BUTTON
277      * OBJECT_TYPE_PICTURE
278      * OBJECT_TYPE_POLYGON
279      * OBJECT_TYPE_RESERVED1
280      * OBJECT_TYPE_CHECKBOX
281      * OBJECT_TYPE_OPTION_BUTTON
282      * OBJECT_TYPE_EDIT_BOX
283      * OBJECT_TYPE_LABEL
284      * OBJECT_TYPE_DIALOG_BOX
285      * OBJECT_TYPE_SPINNER
286      * OBJECT_TYPE_SCROLL_BAR
287      * OBJECT_TYPE_LIST_BOX
288      * OBJECT_TYPE_GROUP_BOX
289      * OBJECT_TYPE_COMBO_BOX
290      * OBJECT_TYPE_RESERVED2
291      * OBJECT_TYPE_RESERVED3
292      * OBJECT_TYPE_RESERVED4
293      * OBJECT_TYPE_RESERVED5
294      * OBJECT_TYPE_COMMENT
295      * OBJECT_TYPE_RESERVED6
296      * OBJECT_TYPE_RESERVED7
297      * OBJECT_TYPE_RESERVED8
298      * OBJECT_TYPE_RESERVED9
299      * OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING
300      */

301     public void setObjectType(short field_1_objectType)
302     {
303         this.field_1_objectType = field_1_objectType;
304     }
305
306     /**
307      * Get the object id field for the CommonObjectData record.
308      */

309     public short getObjectId()
310     {
311         return field_2_objectId;
312     }
313
314     /**
315      * Set the object id field for the CommonObjectData record.
316      */

317     public void setObjectId(short field_2_objectId)
318     {
319         this.field_2_objectId = field_2_objectId;
320     }
321
322     /**
323      * Get the option field for the CommonObjectData record.
324      */

325     public short getOption()
326     {
327         return field_3_option;
328     }
329
330     /**
331      * Set the option field for the CommonObjectData record.
332      */

333     public void setOption(short field_3_option)
334     {
335         this.field_3_option = field_3_option;
336     }
337
338     /**
339      * Get the reserved1 field for the CommonObjectData record.
340      */

341     public int getReserved1()
342     {
343         return field_4_reserved1;
344     }
345
346     /**
347      * Set the reserved1 field for the CommonObjectData record.
348      */

349     public void setReserved1(int field_4_reserved1)
350     {
351         this.field_4_reserved1 = field_4_reserved1;
352     }
353
354     /**
355      * Get the reserved2 field for the CommonObjectData record.
356      */

357     public int getReserved2()
358     {
359         return field_5_reserved2;
360     }
361
362     /**
363      * Set the reserved2 field for the CommonObjectData record.
364      */

365     public void setReserved2(int field_5_reserved2)
366     {
367         this.field_5_reserved2 = field_5_reserved2;
368     }
369
370     /**
371      * Get the reserved3 field for the CommonObjectData record.
372      */

373     public int getReserved3()
374     {
375         return field_6_reserved3;
376     }
377
378     /**
379      * Set the reserved3 field for the CommonObjectData record.
380      */

381     public void setReserved3(int field_6_reserved3)
382     {
383         this.field_6_reserved3 = field_6_reserved3;
384     }
385
386     /**
387      * Sets the locked field value.
388      * true if object is locked when sheet has been protected
389      */

390     public void setLocked(boolean value)
391     {
392         field_3_option = locked.setShortBoolean(field_3_option, value);
393     }
394
395     /**
396      * true if object is locked when sheet has been protected
397      * @return the locked field value.
398      */

399     public boolean isLocked()
400     {
401         return locked.isSet(field_3_option);
402     }
403
404     /**
405      * Sets the printable field value.
406      * object appears when printed
407      */

408     public void setPrintable(boolean value)
409     {
410         field_3_option = printable.setShortBoolean(field_3_option, value);
411     }
412
413     /**
414      * object appears when printed
415      * @return the printable field value.
416      */

417     public boolean isPrintable()
418     {
419         return printable.isSet(field_3_option);
420     }
421
422     /**
423      * Sets the autofill field value.
424      * whether object uses an automatic fill style
425      */

426     public void setAutofill(boolean value)
427     {
428         field_3_option = autofill.setShortBoolean(field_3_option, value);
429     }
430
431     /**
432      * whether object uses an automatic fill style
433      * @return the autofill field value.
434      */

435     public boolean isAutofill()
436     {
437         return autofill.isSet(field_3_option);
438     }
439
440     /**
441      * Sets the autoline field value.
442      * whether object uses an automatic line style
443      */

444     public void setAutoline(boolean value)
445     {
446         field_3_option = autoline.setShortBoolean(field_3_option, value);
447     }
448
449     /**
450      * whether object uses an automatic line style
451      * @return the autoline field value.
452      */

453     public boolean isAutoline()
454     {
455         return autoline.isSet(field_3_option);
456     }
457
458
459 } // END OF CLASS
460

461
462
Popular Tags