diagram_core/src/structure/rel.rs#
Source: lib/diagram_core/src/structure/rel.rs
structure::rel -- the Relationships cell: which shapes a shape is structurally tied to
relations(doc, shape) -> Relations what the cell names, by relationship type
write(tx, shape, &relations) the cell written the way Visio writes it
Visio keeps container membership, list order and callout targets in the single cell
Relationships of both shapes (Z2, Z3; learn.microsoft.com "Relationships Cell (Shape Layout
Section)"; a plain cell under <Shape>, V="0"):
container: SUM(DEPENDSON(1,Sheet.12!SheetRef(),Sheet.15!SheetRef())) its members
member: SUM(DEPENDSON(4,Sheet.7!SheetRef())) its containers
1 members of this container 4 containers of this shape
2 items of this list (in order) 5 the list of this item
3 callouts on this shape 6 the target of this callout
7 .. 10 the container on whose left / right / top / bottom edge the shape sits (JD21:
written and read by structure::edge; the container names it as a member, type 1)
11 the list this list overlaps (a cross-functional flowchart's lanes and phases)
One DEPENDSON per type, the type first, the shapes after it; Visio leaves an empty term
(SUM(DEPENDSON(4))) after the last member left, which means nothing. The order inside a term
is kept: a list's items are written in list order (how Visio stores list order is not
documented; the items also stand in that order on the page, so both readings agree). The cell has no other meaning: the formula engine evaluates it to 0 and records
the dependencies, which is what makes Visio recompute the shapes that read the structure
(CONTAINERSHEETREF, LISTORDER ...). Both sides are written; a side that is missing or
names a shape that is gone is repaired by the editing functions (structure::repair).
/// the relationship types of DEPENDSON's first argument: a container names its members
REL_CONTAINER: u32 = 1
/// a list names its items (in list order)
REL_LIST: u32 = 2
/// a target names its callouts
REL_TARGET: u32 = 3
/// a member names its containers
REL_MEMBER: u32 = 4
/// an item names its list
REL_ITEM: u32 = 5
/// a callout names its target
REL_CALLOUT: u32 = 6
fn back(kind: u32) -> Option<u32>the type the other side writes for a type (None: kept as it is, 7 .. 11)struct Relationswhat a Relationships cell names: per type the shapes in the order writtengroups: Vec<(u32, Vec<ShapeRef>)>
impl Relations
fn get(&self, kind: u32) -> &[ShapeRef]the shapes of typekindfn get_mut(&mut self, kind: u32) -> &mut Vec<ShapeRef>the list of typekind, made when missingfn is_empty(&self) -> boolwhether it names nothingfn formula(doc: &Document, shape: ShapeRef) -> Option<&str>the formula text of a shape's Relationships cell (inheritance included; masters carry none in practice, but a copy may)fn relations(doc: &Document, shape: ShapeRef) -> Relationswhat the Relationships cell ofshapenames (shapes that are gone are left out)fn parse(f: &str) -> Vec<(u32, Vec<u32>)>the DEPENDSON groups of a formula: (type, shape IDs named by Sheet.N!)fn formula_of(doc: &Document, rel: &Relations) -> Option<String>the formula Visio writes for these relations (None: nothing to name)fn write(tx: &mut Transaction, shape: ShapeRef, rel: &Relations) -> Result<(), EditError>write a shape's Relationships cell (over a GUARD, as Visio does: the cell is the structure's, not the user's)