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 common object data record is used to store all common preferences for an excel object.
024: * NOTE: This source is automatically generated please do not modify this file. Either subclass or
025: * remove the record in src/records/definitions.
026:
027: * @author Glen Stampoultzis (glens at apache.org)
028: */
029: public class CommonObjectDataSubRecord extends SubRecord {
030: public final static short sid = 0x15;
031: private short field_1_objectType;
032: public final static short OBJECT_TYPE_GROUP = 0;
033: public final static short OBJECT_TYPE_LINE = 1;
034: public final static short OBJECT_TYPE_RECTANGLE = 2;
035: public final static short OBJECT_TYPE_OVAL = 3;
036: public final static short OBJECT_TYPE_ARC = 4;
037: public final static short OBJECT_TYPE_CHART = 5;
038: public final static short OBJECT_TYPE_TEXT = 6;
039: public final static short OBJECT_TYPE_BUTTON = 7;
040: public final static short OBJECT_TYPE_PICTURE = 8;
041: public final static short OBJECT_TYPE_POLYGON = 9;
042: public final static short OBJECT_TYPE_RESERVED1 = 10;
043: public final static short OBJECT_TYPE_CHECKBOX = 11;
044: public final static short OBJECT_TYPE_OPTION_BUTTON = 12;
045: public final static short OBJECT_TYPE_EDIT_BOX = 13;
046: public final static short OBJECT_TYPE_LABEL = 14;
047: public final static short OBJECT_TYPE_DIALOG_BOX = 15;
048: public final static short OBJECT_TYPE_SPINNER = 16;
049: public final static short OBJECT_TYPE_SCROLL_BAR = 17;
050: public final static short OBJECT_TYPE_LIST_BOX = 18;
051: public final static short OBJECT_TYPE_GROUP_BOX = 19;
052: public final static short OBJECT_TYPE_COMBO_BOX = 20;
053: public final static short OBJECT_TYPE_RESERVED2 = 21;
054: public final static short OBJECT_TYPE_RESERVED3 = 22;
055: public final static short OBJECT_TYPE_RESERVED4 = 23;
056: public final static short OBJECT_TYPE_RESERVED5 = 24;
057: public final static short OBJECT_TYPE_COMMENT = 25;
058: public final static short OBJECT_TYPE_RESERVED6 = 26;
059: public final static short OBJECT_TYPE_RESERVED7 = 27;
060: public final static short OBJECT_TYPE_RESERVED8 = 28;
061: public final static short OBJECT_TYPE_RESERVED9 = 29;
062: public final static short OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING = 30;
063: private short field_2_objectId;
064: private short field_3_option;
065: private BitField locked = BitFieldFactory.getInstance(0x1);
066: private BitField printable = BitFieldFactory.getInstance(0x10);
067: private BitField autofill = BitFieldFactory.getInstance(0x2000);
068: private BitField autoline = BitFieldFactory.getInstance(0x4000);
069: private int field_4_reserved1;
070: private int field_5_reserved2;
071: private int field_6_reserved3;
072:
073: public CommonObjectDataSubRecord() {
074:
075: }
076:
077: /**
078: * Constructs a CommonObjectData record and sets its fields appropriately.
079: *
080: * @param in the RecordInputstream to read the record from
081: */
082:
083: public CommonObjectDataSubRecord(RecordInputStream in) {
084: super (in);
085: }
086:
087: /**
088: * Checks the sid matches the expected side for this record
089: *
090: * @param id the expected sid.
091: */
092: protected void validateSid(short id) {
093: if (id != sid) {
094: throw new RecordFormatException(
095: "Not a CommonObjectData record");
096: }
097: }
098:
099: protected void fillFields(RecordInputStream in) {
100: field_1_objectType = in.readShort();
101: field_2_objectId = in.readShort();
102: field_3_option = in.readShort();
103: field_4_reserved1 = in.readInt();
104: field_5_reserved2 = in.readInt();
105: field_6_reserved3 = in.readInt();
106: }
107:
108: public String toString() {
109: StringBuffer buffer = new StringBuffer();
110:
111: buffer.append("[ftCmo]\n");
112: buffer.append(" .objectType = ").append("0x")
113: .append(HexDump.toHex(getObjectType())).append(" (")
114: .append(getObjectType()).append(" )");
115: buffer.append(System.getProperty("line.separator"));
116: buffer.append(" .objectId = ").append("0x")
117: .append(HexDump.toHex(getObjectId())).append(" (")
118: .append(getObjectId()).append(" )");
119: buffer.append(System.getProperty("line.separator"));
120: buffer.append(" .option = ").append("0x")
121: .append(HexDump.toHex(getOption())).append(" (")
122: .append(getOption()).append(" )");
123: buffer.append(System.getProperty("line.separator"));
124: buffer.append(" .locked = ").append(
125: isLocked()).append('\n');
126: buffer.append(" .printable = ").append(
127: isPrintable()).append('\n');
128: buffer.append(" .autofill = ").append(
129: isAutofill()).append('\n');
130: buffer.append(" .autoline = ").append(
131: isAutoline()).append('\n');
132: buffer.append(" .reserved1 = ").append("0x")
133: .append(HexDump.toHex(getReserved1())).append(" (")
134: .append(getReserved1()).append(" )");
135: buffer.append(System.getProperty("line.separator"));
136: buffer.append(" .reserved2 = ").append("0x")
137: .append(HexDump.toHex(getReserved2())).append(" (")
138: .append(getReserved2()).append(" )");
139: buffer.append(System.getProperty("line.separator"));
140: buffer.append(" .reserved3 = ").append("0x")
141: .append(HexDump.toHex(getReserved3())).append(" (")
142: .append(getReserved3()).append(" )");
143: buffer.append(System.getProperty("line.separator"));
144:
145: buffer.append("[/ftCmo]\n");
146: return buffer.toString();
147: }
148:
149: public int serialize(int offset, byte[] data) {
150: int pos = 0;
151:
152: LittleEndian.putShort(data, 0 + offset, sid);
153: LittleEndian.putShort(data, 2 + offset,
154: (short) (getRecordSize() - 4));
155:
156: LittleEndian.putShort(data, 4 + offset + pos,
157: field_1_objectType);
158: LittleEndian.putShort(data, 6 + offset + pos, field_2_objectId);
159: LittleEndian.putShort(data, 8 + offset + pos, field_3_option);
160: LittleEndian.putInt(data, 10 + offset + pos, field_4_reserved1);
161: LittleEndian.putInt(data, 14 + offset + pos, field_5_reserved2);
162: LittleEndian.putInt(data, 18 + offset + pos, field_6_reserved3);
163:
164: return getRecordSize();
165: }
166:
167: /**
168: * Size of record (exluding 4 byte header)
169: */
170: public int getRecordSize() {
171: return 4 + 2 + 2 + 2 + 4 + 4 + 4;
172: }
173:
174: public short getSid() {
175: return sid;
176: }
177:
178: public Object clone() {
179: CommonObjectDataSubRecord rec = new CommonObjectDataSubRecord();
180:
181: rec.field_1_objectType = field_1_objectType;
182: rec.field_2_objectId = field_2_objectId;
183: rec.field_3_option = field_3_option;
184: rec.field_4_reserved1 = field_4_reserved1;
185: rec.field_5_reserved2 = field_5_reserved2;
186: rec.field_6_reserved3 = field_6_reserved3;
187: return rec;
188: }
189:
190: /**
191: * Get the object type field for the CommonObjectData record.
192: *
193: * @return One of
194: * OBJECT_TYPE_GROUP
195: * OBJECT_TYPE_LINE
196: * OBJECT_TYPE_RECTANGLE
197: * OBJECT_TYPE_OVAL
198: * OBJECT_TYPE_ARC
199: * OBJECT_TYPE_CHART
200: * OBJECT_TYPE_TEXT
201: * OBJECT_TYPE_BUTTON
202: * OBJECT_TYPE_PICTURE
203: * OBJECT_TYPE_POLYGON
204: * OBJECT_TYPE_RESERVED1
205: * OBJECT_TYPE_CHECKBOX
206: * OBJECT_TYPE_OPTION_BUTTON
207: * OBJECT_TYPE_EDIT_BOX
208: * OBJECT_TYPE_LABEL
209: * OBJECT_TYPE_DIALOG_BOX
210: * OBJECT_TYPE_SPINNER
211: * OBJECT_TYPE_SCROLL_BAR
212: * OBJECT_TYPE_LIST_BOX
213: * OBJECT_TYPE_GROUP_BOX
214: * OBJECT_TYPE_COMBO_BOX
215: * OBJECT_TYPE_RESERVED2
216: * OBJECT_TYPE_RESERVED3
217: * OBJECT_TYPE_RESERVED4
218: * OBJECT_TYPE_RESERVED5
219: * OBJECT_TYPE_COMMENT
220: * OBJECT_TYPE_RESERVED6
221: * OBJECT_TYPE_RESERVED7
222: * OBJECT_TYPE_RESERVED8
223: * OBJECT_TYPE_RESERVED9
224: * OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING
225: */
226: public short getObjectType() {
227: return field_1_objectType;
228: }
229:
230: /**
231: * Set the object type field for the CommonObjectData record.
232: *
233: * @param field_1_objectType
234: * One of
235: * OBJECT_TYPE_GROUP
236: * OBJECT_TYPE_LINE
237: * OBJECT_TYPE_RECTANGLE
238: * OBJECT_TYPE_OVAL
239: * OBJECT_TYPE_ARC
240: * OBJECT_TYPE_CHART
241: * OBJECT_TYPE_TEXT
242: * OBJECT_TYPE_BUTTON
243: * OBJECT_TYPE_PICTURE
244: * OBJECT_TYPE_POLYGON
245: * OBJECT_TYPE_RESERVED1
246: * OBJECT_TYPE_CHECKBOX
247: * OBJECT_TYPE_OPTION_BUTTON
248: * OBJECT_TYPE_EDIT_BOX
249: * OBJECT_TYPE_LABEL
250: * OBJECT_TYPE_DIALOG_BOX
251: * OBJECT_TYPE_SPINNER
252: * OBJECT_TYPE_SCROLL_BAR
253: * OBJECT_TYPE_LIST_BOX
254: * OBJECT_TYPE_GROUP_BOX
255: * OBJECT_TYPE_COMBO_BOX
256: * OBJECT_TYPE_RESERVED2
257: * OBJECT_TYPE_RESERVED3
258: * OBJECT_TYPE_RESERVED4
259: * OBJECT_TYPE_RESERVED5
260: * OBJECT_TYPE_COMMENT
261: * OBJECT_TYPE_RESERVED6
262: * OBJECT_TYPE_RESERVED7
263: * OBJECT_TYPE_RESERVED8
264: * OBJECT_TYPE_RESERVED9
265: * OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING
266: */
267: public void setObjectType(short field_1_objectType) {
268: this .field_1_objectType = field_1_objectType;
269: }
270:
271: /**
272: * Get the object id field for the CommonObjectData record.
273: */
274: public short getObjectId() {
275: return field_2_objectId;
276: }
277:
278: /**
279: * Set the object id field for the CommonObjectData record.
280: */
281: public void setObjectId(short field_2_objectId) {
282: this .field_2_objectId = field_2_objectId;
283: }
284:
285: /**
286: * Get the option field for the CommonObjectData record.
287: */
288: public short getOption() {
289: return field_3_option;
290: }
291:
292: /**
293: * Set the option field for the CommonObjectData record.
294: */
295: public void setOption(short field_3_option) {
296: this .field_3_option = field_3_option;
297: }
298:
299: /**
300: * Get the reserved1 field for the CommonObjectData record.
301: */
302: public int getReserved1() {
303: return field_4_reserved1;
304: }
305:
306: /**
307: * Set the reserved1 field for the CommonObjectData record.
308: */
309: public void setReserved1(int field_4_reserved1) {
310: this .field_4_reserved1 = field_4_reserved1;
311: }
312:
313: /**
314: * Get the reserved2 field for the CommonObjectData record.
315: */
316: public int getReserved2() {
317: return field_5_reserved2;
318: }
319:
320: /**
321: * Set the reserved2 field for the CommonObjectData record.
322: */
323: public void setReserved2(int field_5_reserved2) {
324: this .field_5_reserved2 = field_5_reserved2;
325: }
326:
327: /**
328: * Get the reserved3 field for the CommonObjectData record.
329: */
330: public int getReserved3() {
331: return field_6_reserved3;
332: }
333:
334: /**
335: * Set the reserved3 field for the CommonObjectData record.
336: */
337: public void setReserved3(int field_6_reserved3) {
338: this .field_6_reserved3 = field_6_reserved3;
339: }
340:
341: /**
342: * Sets the locked field value.
343: * true if object is locked when sheet has been protected
344: */
345: public void setLocked(boolean value) {
346: field_3_option = locked.setShortBoolean(field_3_option, value);
347: }
348:
349: /**
350: * true if object is locked when sheet has been protected
351: * @return the locked field value.
352: */
353: public boolean isLocked() {
354: return locked.isSet(field_3_option);
355: }
356:
357: /**
358: * Sets the printable field value.
359: * object appears when printed
360: */
361: public void setPrintable(boolean value) {
362: field_3_option = printable.setShortBoolean(field_3_option,
363: value);
364: }
365:
366: /**
367: * object appears when printed
368: * @return the printable field value.
369: */
370: public boolean isPrintable() {
371: return printable.isSet(field_3_option);
372: }
373:
374: /**
375: * Sets the autofill field value.
376: * whether object uses an automatic fill style
377: */
378: public void setAutofill(boolean value) {
379: field_3_option = autofill
380: .setShortBoolean(field_3_option, value);
381: }
382:
383: /**
384: * whether object uses an automatic fill style
385: * @return the autofill field value.
386: */
387: public boolean isAutofill() {
388: return autofill.isSet(field_3_option);
389: }
390:
391: /**
392: * Sets the autoline field value.
393: * whether object uses an automatic line style
394: */
395: public void setAutoline(boolean value) {
396: field_3_option = autoline
397: .setShortBoolean(field_3_option, value);
398: }
399:
400: /**
401: * whether object uses an automatic line style
402: * @return the autoline field value.
403: */
404: public boolean isAutoline() {
405: return autoline.isSet(field_3_option);
406: }
407:
408: } // END OF CLASS
|