JFLib

diagram_core/src/page.rs#

Source: lib/diagram_core/src/page.rs

page -- pages, masters and styles: the containers of sheets and shapes

  Page { header, sheet, shapes, connects, theme, extras, contents_extras, part }
  PageHeader { id, name, name_u, background, back_page, sheet_styles, attrs ... }
  Master { header, sheet, icon, shapes, connects, extras, contents_extras, part }
  MasterHeader { id, name, name_u, base_id, unique_id, sheet_styles, attrs ... }
  Style { header, sheet, extras }  StyleHeader { id, name, name_u, based_on, attrs ... }
  Connect { from_sheet, from_cell, from_part, to_sheet, to_cell, to_part }
  attr(&attrs, name) -> Option<Sym>   one of the attributes kept as written

A foreground page names its background page by the background's page ID (back_page); a
background page can have one of its own.  A master's content is a page of its own with
shapes; a stencil is a document of masters without pages.  The attributes the model works
with are fields, every other attribute stays in `attrs` in file order (ViewScale,
ViewCenterX, Prompt, IconSize, PatternFlags ...), read with attr().
Connect rows are the file's record of glue (CN-15): which cell of which shape (FromSheet,
FromCell, FromPart) is glued to which part of which other shape (ToSheet, ToCell, ToPart);
the sheets are shape IDs of the same page or master.
  • fn attr(attrs: &[(Sym, Sym)], name: Sym) -> Option<Sym> the value of an attribute kept as written

  • struct Connect a Connect entry

    • from_sheet: u32 -- FromSheet: the ID of the glued shape (a connector, a callout)
    • from_cell: Option<Sym> -- FromCell: its glued cell (BeginX, EndX, Controls.Row_1 ...)
    • from_part: Option<i32> -- FromPart as written
    • to_sheet: u32 -- ToSheet: the ID of the shape it is glued to
    • to_cell: Option<Sym> -- ToCell: the cell glued to (Connections.X1, PinX ...)
    • to_part: Option<i32> -- ToPart as written
    • extras: Extras -- unknown items
  • struct PageHeader the attributes of a page (and of its PageSheet element)

    • id: u32 -- ID: unique among the pages of the document
    • name: Option<Sym> -- Name: the language-dependent name ("Zeichenblatt-1")
    • name_u: Option<Sym> -- NameU: the universal name ("Page-1")
    • is_custom_name: Option<bool> -- IsCustomName as written
    • is_custom_name_u: Option<bool> -- IsCustomNameU as written
    • background: bool -- Background="1": a background page
    • back_page: Option<u32> -- BackPage: the ID of this page's background page
    • sheet_styles: StyleRefs -- LineStyle, FillStyle, TextStyle of the PageSheet element
    • attrs: Vec<(Sym, Sym)> -- the other attributes of the Page element in file order
  • struct Page a foreground or background page

    • header: PageHeader -- the attributes
    • sheet: Sheet -- the page's ShapeSheet (size, scale, layout, print, layers in the Layer section)
    • shapes: ShapeTree -- the shapes on the page
    • connects: Vec<Connect> -- the glue records
    • theme: Option<u32> -- the theme of the page (an index into Document::themes)
    • extras: Extras -- unknown items of the Page element (in pages.xml)
    • contents_extras: Extras -- unknown items of the PageContents element (the page's own part)
    • part: Option<Sym> -- the name of the page's part as read (None: a new page)

impl Page

  • fn new(header: PageHeader) -> Page an empty page with this header

  • struct MasterHeader the attributes of a master (and of its PageSheet element)

    • id: u32 -- ID: unique among the masters of the document
    • name: Option<Sym> -- Name: the language-dependent name
    • name_u: Option<Sym> -- NameU: the universal name; with BaseID the key for matching masters (LG-04, MS-02)
    • is_custom_name: Option<bool> -- IsCustomName as written
    • is_custom_name_u: Option<bool> -- IsCustomNameU as written
    • base_id: Option<Sym> -- BaseID: the GUID of the master's origin
    • unique_id: Option<Sym> -- UniqueID: the GUID of this master's version
    • sheet_styles: StyleRefs -- LineStyle, FillStyle, TextStyle of the PageSheet element
    • attrs: Vec<(Sym, Sym)> -- the other attributes of the Master element in file order (Prompt, Hidden, IconSize ...)
  • struct Master a master: a template shape with its own page

    • header: MasterHeader -- the attributes
    • sheet: Sheet -- the master page's ShapeSheet
    • icon: Option<Sym> -- the icon as written (base64 text of the Icon element)
    • shapes: ShapeTree -- the master's shapes; the first top-level shape is the master shape of instances
    • connects: Vec<Connect> -- glue records inside the master
    • extras: Extras -- unknown items of the Master element (in masters.xml)
    • contents_extras: Extras -- unknown items of the MasterContents element
    • part: Option<Sym> -- the name of the master's part as read

impl Master

  • fn new(header: MasterHeader) -> Master an empty master with this header; its new shapes get IDs from 5 on, as Visio's (a file's masters keep the IDs they have)

  • fn master_shape(&self) -> Option<u32> the slot of the shape instances inherit from (the first top-level shape)

  • struct StyleHeader the attributes of a style sheet

    • id: u32 -- ID: unique among the styles (0 is "No Style")
    • name: Option<Sym> -- Name: the language-dependent name
    • name_u: Option<Sym> -- NameU: the universal name
    • is_custom_name: Option<bool> -- IsCustomName as written
    • is_custom_name_u: Option<bool> -- IsCustomNameU as written
    • based_on: StyleRefs -- LineStyle, FillStyle, TextStyle: the styles this one is based on
    • attrs: Vec<(Sym, Sym)> -- the other attributes in file order
  • struct Style a style sheet (Formatvorlage)

    • header: StyleHeader -- the attributes
    • sheet: Sheet -- its cells
    • extras: Extras -- unknown items of the StyleSheet element

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