summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tagpdf/tagpdf-attr-code.sty
blob: 03bfb78a98d46dce4029e23bf64846ee3f64b2e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
%%
%% This is file `tagpdf-attr-code.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tagpdf-struct.dtx  (with options: `attr')
%% 
%% Copyright (C) 2019 Ulrike Fischer
%% 
%% It may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License (LPPL), either version 1.3c of
%% this license or (at your option) any later version.  The latest
%% version of this license is in the file:
%% 
%%    https://www.latex-project.org/lppl.txt
%% 
%% This file is part of the "tagpdf bundle" (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%% 
%% File: tagpdf-struct.dtx

\ProvidesExplPackage {tagpdf-attr-code} {2021/02/23} {0.80}
  {part of tagpdf - code related to attributes and attribute classes}


\seq_new:N  \g__tag_attr_class_used_seq
\prop_new:N \g__tag_attr_objref_prop %will contain obj num of used attributes

\prop_new:N \g__tag_attr_entries_prop
\tl_new:N   \g__tag_attr_class_content_tl
\tl_new:N   \l__tag_attr_objtmp_tl
\tl_new:N   \l__tag_attr_value_tl

\cs_new_protected:Nn \__tag_attr_new_entry:nn %#1:name, #2: content
  {
    \prop_gput:Nnn \g__tag_attr_entries_prop
      {#1}{#2}
  }

\keys_define:nn { __tag / setup }
  {
    newattribute .code:n =
      {
        \__tag_attr_new_entry:nn #1
      }
  }

\keys_define:nn { __tag / struct }
  {
    attribute-class .code:n =
     {
       \clist_set:No \l_tmpa_clist { #1 }
       \seq_set_from_clist:NN \l_tmpa_seq \l_tmpa_clist
       \seq_map_inline:Nn \l_tmpa_seq
         {
           \prop_if_in:NnF \g__tag_attr_entries_prop {##1}
             {
               \msg_error:nnn { tag } { attr-unknown } { ##1 }
             }
           \seq_gput_left:Nn\g__tag_attr_class_used_seq { ##1}
         }
       \seq_set_map:NNn \l_tmpb_seq \l_tmpa_seq
         {
           /##1
         }
       \tl_set:Nx \l_tmpa_tl
         {
           \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{[}
           \seq_use:Nn \l_tmpb_seq  { \c_space_tl  }
           \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{]}
         }
       \int_compare:nT { \seq_count:N \l_tmpa_seq > 0 }
         {
           \__tag_prop_gput:cnx
             { g__tag_struct_\int_eval:n {\c@g__tag_struct_abs_int}_prop }
             { C }
             { \l_tmpa_tl }
          %\prop_show:c  { g__tag_struct_\int_eval:n {\c@g__tag_struct_abs_int}_prop }
         }
    }
  }

\keys_define:nn { __tag / struct }
  {
    attribute .code:n  = % A property (attribute, value currently a dictionary)
      {
        \clist_set:No          \l_tmpa_clist { #1 }
        \seq_set_from_clist:NN \l_tmpa_seq \l_tmpa_clist
        \tl_set:Nx \l__tag_attr_value_tl
          {
            \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{[}%]
          }
        \seq_map_inline:Nn \l_tmpa_seq
          {
            \prop_if_in:NnF \g__tag_attr_entries_prop {##1}
              {
                \msg_error:nnn { tag } { attr-unknown } { ##1 }
              }
            \prop_if_in:NnF \g__tag_attr_objref_prop {##1}
              {%\prop_show:N \g__tag_attr_entries_prop
                \pdf_object_unnamed_write:nx
                  { dict }
                  {
                    \prop_item:Nn\g__tag_attr_entries_prop {##1}
                  }
                \prop_gput:Nnx \g__tag_attr_objref_prop {##1} {\pdf_object_ref_last:}
              }
            \tl_put_right:Nx \l__tag_attr_value_tl
              {
                \c_space_tl
                \prop_item:Nn \g__tag_attr_objref_prop {##1}
              }
 %     \tl_show:N \l__tag_attr_value_tl
          }
        \tl_put_right:Nx \l__tag_attr_value_tl
          { %[
            \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{]}%
          }
 %     \tl_show:N \l__tag_attr_value_tl
        \__tag_prop_gput:cnx
          { g__tag_struct_\int_eval:n {\c@g__tag_struct_abs_int}_prop }
          { A }
          { \l__tag_attr_value_tl }
    },
  }
%% 
%%
%% End of file `tagpdf-attr-code.sty'.