[latex3-commits] [git/LaTeX3-latex3-pdfresources] renamedict77: moved info section (efb36f8)

Ulrike Fischer fischer at troubleshooting-tex.de
Sat Apr 11 00:32:39 CEST 2020


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

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

commit efb36f8322a5d07be5220bbdc721e744a78230f8
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Sat Apr 11 00:32:39 2020 +0200

    moved info section


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

efb36f8322a5d07be5220bbdc721e744a78230f8
 pdfresources.dtx | 251 +++++++++++++++++++++++++++++++++----------------------
 1 file changed, 149 insertions(+), 102 deletions(-)

diff --git a/pdfresources.dtx b/pdfresources.dtx
index a317662..0534d28 100644
--- a/pdfresources.dtx
+++ b/pdfresources.dtx
@@ -146,6 +146,10 @@
   {
     The~dictionary~'#1'~is~not~declared.
   }
+\msg_new:nnn  { pdfdict } { dict-already-defined  }
+  {
+    The~dictionary~'#1'~is~already~defined.
+  }
 \msg_new:nnn  { pdfdict } { empty-value }
               { The~value~for~#1~is~empty~and~will~be~ignored }
 %    \end{macrocode}
@@ -409,6 +413,16 @@
 %
 %  Currently the following names are used: ^^A!!!!! check, compare with g_@@_dict_gnames_seq
 %  \begin{verbatim}
+%  /Info           %w, \pdfinfo    -> pdfdict
+%  /Catalog            %           -> pdfdict
+%  /Catalog/AA
+%  /Catalog/OCProperties
+%  /Catalog/OutputIntents
+%  /Catalog/AcroForm
+%  /Catalog/AcroForm/DR
+%  /Catalog/AcroForm/DR/Font
+%  /Catalog/MarkInfo
+%  /Catalog/ViewerPreferences
 %  /Pages           %w,  \pagesattr ->pdfdict
 %  /backend_Page    %!!!!! consider name Page?
 %  /backend_PageN   %!!!!! consider name PageN?
@@ -420,16 +434,6 @@
 %  /PageN/Resources/Pattern
 %  /PageN/Resources/Shading
 %  /PageN/Resources/Properties
-%  /Info           %w, \pdfinfo ->pdfdict
-%  /Catalog            % -> pdfdict
-%  /Catalog/AA
-%  /Catalog/OCProperties
-%  /Catalog/OutputIntents
-%  /Catalog/AcroForm
-%  /Catalog/AcroForm/DR
-%  /Catalog/AcroForm/DR/Font
-%  /Catalog/MarkInfo
-%  /Catalog/ViewerPreferences
 %  /xform/Resources/Properties
 %  \end{verbatim}
 % \begin{macro}{\@@_dict_item:nn,\@@_dict_objref_item:nn}
@@ -447,8 +451,17 @@
   }
 %    \end{macrocode}
 % \end{macro}
-%  \begin{macro}{\@@_dict_get_g:n,\@@_dict_gname:n,\@@_dict_name:n,
-%   \@@_dict_gnew:n,\@@_dict_new:n,\g_@@_dict_gnames_seq,\g_@@_dict_names_seq}
+% \begin{macro}
+%   {
+%    \@@_dict_get_g:n,
+%    \@@_dict_gname:n,
+%    \@@_dict_name:n,
+%    \@@_dict_gnew:n,
+%    \@@_dict_new:n,
+%    \g_@@_dict_gnames_seq,
+%    \g_@@_dict_names_seq
+%   }
+%   \cs{@@_dict_get_g:n} gives back a \enquote{g} if the dictionary is global.
 %    \begin{macrocode}
 \seq_new:N \g_@@_dict_gnames_seq
 \seq_new:N \g_@@_dict_names_seq
