public override void Serialize(LittleEndianOutput out1) { out1.WriteByte(field_1_last_column_index); out1.WriteByte(field_2_first_column_index); out1.WriteShort(field_3_row_index); ConstantValueParser.Encode(out1, field_4_constant_values); }
public int WriteTokenValueBytes(ILittleEndianOutput out1) { out1.WriteByte(_nColumns - 1); out1.WriteShort(_nRows - 1); ConstantValueParser.Encode(out1, _arrayValues); return(3 + ConstantValueParser.GetEncodedSize(_arrayValues)); }
public int WriteTokenValueBytes(LittleEndianOutput out1) { out1.WriteByte(token_1_columns - 1); out1.WriteShort(token_2_rows - 1); ConstantValueParser.Encode(out1, token_3_arrayValues); return(3 + ConstantValueParser.GetEncodedSize(token_3_arrayValues)); }
public CRNRecord(RecordInputStream in1) { field_1_last_column_index = in1.ReadByte() & 0x00FF; field_2_first_column_index = in1.ReadByte() & 0x00FF; field_3_row_index = in1.ReadShort(); int nValues = field_1_last_column_index - field_2_first_column_index + 1; field_4_constant_values = ConstantValueParser.Parse(in1, nValues); }
public void TestEncode() { int size = ConstantValueParser.GetEncodedSize(SAMPLE_VALUES); byte[] data = new byte[size]; ConstantValueParser.Encode(new LittleEndianByteArrayOutputStream(data, 0), SAMPLE_VALUES); if (!Arrays.Equals(data, SAMPLE_ENCODING)) { Assert.Fail("Encoding differs"); } }
public void TestDecode() { ILittleEndianInput in1 = TestcaseRecordInputStream.CreateLittleEndian(SAMPLE_ENCODING); object[] values = ConstantValueParser.Parse(in1, 4); for (int i = 0; i < values.Length; i++) { if (!IsEqual(SAMPLE_VALUES[i], values[i])) { Assert.Fail("Decoded result differs"); } } }
public void TestDecode() { RecordInputStream inStream = TestcaseRecordInputStream.CreateWithFakeSid(SAMPLE_ENCODING); object[] values = ConstantValueParser.Parse(inStream, 4); for (int i = 0; i < values.Length; i++) { if (!IsEqual(SAMPLE_VALUES[i], values[i])) { Assert.Fail("Decoded result differs"); } } }
public ExternalNameRecord(RecordInputStream in1) { field_1_option_flag = in1.ReadShort(); field_2_index = in1.ReadShort(); field_3_not_used = in1.ReadShort(); int nameLength = in1.ReadUByte(); int multibyteFlag = in1.ReadUByte(); if (multibyteFlag == 0) { field_4_name = in1.ReadCompressedUnicode(nameLength); } else { field_4_name = in1.ReadUnicodeLEString(nameLength); } if (!HasFormula) { if (!IsStdDocumentNameIdentifier && !IsOLELink && IsAutomaticLink) { // both need to be incremented int nColumns = in1.ReadUByte() + 1; int nRows = in1.ReadShort() + 1; int totalCount = nRows * nColumns; _ddeValues = ConstantValueParser.Parse(in1, totalCount); _nColumns = nColumns; _nRows = nRows; } if (in1.Remaining > 0) { throw ReadFail("Some Unread data (is formula present?)"); } field_5_name_definition = null; return; } int nBytesRemaining = in1.Available(); if (in1.Remaining <= 0) { throw ReadFail("Ran out of record data trying to read formula."); } short formulaLen = in1.ReadShort(); nBytesRemaining -= 2; field_5_name_definition = NPOI.SS.Formula.Formula.Read(formulaLen, in1, nBytesRemaining); }
public override void Serialize(ILittleEndianOutput out1) { //out1.WriteShort(field_1_option_flag); //out1.WriteShort(field_2_ixals); //out1.WriteShort(field_3_not_used); //int nameLen = field_4_name.Length; //out1.WriteShort(nameLen); //StringUtil.PutCompressedUnicode(field_4_name, out1); //if (HasFormula) //{ // field_5_name_definition.Serialize(out1); //} //else //{ // if (_ddeValues != null) // { // out1.WriteByte(_nColumns - 1); // out1.WriteShort(_nRows - 1); // ConstantValueParser.Encode(out1, _ddeValues); // } //} out1.WriteShort(field_1_option_flag); out1.WriteShort(field_2_ixals); out1.WriteShort(field_3_not_used); out1.WriteByte(field_4_name.Length); StringUtil.WriteUnicodeStringFlagAndData(out1, field_4_name); if (!IsOLELink && !IsStdDocumentNameIdentifier) { if (IsAutomaticLink) { if (_ddeValues != null) { out1.WriteByte(_nColumns - 1); out1.WriteShort(_nRows - 1); ConstantValueParser.Encode(out1, _ddeValues); } } else { field_5_name_definition.Serialize(out1); } } }
/** * Read in the actual token (array) values. This occurs * AFTER the last Ptg in the expression. * See page 304-305 of Excel97-2007BinaryFileFormat(xls)Specification.pdf */ public void ReadTokenValues(LittleEndianInput in1) { short nColumns = (short)in1.ReadUByte(); short nRows = in1.ReadShort(); //The token_1_columns and token_2_rows do not follow the documentation. //The number of physical rows and columns is actually +1 of these values. //Which is not explicitly documented. nColumns++; nRows++; token_1_columns = nColumns; token_2_rows = nRows; int totalCount = nRows * nColumns; token_3_arrayValues = ConstantValueParser.Parse(in1, totalCount); }
/** * Read in the actual token (array) values. This occurs * AFTER the last Ptg in the expression. * See page 304-305 of Excel97-2007BinaryFileFormat(xls)Specification.pdf */ public ArrayPtg FinishReading(ILittleEndianInput in1) { int nColumns = in1.ReadUByte(); short nRows = in1.ReadShort(); //The token_1_columns and token_2_rows do not follow the documentation. //The number of physical rows and columns is actually +1 of these values. //Which is not explicitly documented. nColumns++; nRows++; int totalCount = nRows * nColumns; Object[] arrayValues = ConstantValueParser.Parse(in1, totalCount); ArrayPtg result = new ArrayPtg(_reserved0, _reserved1, _reserved2, nColumns, nRows, arrayValues); result.PtgClass = this.PtgClass; return(result); }
public override void Serialize(LittleEndianOutput out1) { out1.WriteShort(field_1_option_flag); out1.WriteShort(field_2_index); out1.WriteShort(field_3_not_used); int nameLen = field_4_name.Length; out1.WriteShort(nameLen); StringUtil.PutCompressedUnicode(field_4_name, out1); if (HasFormula) { field_5_name_definition.Serialize(out1); } else { if (_ddeValues != null) { out1.WriteByte(_nColumns - 1); out1.WriteShort(_nRows - 1); ConstantValueParser.Encode(out1, _ddeValues); } } }
public ExternalNameRecord(RecordInputStream in1) { field_1_option_flag = in1.ReadShort(); field_2_ixals = in1.ReadShort(); field_3_not_used = in1.ReadShort(); int numChars = in1.ReadUByte(); field_4_name = StringUtil.ReadUnicodeString(in1, numChars); // the record body can take different forms. // The form is dictated by the values of 3-th and 4-th bits in field_1_option_flag if (!IsOLELink && !IsStdDocumentNameIdentifier) { // another switch: the fWantAdvise bit specifies whether the body describes // an external defined name or a DDE data item if (IsAutomaticLink) { if (in1.Available() > 0) { //body specifies DDE data item int nColumns = in1.ReadUByte() + 1; int nRows = in1.ReadShort() + 1; int totalCount = nRows * nColumns; _ddeValues = ConstantValueParser.Parse(in1, totalCount); _nColumns = nColumns; _nRows = nRows; } } else { //body specifies an external defined name int formulaLen = in1.ReadUShort(); field_5_name_definition = Formula.Read(formulaLen, in1); } } }
public ExternalNameRecord(RecordInputStream in1) { field_1_option_flag = in1.ReadShort(); field_2_ixals = in1.ReadShort(); field_3_not_used = in1.ReadShort(); int numChars = in1.ReadUByte(); field_4_name = StringUtil.ReadUnicodeString(in1, numChars); // the record body can take different forms. // The form is dictated by the values of 3-th and 4-th bits in field_1_option_flag if (!IsOLELink && !IsStdDocumentNameIdentifier) { // another switch: the fWantAdvise bit specifies whether the body describes // an external defined name or a DDE data item if (IsAutomaticLink) { if (in1.Available() > 0) { //body specifies DDE data item int nColumns = in1.ReadUByte() + 1; int nRows = in1.ReadShort() + 1; int totalCount = nRows * nColumns; _ddeValues = ConstantValueParser.Parse(in1, totalCount); _nColumns = nColumns; _nRows = nRows; } } else { //body specifies an external defined name int formulaLen = in1.ReadUShort(); field_5_name_definition = Formula.Read(formulaLen, in1); } } //int nameLength = in1.ReadUByte(); //int multibyteFlag = in1.ReadUByte(); //if (multibyteFlag == 0) //{ // field_4_name = in1.ReadCompressedUnicode(nameLength); //} //else //{ // field_4_name = in1.ReadUnicodeLEString(nameLength); //} //if (!HasFormula) //{ // if (!IsStdDocumentNameIdentifier && !IsOLELink && IsAutomaticLink) // { // // both need to be incremented // int nColumns = in1.ReadUByte() + 1; // int nRows = in1.ReadShort() + 1; // int totalCount = nRows * nColumns; // _ddeValues = ConstantValueParser.Parse(in1, totalCount); // _nColumns = nColumns; // _nRows = nRows; // } // if (in1.Remaining > 0) // { // throw ReadFail("Some Unread data (is formula present?)"); // } // field_5_name_definition = null; // return; //} //int nBytesRemaining = in1.Available(); //if (in1.Remaining <= 0) //{ // throw ReadFail("Ran out of record data trying to read formula."); //} //short formulaLen = in1.ReadShort(); //nBytesRemaining -= 2; //field_5_name_definition = Zephyr.Utils.NPOI.SS.Formula.Formula.Read(formulaLen, in1, nBytesRemaining); }
public void TestGetEncodedSize() { int actual = ConstantValueParser.GetEncodedSize(SAMPLE_VALUES); Assert.AreEqual(51, actual); }