namespace com.azkoss.excellite
{
using System;
///
///Formula token for holding the index to a NAME/EXTERNNAME record.
///
internal class NameFormulaToken : FormulaToken
{
// Methods
///
///Initializes a new instance of the class.
///
///The code.
public NameFormulaToken(FormulaTokenCode code) : base(code, 5, FormulaTokenType.Operand)
{
this.nameIndex = 0;
}
///
///Convert formula token to array of byte representation.
///
///formula token' array of byte representation
public override byte[] ConvertToBytes()
{
byte[] buffer1 = base.ConvertToBytes();
BitConverter.GetBytes(this.nameIndex).CopyTo(buffer1, 1);
return buffer1;
}
///
///Make custom delay initialize.
///
///The data for initialization which is unique for each formula token.
public override void DelayInitialize(object[] data)
{
string text1 = data[0] as string;
ExcelWorksheet worksheet1 = data[1] as ExcelWorksheet;
this.nameIndex = (ushort) (Array.IndexOf(worksheet1.NamedRanges.Names, text1) + 1);
}
///
///Initialize formula token by reading input data from array of bytes
///
///input data, array of bytes
///start position for array of bytes to read from
public override void Read(byte[] rpnBytes, int startIndex)
{
this.nameIndex = BitConverter.ToUInt16(rpnBytes, startIndex + 1);
}
///
///Convert formula token to string representation.
///
///formula token string representation
public override string ToString()
{
return "Name";
}
// Fields
///
///One-based index to ExternName record.
///
private ushort nameIndex;
}
}