mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-13 06:12:19 +00:00
Forms: a later XFA script reads the highlight an earlier one set
This commit is contained in:
1 parent
1ef0c1b948
commit
9da056e00e
3 files changed
+8
-2
No files matched your search
@@ -6116,6 +6116,7 @@ fn a_forms_layout_ready_scripts_run_once_it_is_laid_out() {
|
||||
let out = s.take_js_output(id);
|
||||
assert_eq!(out.requests, vec![js::Request::Highlight(true)], "the form turns field highlighting on: {out:?}");
|
||||
assert_eq!(value(&s, "stamp"), vec!["laid out".to_string()]);
|
||||
assert_eq!(value(&s, "seen"), vec!["true".to_string()], "a later script reads the highlight the root's turned on");
|
||||
assert!(value(&s, "pageNo").iter().all(|v| v.is_empty()), "page numbers are the layout's: {:?}", value(&s, "pageNo"));
|
||||
assert!(value(&s, "note").iter().all(|v| v.is_empty()), "form:ready is another event");
|
||||
// With highlighting already on, the form has nothing to ask for.
|
||||
|
||||
@@ -636,6 +636,9 @@ impl<'a, 'b> Runner<'a, 'b> {
|
||||
XfaEffect::Beep => self.run.out.requests.push(Request::Beep),
|
||||
XfaEffect::Highlight(on) => {
|
||||
self.run.highlight = *on;
|
||||
// The session's scripts read the setting it started with: the next script
|
||||
// gets a session that reads the new one.
|
||||
self.session = None;
|
||||
self.run.out.requests.push(Request::Highlight(*on));
|
||||
}
|
||||
XfaEffect::Recalculate => {}
|
||||
|
||||
@@ -119,8 +119,9 @@ fn assemble(objs: Vec<Vec<u8>>) -> Vec<u8> {
|
||||
/// a table whose `row` (item, amount) repeats, with `addRow`, `removeRow` and `hello` buttons;
|
||||
/// `grand`, the calculated sum of the amounts.
|
||||
/// A form with `layout:ready` scripts: the root subform turns field highlighting on (as forms
|
||||
/// do with `app.runtimeHighlight`), `stamp` takes a value, and `pageNo` numbers its page (left to
|
||||
/// the layout). `note` has a `form:ready` script, a different event.
|
||||
/// do with `app.runtimeHighlight`), `stamp` takes a value, `seen` records the highlight its script
|
||||
/// reads after the root's, and `pageNo` numbers its page (left to the layout). `note` has a
|
||||
/// `form:ready` script, a different event.
|
||||
pub fn layout_ready_template() -> String {
|
||||
r##"<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
|
||||
@@ -130,6 +131,7 @@ pub fn layout_ready_template() -> String {
|
||||
<pageSet><pageArea name="front"><contentArea x="0.5in" y="0.5in" w="7.5in" h="10in"/><medium short="8.5in" long="11in"/></pageArea></pageSet>
|
||||
<subform name="page" layout="tb">
|
||||
<field name="stamp" w="2in" h="0.3in"><ui><textEdit/></ui><event activity="ready" ref="$layout"><script contentType="application/x-javascript">this.rawValue = "laid out";</script></event></field>
|
||||
<field name="seen" w="2in" h="0.3in"><ui><textEdit/></ui><event activity="ready" ref="$layout"><script contentType="application/x-javascript">this.rawValue = String(app.runtimeHighlight);</script></event></field>
|
||||
<field name="pageNo" w="1in" h="0.3in"><ui><textEdit/></ui><event activity="ready" ref="$layout"><script contentType="application/x-javascript">this.rawValue = xfa.layout.page(this);</script></event></field>
|
||||
<field name="note" w="2in" h="0.3in"><ui><textEdit/></ui><event activity="ready" ref="$form"><script contentType="application/x-javascript">this.rawValue = "form ready";</script></event></field>
|
||||
</subform>
|
||||
|
||||
Reference in new issue
Block a user