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: * Links text to an object on the chart or identifies it as the title.
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 ObjectLinkRecord extends Record {
030: public final static short sid = 0x1027;
031: private short field_1_anchorId;
032: public final static short ANCHOR_ID_CHART_TITLE = 1;
033: public final static short ANCHOR_ID_Y_AXIS = 2;
034: public final static short ANCHOR_ID_X_AXIS = 3;
035: public final static short ANCHOR_ID_SERIES_OR_POINT = 4;
036: public final static short ANCHOR_ID_Z_AXIS = 7;
037: private short field_2_link1;
038: private short field_3_link2;
039:
040: public ObjectLinkRecord() {
041:
042: }
043:
044: /**
045: * Constructs a ObjectLink record and sets its fields appropriately.
046: *
047: * @param in the RecordInputstream to read the record from
048: */
049:
050: public ObjectLinkRecord(RecordInputStream in) {
051: super (in);
052:
053: }
054:
055: /**
056: * Checks the sid matches the expected side for this record
057: *
058: * @param id the expected sid.
059: */
060: protected void validateSid(short id) {
061: if (id != sid) {
062: throw new RecordFormatException("Not a ObjectLink record");
063: }
064: }
065:
066: protected void fillFields(RecordInputStream in) {
067: field_1_anchorId = in.readShort();
068: field_2_link1 = in.readShort();
069: field_3_link2 = in.readShort();
070:
071: }
072:
073: public String toString() {
074: StringBuffer buffer = new StringBuffer();
075:
076: buffer.append("[OBJECTLINK]\n");
077: buffer.append(" .anchorId = ").append("0x")
078: .append(HexDump.toHex(getAnchorId())).append(" (")
079: .append(getAnchorId()).append(" )");
080: buffer.append(System.getProperty("line.separator"));
081: buffer.append(" .link1 = ").append("0x")
082: .append(HexDump.toHex(getLink1())).append(" (").append(
083: getLink1()).append(" )");
084: buffer.append(System.getProperty("line.separator"));
085: buffer.append(" .link2 = ").append("0x")
086: .append(HexDump.toHex(getLink2())).append(" (").append(
087: getLink2()).append(" )");
088: buffer.append(System.getProperty("line.separator"));
089:
090: buffer.append("[/OBJECTLINK]\n");
091: return buffer.toString();
092: }
093:
094: public int serialize(int offset, byte[] data) {
095: int pos = 0;
096:
097: LittleEndian.putShort(data, 0 + offset, sid);
098: LittleEndian.putShort(data, 2 + offset,
099: (short) (getRecordSize() - 4));
100:
101: LittleEndian.putShort(data, 4 + offset + pos, field_1_anchorId);
102: LittleEndian.putShort(data, 6 + offset + pos, field_2_link1);
103: LittleEndian.putShort(data, 8 + offset + pos, field_3_link2);
104:
105: return getRecordSize();
106: }
107:
108: /**
109: * Size of record (exluding 4 byte header)
110: */
111: public int getRecordSize() {
112: return 4 + 2 + 2 + 2;
113: }
114:
115: public short getSid() {
116: return sid;
117: }
118:
119: public Object clone() {
120: ObjectLinkRecord rec = new ObjectLinkRecord();
121:
122: rec.field_1_anchorId = field_1_anchorId;
123: rec.field_2_link1 = field_2_link1;
124: rec.field_3_link2 = field_3_link2;
125: return rec;
126: }
127:
128: /**
129: * Get the anchor id field for the ObjectLink record.
130: *
131: * @return One of
132: * ANCHOR_ID_CHART_TITLE
133: * ANCHOR_ID_Y_AXIS
134: * ANCHOR_ID_X_AXIS
135: * ANCHOR_ID_SERIES_OR_POINT
136: * ANCHOR_ID_Z_AXIS
137: */
138: public short getAnchorId() {
139: return field_1_anchorId;
140: }
141:
142: /**
143: * Set the anchor id field for the ObjectLink record.
144: *
145: * @param field_1_anchorId
146: * One of
147: * ANCHOR_ID_CHART_TITLE
148: * ANCHOR_ID_Y_AXIS
149: * ANCHOR_ID_X_AXIS
150: * ANCHOR_ID_SERIES_OR_POINT
151: * ANCHOR_ID_Z_AXIS
152: */
153: public void setAnchorId(short field_1_anchorId) {
154: this .field_1_anchorId = field_1_anchorId;
155: }
156:
157: /**
158: * Get the link 1 field for the ObjectLink record.
159: */
160: public short getLink1() {
161: return field_2_link1;
162: }
163:
164: /**
165: * Set the link 1 field for the ObjectLink record.
166: */
167: public void setLink1(short field_2_link1) {
168: this .field_2_link1 = field_2_link1;
169: }
170:
171: /**
172: * Get the link 2 field for the ObjectLink record.
173: */
174: public short getLink2() {
175: return field_3_link2;
176: }
177:
178: /**
179: * Set the link 2 field for the ObjectLink record.
180: */
181: public void setLink2(short field_3_link2) {
182: this .field_3_link2 = field_3_link2;
183: }
184:
185: } // END OF CLASS
|