[latex3-commits] [git/LaTeX3-latex3-pdfresources] textfields: storing (19ece74)
Ulrike Fischer
fischer at troubleshooting-tex.de
Sat May 8 12:43:45 CEST 2021
Repository : https://github.com/latex3/pdfresources
On branch : textfields
Link : https://github.com/latex3/pdfresources/commit/19ece74b5aec987a83e230babb4311fc38caf951
>---------------------------------------------------------------
commit 19ece74b5aec987a83e230babb4311fc38caf951
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Sat May 8 12:43:45 2021 +0200
storing
>---------------------------------------------------------------
19ece74b5aec987a83e230babb4311fc38caf951
l3pdffield-checkbox.dtx | 36 +++++++++++++++++---------
l3pdffield.dtx | 69 ++++++++++++++++++++++++++++++++++---------------
2 files changed, 72 insertions(+), 33 deletions(-)
diff --git a/l3pdffield-checkbox.dtx b/l3pdffield-checkbox.dtx
index 125040e..035c63e 100644
--- a/l3pdffield-checkbox.dtx
+++ b/l3pdffield-checkbox.dtx
@@ -105,11 +105,24 @@
%
% \subsection{Keys}
%
-% The new checkbox commands accepts following keys:
-%
-% \DescribeCheckboxkey{name} This sets the (internal) name of the field. It shouldn't contain
-% a period, be not empty and sensibly consist of simple chars. Checkboxes instances
-% with the same name belong to the same field and are checked and unchecked together.
+% The new checkbox commands accept all field and annot keys from l3pdffield.
+% A number of keys have more user friendly alias names, which roughly follow the
+% naming used in hyperref for the analog feature. Some keys have a more checkbox specific
+% behaviour or have other defaults than with the basic commands. Additionally there
+% are a small number of keys specific to a checkbox.
+%
+% All the difference are described in the following paragraphs.
+%
+% \DescribeCheckboxkey{name}\DescribeCheckboxkey{T}
+% This sets like the |T| key for fields the partial name of the field. The value
+% shouldn't contain a period, be not empty and sensibly consist of simple chars.
+% Additionally the value is used to create the field ID.
+% This means that checkboxes with the same partial name are annotations
+% with all the same field as parent and are checked and unchecked together---this
+% what is typically expected. There could be an option to change the behaviour
+% but currently I can't see a sensible use case.
+% The field ID is internal as the field has a field annotation and so
+% is always a terminal field.
%
% \DescribeCheckboxkey{parent} This is only needed if the field should be part
% of a larger fieldset. The value should be a field name of field created previously
@@ -386,9 +399,10 @@
\group_begin:
\keys_set_known:nnN {pdffield / checkbox }
{
- fieldname=,
name=checkbox,
appearance = checkbox/default,
+ width =\baselineskip,
+ height=\baselineskip,
#1
}\l_@@_tmpa_keys_tl
\keys_set_known:nVN {pdffield / checkbox / field } \l_@@_tmpa_keys_tl \l_@@_tmpa_keys_tl
@@ -398,11 +412,9 @@
,unsetFf={Radio,Pushbutton}
,FT= Btn
}
- \tl_if_empty:NT \l_@@_fieldname_tl
- {
- \pdfdict_get:nnN {l_@@/field}{T}\l_@@_fieldname_tl
- }
- \@@_checkbox_field:V\l_@@_fieldname_tl
+ \pdfdict_get:nnN {l_@@/field}{T}\l_@@_tmpa_tl
+ \tl_put_left:Nn \l_@@_tmpa_tl {@@/checkbox/}
+ \@@_checkbox_field:V\l_@@_tmpa_tl
\@@_annot:
\group_end:
}
@@ -429,7 +441,7 @@
,name .initial:n = checkbox
,altname .meta:nn = {pdffield/field}{TU=#1}
,mappingname .meta:nn = {pdffield/field}{TM=#1}
- ,fieldname .tl_set:N = \l_@@_fieldname_tl
+ ,parent .tl_set:N = \l_@@_currentparent_tl
}
% \end{macrocode}
diff --git a/l3pdffield.dtx b/l3pdffield.dtx
index 8514738..08075ea 100644
--- a/l3pdffield.dtx
+++ b/l3pdffield.dtx
@@ -220,9 +220,9 @@
% \section{Commands}
% \begin{function}{\pdffield_field:nn,\pdffield_field:Vn}
% \begin{syntax}
-% \cs{pdffield_field:nn}\Arg{key val list}\Arg{name}
+% \cs{pdffield_field:nn}\Arg{key val list}\Arg{field ID}
% \end{syntax}
-% This creates a new field. \meta{name} will be used to create and
+% This creates a new field. \meta{field ID} will be used to create and
% reference the needed objects but it is not the direct object name, so
% |pdf_object_ref:n| can not be used to access (and there will not
% clash with object names). It is recommended to start
@@ -276,7 +276,7 @@
% \begin{tabular}{>{\ttfamily}lllll}
% \toprule
% key & value & required & inheritable &remark\\\midrule
-% parent & field name & for non-root fields & \\
+% parent & field ID & for non-root fields & \\
% T & string & mostly & \\
% TU & string & & \\
% TM & string & & \\
@@ -303,7 +303,7 @@
% \end{table}
%
% \DescribeFieldkey{parent} This declares the parent of the field. It is required if
-% the field is not the root of the fieldset. The value is the field name
+% the field is not the root of the fieldset. The value is the field ID
% of the parent, the parent should have been already declared.
% It will add the reference to the parent field to the |/Parent| key, and also
% add reference of the kid as |/Kid| in the parent field.
@@ -420,7 +420,7 @@
% \begin{tabular}{>{\ttfamily}lllll}
% \toprule
% key & value & required &remark\\\midrule
-% parent & field name & yes \\
+% parent & field ID & yes \\
% width & dim expression & (yes) & default is 0pt \\
% height & dim expression & (yes) & default is 0pt \\
% depth & dim expression & (yes) & default is 0pt \\
@@ -444,7 +444,7 @@
% The value should be a command that expands to a dimension expression. By default
% all values are zero.
%
-% \DescribeAnnotkey{parent} This sets the parent. The value should be the object name of
+% \DescribeAnnotkey{parent} This sets the parent. The value should be field ID of
% an already declared field.
%
% \DescribeAnnotkey{AP/N}\DescribeAnnotkey{AP/R}\DescribeAnnotkey{AP/D}
@@ -453,7 +453,7 @@
%
% \DescribeAnnotkey{AS} This key sets the default appearance state.
% The value is a name without the starting slash
-% (it is passed throught |\pdf_name_from_unicode_e:n|),
+% (it is passed through |\pdf_name_from_unicode_e:n|),
% for checkbox for example |Yes|. If used it should typically have the same value
% as the V and DV key of the field.
%
@@ -501,12 +501,11 @@
%
% \begin{macrocode}
\str_new:N \l_@@_tmpa_str
-\tl_new:N \l_@@_tmpa_tl
+\tl_new:N \l_@@_tmpa_tl
\tl_new:N \l_@@_tmpa_keys_tl
\cs_new_protected:Npn \@@_tmpa:n #1 {}
\cs_new_protected:Npn \@@_tmpa:nn #1 #2 {}
\tl_new:N \l_@@_currentparent_tl
-\tl_new:N \l_@@_fieldname_tl
% \end{macrocode}
%
% \subsection{messages}
@@ -535,6 +534,11 @@
Support~for~'/#1'~is~not~implemented\\
The~key~is~ignored.
}
+\msg_new:nnn {pdffield}{parent-field-missing}
+ {
+ The~parent~field~'#1'~doesn't~exist\\
+ Create~it~with~\tl_to_str:n{\pdffield_field:nn}
+ }
% \end{macrocode}
% \subsection{bitsets}
@@ -620,24 +624,33 @@
% \end{macrocode}
% \begin{macro}{\@@_field:n}
% \begin{syntax}
-% \cs{@@_field:n}\Arg{obj name}
+% \cs{@@_field:n}\Arg{field ID}
% \end{syntax}
% \begin{macrocode}
\cs_new_protected:Npn \@@_field:n #1
{
\pdf_object_new:nn {@@/field/#1} {dict}
\pdf_object_new:nn {@@/field/Kids/#1} {array}
- \tl_if_empty:NF \l_@@_currentparent_tl
+ \tl_if_empty:NTF \l_@@_currentparent_tl
{
- \pdfdict_put:nnx { l_@@/field }{Parent}
- {\pdf_object_ref:n{@@/field/\l_@@_currentparent_tl}}
- \seq_gput_right:cx {g_@@_field/Kids/\l_@@_currentparent_tl _seq}
- { \exp_args:Ne \pdf_object_ref:n{@@/field/#1}}
\pdfmanagement_add:nnx
{ Catalog / AcroForm }
{ Fields }
{\pdf_object_ref:n {@@/field/#1} }
}
+ {
+ \exp_args:Ne
+ \pdf_object_if_exist:nTF {@@/field/\l_@@_currentparent_tl}
+ {
+ \pdfdict_put:nnx { l_@@/field }{Parent}
+ {\exp_args:Ne \pdf_object_ref:n{@@/field/\l_@@_currentparent_tl}}
+ \seq_gput_right:cx {g_@@_field/Kids/\l_@@_currentparent_tl _seq}
+ { \exp_args:Ne \pdf_object_ref:n{@@/field/#1}}
+ }
+ {
+ \msg_error:nnx {pdffield}{parent-field-missing}{\l_@@_currentparent_tl}
+ }
+ }
\seq_new:c {g_@@_field/Kids/#1_seq}
\pdfdict_put:nnx {l_@@/field}
{Kids}
@@ -671,7 +684,7 @@
\cs_new_protected:Npn \pdffield_field:nn #1 #2
{
\group_begin:
- \keys_set_known:nn {pdffield / field } {#1}
+ \keys_set:nn { pdffield / field } {#1}
\@@_field:n {#2}
\group_end:
}
@@ -683,6 +696,8 @@
% leave vertical mode.
%
% \begin{macro}{\@@_annot:}
+% The command doesn't add grouping, so should only be used inside a group.
+%
% \begin{macrocode}
\cs_new_protected:Npn \@@_annot:
{
@@ -694,7 +709,6 @@
\bitset_set_false:Nn \l_@@_F_bitset {Invisible}
\bitset_set_false:Nn \l_@@_F_bitset {NoView}
}
- %\pdfdict_put:nnx {l_@@/annot}{F}{ \bitset_to_arabic:N \l_@@_F_bitset }
\pdfannot_dict_put:nnx {widget}{F}{ \bitset_to_arabic:N \l_@@_F_bitset }
\mode_leave_vertical:
\hbox_to_wd:nn
@@ -709,13 +723,21 @@
}
\tl_if_empty:NF \l_@@_currentparent_tl
{
- \seq_gput_right:cx {g_@@_field/Kids/\l_@@_currentparent_tl _seq}{ \pdfannot_box_ref_last:}
+ \seq_if_exist:cTF {g_@@_field/Kids/\l_@@_currentparent_tl _seq}
+ {
+ \seq_gput_right:cx
+ {g_@@_field/Kids/\l_@@_currentparent_tl _seq}
+ { \pdfannot_box_ref_last:}
+ }
+ {
+ \msg_error:nnx { pdffield}{parent-field-missing}{\l_@@_currentparent_tl}
+ }
}
}
\cs_new_protected:Npn \pdffield_annot:n #1
{
\group_begin:
- \keys_set_known:nn {pdffield / annot } {#1} %preset something? dimensions?
+ \keys_set:nn {pdffield / annot } {#1}
\@@_annot:
\group_end:
}
@@ -796,7 +818,6 @@
{
\pdfdict_put:nnx { l_@@/field }{I}{ \pdf_object_ref:n{#1} }
}
-
}
% \end{macrocode}
@@ -897,7 +918,13 @@
parent .code:n =
{
\tl_set:Nn \l_@@_currentparent_tl {#1}
- \pdfannot_dict_put:nnx {widget}{Parent}{\pdf_object_ref:n{@@/field/#1}}
+ \pdf_object_if_exist:nTF { @@/field/#1 }
+ {
+ \pdfannot_dict_put:nnx {widget}{Parent}{\pdf_object_ref:n{@@/field/#1}}
+ }
+ {
+ \msg_error:nnn { pdffield }{parent-field-missing}{#1}
+ }
}
,AS .code:n =
{
More information about the latex3-commits
mailing list.