mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-08 20:01:37 +00:00
.ai save: the editing copy warns about missing placed files
A .ai saved with pdfCompatible false resolved placed files for the editing copy but dropped the warnings for the ones it couldn't find, so a missing placed file was written as its preview without a warning. The save now keeps those warnings.
This commit is contained in:
@@ -637,17 +637,21 @@ pub(super) fn encode_ai(cmd: &str, f: &Format, doc: &Document, p: &Value) -> Res
|
||||
}
|
||||
// The art with placed files resolved as the pages draw them, also when the pages are blank.
|
||||
let resolved;
|
||||
let art: &Document = if pdf_compatible {
|
||||
&pages
|
||||
let (art, mut resolved_warnings): (&Document, Vec<String>) = if pdf_compatible {
|
||||
(&pages, Vec::new())
|
||||
} else {
|
||||
resolved = crate::cmd::place::document::full_documents(&edited).0;
|
||||
&resolved
|
||||
let (d, w) = crate::cmd::place::document::full_documents(&edited);
|
||||
resolved = d;
|
||||
(&resolved, w)
|
||||
};
|
||||
let o = vectorcraft_eps::AiEditingOptions {
|
||||
title: doc.title.clone(),
|
||||
created: doc.metadata.created.or_else(vectorcraft_doc::metadata::output_time),
|
||||
};
|
||||
vectorcraft_eps::ai_private_data(art, &o).map(Some).map_err(|e| bad(cmd, e))
|
||||
let (data, lost) = vectorcraft_eps::ai_private_data(art, &o).map_err(|e| bad(cmd, e))?;
|
||||
// Placed files that weren't found are written as their previews here too.
|
||||
resolved_warnings.extend(lost);
|
||||
Ok(Some((data, resolved_warnings)))
|
||||
};
|
||||
let (bytes, mut warnings) = super::pdf::encode_carrying(cmd, &pages, ¶ms, native, private)?;
|
||||
warnings.extend(placed_warnings);
|
||||
|
||||
@@ -288,6 +288,30 @@ fn ai_export_public_aliases_preserve_missing_placed_links() {
|
||||
}
|
||||
}
|
||||
|
||||
/// The `.ai` editing copy for other apps draws a missing placed file as its preview, with the
|
||||
/// pages or without them, and says so.
|
||||
#[test]
|
||||
fn ai_editing_copy_warns_about_missing_placed_files() {
|
||||
let dir = Folder::new("placed-ai-editing-copy-missing");
|
||||
let src = dir.file("logo.vectorcraft");
|
||||
star_source(&src, "placed-ai-editing-copy-missing-unique");
|
||||
let mut s = session();
|
||||
place(&mut s, &src);
|
||||
let parent = dir.file("parent.vectorcraft");
|
||||
save(&mut s, &parent);
|
||||
std::fs::remove_file(&src).unwrap();
|
||||
open(&mut s, &parent);
|
||||
let doc = &s.doc().unwrap().doc;
|
||||
let (_, missing) = cmd::place::document::full_documents(doc);
|
||||
assert!(!missing.is_empty());
|
||||
for compatible in [true, false] {
|
||||
let enc = cmd::fileio::encode_all(doc, "ai", &json!({"pdfCompatible": compatible})).unwrap();
|
||||
for w in &missing {
|
||||
assert!(enc.warnings.contains(w), "pdfCompatible {compatible}: {w:?} not in {:?}", enc.warnings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Include Linked Files must retain relinkable objects when only their previews are available.
|
||||
#[test]
|
||||
fn native_included_links_keep_missing_placed_documents_editable() {
|
||||
|
||||
Reference in New Issue
Block a user