JFLib

diagram_core/src/inherit.rs#

Source: lib/diagram_core/src/inherit.rs

inherit -- reading cells with inheritance: shape -> master shape -> styles -> default

  doc.resolve(sheet, &addr) -> Resolved   the formula's origin and source cell, the value
  doc.rows(sheet, sec) -> Vec<EffRow>     the rows a section really has: inherited ones,
                                          overridden ones and own ones, minus deleted ones
  doc.section_indices(sheet, name)        which Geometry sections (indices) a shape has
  doc.parent_sheet(sheet, category)       the next sheet on the way up

The way up from a sheet (FX-03, MS-10, [MS-VSDX] Style-to-Shape Inheritance):
* a shape asks first its own style of the cell's category when it names one itself
  (LineStyle for line cells, FillStyle for fill and effect cells, TextStyle for text);
* otherwise the master shape (instances and their subshapes); the master shape then follows
  the same rules, so its styles come after it;
* a shape without master asks its style of the category, cells without category end there;
* a style asks the style it is based on for that category; pages, masters' pages and the
  document ask their LineStyle/FillStyle/TextStyle;
* at the end the cell has its default (Origin::Default; the document's "No Style" style is
  normally the last style of every chain and holds real values).
A cell with F="Inh" on the way gives the value (its sheet's own result) but not the formula;
the search goes on for the formula.  A row or section with Del="1" on the way ends the
search: Origin::Deleted.  Rows are matched by IX or N, sections by name and index.  The way
is at most 64 sheets long (a cycle of styles or masters in a broken file ends there).
  • struct Resolved<'d> a cell read with inheritance
    • origin: Origin -- where the formula comes from
    • source: Option<SheetRef> -- the sheet whose cell holds the formula (None: default or deleted)
    • cell: Option<&'d Cell> -- that cell
    • cached: Option<&'d Cell> -- the nearest cell on the way, which holds the value for the asked sheet (an F="Inh" cell of the sheet itself, else the source cell)

impl<'d> Resolved<'d>

  • fn value(&self) -> Value the value for the asked sheet

  • fn num(&self) -> Option<f64> the value as a number

  • fn formula(&self) -> Formula the formula (Formula::Absent when the source cell is a constant or there is none)

  • fn unit(&self) -> Option<Unit> the unit the value is shown in

  • fn error(&self) -> Option<Sym> the error state of the value

  • fn exists(&self) -> bool whether the cell exists for the sheet (not default, not deleted)

  • struct EffRow a row a section really has (Document::rows)

    • key: RowKey -- IX or N
    • kind: Option<Sym> -- the row type (T), from the nearest sheet that names it
    • origin: Origin -- where the row comes from: Local when only the asked sheet has it
    • local: bool -- whether the asked sheet has an entry for it (own row or override)

impl Document

  • fn category(&self, addr: &CellAddr) -> Option<Category> the category of the cell at addr (which style it inherits from)

  • fn parent_sheet(&self, sheet: SheetRef, cat: Option<Category>) -> Option<SheetRef> the next sheet up from sheet for a cell of this category

  • fn resolve(&self, sheet: SheetRef, addr: &CellAddr) -> Resolved<'_> the cell at addr for sheet, with inheritance

  • fn value_of(&self, sheet: SheetRef, cell: &str) -> Value the value of a single cell (PinX, Width ...) for sheet, with inheritance

  • fn rows(&self, sheet: SheetRef, sec: SecKey) -> Vec<EffRow>

  • fn has_row(&self, sheet: SheetRef, sec: SecKey, key: RowKey) -> bool whether section sec has row key for sheet (inherited or own, not deleted)

  • fn section_indices(&self, sheet: SheetRef, name: Sym) -> Vec<u32> the indices of the sections named name that sheet really has (Geometry1 is 0)

  • fn has_section(&self, sheet: SheetRef, sec: SecKey) -> bool whether sheet has section sec (inherited or own, not deleted)

  • fn is_guarded(&self, sheet: SheetRef, addr: &CellAddr) -> bool whether the effective formula at addr is guarded (GUARD(...) at its top): edits of the user leave it alone (FX-04; the engine of JD6 knows the rest)

  • fn geometry(&self, sheet: SheetRef) -> Vec<SecKey> the Geometry sections of a sheet as keys

  • fn guarded(formula: &str) -> bool whether a formula text is GUARD(...) as a whole

Source: docs/API.md in the JFLib repository.