[latex3-commits] [git/LaTeX3-latex3-pdfresources] splitting: changing emdeddedfiles handling (0655407)

Ulrike Fischer fischer at troubleshooting-tex.de
Thu Jul 2 00:33:12 CEST 2020


Repository : https://github.com/latex3/pdfresources
On branch  : splitting
Link       : https://github.com/latex3/pdfresources/commit/065540789629d53495fe25d623ba736654f8ad3d

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

commit 065540789629d53495fe25d623ba736654f8ad3d
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Thu Jul 2 00:33:12 2020 +0200

    changing emdeddedfiles handling


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

065540789629d53495fe25d623ba736654f8ad3d
 experiments/embedfiles.tex | 11 ++++++--
 l3backend-pdf-extra.dtx    | 29 ++++++++++++-------
 l3pdffile.dtx              | 70 ++++++++++++++++++++++------------------------
 3 files changed, 62 insertions(+), 48 deletions(-)

diff --git a/experiments/embedfiles.tex b/experiments/embedfiles.tex
index 4a960e2..289a47d 100644
--- a/experiments/embedfiles.tex
+++ b/experiments/embedfiles.tex
@@ -27,13 +27,20 @@
 \pdfdict_put:nnn  {file/FileSpec} {AFRelationship}{/Source}
 \pdfdict_put:nnn  {file/FileSpec} {Desc}{(this~is~a~eps)}
 
-\pdffile_embed_file:nnn {testinput.txt}{grüße.tex}{example1}
+\pdffile_embed_file:nnn {testinput.txt}{xxxxx.tex}{example1}
 
 \pdfdict_put:nnn  {file/FileSpec} {AFRelationship}{/Data}
 \pdfdict_put:nnn  {file/FileSpec} {Desc}{(this~is~a~text~file)}
-\pdffile_embed_stream:nnn {testinput.txt} {mystream.txt} {example2}
+\pdffile_embed_stream:nnn {stream text} {xxxxx.txt} {example2}
 
 \prop_show:N \g__pdffile_file_embed_sources_prop
+\exp_args:Nx
+          \__pdf_backend_NamesEmbeddedFiles_add:n {\pdf_object_ref:n{example2}} 
+\exp_args:Nx
+          \__pdf_backend_NamesEmbeddedFiles_add:n {\pdf_object_ref:n{example1}} 
+
+\seq_show:N \g__pdf_backend_EmbeddedFiles_seq
+\prop_show:N \g__pdf_backend_EmbeddedFiles_named_prop
 %\pdffile_attach:n {example1}
 \group_end:
 \end{document}
diff --git a/l3backend-pdf-extra.dtx b/l3backend-pdf-extra.dtx
index 8eca66a..81ddcd0 100644
--- a/l3backend-pdf-extra.dtx
+++ b/l3backend-pdf-extra.dtx
@@ -637,34 +637,43 @@
 %</drivers>
 %    \end{macrocode}
 % \end{macro}
-% \begin{variable}{\g_@@_backend_EmbeddedFiles_seq}
+% \begin{variable}{\g_@@_backend_EmbeddedFiles_seq,\g_@@_backend_EmbeddedFiles_named_prop}
+% The sequence will hold the content of the array that is pushed out at then
+% end (not with dvips), the prop holds the obj names-names relation.
 %    \begin{macrocode}
 %<*drivers>
 \seq_new:N \g_@@_backend_EmbeddedFiles_seq
+\prop_new:N \g_@@_backend_EmbeddedFiles_named_prop
 %</drivers>
 %    \end{macrocode}
-% \begin{macro}{\@@_backend_NamesEmbeddedFiles_add:nN}
+% \begin{macro}{\@@_backend_NamesEmbeddedFiles_add:n}
 % This command saves an object reference of a filespec dictionary in the
-% EmbeddedFiles name tree.
+% EmbeddedFiles name tree. We define a prop to store the relation between
+% object name and name in the name tree.
 %    \begin{macrocode}
 %<*pdfmode|dvipdfmx|xdvipdfmx>
