diagram_io/lib.rs
1// diagram_io -- Visio file formats (the VSDX family) and diagram exports
2//
3// Reads and writes the model of diagram_core (apps/JFDiagrammer, plan in its PLAN.md). The
4// format follows the public specification [MS-VSDX]; no code of other implementations is used.
5//
6// vsdx::read(&bytes, &vsdx::Limits::VSDX) -> Result<vsdx::Loaded, vsdx::Error>
7// a .vsdx, .vsdm, .vstx, .vstm, .vssx or .vssm file into a Document:
8// styles, the document sheet, colours and fonts, pages with shapes and
9// connects, masters, themes (raw), windows.xml, properties, media,
10// comments (kept as parts), data connections and recordsets (JD18:
11// doc.data, data.rs); unknown items in the Extras where they stood
12// (DF-03); nothing recomputed or rerouted
13// vsdx::write(&doc, &vsdx::WriteOptions::DEFAULT) -> Result<Vec<u8>, vsdx::WriteError>
14// the model as a file of any of the six formats, with everything it does
15// not know where it stood; deterministic, DEFLATE; a file read and written
16// unchanged reads back as the same model
17// vsdx::new_document(kind, Measure::Metric) a new drawing, template or stencil with JFLib's
18// own styles, document sheet and DrawingML theme "NetLab"
19// vsdx::Format the six formats by main content type or extension
20// stencil::build(&files, Measure::Metric) -> Result<stencil::Built, stencil::SourceError>
21// (JD9) the text sources of a stencil (stencil.txt, *.master, SVG
22// drawings; apps/JFDiagrammer/stencils/README.md) into a stencil:
23// masters in five languages, formulas computed, icons rendered from the
24// shapes, name-based GUIDs; stencil::build_vssx gives the .vssx bytes too
25// template::build(&files, Measure::Metric, &stencils) -> Result<Vec<BuiltTemplate>, SourceError>
26// (JD13) the text sources of a template (template.txt, *.starter,
27// rules.txt; apps/JFDiagrammer/templates/README.md) into its forms: the
28// blank template and one per starter diagram, with stencil windows, rule
29// set and the catalogue's cells; template::stencil_windows,
30// set_stencil_windows, info, registers and to_drawing for the app
31//
32// vdx::read(&bytes, DocKind::Drawing, &vsdx::Limits::VSDX) -> Result<vsdx::Loaded, vsdx::Error>
33// (JD16) the XML formats of Visio 2003-2010 (.vdx drawing, .vsx stencil,
34// .vtx template) into the same model: cells with formula and value,
35// sections, masters, pages, pictures as parts, fonts by name, document
36// properties, windows, the macro project; vdx::kind_of, vdx::sniff
37// props::read(&doc) / props::write(&mut doc, &props)
38// (JD16) the document properties (docProps core, app and custom)
39// windows::drawing_window(&doc) / set_drawing_window(&mut doc, &w)
40// (JD16) the drawing window of windows.xml: page, zoom, centre, what is
41// shown; vsdx::remove_macros takes a macro project out
42// data::ado(&recordset) -> String
43// (JD18) a recordset's rows as an ADO persisted recordset (the recordset
44// parts of a .vsdx; Visio's DataAsXML format)
45// report::parse(xml) / report::to_xml(&def) / report::stored(&doc), add, replace, rename,
46// remove (JD19, DA-09) shape report definitions (diagram_core::report's
47// model) as Visio's VisioReportDefinition XML (.vrd files the same) and
48// as the document sheet's User rows visPropRptN, as transactions
49// textdraw::parse(text, &opts, &limits) / textdraw::apply(tx, eng, page, &plan, &masters, &b)
50// (JD18, IM-08) a connected drawing from a text file: Shape and Link
51// records (Visio's text import) into a plan with problems per line, then
52// shapes, shape data and glued dynamic connectors, laid out in layers
53//
54// vss::read(&bytes, DocKind::Stencil, &vsdx::Limits::VSDX) -> Result<vsdx::Loaded, vsdx::Error>
55// (JD17) the binary formats of Visio 2003-2010 (.vss; .vsd, .vst as far
56// as their masters and styles go), import only: the compound file
57// (archive::cfb), the VisioDocument stream's compressed tree of streams and
58// chunks become the XML of 2003-2010 and go through vdx::read; cells with
59// formula and value, formulas in Visio's text, texts with fields, styles,
60// masters; vss::to_vdx, vss::kind_of, vss::sniff
61//
62// The ZIP and OPC parts come from archive (archive::opc, JD1), shared with doc_io's DOCX.
63// Every file is untrusted input: sizes, counts and nesting are bounded, a file that breaks a
64// rule is an error and never a panic, external links are kept as data and never followed, and
65// nothing in a file is ever run (the macro project of a .vsdm is kept as bytes).
66#![no_std]
67#![forbid(unsafe_code)]
68
69extern crate alloc;
70
71mod blank;
72pub mod data;
73mod pack;
74pub mod props;
75// (JD19) shape report definitions: their XML, the document sheet's visPropRptN rows
76pub mod report;
77mod read;
78pub mod stencil;
79mod stencil_icon;
80mod stencil_src;
81mod stencil_svg;
82pub mod template;
83mod template_src;
84pub mod textdraw;
85pub mod vdx;
86pub mod vss;
87pub mod vsdx;
88pub mod windows;
89mod write;
90mod xml;
91
92// the test binary of the unit tests (template.rs, template_src.rs): plat's start of a std
93// program refers to the jfgui_main a program defines
94#[cfg(test)]
95rt::test_main!();
96
97#[cfg(test)]
98mod tests;