Commit Graph
8520 Commits
Author SHA1 Message Date
kiwi4boy 1f5f1f0f51 craft-xlsx: a shared formula stops decoding copies once one is kept as its value
From gridcraft#3821's review (CodeRabbit, still open there): a shared formula's copies are
checked against the formula text allowance with the first cell's length, which a copy can
exceed. A copy that was decoded and printed, then kept as its value because it didn't fit, or
because it couldn't be decoded, charged nothing, so a file with many cells of one long shared
formula could repeat that work for each of them. The PR's case was GridCraft's 8,192-character
rejection, which isn't here; the allowance and decode failures are the same path.

After one such copy the group keeps every later copy as its value without decoding it, so a
group costs at most one wasted decode. A new test shows a later copy that would have fit kept
as its value; it fails without this commit.
2026-11-12 23:36:18 -05:00
kiwi4boy 734ade8cd9 craft-xlsx: read shared, array and dynamic-array formulas from .xlsb files (port of gridcraft#3821)
A cell whose tokens are only PtgExp (row) + PtgExtraCol (column) belongs to the shared or array
formula starting there; its first cell is followed by BrtShrFmla or BrtArrFmla.

- Shared formulas: each cell's copy is decoded from the shared tokens at its own cell, as
  [MS-XLSB] defines it (PtgRefN/PtgAreaN offsets, wrapping around the grid). Every cell of the
  group gets FormulaKind::Shared, its own text and the group's index (`si`, counted per sheet);
  the first also gets the group's range. Its first cell is the first that uses it, anywhere in
  its range. Copies are charged to the formula text allowance before they are decoded, so a long
  formula shared by a million cells stops costing once the allowance is spent.
- Ctrl+Shift+Enter and dynamic arrays: the first cell gets FormulaKind::Array with its range; a
  dynamic one also has its cell metadata (BrtCellMeta, which now also holds across a BrtValueMeta
  written in between), as `cm` marks it in .xlsx. The other cells of an array keep their cached
  values and have no formula, as in .xlsx.
- A record that can't be read leaves its range as values and never fails the file, with a
  warning; so does a first cell with no formula record after it.

Ported from storytold/gridcraft#3821 (issue gridcraft#3806), with its review fixes (each copy
decoded at its own cell; a shared formula may start inside its range). Changed from the
GridCraft PR:
- In .xlsx a shared formula's other cells have empty text. Here they have their own decoded text
  (and CellFormula's doc says so), because that is exact where shifting the first cell's text is
  not, as the PR's review found.
- Clearing an array's other cells for recalculation, marking dynamic arrays to spill, and the
  check against GridCraft's parser's 8,192-character limit are GridCraft's reading, not the
  file's: the cells keep what the file holds. That test becomes one that a copy may be longer
  than its first cell.
The PR's tests come along in tests/xlsb.rs, with craft-xlsx's model in the expectations.

Checked against Excel: in a workbook Excel saved both as .xlsb and as .xlsx, every formula this
reads (33, shared, array and dynamic ones included) has the .xlsx text, kind and range; the other
5 use tables, an external link or defined names.
2026-11-12 23:34:15 -05:00
kiwi4boy 787b3e44f4 craft-xlsx: read cell formulas from .xlsb files (port of gridcraft#3818)
A BIFF12 decoder for cell formulas (xlsb/formula.rs), separate from craft-xls's BIFF8 one because
nearly every operand differs (32-bit rows, 14-bit columns, UTF-16 strings, its own array-constant
codes, newer functions called through hidden names). It reads references, 3-D references,
constants, array constants, functions by number (xlsb/ftab.rs) and newer functions through
Excel's hidden _xlfn. names. A formula cell's CellFormula holds the text as an .xlsx file holds it
(`_xlfn.CONCAT`, `_xlpm.x`, no implicit `@`), and a BrtCellMeta before a cell gives it
cell_metadata, as `cm` does. Reverse-Polish tokens group by order alone, so the decoded tree
gets the parentheses its text needs from operator precedence; Excel's own text is unchanged. A
chain of string constants joined with & prints as one flat chain.

What a formula refers to must be readable too, so shared, array and data-table forms, user
defined names (XLSB names aren't read yet), table references, external links and PY(index, ...)
(code stored elsewhere in the package) keep only their saved results, with a warning saying why.
So does a formula past Limits::binary_formula_text (128 MiB of text over the workbook). The
workbook's links and names are optional: if they can't be read, the file opens with values only,
as before, and a warning says so.

Ported from storytold/gridcraft#3818 (issue gridcraft#3806), with its two review fixes
(grouping by precedence, the flat & chain). Changed from the GridCraft PR:
- The tree and its A1 printer (xlsb/expr.rs) are a copy of craft-xls's expr.rs, with
  BinOp::precedence added; the decoder's stack and depth guards are copies of craft-xls's. The
  PR used GridCraft's formula crate and shared these with GridCraft's .xls decoder.
- No fmla::from_file, implicit `@`, parse check or Python-cell adoption: those are GridCraft's
  reading of the text, not the file's. A single-cell dynamic-array formula is read (with its
  cell metadata) instead of being kept as its value; the PR left dynamic arrays to the next PR.
- The links are read with the workbook part and kept by Package for its sheets.
Its tests come along in tests/xlsb.rs, with the expected text in the file's spelling.

Checked against Excel: of the formulas in a workbook Excel saved both as .xlsb and as .xlsx,
every one this reads (26) has the text of the .xlsx; the other 12 are the kinds above.
2026-11-12 23:29:29 -05:00
aiongg 409e1c9d67 docs: porting guide 6.4 captures old and port through craft-automation; trial for the client sample; README client row 2026-11-13 04:28:22 +00:00
Dylan M. Taylor 7c10820123 Preserve ZIP directory semantics in bundle reader 2026-11-13 04:26:31 +00:00
aiongg 62e38dc39f docs: porting guide (docs/porting.md), linked from craft-framework.md and development.md 2026-11-13 04:25:52 +00:00
kiwi4boy 1bdaa7aff3 craft-xlsx: the XLSB function table, with the numbers 0x17C-0x1E4 (port of gridcraft#3810)
[MS-XLSB]'s Ftab (2.5.98.10) continues the [MS-XLS] table from 0x17C: the cube functions, the old
Analysis ToolPak functions, IFERROR, COUNTIFS, SUMIFS and AVERAGEIF(S). Excel writes these by
number in .xlsb (PtgFunc / PtgFuncVar) where .xls calls them by name, so an XLSB formula decoder
needs them. Generated from the spec with the same argument-count rule as the existing entries.

Ported from storytold/gridcraft#3810 (issue gridcraft#3806). There the entries were appended to
GridCraft's .xls table, which is now craft-xls's. Here the table is craft-xlsx's own
(xlsb/ftab.rs): craft-xls's 0-379, which match GridCraft's table before the PR, then the PR's
entries. The two formats follow separate specifications and develop separately; they can share a
table later if both readers settle on one. The PR's table checks come along. Its decoding checks
(IFERROR, SUMIFS by number) go with the decoder in the next commit, and its check that every new
name is a GridCraft function stays in GridCraft.
2026-11-12 23:23:02 -05:00
Dylan M. Taylor a2e0f58632 Bound shared SoundCraft session IO 2026-11-13 04:20:55 +00:00
Dylan M. Taylor 88aa0bed6a Add shared SoundCraft session format 2026-11-13 04:07:08 +00:00
kiwi4boy 4a5cb98651 craft-math: review fixes: a number base after a number, a cap on kept OMML, is_number without a Vec
From the second review round:

- A number base right after a digit, `.` or `,` keeps its brackets. Bare, it continued the number
  before it: `1` then `23^4` was written `123^4` and read back with 123 as the base, and the same
  for a one-digit base (`12^4`), `x.` then `5^2` and `1,` then `5^2`. This came with the bare
  number base, before the first review round. A number base after a letter or an operator stays
  bare (`a2^4`, `1+2^4`).
- Both parses of kept OMML are capped at the elements the reader keeps (MAX_ELEMENTS × 2) instead
  of craft-xml's defaults, and roxmltree gets the same cap as `nodes_limit`. Kept OMML can come
  from a hostile JSON document; larger kept OMML is written from its nodes. The reader can't keep
  more than this, so OMML read from a file is unaffected.
- is_number scans bytes instead of collecting a Vec<char>: everything a number holds is ASCII.

The two new tests fail without their fix.
2026-11-12 22:51:39 -05:00
Dylan M. Taylor 4c25109473 test(openpgp): align signature time with generated key 2026-11-13 03:47:36 +00:00
Dylan M. Taylor f29cb7076f Merge remote-tracking branch 'origin/main' into codex/craft-time-soundcraft
# Conflicts:
#	Cargo.lock
#	Cargo.toml
#	README.md
2026-11-13 03:46:49 +00:00
Dylan M. Taylor ae0f0488dc craft-time: preserve SoundCraft time API and serialization 2026-11-13 03:44:51 +00:00
kiwi4boy ae00359d2b craft-math: review fixes: number bases, a comma after a script, whitespace in kept OMML
From the review of this series:

- A base that is one number by the parser's rule (1,000 as well as 2.5 and .5) is written bare,
  1,000^2 rather than 〖1,000〗^2. lin_base tested numbers with digits and points only, so a
  comma made it a multi-letter base. The rule is now is_number, the parser's number_len over the
  whole text; simple_operand, which fractions share, is unchanged.
- A bare script followed by a comma and a digit is ended with a space: x^2 then ,3 was written
  x^2,3, and the number script read the ,3 back into the exponent. Only a comma before a digit
  gets one; x^2, y is written as before.
- Kept OMML whose element name is followed by a tab, carriage return or line feed (all XML
  whitespace) is written back like one followed by a space, instead of from the nodes.

Each new test fails without its fix.
2026-11-12 22:36:13 -05:00
aiongg 0109b9b8bf craft-automation: trials for the screenshot queue's budgets, settling, deadlines, cancellation, document generation and image checks 2026-11-13 03:20:08 +00:00
aiongg 738d034b69 craft-automation: names_open_dialog tells an app which ui.dialog requests are its DialogHost's 2026-11-13 03:20:08 +00:00
aiongg d4c4f57d96 craft-automation: a finished job sends the app's reply, so an error can carry partial results 2026-11-13 03:20:08 +00:00
Dylan M. Taylor 7316e4e223 fix: clear workspace baseline gates on Rust 1.100 2026-11-13 03:13:53 +00:00
kiwi4boy fd4a95d261 craft-math: tests for the OMML writer and the linear format (port of wordcraft#6080)
The OMML writer (omml/write.rs) had no tests of its own, and the linear-format parser
(math_linear.rs) none in its own module.

- omml/write/tests.rs: every MNode variant and option, run properties, the three sources
  write_equation takes an equation from (kept OMML, nodes, linear text), the equation colour
  (#1467), display jc, resolve_numbers, m:mathPr and the matrix and depth caps (#4000) are written
  and read back with read_omath. What the reader gives back differently on purpose (merged runs,
  half-point sizes, matrix column alignments, an empty delimiter...) is stated as such. Element
  order, which a round trip can't see, is pinned by exact XML: each structure with its defaults
  and with every property on, a run, m:oMathPara and m:mathPr. The strings follow the ECMA-376
  shared-math sequences.
- math_linear/tests.rs: one case per construct of the module doc, the helpers (closer,
  is_combining, strip_parens), to_linear round trips and truncated input. Where Word builds the
  same text, the expected tree is Word's.

Tests only; no behaviour change.

Ported from storytold/wordcraft#6080 (issue wordcraft#6079), on top of the other ports in this
series, which they pass with unchanged. The writer tests move from WordCraft's
docx/src/write/math/tests.rs to omml/write/tests.rs, with craft-math's paths for what they used
from WordCraft (read_omath, para_jc and read_math_pr from omml, each_run_mut from math_tree,
map_args from math_linear), and OMML read back with omml::parse instead of WordCraft's
xml::parse_strict over namespace-wrapped text.
2026-11-12 22:11:18 -05:00
kiwi4boy 28bd7be180 craft-math, craft-docx: keep an equation's kept OMML only when it is one well-formed m:oMath (port of wordcraft#6081)
write_equation writes Math::omml verbatim into the host document once a check passes, and documents
saved as JSON carry that field, so a JSON → .docx conversion could write a document.xml that isn't
well-formed, or any WordprocessingML verbatim. craft-math's check was a strict craft-xml read of
text starting with <m:oMath, which already refuses unclosed and mismatched tags, unknown entities
and trailing markup, but let through: an m:oMathPara (nested in a second one), an m: bound to
another namespace, names that aren't XML names, undeclared prefixes, two attributes with one
expanded name, a < in an attribute value, ]]> in text, and characters XML 1.0 doesn't allow.

The kept XML is now written only when it starts with <m:oMath> (not m:oMathPara), passes the strict
read (which also bounds the nesting), and then parses with roxmltree, a conforming parser, as
exactly one element that is m:oMath by namespace. The canonical prefixes of kept OMML (m:, w:, mc:)
are declared for that parse, as craft-math already documents them and the .docx root declares
them; any other prefix is undeclared there. Otherwise the equation is written from its nodes.

In craft-docx, Flat OPC's one_element (the gate for inlining kept bytes as pkg:xmlData) now also
requires XML names and attribute values that unescape, as in the WordCraft PR.

Ported from storytold/wordcraft#6081 (issue wordcraft#6072). The check differs from the PR's in
where it lives: the PR combined flat::one_element, parse_strict and roxmltree in the DOCX writer,
over the OMML wrapped in every namespace document.xml declares. Here the writer is in craft-math,
which doesn't know the host's namespaces, so it declares the three canonical ones. Its tests go
into craft-docx's integration tests (tests/it/kept_omml_check.rs), with only the crate names
changed; all 22 malformed cases fail without this commit except the 11 craft-math already refused.
roxmltree 0.21 is already in the lock as a dependency of other crates.

Checked on the 72 .docx files with equations from earlier Word probes (488 equations with kept
OMML, 35 files saved by Word): the same equations are written back verbatim as before, except one
empty <m:oMath/> in a hand-made repro file, which is now written from its (empty) nodes.
2026-11-12 22:09:54 -05:00
Dylan M. Taylor 94e65a4606 ci: run workspace checks with shared gate and test inputs 2026-11-13 03:06:38 +00:00
kiwi4boy a5a8829a14 craft-math: no m:sty or m:scr on normal text in an equation (port of wordcraft#6082)
CT_RPR holds m:nor or m:scr/m:sty, not both, and Word keeps only the m:nor of such a run, so bold
normal text lost its bold there. Normal text now writes neither; its bold and italic go in w:rPr
(w:b/w:i), which the reader already reads back for normal text.

Ported from storytold/wordcraft#6082 (issue wordcraft#6073). The writer change moves from
WordCraft's docx/src/write/math.rs to omml/write.rs, where the OMML writer now lives. Its test
saves and reopens a .docx, so it goes into craft-docx's integration tests
(tests/it/math_normal_text.rs) with only the crate names changed.
2026-11-12 22:02:35 -05:00
kiwi4boy 21f838c14e craft-math: a number is one item in the linear format (port of wordcraft#6236)
The parser pushed digits one character at a time, so a script took only the last digit as its
base: 10^3 built 1 followed by 0³, where Word builds 10³. A number is now read as one atom, by the
rule Word follows: digits, with a . or , continuing it only when a digit follows (2.5, 3.14, 1,000)
and a leading . before a digit starting one (.5); a trailing point (2.) isn't part of it, and
letters and signs are separate items. A script or a fraction operand takes the whole number (10^3,
2.5/3). A number script follows the same rule (x^.5, x_1,000; x^2. keeps the point out), keeping
letters after the digits (#1609).

Ported from storytold/wordcraft#6236 (issue wordcraft#6229): its change to math_linear.rs and its
tests/number_bases.rs, with only paths and crate names changed. Its typing test (engine) and the
docs/typing-parity.md note stay in WordCraft.
2026-11-12 22:01:24 -05:00
kiwi4boy cc63fb5074 craft-math: a multi-letter script base survives linear text (port of wordcraft#6230)
The parser attaches a script to the last character before it (mc^2 is m, c²), so a base of
several letters from a Word or LibreOffice file, written bare, read back split. lin_base now writes
such a base in invisible brackets, 〖mc〗^2, as Word linearizes it; a number (10^3, as Word writes
it) and an upright function name stay bare.

Ported from storytold/wordcraft#6230 (issue wordcraft#6228), which is stacked on wordcraft#6084:
its own change to math.rs and its tests/linear_multichar_base.rs. The ODT test that pinned
LibreOffice's E=mc^2 (<msup><mi>mc</mi>…) moves with it: in craft-odf it now expects E=〖mc〗^2,
as in the WordCraft PR. It runs only with craft-odf's `text` feature.
2026-11-12 21:59:46 -05:00
kiwi4boy 8d2481a748 craft-math: an empty shown n-ary limit survives linear text (port of wordcraft#6085)
to_linear wrote a limit only when it wasn't empty, so half-typed ∑_ (an empty, shown lower limit)
came out as ∑▒() and read back with both limits hidden. A shown limit is now written even when
empty, as _() or ^().

Ported from storytold/wordcraft#6085 (issue wordcraft#6076): its change to math.rs and its
tests/linear_empty_limits.rs, with only paths and crate names changed.
2026-11-12 21:53:35 -05:00
kiwi4boy 10f2625365 craft-math: a script on a script prints back the same in linear text (port of wordcraft#6084)
to_linear wrote a script base that isn't simple in parentheses, so sSup(sSup(a, b), c) came out
as (a^b)^c and read back with a visible delimiter. It now writes 〖a^b〗^c, as Word does, and the
parser takes a lone 〖…〗 group as the base itself, as Word builds 〖a+b〗^2, instead of an invisible
delimiter. simple_operand is split out of lin_operand so both use one rule.

From the PR's review: an invisible delimiter that is itself a script base gets an outer pair
(〖〖a〗〗^2); a one-character operator base is written 〖⊗〗_i, since a script after an operator reads
as a pre-script; and only a base just closed by 〗 (after_group) is unwrapped, so an explicit ├a┤^2
keeps its delimiter.

Ported from storytold/wordcraft#6084 (issue wordcraft#6075): its changes to math.rs and
math_linear.rs and its tests/linear_script_base.rs. In the function-name branch of the parser,
where #6083 (stacked scripts) and this PR both change the `attach_script` calls, the stacked-script
chain is kept and the calls pass this PR's new `group` argument (`false`).
2026-11-12 21:53:35 -05:00
kiwi4boy ef0f27a306 craft-math: stacked scripts in the linear format nest to the right (port of wordcraft#6083)
a^b^c built (a^b)^c; Word builds a^(b^c), and the same for a_b_c and x^2^3. After a script
operand, the same script operator now nests inside it. The chain stops at WRAP_DEPTH like every
other wrap, so the #1456 guard holds. a_b^c, a^b_c and (a^b)^c are unchanged.

From the PR's review: sin^2^3 on the function-name path nests to the right too (script_chain for
the first script; a second script joins only when it is the other operator, log_2^3). A level that
would make the whole tree too deep keeps its operator as text, as expr does at its own cap, and a
^ or _ the chain left at its cap isn't taken as the start of a function's operand.

Ported from storytold/wordcraft#6083 (issue wordcraft#6074): its change to math_linear.rs and its
tests/stacked_scripts.rs, with only paths and crate names changed. Its typing test (engine) and
the docs/typing-parity.md note stay in WordCraft.
2026-11-12 21:53:35 -05:00
Nicolas Bohn 5056c13ef7 fix(dxf): split binary hex payloads into chunks of at most 127 bytes (#1147) (#1148) 2026-11-12 21:49:37 -05:00
aiongg d9566067a7 List rows: a row in_label_column keeps its label in the label column and leaves the empty toggle columns before it empty; Brush Tip Shape lines up with the section names 2026-11-13 02:48:04 +00:00
aiongg f780c31085 List rows: in a list of toggle columns only, the label band takes the room past the last column, so the label shows whole as measure counts it 2026-11-13 02:48:04 +00:00
Dylan M. Taylor 1b53814a38 Apply verified workspace format fixes 2026-11-13 02:37:09 +00:00
Dylan M. Taylor 7a639e04a7 Fix workspace clippy loop in LaTeX tests 2026-11-13 02:35:01 +00:00
aiongg f80288f2a0 RasterDisplay: the checkerboard and edge of a mapped display lie on its area, for painted pictures too
mapped/placed say where a picture lies in document space for a source and a
painted display alike. A size-changing preview the app paints (a rotation
centred off the document's origin) gets its checkerboard and edge under the
preview, not at 0..size. Trial with offset areas; story RasterDisplay rotated.
2026-11-13 02:34:07 +00:00
Dylan M. Taylor d31b04810b Fix current workspace clippy diagnostics 2026-11-13 02:28:06 +00:00
aiongg 0381885d67 Layer Style: the effect list has a name column, so a name shows whole and the list takes its widest name's width 2026-11-13 02:26:58 +00:00
aiongg 1e5782dfd4 Dialogs: StackDialog::story_facts; hosted forms keep their last pass's facts and hosted stories report them 2026-11-13 02:26:58 +00:00
aiongg af8855c139 Dialogs: FormDialog::preview takes an optional owner, every owner-less open starts with Preview on; Guide Layout's Preview box is FormDialog's; the story host is a story note 2026-11-13 02:26:58 +00:00
aiongg 7f34140aa6 Dialogs: FormDialog::preview is the one Preview box; hosted stories reopen their dialog when a knob changes
FormDialog::preview(Bind<bool>) adds the Preview check box under the side buttons, with one
word (formDialog.preview) and hold-to-compare in FormOutput::comparing. ParamDialog,
HostedAdjustDialog and HostedLayerStyle use it; their own boxes and the paramDialog.preview,
adjust.preview and layerStyle.preview words are gone.

The hosted story helpers take the knob values the dialog is built from and replace the open
dialog when they change. The Export As story asks for a preview only while preview_ready is on.
2026-11-13 02:26:58 +00:00
aiongg be927e9393 Dialogs: hosted forms for Canvas Size, About, format options, Export As, Alert, Layer Style and the adjustment dialogs
Each opens on a DialogHost as a StackDialog that owns what its dialog edits
and binds the dialog's open state to its own field, so it opens again after
closing. HostedCanvasSize and HostedImageSize share SizingOutput::hosted.
HostedExportAs keeps its preview and save requests for the app as
HostedSaveForWeb does; HostedAbout keeps the activated link. HostedAlert
holds an Alert's content. HostedLayerStyle frames the Layer Style body in a
form dialog with side buttons and the Preview box, and queues the page's asks
as LayerStyleAsk. HostedAdjustDialog<V, E> frames any adjustment editor the
same way, resizable and remembered for Curves, with the editor's asks as E.

Stories open the hosted dialogs through a story host bound to the card's
open value (dialog::stories::hosted), so the card holds them behind its
button and story-render shows them open. Trials open each on a DialogHost
and check Escape, OK and the asks.
2026-11-13 02:26:58 +00:00
aiongg c2d351eb83 RasterSource::read: out holds premultiplied sRGBA, as ColorImage does 2026-11-13 02:24:03 +00:00
Dylan M. Taylor c7fb7544c2 craft-stencilcraft-format: add native JSON schema 2026-11-13 02:23:04 +00:00
Dylan M. Taylor 6ef2334920 plotter: expect registration offset command 2026-11-13 02:05:17 +00:00
Dylan M. Taylor d316f0fc2d fix(xml): walk deep KRA and ORA trees iteratively 2026-11-13 02:05:09 +00:00
aiongg f5dafff290 BrushSectionEvent: constructors for hosts and their tests 2026-11-13 02:01:17 +00:00
aiongg 1a128b726a Brush Settings stories: switch rows carry a lock 2026-11-13 02:01:17 +00:00
aiongg f824a7c6c0 BrushSectionList: a switch row carries its lock like a pane row 2026-11-13 02:01:17 +00:00
aiongg ce8b988404 RasterDisplay: checkerboard under the run of copies and the document only 2026-11-13 01:44:11 +00:00
aiongg e918fb84e4 RasterDisplay stories tiled and beyond 2026-11-13 01:44:11 +00:00
aiongg dbd8ec10c6 RasterDisplay extent: tiled copies and a region past the document, for source and painted pictures 2026-11-13 01:44:11 +00:00
Dylan M. Taylor 2253894e2f fix: satisfy Rust 1.100 workspace clippy 2026-11-13 01:39:26 +00:00