mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-15 14:52:26 +00:00
WordArt: refuse insertion on a protected sheet
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
dd5cd48b8f
commit
224d0e96d7
2 files changed
+17
No files matched your search
@@ -180,6 +180,9 @@ fn insert_word_art(s: &mut Session, p: &Json) -> Result<Json> {
|
||||
let style = style_param("insert.wordArt", p)?.unwrap_or(&STYLES[0]);
|
||||
let text = text_param("insert.wordArt", p)?.unwrap_or_else(|| DEFAULT_TEXT.to_string());
|
||||
let d = s.doc()?;
|
||||
if d.wb.active().is_some_and(|sh| sh.is_protected()) {
|
||||
return Err(EngineError::Other(PROTECTED.into()));
|
||||
}
|
||||
let id = d.wb.next_object_id();
|
||||
let at = cell_param(s, p, "at")?.unwrap_or(d.selection.active);
|
||||
let mut shape = Shape {
|
||||
|
||||
@@ -494,6 +494,20 @@ fn shape_text_edit_survives_xlsx_roundtrip() {
|
||||
assert_eq!(shape.text, text);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn word_art_insert_respects_sheet_protection() {
|
||||
let mut s = s();
|
||||
s.execute("review.protectSheet", json!({})).unwrap();
|
||||
let before = s.doc().unwrap().wb.clone();
|
||||
let undo_len = s.doc().unwrap().undo.len();
|
||||
assert!(s.execute("insert.wordArt", json!({})).is_err());
|
||||
assert!(std::sync::Arc::ptr_eq(&s.doc().unwrap().wb, &before));
|
||||
assert_eq!(s.doc().unwrap().undo.len(), undo_len);
|
||||
s.execute("review.unprotectSheet", json!({})).unwrap();
|
||||
s.execute("insert.wordArt", json!({})).unwrap();
|
||||
assert_eq!(s.doc().unwrap().wb.active().unwrap().shapes.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn word_art_inserts_with_defaults_and_undoes() {
|
||||
use gridcraft_model::ShapeKind;
|
||||
|
||||
Reference in new issue
Block a user