-\cs_new_protected:Npn  \@@_backend_NamesEmbeddedFiles_add:nN #1 #2
-    %#1 object ref , #2 in case the name must be retourned
+\cs_new_protected:Npn  \@@_backend_NamesEmbeddedFiles_add:n #1
+    %#1 object ref
     {
       \int_gincr:N \g_@@_backend_EmbeddedFiles_int
-      \tl_set:Nx #2 { \@@_backend_EmbeddedFiles_name: }
-      \seq_gput_right:Nx \g_@@_backend_EmbeddedFiles_seq { #2 ~#1 }
+      \prop_gput:Nnx \g_@@_backend_EmbeddedFiles_named_prop
+        { #1 }
+        { \@@_backend_EmbeddedFiles_name: }
+      \seq_gput_right:Nx \g_@@_backend_EmbeddedFiles_seq
+        { \@@_backend_EmbeddedFiles_name: \c_space_tl #1 }
     }
 
 %</pdfmode|dvipdfmx|xdvipdfmx>
 %<*dvips>
-\cs_new_protected:Npn  \@@_backend_NamesEmbeddedFiles_add:nN #1 #2
+\cs_new_protected:Npn  \@@_backend_NamesEmbeddedFiles_add:n #1
       {
         \int_gincr:N \g_@@_backend_EmbeddedFiles_int
-        \tl_set:Nx #2 { \@@_backend_EmbeddedFiles_name: }
+        \prop_gput:Nnx \g_@@_backend_EmbeddedFiles_named_prop
+         { #1 }
+         { \@@_backend_EmbeddedFiles_name: }
         \@@_backend_pdfmark:x
           {
-            /Name~#2~
+            /Name~\@@_backend_EmbeddedFiles_name:~
             /FS~#1~
             /EMBED
           }
diff --git a/l3pdffile.dtx b/l3pdffile.dtx
index 2a4b8fe..5c36bef 100644
--- a/l3pdffile.dtx
+++ b/l3pdffile.dtx
@@ -469,6 +469,7 @@
 % we record here the source file. This allows also to test if an object name
 % has an embedded file or is only a filespec
 
+
 \prop_new:N \g_@@_file_embed_sources_prop
 
 %#1 {source filename}
@@ -477,7 +478,7 @@
 \cs_new_protected:Npn \pdffile_embed_file:nnn #1 #2 #3
   { %               if #1 empty => only filespec
     %               if #2 empty => = #1
-    \pdf_object_if_exist:nTF { @@_#3 }
+    \pdf_object_if_exist:nTF { #3 }
       {
         \msg_error:nnn { pdffile }{ object-exists } { #3 }
       }
@@ -511,7 +512,7 @@
             \exp_args:Nnnx
               \@@_file_filespec_write:nnn
                 %#1 dict, #2 target file name, #3 object ref
-                { @@_#3 }
+                { #3 }
                 { #1 }
                 {\l_@@_file_embed_ref_tl}
           }
@@ -519,7 +520,7 @@
             \exp_args:Nnnx
               \@@_file_filespec_write:nnn
                 %#1 dict, #2 target file name, #3 object ref
-                { @@_#3 }
+                { #3 }
                 { #2 }
                 {\l_@@_file_embed_ref_tl}
           }
@@ -533,7 +534,7 @@
 \cs_new_protected:Npn \pdffile_embed_stream:nnn #1 #2 #3
   {
     %               if #2 empty => error
-    \pdf_object_if_exist:nTF { @@_#3 }
+    \pdf_object_if_exist:nTF { #3 }
       {
          \msg_error:nnn { pdffile }{ object-exists } { #3 }
       }
@@ -557,17 +558,14 @@
             \exp_args:Nnnx
               \@@_file_filespec_write:nnn
                 %#1 dict, #2 target file name, #3 object ref
-                { @@_#3 }
+                { #3 }
                 { #2 }
                 {\l_@@_file_embed_ref_tl}
           }
       }
   }
 
-\cs_new:Npn \pdffile_embed_ref:n #1 % #1 is the symbolic name used above
-  {
-    \pdf_object_ref:n {@@_#1}
-  }
+
 %    \end{macrocode}
 % \end{macro}
 
@@ -590,55 +588,55 @@
 %   case it is needed to setup up for example a collection.
 %\end{function}
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_file_check_attach_aux:nN #1  #2
+\cs_new_protected:Npn \@@_file_check_attach_aux:n #1
   {
     \prop_get:NnNTF \g_@@_file_embed_sources_prop { #1 } \l_tmpa_str
       {
         \exp_args:Nx
-          \@@_backend_NamesEmbeddedFiles_add:nN {\pdf_object_ref:n{#1}} #2
+          \__pdf_backend_NamesEmbeddedFiles_add:n {\pdf_object_ref:n{#1}}
       }
       {
         \msg_warning:nnn { pdffile } { no-file-embedded } { #1 }
       }
   }
 
-\cs_new_protected:Npn \pdffile_attach:nN #1 #2 % #1 name of filespec object, #2 in case the name must be retourned
+\cs_new_protected:Npn \pdffile_attach:n #1% #1 name of filespec object, #2 in case the name must be retourned
  {
    \@@_backend_object_if_exist:nTF { #1 }
      {
-       \@@_file_check_attach_aux:nN { #1 } #2
+       \@@_file_check_attach_aux:n { #1 }
      }
      {
        \msg_error:nnn { pdffile } { file-object-no-found } { #1 }
      }
  }
 
-\cs_new_protected:Npn \pdffile_attach:n #1 % name of filespec object
- {
-   \@@_backend_object_if_exist:nTF { #1}
-     {
-       \@@_file_check_attach_aux:nN { #1 } \l_@@_file_tmpa_tl
-     }
-     {
-       \msg_error:nnn { pdffile } { file-object-no-found } { #1 }
-     }
- }
+%\cs_new_protected:Npn \pdffile_attach:n #1 % name of filespec object
+% {
+%   \@@_backend_object_if_exist:nTF { #1}
+%     {
+%       \@@_file_check_attach_aux:nN { #1 } \l_@@_file_tmpa_tl
+%     }
+%     {
+%       \msg_error:nnn { pdffile } { file-object-no-found } { #1 }
+%     }
+% }
 
 % for anonymous objects. This allows to use the interface with objects not
 % created with l3 commands / naming. Testing if there is a file is not possible here
-\cs_new_protected:Npn \pdffile_attach_last:N #1 % #1 in case the name must be retourned
- {
-   \tl_set:Nx \l_@@_file_tmpa_tl {\pdf_object_last:}
-   \exp_args:Nx
-     \@@_backend_NamesEmbeddedFiles_add:nN { \l_@@_file_tmpa_tl } #1
- }
-
-\cs_new_protected:Npn \pdffile_attach_last:
- {
-   \tl_set:Nx \l_@@_file_tmpa_tl {\pdf_object_last:}
-   \exp_args:Nx
-     \@@_backend_NamesEmbeddedFiles_add:nN { \l_@@_file_tmpa_tl } \l_@@_file_tmpa_tl
- }
+%\cs_new_protected:Npn \pdffile_attach_last:N #1 % #1 in case the name must be retourned
+% {
+%   \tl_set:Nx \l_@@_file_tmpa_tl {\pdf_object_last:}
+%   \exp_args:Nx
+%     \@@_backend_NamesEmbeddedFiles_add:n { \l_@@_file_tmpa_tl }
+% }
+%
+%\cs_new_protected:Npn \pdffile_attach_last:
+% {
+%   \tl_set:Nx \l_@@_file_tmpa_tl {\pdf_object_last:}
+%   \exp_args:Nx
+%     \@@_backend_NamesEmbeddedFiles_add:nN { \l_@@_file_tmpa_tl } \l_@@_file_tmpa_tl
+% }
 
 
 %    \end{macrocode}





More information about the latex3-commits mailing list.