Inspired by bug #44958 - Record level support for Data Tables. (No formula parser...
[poi.git] / src / java / org / apache / poi / hssf / record / ObjectLinkRecord.java
blob0d64ee3d6bb113387ddcbb3f5a14d46b0e638068
2 /* ====================================================================
3 Licensed to the Apache Software Foundation (ASF) under one or more
4 contributor license agreements. See the NOTICE file distributed with
5 this work for additional information regarding copyright ownership.
6 The ASF licenses this file to You under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with
8 the License. You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================== */
20 package org.apache.poi.hssf.record;
24 import org.apache.poi.util.*;
26 /**
27 * Links text to an object on the chart or identifies it as the title.
28 * NOTE: This source is automatically generated please do not modify this file. Either subclass or
29 * remove the record in src/records/definitions.
31 * @author Andrew C. Oliver (acoliver at apache.org)
33 public class ObjectLinkRecord
34 extends Record
36 public final static short sid = 0x1027;
37 private short field_1_anchorId;
38 public final static short ANCHOR_ID_CHART_TITLE = 1;
39 public final static short ANCHOR_ID_Y_AXIS = 2;
40 public final static short ANCHOR_ID_X_AXIS = 3;
41 public final static short ANCHOR_ID_SERIES_OR_POINT = 4;
42 public final static short ANCHOR_ID_Z_AXIS = 7;
43 private short field_2_link1;
44 private short field_3_link2;
47 public ObjectLinkRecord()
52 /**
53 * Constructs a ObjectLink record and sets its fields appropriately.
55 * @param in the RecordInputstream to read the record from
58 public ObjectLinkRecord(RecordInputStream in)
60 super(in);
64 /**
65 * Checks the sid matches the expected side for this record
67 * @param id the expected sid.
69 protected void validateSid(short id)
71 if (id != sid)
73 throw new RecordFormatException("Not a ObjectLink record");
77 protected void fillFields(RecordInputStream in)
79 field_1_anchorId = in.readShort();
80 field_2_link1 = in.readShort();
81 field_3_link2 = in.readShort();
85 public String toString()
87 StringBuffer buffer = new StringBuffer();
89 buffer.append("[OBJECTLINK]\n");
90 buffer.append(" .anchorId = ")
91 .append("0x").append(HexDump.toHex( getAnchorId ()))
92 .append(" (").append( getAnchorId() ).append(" )");
93 buffer.append(System.getProperty("line.separator"));
94 buffer.append(" .link1 = ")
95 .append("0x").append(HexDump.toHex( getLink1 ()))
96 .append(" (").append( getLink1() ).append(" )");
97 buffer.append(System.getProperty("line.separator"));
98 buffer.append(" .link2 = ")
99 .append("0x").append(HexDump.toHex( getLink2 ()))
100 .append(" (").append( getLink2() ).append(" )");
101 buffer.append(System.getProperty("line.separator"));
103 buffer.append("[/OBJECTLINK]\n");
104 return buffer.toString();
107 public int serialize(int offset, byte[] data)
109 int pos = 0;
111 LittleEndian.putShort(data, 0 + offset, sid);
112 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
114 LittleEndian.putShort(data, 4 + offset + pos, field_1_anchorId);
115 LittleEndian.putShort(data, 6 + offset + pos, field_2_link1);
116 LittleEndian.putShort(data, 8 + offset + pos, field_3_link2);
118 return getRecordSize();
122 * Size of record (exluding 4 byte header)
124 public int getRecordSize()
126 return 4 + 2 + 2 + 2;
129 public short getSid()
131 return sid;
134 public Object clone() {
135 ObjectLinkRecord rec = new ObjectLinkRecord();
137 rec.field_1_anchorId = field_1_anchorId;
138 rec.field_2_link1 = field_2_link1;
139 rec.field_3_link2 = field_3_link2;
140 return rec;
147 * Get the anchor id field for the ObjectLink record.
149 * @return One of
150 * ANCHOR_ID_CHART_TITLE
151 * ANCHOR_ID_Y_AXIS
152 * ANCHOR_ID_X_AXIS
153 * ANCHOR_ID_SERIES_OR_POINT
154 * ANCHOR_ID_Z_AXIS
156 public short getAnchorId()
158 return field_1_anchorId;
162 * Set the anchor id field for the ObjectLink record.
164 * @param field_1_anchorId
165 * One of
166 * ANCHOR_ID_CHART_TITLE
167 * ANCHOR_ID_Y_AXIS
168 * ANCHOR_ID_X_AXIS
169 * ANCHOR_ID_SERIES_OR_POINT
170 * ANCHOR_ID_Z_AXIS
172 public void setAnchorId(short field_1_anchorId)
174 this.field_1_anchorId = field_1_anchorId;
178 * Get the link 1 field for the ObjectLink record.
180 public short getLink1()
182 return field_2_link1;
186 * Set the link 1 field for the ObjectLink record.
188 public void setLink1(short field_2_link1)
190 this.field_2_link1 = field_2_link1;
194 * Get the link 2 field for the ObjectLink record.
196 public short getLink2()
198 return field_3_link2;
202 * Set the link 2 field for the ObjectLink record.
204 public void setLink2(short field_3_link2)
206 this.field_3_link2 = field_3_link2;
210 } // END OF CLASS