Esempio n. 1
0
 static void writeSttbSavedBy(String[] data, HWPFOutputStream tableStream) throws IOException {
   Sttb sttb = new Sttb();
   sttb.cDataLength = CDATA_SIZE_STTB_SAVED_BY;
   sttb.data = data;
   sttb.cbExtra = CBEXTRA_STTB_SAVED_BY;
   write(sttb, tableStream);
 }
Esempio n. 2
0
 static void writeSttbfRMark(String[] data, HWPFOutputStream tableStream) throws IOException {
   Sttb sttb = new Sttb();
   sttb.cDataLength = CDATA_SIZE_STTBF_R_MARK;
   sttb.data = data;
   sttb.cbExtra = CBEXTRA_STTBF_R_MARK;
   write(sttb, tableStream);
 }
Esempio n. 3
0
  static Sttb read(int cDataLength, byte[] buffer, int startOffset) {
    short ffff = LittleEndian.getShort(buffer, startOffset);
    int offset = startOffset + 2;

    if (ffff != (short) 0xffff) {
      // Non-extended character Pascal strings
      throw new UnsupportedOperationException(
          "Non-extended character Pascal strings are not supported right now. "
              + "Please, contact POI developers for update.");
    }
    // strings are extended character strings

    int cData =
        cDataLength == 2
            ? LittleEndian.getUShort(buffer, offset)
            : LittleEndian.getInt(buffer, offset);
    offset += cDataLength;

    Sttb sttb = new Sttb();
    sttb.cDataLength = cDataLength;
    sttb.cbExtra = LittleEndian.getUShort(buffer, offset);
    offset += 2;

    sttb.data = new String[cData];
    sttb.extraData = new byte[cData][];

    for (int i = 0; i < cData; i++) {
      int cchData = LittleEndian.getShort(buffer, offset);
      offset += 2;

      if (cchData < 0) continue;

      sttb.data[i] = StringUtil.getFromUnicodeLE(buffer, offset, cchData);
      offset += cchData * 2;

      sttb.extraData[i] = LittleEndian.getByteArray(buffer, offset, sttb.cbExtra);
      offset += sttb.cbExtra;
    }

    return sttb;
  }