Repository navigation
Preserve VBA macros + Excel-style macros UX (issue #6) - #19
Conversation
Local clippy (1.96) flags pre-existing code that an older toolchain accepted; these lints fire on clean main and block `cargo xtask ci`. All rewrites are behavior-preserving: - core/date.rs, numfmt/render.rs, functions/math.rs, functions/stat.rs: `!x.is_finite() || x < a || x >= b` -> `!(a..b).contains(&x)` (Range::contains is false for NaN/inf, matching the existing is_finite guard). - functions/util.rs: `!(A && !B)` -> `!A || B`. - engine/cmd/file.rs: drop a dead `.filter(|| true)`. - ui-egui/grid.rs: `find(|| true)` was always the first table (use `.first()`); `wrap || Justify || (nl && wrap)` -> `wrap || Justify`. - ui-egui/formula_bar.rs: `tab || (enter && false)` -> `tab`. - engine/cmd/spelling.rs: split the wasm/non-wasm dictionary init so the non-wasm `mut` no longer warns under wasm check.
…book (storytold#6) Opening an .xlsm and saving it silently stripped xl/vbaProject.bin, turning a macro-enabled workbook into a macro-free one — data loss for anyone whose work depends on macros. GridCraft still does not run VBA, but it now carries the project through unchanged. - model: `Workbook.vba_project: Option<Vec<u8>>` (base64 in JSON via a new `b64::opt` helper). `None` = no macros. - xlsx read: capture the `vbaProject` relationship's bytes instead of warning and dropping them; warn that macros are kept but not executed. - xlsx write: when present, emit `xl/vbaProject.bin` byte-identical, add the `.../relationships/vbaProject` relationship, switch the main part to the macro-enabled content type (`...sheet.macroEnabled.main+xml`) and add the `application/vnd.ms-office.vbaProject` override. - engine: `view.macros` lists the preserved project alongside GridCraft's own scripts (`{"kind":"vba","executed":false}`), so callers can see it is there. - ROADMAP: scope now "preserve, don't execute" (was "out of scope"). Tests: round-trip byte-identical blob + correct content types/relationship; capture from a foreign-produced .xlsm; a macro-free workbook stays clean.
… file Builds a macro-enabled .xlsm with a fake xl/vbaProject.bin, runs it through `gridcraft-cli run`, and asserts the blob comes back byte-identical with the macro-enabled content type and vbaProject relationship intact — the open → edit → save path a user would exercise by hand.
…torytold#6) The engine now preserves a workbook's VBA project, but the UI had no surface for it and silently dropped every open-time warning. Give preserved macros an honest, Excel-shaped home without a false "Enable Content": - Info bar under the ribbon (Excel's message-bar slot) showing the warning a `file.open` result carries. A VBA project gets an amber bar reading "This workbook contains VBA macros. GridCraft keeps them intact when you save, but does not run them." with a "What this means" button; anything else becomes a blue informational bar. Dismissable; a clean open clears a stale notice. - Macros dialog (Automate ▸ Macros, Alt+F8): lists GridCraft's own scripts and the preserved VBA project (presence + size, not module names — the blob is opaque). Mirrors Excel's Developer ▸ Macros without claiming to run VBA. - Status-bar badge "Macros preserved (not executed)" whenever the workbook carries a VBA project. New panel `notice_bar` reuses theme tokens (notice_warn_*/notice_info_*), so it follows light/dark. Two new UI commands, `ui.notice` and `ui.notice.dismiss`, reach it from the control channel. Tests: info bar appears for a macro workbook and clears on dismiss; a non-VBA warning becomes an info bar; clean open clears the notice; the macros dialog lists the VBA entry; status bar renders with a VBA project; Alt+F8 opens the dialog. Snapshot-verified in light and dark.
|
Thank you — and good to see GridCraft never executes VBA here (opaque bytes, honest UX wording). Needed before merge: (1) saving as If you haven't already, please come join us on Discord: https://discord.gg/artcraft — happy to talk any of this through there. |
…sx never carries a VBA project); drop the shell round-trip script (review fix-up for storytold#19) The Rust round-trip test covers what scripts/check-vba-roundtrip.sh checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged — thank you for the contribution! (I merged main into your branch and made one behaviour change: macros are saved only into an .xlsm — saving under an .xlsx name writes the workbook without the VBA project, as Excel does, since Excel refuses an .xlsx with a macro-enabled main part. I also dropped scripts/check-vba-roundtrip.sh, since your Rust round-trip test covers it.) If you haven't already, come join us on the ArtCraft Discord: https://discord.gg/artcraft |
What
Opening a macro-enabled workbook (
.xlsm) and saving it silently strippedxl/vbaProject.bin, turning it into a macro-free file. For anyone whose work depends on macros, that is data loss — the same class of failure as a crash, which this project ranks above feature work.GridCraft still does not run VBA (its own recorded/editable scripts remain the automation path). It now carries the project through unchanged, so a macro-enabled workbook survives open → edit → save, and the UI tells the user so in an Excel-shaped surface rather than dropping the warning on the floor.
Changes
Engine — preserve, don't destroy
Workbook.vba_project: Option<Vec<u8>>(base64 in JSON via a newb64::opthelper).None= no macros.vbaProjectrelationship's bytes instead of warning and dropping them; warn that macros are kept but not executed.xl/vbaProject.binbyte-identical, add the.../relationships/vbaProjectrelationship, switch the main part to the macro-enabled content type (...sheet.macroEnabled.main+xml), and add theapplication/vnd.ms-office.vbaProjectoverride.view.macroslists the preserved project alongside GridCraft's own scripts ({"kind":"vba","executed":false}).UI — Excel-style surfaces, honest about what GridCraft does (the open-time warning used to be discarded)
ui.notice/ui.notice.dismiss.Tests
.xlsm(not our own writer).scripts/check-vba-roundtrip.sh.Notes
mainand blockcargo xtask ci; they are unrelated to VBA and split out so they can be reviewed/dropped independently. Repro:git stash+ clippy on pristinemain.vbaProject.bin; this PR shows presence + size only.Closes #6.