diagram_core/src/sheet.rs#
Source: lib/diagram_core/src/sheet.rs
sheet -- the ShapeSheet store: sheets of single cells and sections of rows (decision V1)
Sheet { cells, sections, triggers, extras } a shape's, page's, master's, style's or the
document's cells
Section { name, index, del, cells, rows, ... } Geometry1..n (index), Character, User ...
Row { key, kind, del, cells, ... } RowKey::Index(ix) or RowKey::Named(name)
CellAddr::single(c) / section(s, c) / row(s, r, c) where a cell sits in a sheet
SecKey { name, index } a section: Geometry has index 0, 1, 2 ...,
every other section index 0
sheet.cell(name) / section(key) / find(addr) plain lookups, no inheritance (inherit.rs)
Extras / Extra / Place / ExtraItem what the file had and the model does not
know (DF-03), at the place it stood
Rows of the sections User, Property, Actions, Control, Hyperlink and ActionTag are named (N),
the others indexed (IX); IX may be missing in the file, then the row's position counts
(`ix_written` remembers which). `del` is the file's Del="1": the row or section a master shape
or style would pass on is deleted here. Cells keep the file's order.
Extras: diagram_io fills them while reading (JD3) and writes them back at their place (JD5):
unknown attributes of the element, unknown child elements and text after the n-th known
child, what stood inside a cell (RefBy, text) by the cell's position, and what stood inside
the Shapes and Connects lists by the entries before it. An element is kept as the file
wrote it; a namespace prefix in it is declared on the part's root (kept with the root's
attributes). The model never looks into them.
enum Placewhere an unknown item stoodElement-- an attribute of the element itselfAfterChild(u32)-- a child after this many known children (0: before the first)InCell(u32)-- inside the element's cell at this position (attributes, RefBy, text)InShapes(u32)-- inside the element's Shapes child (a page's, master's or group's), after this many Shape elements; an attribute here is one of the Shapes element itselfInConnects(u32)-- inside the element's Connects child, after this many Connect elements; an attribute here is one of the Connects element itself
enum ExtraIteman unknown attribute, element or textAttribute { name: Sym, value: Sym, }-- name="value" (the name with its prefix as written)Element(Sym)-- an element with everything inside it, as XML textText(Sym)-- character data
struct Extraone unknown item and its placeplace: Place-- where it stooditem: ExtraItem-- what it was
struct Extras(Option<Box<Vec<Extra>>>)the unknown items of one element (nothing allocated while there are none)
impl Extras
const fn new() -> Selfnonefn push(&mut self, extra: Extra)add one itemfn items(&self) -> &[Extra]the items in the order they were addedfn is_empty(&self) -> boolwhether there are nonestruct Triggeran update trigger (Trigger N="..." with its RefBy children kept as XML)name: Sym-- the trigger name (N)inner: Sym-- its children as XML text (Sym::EMPTY: none)
enum RowKeyhow a row is identified in its sectionIndex(u32)-- IX (rows of Geometry, Character, Connection ...)Named(Sym)-- N (rows of User, Property, Hyperlink ...)
struct SecKeyhow a section is identified in its sheet: Geometry by index, every other section index 0name: Sym-- the section name (N)index: u32-- IX of the section (0-based; only Geometry has several)
impl SecKey
const fn one(name: Sym) -> SecKeya section that exists once per sheetstruct CellAddrwhere a cell sits in a sheetsection: Option<SecKey>-- None: a single cell of the sheetrow: Option<RowKey>-- None: a cell of the section itself (Geometry's NoFill ...)cell: Sym-- the cell name
impl CellAddr
const fn single(cell: Sym) -> CellAddra single cell (PinX, Width ...)const fn section(section: SecKey, cell: Sym) -> CellAddra cell of a section itself (Geometry1.NoFill)const fn row(section: SecKey, row: RowKey, cell: Sym) -> CellAddra cell of a row (Geometry1.X2, Prop.Name.Value)struct Rowa row of a sectionkey: RowKey-- IX or Nix_written: bool-- whether IX stood in the file (false: the position gave the index)local_name: Option<Sym>-- the language-dependent name (LocalName)kind: Option<Sym>-- the row type (T): MoveTo, LineTo ... in Geometry; None: inherited or nonedel: bool-- Del="1": the inherited row is deleted herecells: Vec<Cell>-- the cells in file ordertriggers: Vec<Trigger>-- update triggers of the rowextras: Extras-- unknown items
impl Row
fn new(key: RowKey) -> Rowan empty rowfn cell(&self, name: Sym) -> Option<&Cell>the cell namednamefn cell_pos(&self, name: Sym) -> Option<usize>the position of the cell namednamestruct Sectiona section of a sheetname: Sym-- the section name (N)index: u32-- IX (0-based; counted when the file has none)ix_written: bool-- whether IX stood in the filedel: bool-- Del="1": the inherited section is deleted herecells: Vec<Cell>-- cells of the section itself (Geometry: NoFill, NoLine, NoShow, NoSnap, NoQuickDrag)rows: Vec<Row>-- the rows in file order (indexed rows by rising IX)triggers: Vec<Trigger>-- update triggers of the sectionextras: Extras-- unknown items
impl Section
fn new(key: SecKey) -> Sectionan empty sectionfn key(&self) -> SecKeythe section's keyfn row(&self, key: RowKey) -> Option<&Row>the row with this keyfn row_pos(&self, key: RowKey) -> Option<usize>the position of the row with this keyfn cell(&self, name: Sym) -> Option<&Cell>the cell of the section itself namednamefn insert_pos(&self, key: RowKey) -> usizewhere a new indexed row with this index belongs (rows stay sorted by index)struct Sheeta ShapeSheet: single cells and sectionscells: Vec<Cell>-- the single cells in file ordersections: Vec<Section>-- the sections in file ordertriggers: Vec<Trigger>-- update triggers of the sheetextras: Extras-- unknown items
enum Local<'a>what a sheet holds at an address, without inheritanceCell(&'a Cell)-- the cell is hereDeleted-- the row or section is here with Del="1"Missing-- nothing here: ask the parent
impl Sheet
fn new() -> Sheetan empty sheetfn cell(&self, name: Sym) -> Option<&Cell>the single cell namednamefn section(&self, key: SecKey) -> Option<&Section>the section with this keyfn section_pos(&self, key: SecKey) -> Option<usize>the position of the section with this keyfn find(&self, addr: &CellAddr) -> Local<'_>the cell ataddrin this sheet alone (no inheritance)fn is_empty(&self) -> boolwhether the sheet holds no cells, sections or triggers