fix(pdfimport): reference geometry precision, file and page messages, picker automation

- The page transform is read as 16.16 fixed point held in single precision
  and each user-space coordinate as a single-precision value kept to six
  decimals, so imported coordinates match the reference to the last digit.
- Paths wholly outside the page (crop box) or the current clip are left out.
- The page's /UserUnit scales the import.
- Unreadable files (no trailer, empty, not a PDF) print the "This file
  cannot be opened." block; encrypted files are asked for again silently.
- Page prompt: digits only, "There is no N in <file>." past the last page;
  page list prompt keeps asking with "Please enter page number or *.".
- Automation: pdf_import_pick (the path the next PDF picker returns) and
  pdf_import_dialog (page / on_screen / scale / rotation / ok / cancel).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ramox81andClaude Opus 5.5 committed 2026-10-16 12:37:20 +03:00
1 parent 218150c76a
commit dae01bdb14
6 files changed
+199 -35

No files matched your search

+36
View File
@@ -109,6 +109,8 @@ pub(super) const NAMES: &[&str] = &[
"view_background",
"image_adjust",
"import_file_dialog",
"pdf_import_pick",
"pdf_import_dialog",
"dgn_import_dialog",
"refedit_dialog",
"pdf_shx_settings",
@@ -2164,6 +2166,40 @@ impl OpenCADStudio {
_ => return Err(bad()),
}
}
// The file the next PDF import picker returns, without showing
// it (value: the path).
"pdf_import_pick" => {
crate::sys::set_pdf_import_pick(string(req, "value")?.into());
return Ok(Task::none());
}
// The Import PDF window, one field per call: "page=<n>" (1-based),
// "on_screen=0|1" (insertion point asked after OK), "scale=<value>",
// "rotation=0|90|180|270", "ok" or "cancel".
"pdf_import_dialog" => {
use crate::ui::window::pdf_dialogs::{PdfDialogMsg as P, RotationChoice};
if self.active_modal != Some(crate::app::ModalKind::PdfImportFile) {
return Err(failure("no_dialog", "The Import PDF window is not open"));
}
let spec = string(req, "value")?;
let (key, value) = spec.split_once('=').unwrap_or((spec, ""));
let bad = || failure("invalid_value", spec);
if key == "cancel" {
return Ok(Task::done(Message::CloseModal));
}
Message::PdfDialog(match key {
"ok" => P::ImportOk,
"page" => P::ImportPageText(value.to_string()),
"on_screen" => P::ImportInsertOnScreen(value == "1"),
"scale" => P::ImportScale(value.to_string()),
"rotation" => P::ImportRotation(
RotationChoice::ALL
.into_iter()
.find(|r| value.trim().parse() == Ok(r.0))
.ok_or_else(bad)?,
),
_ => return Err(bad()),
})
}
// The Import File window, one field per call: "path=<file>",
// "format=<index or name>", "search=<text>", "filter=all|supported",
// "recent=<n>", "ok" or "cancel".