diagram_core/src/field.rs#
Source: lib/diagram_core/src/field.rs
field -- text fields (TX-06): a <fld IX='n'/> mark in a shape's text shows Field row n of the
shape, the value of its Value cell in the format picture of its Format cell
Env what fields show that the file does not hold (Document::fields,
set by the app): the decimal sign and the digit groups, month and
day names, the date picture of the general format, the clock
(NOW), when the drawing was made, saved and edited (when the
document's properties do not say), the file's path (DIRECTORY,
FILENAME), the zone's offset (the properties' times are UTC)
Shown / format(&v, picture, &env) -> String a value in a picture of Visio's FORMAT
shown(doc, sheet, ix) -> String the text Field row ix of a sheet shows
cached(xml) -> Option<String> the text a field kept as XML (Visio's own
<fld IX='n'>text</fld>) has cached
Seg / segments(doc, shape) the shape's text as runs of characters and fields,
each field with the text it shows (editing in
place, Find and Replace)
plain(doc, shape) -> String the text as it shows, fields included
marked("Länge: {fld 0}") -> Text / marks(&text) (JD15) a text written with field marks as
characters and fields (the stencil build tool's
master texts, the instance of such a master) / the
Field rows a text names
Kind / Spec / insert(tx, eng, shape, at, &spec) -> ix a new field: its Field row (Value
formula, Format, Type) and its mark in the text,
computed at once
Props / props(doc) the document's properties (docProps/core.xml and
app.xml): title, creator, keywords, dates ...
ole_days(y, m, d, h, min, s) / civil(days) dates as Visio keeps them: days since 30 December
1899, the time of day as the fraction
The Field section (Visio's Text Fields section, [MS-VSDX] Field_Type): Value holds the
formula (Width, PAGENAME(), NOW(), Prop.Cost, a formula of the user's) and its result in the
unit the field shows (U="MM" for a length in millimetres, U="DATE" for a date, U="STR" for a
text); Format holds the format picture as a string. Type: 0 text, 2 number, 5 date or time,
6 duration, 7 currency (Annahme: the numbering of the shape data's Type cell, which the Text
Fields section shares as far as known here). The cells UICat, UICod and UIFmt, which only
Visio's own dialog reads, are not written; Visio's dialog then opens a field of ours as a
custom formula (Annahme). A field the file wrote with its text inside
(<fld IX='0'>19.11.2026</fld>, Visio's way) stays as the reader kept it (TextItem::Other) and
shows that text (JD4); a field without text inside (ours, TextItem::Field) shows its value,
which the formula engine computes when what it reads changes.
Format pictures (Visio's FORMAT; Annahmen as far as Visio's own documentation was not at hand):
numbers 0 a digit or 0, # a digit or nothing, . the decimal sign, , groups of three in the
integer part, % times 100, u / U the unit's abbreviation (uu / UU the same), "..."
and \c literal text, anything else literal; "a;b;c": a for positive, b for
negative (without its sign), c for zero; a length, angle or duration shows in the
unit of its cell (25.4 mm for an inch in a cell with U="MM")
dates {{ ... }} around date and time parts: d dd day, ddd dddd its name, M MM month,
MMM MMMM its name, yy yyyy year, H HH hours (24), h hh hours (12), m mm minutes,
s ss seconds, t tt AM / PM; '...' literal inside, text outside the braces literal
texts @ the text, @+ in capitals, @- in small letters
empty the general format: a number with up to four decimals (a length with its unit),
a date in Env::date, a text as it is
struct Envwhat fields show that the file does not hold (see the file header)decimal: char-- the decimal sign ('.' in English, ',' in German)group: char-- the sign between groups of three digitsmonths: [&'static str; 12]-- January .. Decemberdays: [&'static str; 7]-- Sunday .. Saturdayam_pm: [&'static str; 2]-- the marks of the morning and the afternoon (t, tt)date: &'static str-- the date picture of the general format (without the braces): "M/d/yyyy", "dd.MM.yyyy"now: f64-- now in local time (days since 30 Dec 1899; NaN: unknown, NOW() keeps its stored value)created: f64-- when the drawing was made (local time; NaN: unknown) when its properties do not saysaved: f64-- when it was saved last (the same)edited: f64-- when it was edited last (NaN: when it was saved)path: String-- the file's path ("": not saved yet)utc_offset: f64-- local time minus UTC, in days (the properties' times are UTC)
/// English month names
MONTHS_EN: [&str; 12] = ["January", "February", "March", "April", "May", "June", ...
/// English day names, Sunday first
DAYS_EN: [&str; 7] = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", ...
enum Shown<'a>a value to showNum(f64, Option<Unit>)-- a number in internal units and the unit of its cellText(&'a str)-- a textNothing-- nothing (no value)
fn format(v: &Shown, picture: &str, env: &Env) -> Stringa value in a format picture (see the file header)fn unit_abbr(u: Unit) -> &'static strthe abbreviation a picture's u shows for a unitfn ole_days(year: i64, month: u32, day: u32, hour: u32, min: u32, sec: u32) -> f64the days since 30 December 1899 of a date and time (Visio's date values)fn civil(days: f64) -> (i64, u32, u32, u32, u32, u32, u32)a date value as (year, month, day, hour, minute, second, weekday with Sunday 0)fn shown(doc: &Document, sheet: SheetRef, ix: u32) -> Stringthe text Field row ix of a sheet shows: its value in its format ("" for an error)fn picture(doc: &Document, sheet: SheetRef, ix: u32) -> &strthe format picture of Field row ix ("" for none)fn cached(xml: &str) -> Option<String>the text inside a <fld ...>text</fld> element (a field as Visio writes it, kept as XML)enum Sega run of a shape's textText(String)-- characters (the marks between them left out)Field { item: usize, text: String, }-- a field: its item in Text::items and the text it shows
impl Seg
fn text(&self) -> &strthe text the run showsfn segments_of(doc: &Document, sheet: SheetRef, text: &Text) -> Vec<Seg>the runs of a text (sheet: the shape's, for the values of its fields)fn segments(doc: &Document, shape: ShapeRef) -> Vec<Seg>the runs of a shape's text (its master's when it has none of its own)fn plain(doc: &Document, shape: ShapeRef) -> Stringthe text of a shape as it shows, fields includedenum Kindwhat a field holds (its Type cell)Text-- a text (Type 0)Number-- a number, also a length or an angle (Type 2)Date-- a date or a time (Type 5)Duration-- a duration (Type 6)Currency-- an amount of money (Type 7)
impl Kind
fn code(self) -> f64the Type cell's valuestruct Spec<'a>a new fieldformula: &'a str-- the Value cell's formula (Width, PAGENAME(), NOW(), Prop.Cost ...)format: &'a str-- the format picture ("" the general format)unit: Option<Unit>-- the unit the value shows in (MM, DEG, DATE ...; None: a plain number; a text: STR)kind: Kind-- what it holds
/// the mark of Field row N in a text written as source (MARK_OPEN N MARK_CLOSE: "{fld 0}"), as
/// the stencil build tool reads a master's text and the instance of such a master gets it (JD15)
MARK_OPEN: &str = "{fld "
/// the end of a field mark (MARK_OPEN)
MARK_CLOSE: char = '}'
fn marked(s: &str) -> Texta text written with field marks ("Länge: {fld 0}") as characters and fields: "{fld N}" with N a row index (decimal digits) is the mark of Field row N, everything else stays characters (also a "{" that starts no such mark)fn marks(text: &Text) -> Vec<u32>the Field rows a text's marks name (the IX of each TextItem::Field, in text order)fn insert_item(doc: &Document, sheet: SheetRef, text: &Text, at: Option<usize>, item: TextItem) -> Texta text withitemput in at a shown position (fields count with the text they show; a position inside a field goes behind it; None: at the end, in front of the last line break)fn insert(tx: &mut Transaction, eng: &mut Engine, shape: ShapeRef, at: Option<usize>, spec: &Spec) -> Result<u32, EditError>a new field in a shape's text at the shown positionat(None: at its end, on a line of its own when the text has words): a Field row with the formula, the format and the type, computed at once, and its mark in the text -> the row's IXstruct Propsthe document's properties (docProps/core.xml, docProps/app.xml); dates as days since 30 Dec 1899 in local time (Env::utc_offset), None when the part does not saytitle: Stringsubject: Stringcreator: Stringkeywords: Stringdescription: Stringcategory: Stringmanager: Stringcompany: Stringhyperlink_base: Stringcreated: Option<f64>modified: Option<f64>printed: Option<f64>
fn props(doc: &Document) -> Propsthe document's properties (see Props)