public ArrayRecord(RecordInputStream in) {
   super(in);
   _options = in.readUShort();
   _field3notUsed = in.readInt();
   int formulaTokenLen = in.readUShort();
   int totalFormulaLen = in.available();
   _formula = Formula.read(formulaTokenLen, in, totalFormulaLen);
 }
Exemple #2
0
  /** @param in the RecordInputstream to read the record from */
  public LabelRecord(RecordInputStream in) {
    field_1_row = in.readUShort();
    field_2_column = in.readShort();
    field_3_xf_index = in.readShort();
    field_4_string_len = in.readShort();
    field_5_unicode_flag = in.readByte();
    if (field_4_string_len > 0) {
      if (isUnCompressedUnicode()) {
        field_6_value = in.readUnicodeLEString(field_4_string_len);
      } else {
        field_6_value = in.readCompressedUnicode(field_4_string_len);
      }
    } else {
      field_6_value = "";
    }

    if (in.remaining() > 0) {
      logger.log(
          POILogger.INFO,
          "LabelRecord data remains: "
              + in.remaining()
              + " : "
              + HexDump.toHex(in.readRemainder()));
    }
  }
Exemple #3
0
  /** @param in the RecordInputstream to read the record from */
  public StringRecord(RecordInputStream in) {
    int field_1_string_length = in.readUShort();
    _is16bitUnicode = in.readByte() != 0x00;

    if (_is16bitUnicode) {
      _text = in.readUnicodeLEString(field_1_string_length);
    } else {
      _text = in.readCompressedUnicode(field_1_string_length);
    }
  }
  public TextObjectRecord(RecordInputStream in) {
    field_1_options = in.readUShort();
    field_2_textOrientation = in.readUShort();
    field_3_reserved4 = in.readUShort();
    field_4_reserved5 = in.readUShort();
    field_5_reserved6 = in.readUShort();
    int field_6_textLength = in.readUShort();
    int field_7_formattingDataLength = in.readUShort();
    field_8_reserved7 = in.readInt();

    if (in.remaining() > 0) {
      // Text Objects can have simple reference formulas
      // (This bit not mentioned in the MS document)
      if (in.remaining() < 11) {
        throw new RecordFormatException("Not enough remaining data for a link formula");
      }
      int formulaSize = in.readUShort();
      _unknownPreFormulaInt = in.readInt();
      Ptg[] ptgs = Ptg.readTokens(formulaSize, in);
      if (ptgs.length != 1) {
        throw new RecordFormatException("Read " + ptgs.length + " tokens but expected exactly 1");
      }
      _linkRefPtg = (OperandPtg) ptgs[0];
      if (in.remaining() > 0) {
        _unknownPostFormulaByte = Byte.valueOf(in.readByte());
      } else {
        _unknownPostFormulaByte = null;
      }
    } else {
      _linkRefPtg = null;
    }
    if (in.remaining() > 0) {
      throw new RecordFormatException("Unused " + in.remaining() + " bytes at end of record");
    }

    String text;
    if (field_6_textLength > 0) {
      text = readRawString(in, field_6_textLength);
    } else {
      text = "";
    }
    _text = new HSSFRichTextString(text);

    if (field_7_formattingDataLength > 0) {
      processFontRuns(in, _text, field_7_formattingDataLength);
    }
  }
 public DefaultColWidthRecord(RecordInputStream in) {
   field_1_col_width = in.readUShort();
 }
  public HyperlinkRecord(RecordInputStream in) {
    _range = new CellRangeAddress(in);

    _guid = new GUID(in);

    /**
     * streamVersion (4 bytes): An unsigned integer that specifies the version number of the
     * serialization implementation used to save this structure. This value MUST equal 2.
     */
    int streamVersion = in.readInt();
    if (streamVersion != 0x00000002) {
      throw new RecordFormatException("Stream Version must be 0x2 but found " + streamVersion);
    }
    _linkOpts = in.readInt();

    if ((_linkOpts & HLINK_LABEL) != 0) {
      int label_len = in.readInt();
      _label = in.readUnicodeLEString(label_len);
    }

    if ((_linkOpts & HLINK_TARGET_FRAME) != 0) {
      int len = in.readInt();
      _targetFrame = in.readUnicodeLEString(len);
    }

    if ((_linkOpts & HLINK_URL) != 0 && (_linkOpts & HLINK_UNC_PATH) != 0) {
      _moniker = null;
      int nChars = in.readInt();
      _address = in.readUnicodeLEString(nChars);
    }

    if ((_linkOpts & HLINK_URL) != 0 && (_linkOpts & HLINK_UNC_PATH) == 0) {
      _moniker = new GUID(in);

      if (URL_MONIKER.equals(_moniker)) {
        int length = in.readInt();
        /**
         * The value of <code>length<code> be either the byte size of the url field
         * (including the terminating NULL character) or the byte size of the url field plus 24.
         * If the value of this field is set to the byte size of the url field,
         * then the tail bytes fields are not present.
         */
        int remaining = in.remaining();
        if (length == remaining) {
          int nChars = length / 2;
          _address = in.readUnicodeLEString(nChars);
        } else {
          int nChars = (length - TAIL_SIZE) / 2;
          _address = in.readUnicodeLEString(nChars);
          /**
           * TODO: make sense of the remaining bytes According to the spec they consist of: 1.
           * 16-byte GUID: This field MUST equal {0xF4815879, 0x1D3B, 0x487F, 0xAF, 0x2C, 0x82,
           * 0x5D, 0xC4, 0x85, 0x27, 0x63} 2. Serial version, this field MUST equal 0 if present. 3.
           * URI Flags
           */
          _uninterpretedTail = readTail(URL_TAIL, in);
        }
      } else if (FILE_MONIKER.equals(_moniker)) {
        _fileOpts = in.readShort();

        int len = in.readInt();
        _shortFilename = StringUtil.readCompressedUnicode(in, len);
        _uninterpretedTail = readTail(FILE_TAIL, in);
        int size = in.readInt();
        if (size > 0) {
          int charDataSize = in.readInt();

          // From the spec: An optional unsigned integer that MUST be 3 if present
          // but some files has 4
          int usKeyValue = in.readUShort();

          _address = StringUtil.readUnicodeLE(in, charDataSize / 2);
        } else {
          _address = null;
        }
      } else if (STD_MONIKER.equals(_moniker)) {
        _fileOpts = in.readShort();

        int len = in.readInt();

        byte[] path_bytes = new byte[len];
        in.readFully(path_bytes);

        _address = new String(path_bytes);
      }
    }

    if ((_linkOpts & HLINK_PLACE) != 0) {

      int len = in.readInt();
      _textMark = in.readUnicodeLEString(len);
    }

    if (in.remaining() > 0) {
      logger.log(
          POILogger.WARN,
          "Hyperlink data remains: " + in.remaining() + " : " + HexDump.toHex(in.readRemainder()));
    }
  }