diff options
author | Karl Berry <karl@freefriends.org> | 2017-03-17 21:36:21 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-03-17 21:36:21 +0000 |
commit | e33fc7da87a62f72327720abe39033ef04b6a265 (patch) | |
tree | 96bafd8c98df417780309a175da5e9cc194694fe /Master/texmf-dist/tex/latex | |
parent | 3e61a137bdc5f0026fd9ea0c19646343410a3faf (diff) |
ocgx2 (17may17)
git-svn-id: svn://tug.org/texlive/trunk@43530 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty | 28 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty | 227 |
2 files changed, 61 insertions, 194 deletions
diff --git a/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty b/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty index 3646351314e..0b43c9e0e9b 100644 --- a/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty +++ b/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty @@ -97,7 +97,10 @@ \RequirePackage{atenddvi} \RequirePackage{pdfbase} -\ProvidesExplPackage{ocgbase}{2017/03/09}{0.7} +\def\g@ocgbase@date@tl{2017/03/16} +\def\g@ocgbase@version@tl{0.8} + +\ProvidesExplPackage{ocgbase}{\g@ocgbase@date@tl}{\g@ocgbase@version@tl} {support package for ocgx2.sty} \tl_new:N\g_ocgbase_ocgs_tl %takes ocg object refs @@ -283,6 +286,25 @@ \cs_new_nopar:Nn\ocgbase_oc_bdc:n{\pbs_pdfbdc:nn{/OC}{#1}} \cs_new_nopar:Nn\ocgbase_oc_emc:{\pbs_pdfemc:} +%stack of PDF obj references of currently open OCGs +\seq_new:N\g_ocgbase_ocgstack_seq +%push OCG to stack +\cs_new_nopar:Nn\ocgbase_ocgstack_push:n{ + \seq_gpush:Nx\g_ocgbase_ocgstack_seq{#1}} +%pop OCG from stack into tl +\cs_new_nopar:Nn\ocgbase_ocgstack_pop:N{\seq_gpop:NN\g_ocgbase_ocgstack_seq#1} +%get top OCG on stack, without removing it +\cs_new_nopar:Nn\ocgbase_ocgstack_top:{ + \seq_item:Nn\g_ocgbase_ocgstack_seq{c_one}} + +%command that inserts /OC <<OCMD with currently open OCGs>> entry; +%for use within annotation/xobject dicts +\cs_new_nopar:Nn\ocgbase_insert_oc:{ + \seq_if_empty:NF\g_ocgbase_ocgstack_seq{ + /OC~<</Type/OCMD/OCGs~[\seq_use:Nn\g_ocgbase_ocgstack_seq{~}]/P/AllOn>> + } +} + %l2e versions \cs_gset_eq:NN\ocgbase@new@ocg\ocgbase_new_ocg:nnn \cs_gset_eq:NN\ocgbase@last@ocg\ocgbase_last_ocg: @@ -292,3 +314,7 @@ \cs_gset_eq:NN\ocgbase@add@ocg@to@radiobtn@grp\ocgbase_add_ocg_to_radiobtn_grp:nnn \cs_gset_eq:NN\ocgbase@oc@bdc\ocgbase_oc_bdc:n \cs_gset_eq:NN\ocgbase@oc@emc\ocgbase_oc_emc: +\cs_gset_eq:NN\ocgbase@insert@oc\ocgbase_insert_oc: +\cs_gset_eq:NN\ocgbase@ocgstack@top\ocgbase_ocgstack_top: +\cs_gset_eq:NN\ocgbase@ocgstack@pop\ocgbase_ocgstack_pop:N +\cs_gset_eq:NN\ocgbase@ocgstack@push\ocgbase_ocgstack_push:n diff --git a/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty b/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty index 3e1114c2eb9..76c57f22d2b 100644 --- a/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty +++ b/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty @@ -37,7 +37,10 @@ \RequirePackage{xparse} \RequirePackage{l3keys2e} -\ProvidesExplPackage{ocgx2}{2017/03/09}{0.19} +\def\g@ocgxii@date@tl{2017/03/16} +\def\g@ocgxii@version@tl{0.20} + +\ProvidesExplPackage{ocgx2}{\g@ocgxii@date@tl}{\g@ocgxii@version@tl} {ports `ocgx' functionality to dvips+ps2pdf, xelatex and dvipdfmx} %creating global definitions @@ -135,9 +138,7 @@ \cs_new_nopar:Nn\ocgxii_beginocg:nnnn{ \bool_if:NT\g_ocgxii_nestedB_bool{ - \seq_gput_left:Nx\g_ocgxii_nested_seq{ - \seq_item:Nn\g_ocgxii_ocgstack_seq{\c_one} - } + \seq_gput_left:Nx\g_ocgxii_nested_seq{\ocgbase_ocgstack_top:} \ocgbase_add_to_order_list:n{[} } \bool_gset_true:N\g_ocgxii_nestedB_bool @@ -197,8 +198,8 @@ } } \tl_gset:cx{ocgx2.ocg.#3}{\tl_use:c{ocgxii@#3}} - \seq_gput_left:Nx\g_ocgxii_ocgstack_seq{\tl_use:c{ocgxii@#3}} - \ocgxii_ocgstack_shipout:N\g_ocgxii_ocgstack_seq + \ocgbase_ocgstack_push:n{\tl_use:c{ocgxii@#3}} + \ocgxii_ocgstack_shipout:N\g_ocgbase_ocgstack_seq \group_end: \ocgbase_oc_bdc:n{\tl_use:c{ocgxii@#3}} \ignorespaces @@ -212,14 +213,14 @@ \str_if_eq_x_p:nn{ \seq_item:Nn\g_ocgxii_nested_seq{\c_one} }{ - \seq_item:Nn\g_ocgxii_ocgstack_seq{\c_one} + \ocgbase_ocgstack_top: } }{ \ocgbase_add_to_order_list:n{]} \seq_gpop_left:NN\g_ocgxii_nested_seq\l_trash_tl } - \seq_gpop_left:NN\g_ocgxii_ocgstack_seq\l_trash_tl - \ocgxii_ocgstack_shipout:N\g_ocgxii_ocgstack_seq + \ocgbase_ocgstack_pop:N\l_trash_tl + \ocgxii_ocgstack_shipout:N\g_ocgbase_ocgstack_seq \bool_gset_false:N\g_ocgxii_nestedB_bool \bool_gset_true:N\g_ocgxii_nestedE_bool } @@ -313,17 +314,6 @@ \ocgxii_outputpage_orig: } -%stack of PDF obj references of currently open OCGs -\seq_new:N\g_ocgxii_ocgstack_seq - -%macro that inserts /OC <<OCMD with currently open OCGs>> entry; -%for use within annotation dicts -\cs_new_nopar:Npn\ocgxii@insert@OC{ - \seq_if_empty:NF\g_ocgxii_ocgstack_seq{ - /OC~<</Type/OCMD/OCGs~[\seq_use:Nn\g_ocgxii_ocgstack_seq{~}]/P/AllOn>> - } -} - \cs_new_nopar:Nn\ocgxii_ocglist_reset:{ \tl_clear_new:N\l_ocgxii_u_list_tl \tl_clear_new:N\l_ocgxii_d_list_tl @@ -373,176 +363,32 @@ \int_new:N\g_ocgxii_widcount_int% widget counter -%re-implement commands from ocg-p.sty / ocgx.sty (all engines including -%ps2pdf [gs>=9.15]) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% re-implement commands from ocgx.sty (all engines including ps2pdf [gs>=9.15]) +% adding optional `*` (arg 1) -> non-breakable Button Widget & mouse-up trigger +% instead of plain (multiline) Link +% adding optional 2nd argument -> Button Widget with one of various mouse +% triggers +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \DeclareDocumentCommand\switchocg{s o m +m}{ - \leavevmode - \bool_if:nTF{ - \IfBooleanTF{#1}{\c_true_bool}{\c_false_bool} || - \IfValueTF{#2}{\c_true_bool}{\c_false_bool} - }{ - % implemented as Widget annot (non-breakable) - \ocgxii_ocglist_process_idlist:nn{ - \IfValueTF{#2}{#2}{triggerocg=onmouseup} - }{#3} - \hbox_set:Nn\l_tmpa_box{#4} - %dummy Widget, workaround for pre AR-DC bug; - %see https://forums.adobe.com/message/5787612#5787612 - \str_if_eq_x:nnF{\ocgxii@insert@OC}{}{\pbs_pdfannot:nnnn{ - \dim_use:N\box_wd:N\l_tmpa_box}{ - \dim_use:N\box_ht:N\l_tmpa_box}{ - \dim_use:N\box_dp:N\l_tmpa_box - }{/Subtype/Widget/F~2}} - \pbs_pdfannot:nnnn{ - \dim_use:N\box_wd:N\l_tmpa_box}{ - \dim_use:N\box_ht:N\l_tmpa_box}{ - \dim_use:N\box_dp:N\l_tmpa_box - }{ - /Subtype/Widget/Ff~65536/FT/Btn/H/I - /T~(ocgx2@\int_use:N\g_ocgxii_widcount_int) - \ocgxii@insert@OC - /AA << - \str_if_eq:VnF\l_ocgxii_u_list_tl{}{ - /U <</S/SetOCGState/State [/Toggle~\l_ocgxii_u_list_tl]>> - } - \str_if_eq:VnF\l_ocgxii_d_list_tl{}{ - /D <</S/SetOCGState/State [/Toggle~\l_ocgxii_d_list_tl]>> - } - \str_if_eq:VnF\l_ocgxii_e_list_tl{}{ - /E <</S/SetOCGState/State [/Toggle~\l_ocgxii_e_list_tl]>> - } - \str_if_eq:VnF\l_ocgxii_x_list_tl{}{ - /X <</S/SetOCGState/State [/Toggle~\l_ocgxii_x_list_tl]>> - } - >> - }\box_use_clear:N\l_tmpa_box - \pbs_appendtofields:n{\pbs_pdflastann:} - \int_gincr:N\g_ocgxii_widcount_int - }{ - \ocgxii_ocglist_process_idlist:nn{triggerocg=onmouseup}{#3} - \pbs_pdflink:nn{ - /Subtype/Link\ocgxii@insert@OC - /A <</S/SetOCGState/State [ - \str_if_eq:VnF\l_ocgxii_u_list_tl{}{/Toggle~\l_ocgxii_u_list_tl}]>> - /Border [0~0~0] - }{#4} - } + \ocgxii_actionsocg:nnnnnn{#1}{#2}{#3}{}{}{#4} } \DeclareDocumentCommand\showocg{s o m +m}{ - \leavevmode - \bool_if:nTF{ - \IfBooleanTF{#1}{\c_true_bool}{\c_false_bool} || - \IfValueTF{#2}{\c_true_bool}{\c_false_bool} - }{ - % implemented as Widget annot (non-breakable) - \ocgxii_ocglist_process_idlist:nn{ - \IfValueTF{#2}{#2}{triggerocg=onmouseup} - }{#3} - \hbox_set:Nn\l_tmpa_box{#4} - %dummy Widget, workaround for pre AR-DC bug; - %see https://forums.adobe.com/message/5787612#5787612 - \str_if_eq_x:nnF{\ocgxii@insert@OC}{}{\pbs_pdfannot:nnnn{ - \dim_use:N\box_wd:N\l_tmpa_box}{ - \dim_use:N\box_ht:N\l_tmpa_box}{ - \dim_use:N\box_dp:N\l_tmpa_box - }{/Subtype/Widget/F~2}} - \pbs_pdfannot:nnnn{ - \dim_use:N\box_wd:N\l_tmpa_box}{ - \dim_use:N\box_ht:N\l_tmpa_box}{ - \dim_use:N\box_dp:N\l_tmpa_box - }{ - /Subtype/Widget/Ff~65536/FT/Btn/H/I - /T~(ocgx2@\int_use:N\g_ocgxii_widcount_int) - \ocgxii@insert@OC - /AA << - \str_if_eq:VnF\l_ocgxii_u_list_tl{}{ - /U <</S/SetOCGState/State [/ON~\l_ocgxii_u_list_tl]>> - } - \str_if_eq:VnF\l_ocgxii_d_list_tl{}{ - /D <</S/SetOCGState/State [/ON~\l_ocgxii_d_list_tl]>> - } - \str_if_eq:VnF\l_ocgxii_e_list_tl{}{ - /E <</S/SetOCGState/State [/ON~\l_ocgxii_e_list_tl]>> - } - \str_if_eq:VnF\l_ocgxii_x_list_tl{}{ - /X <</S/SetOCGState/State [/ON~\l_ocgxii_x_list_tl]>> - } - >> - }\box_use_clear:N\l_tmpa_box - \pbs_appendtofields:n{\pbs_pdflastann:} - \int_gincr:N\g_ocgxii_widcount_int - }{ - \ocgxii_ocglist_process_idlist:nn{triggerocg=onmouseup}{#3} - \pbs_pdflink:nn{ - /Subtype/Link\ocgxii@insert@OC - /A <</S/SetOCGState/State [ - \str_if_eq:VnF\l_ocgxii_u_list_tl{}{/ON~\l_ocgxii_u_list_tl}]>> - /Border [0~0~0] - }{#4} - } + \ocgxii_actionsocg:nnnnnn{#1}{#2}{}{#3}{}{#4} } \DeclareDocumentCommand\hideocg{s o m +m}{ - \leavevmode - \bool_if:nTF{ - \IfBooleanTF{#1}{\c_true_bool}{\c_false_bool} || - \IfValueTF{#2}{\c_true_bool}{\c_false_bool} - }{ - % implemented as Widget annot (non-breakable) - \ocgxii_ocglist_process_idlist:nn{ - \IfValueTF{#2}{#2}{triggerocg=onmouseup} - }{#3} - \hbox_set:Nn\l_tmpa_box{#4} - %dummy Widget, workaround for pre AR-DC bug; - %see https://forums.adobe.com/message/5787612#5787612 - \str_if_eq_x:nnF{\ocgxii@insert@OC}{}{\pbs_pdfannot:nnnn{ - \dim_use:N\box_wd:N\l_tmpa_box}{ - \dim_use:N\box_ht:N\l_tmpa_box}{ - \dim_use:N\box_dp:N\l_tmpa_box - }{/Subtype/Widget/F~2}} - \pbs_pdfannot:nnnn{ - \dim_use:N\box_wd:N\l_tmpa_box}{ - \dim_use:N\box_ht:N\l_tmpa_box}{ - \dim_use:N\box_dp:N\l_tmpa_box - }{ - /Subtype/Widget/Ff~65536/FT/Btn/H/I - /T~(ocgx2@\int_use:N\g_ocgxii_widcount_int) - \ocgxii@insert@OC - /AA << - \str_if_eq:VnF\l_ocgxii_u_list_tl{}{ - /U <</S/SetOCGState/State [/OFF~\l_ocgxii_u_list_tl]>> - } - \str_if_eq:VnF\l_ocgxii_d_list_tl{}{ - /D <</S/SetOCGState/State [/OFF~\l_ocgxii_d_list_tl]>> - } - \str_if_eq:VnF\l_ocgxii_e_list_tl{}{ - /E <</S/SetOCGState/State [/OFF~\l_ocgxii_e_list_tl]>> - } - \str_if_eq:VnF\l_ocgxii_x_list_tl{}{ - /X <</S/SetOCGState/State [/OFF~\l_ocgxii_x_list_tl]>> - } - >> - }\box_use_clear:N\l_tmpa_box - \pbs_appendtofields:n{\pbs_pdflastann:} - \int_gincr:N\g_ocgxii_widcount_int - }{ - \ocgxii_ocglist_process_idlist:nn{triggerocg=onmouseup}{#3} - \pbs_pdflink:nn{ - /Subtype/Link\ocgxii@insert@OC - /A <</S/SetOCGState/State [ - \str_if_eq:VnF\l_ocgxii_u_list_tl{}{/OFF~\l_ocgxii_u_list_tl}]>> - /Border [0~0~0] - }{#4} - } + \ocgxii_actionsocg:nnnnnn{#1}{#2}{}{}{#3}{#4} } \DeclareDocumentCommand\actionsocg{s o m m m +m}{ + \ocgxii_actionsocg:nnnnnn{#1}{#2}{#3}{#4}{#5}{#6} +} + +\cs_new:Nn\ocgxii_actionsocg:nnnnnn{ \leavevmode - \bool_if:nTF{ - \IfBooleanTF{#1}{\c_true_bool}{\c_false_bool} || - \IfValueTF{#2}{\c_true_bool}{\c_false_bool} - }{ + \bool_if:nTF{#1 || \IfValueTF{#2}{\c_true_bool}{\c_false_bool}}{ % implemented as Widget annot (non-breakable) \ocgxii_ocglist_process_idlist:nn{ \IfValueTF{#2}{#2}{triggerocg=onmouseup} @@ -566,13 +412,6 @@ \tl_set_eq:NN\l_ocgxii_tohide_d_tl\l_ocgxii_d_list_tl \tl_set_eq:NN\l_ocgxii_tohide_u_tl\l_ocgxii_u_list_tl \hbox_set:Nn\l_tmpa_box{#6} - %dummy Widget, workaround for pre AR-DC bug; - %see https://forums.adobe.com/message/5787612#5787612 - \str_if_eq_x:nnF{\ocgxii@insert@OC}{}{\pbs_pdfannot:nnnn{ - \dim_use:N\box_wd:N\l_tmpa_box}{ - \dim_use:N\box_ht:N\l_tmpa_box}{ - \dim_use:N\box_dp:N\l_tmpa_box - }{/Subtype/Widget/F~2}} \pbs_pdfannot:nnnn{ \dim_use:N\box_wd:N\l_tmpa_box}{ \dim_use:N\box_ht:N\l_tmpa_box}{ @@ -580,7 +419,6 @@ }{ /Subtype/Widget/Ff~65536/FT/Btn/H/I /T~(ocgx2@\int_use:N\g_ocgxii_widcount_int) - \ocgxii@insert@OC /AA << \str_if_eq_x:nnF{}{ \l_ocgxii_toswitch_u_tl\l_ocgxii_toshow_u_tl\l_ocgxii_tohide_u_tl @@ -654,7 +492,7 @@ \ocgxii_ocglist_process_idlist:nn{triggerocg=onmouseup}{#5} \tl_set_eq:NN\l_ocgxii_tohide_u_tl\l_ocgxii_u_list_tl \pbs_pdflink:nn{ - /Subtype/Link\ocgxii@insert@OC + /Subtype/Link /A <</S/SetOCGState /State [ \str_if_eq:VnF{\l_ocgxii_toswitch_u_tl}{}{ @@ -668,11 +506,12 @@ } } -% mimic commands from ocg-p -\def\toggleocgs{\switchocg*} -\def\showocgs{\showocg*} -\def\hideocgs{\hideocg*} -\def\setocgs{\actionsocg*} +%mimic commands from ocg-p +\cs_new:Npn\toggleocgs{\switchocg*} +\cs_new:Npn\showocgs{\showocg*} +\cs_new:Npn\hideocgs{\hideocg*} +\cs_new:Npn\setocgs{\actionsocg*} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \cs_new:Nn\ocgxii_process_ocgref:NN{ \str_if_eq_x:nnF{#2}{}{ @@ -816,8 +655,10 @@ \RequirePackage{tikz} \usetikzlibrary{calc} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Copyright notice: The code that follows until the end of the file was % taken from Paul Gaborit's `tikzlibraryocgx.code.tex' with minor additions. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \tikzset{ ocg/.style={ocg/.cd,#1,/tikz/.cd}, ocg={ |