diff --git a/Cargo.lock b/Cargo.lock index 4df93ed3fe..3e984b5159 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4684,6 +4684,7 @@ dependencies = [ "pdfcraft-model", "pdfcraft-platform", "pdfcraft-render", + "pdfcraft-testkit", "pdfcraft-xfa", "plist", "png 0.18.1", diff --git a/ROADMAP.md b/ROADMAP.md index 6ef9e2c369..ac3e7c4d8f 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -261,6 +261,7 @@ Ranked; detail and the full milestone table in [docs/roadmap.md](docs/roadmap.md - **2026-10-29 (M7, #2517):** Widening a paragraph rejoins a wrap with the number of spaces that wrap consumed, including a typed run and none for a Chinese or Japanese word split. The count survives an incremental save and a full rewrite, and a width-only `text_edit` uses it. Estimates unchanged. - **2026-10-26 (M11, JBIG2 symbols):** Lossless JBIG2 now stores each distinct mark of a black-and-white image once, as a symbol, and places its exact copies, when that is smaller than the generic region: on six pages of rendered 300 dpi text 28% of the generic region's size and 17% of Group 4's, and the same bits back through two independent decoders (hayro-jbig2 and Poppler). Scans, whose letters are seldom identical, gain little until refinement coding; a dictionary shared between pages (`/JBIG2Globals`) is next. Estimates unchanged. - **2026-10-25 (M5, comment replies):** One reply can be deleted from the Comments panel without its thread. On the selected card each reply has its own "…" menu (Edit, Copy text, Delete); Delete takes that reply with its pop-up and the replies to it, as `comment_delete` already did headlessly, and the comment and its other replies stay. The card stays selected, and the panel's editor stays open, on what they were on though the delete moved it in `/Annots`. Undo and Redo close the editor, since either can move what it was open on. A locked reply can't be deleted. Estimates unchanged. +- **2026-10-25 (M4, #2725):** Dismissing the ordinary form-field reminder persists across launches, while security, repair and XFA notices keep their independent controls and defaults. Estimates unchanged. - **2026-10-24 (M10, #4158 partial):** Word, HTML, RTF and PowerPoint export keep a block that continues another on its line (an italic case name, a link, a superscript) as a run in its own style inside that paragraph, with the source's word space, instead of a paragraph of its own. Style changes that wrap onto the next line still split paragraphs (the reading blocks keep style boundaries). Estimates unchanged. - **2026-10-24 (M3, window move on Wayland, #3970 follow-up):** After a move or resize by PdfCraft's own title bar or edges, the button release given back to egui goes before the pointer leaving the window, so hover no longer sticks at the old place until the pointer moves. Found by CodeRabbit in review of #3970; a unit test covers it. Estimates unchanged. - **2026-10-24 (M14, #4253):** The annotation quick bar remembers Keep tool selected across restarts, including unpinning. Old and malformed settings keep safe defaults; the opt-in UI control channel reads and changes the same preference. Estimates unchanged. diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index c859b93cf6..e29bd2393a 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -91,6 +91,7 @@ web-sys = { version = "0.3", features = ["Window", "Document", "Element", "HtmlE [dev-dependencies] craft-update = { workspace = true } +pdfcraft-testkit = { workspace = true } pdfcraft-xfa = { workspace = true } egui_kittest = { workspace = true, features = ["eframe", "wgpu"] } # Tests draw PdfCraft text without a system provider: the bundled and monochrome emoji faces must diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 6ac8ea8783..1a4d71f0a2 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -62,7 +62,8 @@ impl PdfCraftApp { } } - /// Construct an application with the default session, panels, theme and control state. + /// Construct an application with the default session, panels, theme, control state + /// and enabled ordinary form reminders. pub fn new() -> Self { Self { session: Session::new(), @@ -72,6 +73,7 @@ impl PdfCraftApp { mode: Mode::AllTools, default_mode: Mode::AllTools, view_defaults: Default::default(), + show_form_field_reminder: true, units: Default::default(), blank_paper: crate::paper::Paper::system(), date_format_draft: None, diff --git a/crates/ui-egui/src/app/control.rs b/crates/ui-egui/src/app/control.rs index 0309042bf1..d8ba6d2e92 100644 --- a/crates/ui-egui/src/app/control.rs +++ b/crates/ui-egui/src/app/control.rs @@ -85,6 +85,13 @@ impl PdfCraftApp { ("default-mode", _) => { self.default_mode = Mode::parse(value).ok_or("default-mode must be all, read, edit, convert or sign")?; } + ("form-reminder", _) => { + self.show_form_field_reminder = match value { + "on" | "true" => true, + "off" | "false" => false, + _ => return Err("form-reminder must be on or off".to_string()), + }; + } ("date-format", _) => self.session.set_date_format(value)?, ("date-language", _) => self.session.set_date_language(Some(value).filter(|v| *v != "auto"))?, ("tool", _) => { diff --git a/crates/ui-egui/src/app/prefs.rs b/crates/ui-egui/src/app/prefs.rs index 08a20afb45..c1f0123f97 100644 --- a/crates/ui-egui/src/app/prefs.rs +++ b/crates/ui-egui/src/app/prefs.rs @@ -146,6 +146,7 @@ impl PdfCraftApp { v["pinned_tools"] = serde_json::json!(self.pinned_tools); // Set outside json! above, which is at serde_json's macro recursion limit. v["hide_empty_highlight_hover"] = serde_json::Value::Bool(self.comment_prefs.hide_empty_highlight_hover); + v["show_form_field_reminder"] = serde_json::Value::Bool(self.show_form_field_reminder); v["show_page_edge_shadows"] = self.show_page_edge_shadows.into(); v["hotbar"] = serde_json::to_value(&self.hotbar).unwrap_or_default(); v["comment_tool_pinned"] = serde_json::Value::Bool(self.comment_prefs.pinned); @@ -276,6 +277,9 @@ impl PdfCraftApp { if let Some(on) = v["highlight_fields"].as_bool() { self.view_defaults.highlight_fields = on; } + if let Some(show) = v["show_form_field_reminder"].as_bool() { + self.show_form_field_reminder = show; + } if let Some(closed) = v["comments_panel_closed"].as_bool() { self.comments_panel_closed = closed; } diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index be2dd97d53..52de7a9e6c 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -2380,6 +2380,7 @@ fn apply_notice(app: &mut PdfCraftApp, index: usize, notice: Option) { } Some(Notice::Signatures) => app.right = Some(RightPanel::Signatures), Some(Notice::FieldHighlights(on)) => app.view_defaults.highlight_fields = on, + Some(Notice::DismissFormReminder) => app.show_form_field_reminder = false, Some(Notice::Console) => app.dialog = Some(crate::Dialog::JsConsole), // Back on in Preferences ▸ General. Some(Notice::HideSecured) => app.show_secured_notice = false, @@ -2875,8 +2876,7 @@ pub fn document_area(app: &mut PdfCraftApp, index: usize, ui: &mut egui::Ui) { // the user turned it off (#4035): the restrictions themselves, and Document Properties ▸ // Security, stay as they are. let secured = show_secured_notice && doc.security_summary().is_some_and(|s| !(s.owner || (s.permissions.modify() && s.permissions.assemble()))); - let repaired = !doc.repair_log().is_empty(); - let notice = notices(view, doc, secured, repaired, crate::sign_ui::banner(&doc.signatures), ui, &t); + let notice = notices(view, doc, app.show_form_field_reminder, secured, crate::sign_ui::banner(&doc.signatures), ui, &t); apply_notice(app, index, notice); let Some(doc) = app.session.get(app.views[index].id) else { return }; let info = &doc.info; diff --git a/crates/ui-egui/src/canvas/bars.rs b/crates/ui-egui/src/canvas/bars.rs index dd3fe8c498..d377031815 100644 --- a/crates/ui-egui/src/canvas/bars.rs +++ b/crates/ui-egui/src/canvas/bars.rs @@ -48,6 +48,8 @@ pub(super) enum Notice { Repairs, /// Highlight fields was turned on or off. FieldHighlights(bool), + /// Remember dismissal of the ordinary form-field reminder, independently of warnings. + DismissFormReminder, /// Open the JavaScript console (the form's scripts were turned off; the error is there). Console, /// Unlock… (enter the permissions password). @@ -64,14 +66,15 @@ pub(super) enum Notice { pub(super) fn notices( view: &mut DocView, doc: &pdfcraft_engine::Document, + show_form_field_reminder: bool, secured: bool, - repaired: bool, signed: Option<(&str, Color32, &str, String)>, ui: &mut egui::Ui, t: &Tokens, ) -> Option { let info = &doc.info; let xfa = doc.xfa.as_ref(); + let repaired = !doc.repair_log().is_empty(); // The file changed on disk while this document has unsaved changes (#431): ask before // replacing it, ahead of every other notice. if view.disk_changed { @@ -128,9 +131,6 @@ pub(super) fn notices( }); return open.then_some(Notice::Signatures); } - if view.notice_dismissed { - return None; - } let mut open_security = false; let mut unlock = false; let mut hide_secured = false; @@ -140,6 +140,14 @@ pub(super) fn notices( // A form whose scripts were turned off no longer calculates or answers its buttons: that // comes before what else there is to say about the document. let scripts_off = doc.xfa_scripts_off(); + // Only the ordinary fillable-field hint is optional. Skipping it must still allow + // security, repair and XFA warnings through, and never set the general dismissal flag. + let fillable_form = info.fields.iter().any(|f| f.kind != pdfcraft_render::FieldKind::PushButton); + let form_reminder = show_form_field_reminder && !scripts_off && !secured && xfa.is_none() && info.xfa.is_none() && fillable_form; + // Restoring this hint must not be blocked by, or clear, a dismissed repair warning. + if view.notice_dismissed && !form_reminder { + return None; + } // What the document is as a form, if it is one: what the bar says first, secured or not. let form = if let Some(x) = xfa { let lang = crate::i18n::current(); @@ -169,7 +177,7 @@ pub(super) fn notices( tl!("XFA form: its fields and its XFA data are kept in step, so other viewers show what you fill in.").to_string(), true, )) - } else if info.fields.iter().any(|f| f.kind != pdfcraft_render::FieldKind::PushButton) { + } else if fillable_form && (show_form_field_reminder || secured) { // Push buttons alone (LaTeX `animate` frames, navigation buttons) leave nothing to fill in. Some(( "text-cursor-input", @@ -201,7 +209,11 @@ pub(super) fn notices( let (icon, text, fields) = msg?; notice_bar(ui, t, icon, t.accent_text, text, |ui| { if icons::button(ui, "x", 22.0, false, tl!("Dismiss")).clicked() { - view.notice_dismissed = true; + if form_reminder { + toggled = Some(Notice::DismissFormReminder); + } else { + view.notice_dismissed = true; + } } if fields { let label = if view.highlight_fields { tl!("Hide field highlights") } else { tl!("Highlight fields") }; diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs index 44e5481a11..a9461ec9f1 100644 --- a/crates/ui-egui/src/control.rs +++ b/crates/ui-egui/src/control.rs @@ -38,6 +38,9 @@ //! for this session without changing the saved preference. `ui.state.default_mode` reports it. //! `theme=light|dark|system` changes the saved theme preference; `ui.state.theme_preference` //! reports the choice and `ui.state.theme` reports the resolved light/dark colours. +//! `form-reminder=on|off` persistently shows or hides the ordinary form-field reminder, +//! independently of security, repair and XFA notices. `ui.state.show_form_field_reminder` +//! reports the choice; it can also be changed before opening a document. //! `comment-tool-pinned=true|false` remembers the annotation quick bar's pin across restarts; //! `hotbar-tools` accepts comma-separated command IDs (empty clears the bar), and //! `hotbar-side=float|left|right|top|bottom` floats or docks the customizable hotbar; diff --git a/crates/ui-egui/src/control/host.rs b/crates/ui-egui/src/control/host.rs index b803f2738c..7a5a942f12 100644 --- a/crates/ui-egui/src/control/host.rs +++ b/crates/ui-egui/src/control/host.rs @@ -55,6 +55,7 @@ impl Host for crate::PdfCraftApp { self.request_quit(ctx) } + /// Report UI and preference state through the authenticated control channel. fn state(&self) -> Value { let active = self.active.and_then(|i| self.views.get(i)); let docs: Vec = self @@ -133,6 +134,7 @@ impl Host for crate::PdfCraftApp { "home": self.active.is_none(), "mode": format!("{:?}", self.mode), "default_mode": self.default_mode, + "show_form_field_reminder": self.show_form_field_reminder, "hotbar": self.hotbar, "comment_tool_pinned": self.comment_prefs.pinned, "left_panel": if self.left_open { json!(format!("{:?}", self.left)) } else { Value::Null }, diff --git a/crates/ui-egui/src/dialogs/preferences.rs b/crates/ui-egui/src/dialogs/preferences.rs index 9e3182e416..52f17db1cb 100644 --- a/crates/ui-egui/src/dialogs/preferences.rs +++ b/crates/ui-egui/src/dialogs/preferences.rs @@ -660,6 +660,7 @@ fn card_general(ui: &mut egui::Ui, app: &mut PdfCraftApp, t: &Tokens, ctx: &mut #[cfg(not(target_arch = "wasm32"))] ctx.checkbox(ui, &mut app.reload_changed_files, tl!("Reload documents when their files change on disk"), t); ctx.checkbox(ui, &mut app.show_secured_notice, tl!("Show a notice when a document is secured"), t); + ctx.checkbox(ui, &mut app.show_form_field_reminder, tl!("Show form field reminder"), t); #[cfg(not(target_arch = "wasm32"))] { diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 643d5e90ff..86a1dabaae 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -264,6 +264,9 @@ pub struct PdfCraftApp { /// Documents and view). Continuous scrolling at fit width by default, which never snaps /// between pages. pub view_defaults: canvas::ViewDefaults, + /// Show the ordinary AcroForm field reminder; dismissing it persists across sessions. + /// Security, repair, signature and XFA notices are independent of this preference. + pub show_form_field_reminder: bool, /// The unit page sizes and margins are shown in (Preferences ▸ Documents and view). pub units: units::Unit, /// The paper Create ▸ Blank page makes (#5644): the system region's. diff --git a/crates/ui-egui/tests/it/form_reminder.rs b/crates/ui-egui/tests/it/form_reminder.rs new file mode 100644 index 0000000000..45481e2bd7 --- /dev/null +++ b/crates/ui-egui/tests/it/form_reminder.rs @@ -0,0 +1,280 @@ +//! Persistent dismissal of the ordinary AcroForm reminder (#2725). + +use egui_kittest::{Harness, kittest::Queryable}; +use pdfcraft_testkit::Pdf; +use pdfcraft_ui_egui::PdfCraftApp; + +const REMINDER: &str = "This document contains 1 interactive form fields."; +const PREFERENCE: &str = "Show form field reminder"; + +/// Build one synthetic AcroForm text field for reminder-visibility regressions. +fn form() -> Vec { + Pdf::new() + .obj("<< /Type /Catalog /Pages 2 0 R /AcroForm << /Fields [4 0 R] >> >>") + .obj("<< /Type /Pages /Kids [3 0 R] /Count 1 /MediaBox [0 0 300 400] >>") + .obj("<< /Type /Page /Parent 2 0 R /Annots [4 0 R] >>") + .obj("<< /Type /Annot /Subtype /Widget /FT /Tx /T (name) /V (Synthetic) /Rect [50 300 250 330] /P 3 0 R >>") + .build() +} + +/// Restore optional saved preferences and open the synthetic document in a headless UI. +fn harness(saved: Option, bytes: Vec) -> Harness<'static, PdfCraftApp> { + let mut h = Harness::builder().with_size(egui::vec2(1400.0, 1000.0)).build_eframe(move |_cc| { + let mut app = PdfCraftApp::new(); + if let Some(saved) = saved { + app.restore(&saved); + } + app.set_option("language", "en").unwrap(); + app.open_bytes("synthetic-form.pdf", None, bytes).unwrap(); + app.set_option("left", "closed").unwrap(); + app.set_option("panel", "none").unwrap(); + app + }); + h.run_steps(6); + h +} + +/// Optional private visual checks use the real egui shell with only our synthetic form. +fn shot(h: &mut Harness<'static, PdfCraftApp>, name: &str) { + if let Ok(dir) = std::env::var("PDFCRAFT_FORM_REMINDER_SHOT_DIR") { + let path = std::path::Path::new(&dir).join(format!("{name}.png")); + std::fs::create_dir_all(&dir).unwrap(); + std::fs::write(std::path::Path::new(&dir).join("synthetic-form.pdf"), form()).unwrap(); + h.render().unwrap().save(path).unwrap(); + } +} + +/// Closing the existing reminder applies to another document and a freshly restored app. +#[test] +fn dismissing_form_reminder_survives_new_documents_and_restart() { + let mut h = harness(None, form()); + let id = h.state().views[0].id; + let original = h.state().session.get(id).unwrap().bytes.clone(); + assert!(h.state().session.get(id).unwrap().repair_log().is_empty(), "use a valid fixture"); + h.get_by_label(REMINDER); + let highlights = h.state().views[0].highlight_fields; + h.get_by_label("Dismiss").click(); + h.run_steps(4); + assert!(h.query_by_label(REMINDER).is_none()); + assert!(!h.state().views[0].notice_dismissed, "the general warning dismissal must remain session-local"); + assert!(!h.state().session.get(id).unwrap().dirty); + assert_eq!(h.state().views[0].highlight_fields, highlights); + assert_eq!(h.state().session.get(id).unwrap().bytes, original, "a UI preference must not change PDF bytes"); + let saved = h.state().persist(); + h.state_mut().open_bytes("another-form.pdf", None, form()).unwrap(); + h.run_steps(4); + assert!(h.query_by_label(REMINDER).is_none(), "another form must keep the preference"); + let h = harness(Some(saved), form()); + assert!(h.query_by_label(REMINDER).is_none(), "the reminder must stay dismissed after restarting"); +} + +/// Preferences can restore a dismissed reminder immediately and keep the choice on restart. +#[test] +fn preferences_can_restore_the_form_reminder() { + use egui::accesskit::Role; + let mut h = harness(None, form()); + shot(&mut h, "reminder-on"); + h.get_by_label("Dismiss").click(); + h.run_steps(4); + shot(&mut h, "reminder-dismissed"); + h.state_mut().set_option("dialog", "preferences").unwrap(); + h.run_steps(4); + h.get_by_role_and_label(Role::CheckBox, PREFERENCE).scroll_to_me(); + h.run_steps(4); + shot(&mut h, "preferences-reminder-off"); + h.get_by_role_and_label(Role::CheckBox, PREFERENCE).click(); + h.run_steps(4); + h.get_by_label("OK").scroll_to_me(); + h.run_steps(4); + h.get_by_label("OK").click(); + h.run_steps(4); + assert!(h.state().dialog.is_none(), "Preferences must actually close before checking the restored reminder"); + h.get_by_label(REMINDER); + shot(&mut h, "reminder-restored"); + let saved = h.state().persist(); + let h = harness(Some(saved), form()); + h.get_by_label(REMINDER); +} + +/// Older or malformed settings retain the previous default, while a stored false is honoured. +#[test] +fn stored_form_reminder_choice_preserves_old_settings_defaults() { + for (saved, expected) in [ + ("{}", true), + (r#"{"show_form_field_reminder":null}"#, true), + (r#"{"show_form_field_reminder":"off"}"#, true), + (r#"{"show_form_field_reminder":0}"#, true), + (r#"{"show_form_field_reminder":true}"#, true), + (r#"{"show_form_field_reminder":false}"#, false), + ] { + let h = harness(Some(saved.to_string()), form()); + assert_eq!(h.query_by_label(REMINDER).is_some(), expected, "{saved}"); + } +} + +/// Hiding a normal form reminder must leave damage warnings visible and session-local. +#[test] +fn a_hidden_form_reminder_does_not_hide_repair_warnings() { + let mut bytes = form(); + let xref = bytes.windows(5).position(|w| w == b"xref\n").unwrap(); + bytes.truncate(xref); + bytes.extend_from_slice(b"trailer << /Root 1 0 R >>\n%%EOF\n"); + let saved = r#"{"show_form_field_reminder":false}"#.to_string(); + let mut h = harness(Some(saved), bytes.clone()); + assert!(h.query_by_label(REMINDER).is_none()); + h.get_by_label("This file was damaged and has been repaired. Saving keeps the repaired version."); + h.get_by_label("Dismiss").click(); + h.run_steps(4); + let h = harness(Some(h.state().persist()), bytes); + h.get_by_label("This file was damaged and has been repaired. Saving keeps the repaired version."); +} + +/// Restoring the ordinary hint must neither be blocked by nor revive a dismissed warning. +#[test] +fn a_dismissed_repair_warning_does_not_block_restoring_the_form_reminder() { + let mut bytes = form(); + let xref = bytes.windows(5).position(|w| w == b"xref\n").unwrap(); + bytes.truncate(xref); + bytes.extend_from_slice(b"trailer << /Root 1 0 R >>\n%%EOF\n"); + let mut h = harness(Some(r#"{"show_form_field_reminder":false}"#.to_string()), bytes); + let warning = "This file was damaged and has been repaired. Saving keeps the repaired version."; + h.get_by_label(warning); + h.get_by_label("Dismiss").click(); + h.run_steps(4); + assert!(h.state().views[0].notice_dismissed); + assert!(h.query_by_label(warning).is_none()); + shot(&mut h, "warning-dismissed"); + h.state_mut().set_option("form-reminder", "on").unwrap(); + h.run_steps(4); + h.get_by_label(REMINDER); + assert!(h.query_by_label(warning).is_none()); + shot(&mut h, "reminder-after-dismissed-warning"); + assert!(h.state().views[0].notice_dismissed, "do not clear the independent warning dismissal"); + h.get_by_label("Dismiss").click(); + h.run_steps(4); + assert!(h.query_by_label(REMINDER).is_none()); + assert!(h.query_by_label(warning).is_none(), "the warning must stay dismissed after hiding the reminder again"); +} + +/// The persistent preference is independent of the document's security restrictions. +#[test] +fn a_hidden_form_reminder_does_not_hide_security_notices() { + let mut doc = pdfcraft_cos::Document::open(std::sync::Arc::new(form())).unwrap(); + doc.set_encryption(&pdfcraft_cos::NewEncryption { + algorithm: pdfcraft_cos::Algorithm::Aes256, + user_password: "", + owner_password: "synthetic-owner", + permissions: 0b0100, + encrypt_metadata: true, + seed: [7; 32], + }) + .unwrap(); + let bytes = pdfcraft_cos::write_full(&doc, &Default::default()).unwrap(); + for show in [true, false] { + let saved = serde_json::json!({"show_form_field_reminder":show}).to_string(); + let mut h = harness(Some(saved), bytes.clone()); + let id = h.state().views[0].id; + h.get_by_label_contains("interactive form fields. This document is secured. Some changes are restricted by its security settings."); + h.get_by_label("Security settings"); + let before = h.state().views[0].highlight_fields; + let label = if before { "Hide field highlights" } else { "Highlight fields" }; + h.get_by_label(label).click(); + h.run_steps(4); + assert_eq!(h.state().views[0].highlight_fields, !before); + assert_eq!(h.state().session.get(id).unwrap().bytes.as_ref(), bytes.as_slice()); + assert!(!h.state().session.get(id).unwrap().dirty); + if !show { + shot(&mut h, "secured-form-with-reminder-off"); + } + h.get_by_label("Dismiss").click(); + h.run_steps(4); + assert!(h.query_by_label_contains("This document is secured").is_none()); + assert!(h.state().views[0].notice_dismissed); + let saved = h.state().persist(); + assert_eq!(serde_json::from_str::(&saved).unwrap()["show_form_field_reminder"], show); + let h = harness(Some(saved), bytes.clone()); + h.get_by_label_contains("interactive form fields. This document is secured."); + h.get_by_label("Security settings"); + } +} + +/// The security-notice preference and ordinary form reminder remain independent after restart. +#[test] +fn form_and_security_notice_preferences_remain_independent() { + let mut doc = pdfcraft_cos::Document::open(std::sync::Arc::new(form())).unwrap(); + doc.set_encryption(&pdfcraft_cos::NewEncryption { + algorithm: pdfcraft_cos::Algorithm::Aes256, + user_password: "", + owner_password: "synthetic-owner", + permissions: 0b0100, + encrypt_metadata: true, + seed: [8; 32], + }) + .unwrap(); + let bytes = pdfcraft_cos::write_full(&doc, &Default::default()).unwrap(); + for show_form in [false, true] { + for show_security in [false, true] { + let settings = serde_json::json!({ + "show_form_field_reminder": show_form, + "show_secured_notice": show_security, + }) + .to_string(); + let h = harness(Some(settings), bytes.clone()); + let settings = h.state().persist(); + let h = harness(Some(settings), bytes.clone()); + assert_eq!(h.query_by_label_contains("This document is secured").is_some(), show_security); + assert_eq!(h.query_by_label(REMINDER).is_some(), show_form && !show_security); + let id = h.state().views[0].id; + assert!(h.state().session.get(id).unwrap().security_summary().is_some_and(|s| !s.owner)); + assert!(!h.state().session.get(id).unwrap().dirty); + } + } +} + +/// XFA status and disabled-script warnings keep their existing dismissal behaviour. +#[test] +fn a_hidden_form_reminder_does_not_hide_xfa_notices() { + let template = pdfcraft_xfa::fixtures::scripted_template(); + let h = harness(Some(r#"{"show_form_field_reminder":false}"#.to_string()), pdfcraft_xfa::fixtures::shell(&template)); + h.get_by_label_contains("Dynamic XFA form laid out from its template:"); + let runaway = "function f() { for (var j = 0; j < 99999; j++) {} } for (var k = 0; k < 5000; k++) f();"; + let template = template.replace("if (qty.rawValue === null) qty.rawValue = 2;", runaway); + let mut h = harness(Some(r#"{"show_form_field_reminder":false}"#.to_string()), pdfcraft_xfa::fixtures::shell(&template)); + let id = h.state().views[0].id; + assert!(h.state().session.get(id).unwrap().xfa_scripts_off()); + h.state_mut().toast = None; + h.run_steps(4); + h.get_by_label_contains("This form's scripts are turned off because one ran too long."); + h.get_by_label("JavaScript Console"); +} + +/// The existing control channel changes and reports the same persistent preference. +#[test] +fn control_form_reminder_is_persistent_and_rejects_invalid_values() { + use serde_json::json; + let mut h = harness(None, form()); + let ctx = h.ctx.clone(); + let control = h.state_mut().attach_control(&ctx); + let call = |h: &mut Harness<'static, PdfCraftApp>, method: &str, params| { + let reply = control.send(method, params); + for _ in 0..30 { + h.step(); + if let Ok(result) = reply.try_recv() { + return result; + } + } + panic!("no control reply for {method}"); + }; + call(&mut h, "ui.set", json!({"key":"form-reminder","value":"off"})).unwrap(); + h.run_steps(4); + assert!(h.query_by_label(REMINDER).is_none()); + assert_eq!(call(&mut h, "ui.state", json!({})).unwrap()["show_form_field_reminder"], false); + assert!(call(&mut h, "ui.set", json!({"key":"form-reminder","value":"maybe"})).is_err()); + assert_eq!(call(&mut h, "ui.state", json!({})).unwrap()["show_form_field_reminder"], false); + let saved = h.state().persist(); + let h = harness(Some(saved), form()); + assert!(h.query_by_label(REMINDER).is_none()); + let mut app = PdfCraftApp::new(); + app.set_option("form-reminder", "off").unwrap(); + assert_eq!(serde_json::from_str::(&app.persist()).unwrap()["show_form_field_reminder"], false); +} diff --git a/crates/ui-egui/tests/it/main.rs b/crates/ui-egui/tests/it/main.rs index 20243ea86d..08f3f5dd91 100644 --- a/crates/ui-egui/tests/it/main.rs +++ b/crates/ui-egui/tests/it/main.rs @@ -45,6 +45,7 @@ mod export; mod fill_sign; mod folders; mod fonts; +mod form_reminder; mod forms; mod identity; mod javascript; diff --git a/docs/development.md b/docs/development.md index 8cb132d9f8..79d5071e68 100644 --- a/docs/development.md +++ b/docs/development.md @@ -138,6 +138,19 @@ the app logs the failure and continues using the original preferences folder. The existing PrintCraft-to-PdfCraft migration runs first. macOS, Windows and portable copies retain their current preferences locations. +Preferences ▸ Documents and view ▸ **Show form field reminder** controls the ordinary +"This document contains … interactive form fields" notice. Closing that notice turns the +preference off for all open and future documents, including after a restart. Turn the checkbox +back on to restore it immediately. Older settings default to showing the reminder; malformed +values are ignored. This does not change field highlighting or hide security, repair, signature +or XFA notices, and it does not modify the PDF. +Secured forms retain their combined form/security notice and field-highlighting controls with +either reminder preference. Closing that security notice dismisses it only for the current view. + +The opt-in UI control channel uses `ui.set` with `key=form-reminder`, `value=on|off`; the same +option is available as `pdfcraft --form-reminder off`. `ui.state.show_form_field_reminder` +reports the persistent choice even with no document open. + ## Environment variables | Variable | Effect | diff --git a/docs/roadmap.md b/docs/roadmap.md index d17893c1aa..898a16f278 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -217,7 +217,7 @@ total matches the parity estimate. | M2 | Model, render, text | 200–350 | 15% | 130–230 | hayro bootstrap renderer (vendored patches); inspector predictor scratch is bounded by available input, and JPX sample rescaling handles 1–32 bits safely. Text extraction reaches word-F1 0.98 against pdftotext. Short same-line redraws split before placement rather than interleaving. A custom text match that ends on a reconstructed separator stops before the next glyph (#1315). Missing: model crate, fonts, DisplayList, renderer independent of hayro. Inspector page-label traversal and output are resource-bounded, with physical-number fallback warnings | | M2 | Model, render, text | 200–350 | 15% | 130–230 | hayro bootstrap renderer (vendored patches); Lab Bradford adaptation uses LMS white-point ratios, covered by independent neutral/chromatic and direct/Indexed render oracles; inspector predictor scratch is bounded by available input, and JPX sample rescaling handles 1–32 bits safely. Text extraction reaches word-F1 0.98 against pdftotext. Short same-line redraws split before placement rather than interleaving. Missing: model crate, fonts, DisplayList, renderer independent of hayro. Inspector page-label traversal and output are resource-bounded, with physical-number fallback warnings. Literal page-label prefix whitespace is preserved; nine public-inspection cases cover prefix spaces, encodings and empty-prefix controls | | M3 | Viewer app (native + web) | 80–150 | 90% | 10–20 | Acrobat-style shell, find, select, panels, tiles, web build, UI control channel for agents (opt-in). Missing: 60 fps test on a 500-page document, snapshot tests of every panel
Done since: fit visible, document title in the window; Linux middle-button scrolling; shared three-state theme preferences in the toolbar, View menu and control channel; numeric Linux portal events and idle wakeups completing #881, with native appearance inheritance retained (#446); late browser startup downloads preserve the current document and Save target (#171). | -| M4 | Engine, history, save, organize | 100–180 | 95% | 8–15 | Done:
- command registry (menus, shortcuts and palette all use it);
- undo/redo; incremental, atomic and encrypted saves;
- autosave and crash recovery;
- organize, combine, extract, split and insert-from-file, with identical fonts and images stored once;
- CLI `edit/combine/extract/split`.
Done since: Organize opens directly into the page overview, with checkbox selection, an editable page-range selection (#1092), and per-page rotate/delete controls; Combine files in its own tab (sortable, resizable columns; folders; early warnings; unlocking protected files), bookmark editing, page labels (Number pages), CLI `run`, Set Page Boxes, Crop tool, Duplicate pages, Ctrl+A / Cmd+A to select all pages in Organize, Replace pages, bookmarks from tagged headings. Extract and Split preserve shared Type 3 glyph resource graphs, retaining conservative pruning limits. Undo back to the opened or last saved file is clean; Revert opens that saved file after an undo; a later save appends to it so the saved revision stays in the file (#1310, #1311, #1312). Ctrl-drag (Option on macOS) on a grid thumbnail copies the pages into the drop gap, with a "+" badge and the copies selected (#2997). Initial-view window and interface options resolve indirect boolean preferences. Done since: #3309: Stack-safe named-destination pruning visits shared/cyclic indirect nodes once, without a name-count limit. Synthetic deep-tree and 60,000-name tests verify deletion, surviving targets, undo/redo, both save modes and reopening. Organize drags cancel after document edits and Undo/Redo (#3916 partial). Missing: page transitions, recovery on the web | +| M4 | Engine, history, save, organize | 100–180 | 95% | 8–15 | Done:
- command registry (menus, shortcuts and palette all use it);
- undo/redo; incremental, atomic and encrypted saves;
- autosave and crash recovery;
- organize, combine, extract, split and insert-from-file, with identical fonts and images stored once;
- CLI `edit/combine/extract/split`.
Done since: Organize opens directly into the page overview, with checkbox selection, an editable page-range selection (#1092), and per-page rotate/delete controls; Combine files in its own tab (sortable, resizable columns; folders; early warnings; unlocking protected files), bookmark editing, page labels (Number pages), CLI `run`, Set Page Boxes, Crop tool, Duplicate pages, Ctrl+A / Cmd+A to select all pages in Organize, Replace pages, bookmarks from tagged headings. Extract and Split preserve shared Type 3 glyph resource graphs, retaining conservative pruning limits. Undo back to the opened or last saved file is clean; Revert opens that saved file after an undo; a later save appends to it so the saved revision stays in the file (#1310, #1311, #1312). Ctrl-drag (Option on macOS) on a grid thumbnail copies the pages into the drop gap, with a "+" badge and the copies selected (#2997). Initial-view window and interface options resolve indirect boolean preferences. Done since: #3309: Stack-safe named-destination pruning visits shared/cyclic indirect nodes once, without a name-count limit. Synthetic deep-tree and 60,000-name tests verify deletion, surviving targets, undo/redo, both save modes and reopening. Organize drags cancel after document edits and Undo/Redo (#3916 partial). Missing: page transitions, recovery on the web Candidate #2725: Dismissing the ordinary form-field reminder persists across launches. Preferences and UI control restore it. | | M4 | Engine, history, save, organize | 100–180 | 95% | 8–15 | Done:
- command registry (menus, shortcuts and palette all use it);
- undo/redo; incremental, atomic and encrypted saves;
- autosave and crash recovery;
- organize, combine, extract, split and insert-from-file, with identical fonts and images stored once;
- CLI `edit/combine/extract/split`.
Done since: Organize opens directly into the page overview, with checkbox selection, an editable page-range selection (#1092), and per-page rotate/delete controls; Combine files in its own tab (sortable, resizable columns; folders; early warnings; unlocking protected files), bookmark editing, page labels (Number pages), CLI `run`, Set Page Boxes, Crop tool, Duplicate pages, Ctrl+A / Cmd+A to select all pages in Organize, Replace pages, bookmarks from tagged headings. Extract and Split preserve shared Type 3 glyph resource graphs, retaining conservative pruning limits. Undo back to the opened or last saved file is clean; Revert opens that saved file after an undo; a later save appends to it so the saved revision stays in the file (#1310, #1311, #1312). Rotation queries and edits resolve indirect values on pages and ancestors. Refreshed against upstream `99941daa` (2026-10-15). Repeated page indices accumulate rotations from the latest local value (#1919); saved/reopened regressions retain inherited angles and siblings. Missing: page transitions, recovery on the web | | M4 | Engine, history, save, organize | 100–180 | 95% | 8–15 | Done:
- command registry (menus, shortcuts and palette all use it);
- undo/redo; incremental, atomic and encrypted saves;
- autosave and crash recovery;
- organize, combine, extract, split and insert-from-file, with identical fonts and images stored once;
- CLI `edit/combine/extract/split`.
Done since: Organize opens directly into the page overview, with checkbox selection, an editable page-range selection (#1092), and per-page rotate/delete controls; Combine files in its own tab (sortable, resizable columns; folders; early warnings; unlocking protected files), bookmark editing, page labels (Number pages), CLI `run`, Set Page Boxes, Crop tool, Duplicate pages, Ctrl+A / Cmd+A to select all pages in Organize, Replace pages, bookmarks from tagged headings. Extract and Split preserve shared Type 3 glyph resource graphs, retaining conservative pruning limits. Undo back to the opened or last saved file is clean; Revert opens that saved file after an undo; a later save appends to it so the saved revision stays in the file (#1310, #1311, #1312). Rotation queries and edits resolve indirect values on pages and ancestors. Missing: page transitions, recovery on the web | | M4 | Engine, history, save, organize | 100–180 | 95% | 8–15 | Done:
- command registry (menus, shortcuts and palette all use it);
- undo/redo; incremental, atomic and encrypted saves;
- autosave and crash recovery;
- organize, combine, extract, split and insert-from-file, with identical fonts and images stored once;
- CLI `edit/combine/extract/split`.
Done since: Organize opens directly into the page overview, with checkbox selection, an editable page-range selection (#1092), and per-page rotate/delete controls; Combine files in its own tab (sortable, resizable columns; folders; early warnings; unlocking protected files), bookmark editing, page labels (Number pages), CLI `run`, Set Page Boxes, Crop tool, Duplicate pages, Ctrl+A / Cmd+A to select all pages in Organize, Replace pages, bookmarks from tagged headings. Extract and Split preserve shared Type 3 glyph resource graphs, retaining conservative pruning limits. Missing: page transitions, recovery on the web M4: Insert-from-file preserves source bookmarks; integration tests retained with current main. | diff --git a/parity/acrobat-features.toml b/parity/acrobat-features.toml index 822496df3b..4d658d6c6f 100644 --- a/parity/acrobat-features.toml +++ b/parity/acrobat-features.toml @@ -9992,11 +9992,11 @@ title = "Preferences: forms" area = "N" tier = "P1" milestone = "M14" -status = "planned" -commands = [] +status = "partial" +commands = ["app.preferences"] tools = [] -evidence = [] -notes = "" +evidence = ["crates/ui-egui/tests/it/form_reminder.rs::dismissing_form_reminder_survives_new_documents_and_restart", "crates/ui-egui/tests/it/form_reminder.rs::preferences_can_restore_the_form_reminder", "crates/ui-egui/tests/it/form_reminder.rs::stored_form_reminder_choice_preserves_old_settings_defaults", "crates/ui-egui/tests/it/form_reminder.rs::a_hidden_form_reminder_does_not_hide_repair_warnings", "crates/ui-egui/tests/it/form_reminder.rs::a_hidden_form_reminder_does_not_hide_security_notices", "crates/ui-egui/tests/it/form_reminder.rs::a_hidden_form_reminder_does_not_hide_xfa_notices", "crates/ui-egui/tests/it/form_reminder.rs::control_form_reminder_is_persistent_and_rejects_invalid_values", "crates/ui-egui/tests/it/form_reminder.rs::a_dismissed_repair_warning_does_not_block_restoring_the_form_reminder"] +notes = "The ordinary AcroForm field reminder can be persistently dismissed and restored in Preferences or through opt-in UI control. Existing settings default to showing it. Security, repair, signature and XFA notices remain independent; this does not change field highlighting or PDF data. Other Forms preferences, including a Preferences field-highlighting toggle, remain missing." [[feature]] id = "misc.prefs-identity"