[latex3-commits] [git/LaTeX3-latex3-pdfresources] renamedict77: attachfile changes (bc561ec)

Ulrike Fischer fischer at troubleshooting-tex.de
Sat May 2 01:16:01 CEST 2020


Repository : https://github.com/latex3/pdfresources
On branch  : renamedict77
Link       : https://github.com/latex3/pdfresources/commit/bc561ec23f916cb9edd393b60c6bc3c047bcb029

>---------------------------------------------------------------

commit bc561ec23f916cb9edd393b60c6bc3c047bcb029
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Sat May 2 01:16:01 2020 +0200

    attachfile changes


>---------------------------------------------------------------

bc561ec23f916cb9edd393b60c6bc3c047bcb029
 experiments/new-attachfile.tex |  16 ++-
 l3pdffile.dtx                  |   1 -
 newpackages/new-attachfile.sty | 282 ++++++++++++++++++++---------------------
 3 files changed, 151 insertions(+), 148 deletions(-)

diff --git a/experiments/new-attachfile.tex b/experiments/new-attachfile.tex
index dceb528..12a2890 100644
--- a/experiments/new-attachfile.tex
+++ b/experiments/new-attachfile.tex
@@ -11,7 +11,15 @@
 \begin{document}
 abc
 \makeatletter 
-\attachfilesetup{color=red}
+\attachfilesetup{color=red,author=Müsterhaße}
+\ExplSyntaxOn
+\tl_show:N \l__atfi_annot_color_tl
+\tl_show:N \l__atfi_setup_keyval_tl
+\keys_set:no {atfi} { \l__atfi_setup_keyval_tl }
+\pdfdict_show:n{annot/FileAttachment}
+\tl_show:N \l__atfi_annot_color_tl
+
+\ExplSyntaxOff
 \attachfile[icon=Graph,mimetype=text/plain,color=red]{catalogue.tex} some text
 \atfi at acroPaperclip
 \atfi at acroTag
@@ -19,9 +27,9 @@ abc
 \atfi at acroPushPin
 
 \ExplSyntaxOn
-\keys_set:nn {atfi}{mimetype=text/mix}
-\pdfdict_show:n{file}
-\pdfdict_show:n{file/FileSpec}
+%\keys_set:nn {atfi}{mimetype=text/mix}
+%\pdfdict_show:n{file}
+%\pdfdict_show:n{file/FileSpec}
 \ExplSyntaxOff
 \end{document}
 \__pdf_backend_xform_if_exist:nTF { atfi at appearancebox }{true}{false}
diff --git a/l3pdffile.dtx b/l3pdffile.dtx
index fc0c98e..8d714ff 100644
--- a/l3pdffile.dtx
+++ b/l3pdffile.dtx
@@ -220,7 +220,6 @@
 %    \begin{macrocode}
 %<@@=pdf>
 \cs_set_eq:NN \@@_file_filename_convert:nN \pdftool_textstringhex_print:nN
-\cs_show:N\@@_file_filename_convert:nN
 %    \end{macrocode}
 %    \begin{macrocode}
 % https://github.com/latex3/latex3/issues/711
diff --git a/newpackages/new-attachfile.sty b/newpackages/new-attachfile.sty
index 042ee1b..93ba501 100644
--- a/newpackages/new-attachfile.sty
+++ b/newpackages/new-attachfile.sty
@@ -51,18 +51,19 @@
 \DeclareBoolOption{draft}
 \DeclareComplementaryOption{final}{draft}
 
+% need a
+\DeclareRobustCommand{\atfi at pdfstringdef}[2]{%
+  \pdfstringdef\atfi at temp@string{#2}%
+  \edef#1{\atfi at temp@string}%
+}
+
+
 % keyval setup is stored in a list. It should be executed locally to be
 % able to change the dictionaries in a group
 
 \ExplSyntaxOn
+% message
 \cs_new:Npn \__atfi_clist_display:n #1 {*~#1\\}
-
-\tl_new:N \l__atfi_setup_keyval_tl
-\tl_new:N \l__atfi_annot_icon_tl
-\tl_new:N \l__atfi_annot_color_tl
-\tl_new:N \l__atfi_filename_tl
-\color_set:nnn {__atfi_annot_color}{rgb}{1,0.9255,0.7765}
-
 \msg_new:nnn
   { atfi }
   { unknown-choice }
@@ -73,22 +74,58 @@
     An~empty~value~removes~the~setting.
   }
 
