Form controls: the object commands leave a locked control on a protected sheet alone

control.format and control.assign refused to change a locked control on
a protected sheet, but object.move, object.delete,
object.setAnchorMode, arrange.bringForward, arrange.sendBackward and
arrange.align changed it all the same. They now refuse it with the
same message; an unlocked control still moves, and other kinds of
objects are unchanged.
This commit is contained in:
prxnvt
2026-10-31 16:35:36 -04:00
parent 0fb3ea7a68
commit 14dee9155d
4 changed files with 50 additions and 1 deletions
+6
View File
@@ -36,6 +36,9 @@ pub(super) fn arrange(s: &mut Session, p: &Json, forward: bool) -> Result<Json>
let kind = str_param(p, "kind").unwrap_or("shape").to_string();
let extreme = bool_param(p, "toFront").or(bool_param(p, "toBack")).unwrap_or(false);
let si = s.doc()?.wb.active_sheet();
if let Some(k) = gridcraft_model::ObjKind::parse(&kind) {
crate::cmd::controls::check_objects_unlocked(s, si, k, &[id])?;
}
fn reorder<T>(v: &mut Vec<T>, i: usize, forward: bool, extreme: bool) {
if i >= v.len() {
return;
@@ -125,6 +128,9 @@ pub(super) fn align(s: &mut Session, p: &Json) -> Result<Json> {
p.get("ids").and_then(Json::as_array).map(|a| a.iter().filter_map(|v| v.as_u64().map(|x| x as u32)).collect()).unwrap_or_default();
let how = str_param(p, "align").unwrap_or("left").to_string();
let si = s.doc()?.wb.active_sheet();
if let Some(k) = gridcraft_model::ObjKind::parse(&kind) {
crate::cmd::controls::check_objects_unlocked(s, si, k, &ids)?;
}
edit(s, |cx| {
let sheet = cx.sheet_mut(si)?;
let geo: Vec<(u32, f64, f64, f32, f32)> = {