1 2 17 18 19 package org.apache.poi.hwpf.model; 20 21 import java.lang.reflect.AccessibleObject ; 22 import java.lang.reflect.Field ; 23 import java.util.HashSet ; 24 import java.io.IOException ; 25 26 import org.apache.poi.util.BitField; 27 import org.apache.poi.util.LittleEndian; 28 import org.apache.poi.hwpf.model.io.*; 29 30 31 import org.apache.poi.hwpf.model.types.FIBAbstractType; 32 33 37 public class FileInformationBlock extends FIBAbstractType 38 implements Cloneable 39 { 40 41 FIBLongHandler _longHandler; 42 FIBShortHandler _shortHandler; 43 FIBFieldHandler _fieldHandler; 44 45 46 public FileInformationBlock(byte[] mainDocument) 47 { 48 fillFields(mainDocument, 0); 49 } 50 51 public void fillVariableFields(byte[] mainDocument, byte[] tableStream) 52 { 53 HashSet fieldSet = new HashSet (); 54 fieldSet.add(new Integer (FIBFieldHandler.STSHF)); 55 fieldSet.add(new Integer (FIBFieldHandler.CLX)); 56 fieldSet.add(new Integer (FIBFieldHandler.DOP)); 57 fieldSet.add(new Integer (FIBFieldHandler.PLCFBTECHPX)); 58 fieldSet.add(new Integer (FIBFieldHandler.PLCFBTEPAPX)); 59 fieldSet.add(new Integer (FIBFieldHandler.PLCFSED)); 60 fieldSet.add(new Integer (FIBFieldHandler.PLCFLST)); 61 fieldSet.add(new Integer (FIBFieldHandler.PLFLFO)); 62 fieldSet.add(new Integer (FIBFieldHandler.PLCFFLDMOM)); 63 fieldSet.add(new Integer (FIBFieldHandler.STTBFFFN)); 64 fieldSet.add(new Integer (FIBFieldHandler.MODIFIED)); 65 66 67 _shortHandler = new FIBShortHandler(mainDocument); 68 _longHandler = new FIBLongHandler(mainDocument, _shortHandler.START + _shortHandler.sizeInBytes()); 69 _fieldHandler = new FIBFieldHandler(mainDocument, 70 _shortHandler.START + _shortHandler.sizeInBytes() + _longHandler.sizeInBytes(), 71 tableStream, fieldSet, true); 72 } 73 74 public int getFcDop() 75 { 76 return _fieldHandler.getFieldOffset(FIBFieldHandler.DOP); 77 } 78 79 public void setFcDop(int fcDop) 80 { 81 _fieldHandler.setFieldOffset(FIBFieldHandler.DOP, fcDop); 82 } 83 84 public int getLcbDop() 85 { 86 return _fieldHandler.getFieldSize(FIBFieldHandler.DOP); 87 } 88 89 public void setLcbDop(int lcbDop) 90 { 91 _fieldHandler.setFieldSize(FIBFieldHandler.DOP, lcbDop); 92 } 93 94 public int getFcStshf() 95 { 96 return _fieldHandler.getFieldOffset(FIBFieldHandler.STSHF); 97 } 98 99 public int getLcbStshf() 100 { 101 return _fieldHandler.getFieldSize(FIBFieldHandler.STSHF); 102 } 103 104 public void setFcStshf(int fcStshf) 105 { 106 _fieldHandler.setFieldOffset(FIBFieldHandler.STSHF, fcStshf); 107 } 108 109 public void setLcbStshf(int lcbStshf) 110 { 111 _fieldHandler.setFieldSize(FIBFieldHandler.STSHF, lcbStshf); 112 } 113 114 public int getFcClx() 115 { 116 return _fieldHandler.getFieldOffset(FIBFieldHandler.CLX); 117 } 118 119 public int getLcbClx() 120 { 121 return _fieldHandler.getFieldSize(FIBFieldHandler.CLX); 122 } 123 124 public void setFcClx(int fcClx) 125 { 126 _fieldHandler.setFieldOffset(FIBFieldHandler.CLX, fcClx); 127 } 128 129 public void setLcbClx(int lcbClx) 130 { 131 _fieldHandler.setFieldSize(FIBFieldHandler.CLX, lcbClx); 132 } 133 134 public int getFcPlcfbteChpx() 135 { 136 return _fieldHandler.getFieldOffset(FIBFieldHandler.PLCFBTECHPX); 137 } 138 139 public int getLcbPlcfbteChpx() 140 { 141 return _fieldHandler.getFieldSize(FIBFieldHandler.PLCFBTECHPX); 142 } 143 144 public void setFcPlcfbteChpx(int fcPlcfBteChpx) 145 { 146 _fieldHandler.setFieldOffset(FIBFieldHandler.PLCFBTECHPX, fcPlcfBteChpx); 147 } 148 149 public void setLcbPlcfbteChpx(int lcbPlcfBteChpx) 150 { 151 _fieldHandler.setFieldSize(FIBFieldHandler.PLCFBTECHPX, lcbPlcfBteChpx); 152 } 153 154 public int getFcPlcfbtePapx() 155 { 156 return _fieldHandler.getFieldOffset(FIBFieldHandler.PLCFBTEPAPX); 157 } 158 159 public int getLcbPlcfbtePapx() 160 { 161 return _fieldHandler.getFieldSize(FIBFieldHandler.PLCFBTEPAPX); 162 } 163 164 public void setFcPlcfbtePapx(int fcPlcfBtePapx) 165 { 166 _fieldHandler.setFieldOffset(FIBFieldHandler.PLCFBTEPAPX, fcPlcfBtePapx); 167 } 168 169 public void setLcbPlcfbtePapx(int lcbPlcfBtePapx) 170 { 171 _fieldHandler.setFieldSize(FIBFieldHandler.PLCFBTEPAPX, lcbPlcfBtePapx); 172 } 173 174 public int getFcPlcfsed() 175 { 176 return _fieldHandler.getFieldOffset(FIBFieldHandler.PLCFSED); 177 } 178 179 public int getLcbPlcfsed() 180 { 181 return _fieldHandler.getFieldSize(FIBFieldHandler.PLCFSED); 182 } 183 184 public void setFcPlcfsed(int fcPlcfSed) 185 { 186 _fieldHandler.setFieldOffset(FIBFieldHandler.PLCFSED, fcPlcfSed); 187 } 188 189 public void setLcbPlcfsed(int lcbPlcfSed) 190 { 191 _fieldHandler.setFieldSize(FIBFieldHandler.PLCFSED, lcbPlcfSed); 192 } 193 194 public int getFcPlcfLst() 195 { 196 return _fieldHandler.getFieldOffset(FIBFieldHandler.PLCFLST); 197 } 198 199 public int getLcbPlcfLst() 200 { 201 return _fieldHandler.getFieldSize(FIBFieldHandler.PLCFLST); 202 } 203 204 public void setFcPlcfLst(int fcPlcfLst) 205 { 206 _fieldHandler.setFieldOffset(FIBFieldHandler.PLCFLST, fcPlcfLst); 207 } 208 209 public void setLcbPlcfLst(int lcbPlcfLst) 210 { 211 _fieldHandler.setFieldSize(FIBFieldHandler.PLCFLST, lcbPlcfLst); 212 } 213 214 public int getFcPlfLfo() 215 { 216 return _fieldHandler.getFieldOffset(FIBFieldHandler.PLFLFO); 217 } 218 219 public int getLcbPlfLfo() 220 { 221 return _fieldHandler.getFieldSize(FIBFieldHandler.PLFLFO); 222 } 223 224 public void setFcPlfLfo(int fcPlfLfo) 225 { 226 _fieldHandler.setFieldOffset(FIBFieldHandler.PLFLFO, fcPlfLfo); 227 } 228 229 public void setLcbPlfLfo(int lcbPlfLfo) 230 { 231 _fieldHandler.setFieldSize(FIBFieldHandler.PLFLFO, lcbPlfLfo); 232 } 233 234 public int getFcSttbfffn() 235 { 236 return _fieldHandler.getFieldOffset(FIBFieldHandler.STTBFFFN); 237 } 238 239 public int getLcbSttbfffn() 240 { 241 return _fieldHandler.getFieldSize(FIBFieldHandler.STTBFFFN); 242 } 243 244 public void setFcSttbfffn(int fcSttbFffn) 245 { 246 _fieldHandler.setFieldOffset(FIBFieldHandler.STTBFFFN, fcSttbFffn); 247 } 248 249 public void setLcbSttbfffn(int lcbSttbFffn) 250 { 251 _fieldHandler.setFieldSize(FIBFieldHandler.STTBFFFN, lcbSttbFffn); 252 } 253 254 public int getModifiedLow() 255 { 256 return _fieldHandler.getFieldOffset(FIBFieldHandler.PLFLFO); 257 } 258 259 public int getModifiedHigh() 260 { 261 return _fieldHandler.getFieldSize(FIBFieldHandler.PLFLFO); 262 } 263 264 public void setModifiedLow(int modifiedLow) 265 { 266 _fieldHandler.setFieldOffset(FIBFieldHandler.PLFLFO, modifiedLow); 267 } 268 269 public void setModifiedHigh(int modifiedHigh) 270 { 271 _fieldHandler.setFieldSize(FIBFieldHandler.PLFLFO, modifiedHigh); 272 } 273 274 public void setCbMac(int cbMac) 275 { 276 _longHandler.setLong(FIBLongHandler.CBMAC, cbMac); 277 } 278 279 public void clearOffsetsSizes() 280 { 281 _fieldHandler.clearFields(); 282 } 283 284 public int getFcPlcffldMom() 285 { 286 return _fieldHandler.getFieldOffset(FIBFieldHandler.PLCFFLDMOM); 287 } 288 289 public int getLcbPlcffldMom() 290 { 291 return _fieldHandler.getFieldSize(FIBFieldHandler.PLCFFLDMOM); 292 } 293 294 public void writeTo (byte[] mainStream, HWPFOutputStream tableStream) 295 throws IOException 296 { 297 300 super.serialize(mainStream, 0); 301 302 int size = super.getSize(); 303 _shortHandler.serialize(mainStream); 304 _longHandler.serialize(mainStream, size + _shortHandler.sizeInBytes()); 305 _fieldHandler.writeTo(mainStream, 306 super.getSize() + _shortHandler.sizeInBytes() + _longHandler.sizeInBytes(), tableStream); 307 308 } 309 310 public int getSize() 311 { 312 return super.getSize() + _shortHandler.sizeInBytes() + 313 _longHandler.sizeInBytes() + _fieldHandler.sizeInBytes(); 314 } 315 } 328 329 | Popular Tags |