コード例 #1
0
ファイル: FIBFieldHandler.java プロジェクト: chiyiangel/UXIN
 void writeTo(byte mainStream[], int offset, HWPFOutputStream tableStream) throws IOException {
   int length = _fields.length / 2;
   LittleEndian.putShort(mainStream, offset, (short) length);
   offset += 2;
   for (int x = 0; x < length; x++) {
     UnhandledDataStructure ds = (UnhandledDataStructure) _unknownMap.get(Integer.valueOf(x));
     if (ds != null) {
       _fields[x * 2] = tableStream.getOffset();
       LittleEndian.putInt(mainStream, offset, tableStream.getOffset());
       offset += 4;
       byte buf[] = ds.getBuf();
       tableStream.write(buf);
       _fields[x * 2 + 1] = buf.length;
       LittleEndian.putInt(mainStream, offset, buf.length);
       offset += 4;
     } else {
       LittleEndian.putInt(mainStream, offset, _fields[x * 2]);
       offset += 4;
       LittleEndian.putInt(mainStream, offset, _fields[x * 2 + 1]);
       offset += 4;
     }
   }
 }
コード例 #2
0
ファイル: FIBFieldHandler.java プロジェクト: chiyiangel/UXIN
 public FIBFieldHandler(
     byte mainStream[],
     int startOffset,
     byte tableStream[],
     HashSet offsetList,
     boolean areKnown) {
   _unknownMap = new HashMap();
   int numFields = LittleEndian.getShort(mainStream, startOffset);
   int offset = startOffset + 2;
   _fields = new int[numFields * 2];
   for (int x = 0; x < numFields; x++) {
     int fieldOffset = x * 8 + offset;
     int dsOffset = LittleEndian.getInt(mainStream, fieldOffset);
     fieldOffset += 4;
     int dsSize = LittleEndian.getInt(mainStream, fieldOffset);
     if (offsetList.contains(Integer.valueOf(x)) ^ areKnown && dsSize > 0)
       if (dsOffset + dsSize > tableStream.length) {
         log.log(
             POILogger.WARN,
             (new StringBuilder())
                 .append("Unhandled data structure points to outside the buffer. offset = ")
                 .append(dsOffset)
                 .append(", length = ")
                 .append(dsSize)
                 .append(", buffer length = ")
                 .append(tableStream.length)
                 .toString());
       } else {
         UnhandledDataStructure unhandled =
             new UnhandledDataStructure(tableStream, dsOffset, dsSize);
         _unknownMap.put(Integer.valueOf(x), unhandled);
       }
     _fields[x * 2] = dsOffset;
     _fields[x * 2 + 1] = dsSize;
   }
 }