Package org.apache.poi.util

Examples of org.apache.poi.util.LittleEndianInput


    byte[] fullData = concat(ENCODED_PTG_DATA, ENCODED_CONSTANT_DATA);

    // Force encoded operand class for tArray
    fullData[0] = (byte) (ArrayPtg.sid + operandClass);

    LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(fullData);

    Ptg[] ptgs = Ptg.readTokens(ENCODED_PTG_DATA.length, in);
    assertEquals(1, ptgs.length);
    ArrayPtg aPtg = (ArrayPtg) ptgs[0];
    assertEquals(operandClass, aPtg.getPtgClass());
View Full Code Here


   * runtime exception for bad/icomplete data.
   *
   * @param ris the RecordInputstream to read the record from
   */
  public NameRecord(RecordInputStream ris) {
    LittleEndianInput in = ris;
    field_1_option_flag                 = in.readShort();
    field_2_keyboard_shortcut           = in.readByte();
    int field_3_length_name_text        = in.readUByte();
    int field_4_length_name_definition  = in.readShort();
    field_5_externSheetIndex_plus1      = in.readShort();
    field_6_sheetNumber                 = in.readUShort();
    int f7_customMenuLen      = in.readUByte();
    int f8_descriptionTextLen = in.readUByte();
    int f9_helpTopicTextLen  = in.readUByte();
    int f10_statusBarTextLen = in.readUByte();

    //store the name in byte form if it's a built-in name
    field_11_nameIsMultibyte = (in.readByte() != 0);
    if (isBuiltInName()) {
      field_12_built_in_code = in.readByte();
    } else {
      if (field_11_nameIsMultibyte) {
        field_12_name_text = StringUtil.readUnicodeLE(in, field_3_length_name_text);
      } else {
        field_12_name_text = StringUtil.readCompressedUnicode(in, field_3_length_name_text);
      }
    }

    int nBytesAvailable = in.available() - (f7_customMenuLen
        + f8_descriptionTextLen + f9_helpTopicTextLen + f10_statusBarTextLen);
    field_13_name_definition = Formula.read(field_4_length_name_definition, in, nBytesAvailable);

    //Who says that this can only ever be compressed unicode???
    field_14_custom_menu_text = StringUtil.readCompressedUnicode(in, f7_customMenuLen);
View Full Code Here

      out.writeShort(_comboStyle);
      out.writeShort(_lineCount);
      out.writeShort(_unknownShort13);
    }
    private static Ptg readRefPtg(byte[] formulaRawBytes) {
      LittleEndianInput in = new LittleEndianByteArrayInputStream(formulaRawBytes);
      byte ptgSid = in.readByte();
      switch(ptgSid) {
        case AreaPtg.sid:   return new AreaPtg(in);
        case Area3DPtg.sid: return new Area3DPtg(in);
        case RefPtg.sid:    return new RefPtg(in);
        case Ref3DPtg.sid:  return new Ref3DPtg(in);
View Full Code Here

    System.arraycopy(ENCODED_CONSTANT_DATA, 0, fullData, ENCODED_PTG_DATA.length, ENCODED_CONSTANT_DATA.length);

    // Force encoded operand class for tArray
    fullData[0] = (byte) (ArrayPtg.sid + operandClass);
   
    LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(fullData);
   
    Ptg[] ptgs = Ptg.readTokens(ENCODED_PTG_DATA.length, in);
    assertEquals(1, ptgs.length);
    ArrayPtg aPtg = (ArrayPtg) ptgs[0];
    assertEquals(operandClass, aPtg.getPtgClass());
View Full Code Here

    }
    private static final byte[] tRefN_data = {
      0x2C, 33, 44, 55, 66,
    };
    public void testReadWrite_tRefN_bug45091() {
      LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(tRefN_data);
        Ptg[] ptgs = Ptg.readTokens(tRefN_data.length, in);
        byte[] outData = new byte[5];
        Ptg.serializePtgs(ptgs, outData, 0);
        if (outData[0] == 0x24) {
            throw new AssertionFailedError("Identified bug 45091");
View Full Code Here

  /**
   * Fix for bug visible around svn r706772.
   */
  public void testReserializeAttrChoose() {
    byte[] data = HexRead.readFromString("19, 04, 03, 00, 08, 00, 11, 00, 1A, 00, 23, 00");
    LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(data);
    Ptg[] ptgs = Ptg.readTokens(data.length, in);
    byte[] data2 = new byte[data.length];
    try {
      Ptg.serializePtgs(ptgs, data2, 0);
    } catch (ArrayIndexOutOfBoundsException e) {
View Full Code Here

        bos.writeShort(1);
        bos.writeShort(1);
        bos.writeShort(3);
        bos.writeShort(42);
       
        LittleEndianInput in = new LittleEndianByteArrayInputStream(buf, 0, bos.getWriteIndex());
        UnicodeString.ExtRst extRst1 = new UnicodeString.ExtRst(in, bos.getWriteIndex());
        in = new LittleEndianByteArrayInputStream(buf, 0, bos.getWriteIndex());
        UnicodeString.ExtRst extRst2 = new UnicodeString.ExtRst(in, bos.getWriteIndex());
       
        assertEquals(extRst1, extRst2);
View Full Code Here

    byte[] fullData = concat(ENCODED_PTG_DATA, ENCODED_CONSTANT_DATA);

    // Force encoded operand class for tArray
    fullData[0] = (byte) (ArrayPtg.sid + operandClass);

    LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(fullData);

    Ptg[] ptgs = Ptg.readTokens(ENCODED_PTG_DATA.length, in);
    assertEquals(1, ptgs.length);
    ArrayPtg aPtg = (ArrayPtg) ptgs[0];
    assertEquals(operandClass, aPtg.getPtgClass());
View Full Code Here

    }
    field_6_unknown = readRawData(in, remaining);
  }

  private static Ptg readRefPtg(byte[] formulaRawBytes) {
    LittleEndianInput in = new LittleEndianInputStream(new ByteArrayInputStream(formulaRawBytes));
    byte ptgSid = in.readByte();
    switch(ptgSid) {
      case AreaPtg.sid:   return new AreaPtg(in);
      case Area3DPtg.sid: return new Area3DPtg(in);
      case RefPtg.sid:  return new RefPtg(in);
      case Ref3DPtg.sid:  return new Ref3DPtg(in);
View Full Code Here

  public FormulaRecord() {
    field_8_parsed_expr = Formula.create(Ptg.EMPTY_PTG_ARRAY);
  }

  public FormulaRecord(RecordInputStream ris) {
    LittleEndianInput in = ris;
    field_1_row = in.readUShort();
    field_2_column = in.readShort();
    field_3_xf = in.readShort();
    long valueLongBits  = in.readLong();
    field_5_options = in.readShort();
    specialCachedValue = SpecialCachedValue.create(valueLongBits);
    if (specialCachedValue == null) {
      field_4_value = Double.longBitsToDouble(valueLongBits);
    }

    field_6_zero = in.readInt();

    int field_7_expression_len = in.readShort(); // this length does not include any extra array data
    int nBytesAvailable = in.available();
    field_8_parsed_expr = Formula.read(field_7_expression_len, in, nBytesAvailable);
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.util.LittleEndianInput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.