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 frame record indicates whether there is a border around the displayed text of a chart.
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 FrameRecord extends Record {
030: public final static short sid = 0x1032;
031: private short field_1_borderType;
032: public final static short BORDER_TYPE_REGULAR = 0;
033: public final static short BORDER_TYPE_SHADOW = 1;
034: private short field_2_options;
035: private BitField autoSize = BitFieldFactory.getInstance(0x1);
036: private BitField autoPosition = BitFieldFactory.getInstance(0x2);
037:
038: public FrameRecord() {
039:
040: }
041:
042: /**
043: * Constructs a Frame record and sets its fields appropriately.
044: *
045: * @param in the RecordInputstream to read the record from
046: */
047:
048: public FrameRecord(RecordInputStream in) {
049: super (in);
050:
051: }
052:
053: /**
054: * Checks the sid matches the expected side for this record
055: *
056: * @param id the expected sid.
057: */
058: protected void validateSid(short id) {
059: if (id != sid) {
060: throw new RecordFormatException("Not a Frame record");
061: }
062: }
063:
064: protected void fillFields(RecordInputStream in) {
065: field_1_borderType = in.readShort();
066: field_2_options = in.readShort();
067: }
068:
069: public String toString() {
070: StringBuffer buffer = new StringBuffer();
071:
072: buffer.append("[FRAME]\n");
073: buffer.append(" .borderType = ").append("0x")
074: .append(HexDump.toHex(getBorderType())).append(" (")
075: .append(getBorderType()).append(" )");
076: buffer.append(System.getProperty("line.separator"));
077: buffer.append(" .options = ").append("0x")
078: .append(HexDump.toHex(getOptions())).append(" (")
079: .append(getOptions()).append(" )");
080: buffer.append(System.getProperty("line.separator"));
081: buffer.append(" .autoSize = ").append(
082: isAutoSize()).append('\n');
083: buffer.append(" .autoPosition = ").append(
084: isAutoPosition()).append('\n');
085:
086: buffer.append("[/FRAME]\n");
087: return buffer.toString();
088: }
089:
090: public int serialize(int offset, byte[] data) {
091: int pos = 0;
092:
093: LittleEndian.putShort(data, 0 + offset, sid);
094: LittleEndian.putShort(data, 2 + offset,
095: (short) (getRecordSize() - 4));
096:
097: LittleEndian.putShort(data, 4 + offset + pos,
098: field_1_borderType);
099: LittleEndian.putShort(data, 6 + offset + pos, field_2_options);
100:
101: return getRecordSize();
102: }
103:
104: /**
105: * Size of record (exluding 4 byte header)
106: */
107: public int getRecordSize() {
108: return 4 + 2 + 2;
109: }
110:
111: public short getSid() {
112: return sid;
113: }
114:
115: public Object clone() {
116: FrameRecord rec = new FrameRecord();
117:
118: rec.field_1_borderType = field_1_borderType;
119: rec.field_2_options = field_2_options;
120: return rec;
121: }
122:
123: /**
124: * Get the border type field for the Frame record.
125: *
126: * @return One of
127: * BORDER_TYPE_REGULAR
128: * BORDER_TYPE_SHADOW
129: */
130: public short getBorderType() {
131: return field_1_borderType;
132: }
133:
134: /**
135: * Set the border type field for the Frame record.
136: *
137: * @param field_1_borderType
138: * One of
139: * BORDER_TYPE_REGULAR
140: * BORDER_TYPE_SHADOW
141: */
142: public void setBorderType(short field_1_borderType) {
143: this .field_1_borderType = field_1_borderType;
144: }
145:
146: /**
147: * Get the options field for the Frame record.
148: */
149: public short getOptions() {
150: return field_2_options;
151: }
152:
153: /**
154: * Set the options field for the Frame record.
155: */
156: public void setOptions(short field_2_options) {
157: this .field_2_options = field_2_options;
158: }
159:
160: /**
161: * Sets the auto size field value.
162: * excel calculates the size automatically if true
163: */
164: public void setAutoSize(boolean value) {
165: field_2_options = autoSize.setShortBoolean(field_2_options,
166: value);
167: }
168:
169: /**
170: * excel calculates the size automatically if true
171: * @return the auto size field value.
172: */
173: public boolean isAutoSize() {
174: return autoSize.isSet(field_2_options);
175: }
176:
177: /**
178: * Sets the auto position field value.
179: * excel calculates the position automatically
180: */
181: public void setAutoPosition(boolean value) {
182: field_2_options = autoPosition.setShortBoolean(field_2_options,
183: value);
184: }
185:
186: /**
187: * excel calculates the position automatically
188: * @return the auto position field value.
189: */
190: public boolean isAutoPosition() {
191: return autoPosition.isSet(field_2_options);
192: }
193:
194: } // END OF CLASS
|