JFLib

diagram_io#

Visio file formats (the VSDX family) and diagram exports -- crate root lib/diagram_io/src/lib.rs

diagram_io -- Visio file formats (the VSDX family) and diagram exports

Reads and writes the model of diagram_core (apps/JFDiagrammer, plan in its PLAN.md).  The
format follows the public specification [MS-VSDX]; no code of other implementations is used.

  vsdx::read(&bytes, &vsdx::Limits::VSDX) -> Result<vsdx::Loaded, vsdx::Error>
                      a .vsdx, .vsdm, .vstx, .vstm, .vssx or .vssm file into a Document:
                      styles, the document sheet, colours and fonts, pages with shapes and
                      connects, masters, themes (raw), windows.xml, properties, media,
                      comments (kept as parts), data connections and recordsets (JD18:
                      doc.data, data.rs); unknown items in the Extras where they stood
                      (DF-03); nothing recomputed or rerouted
  vsdx::write(&doc, &vsdx::WriteOptions::DEFAULT) -> Result<Vec<u8>, vsdx::WriteError>
                      the model as a file of any of the six formats, with everything it does
                      not know where it stood; deterministic, DEFLATE; a file read and written
                      unchanged reads back as the same model
  vsdx::new_document(kind, Measure::Metric)   a new drawing, template or stencil with JFLib's
                      own styles, document sheet and DrawingML theme "NetLab"
  vsdx::Format        the six formats by main content type or extension
  stencil::build(&files, Measure::Metric) -> Result<stencil::Built, stencil::SourceError>
                      (JD9) the text sources of a stencil (stencil.txt, *.master, SVG
                      drawings; apps/JFDiagrammer/stencils/README.md) into a stencil:
                      masters in five languages, formulas computed, icons rendered from the
                      shapes, name-based GUIDs; stencil::build_vssx gives the .vssx bytes too
  template::build(&files, Measure::Metric, &stencils) -> Result<Vec<BuiltTemplate>, SourceError>
                      (JD13) the text sources of a template (template.txt, *.starter,
                      rules.txt; apps/JFDiagrammer/templates/README.md) into its forms: the
                      blank template and one per starter diagram, with stencil windows, rule
                      set and the catalogue's cells; template::stencil_windows,
                      set_stencil_windows, info, registers and to_drawing for the app

  vdx::read(&bytes, DocKind::Drawing, &vsdx::Limits::VSDX) -> Result<vsdx::Loaded, vsdx::Error>
                      (JD16) the XML formats of Visio 2003-2010 (.vdx drawing, .vsx stencil,
                      .vtx template) into the same model: cells with formula and value,
                      sections, masters, pages, pictures as parts, fonts by name, document
                      properties, windows, the macro project; vdx::kind_of, vdx::sniff
  props::read(&doc) / props::write(&mut doc, &props)
                      (JD16) the document properties (docProps core, app and custom)
  windows::drawing_window(&doc) / set_drawing_window(&mut doc, &w)
                      (JD16) the drawing window of windows.xml: page, zoom, centre, what is
                      shown; vsdx::remove_macros takes a macro project out
  data::ado(&recordset) -> String
                      (JD18) a recordset's rows as an ADO persisted recordset (the recordset
                      parts of a .vsdx; Visio's DataAsXML format)
  report::parse(xml) / report::to_xml(&def) / report::stored(&doc), add, replace, rename,
                      remove   (JD19, DA-09) shape report definitions (diagram_core::report's
                      model) as Visio's VisioReportDefinition XML (.vrd files the same) and
                      as the document sheet's User rows visPropRptN, as transactions
  textdraw::parse(text, &opts, &limits) / textdraw::apply(tx, eng, page, &plan, &masters, &b)
                      (JD18, IM-08) a connected drawing from a text file: Shape and Link
                      records (Visio's text import) into a plan with problems per line, then
                      shapes, shape data and glued dynamic connectors, laid out in layers

  vss::read(&bytes, DocKind::Stencil, &vsdx::Limits::VSDX) -> Result<vsdx::Loaded, vsdx::Error>
                      (JD17) the binary formats of Visio 2003-2010 (.vss; .vsd, .vst as far
                      as their masters and styles go), import only: the compound file
                      (archive::cfb), the VisioDocument stream's compressed tree of streams and
                      chunks become the XML of 2003-2010 and go through vdx::read; cells with
                      formula and value, formulas in Visio's text, texts with fields, styles,
                      masters; vss::to_vdx, vss::kind_of, vss::sniff

The ZIP and OPC parts come from archive (archive::opc, JD1), shared with doc_io's DOCX.
Every file is untrusted input: sizes, counts and nesting are bounded, a file that breaks a
rule is an error and never a panic, external links are kept as data and never followed, and
nothing in a file is ever run (the macro project of a .vsdm is kept as bytes).

Sections

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