+\msg_new:nnn
+  { atfi }
+  { no-bool }
+  {
+    Value~'#2'~is~invalid~for~key~'#1'.\\
+    The~key~accepts~only~the~choices\\
+    *~true\\
+    *~false \\
+    No~value~is~equivalent~to~using~`true`.
+  }
+% variables
+% probably generic ....
+\pdfdict_new:n   {annot/FileAttachment}
+\pdfdict_put:nnn {annot/FileAttachment}{Subtype}{/FileAttachment}
+\pdfdict_new:n   {annot/FileAttachment/AP} % appearance
+
+%
+\color_set:nnn {__atfi_annot_color}{rgb}{1,0.9255,0.7765}
+\bitsetReset {__atfi_annotFlags} %
+
+\tl_new:N \l__atfi_tmpa_tl
+% key-val
+
+\tl_new:N   \l__atfi_setup_keyval_tl
+\tl_new:N   \l__atfi_filename_tl
+
+\tl_new:N   \l__atfi_annot_icon_tl
+\tl_new:N   \l__atfi_annot_color_tl
+\fp_new:N   \l__atfi_annot_scale_fp
+\bool_new:N \l__atfi_annot_print_bool
+\bool_new:N \l__atfi_annot_appearance_bool
+\bool_set_true:N \l__atfi_annot_appearance_bool
 
 \NewDocumentCommand\attachfilesetup { m }
  {
    \tl_put_right:Nn \l__atfi_setup_keyval_tl {, #1 }
  }
 
+% defaults:
+
+\attachfilesetup
+  {
+    ,icon=PushPin
+    ,date=\file_timestamp:n{\jobname.log}
+  }
+
 % replace later
 \cs_new_protected:Npn \atfi at setup #1
   {
     \keys_set:nn {atfi} { #1 }
   }
 
-% probably generic ....
-\pdfdict_new:n   {annot/FileAttachment}
-\pdfdict_put:nnn {annot/FileAttachment}{Subtype}{/FileAttachment}
-\pdfdict_new:n   {annot/FileAttachment/AP} % appearance
 
 \keys_define:nn { atfi }
   {
@@ -108,8 +145,10 @@
         \tl_if_empty:nF { #1 }
           {
            \pdftool_textstringhex_print:nN  { #1 } \l__atfi_filename_tl %variable
+           \pdfdict_put:nnx { file/FileSpec } {F} { \l__atfi_filename_tl }
           }
       }
+    ,filename .groups:n = {embed}
     %ucfilespec -> embed step
     %checksum   -> bool to suppress the checksum
     %creationdate ->additional /CreationDate in FileSpec-dict
@@ -138,166 +177,123 @@
           { Data, Graph, PushPin, Tag }
           { \exp_not:n {#1} }
       }
-    ,icon     .groups:n =  { attach }
+    ,icon     .groups:n =  { annot }
     %         initial: PushPin, but should be set only in the command
     ,color    .tl_set:N = \l__atfi_annot_color_tl
-    ,color    .groups:n =  { attach }
+    ,color    .groups:n =  { annot }
     ,color    .initial:n = { __atfi_annot_color }
     %color    -> attach step, affects icon
     %         decide allowed syntax of expressions ...
     %         initial: 1 0.9255 0.7765
 
     %% annotation dict (attach step)
-    %date     /M(...)
-    %         initial  \file_timestamp:n {\jobname.log}
-
+    ,date     .code:n  =
+      {  % escaping??
+         \pdfdict_put:nnn {annot/FileAttachment}{M}{(#1)}
+      }
     %annotname /NM (..) (unique name)
     %          no initial value
-
+    ,annotname    .code:n    =
+      {
+        %code to sanitize the value
+        %need an expl3 variant ...
+        \atfi at pdfstringdef\l__atfi_tmpa_tl { #1 }
+        \pdfdict_put:nnx {annot/FileAttachment}{NM}{(\l__atfi_tmpa_tl)}
+      }
+    ,annotname    .groups:n =  { annot }
+    %          no initial value
     ,author    .code:n    =
       {
-        %!! code to sanitize the value
-        \pdfdict_put:nnn {annot/FileAttachment}{T}{#1}
+        %code to sanitize the value
+        %need an expl3 variant ...
+        \atfi at pdfstringdef\l__atfi_tmpa_tl { #1 }
+        \pdfdict_put:nnx {annot/FileAttachment}{T}{(\l__atfi_tmpa_tl)}
       }
-    ,author     .groups:n =  { attach }
+    ,author     .groups:n =  { annot }
     %          no initial value
 
     % description /Contents
+    ,description    .code:n    =
+      {
+        %code to sanitize the value
+        %need an expl3 variant ...
+        \atfi at pdfstringdef\l__atfi_tmpa_tl { #1 }
+        \pdfdict_put:nnx {annot/FileAttachment}{Contents}{(\l__atfi_tmpa_tl)}
+      }
+    ,description     .groups:n =  { annot }
 
     ,subject    .code:n    =
       {
-        %!! code to sanitize the value
-        \pdfdict_put:nnn {annot/FileAttachment}{Subj}{#1}
+      %code to sanitize the value
+        %need an expl3 variant ...
+        \atfi at pdfstringdef\l__atfi_tmpa_tl { #1 }
+        \pdfdict_put:nnn {annot/FileAttachment}{Subj}{(\l__atfi_tmpa_tl)}
       }
-    ,subject     .groups:n =  { attach }
-
+    ,subject     .groups:n =  { annot }
+    ,appearance  .bool_set:N = \l__atfi_annot_appearance_bool
+    ,appearance  .groups:n =  { annot }
     % appearance: decides if the appearance dict is insert. drop?
-
+    ,print .choice:
+    ,print / false .code:n =
+      {
+        \bool_set_false:N \__atfi_annot_print_bool
+        \bitsetClear { __atfi_annotFlags }{\prop_item:Nn\c_pdfannot_flags_prop {Print}}
+        \pdfdict_put:nnx {annot/FileAttachment}{F}{\bitsetGetDec { __atfi_annotFlags }}
+      }
+    ,print / true .code:n =
+      {
+        \bool_set_true:N \__atfi_annot_print_bool
+        \bitsetSet { __atfi_annotFlags }{\prop_item:Nn\c_pdfannot_flags_prop {Print}}
+        \pdfdict_put:nnx {annot/FileAttachment}{F}{\bitsetGetDec { __atfi_annotFlags }}
+      }
+    ,print    .default:n = true
+    ,print / unknown .code:n =
+     {
+       \msg_warning:nnxx { atfi} { no-bool }
+         { print }
+         { \exp_not:n {#1} }
+     }
+    ,print .groups:n = { annot }
     % print: sets /F flag, also boolean used in the no-XXX command
-
-    % scale :scales the icon/annot
-
-    %   timezone,: ignored (we take \file_timestamp)
+    ,zoom .choice:
+    ,zoom / false .code:n =
+      {
+        \bool_set_false:N \__atfi_annot_zoom_bool
+        \bitsetSet { __atfi_annotFlags }{\prop_item:Nn\c_pdfannot_flags_prop {NoZoom}}
+        \pdfdict_put:nnx {annot/FileAttachment}{F}{\bitsetGetDec { __atfi_annotFlags }}
+      }
+    ,zoom / true .code:n =
+      {
+        \bool_set_true:N \__atfi_annot_zoom_bool
+        \bitsetClear { __atfi_annotFlags }{\prop_item:Nn\c_pdfannot_flags_prop {NoZoom}}
+        \pdfdict_put:nnx {annot/FileAttachment}{F}{\bitsetGetDec { __atfi_annotFlags }}
+      }
+    ,zoom / unknown .code:n =
+     {
+       \msg_warning:nnxx { atfi} { no-bool }
+         { zoom }
+         { \exp_not:n {#1} }
+     }
+    ,print .groups:n = { annot }
+    ,scale .fp_set:N = \l__atfi_annot_scale_fp
+    ,scale .initial:n = 1
   }
 
-\bitsetReset {__atfi_annotFlags}
+
 \ExplSyntaxOff
-%\def\atfi at mimetype{}
-%\define at key{AtFi}{mimetype}{%
-%  \edef\atfi at mimetype{#1}%
-%  % pattern matching remove as it fails with allowed types
-%  %
-%  \ifx\atfi at mimetype\ltx at empty
-%  \else
-%    \EdefEscapeName\atfi at mimetype{\atfi at mimetype}%
-%    \edef\atfi at mimetype{/Subtype/\atfi at mimetype}%
-%  \fi
+
+% more colors?
+%\define at key{AtFi}{color}{%
+%  \HyColor at AttachfileColor{#1}%
+%          \atfi at color@tex\atfi at color@inline\atfi at color@annot
+%          {attachfile2}{color}%
 %}
-\define at key{AtFi}{icon}{%
-  \def\atfi at icon{/Name/#1}%
-  \def\atfi at icon@icon{#1}%
-}
-\atfi at setup{icon=PushPin}
-\define at key{AtFi}{color}{%
-  \HyColor at AttachfileColor{#1}%
-          \atfi at color@tex\atfi at color@inline\atfi at color@annot
-          {attachfile2}{color}%
-}
-%\atfi at setup{color=1 0.9255 0.7765}
-\def\atfi at pad@ii#1{%
-  \ifnum#1>9 %
-    \number#1%
-  \else
-    0\number#1%
-  \fi%
-}
-\let\atfi at timezone\ltx at empty
-\define at key{AtFi}{timezone}{\def\atfi at timezone{#1}}
-\edef\atfi at time{\the\time}
-\def\atfi at hours{%
-  \numexpr\dimexpr0.01667\dimexpr\atfi at time sp\relax\relax\relax
-}
-\def\atfi at minutes{%
-  \numexpr\atfi at time-60*\atfi at hours\relax
-}
-\def\atfi at seconds{0}
-\ExplSyntaxOn
-\def\atfi at date{%
-  /M(\file_timestamp:n{\jobname.log})%
-}
-\ExplSyntaxOff
-\define at key{AtFi}{date}{%
-  \EdefEscapeString\atfi at date{#1}%
-  \edef\atfi at date{/M(\atfi at date)}%
-}
-\DeclareRobustCommand{\atfi at pdfstringdef}[2]{%
-  \pdfstringdef\atfi at temp@string{#2}%
-  \edef#1{\atfi at temp@string}%
-}
-\def\atfi at NoValue{\NoValue}
-\def\atfi at DefNoValueName#1#2#3{%
-  \def#1{#3}%
-  \ifx#1\atfi at NoValue
-    \let#1\ltx at empty
-  \else
-    \atfi at pdfstringdef#1{#1}%
-    \edef#1{/#2(#1)}%
-  \fi
-}
-\let\atfi at annotname\ltx at empty
-\define at key{AtFi}{annotname}[\NoValue]{%
-  \atfi at DefNoValueName\atfi at annotname{NM}{#1}%
-}
-\def\atfi at author{}
-\define at key{AtFi}{author}[\NoValue]{%
-  \atfi at DefNoValueName\atfi at author{T}{#1}%
-}
-\def\atfi at description{}
-\define at key{AtFi}{description}[\NoValue]{%
-  \atfi at DefNoValueName\atfi at description{Contents}{#1}%
-}
-\def\atfi at subject{}
-\define at key{AtFi}{subject}[\NoValue]{%
-  \atfi at DefNoValueName\atfi at subject{Subj}{#1}%
-}
-\DeclareBoolOption[true]{print} % should set boolean and
-%\bitsetSet{__atfi_annotFlags}{\prop_item:Nn\c__pdf_annot_flag_prop:{Print}}
-
-\DeclareBoolOption[true]{zoom} %should set boolean and
-%\bitsetSet{__atfi_annotFlags}{\prop_item:Nn\c__pdf_annot_flag_prop:{Zoom}}
-
-\DeclareBoolOption[true]{appearance}
-\DeclareStringOption[1]{scale}
-\def\atfi at ucfilespec{}
-\define at key{AtFi}{ucfilespec}[1]{%
-  \def\atfi at ucfilespec{#1}%
-  \ifx\atfi at ucfilespec\ltx at empty
-  \else
-    \atfi at pdfstringdef\atfi at ucfilespec{#1}%
-  \fi
-}
 
-\DeclareRobustCommand{\attachfilesetup}[1]{\setkeys{AtFi}{#1}}
-\DeclareLocalOptions{%
-  annotname,%
-  appearance,%
-  author,%
-  color,%
-  date,%
-  description,%
-  icon,%
-  mimetype,%
-  print,%
-  scale,%
-  subject,%
-  ucfilespec,%
-  zoom,%
-}
-\InputIfFileExists{attachfile.cfg}{}{}
+
 \ProcessKeyvalOptions*
-\def\atfi at DisableOption{%
-  \DisableKeyvalOption[action=error,package=attachfile2]{AtFi}%
-}
+%\def\atfi at DisableOption{%
+%  \DisableKeyvalOption[action=error,package=attachfile2]{AtFi}%
+%}
 
 \DeclareRobustCommand{\notextattachfile}[2][]{%
   \begingroup





More information about the latex3-commits mailing list.