📄 unaryoperator.cs
字号:
using System;
using System.Collections;
using Microsoft.Fawvw.Components.NExcel.Biff;
namespace Microsoft.Fawvw.Components.NExcel.Biff.Formula
{
/// <summary> A cell reference in a formula</summary>
abstract class UnaryOperator:Operator, ParsedThing
{
/// <summary> Gets the token representation of this item in RPN
///
/// </summary>
/// <returns> the bytes applicable to this formula
/// </returns>
override internal sbyte[] Bytes
{
get
{
// Get the data for the operands
ParseItem[] operands = getOperands();
sbyte[] data = operands[0].Bytes;
// Add on the operator byte
sbyte[] newdata = new sbyte[data.Length + 1];
Array.Copy(data, 0, newdata, 0, data.Length);
newdata[data.Length] = Token.Code;
return newdata;
}
}
/// <summary> Abstract method which gets the token for this operator
///
/// </summary>
/// <returns> the string symbol for this token
/// </returns>
internal abstract Token Token{get;}
/// <summary> Constructor</summary>
public UnaryOperator()
{
}
/// <summary> Reads the ptg data from the array starting at the specified position
///
/// </summary>
/// <param name="data">the RPN array
/// </param>
/// <param name="pos">the current position in the array, excluding the ptg identifier
/// </param>
/// <returns> the number of bytes read
/// </returns>
public virtual int read(sbyte[] data, int pos)
{
return 0;
}
/// <summary> Gets the operands for this operator from the stack</summary>
public override void getOperands(Stack s)
{
ParseItem o1 = (ParseItem) s.Pop();
add(o1);
}
/// <summary> Gets the string
///
/// </summary>
/// <param name="">buf
/// </param>
public override void getString(System.Text.StringBuilder buf)
{
ParseItem[] operands = getOperands();
buf.Append(getSymbol());
operands[0].getString(buf);
}
/// <summary> Adjusts all the relative cell references in this formula by the
/// amount specified. Used when copying formulas
///
/// </summary>
/// <param name="colAdjust">the amount to add on to each relative cell reference
/// </param>
/// <param name="rowAdjust">the amount to add on to each relative row reference
/// </param>
public override void adjustRelativeCellReferences(int colAdjust, int rowAdjust)
{
ParseItem[] operands = getOperands();
operands[0].adjustRelativeCellReferences(colAdjust, rowAdjust);
}
/// <summary> Called when a column is inserted on the specified sheet. Tells
/// the formula parser to update all of its cell references beyond this
/// column
///
/// </summary>
/// <param name="sheetIndex">the sheet on which the column was inserted
/// </param>
/// <param name="col">the column number which was inserted
/// </param>
/// <param name="currentSheet">TRUE if this formula is on the sheet in which the
/// column was inserted, FALSE otherwise
/// </param>
public override void columnInserted(int sheetIndex, int col, bool currentSheet)
{
ParseItem[] operands = getOperands();
operands[0].columnInserted(sheetIndex, col, currentSheet);
}
/// <summary> Called when a column is inserted on the specified sheet. Tells
/// the formula parser to update all of its cell references beyond this
/// column
///
/// </summary>
/// <param name="sheetIndex">the sheet on which the column was removed
/// </param>
/// <param name="col">the column number which was removed
/// </param>
/// <param name="currentSheet">TRUE if this formula is on the sheet in which the
/// column was inserted, FALSE otherwise
/// </param>
internal override void columnRemoved(int sheetIndex, int col, bool currentSheet)
{
ParseItem[] operands = getOperands();
operands[0].columnRemoved(sheetIndex, col, currentSheet);
}
/// <summary> Called when a column is inserted on the specified sheet. Tells
/// the formula parser to update all of its cell references beyond this
/// column
///
/// </summary>
/// <param name="sheetIndex">the sheet on which the row was inserted
/// </param>
/// <param name="row">the row number which was inserted
/// </param>
/// <param name="currentSheet">TRUE if this formula is on the sheet in which the
/// column was inserted, FALSE otherwise
/// </param>
internal override void rowInserted(int sheetIndex, int row, bool currentSheet)
{
ParseItem[] operands = getOperands();
operands[0].rowInserted(sheetIndex, row, currentSheet);
}
/// <summary> Called when a column is inserted on the specified sheet. Tells
/// the formula parser to update all of its cell references beyond this
/// column
///
/// </summary>
/// <param name="sheetIndex">the sheet on which the row was removed
/// </param>
/// <param name="row">the row number which was removed
/// </param>
/// <param name="currentSheet">TRUE if this formula is on the sheet in which the
/// column was inserted, FALSE otherwise
/// </param>
internal override void rowRemoved(int sheetIndex, int row, bool currentSheet)
{
ParseItem[] operands = getOperands();
operands[0].rowRemoved(sheetIndex, row, currentSheet);
}
/// <summary> Abstract method which gets the binary operator string symbol
///
/// </summary>
/// <returns> the string symbol for this token
/// </returns>
public abstract string getSymbol();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -