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: * Describes the frozen and unfozen panes.
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 PaneRecord extends Record {
030: public final static short sid = 0x41;
031: private short field_1_x;
032: private short field_2_y;
033: private short field_3_topRow;
034: private short field_4_leftColumn;
035: private short field_5_activePane;
036: public final static short ACTIVE_PANE_LOWER_RIGHT = 0;
037: public final static short ACTIVE_PANE_UPPER_RIGHT = 1;
038: public final static short ACTIVE_PANE_LOWER_LEFT = 2;
039: public final static short ACTIVE_PANE_UPER_LEFT = 3;
040:
041: public PaneRecord() {
042:
043: }
044:
045: /**
046: * Constructs a Pane record and sets its fields appropriately.
047: *
048: * @param in the RecordInputstream to read the record from
049: */
050:
051: public PaneRecord(RecordInputStream in) {
052: super (in);
053:
054: }
055:
056: /**
057: * Checks the sid matches the expected side for this record
058: *
059: * @param id the expected sid.
060: */
061: protected void validateSid(short id) {
062: if (id != sid) {
063: throw new RecordFormatException("Not a Pane record");
064: }
065: }
066:
067: protected void fillFields(RecordInputStream in) {
068: field_1_x = in.readShort();
069: field_2_y = in.readShort();
070: field_3_topRow = in.readShort();
071: field_4_leftColumn = in.readShort();
072: field_5_activePane = in.readShort();
073:
074: }
075:
076: public String toString() {
077: StringBuffer buffer = new StringBuffer();
078:
079: buffer.append("[PANE]\n");
080: buffer.append(" .x = ").append("0x")
081: .append(HexDump.toHex(getX())).append(" (").append(
082: getX()).append(" )");
083: buffer.append(System.getProperty("line.separator"));
084: buffer.append(" .y = ").append("0x")
085: .append(HexDump.toHex(getY())).append(" (").append(
086: getY()).append(" )");
087: buffer.append(System.getProperty("line.separator"));
088: buffer.append(" .topRow = ").append("0x")
089: .append(HexDump.toHex(getTopRow())).append(" (")
090: .append(getTopRow()).append(" )");
091: buffer.append(System.getProperty("line.separator"));
092: buffer.append(" .leftColumn = ").append("0x")
093: .append(HexDump.toHex(getLeftColumn())).append(" (")
094: .append(getLeftColumn()).append(" )");
095: buffer.append(System.getProperty("line.separator"));
096: buffer.append(" .activePane = ").append("0x")
097: .append(HexDump.toHex(getActivePane())).append(" (")
098: .append(getActivePane()).append(" )");
099: buffer.append(System.getProperty("line.separator"));
100:
101: buffer.append("[/PANE]\n");
102: return buffer.toString();
103: }
104:
105: public int serialize(int offset, byte[] data) {
106: int pos = 0;
107:
108: LittleEndian.putShort(data, 0 + offset, sid);
109: LittleEndian.putShort(data, 2 + offset,
110: (short) (getRecordSize() - 4));
111:
112: LittleEndian.putShort(data, 4 + offset + pos, field_1_x);
113: LittleEndian.putShort(data, 6 + offset + pos, field_2_y);
114: LittleEndian.putShort(data, 8 + offset + pos, field_3_topRow);
115: LittleEndian.putShort(data, 10 + offset + pos,
116: field_4_leftColumn);
117: LittleEndian.putShort(data, 12 + offset + pos,
118: field_5_activePane);
119:
120: return getRecordSize();
121: }
122:
123: /**
124: * Size of record (exluding 4 byte header)
125: */
126: public int getRecordSize() {
127: return 4 + 2 + 2 + 2 + 2 + 2;
128: }
129:
130: public short getSid() {
131: return sid;
132: }
133:
134: public Object clone() {
135: PaneRecord rec = new PaneRecord();
136:
137: rec.field_1_x = field_1_x;
138: rec.field_2_y = field_2_y;
139: rec.field_3_topRow = field_3_topRow;
140: rec.field_4_leftColumn = field_4_leftColumn;
141: rec.field_5_activePane = field_5_activePane;
142: return rec;
143: }
144:
145: /**
146: * Get the x field for the Pane record.
147: */
148: public short getX() {
149: return field_1_x;
150: }
151:
152: /**
153: * Set the x field for the Pane record.
154: */
155: public void setX(short field_1_x) {
156: this .field_1_x = field_1_x;
157: }
158:
159: /**
160: * Get the y field for the Pane record.
161: */
162: public short getY() {
163: return field_2_y;
164: }
165:
166: /**
167: * Set the y field for the Pane record.
168: */
169: public void setY(short field_2_y) {
170: this .field_2_y = field_2_y;
171: }
172:
173: /**
174: * Get the top row field for the Pane record.
175: */
176: public short getTopRow() {
177: return field_3_topRow;
178: }
179:
180: /**
181: * Set the top row field for the Pane record.
182: */
183: public void setTopRow(short field_3_topRow) {
184: this .field_3_topRow = field_3_topRow;
185: }
186:
187: /**
188: * Get the left column field for the Pane record.
189: */
190: public short getLeftColumn() {
191: return field_4_leftColumn;
192: }
193:
194: /**
195: * Set the left column field for the Pane record.
196: */
197: public void setLeftColumn(short field_4_leftColumn) {
198: this .field_4_leftColumn = field_4_leftColumn;
199: }
200:
201: /**
202: * Get the active pane field for the Pane record.
203: *
204: * @return One of
205: * ACTIVE_PANE_LOWER_RIGHT
206: * ACTIVE_PANE_UPPER_RIGHT
207: * ACTIVE_PANE_LOWER_LEFT
208: * ACTIVE_PANE_UPER_LEFT
209: */
210: public short getActivePane() {
211: return field_5_activePane;
212: }
213:
214: /**
215: * Set the active pane field for the Pane record.
216: *
217: * @param field_5_activePane
218: * One of
219: * ACTIVE_PANE_LOWER_RIGHT
220: * ACTIVE_PANE_UPPER_RIGHT
221: * ACTIVE_PANE_LOWER_LEFT
222: * ACTIVE_PANE_UPER_LEFT
223: */
224: public void setActivePane(short field_5_activePane) {
225: this .field_5_activePane = field_5_activePane;
226: }
227:
228: } // END OF CLASS
|