@@ -487,7 +500,13 @@
 %global
 \cs_new_protected:Npn \@@_dict_gnew:n #1
   {
-    \prop_if_exist:cF {  \@@_dict_gname:n { #1 }  }
+    \@@_dict_if_exist:nTF { #1 }
+      {
+        \msg_error:nnn
+          { pdfdict }
+          { dict-already-defined }
+          { #1}
+       }
       {
         \tl_const:cn { c_@@_dict_/#1_g_tl } { g }
         \prop_new:c  { \@@_dict_gname:n { #1 } }
@@ -498,7 +517,13 @@
 %local
 \cs_new_protected:Npn \@@_dict_new:n #1
   {
-    \prop_if_exist:cF {  \@@_dict_name:n { #1 }  }
+    \@@_dict_if_exist:nTF { #1 }
+      {
+        \msg_error:nnn
+          { pdfdict }
+          { dict-already-defined }
+          { #1}
+       }
       {
         \tl_const:cn { c_@@_dict_/#1_g_tl } {  }
         \prop_new:c  { \@@_dict_name:n { #1 } }
@@ -520,11 +545,16 @@
 %
 %  \begin{macro}{
 %                \@@_dict_clear,
-%                \@@_dict_put:nnn,
+%                \@@_dict_handler_put:nnn,
 %                \@@_dict_get:nnN,
 %                \@@_dict_remove:nn,
 %                \@@_dict_show:n
 %                }
+%  \cs{@@_dict_handler_put:nnn} is the main command to fill the dictionaries.
+%  In simple cases it directly fill the property list, but if a handler exists
+%  this is called. It is important to use it only in places where this make sense.
+%  \cs{@@_dict_put:nnn} is a simpler variant which only fills the property list.
+%
 %    \begin{macrocode}
 
 %local + global
@@ -536,7 +566,7 @@
 
 
 %local + global
-\cs_new_protected:Npn \@@_dict_put:nnn #1 #2 #3  %#1 path, #2 name, #3 value
+\cs_new_protected:Npn \@@_dict_handler_put:nnn #1 #2 #3  %#1 path, #2 name, #3 value
   {
     \tl_if_empty:nTF { #3 }
       {
@@ -565,8 +595,25 @@
   }
 
 
-\cs_generate_variant:Nn \@@_dict_put:nnn {nxx}
+\cs_generate_variant:Nn \@@_dict_handler_put:nnn {nxx}
 
+\cs_new_protected:Npn \@@_dict_put:nnn #1 #2 #3  %#1 path, #2 name, #3 value
+  {
+    \tl_if_empty:nTF { #3 }
+      {
+        \msg_none:nnn { pdfdict }{ empty-value }{ /#1/#2 }
+      }
+      {
+       \@@_dict_if_exist:nTF { #1 }
+         {
+           \use:c { prop_\@@_dict_get_g:n{#1}put:cnn }
+             { \@@_dict_Xname:n { #1 } }{ #2 } { #3 }
+         }
+         {
+           \msg_error:nnn { pdfdict } { unknown-dict } { /#1 }
+         }
+      }
+  }
 
 %local + global
 
@@ -608,7 +655,7 @@
 %
 % \begin{macro}{ \@@_dict_map_dict_item:n }
 % \cs{@@_dict_map_dict_item:n} outputs a prop as needed in a dictionary:
-%  a list of /\meta{key} \meta{value} pairs.
+%  as a list of /\meta{key} \meta{value} pairs.
 %    \begin{macrocode}
 %local + global
 %!! Xname must be replaced later!
@@ -691,7 +738,7 @@
 
 \cs_new_protected:Npn \pdfdict_put:nnn #1 #2 #3
   {
-     \@@_dict_put:nnn { #1 }{ #2 }{ #3 }
+     \@@_dict_handler_put:nnn { #1 }{ #2 }{ #3 }
   }
 
 \cs_generate_variant:Nn \pdfdict_put:nnn {nnx}
@@ -750,7 +797,7 @@
 %     \pdfdict_remove:nn,
 %   }
 %   \begin{syntax}
-%     \cs{pdfdict_remove:n} \Arg{dictionary} \Arg{name}
+%     \cs{pdfdict_remove:nn} \Arg{dictionary} \Arg{name}
 %   \end{syntax}
 %   Removes  |/|\meta{name} and its associated \meta{value} from the \Arg{dictionary}
 %   or \Arg{local dict} (if the name-value pair has been added by
@@ -767,13 +814,76 @@
   {
     \@@_dict_remove:nn { #1 }{ #2 }
   }
-
-
 %    \end{macrocode}
+%
+% \subsection{pdfdict: \enquote{Info} (pdfinfo)}
+% \begin{NOTE}{UF}
+% path: Info
+% The info dictionary is filled by e.g. \cs{pdfinfo}. Multiple appearances of
+% \cs{pdfinfo} are concatenated, so one could end with multiple /Title or /Author entries.
+% It is then viewer dependent which one is showed, so it is better to avoid this.
+% We therefore setup a property which is filled and written to the info
+% directory in one go. According to hyperref a few odd drivers (hvtex, dvipsone, dviwind)
+% don't support arbitrary keys, but this should be handle elsewhere. Most entries are
+% strings so there is a special command for this. As entries with empty content
+% should be omitted we add a test. The string command should perhaps escape the argument,
+% but for now we are assuming that the argument is pdf safe.
+% hyperref writes to the info dictionary at the shipout of the first page --
+% probably to catch the  case that \cs{title} is issued after the begin of the document.
+% We are outputting at the last page -- this needs a second compilation but
+% this is needed anyway.
+% \end{NOTE}
+%
+% \subsubsection{\enquote{Info}/backend}
+% The backend code is already in expl3.
+% \cs{@@_backend_info_gput:nn} inserts one name/value pair.
+%
+% \subsubsection{\enquote{Info}/management}
+% \potentialclash If the primitive commands are used additionally there will
+% be double entries in the pdf with the backend pdftex and luatex.
+% How pdf viewer handles this is unpredictable.
+%
+%  \begin{function}
+%   {
+%     pdfdict: Info (global)
+%   }
+%   \begin{syntax}
+%     \cs{pdfdict_put:nnn} \{Info\} \Arg{name} \Arg{value}
+%   \end{syntax}
+%   Adds |/|\meta{name} and the \meta{value} to the Info dictionary.
+%   \meta{name} should be a valid pdf name without the leading slash,
+%   \meta{value} should be a valid pdf value. Any escaping or (re)encoding must be
+%   done explicitly.
+%   If a \meta{name} is used twice, only the last \meta{value}
+%   set will be used. The info dictionary is written at the end of the compilation,
+%   so values can be set at any time.
+%   The info dictionary expects utf8 in the strings, so a conversion like this is
+%   normally sensible:
+%   \begin{verbatim}
+%   \str_set_convert:Nnnn \l_tmpa_str { Grüße }{ utf8 } {utf8/string}
+%   \pdfdict_put:nx {Title}{(\l_tmpa_str)}
+%   \end{verbatim}
+% \end{function}
+%    \begin{macrocode}
+\@@_dict_gnew:n {Info}
+%    \end{macrocode}
+%
+% \begin{macro}{\@@_dict_Info_gpush:}
+% \cs{@@_dict_Info_gpush:} is the command that outputs the info dictionary (currently
+% in the end-of-run hooks).
+%    \begin{macrocode}
+% push to the register command / issue the special
+\cs_new_protected:Npn \@@_dict_Info_gpush:
+  {
+    \prop_map_function:cN  { \@@_dict_Xname:n {Info} } \@@_backend_info_gput:nn
+    \prop_gclear:c { \@@_dict_Xname:n {Info} }
+  }
+%    \end{macrocode}
+% \end{macro}
 % \subsection{pdfdict \enquote{Pages} (pdfpagesattr)}
 % The content of the property list associated with this dictionary name is written to the
 % /Pages object. This replaces \cs{pdfpagesattr}. This dictionary is global.
-% \subsubsection{pdfdict \enquote{Pages} pdfpagesattr/backend}
+% \subsubsection{pdfdict \enquote{Pages} (pdfpagesattr)/backend}
 % \begin{NOTE}{UF}
 %  path: Pages
 %  pdfpagesattr is a single token register which is used at the end of the compilation.
@@ -927,7 +1037,7 @@
   % sets a lua table with lualatex
   \cs_new_protected:Npn \@@_backend_Page_gput:nn #1 #2 %key,value
     {
-      \@@_dict_put:nnn {backend_Page}{ #1 }{ #2 }
+      \@@_dict_handler_put:nnn {backend_Page}{ #1 }{ #2 }
     }
   % the command to remove a default value.
   % Uses a prop with pdflatex + dvi,
@@ -953,7 +1063,7 @@
             {0}
         }
       \@@_dict_gnew:n    {backend_Page\l_@@_tmpa_tl}
-      \@@_dict_put:nnn {backend_Page\l_@@_tmpa_tl}{ #1 }{ #2 }
+      \@@_dict_handler_put:nnn {backend_Page\l_@@_tmpa_tl}{ #1 }{ #2 }
     }
   %the code to push the values, used in shipout
   %merges the two props and then fills the register in pdflatex
@@ -1050,7 +1160,7 @@
   % sets a lua table with lualatex
     \cs_new_protected:Npn \@@_backend_Page_gput:nn #1 #2
       {
-        \@@_dict_put:nnn {backend_Page}{ #1 }{ #2 }
+        \@@_dict_handler_put:nnn {backend_Page}{ #1 }{ #2 }
       }
   % the command to remove a default value.
   % Uses a prop with pdflatex + dvi,
@@ -1091,7 +1201,7 @@
   % sets a lua table with lualatex
     \cs_new_protected:Npn \@@_backend_Page_gput:nn #1 #2
       {
-        \@@_dict_put:nnn {backend_Page}{ #1 }{ #2 }
+        \@@_dict_handler_put:nnn {backend_Page}{ #1 }{ #2 }
       }
   % the command to remove a default value.
   % Uses a prop with pdflatex + dvi,
@@ -1223,70 +1333,7 @@
 
 %    \end{macrocode}
 %
-% \subsection{pdfdict: \enquote{Info} (pdfinfo)}
-% \begin{NOTE}{UF}
-% path: Info
-% The info dictionary is filled by e.g. \cs{pdfinfo}. Multiple appearances of
-% \cs{pdfinfo} are concatenated, so one could end with multiple /Title or /Author entries.
-% It is then viewer dependent which one is showed, so it is better to avoid this.
-% We therefore setup a property which is filled and written to the info
-% directory in one go. According to hyperref a few odd drivers (hvtex, dvipsone, dviwind)
-% don't support arbitrary keys, but this should be handle elsewhere. Most entries are
-% strings so there is a special command for this. As entries with empty content
-% should be omitted we add a test. The string command should perhaps escape the argument,
-% but for now we are assuming that the argument is pdf safe.
-% hyperref writes to the info dictionary at the shipout of the first page --
-% probably to catch the  case that \cs{title} is issued after the begin of the document.
-% We are outputting at the last page -- this needs a second compilation but
-% this is needed anyway.
-% \end{NOTE}
-%
-% \subsubsection{\enquote{Info}/backend}
-% The backend code is already in expl3.
-% \cs{@@_backend_info_gput:nn} inserts one name/value pair.
-%
-% \subsubsection{\enquote{Info}/management}
-% \potentialclash If the primitive commands are used additionally there will
-% be double entries in the pdf with the backend pdftex and luatex.
-% How pdf viewer handles this is unpredictable.
-%
-%  \begin{function}
-%   {
-%     pdfdict: Info (global)
-%   }
-%   \begin{syntax}
-%     \cs{pdfdict_put:nnn} \{Info\} \Arg{name} \Arg{value}
-%   \end{syntax}
-%   Adds |/|\meta{name} and the \meta{value} to the info dictionary.
-%   \meta{name} should be a valid pdf name without the leading slash,
-%   \meta{value} should be a valid pdf value. Any escaping or (re)encoding must be
-%   done explicitly.
-%   If a \meta{name} is used twice, only the last \meta{value}
-%   set will be used. The info dictionary is written at the end of the compilation,
-%   so values can be set at any time.
-%   The info dictionary expects utf8 in the strings, so a conversion like this is
-%   normally sensible:
-%   \begin{verbatim}
-%   \str_set_convert:Nnnn \l_tmpa_str { Grüße }{ utf8 } {utf8/string}
-%   \pdfdict_put:nx {Title}{(\l_tmpa_str)}
-%   \end{verbatim}
-% \end{function}
-%    \begin{macrocode}
-\@@_dict_gnew:n {Info}
-%    \end{macrocode}
-%
-% \begin{macro}{\@@_dict_Info_gpush:}
-% \cs{@@_dict_Info_gpush:} is the command that outputs the info dictionary (currently
-% in the end-of-run hooks).
-%    \begin{macrocode}
-% push to the register command / issue the special
-\cs_new_protected:Npn \@@_dict_Info_gpush:
-  {
-    \prop_map_function:cN  { \@@_dict_gname:n {Info} } \@@_backend_info_gput:nn
-    \prop_gclear:c { \@@_dict_gname:n {Info} }
-  }
-%    \end{macrocode}
-% \end{macro}
+
 %
 % \subsection{page resources:  Properties and bdc-mark}
 % \begin{NOTE}{UF}
@@ -1491,7 +1538,7 @@
           { /#1 ~ /l3pdf\int_use:N\g_@@_backend_name_int\c_space_tl BDC }
         \bool_if:NTF \l_@@_backend_xform_bool
           {
-            \exp_args:Nnx\@@_dict_put:nnn
+            \exp_args:Nnx\@@_dict_handler_put:nnn
               { xform/Resources/Properties }
               { l3pdf\int_use:N\g_@@_backend_name_int }
               { \@@_backend_object_ref:n { #2 } }
@@ -1515,7 +1562,7 @@
           { /#1 ~ /l3pdf\int_use:N\g_@@_backend_name_int\c_space_tl BDC }
         \bool_if:NTF \l_@@_backend_xform_bool
           {
-            \@@_dict_put:nxx
+            \@@_dict_handler_put:nxx
               { xform/Resources/Properties }
               { l3pdf\int_use:N\g_@@_backend_name_int }
               { \@@_backend_object_last: }
@@ -1557,7 +1604,7 @@
         \int_gincr:N\g_@@_backend_resourceid_int
         \bool_if:NTF \l_@@_backend_xform_bool
           {
-            \@@_dict_put:nxx
+            \@@_dict_handler_put:nxx
               { xform/Resources/Properties }
               { l3pdf\int_use:N\g_@@_backend_resourceid_int }
               { \@@_backend_object_ref:n { #2 } }
@@ -1574,7 +1621,7 @@
                   {0}
               }
             \@@_dict_gnew:n { backend_Page\l_@@_tmpa_tl/Resources/Properties }
-            \@@_dict_put:nxx
+            \@@_dict_handler_put:nxx
               { backend_Page\l_@@_tmpa_tl/Resources/Properties }
               { l3pdf\int_use:N\g_@@_backend_resourceid_int }
               { \@@_backend_object_ref:n{#2} }
@@ -1589,7 +1636,7 @@
         \int_gincr:N\g_@@_backend_resourceid_int
         \bool_if:NTF \l_@@_backend_xform_bool
           {
-            \@@_dict_put:nxx
+            \@@_dict_handler_put:nxx
               { xform/Resources/Properties }
               { l3pdf\int_use:N\g_@@_backend_resourceid_int }
               { \@@_backend_object_last: }
@@ -1606,7 +1653,7 @@
                   {0}
               }
             \@@_dict_gnew:n { backend_Page\l_@@_tmpa_tl/Resources/Properties }
-            \@@_dict_put:nxx
+            \@@_dict_handler_put:nxx
               { backend_Page\l_@@_tmpa_tl/Resources/Properties }
               { l3pdf\int_use:N\g_@@_backend_resourceid_int }
               { \@@_backend_object_last: }
@@ -2096,7 +2143,7 @@
       {
         \cs_new_protected:Npn \@@_backend_PageNResources_gput:nnn #1 #2 #3
           {
-            \@@_dict_put:nnn {PageN/Resources/#1} { #2 }{ #3 }
+            \@@_dict_handler_put:nnn {PageN/Resources/#1} { #2 }{ #3 }
             % luatex must also trigger the lua side
             \tex_latelua:D{l3kernel.@@.Page.Resources.#1=true}
             \tex_latelua:D
@@ -2108,7 +2155,7 @@
       { %pdftex
         \cs_new_protected:Npn \@@_backend_PageNResources_gput:nnn #1 #2 #3
           {
-            \@@_dict_put:nnn {PageN/Resources/#1} { #2 }{ #3 }
+            \@@_dict_handler_put:nnn {PageN/Resources/#1} { #2 }{ #3 }
           }
       }
 
@@ -2146,7 +2193,7 @@
       {
         \@@_backend:n {put~@resources~<<#1>>}
       }
-
+    %\@@_dict_gnew:n {PageN/Resources/ExtGState} ???? global/local problem.
     \cs_new_protected:Npn \@@_backend_PageNResources_gput:nnn #1 #2 #3
       {
        % this is unused but can be used by the show command
@@ -2167,7 +2214,7 @@
     \cs_new_protected:Npn \@@_backend_PageNResources:n #1 {}
     \cs_new_protected:Npn \@@_backend_PageNResources_gput:nnn #1 #2 #3
       { %only for the show command TEST!!
-        %\@@_dict_put:nnn {PageN/Resources/#1} { #2 }{ #3 }
+        %\@@_dict_handler_put:nnn {PageN/Resources/#1} { #2 }{ #3 }
       }
     \cs_new_protected:Npn \@@_PageNResources_gpush: {}
   }
@@ -2590,7 +2637,7 @@
              { g_@@_dict_/Catalog/AcroForm_obj }
              { \@@_dict_map_dict_item:n { Catalog/AcroForm } }
          \exp_args:Nnnx
-           \@@_dict_put:nnn
+           \@@_dict_handler_put:nnn
              { Catalog }
              { AcroForm }
              { \@@_backend_object_ref:n { g_@@_dict_/Catalog/AcroForm_obj } }





More information about the latex3-commits mailing list.