diagram_core/src/report.rs#
Source: lib/diagram_core/src/report.rs
report -- (JD19) shape reports (DA-09, DA-13, AS-05, EX-12): Visio's report definitions as a
model, run against a drawing into a table, put on a page as a table shape
ReportDef a definition as Visio's VisioReportDefinition describes it:
name, title, description, which shapes (Scope), the criteria
(Filter), the columns (Field: built-in fields, shape data,
user cells; display names and order; summaries), grouping
with subtotals, grand summary and duplicates (Grouping),
up to three sort keys (Sort), precision, units, case; what a
file had and the model does not know stays as data (attrs,
extra) for the writer
run(doc, &def, &Ctx) -> Table the result: title, columns, item rows, group headers,
subtotal rows, the grand total; every cell as text (in the
definition's precision, with units when it says so) and
typed (for CSV and XLSX)
place(tx, eng, owner, at, &table, &Place) -> ShapeRef the table shape: a group of cell
shapes (title, header, grid, group and summary rows) on its
own layer, marked with User.JFD_Report* (report/shape.rs)
report_shape(doc, shape) / refresh(tx, eng, shape, &table) / report_layer(..) find a table
shape (a cell of it too), build it anew in place (DA-13)
The XML (VisioReportDefinition, .vrd files) and the definitions kept in the document sheet
(User.visPropRptN, U="STR") are diagram_io::report: this crate holds no file format. The
codes below (Scope::code, Condition::code, Func::bit, Property::tag, Builtin::key) are the
numbers and names that XML carries.
Assumptions where no source says (Annahmen; the user's own Visio file will settle them):
* SelectDrawingDataMethod: 1 every page, 2 the current page (both seen), 3 the selected
shapes (not seen); another number reads as Scope::Other and runs over every page.
* Condition, checked in Visio 16 (a definition per code run through Visio's report add-on,
Auslastung against 60): 1 =, 2 <>, 3 >, 4 <, 5 >=, 6 <=, 8 exists; Visio's own definitions
(INVENTRY.VRD) write "exists" as 8 with Value 1 and PropertyDataType 3 (a Boolean), so "does
not exist" is written as 8 with Value 0 (diagram_io::report; 7 is read as it too, earlier
JFDiagrammer files wrote it, Visio gives no report for 7).
* AdvancedFilter: Visio's own definitions write 0; with 1 Visio leaves the criteria out (every
code gave every shape), so they count only without it (run.rs, as Visio).
* SummaryTypes is a bit mask, checked in Visio 16 (JD19's Visio check: a definition with each
bit alone run through Visio's report add-on): 1 count, 2 total, 4 average, 8 minimum,
16 maximum, 32 median (Func::bit); Visio's grand total row shows the total alone.
* Tag 1 a built-in field, 2 shape data, 3 a user cell (seen); Type and PropertyDataType are
the shape data types of diagram_core::data::kind (0 text, 2 number, 3 Boolean seen).
* ItemDisplay 1 shows the shapes' rows with the summaries, 0 only the summaries (one row per
group); GroupingField 0 groups nothing; a Boolean attribute is 1 or 0 (true / -1 read too).
* A shape data field is named by its row name (Prop.<Name>); a shape that has no row of that
name but one with that label counts too (Visio's dialog lists the fields by label).
* NAMEINFO is the shape's name as shown (Name), NAMEIDINFO its NameID ("Sheet.5"); lengths
(PINXINFO ...) in the unit of their cell, else the page's.
* Visio's output "Visio-Shape" is an embedded Excel object (NO-22: not here), an instance of
its hidden master "Report shape" that names the definition only in RUNADDONWARGS formulas
(EventDrop, the actions "Bericht aktualisieren" and "Bericht erstellen"; seen in JD19's
check). The table shape here is JFDiagrammer's own: User.JFD_Report = 1,
JFD_ReportName, JFD_ReportDef (a copy of the definition) or JFD_ReportLink (the
definition's name in the drawing or a .vrd path), on the layer the app names ("Bericht").
The columns are in DisplayOrder with the grouping field first, as Visio's report shows them.
Which shapes a report sees (run.rs): the top-level shapes of the pages of its scope (the
foreground pages for "every page") or the selected shapes; a group without master and without
shape data of its own stands for its members (a user's group of devices counts its devices),
every other shape counts as one -- an instance's subshapes never. Table shapes of reports
are left out. Summaries: Count counts the rows of the group, the others take the numbers.
enum Scopewhich shapes a report takes (SelectDrawingDataMethod)AllPages-- the shapes of every (foreground) page: 1Page-- the shapes of the current page: 2Selection-- the selected shapes: 3 (assumed)Other(u32)-- a number not known here (runs like AllPages, written back as read)
impl Scope
fn code(self) -> u32the code of SelectDrawingDataMethodfn of(code: u32) -> Scopethe scope of a codeenum Builtina built-in field (Tag 1): its name in the definitionText-- TEXTINFO: the shape's text as shown (fields included)Master-- MASTERINFO: the name of the shape's masterName-- NAMEINFO: the shape's nameNameId-- NAMEIDINFO: the shape's NameID ("Sheet.5")PinX-- PINXINFOPinY-- PINYINFOWidth-- WIDTHINFOHeight-- HEIGHTINFOOther(String)-- a name not known here (kept; it shows nothing)
/// the built-in fields in the order the wizard offers them
BUILTINS: [Builtin; 8] = [Builtin::Text, Builtin::Master, Builtin::Name, Builtin:: ...
impl Builtin
fn key(&self) -> &strthe name in the definition (TEXTINFO ...)fn of(key: &str) -> Builtinthe field of a namefn is_length(&self) -> boolwhether its values are lengthsenum Propertywhat a column or a criterion reads from a shapeBuiltin(Builtin)-- a built-in field (Tag / PropertyType 1)Data(String)-- a shape data field by its row name (Prop.<name>; Tag 2)User(String)-- a user cell by its row name (User.<name>; Tag 3)
impl Property
fn tag(&self) -> u32Tag / PropertyTypefn key(&self) -> &strthe name the definition writes (TEXTINFO, the row name)fn of(tag: u32, key: &str) -> Propertythe property of a tag and a name (an unknown tag reads as shape data)enum Funca summary function of a column (SummaryTypes, a bit each; Visio's bits, checked in Visio 16)Total-- the sum: bit 2Average-- the mean: bit 4Median-- the middle value: bit 32Count-- the number of rows: bit 1Min-- the smallest number: bit 8Max-- the largest number: bit 16
/// the functions in the order of the dialog (and of the summary rows)
FUNCS: [Func; 6] = [Func::Total, Func::Average, Func::Median, Func::Count, F ...
impl Func
fn bit(self) -> u32its bit in SummaryTypesfn of_mask(mask: u32) -> Vec<Func>the functions of a SummaryTypes mask, in orderstruct Fielda column of the report (VisioRptDefField)id: u32-- ID (groups and sort keys name it)property: Property-- what it shows (Tag with Name)display_name: String-- DisplayName: the column's heading ("" -- the property's name)display: bool-- Display: shown as a columnorder: u32-- DisplayOrder: the column's place (smaller first)data_type: u16-- Type: the data type (data::kind: 0 text, 2 number ...)summary: u32-- SummaryTypes (Func::bit)attrs: Vec<(String, String)>-- attributes not known here, kept
impl Field
fn new(id: u32, property: Property, display_name: &str) -> Fielda shown column of a property with a headingfn heading(&self) -> &strthe heading: DisplayName, else the property's nameenum Conditiona condition of a criterion (Condition; codes assumed, see the file head)Eq-- =Ne-- <>Gt-- >Ge-- >=Lt-- <Le-- <=Exists-- the shape has the propertyNotExists-- the shape does not have itOther(u32)-- a code not known here (the criterion holds for no shape)
/// the conditions with their codes (one table: the assumption lives here)
CONDITIONS: [(Condition, u32); 8] = [ (Condition::Eq, 1), (Condition::Ne, 2), (Condition::Gt, ...
impl Condition
fn code(self) -> u32the code of Conditionfn of(code: u32) -> Conditionthe condition of a codefn has_value(self) -> boolwhether it compares with a value (Exists and NotExists do not)struct Filtera criterion: which shapes the report takes (VisioRptDefFilter)id: u32-- IDproperty: Property-- the property compared (PropertyType with Property)condition: Condition-- Conditionvalue: String-- Value: what it compares withunit: String-- Unit: the value's unit code ("MM"; "" none)data_type: u16-- PropertyDataType (data::kind)and: bool-- AndOr: 1 and (Visio's criteria are all "and"), 0 or with the ones beforeattrs: Vec<(String, String)>-- attributes not known here, kept
impl Filter
fn new(id: u32, property: Property, condition: Condition, value: &str) -> Filtera criterion "property condition value"struct Groupinggrouping and the summaries of the whole (VisioRptDefGroup)id: u32-- IDfield: u32-- GroupingField: the ID of the field the rows are grouped by (0: none)show_items: bool-- ItemDisplay: the shapes' rows are shown (else only the summaries)grand_summary: bool-- GrandSummary: summaries over every row at the endexclude_duplicates: bool-- ExcludeDuplicates: a row the same as one before is left outattrs: Vec<(String, String)>-- attributes not known here, kept
struct Sorta sort key (VisioRptDefSort)id: u32-- IDfield: u32-- SortField: the field's IDascending: bool-- Ascendingcase_sensitive: bool-- CaseSensitiveattrs: Vec<(String, String)>-- attributes not known here, kept
impl Sort
fn new(id: u32, field: u32, ascending: bool) -> Sorta sort key on a fieldstruct ReportDefa report definition (VisioReportDefinition; a .vrd file holds the same)name: String-- Name: what the list of reports showstitle: String-- Title: the heading of the result ("" -- the name)description: String-- Descriptionscope: Scope-- SelectDrawingDataMethodprecision: u32-- Precision: decimals of numbersshow_units: bool-- ShowUnits: lengths, angles and durations with their unitcase_sensitive: bool-- CaseSensitive: criteria compare texts with caseuser_cells: bool-- UserCells: the wizard offers user cells (Visio's "Show all properties")hidden_properties: bool-- HiddenProperties: the wizard offers hidden shape dataadvanced_filter: bool-- AdvancedFilter: criteria were given (Visio's dialog Erweitert)filter_expression: String-- FilterExpression as read (written back unchanged)exists: bool-- ReportExistsversion: String-- Version ("3")fields: Vec<Field>-- the columns in file orderfilters: Vec<Filter>-- the criteriagrouping: Option<Grouping>-- grouping and summaries (None: the file has no group element)sorts: Vec<Sort>-- the sort keys, the first one firstattrs: Vec<(String, String)>-- root attributes not known here, keptextra: Vec<String>-- child elements not known here, as XML text, written back after the known ones
impl ReportDef
fn new(name: &str) -> ReportDefan empty definition namedname(every page, two decimals, units shown)fn field(&self, id: u32) -> Option<&Field>a field by IDfn columns(&self) -> Vec<&Field>the shown fields in their display order (DisplayOrder, then file order)fn heading(&self) -> &strthe title shown: Title, else Namefn next_field_id(&self) -> u32the next free field ID