diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty | 318 |
1 files changed, 251 insertions, 67 deletions
diff --git a/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty b/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty index f7c6e12b26b..e0da040c319 100644 --- a/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty +++ b/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty @@ -47,7 +47,7 @@ } } -\ProvidesExplPackage{ocgx2}{2015/07/20}{0.7} +\ProvidesExplPackage{ocgx2}{2015/09/11}{0.8} {ports `ocgx' functionality to dvips+ps2pdf, xelatex and dvipdfmx} %re-implement ocg-p's `ocg' environment @@ -115,6 +115,7 @@ %stack of PDF obj references of currently open OCGs \seq_new:N\g_fixocg_ocgstack_seq + %macro that inserts /OC <<OCMD with currently open OCGs>> entry; %for use within annotation dicts \tl_set:Nn\ocgxii@insert@OC{ @@ -123,86 +124,266 @@ } } -%re-implement commands from ocgx.sty (all engines including ps2pdf [gs>=9.15]) -\DeclareDocumentCommand\switchocg{m +m}{ - \tl_set:Nn\l_ocgxii_ocglist_tl{} - \tl_set:Nx\l_ocglistarg_tl{#1}\tl_trim_spaces:N\l_ocglistarg_tl - \seq_set_split:NnV\l_ocgxii_ocglistarg_seq{~}\l_ocglistarg_tl - \seq_map_variable:NNn\l_ocgxii_ocglistarg_seq\l_tempa_tl{ - \ocgxii_process_ocgref:NN\l_ocgxii_ocglist_tl\l_tempa_tl - } - \leavevmode - \ocgxii_pdflink:nn{ - /Subtype/Link\ocgxii@insert@OC - /A <</S/SetOCGState/State [ - \str_if_eq:VnF{\l_ocgxii_ocglist_tl}{}{/Toggle~\l_ocgxii_ocglist_tl}]>> - /Border [0~0~0] - }{#2} +\cs_set:Nn\ocgxii_ocglist_reset:{ + \tl_clear_new:N\l_ocgxii_u_list_tl + \tl_clear_new:N\l_ocgxii_d_list_tl + \tl_clear_new:N\l_ocgxii_e_list_tl + \tl_clear_new:N\l_ocgxii_x_list_tl } -\DeclareDocumentCommand\showocg{m +m}{ - \tl_set:Nn\l_ocgxii_ocglist_tl{} - \tl_set:Nx\l_ocglistarg_tl{#1}\tl_trim_spaces:N\l_ocglistarg_tl +\cs_set:Nn\ocgxii_ocglist_build:Nn{ + \tl_set:Nx\l_ocglistarg_tl{#2}\tl_trim_spaces:N\l_ocglistarg_tl \seq_set_split:NnV\l_ocgxii_ocglistarg_seq{~}\l_ocglistarg_tl \seq_map_variable:NNn\l_ocgxii_ocglistarg_seq\l_tempa_tl{ - \ocgxii_process_ocgref:NN\l_ocgxii_ocglist_tl\l_tempa_tl + \ocgxii_process_ocgref:NN#1\l_tempa_tl } - \leavevmode - \ocgxii_pdflink:nn{ - /Subtype/Link\ocgxii@insert@OC - /A <</S/SetOCGState/State [ - \str_if_eq:VnF{\l_ocgxii_ocglist_tl}{}{/ON~\l_ocgxii_ocglist_tl}]>> - /Border [0~0~0] - }{#2} } -\DeclareDocumentCommand\hideocg{m +m}{ - \tl_set:Nn\l_ocgxii_ocglist_tl{} - \tl_set:Nx\l_ocglistarg_tl{#1}\tl_trim_spaces:N\l_ocglistarg_tl - \seq_set_split:NnV\l_ocgxii_ocglistarg_seq{~}\l_ocglistarg_tl - \seq_map_variable:NNn\l_ocgxii_ocglistarg_seq\l_tempa_tl{ - \ocgxii_process_ocgref:NN\l_ocgxii_ocglist_tl\l_tempa_tl +\cs_new:Nn\ocgxii_commalist_process:n{ + \seq_set_split:Nnn\l_tmpa_seq{,}{#1} + \ocgxii_ocglist_build:Nn\l_ocgxii_e_list_tl{\seq_item:Nn\l_tmpa_seq{1}} + \ocgxii_ocglist_build:Nn\l_ocgxii_x_list_tl{\seq_item:Nn\l_tmpa_seq{2}} + \ocgxii_ocglist_build:Nn\l_ocgxii_d_list_tl{\seq_item:Nn\l_tmpa_seq{3}} + \ocgxii_ocglist_build:Nn\l_ocgxii_u_list_tl{\seq_item:Nn\l_tmpa_seq{4}} +} + +\cs_set:Nn\ocgxii_ocglist_process_idlist:nn{ + \ocgxii_ocglist_reset: + \tl_set:Nx\l_ocgxii_opt_tl{#1}\tl_remove_all:Nn\l_ocgxii_opt_tl{~} + \str_case_x:nnF{\l_ocgxii_opt_tl}{ + {triggerocg=onmouseup}{ + \ocgxii_ocglist_build:Nn\l_ocgxii_u_list_tl{#2} + } + {triggerocg=onmousedown}{ + \ocgxii_ocglist_build:Nn\l_ocgxii_d_list_tl{#2} + } + {triggerocg=onmouseenter}{ + \ocgxii_ocglist_build:Nn\l_ocgxii_e_list_tl{#2} + } + {triggerocg=onmouseexit}{ + \ocgxii_ocglist_build:Nn\l_ocgxii_x_list_tl{#2} + } + {triggerocg=allactions}{ + \ocgxii_commalist_process:n{#2} + } + }{ + \msg_error:nnx{ocgx2}{unknown~option}{\l_ocgxii_opt_tl} } - \leavevmode - \ocgxii_pdflink:nn{ - /Subtype/Link\ocgxii@insert@OC - /A <</S/SetOCGState/State [ - \str_if_eq:VnF{\l_ocgxii_ocglist_tl}{}{/OFF~\l_ocgxii_ocglist_tl}]>> - /Border [0~0~0] - }{#2} } -\DeclareDocumentCommand\actionsocg{m m m +m}{ - \tl_set:Nx\l_ocglistarg_tl{#1}\tl_trim_spaces:N\l_ocglistarg_tl - \tl_set:Nn\l_ocgxii_toswitch_tl{} - \seq_set_split:NnV\l_ocgxii_ocglistarg_seq{~}\l_ocglistarg_tl - \seq_map_variable:NNn\l_ocgxii_ocglistarg_seq\l_tempa_tl{ - \ocgxii_process_ocgref:NN\l_ocgxii_toswitch_tl\l_tempa_tl +\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]) +\DeclareDocumentCommand\switchocg{o m +m}{ + \leavevmode + \IfNoValueTF{#1}{ + \ocgxii_ocglist_process_idlist:nn{triggerocg=onmouseup}{#2} + \ocgxii_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] + }{#3} + }{ + \ocgxii_ocglist_process_idlist:nn{#1}{#2} + \ocgxii_pdflink:nn{ + /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]>> + } + >> + }{\mbox{#3}} %Widget annots should not be broken across lines + \int_gincr:N\g_ocgxii_widcount_int } - \tl_set:Nx\l_ocglistarg_tl{#2}\tl_trim_spaces:N\l_ocglistarg_tl - \tl_set:Nn\l_ocgxii_toshow_tl{} - \seq_set_split:NnV\l_ocgxii_ocglistarg_seq{~}\l_ocglistarg_tl - \seq_map_variable:NNn\l_ocgxii_ocglistarg_seq\l_tempa_tl{ - \ocgxii_process_ocgref:NN\l_ocgxii_toshow_tl\l_tempa_tl +} + +\DeclareDocumentCommand\showocg{o m +m}{ + \leavevmode + \IfNoValueTF{#1}{ + \ocgxii_ocglist_process_idlist:nn{triggerocg=onmouseup}{#2} + \ocgxii_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] + }{#3} + }{ + \ocgxii_ocglist_process_idlist:nn{#1}{#2} + \ocgxii_pdflink:nn{ + /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]>> + } + >> + }{\mbox{#3}} %Widget annots should not be broken across lines + \int_gincr:N\g_ocgxii_widcount_int } - \tl_set:Nx\l_ocglistarg_tl{#3}\tl_trim_spaces:N\l_ocglistarg_tl - \tl_set:Nn\l_ocgxii_tohide_tl{} - \seq_set_split:NnV\l_ocgxii_ocglistarg_seq{~}\l_ocglistarg_tl - \seq_map_variable:NNn\l_ocgxii_ocglistarg_seq\l_tempa_tl{ - \ocgxii_process_ocgref:NN\l_ocgxii_tohide_tl\l_tempa_tl +} + +\DeclareDocumentCommand\hideocg{o m +m}{ + \leavevmode + \IfNoValueTF{#1}{ + \ocgxii_ocglist_process_idlist:nn{triggerocg=onmouseup}{#2} + \ocgxii_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] + }{#3} + }{ + \ocgxii_ocglist_process_idlist:nn{#1}{#2} + \ocgxii_pdflink:nn{ + /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]>> + } + >> + }{\mbox{#3}} %Widget annots should not be broken across lines + \int_gincr:N\g_ocgxii_widcount_int } +} + +\DeclareDocumentCommand\actionsocg{o m m m +m}{ \leavevmode - \ocgxii_pdflink:nn{ - /Subtype/Link\ocgxii@insert@OC - /A <</S/SetOCGState - /State [ - \str_if_eq:VnF{\l_ocgxii_toswitch_tl}{}{/Toggle~\l_ocgxii_toswitch_tl}~ - \str_if_eq:VnF{\l_ocgxii_toshow_tl}{}{/ON~\l_ocgxii_toshow_tl}~ - \str_if_eq:VnF{\l_ocgxii_tohide_tl}{}{/OFF~\l_ocgxii_tohide_tl} - ] - >> - /Border [0~0~0] - }{#4} + \IfNoValueTF{#1}{ + \ocgxii_ocglist_process_idlist:nn{triggerocg=onmouseup}{#2} + \tl_set_eq:NN\l_ocgxii_toswitch_u_tl\l_ocgxii_u_list_tl + \ocgxii_ocglist_process_idlist:nn{triggerocg=onmouseup}{#3} + \tl_set_eq:NN\l_ocgxii_toshow_u_tl\l_ocgxii_u_list_tl + \ocgxii_ocglist_process_idlist:nn{triggerocg=onmouseup}{#4} + \tl_set_eq:NN\l_ocgxii_tohide_u_tl\l_ocgxii_u_list_tl + \ocgxii_pdflink:nn{ + /Subtype/Link\ocgxii@insert@OC + /A <</S/SetOCGState + /State [ + \str_if_eq:VnF{\l_ocgxii_toswitch_u_tl}{}{/Toggle~\l_ocgxii_toswitch_tl}~ + \str_if_eq:VnF{\l_ocgxii_toshow_u_tl}{}{/ON~\l_ocgxii_toshow_tl}~ + \str_if_eq:VnF{\l_ocgxii_tohide_u_tl}{}{/OFF~\l_ocgxii_tohide_tl} + ] + >> + /Border [0~0~0] + }{#5} + }{ + \ocgxii_ocglist_process_idlist:nn{#1}{#2} + \tl_set_eq:NN\l_ocgxii_toswitch_e_tl\l_ocgxii_e_list_tl + \tl_set_eq:NN\l_ocgxii_toswitch_x_tl\l_ocgxii_x_list_tl + \tl_set_eq:NN\l_ocgxii_toswitch_d_tl\l_ocgxii_d_list_tl + \tl_set_eq:NN\l_ocgxii_toswitch_u_tl\l_ocgxii_u_list_tl + \ocgxii_ocglist_process_idlist:nn{#1}{#3} + \tl_set_eq:NN\l_ocgxii_toshow_e_tl\l_ocgxii_e_list_tl + \tl_set_eq:NN\l_ocgxii_toshow_x_tl\l_ocgxii_x_list_tl + \tl_set_eq:NN\l_ocgxii_toshow_d_tl\l_ocgxii_d_list_tl + \tl_set_eq:NN\l_ocgxii_toshow_u_tl\l_ocgxii_u_list_tl + \ocgxii_ocglist_process_idlist:nn{#1}{#4} + \tl_set_eq:NN\l_ocgxii_tohide_e_tl\l_ocgxii_e_list_tl + \tl_set_eq:NN\l_ocgxii_tohide_x_tl\l_ocgxii_x_list_tl + \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 + \ocgxii_pdflink:nn{ + /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 + }{ + /U <</S/SetOCGState/State [ + \str_if_eq:VnF\l_ocgxii_toswitch_u_tl{}{ + /Toggle~\l_ocgxii_toswitch_u_tl + } + \str_if_eq:VnF\l_ocgxii_toshow_u_tl{}{ + /ON~\l_ocgxii_toshow_u_tl + } + \str_if_eq:VnF\l_ocgxii_tohide_u_tl{}{ + /OFF~\l_ocgxii_tohide_u_tl + } + ]>> + } + \str_if_eq_x:nnF{}{ + \l_ocgxii_toswitch_d_tl\l_ocgxii_toshow_d_tl\l_ocgxii_tohide_d_tl + }{ + /D <</S/SetOCGState/State [ + \str_if_eq:VnF\l_ocgxii_toswitch_d_tl{}{ + /Toggle~\l_ocgxii_toswitch_d_tl + } + \str_if_eq:VnF\l_ocgxii_toshow_d_tl{}{ + /ON~\l_ocgxii_toshow_d_tl + } + \str_if_eq:VnF\l_ocgxii_tohide_d_tl{}{ + /OFF~\l_ocgxii_tohide_d_tl + } + ]>> + } + \str_if_eq_x:nnF{}{ + \l_ocgxii_toswitch_e_tl\l_ocgxii_toshow_e_tl\l_ocgxii_tohide_e_tl + }{ + /E <</S/SetOCGState/State [ + \str_if_eq:VnF\l_ocgxii_toswitch_e_tl{}{ + /Toggle~\l_ocgxii_toswitch_e_tl + } + \str_if_eq:VnF\l_ocgxii_toshow_e_tl{}{ + /ON~\l_ocgxii_toshow_e_tl + } + \str_if_eq:VnF\l_ocgxii_tohide_e_tl{}{ + /OFF~\l_ocgxii_tohide_e_tl + } + ]>> + } + \str_if_eq_x:nnF{}{ + \l_ocgxii_toswitch_x_tl\l_ocgxii_toshow_x_tl\l_ocgxii_tohide_x_tl + }{ + /X <</S/SetOCGState/State [ + \str_if_eq:VnF\l_ocgxii_toswitch_x_tl{}{ + /Toggle~\l_ocgxii_toswitch_x_tl + } + \str_if_eq:VnF\l_ocgxii_toshow_x_tl{}{ + /ON~\l_ocgxii_toshow_x_tl + } + \str_if_eq:VnF\l_ocgxii_tohide_x_tl{}{ + /OFF~\l_ocgxii_tohide_x_tl + } + ]>> + } + >> + }{\mbox{#5}} %Widget annots should not be broken across lines + \int_gincr:N\g_ocgxii_widcount_int + } } % mimic commands from ocg-p @@ -337,6 +518,9 @@ Line~\msg_line_number: :~OCG~`#1'~is~not~defined. } \msg_set:nnn{ocgx2}{undefined~OCGs}{There~were~undefined~OCGs!} +\msg_set:nnn{ocgx2}{unknown~option}{ + Line~\msg_line_number: :~unknown~option~`#1'. +} % dvipdfmx and xelatex workaround for ocg buttons within `tikzpicture' context \cs_set:Nn\ocgxii_pdflink:nn{ |