1 19 20 package jxl.write.biff; 21 22 import common.Logger; 23 24 import jxl.biff.Type; 25 import jxl.biff.WritableRecordData; 26 import jxl.biff.DVParser; 27 import jxl.biff.formula.FormulaException; 28 import jxl.WorkbookSettings; 29 30 33 class DataValiditySettingsRecord extends WritableRecordData 34 { 35 38 private static final Logger logger = 39 Logger.getLogger(DataValiditySettingsRecord.class); 40 41 44 private byte[] data; 45 46 49 private DVParser dvParser; 50 51 54 private WritableWorkbookImpl workbook; 55 56 59 private WorkbookSettings workbookSettings; 60 61 66 DataValiditySettingsRecord(jxl.read.biff.DataValiditySettingsRecord dvsr, 67 WritableWorkbookImpl w, 68 WorkbookSettings ws) 69 { 70 super(Type.DV); 71 workbook = w; 72 workbookSettings = ws; 73 74 75 data = dvsr.getData(); 76 } 77 78 83 DataValiditySettingsRecord(DataValiditySettingsRecord dvsr, 84 WritableWorkbookImpl w, 85 WorkbookSettings ws) 86 { 87 super(Type.DV); 88 workbook = w; 89 workbookSettings = ws; 90 91 data = new byte[dvsr.data.length]; 92 System.arraycopy(dvsr.data, 0, data, 0, data.length); 93 } 94 95 98 private void initialize() 99 { 100 try 101 { 102 if (dvParser == null) 103 { 104 dvParser = new DVParser(data, workbook, workbook, workbookSettings); 105 } 106 } 107 catch (FormulaException e) 108 { 109 logger.warn("Cannot read drop down range " + e.getMessage()); 110 e.printStackTrace(); 111 } 112 } 113 118 public byte[] getData() 119 { 120 if (dvParser == null) 121 { 122 return data; 123 } 124 125 return dvParser.getData(); 126 } 127 128 133 public void insertRow(int row) 134 { 135 if (dvParser == null) 136 { 137 initialize(); 138 } 139 140 dvParser.insertRow(row); 141 } 142 143 148 public void removeRow(int row) 149 { 150 if (dvParser == null) 151 { 152 initialize(); 153 } 154 155 dvParser.removeRow(row); 156 } 157 158 163 public void insertColumn(int col) 164 { 165 if (dvParser == null) 166 { 167 initialize(); 168 } 169 170 dvParser.insertColumn(col); 171 } 172 173 178 public void removeColumn(int col) 179 { 180 if (dvParser == null) 181 { 182 initialize(); 183 } 184 185 dvParser.removeColumn(col); 186 } 187 188 193 public int getFirstColumn() 194 { 195 if (dvParser == null) 196 { 197 initialize(); 198 } 199 200 return dvParser.getFirstColumn(); 201 } 202 203 208 public int getLastColumn() 209 { 210 if (dvParser == null) 211 { 212 initialize(); 213 } 214 215 return dvParser.getLastColumn(); 216 } 217 218 223 public int getFirstRow() 224 { 225 if (dvParser == null) 226 { 227 initialize(); 228 } 229 230 return dvParser.getFirstRow(); 231 } 232 233 238 public int getLastRow() 239 { 240 if (dvParser == null) 241 { 242 initialize(); 243 } 244 245 return dvParser.getLastRow(); 246 } 247 } 248 | Popular Tags |