1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 24 import org.apache.poi.util.*; 25 26 33 public class ObjectLinkRecord 34 extends Record 35 { 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; 45 46 47 public ObjectLinkRecord() 48 { 49 50 } 51 52 60 61 public ObjectLinkRecord(short id, short size, byte [] data) 62 { 63 super(id, size, data); 64 65 } 66 67 76 77 public ObjectLinkRecord(short id, short size, byte [] data, int offset) 78 { 79 super(id, size, data, offset); 80 81 } 82 83 88 protected void validateSid(short id) 89 { 90 if (id != sid) 91 { 92 throw new RecordFormatException("Not a ObjectLink record"); 93 } 94 } 95 96 protected void fillFields(byte [] data, short size, int offset) 97 { 98 99 int pos = 0; 100 field_1_anchorId = LittleEndian.getShort(data, pos + 0x0 + offset); 101 field_2_link1 = LittleEndian.getShort(data, pos + 0x2 + offset); 102 field_3_link2 = LittleEndian.getShort(data, pos + 0x4 + offset); 103 104 } 105 106 public String toString() 107 { 108 StringBuffer buffer = new StringBuffer (); 109 110 buffer.append("[OBJECTLINK]\n"); 111 buffer.append(" .anchorId = ") 112 .append("0x").append(HexDump.toHex( getAnchorId ())) 113 .append(" (").append( getAnchorId() ).append(" )"); 114 buffer.append(System.getProperty("line.separator")); 115 buffer.append(" .link1 = ") 116 .append("0x").append(HexDump.toHex( getLink1 ())) 117 .append(" (").append( getLink1() ).append(" )"); 118 buffer.append(System.getProperty("line.separator")); 119 buffer.append(" .link2 = ") 120 .append("0x").append(HexDump.toHex( getLink2 ())) 121 .append(" (").append( getLink2() ).append(" )"); 122 buffer.append(System.getProperty("line.separator")); 123 124 buffer.append("[/OBJECTLINK]\n"); 125 return buffer.toString(); 126 } 127 128 public int serialize(int offset, byte[] data) 129 { 130 int pos = 0; 131 132 LittleEndian.putShort(data, 0 + offset, sid); 133 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 134 135 LittleEndian.putShort(data, 4 + offset + pos, field_1_anchorId); 136 LittleEndian.putShort(data, 6 + offset + pos, field_2_link1); 137 LittleEndian.putShort(data, 8 + offset + pos, field_3_link2); 138 139 return getRecordSize(); 140 } 141 142 145 public int getRecordSize() 146 { 147 return 4 + 2 + 2 + 2; 148 } 149 150 public short getSid() 151 { 152 return this.sid; 153 } 154 155 public Object clone() { 156 ObjectLinkRecord rec = new ObjectLinkRecord(); 157 158 rec.field_1_anchorId = field_1_anchorId; 159 rec.field_2_link1 = field_2_link1; 160 rec.field_3_link2 = field_3_link2; 161 return rec; 162 } 163 164 165 166 167 177 public short getAnchorId() 178 { 179 return field_1_anchorId; 180 } 181 182 193 public void setAnchorId(short field_1_anchorId) 194 { 195 this.field_1_anchorId = field_1_anchorId; 196 } 197 198 201 public short getLink1() 202 { 203 return field_2_link1; 204 } 205 206 209 public void setLink1(short field_2_link1) 210 { 211 this.field_2_link1 = field_2_link1; 212 } 213 214 217 public short getLink2() 218 { 219 return field_3_link2; 220 } 221 222 225 public void setLink2(short field_3_link2) 226 { 227 this.field_3_link2 = field_3_link2; 228 } 229 230 231 } 233 234 235 236 | Popular Tags |