mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-28 11:47:21 -06:00
Print: Print, Print Preview and Print Setup take a print preset by name
file.print, print.preview and print.setup took print settings only as settings, so an agent had to read a preset with print.presets.list and copy its settings into the call. They now take preset, the name of [Default] or of a saved print preset in any case. The preset's settings are used instead of the document's, settings applies over them, and print.setup saves them with the document as one undo step. An unknown name is a parameter error that lists the presets. The app's file.print with params passes preset on to the engine. Docs: docs/mcp.md, docs/target-app-parity.md.
This commit is contained in:
@@ -1932,12 +1932,13 @@ proptest! {
|
||||
// ---------- print presets files ----------
|
||||
|
||||
/// Import print presets from `data`, then lay out (and print, when short) the rich document with
|
||||
/// each one imported.
|
||||
/// each one imported, by its settings and by its name.
|
||||
fn print_presets(what: &str, data: &str) -> Result<(), TestCaseError> {
|
||||
survive_library(what, "print.presets.import", data, |s, r| {
|
||||
let list = no_panic(s.execute("print.presets.list", &json!({}))).unwrap_or_default();
|
||||
for name in r["imported"].as_array().into_iter().flatten() {
|
||||
let Some(p) = list["presets"].as_array().into_iter().flatten().find(|p| &p["name"] == name) else { continue };
|
||||
let _ = no_panic(s.execute("print.preview", &json!({ "preset": name })));
|
||||
let settings = json!({ "settings": p["settings"] });
|
||||
let pages = no_panic(s.execute("print.preview", &settings)).ok().and_then(|v| v["pages"].as_u64());
|
||||
let _ = no_panic(s.execute("print.setup", &settings));
|
||||
|
||||
Reference in New Issue
Block a user