From 09a37a8f10a4c33a9407448dbdeb3661f61a5b59 Mon Sep 17 00:00:00 2001
From: prxnvt <53838599+prxnvt@users.noreply.github.com>
Date: Sat, 31 Oct 2026 12:59:59 -0400
Subject: [PATCH] Form controls: a kept button action comes back only on the
same button
The button actions xlsx has no place for (commands, fixed inputs,
output cells) are kept in a hidden name keyed by sheet and the
control's place on the sheet. When another application added, removed
or reordered controls before saving, opening the file gave the action
to whichever button now had that place, and could replace a macro the
file itself gave that button.
Each entry now also holds the button's name and anchor cell, and is
restored only on a button with that name and cell whose own action from
the file does not contradict it: a stored macro action only on a button
that still runs that macro, a stored command only on a button the file
gives no macro.
---
crates/engine/src/cmd/controls.rs | 29 ++++++++++++++----
crates/engine/src/tests/controls.rs | 46 +++++++++++++++++++++++++++++
2 files changed, 69 insertions(+), 6 deletions(-)
diff --git a/crates/engine/src/cmd/controls.rs b/crates/engine/src/cmd/controls.rs
index 4a9ade919..d2cf17f01 100644
--- a/crates/engine/src/cmd/controls.rs
+++ b/crates/engine/src/cmd/controls.rs
@@ -563,14 +563,15 @@ fn plain(a: &ControlAction) -> bool {
}
/// A copy of `wb` for xlsx with the button actions xlsx can't express (commands, fixed inputs,
-/// output cells) in a hidden name, keyed by sheet name and the control's place on the sheet.
-/// `None` when there is nothing to store.
+/// output cells) in a hidden name, keyed by sheet name and the control's place on the sheet, with
+/// the button's name and anchor cell to check it is still the same button when the file comes
+/// back. `None` when there is nothing to store.
pub(crate) fn with_action_names(wb: &Workbook) -> Result