JFLib

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 Place where an unknown item stood

    • Element -- an attribute of the element itself
    • AfterChild(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 itself
    • InConnects(u32) -- inside the element's Connects child, after this many Connect elements; an attribute here is one of the Connects element itself
  • enum ExtraItem an unknown attribute, element or text

    • Attribute { name: Sym, value: Sym, } -- name="value" (the name with its prefix as written)
    • Element(Sym) -- an element with everything inside it, as XML text
    • Text(Sym) -- character data
  • struct Extra one unknown item and its place

    • place: Place -- where it stood
    • item: 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() -> Self none

  • fn push(&mut self, extra: Extra) add one item

  • fn items(&self) -> &[Extra] the items in the order they were added

  • fn is_empty(&self) -> bool whether there are none

  • struct Trigger an 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 RowKey how a row is identified in its section

    • Index(u32) -- IX (rows of Geometry, Character, Connection ...)
    • Named(Sym) -- N (rows of User, Property, Hyperlink ...)
  • struct SecKey how a section is identified in its sheet: Geometry by index, every other section index 0

    • name: Sym -- the section name (N)
    • index: u32 -- IX of the section (0-based; only Geometry has several)

impl SecKey

  • const fn one(name: Sym) -> SecKey a section that exists once per sheet

  • struct CellAddr where a cell sits in a sheet

    • section: Option<SecKey> -- None: a single cell of the sheet
    • row: Option<RowKey> -- None: a cell of the section itself (Geometry's NoFill ...)
    • cell: Sym -- the cell name

impl CellAddr

  • const fn single(cell: Sym) -> CellAddr a single cell (PinX, Width ...)

  • const fn section(section: SecKey, cell: Sym) -> CellAddr a cell of a section itself (Geometry1.NoFill)

  • const fn row(section: SecKey, row: RowKey, cell: Sym) -> CellAddr a cell of a row (Geometry1.X2, Prop.Name.Value)

  • struct Row a row of a section

    • key: RowKey -- IX or N
    • ix_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 none
    • del: bool -- Del="1": the inherited row is deleted here
    • cells: Vec<Cell> -- the cells in file order
    • triggers: Vec<Trigger> -- update triggers of the row
    • extras: Extras -- unknown items

impl Row

  • fn new(key: RowKey) -> Row an empty row

  • fn cell(&self, name: Sym) -> Option<&Cell> the cell named name

  • fn cell_pos(&self, name: Sym) -> Option<usize> the position of the cell named name

  • struct Section a section of a sheet

    • name: Sym -- the section name (N)
    • index: u32 -- IX (0-based; counted when the file has none)
    • ix_written: bool -- whether IX stood in the file
    • del: bool -- Del="1": the inherited section is deleted here
    • cells: 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 section
    • extras: Extras -- unknown items

impl Section

  • fn new(key: SecKey) -> Section an empty section

  • fn key(&self) -> SecKey the section's key

  • fn row(&self, key: RowKey) -> Option<&Row> the row with this key

  • fn row_pos(&self, key: RowKey) -> Option<usize> the position of the row with this key

  • fn cell(&self, name: Sym) -> Option<&Cell> the cell of the section itself named name

  • fn insert_pos(&self, key: RowKey) -> usize where a new indexed row with this index belongs (rows stay sorted by index)

  • struct Sheet a ShapeSheet: single cells and sections

    • cells: Vec<Cell> -- the single cells in file order
    • sections: Vec<Section> -- the sections in file order
    • triggers: Vec<Trigger> -- update triggers of the sheet
    • extras: Extras -- unknown items
  • enum Local<'a> what a sheet holds at an address, without inheritance

    • Cell(&'a Cell) -- the cell is here
    • Deleted -- the row or section is here with Del="1"
    • Missing -- nothing here: ask the parent

impl Sheet

  • fn new() -> Sheet an empty sheet
  • fn cell(&self, name: Sym) -> Option<&Cell> the single cell named name
  • fn section(&self, key: SecKey) -> Option<&Section> the section with this key
  • fn section_pos(&self, key: SecKey) -> Option<usize> the position of the section with this key
  • fn find(&self, addr: &CellAddr) -> Local<'_> the cell at addr in this sheet alone (no inheritance)
  • fn is_empty(&self) -> bool whether the sheet holds no cells, sections or triggers

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