1 19 20 package jxl.read.biff; 21 22 import java.text.DateFormat ; 23 import java.util.Date ; 24 25 import jxl.DateCell; 26 import jxl.CellType; 27 import jxl.biff.IntegerHelper; 28 import jxl.biff.DoubleHelper; 29 import jxl.biff.FormulaData; 30 import jxl.biff.FormattingRecords; 31 import jxl.biff.formula.FormulaParser; 32 import jxl.biff.formula.FormulaException; 33 34 38 public class SharedDateFormulaRecord extends BaseSharedFormulaRecord 39 implements DateCell, FormulaData 40 { 41 45 private DateRecord dateRecord; 46 47 50 private double value; 51 52 61 public SharedDateFormulaRecord(SharedNumberFormulaRecord nfr, 62 FormattingRecords fr, 63 boolean nf, 64 SheetImpl si, 65 int pos) 66 { 67 super(nfr.getRecord(), 68 fr, 69 nfr.getExternalSheet(), 70 nfr.getNameTable(), 71 si, 72 pos); 73 dateRecord = new DateRecord(nfr, nfr.getXFIndex(), fr, nf, si); 74 value = nfr.getValue(); 75 } 76 77 82 public double getValue() 83 { 84 return value; 85 } 86 87 92 public String getContents() 93 { 94 return dateRecord.getContents(); 95 } 96 97 102 public CellType getType() 103 { 104 return CellType.DATE_FORMULA; 105 } 106 107 114 public byte[] getFormulaData() throws FormulaException 115 { 116 if (!getSheet().getWorkbookBof().isBiff8()) 117 { 118 throw new FormulaException(FormulaException.biff8Supported); 119 } 120 121 FormulaParser fp = new FormulaParser 124 (getTokens(), this, 125 getExternalSheet(), getNameTable(), 126 getSheet().getWorkbook().getSettings()); 127 fp.parse(); 128 byte[] rpnTokens = fp.getBytes(); 129 130 byte[] data = new byte[rpnTokens.length + 22]; 131 132 IntegerHelper.getTwoBytes(getRow(), data, 0); 134 IntegerHelper.getTwoBytes(getColumn(), data, 2); 135 IntegerHelper.getTwoBytes(getXFIndex(), data, 4); 136 DoubleHelper.getIEEEBytes(value, data, 6); 137 138 System.arraycopy(rpnTokens, 0, data, 22, rpnTokens.length); 140 IntegerHelper.getTwoBytes(rpnTokens.length, data, 20); 141 142 byte[] d = new byte[data.length - 6]; 144 System.arraycopy(data, 6, d, 0, data.length - 6); 145 146 return d; 147 } 148 149 154 public Date getDate() 155 { 156 return dateRecord.getDate(); 157 } 158 159 165 public boolean isTime() 166 { 167 return dateRecord.isTime(); 168 } 169 170 178 public DateFormat getDateFormat() 179 { 180 return dateRecord.getDateFormat(); 181 } 182 183 } 184 185 186 187 188 189 190 191 192 193 | Popular Tags |