mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-04 04:52:54 -05:00
Import PDF: unlocking a file refreshes the box Crop To started on
A box set while the file was locked no longer leaves the old starting box, so a later pick of Crop Box is still named.
This commit is contained in:
1 parent
8f76825e7a
commit
fd6c41368b
2 files changed
+15
-3
No files matched your search
@@ -220,9 +220,12 @@ impl State {
|
||||
let opened = vectorcraft_pdf::open_pdf(&self.file.bytes, self.password().as_deref()).map_err(|e| e.to_string())?;
|
||||
self.locked = false;
|
||||
self.page_count = opened.page_count();
|
||||
if self.crop == self.start_crop && self.place.is_none() {
|
||||
self.crop = opening_crop(Some(&opened));
|
||||
self.start_crop = self.crop;
|
||||
if self.place.is_none() {
|
||||
let start_crop = opening_crop(Some(&opened));
|
||||
if self.crop == self.start_crop {
|
||||
self.crop = start_crop;
|
||||
}
|
||||
self.start_crop = start_crop;
|
||||
}
|
||||
Ok(self.page_count > 1 && !self.password_only)
|
||||
}
|
||||
|
||||
@@ -441,6 +441,15 @@ fn opening_a_pdf_with_editing_data_keeps_its_trim_boxes_unless_a_box_is_picked()
|
||||
confirm(&mut app).unwrap();
|
||||
assert_eq!((field(&app, "__locked"), field(&app, "cropTo")), (json!(false), json!("trim")), "unlocked");
|
||||
|
||||
let mut app = self::app();
|
||||
assert!(import_pdf::offer(&mut app, "locked.pdf", &trimmed(Some("pw")), None, None));
|
||||
set(&mut app, "cropTo", json!("media"));
|
||||
set(&mut app, "password", json!("pw"));
|
||||
confirm(&mut app).unwrap();
|
||||
set(&mut app, "cropTo", json!("crop"));
|
||||
confirm(&mut app).unwrap();
|
||||
assert_eq!(artboard_widths(&app), [100.0, 200.0]);
|
||||
|
||||
let mut app = self::app();
|
||||
assert!(import_pdf::offer(&mut app, "two.pdf", &trimmed(None), None, Some(&json!({}))));
|
||||
assert_eq!(field(&app, "cropTo"), "crop", "a place");
|
||||
|
||||
Reference in new issue
Block a user