summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-09-12 21:24:55 +0000
committerKarl Berry <karl@freefriends.org>2015-09-12 21:24:55 +0000
commitbfc8d9a37bf1ca7b4f5e97f270877f83158b665d (patch)
treeea199388651b2ee5178bf6875c844b224c6478f4 /Master
parentd501b4397bbc0f4389add919be80ccfca5b3863e (diff)
ocgx2 (12sep15)
git-svn-id: svn://tug.org/texlive/trunk@38361 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/ocgx2/ChangeLog5
-rw-r--r--Master/texmf-dist/doc/latex/ocgx2/README15
-rw-r--r--Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty318
3 files changed, 264 insertions, 74 deletions
diff --git a/Master/texmf-dist/doc/latex/ocgx2/ChangeLog b/Master/texmf-dist/doc/latex/ocgx2/ChangeLog
index 40dc77cf10b..9268b9e1b03 100644
--- a/Master/texmf-dist/doc/latex/ocgx2/ChangeLog
+++ b/Master/texmf-dist/doc/latex/ocgx2/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-11
+ * v0.8
+ * fix: missing option processing for ocg-p command replacements
+ (\toggleocgs, \showocgs etc.)
+
2015-07-20
* v0.7
* fix: expl3-related adjustments
diff --git a/Master/texmf-dist/doc/latex/ocgx2/README b/Master/texmf-dist/doc/latex/ocgx2/README
index aa8eff941df..a3096b1307c 100644
--- a/Master/texmf-dist/doc/latex/ocgx2/README
+++ b/Master/texmf-dist/doc/latex/ocgx2/README
@@ -1,7 +1,7 @@
==================================
The `ocgx2' LaTeX Package
- Version 0.7 [2015/07/20]
+ Version 0.8 [2015/09/11]
(C) 2015--\today Alexander Grahn
==================================
@@ -80,13 +80,14 @@ For details about their usage, read the `ocgx' package manual:
texdoc ocgx
-For compatibility with the `ocg-p' package, the following aliases for
-the above commands have been provided:
+For compatibility with the `ocg-p' package, the following commands have been provided:
- \toggleocgs
- \showocgs
- \hideocgs
- \setocgs
+ \toggleocgs[triggerocg=...]{<layer IDs to toggle, space separated>}{<link text>}
+ \showocgs[triggerocg=...]{<layer IDs to switch ON, space separated>}{<link text>}
+ \hideocgs[triggerocg=...]{<layer IDs to switch OFF, space separated>}{<link text>}
+ \setocgs[triggerocg=...]{<IDs to toggle>}{<IDs to switch ON>}{<IDs to switch OFF>}{<link text>}
+
+See `ocg-p' package manual for the meaning of `triggerocg=...'.
* * *
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{