[latex3-commits] [git/LaTeX3-latex3-pdfresources] renamedict77: more changes to attachfile (0d9bdf2)
Ulrike Fischer
fischer at troubleshooting-tex.de
Fri May 1 01:09:10 CEST 2020
Repository : https://github.com/latex3/pdfresources
On branch : renamedict77
Link : https://github.com/latex3/pdfresources/commit/0d9bdf242f5b932bdcad7f0d039202f9cb4088a0
>---------------------------------------------------------------
commit 0d9bdf242f5b932bdcad7f0d039202f9cb4088a0
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Fri May 1 01:09:10 2020 +0200
more changes to attachfile
>---------------------------------------------------------------
0d9bdf242f5b932bdcad7f0d039202f9cb4088a0
experiments/new-attachfile.tex | 3 +-
newpackages/new-attachfile.sty | 68 +++++++++++++++++++++++-------------------
2 files changed, 39 insertions(+), 32 deletions(-)
diff --git a/experiments/new-attachfile.tex b/experiments/new-attachfile.tex
index ff9aa23..dceb528 100644
--- a/experiments/new-attachfile.tex
+++ b/experiments/new-attachfile.tex
@@ -11,7 +11,8 @@
\begin{document}
abc
\makeatletter
-\attachfile[icon=Graph,mimetype=text/plain]{catalogue.tex} some text
+\attachfilesetup{color=red}
+\attachfile[icon=Graph,mimetype=text/plain,color=red]{catalogue.tex} some text
\atfi at acroPaperclip
\atfi at acroTag
\atfi at acroGraph
diff --git a/newpackages/new-attachfile.sty b/newpackages/new-attachfile.sty
index a2372f8..042ee1b 100644
--- a/newpackages/new-attachfile.sty
+++ b/newpackages/new-attachfile.sty
@@ -59,7 +59,10 @@
\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 }
@@ -85,7 +88,7 @@
% probably generic ....
\pdfdict_new:n {annot/FileAttachment}
\pdfdict_put:nnn {annot/FileAttachment}{Subtype}{/FileAttachment}
-\pdfdict_new:n {annot/FileAttachment/AP} % appearance
+\pdfdict_new:n {annot/FileAttachment/AP} % appearance
\keys_define:nn { atfi }
{
@@ -104,8 +107,7 @@
{
\tl_if_empty:nF { #1 }
{
- \pdftool_str_convert:nN { #1 } \l__atfi_filename_tl
-
+ \pdftool_textstringhex_print:nN { #1 } \l__atfi_filename_tl %variable
}
}
%ucfilespec -> embed step
@@ -124,7 +126,7 @@
}
,moddate .groups:n = { embed }
,icon .choices:nn =
- { Data, Graph, PushPin, Tag } =
+ { Data, Graph, PushPin, Tag }
{
\tl_set:Nn \l__atfi_annot_icon_tl { #1 }
\pdfdict_put:nnn { annot/FileAttachment }{ Name }{ #1 }
@@ -138,7 +140,9 @@
}
,icon .groups:n = { attach }
% initial: PushPin, but should be set only in the command
-
+ ,color .tl_set:N = \l__atfi_annot_color_tl
+ ,color .groups:n = { attach }
+ ,color .initial:n = { __atfi_annot_color }
%color -> attach step, affects icon
% decide allowed syntax of expressions ...
% initial: 1 0.9255 0.7765
@@ -199,7 +203,7 @@
\atfi at color@tex\atfi at color@inline\atfi at color@annot
{attachfile2}{color}%
}
-\atfi at setup{color=1 0.9255 0.7765}
+%\atfi at setup{color=1 0.9255 0.7765}
\def\atfi at pad@ii#1{%
\ifnum#1>9 %
\number#1%
@@ -402,15 +406,16 @@
{\atfi at scale\atfi at appearanceheight}
{\atfi at scale\atfi at appearancedepth}
{
- /Subtype/FileAttachment%
- \atfi at icon
- \atfi at color@annot
- \atfi at author
- \atfi at date
- \atfi at annotname
- \atfi at description
- \atfi at subject
- \atfi at appearance@dict
+ \pdfdict_map:n {annot/FileAttachment}
+ % /Subtype/FileAttachment%
+% \atfi at icon
+% \atfi at color@annot
+% \atfi at author
+% \atfi at date
+% \atfi at annotname
+% \atfi at description
+% \atfi at subject
+% \atfi at appearance@dict
/F~ \bitsetGetDec {__atfi_annotFlags}
/FS~ \pdf_object_ref:n{atfi at fileobj@#1}%
}%
@@ -529,39 +534,41 @@
\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@\atfi at icon@icon}{%
+ \ltx at IfUndefined{atfi at appobj@\l__atfi_annot_icon_tl}{%
\savebox{\atfi at appearancebox}{%
- \@nameuse{atfi at acro\atfi at icon@icon}%
+ \@nameuse{atfi at acro\l__atfi_annot_icon_tl}%
}%
\expandafter
- \xdef\csname atfi at appwidth@\atfi at icon@icon\endcsname{%
+ \xdef\csname atfi at appwidth@\l__atfi_annot_icon_tl\endcsname{%
\the\wd\atfi at appearancebox
}%
\expandafter
- \xdef\csname atfi at appheight@\atfi at icon@icon\endcsname{%
+ \xdef\csname atfi at appheight@\l__atfi_annot_icon_tl\endcsname{%
\the\ht\atfi at appearancebox
}%
\expandafter
- \xdef\csname atfi at appdepth@\atfi at icon@icon\endcsname{%
+ \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@\atfi at icon@icon\endcsname
+ \csname atfi at appobj@\l__atfi_annot_icon_tl\endcsname
\atfi at appearanceobj
}{%
}%
% optimization: \setlength dropped
\atfi at appearancewidth=%
- \@nameuse{atfi at appwidth@\atfi at icon@icon}\relax
+ \@nameuse{atfi at appwidth@\l__atfi_annot_icon_tl}\relax
\atfi at appearanceheight=%
- \@nameuse{atfi at appheight@\atfi at icon@icon}\relax
+ \@nameuse{atfi at appheight@\l__atfi_annot_icon_tl}\relax
\atfi at appearancedepth=%
- \@nameuse{atfi at appdepth@\atfi at icon@icon}\relax
+ \@nameuse{atfi at appdepth@\l__atfi_annot_icon_tl}\relax
\expandafter\let\expandafter\atfi at appearanceobj
- \csname atfi at appobj@\atfi at icon@icon\endcsname
+ \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
@@ -631,10 +638,9 @@
\seq_pop_left:NN #2 \l_tmpa_tl
\tl_set_eq:NN \l_color_fixed_model_tl \l__color_ori_fixed_model_tl
}
+\cs_generate_variant:Nn \__atfi_color_to_rgb_seq:nN {oN}
\cs_new:Npn \__atfi_arg_braced:n #1 {{#1}}
-\color_set:nnn {__atfi_color_inline}{rgb}{1,0.9255,0.7765}
-
\cs_new_protected:Npn \atfi at acroGraph@data
{
\__draw_backend_scope_begin:
@@ -658,7 +664,7 @@
\__draw_backend_rectangle:nnnn {14.7471bp}{4.1367bp}{3.9571bp}{11.8867bp}
\__draw_backend_fill:
- \__atfi_color_to_rgb_seq:nN {__atfi_color_inline} \l_tmpa_seq
+ \__atfi_color_to_rgb_seq:oN {\l__atfi_annot_color_tl} \l_tmpa_seq
\exp_last_unbraced:Ne \__draw_backend_color_fill_rgb:nnn
{ \seq_map_function:NN \l_tmpa_seq \__atfi_arg_braced:n }
@@ -720,7 +726,7 @@
\__draw_backend_literal:x {6.9692~6.3301~6.9692~7.1572~v}
\__draw_backend_literal:x {6.9692~7.9863~6.9692~12.21~y}
\__draw_backend_stroke:
- \__atfi_color_to_rgb_seq:nN {__atfi_color_inline} \l_tmpa_seq
+ \__atfi_color_to_rgb_seq:oN {\l__atfi_annot_color_tl} \l_tmpa_seq
\exp_last_unbraced:Ne \__draw_backend_color_stroke_rgb:nnn
{ \seq_map_function:NN \l_tmpa_seq \__atfi_arg_braced:n }
\__draw_backend_linewidth:n {1bp}
@@ -772,7 +778,7 @@
\__draw_backend_lineto:nn {12bp}{1bp}
\__draw_backend_lineto:nn {11bp}{1bp}
\__draw_backend_lineto:nn {11bp}{6bp}
- \__atfi_color_to_rgb_seq:nN {__atfi_color_inline} \l_tmpa_seq
+ \__atfi_color_to_rgb_seq:oN {\l__atfi_annot_color_tl} \l_tmpa_seq
\exp_last_unbraced:Ne \__draw_backend_color_fill_rgb:nnn
{ \seq_map_function:NN \l_tmpa_seq \__atfi_arg_braced:n }
\__draw_backend_color_stroke_gray:n {0}
@@ -841,7 +847,7 @@
\__draw_backend_curveto:nnnnnn{8.7344bp}{7.2715bp}{9.4463bp}{8.0879bp}{9.4463bp}{9.0957bp}
\__draw_backend_curveto:nnnnnn{9.4463bp}{10.1035bp}{8.7344bp}{10.9199bp}{7.856bp}{10.9199bp}
\__draw_backend_closepath:
- \__atfi_color_to_rgb_seq:nN {__atfi_color_inline} \l_tmpa_seq
+ \__atfi_color_to_rgb_seq:oN {\l__atfi_annot_color_tl} \l_tmpa_seq
\exp_last_unbraced:Ne \__draw_backend_color_fill_rgb:nnn
{ \seq_map_function:NN \l_tmpa_seq \__atfi_arg_braced:n }
\__draw_backend_color_stroke_gray:n {0}
More information about the latex3-commits
mailing list.