diagram_core/src/cell.rs#
Source: lib/diagram_core/src/cell.rs
cell -- one ShapeSheet cell as the file keeps it: name, formula, cached value, unit, error
Cell::new(name) no value, no formula attribute
Cell { name, value, formula, unit, error, stale }
Value::Num(f64) / Text(Sym) / Absent the cached value V (internal units)
Formula::Absent / Inherited / NoFormula / Expr(Sym)
CellError::parse("#REF!") the error state E
Origin where a cell's formula comes from (local, master shape,
style, default) or that its row was deleted
Formula and value are a pair (PLAN.md, "Fallen"):
* Formula::Absent -- no F attribute: the value itself is the formula, a constant shown in U.
* Formula::Expr -- F holds an expression; V is its last result. A formula the engine (JD6)
cannot evaluate keeps V as it is.
* Formula::Inherited -- F="Inh": the formula belongs to the master shape or style, V is this
sheet's own result of it.
* Formula::NoFormula -- F="No Formula": explicitly without formula, V is a plain value.
`stale` says the formula changed and V is not its result yet; the engine clears it. V holds
numbers as f64 and everything else as text: "Themed" (theme inheritance), "#RRGGBB" colours,
strings, NURBS(...) and POLYLINE(...) results, "1.#INF".
enum Valuea cached value (V), numbers in internal unitsAbsent-- no V attributeNum(f64)-- a number (lengths in inches, angles in radians ...)Text(Sym)-- anything that is not a number, as written
impl Value
fn parse(text: &str, unit: Option<Unit>, strings: &mut Strings) -> ValueV as the file writes it with its unit U: a finite number parses to Num, everything else stays text -- also every value of a STR or GUID cell and of an unknown unit ("007" is a serial number there, not 7)fn num(self) -> Option<f64>the number, if the value is onefn text(self) -> Option<Sym>the text, if the value is oneenum Formulathe formula state of a cell (F)Absent-- no F attribute: the value is the formula (a constant)Inherited-- F="Inh": the formula is inherited, the value is this sheet's ownNoFormula-- F="No Formula": no formulaExpr(Sym)-- F holds an expression in the universal syntax
impl Formula
fn parse(text: &str, strings: &mut Strings) -> FormulaF as the file writes it ("Inh", "No Formula" or an expression)fn expr(self) -> Option<Sym>the expression, if F holds oneenum CellErrorthe error state of a cell (E), after [MS-VSDX] Cell_TypeDim-- #DIM!: a dimension out of rangeDivZero-- #DIV/0!Value-- #VALUE!: an operand of the wrong typeRef-- #REF!: a reference to a cell that does not existNum-- #NUM!: an invalid numberNotAvailable-- #N/A: no value availableName-- #NAME?: an unknown name
impl CellError
fn parse(text: &str) -> Option<CellError>the error of an E text (None for texts the crate does not know: keep them as Sym)fn as_str(self) -> &'static strthe text E holdsenum Originwhere a cell's formula comes fromLocal-- the sheet itselfMaster-- the master shape (of an instance or of a subshape of one)Style-- a style sheet (LineStyle, FillStyle, TextStyle and the styles they are based on)Default-- nowhere: the cell has its built-in defaultDeleted-- its row or section was deleted in the sheet or on the way to the master (Del="1")
struct Cellone cell as the file keeps itname: Sym-- the cell name (N): "PinX", "X", "Value" ...value: Value-- the cached value (V) in internal unitsformula: Formula-- the formula state (F)unit: Option<Unit>-- the unit it is shown in (U); None: no U attributeerror: Option<Sym>-- the error state (E) as written; CellError::parse types itstale: bool-- the formula changed and the value is not its result yet
impl Cell
fn new(name: Sym) -> Cella cell without value and formula attributefn constant(name: Sym, value: Value, unit: Option<Unit>) -> Cella constant: the value is the formulafn has_own_formula(&self) -> boolwhether the cell keeps its own formula (not F="Inh")