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 inheritanceorigin: Origin-- where the formula comes fromsource: Option<SheetRef>-- the sheet whose cell holds the formula (None: default or deleted)cell: Option<&'d Cell>-- that cellcached: 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) -> Valuethe value for the asked sheetfn num(&self) -> Option<f64>the value as a numberfn formula(&self) -> Formulathe 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 infn error(&self) -> Option<Sym>the error state of the valuefn exists(&self) -> boolwhether the cell exists for the sheet (not default, not deleted)struct EffRowa row a section really has (Document::rows)key: RowKey-- IX or Nkind: Option<Sym>-- the row type (T), from the nearest sheet that names itorigin: Origin-- where the row comes from: Local when only the asked sheet has itlocal: 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 ataddr(which style it inherits from)fn parent_sheet(&self, sheet: SheetRef, cat: Option<Category>) -> Option<SheetRef>the next sheet up fromsheetfor a cell of this categoryfn resolve(&self, sheet: SheetRef, addr: &CellAddr) -> Resolved<'_>the cell ataddrforsheet, with inheritancefn value_of(&self, sheet: SheetRef, cell: &str) -> Valuethe value of a single cell (PinX, Width ...) forsheet, with inheritancefn rows(&self, sheet: SheetRef, sec: SecKey) -> Vec<EffRow>fn has_row(&self, sheet: SheetRef, sec: SecKey, key: RowKey) -> boolwhether sectionsechas rowkeyforsheet(inherited or own, not deleted)fn section_indices(&self, sheet: SheetRef, name: Sym) -> Vec<u32>the indices of the sections namednamethatsheetreally has (Geometry1 is 0)fn has_section(&self, sheet: SheetRef, sec: SecKey) -> boolwhethersheethas sectionsec(inherited or own, not deleted)fn is_guarded(&self, sheet: SheetRef, addr: &CellAddr) -> boolwhether the effective formula ataddris 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 keysfn guarded(formula: &str) -> boolwhether a formula text is GUARD(...) as a whole