[latex3-commits] [git/LaTeX3-latex3-pdfresources] renamedict77: splitting steps, unfinished (1fa18b6)

Ulrike Fischer fischer at troubleshooting-tex.de
Sun May 3 00:52:30 CEST 2020


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

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

commit 1fa18b64954e2eb6eae2b537be281049502429de
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Sun May 3 00:52:30 2020 +0200

    splitting steps,unfinished


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

1fa18b64954e2eb6eae2b537be281049502429de
 newpackages/new-attachfile.sty | 371 +++++++++++++++--------------------------
 1 file changed, 137 insertions(+), 234 deletions(-)

diff --git a/newpackages/new-attachfile.sty b/newpackages/new-attachfile.sty
index 93ba501..08fc344 100644
--- a/newpackages/new-attachfile.sty
+++ b/newpackages/new-attachfile.sty
@@ -84,6 +84,14 @@
     *~false \\
     No~value~is~equivalent~to~using~`true`.
   }
+
+\msg_new:nnn
+  { atfi }
+  { file-name-exist }
+  {
+    The name~#1~has~already~been~used.\\
+    File~\tl_to_str:n{#2}~will~not~be~embedded.\\
+  }
 % variables
 % probably generic ....
 \pdfdict_new:n   {annot/FileAttachment}
@@ -97,7 +105,7 @@
 \tl_new:N \l__atfi_tmpa_tl
 % key-val
 
-\tl_new:N   \l__atfi_setup_keyval_tl
+\tl_new:N   \l__atfi_setup_keys_tl
 \tl_new:N   \l__atfi_filename_tl
 
 \tl_new:N   \l__atfi_annot_icon_tl
@@ -109,7 +117,7 @@
 
 \NewDocumentCommand\attachfilesetup { m }
  {
-   \tl_put_right:Nn \l__atfi_setup_keyval_tl {, #1 }
+   \tl_put_right:Nn \l__atfi_setup_keys_tl {, #1 }
  }
 
 % defaults:
@@ -295,21 +303,27 @@
 %  \DisableKeyvalOption[action=error,package=attachfile2]{AtFi}%
 %}
 
-\DeclareRobustCommand{\notextattachfile}[2][]{%
-  \begingroup
-    \atfi at setup{#1}%
-    \ifatfi at print
-      \leavevmode
-      \begingroup
-        \HyColor at UseColor\atfi at color@tex
+\ExplSyntaxOn
+\NewDocumentCommand \notextattachfile { O{} m }
+  {
+    \group_begin:
+    % groups?
+    \keys_set:no {atfi} { \l__atfi_setup_keys_tl }
+    \keys_set:n  {atfi} { #1 }
+    \bool_if:NTF \l__atfi_annot_print_bool
+      {
+        \mode_leave_vertical:
+        \group_begin:
+        \exp_args:NV \color_select:n \l__atfi_annot_color_tl
         #2\strut
-      \endgroup
-    \else
-      \sbox\ltx at zero{#2\strut}%
-      \makebox[\wd0]{}%
-    \fi
-  \endgroup
-}
+        \group_end:
+      }
+      {
+        \phantom{#2\strut}
+      }
+    \group_end:
+  }
+\ExplSyntaxOff
 \atfi at DisableOption{draft}%
 \atfi at DisableOption{final}%
 \ifatfi at draft
@@ -327,41 +341,38 @@
   }%
    \expandafter\endinput
 \fi
-%\input{atfi-generic.def}
-\define at key{AtFi at file}{Size}{%
-  \edef\atfi at params{\atfi at params/Size #1}%
-}
+
 \ExplSyntaxOn
-\def\atfi at embedfile#1
-  {%
-  \pdfobject_if_exist:nF { atfi at fileobj@#1 }
-   {
-     %keys for dict entries ...
-     \pdffile_embed:nn { atfi at fileobj@#1 }{ #1 }
-   }
+% embed the file and create the filespec dictionary:
+\cs_new_protected:Npn \__atfi_file_embed:nn #1 #2 % #1 keys, #2 symbolic name, #3 file name
+  {
+    \pdfobject_if_exist:nTF { g__atfi_file_obj_#2 }
+      {
+        % message ...
+        \msg_warning:nnnn {atfi}{name-exist}{#2}{#3}
+      }
+      {
+       \group_begin:
+       %keys for dict entries ...
+       \keys_set_groups:nnV {atfi}{embed} \l__atfi_setup_keys_tl
+       \keys_set_groups:nnn {atfi}{embed} {#1}
+       \pdffile_embed:nn { g__atfi_file_obj_#2 }{ #3 }
+       \group_end:
+      }
   }
 
-% we probably need an xform by icon ...
-
-\def\atfi at xform{%
-  \pdf_xform_if_exist:nF { atfi at appearancebox }
-    {
-      \pdf_xform_new:nnn
-        { atfi at appearancebox }
-        { }
-        { \usebox\atfi at appearancebox }
-    }
-  %\immediate\pdfxform\atfi at appearancebox
-  %\edef\atfi at appearanceobj{\the\pdflastxform}%
-}
-
+% create the appearance xform:
+\cs_new_protected:Npn \__atfi_annot_xform_appearance:n
+  {
+    \pdf_xform_if_exist:nF { g__atfi_annot_iconxform_#1 }
+      {
+        \pdf_xform_new:nnn
+          { g__atfi_annot_iconxform_#1 }
+          { } % attributes?
+          { \use:c { __atfi_annot_print_icon_#1 } }
+      }
+  }
 
-\let\atfi at xform@icon\atfi at xform
-%\def\atfi at refxform#1{%
-%  %\pdf_xform_ref:n { #1 }
-%  \pdf_xform_use:n { atfi at appearancebox }
-%  %\pdfrefxform#1\relax
-%}
 
 \def\atfi at insert@file at annot#1{%
   \rule{0pt}{0pt}%
@@ -438,133 +449,21 @@
   \fi
 }
 
-%\newif\ifatfi at checksum
-%\define at key{AtFi at file}{CheckSum}{%
-%  \atfi at checksumtrue
-%  \edef\atfi at params{\atfi at params/CheckSum<#1>}%
-%}
-%\newif\ifatfi at creationdate
-%\define at key{AtFi at file}{CreationDateTZ}{%
-%  \ifatfi at creationdate
-%  \else
-%    \atfi at creationdatetrue
-%    \edef\atfi at params{%
-%      \atfi at params
-%      /CreationDate(#1)%
-%    }%
-%  \fi
-%}
-%\define at key{AtFi at file}{CreationDate}{%
-%  \ifatfi at creationdate
-%  \else
-%    \atfi at creationdatetrue
-%    \edef\atfi at params{%
-%      \atfi at params
-%      /CreationDate(#1\atfi at timezone)%
-%    }%
-%  \fi
-%}
-\newif\ifatfi at moddate
-\define at key{AtFi at file}{ModDateTZ}{%
-  \ifatfi at moddate
-  \else
-    \atfi at moddatetrue
-    \edef\atfi at params{%
-      \atfi at params
-      /ModDate(#1)%
-    }%
-  \fi
-}
-\define at key{AtFi at file}{ModDate}{%
-  \ifatfi at moddate
-  \else
-    \atfi at moddatetrue
-    \edef\atfi at params{%
-      \atfi at params
-      /ModDate(D:#1\atfi at timezone)%
-    }%
-  \fi
-}
-%\let\atfi at temp\ltx at one
-%\ltx at IfUndefined{pdf at filesize}{%
-%  \let\atfi at temp\ltx at zero
-%}{}
-%\ltx at IfUndefined{pdf at filemoddate}{%
-%  \let\atfi at temp\ltx at zero
-%}{}
-%\ltx at IfUndefined{pdf at filemdfivesum}{%
-%  \let\atfi at temp\ltx at zero
-%}{}
-%\ifcase\atfi at temp
-%  \let\atfi at pdftexdata\ltx at gobble
-%\or
-%  \def\atfi at pdftexdata#1{%
-%    \edef\atfi at temp{\pdf at filesize{#1}}%
-%    \ifx\atfi at temp\ltx at empty
-%    \else
-%      \setkeys{AtFi at file}{Size=\atfi at temp}%
-%      \edef\atfi at temp{\pdf at filemoddate{#1}}%
-%      \ifx\atfi at temp\ltx at empty
-%      \else
-%        \setkeys{AtFi at file}{ModDateTZ=\atfi at temp}%
-%      \fi
-%      \edef\atfi at temp{\pdf at filemdfivesum{#1}}%
-%      \ifx\atfi at temp\ltx at empty
-%      \else
-%        \setkeys{AtFi at file}{CheckSum=\atfi at temp}%
-%      \fi
-%    \fi
-%  }%
-%\fi
-%atfi file unneeded
-%\atfi at DisableOption{nofiles}
+
+
+
 \def\atfi at attachfile#1#2{%
   \atfi at setup{#1}%
   \atfi at embedfile{#2}%
-  \atfi at set@appearance at icon
+
   %\atfi at flags@to at int %flags are set in setup
   \atfi at insert@file at annot{#2}%
   \endgroup
 }
-\newlength{\atfi at appearancewidth}
-\newlength{\atfi at appearanceheight}
-\newlength{\atfi at appearancedepth}
-\newsavebox{\atfi at appearancebox}
+
 \ExplSyntaxOn
-\def\atfi at set@appearance at icon{%
-  \ltx at IfUndefined{atfi at appobj@\l__atfi_annot_icon_tl}{%
-    \savebox{\atfi at appearancebox}{%
-      \@nameuse{atfi at acro\l__atfi_annot_icon_tl}%
-    }%
-    \expandafter
-    \xdef\csname atfi at appwidth@\l__atfi_annot_icon_tl\endcsname{%
-      \the\wd\atfi at appearancebox
-    }%
-    \expandafter
-    \xdef\csname atfi at appheight@\l__atfi_annot_icon_tl\endcsname{%
-      \the\ht\atfi at appearancebox
-    }%
-    \expandafter
-    \xdef\csname atfi at appdepth@\l__atfi_annot_icon_tl\endcsname{%
-      \the\dp\atfi at appearancebox
-    }%
-    \atfi at xform@icon
-    \global\expandafter\let
-        \csname atfi at appobj@\l__atfi_annot_icon_tl\endcsname
-        \atfi at appearanceobj
-  }{%
-  }%
-  % optimization: \setlength dropped
-  \atfi at appearancewidth=%
-      \@nameuse{atfi at appwidth@\l__atfi_annot_icon_tl}\relax
-  \atfi at appearanceheight=%
-      \@nameuse{atfi at appheight@\l__atfi_annot_icon_tl}\relax
-  \atfi at appearancedepth=%
-      \@nameuse{atfi at appdepth@\l__atfi_annot_icon_tl}\relax
-  \expandafter\let\expandafter\atfi at appearanceobj
-      \csname atfi at appobj@\l__atfi_annot_icon_tl\endcsname
-}
-\ExplSyntaxOff
+
+
 \def\atfi at set@appearance#1{%
   \savebox{\atfi at appearancebox}{#1}%
   \atfi at appearancewidth=\wd\atfi at appearancebox
@@ -591,39 +490,40 @@
     \atfi at insert@file at annot{#2}%
   \endgroup
 }
-\DeclareRobustCommand{\attachfile}[1][]{%
-  \begingroup
-    \let\do\@makeother
-    \dospecials
-    \catcode`\{=1\relax
-    \catcode`\}=2\relax
-    \atfi at attachfile{#1}%
-}
-\DeclareRobustCommand{\textattachfile}[1][]{%
-  \begingroup
-    \begingroup
-      \let\do\@makeother
-      \dospecials
-      \catcode`\{=1\relax
-      \catcode`\}=2\relax
-      \atfi at textattachfile{#1}%
-}
-\DeclareRobustCommand{\noattachfile}[1][]{%
-  \begingroup
-    \atfi at setup{#1}%
-    \atfi at set@appearance at icon
-    \ifatfi at print
-      \expandafter
-      %\atfi at refxform\csname atfi at appobj@\atfi at icon@icon\endcsname %???
-      \pdf_xform_use:n { atfi at appearancebox } %icon, is use meant here??
-    \else
-      \makebox[\atfi at appearancewidth]{}%
-    \fi
-  \endgroup
-}
+\DeclareRobustCommand{\attachfile}[2][]
+  {
+    \group_begin:
+    % keys #1
+    %\tl_to_str for #2?? file_name??
+    \atfi at attachfile{#2}%
+    \group_end
+  }
+
+\DeclareRobustCommand{\textattachfile}[3][]
+  {
+    \group_begin:
+    % keys #1
+    \atfi at textattachfile{#2}{#3}%
+    \group_end:
+  }
+
+\DeclareRobustCommand{\noattachfile}[1][]
+  {
+    \group_begin:
+    % key #1
+    \__atfi_annot_store_appearancebox: %????
+    \bool_if:NTF \l__atfi_annot_print_bool
+      {
+        \pdf_xform_use:n { atfi at appearancebox\l__atfi_annot_icon_tl } %icon, is use meant here??
+      }
+      {
+        \makebox[\atfi at appearancewidth]{}% \strut?
+      }
+    \group_end:
+  }
 
 %data for the icons
-\ExplSyntaxOn
+
 
 \cs_new_protected:Npn \__atfi_color_to_rgb_seq:nN #1 #2 % #1 name #2 seq
  {
@@ -637,7 +537,7 @@
 \cs_generate_variant:Nn \__atfi_color_to_rgb_seq:nN {oN}
 \cs_new:Npn \__atfi_arg_braced:n #1 {{#1}}
 
-\cs_new_protected:Npn \atfi at acroGraph@data
+\cs_new_protected:Npn \l__atfi_annot_icon_graph_tl
   {
     \__draw_backend_scope_begin:
     \__draw_backend_color_fill_gray:n {0.5}
@@ -672,18 +572,8 @@
     \__draw_backend_fill:
     \__draw_backend_scope_end:
   }
-\cs_new_protected:Npn \atfi at acroGraph
-  {
-    \raisebox{-1.5bp}
-      {
-        \parbox[b][20bp]{22bp}
-          {
-            \rule{0pt}{0pt}\atfi at acroGraph@data
-          }
-      }
-  }
 
-\cs_new_protected:Npn {\atfi at acroPaperclip@data}
+\cs_new_protected:Npn {\l__atfi_annot_icon_Paperclip_tl}
   {
     \__draw_backend_scope_begin:
     \__draw_backend_color_stroke_gray:n {0.75}
@@ -744,18 +634,9 @@
     \__draw_backend_scope_end:
     }
 
-\cs_new_protected:Npn \atfi at acroPaperclip
-  {
-    \raisebox{-1.25bp}
-      {
-        \parbox[b][21bp]{12bp}
-          {
-            \rule{0pt}{0pt}\atfi at acroPaperclip@data
-          }
-      }
-  }
 
-\cs_new_protected:Npn \atfi at acroPushPin@data
+
+\cs_new_protected:Npn \l__atfi_annot_icon_PushPin_tl
   {
      \__draw_backend_scope_begin:
      \__draw_backend_linewidth:n {1bp}
@@ -793,18 +674,8 @@
      \__draw_backend_stroke:
      \__draw_backend_scope_end:
   }
-\cs_new_protected:Npn \atfi at acroPushPin
-  {
-    \raisebox{-1.25bp}
-      {
-        \parbox[b][14bp]{24bp}
-          {
-            \rule{0pt}{0pt}\atfi at acroPushPin@data
-          }
-      }
-   }
 
-\cs_new_protected:Npn \atfi at acroTag@data
+\cs_new_protected:Npn \l__atfi_annot_icon_Tag_tl
   {
     \__draw_backend_scope_begin:
     \__draw_backend_color_fill_gray:n {0.5}
@@ -870,19 +741,51 @@
     \__draw_backend_scope_end:
   }
 
+\cs_new_protected:Npn \__atfi_annot_print_icon_Graph:
+  {
+    \raisebox{-1.5bp}
+      {
+        \parbox[b][20bp]{22bp}
+          {
+            \rule{0pt}{0pt}\l__atfi_annot_icon_Graph_tl
+          }
+      }
+  }
+
+\cs_new_protected:Npn \__atfi_annot_print_icon_Paperclip:
+  {
+    \raisebox{-1.25bp}
+      {
+        \parbox[b][21bp]{12bp}
+          {
+            \rule{0pt}{0pt}\l__atfi_annot_icon_Paperclip_tl
+          }
+      }
+  }
+
+\cs_new_protected:Npn \__atfi_annot_print_icon_PushPin:
+  {
+    \raisebox{-1.25bp}
+      {
+        \parbox[b][14bp]{24bp}
+          {
+            \rule{0pt}{0pt}\l__atfi_annot_icon_PushPin_tl
+          }
+      }
+   }
 
-\cs_new_protected:Npn \atfi at acroTag
+
+\cs_new_protected:Npn \__atfi_annot_print_icon_Tag:
   {
     \raisebox{-1.6bp}
       {
         \parbox[b][17bp]{25bp}
           {
-            \rule{0pt}{0pt}\atfi at acroTag@data
+            \rule{0pt}{0pt}\l__atfi_annot_icon_Tag_tl
           }
       }
    }
 
-\ExplSyntaxOff
 
 \endinput
 %%





More information about the latex3-commits mailing list.