mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-12 12:24:54 +00:00
EPS: Save As shows the saved artboard as the range when Use Artboards was on
A save that set useArtboards: true and named an artboard with artboard or artboards, without range, wrote that artboard, but file.formatOptions reported the default range. The Save As dialog then opened on All, and OK saved every artboard. file.formatOptions now reports those artboards as the range unless Use Artboards was saved off.
This commit is contained in:
@@ -1094,11 +1094,11 @@ fn format_options(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
}
|
||||
}
|
||||
// An EPS save that named artboards without Use Artboards had it on (the encoder reads them
|
||||
// so): it shows on, with those artboards as the range.
|
||||
// An EPS save that named artboards without Use Artboards, or with it on, had it on (the
|
||||
// encoder reads them so): it shows on, with those artboards as the range.
|
||||
if f.id == "eps"
|
||||
&& let Some(m) = &saved
|
||||
&& m.get("useArtboards").is_none_or(Value::is_null)
|
||||
&& m.get("useArtboards").and_then(Value::as_bool) != Some(false)
|
||||
{
|
||||
let range = m.get("range").and_then(Value::as_str).filter(|r| !r.trim().is_empty());
|
||||
let boards = m
|
||||
|
||||
@@ -510,6 +510,21 @@ fn eps_save_keeps_all_editing_artboards_in_the_file_of_one_page() {
|
||||
assert!(s.execute("document.save", &json!({"format": "eps", "options": {"selectedOnly": true}})).is_err(), "selected-only is Export's job");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eps_save_with_use_artboards_and_a_named_artboard_reports_it_as_the_range() {
|
||||
let d = dir("eps-named-artboard");
|
||||
let eps_path = path(&d, "Art.eps");
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 200, "height": 100, "artboards": 2})).unwrap();
|
||||
rect(&mut s);
|
||||
let options = json!({"useArtboards": true, "artboard": 1, "previewFormat": "none", "thumbnails": false});
|
||||
s.execute("document.save", &json!({"path": eps_path, "options": options})).unwrap();
|
||||
let o = s.execute("file.formatOptions", &json!({})).unwrap();
|
||||
assert_eq!(o["options"]["useArtboards"]["value"], true);
|
||||
assert_eq!(o["options"]["range"]["value"], "2", "the saved artboard, not All");
|
||||
std::fs::remove_dir_all(d).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eps_save_with_use_artboards_writes_the_central_file_and_one_per_artboard() {
|
||||
let d = dir("eps-artboards");
|
||||
|
||||
Reference in New Issue
Block a user