[latex3-commits] [git/LaTeX3-latex3-pdfresources] reworking-annot: replace flag code by bitsets (530a20f)
Ulrike Fischer
fischer at troubleshooting-tex.de
Mon Dec 28 00:12:02 CET 2020
Repository : https://github.com/latex3/pdfresources
On branch : reworking-annot
Link : https://github.com/latex3/pdfresources/commit/530a20f2914a794adbb0215e18b9f649ba8f944f
>---------------------------------------------------------------
commit 530a20f2914a794adbb0215e18b9f649ba8f944f
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Mon Dec 28 00:12:02 2020 +0100
replace flag code by bitsets
>---------------------------------------------------------------
530a20f2914a794adbb0215e18b9f649ba8f944f
l3pdfannot.dtx | 35 +++++++++++++-
l3pdfmeta.dtx | 8 ++--
l3pdfutils.dtx | 95 --------------------------------------
newpackages/hyp-field-checkbox.sty | 42 +++++++++++++++++
4 files changed, 79 insertions(+), 101 deletions(-)
diff --git a/l3pdfannot.dtx b/l3pdfannot.dtx
index 76cfae5..71530d3 100644
--- a/l3pdfannot.dtx
+++ b/l3pdfannot.dtx
@@ -235,6 +235,19 @@
% \texttt{link/URI}, \texttt{link/GoToR}, \texttt{link/Launch},
% \texttt{link/GoTo}, \texttt{link/Named}.
% \end{function}
+%
+% \begin{variable}[added = 2020-12-28]{\l_pdfannot_F_bitset}
+% This is a bitset variable, with the named index names suitable for the
+% /F flag in an annotation.
+% It can be used for example like this:
+% \begin{verbatim}
+% \pdfannot_dict_put:nnn {link/URI}{F}{ \bitset_to_arabic:N \l_pdfannot_F_bitset }
+% \bitset_set_true_key:Nn \l_pdfannot_F_bitset {Print}
+% \end{verbatim}
+% The known keys for the bitset are |Invisible|, |Hidden|,
+% |Print|, |NoZoom|, |NoRotate|, |NoView|, |ReadOnly|, |Locked|, |ToggleNoView|,
+% |LockedContents| which correspond to the names used in the PDF references.
+% \end{variable}
% \end{documentation}
%
% \begin{implementation}
@@ -246,7 +259,26 @@
%<@@=pdfannot>
\ProvidesExplPackage {l3pdfannot} {2020-12-04} {0.1}
{PDF-annotations}
-\RequirePackage{l3pdfutils} %because of the flags ...
+\RequirePackage{l3pdfdict}
+% \end{macrocode}
+% Annotations have a /F flag, we provide a public
+% bitset for it.
+% \begin{macrocode}
+\RequirePackage{l3bitset}
+\bitset_new:N \l_pdfannot_F_bitset
+\bitset_addto_named_index:Nn \l_pdfannot_F_bitset
+ {
+ Invisible = 1,
+ Hidden = 2,
+ Print = 3,
+ NoZoom = 4,
+ NoRotate = 5,
+ NoView = 6,
+ ReadOnly = 7,
+ Locked = 8,
+ ToggleNoView = 9,
+ LockedContents = 10
+ }
% \end{macrocode}
% \begin{NOTE}{UF}
% The code/naming tries to unify general annotations and the special type of
@@ -343,7 +375,6 @@
\seq_map_inline:Nn \c_pdfannot_link_types_seq
{
\pdfdict_new:n { l_@@/link/#1 }
- \pdfdict_put:nnn { l_@@/link/#1}{ F }{ \pdf_flag_use:n { annot/Link} }
\hook_new_pair:nn
{pdfannot/link/#1/before}
{pdfannot/link/#1/after}
diff --git a/l3pdfmeta.dtx b/l3pdfmeta.dtx
index 90bd2c3..e1e650a 100644
--- a/l3pdfmeta.dtx
+++ b/l3pdfmeta.dtx
@@ -197,10 +197,10 @@
,Catalog/OCProperties = false
,named_actions = {NextPage, PrevPage, FirstPage, LastPage}
,annot_flags = {
- \pdf_flag_set:nn {annot/Link}{Print}
- \pdf_flag_clear:nn {annot/Link}{Hidden}
- \pdf_flag_clear:nn {annot/Link}{Invisible}
- \pdf_flag_clear:nn {annot/Link}{NoView}
+ \bitset_set_key:Nn \l_pdfannot_F_bitset {Print}
+ \bitset_clear_key:Nn \l_pdfannot_F_bitset {Hidden}
+ \bitset_clear_key:Nn \l_pdfannot_F_bitset {Invisible}
+ \bitset_clear_key:Nn \l_pdfannot_F_bitset {NoView}
}
% to be continued https://docs.verapdf.org/validation/pdfa-part1/
}
diff --git a/l3pdfutils.dtx b/l3pdfutils.dtx
index d4bcce8..6a543db 100644
--- a/l3pdfutils.dtx
+++ b/l3pdfutils.dtx
@@ -172,101 +172,6 @@
%</package>
% \end{macrocode}
%
-%
-% \subsection{Flags}
-% Every flag should have an associated property that allows to set/clear flag positions by
-% name. The name is \cs{c_@@_flag_\#1_prop}
-% \begin{NOTE}{UF}
-% not sure about this yes, reconsider (naming, implementation ...)
-% \end{NOTE}
-% \begin{macrocode}
-%<*package>
-%<@@=pdf>
-\cs_new_protected:Npn \pdf_flag_new:nn #1 #2
- {
- \bitsetReset { @@_#1_flag }
- \prop_const_from_keyval:cn { c_@@_flag_#1_prop }
- {
- #2
- }
- }
-
-\pdf_flag_new:nn {annot/Link}
- {
- Invisible = 0,
- Hidden = 1,
- Print = 2,
- NoZoom = 3,
- NoRotate = 4,
- NoView = 5,
- ReadOnly = 6,
- Locked = 7,
- ToggleNoView = 8,
- LockedContents = 9
- }
-
-\pdf_flag_new:nn {annot/Field} %name is wrong ... form?? it is not really an annot,
- {
- ReadOnly = 0,
- Required = 1,
- NoExport = 2,
- Multiline = 12,%Tx
- Password = 13,
- NoToggleToOff = 14,%Btn, radio button
- Radio = 15,%Btn: Radio: 15=1, 16=0
- Pushbutton = 16,%Btn: Checkbox: 15=0, 16=0
- %Btn: Pushbutton: 16=1
- Combo = 17,%Ch: Combo=1 List=0
- Edit = 18,%Ch, Combo=1 -> + edit field
- Sort = 19,%Ch, not relevant for view...
- FileSelect = 20,%Tx
- MultiSelect = 21,%Ch
- DoNotSpellCheck = 22,%Tx, Ch (if Combo + Edit set)
- DoNotScroll = 23,%Tx
- Comb = 24,%Tx, requires MaxLen in dict
- RadiosInUnison = 25,%Btn Radio
- RichText = 25,%Tx
- CommitOnSelChange = 26
- }
-
-\pdf_flag_new:nn {annot/Field/submit} %name is wrong ...
- {
- Include/Exclude = 0,
- IncludeNoValueFields = 1,
- ExportFormat = 2,
- GetMethod = 3, % if ExportFormat=0 -> =0 to
- SubmitCoordinates = 4, % if ExportFormat=0 -> =0 to
- XFDF = 5,
- IncludeAppendSaves = 6,
- IncludeAnnotations = 7,
- SubmitPDF = 8,
- CanonicalFormat = 9,
- ExclNonUserAnnots = 10,
- ExclFKey = 11,
- EmbedForm = 12
- }
-
-% #1: type, e.g. annot/Link
-% #2: name of flag, e.g. Print
-\cs_new_protected:Npn \pdf_flag_set:nn #1 #2
- {
- \bitsetSet { @@_#1_flag }
- { \prop_item:cn {c_@@_flag_#1_prop} {#2} }
- }
-
-\cs_new_protected:Npn \pdf_flag_clear:nn #1 #2
- {
- \bitsetClear{ @@_#1_flag }
- { \prop_item:cn {c_@@_flag_#1_prop} {#2} }
- }
-
-%flags are output as decimals.
-\cs_new:Npn \pdf_flag_use:n #1
- {
- \bitsetGetDec { @@_#1_flag }
- }
-%</package>
-% \end{macrocode}
% \subsection{Destinations}
% \begin{NOTE}{UF}
% I'm unsure about the backend code of the rectangle (FitR) variant. Should it
diff --git a/newpackages/hyp-field-checkbox.sty b/newpackages/hyp-field-checkbox.sty
index efef5ca..ec6ff51 100644
--- a/newpackages/hyp-field-checkbox.sty
+++ b/newpackages/hyp-field-checkbox.sty
@@ -7,6 +7,48 @@
%\def\DefaultHeightofCheckBox{\normalbaselineskip}
%\def\DefaultWidthofCheckBox{\normalbaselineskip}
+%\pdf_flag_new:nn {annot/Field} %name is wrong ... form?? it is not really an annot,
+% {
+% ReadOnly = 0,
+% Required = 1,
+% NoExport = 2,
+% Multiline = 12,%Tx
+% Password = 13,
+% NoToggleToOff = 14,%Btn, radio button
+% Radio = 15,%Btn: Radio: 15=1, 16=0
+% Pushbutton = 16,%Btn: Checkbox: 15=0, 16=0
+% %Btn: Pushbutton: 16=1
+% Combo = 17,%Ch: Combo=1 List=0
+% Edit = 18,%Ch, Combo=1 -> + edit field
+% Sort = 19,%Ch, not relevant for view...
+% FileSelect = 20,%Tx
+% MultiSelect = 21,%Ch
+% DoNotSpellCheck = 22,%Tx, Ch (if Combo + Edit set)
+% DoNotScroll = 23,%Tx
+% Comb = 24,%Tx, requires MaxLen in dict
+% RadiosInUnison = 25,%Btn Radio
+% RichText = 25,%Tx
+% CommitOnSelChange = 26
+% }
+%
+%\pdf_flag_new:nn {annot/Field/submit} %name is wrong ...
+% {
+% Include/Exclude = 0,
+% IncludeNoValueFields = 1,
+% ExportFormat = 2,
+% GetMethod = 3, % if ExportFormat=0 -> =0 to
+% SubmitCoordinates = 4, % if ExportFormat=0 -> =0 to
+% XFDF = 5,
+% IncludeAppendSaves = 6,
+% IncludeAnnotations = 7,
+% SubmitPDF = 8,
+% CanonicalFormat = 9,
+% ExclNonUserAnnots = 10,
+% ExclFKey = 11,
+% EmbedForm = 12
+% }
+%
+
\cs_generate_variant:Nn \pdf_xform_wd:n {e}
\cs_generate_variant:Nn \pdf_xform_ht:n {e}
\cs_generate_variant:Nn \pdf_xform_dp:n {e}
More information about the latex3-commits
mailing list.