1 19 20 package jxl.biff.formula; 21 22 import jxl.biff.IntegerHelper; 23 import jxl.biff.WorkbookMethods; 24 25 28 class NameRange extends Operand implements ParsedThing 29 { 30 33 private WorkbookMethods nameTable; 34 35 38 private String name; 39 40 43 private int index; 44 45 48 public NameRange(WorkbookMethods nt) 49 { 50 nameTable = nt; 51 } 52 53 59 public NameRange(String nm, WorkbookMethods nt) throws FormulaException 60 { 61 name = nm; 62 nameTable = nt; 63 64 index = nameTable.getNameIndex(name); 65 66 if (index < 0 ) 67 { 68 throw new FormulaException(FormulaException.cellNameNotFound, name); 69 } 70 71 index += 1; } 73 74 81 public int read(byte[] data, int pos) 82 { 83 index = IntegerHelper.getInt(data[pos], data[pos+1]); 84 85 name = nameTable.getName(index - 1); 87 return 4; 88 } 89 90 95 byte[] getBytes() 96 { 97 byte[] data = new byte[5]; 98 data[0] = Token.NAMED_RANGE.getCode(); 99 100 IntegerHelper.getTwoBytes(index, data, 1); 101 102 return data; 103 } 104 105 111 public void getString(StringBuffer buf) 112 { 113 buf.append(name); 114 } 115 } 116 | Popular Tags |