1 19 20 package jxl.write.biff; 21 22 import common.Assert; 23 import common.Logger; 24 25 import jxl.CellType; 26 import jxl.LabelCell; 27 import jxl.format.CellFormat; 28 import jxl.biff.Type; 29 import jxl.biff.StringHelper; 30 import jxl.biff.IntegerHelper; 31 import jxl.biff.FormattingRecords; 32 import jxl.biff.CellReferenceHelper; 33 34 37 public abstract class LabelRecord extends CellValue 38 { 39 42 private static Logger logger = Logger.getLogger(LabelRecord.class); 43 44 47 private String contents; 48 49 52 private SharedStrings sharedStrings; 53 54 57 private int index; 58 59 66 protected LabelRecord(int c, int r, String cont) 67 { 68 super(Type.LABELSST, c, r); 69 contents = cont; 70 if (contents == null) 71 { 72 contents=""; 73 } 74 } 75 76 85 protected LabelRecord(int c, int r, String cont, CellFormat st) 86 { 87 super(Type.LABELSST, c, r, st); 88 contents = cont; 89 90 if (contents == null) 91 { 92 contents=""; 93 } 94 } 95 96 97 104 protected LabelRecord(int c, int r, LabelRecord lr) 105 { 106 super(Type.LABELSST, c, r, lr); 107 contents = lr.contents; 108 } 109 110 116 protected LabelRecord(LabelCell lc) 117 { 118 super(Type.LABELSST, lc); 119 contents = lc.getString(); 120 if (contents == null) 121 { 122 contents=""; 123 } 124 } 125 126 131 public CellType getType() 132 { 133 return CellType.LABEL; 134 } 135 136 141 public byte[] getData() 142 { 143 byte[] celldata = super.getData(); 144 byte[] data = new byte[celldata.length + 4]; 145 System.arraycopy(celldata, 0, data, 0, celldata.length); 146 IntegerHelper.getFourBytes(index, data, celldata.length); 147 148 return data; 149 } 150 151 158 public String getContents() 159 { 160 return contents; 161 } 162 163 169 public String getString() 170 { 171 return contents; 172 } 173 174 179 protected void setString(String s) 180 { 181 if (s == null) 182 { 183 s = ""; 184 } 185 186 contents = s; 187 188 if (!isReferenced()) 191 { 192 return; 193 } 194 195 Assert.verify(sharedStrings != null); 196 197 index = sharedStrings.getIndex(contents); 199 200 contents = sharedStrings.get(index); 204 } 205 206 215 void setCellDetails(FormattingRecords fr, SharedStrings ss, 216 WritableSheetImpl s) 217 { 218 super.setCellDetails(fr, ss, s); 219 220 sharedStrings = ss; 221 222 index = sharedStrings.getIndex(contents); 223 224 contents = sharedStrings.get(index); 228 } 229 230 } 231 232 233 234 | Popular Tags |