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: * Specifies the window's zoom magnification. If this record isn't present then the windows zoom is 100%. see p384 Excel Dev Kit
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 Andrew C. Oliver (acoliver at apache.org)
028: */
029: public class SCLRecord extends Record {
030: public final static short sid = 0xa0;
031: private short field_1_numerator;
032: private short field_2_denominator;
033:
034: public SCLRecord() {
035:
036: }
037:
038: /**
039: * Constructs a SCL record and sets its fields appropriately.
040: *
041: * @param in the RecordInputstream to read the record from
042: */
043:
044: public SCLRecord(RecordInputStream in) {
045: super (in);
046:
047: }
048:
049: /**
050: * Checks the sid matches the expected side for this record
051: *
052: * @param id the expected sid.
053: */
054: protected void validateSid(short id) {
055: if (id != sid) {
056: throw new RecordFormatException("Not a SCL record");
057: }
058: }
059:
060: protected void fillFields(RecordInputStream in) {
061: field_1_numerator = in.readShort();
062: field_2_denominator = in.readShort();
063: }
064:
065: public String toString() {
066: StringBuffer buffer = new StringBuffer();
067:
068: buffer.append("[SCL]\n");
069: buffer.append(" .numerator = ").append("0x")
070: .append(HexDump.toHex(getNumerator())).append(" (")
071: .append(getNumerator()).append(" )");
072: buffer.append(System.getProperty("line.separator"));
073: buffer.append(" .denominator = ").append("0x")
074: .append(HexDump.toHex(getDenominator())).append(" (")
075: .append(getDenominator()).append(" )");
076: buffer.append(System.getProperty("line.separator"));
077:
078: buffer.append("[/SCL]\n");
079: return buffer.toString();
080: }
081:
082: public int serialize(int offset, byte[] data) {
083: int pos = 0;
084:
085: LittleEndian.putShort(data, 0 + offset, sid);
086: LittleEndian.putShort(data, 2 + offset,
087: (short) (getRecordSize() - 4));
088:
089: LittleEndian
090: .putShort(data, 4 + offset + pos, field_1_numerator);
091: LittleEndian.putShort(data, 6 + offset + pos,
092: field_2_denominator);
093:
094: return getRecordSize();
095: }
096:
097: /**
098: * Size of record (exluding 4 byte header)
099: */
100: public int getRecordSize() {
101: return 4 + 2 + 2;
102: }
103:
104: public short getSid() {
105: return sid;
106: }
107:
108: public Object clone() {
109: SCLRecord rec = new SCLRecord();
110:
111: rec.field_1_numerator = field_1_numerator;
112: rec.field_2_denominator = field_2_denominator;
113: return rec;
114: }
115:
116: /**
117: * Get the numerator field for the SCL record.
118: */
119: public short getNumerator() {
120: return field_1_numerator;
121: }
122:
123: /**
124: * Set the numerator field for the SCL record.
125: */
126: public void setNumerator(short field_1_numerator) {
127: this .field_1_numerator = field_1_numerator;
128: }
129:
130: /**
131: * Get the denominator field for the SCL record.
132: */
133: public short getDenominator() {
134: return field_2_denominator;
135: }
136:
137: /**
138: * Set the denominator field for the SCL record.
139: */
140: public void setDenominator(short field_2_denominator) {
141: this .field_2_denominator = field_2_denominator;
142: }
143:
144: } // END OF CLASS
|