summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/latex/ocgx2/ChangeLog7
-rw-r--r--Master/texmf-dist/doc/latex/ocgx2/README39
-rw-r--r--Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty263
-rw-r--r--Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty220
4 files changed, 409 insertions, 120 deletions
diff --git a/Master/texmf-dist/doc/latex/ocgx2/ChangeLog b/Master/texmf-dist/doc/latex/ocgx2/ChangeLog
index 9268b9e1b03..039e55ed2c7 100644
--- a/Master/texmf-dist/doc/latex/ocgx2/ChangeLog
+++ b/Master/texmf-dist/doc/latex/ocgx2/ChangeLog
@@ -1,3 +1,10 @@
+2015-10-28
+ * v0.9 (ocgx2.sty)
+ * v0.1 (ocgbase.sty)
+ * new: Environment option `radiobtngrp' (adding layers to Radio Button
+ Groups), option `showingui' as a synonym for `listintoolbar';
+ code restructured for better maintenance (new file ocgbase.sty)
+
2015-09-11
* v0.8
* fix: missing option processing for ocg-p command replacements
diff --git a/Master/texmf-dist/doc/latex/ocgx2/README b/Master/texmf-dist/doc/latex/ocgx2/README
index a3096b1307c..89bdddd0c6f 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.8 [2015/09/11]
+ Version 0.9 [2015/10/28]
(C) 2015--\today Alexander Grahn
==================================
@@ -11,7 +11,8 @@
===============
The intent of this package is to be a drop-in replacement for the already
-existing package `ocgx' by Paul Gaborit.
+existing packages `ocgx' by Paul Gaborit and `ocg-p' by Werner Moshammer
+for the creation of PDF Layers.
It re-implements the functionality of the `ocg', `ocgx' and `ocg-p' packages
and adds support for all known engines and back-ends including:
@@ -22,6 +23,8 @@ and adds support for all known engines and back-ends including:
To enable dvipdfmx support, pass `dvipdfmx' globally as a class option.
+ * New feature: grouping layers into Radio Button Groups
+
Also, it adds some minor improvements, such as package options,
remembering option settings of re-opened ocgs, correct behaviour of ocg
switching links that were themselves placed on layers, compatibility
@@ -54,18 +57,34 @@ to enable these TikZ styles and read the `ocgx' documentation about their usage:
... material to be put on a PDF layer ...
\end{ocg}
-With <options> : viewocg = always | never | ifvisible
- printocg = always | never | ifvisible
- exportocg = always | never | ifvisible
- listintoolbar= always | never | iffirstuse
+With <initial visibility> = ( on | true | 1 ) | ( off | false | 0 )
+
+and <options> : viewocg = always | never | ifvisible
+ printocg = always | never | ifvisible
+ exportocg = always | never | ifvisible
+ listintoolbar= always | never | iffirstuse
+
+ not in ocgx, ocg-p:
- tikz (package-only option, see above)
+ showingui (same as `listintoolbar')
+ radiobtngrp = <group name> (string; environment-only option)
+
+ tikz (package-only option, see above)
+
+Layers can be added to one or several Radio Button Groups using the new
+option `radiobtngrp'. From all layers within a Radio Button Group only
+one can be enabled at a time. Enabling a layer, e. g. in the Layers tab
+of the PDF viewer, automatically hides the previously visible layer.
+Option `radiobtngrp' can be used repeatedly for the same OCG in order
+to add the layer to more than one Radio Button Group.
Package options have global scope. Environment options override package
-options locally. `ocg' environments can be nested.
+options locally.
+
+`ocg' environments can be nested.
See the `ocg-p' manual about the environment usage and the meaning of
-the available options:
+the remaining options:
texdoc ocg-p
@@ -87,7 +106,7 @@ For compatibility with the `ocg-p' package, the following commands have been pro
\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=...'.
+See the `ocg-p' package manual for the meaning of `triggerocg=...'.
* * *
diff --git a/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty b/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty
new file mode 100644
index 00000000000..aa24adfc294
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty
@@ -0,0 +1,263 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% ocgbase.sty
+%
+% low-level macros for OCG creation and for managment of global (document-wide)
+% OCG related lists;
+% (automatic) OCG configuration in the PDF catalog
+%
+% Copyright 2015--\today, Alexander Grahn
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% Support package for ocgx2.sty, media9.sty, animate.sty
+%
+% Supported workflows:
+%
+% pdflatex, lualatex
+% latex-->dvips-->ps2pdf or Distiller
+% latex-->dvipdfmx
+% xelatex
+%
+%
+% Package options:
+%
+% xetex,
+% dvipdfmx
+%
+%
+% Commands defined:
+%
+% \ocgbase_new_ocg:xxx
+% \ocgbase@new@ocg (LaTeX2e version)
+% #1: name (as shown in the Layers Tab of the Reader GUI)
+% #2: usage dict (may be empty), see PDF reference:
+% http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/
+% pdf_reference_1-7.pdf#G9.3858276
+% #3: initial visibility (1|0|true|false|on|off)
+%
+% \ocgbase_last_ocg:
+% \ocgbase@last@ocg (LaTeX2e version)
+% inserts ID of PDF object created during most recent call of
+% \ocgbase_new_ocg:xxx
+%
+% --------
+%
+% \ocgbase_add_to_order_list:n
+% \ocgbase@add@to@order@list (LaTeX2e version)
+% #1: PDF object ID of OCG
+% Only OCGs added to the global `Order' list using this command will show
+% up in the Layers Tab
+%
+% --------
+%
+% \ocgbase_add_to_off_list:n
+% \ocgbase@add@to@off@list (LaTeX2e version)
+% #1: PDF object ID of OCG
+% macro for belated setting of initial non-visibility of an OCG
+%
+% --------
+%
+% \ocgbase_add_ocg_to_radiobtn_grp:xxx
+% \ocgbase@add@ocg@to@radiobtn@grp
+% add OCG #2 (obj ref) to radio button group `#1' (string),
+% #3: (0|1|false|true) list OCG as part of group `#1' in the Layers Tab)
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://mirrors.ctan.org/help/Catalogue/licenses.lppl.html
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is A. Grahn.
+
+\RequirePackage{expl3}
+\RequirePackage{atenddvi}
+
+\def\g@ocgbase@date@tl{2015/10/28}
+\def\g@ocgbase@version@tl{0.1}
+
+\ProvidesExplPackage{ocgbase}{\g@ocgbase@date@tl}{\g@ocgbase@version@tl}
+{support package for ocgx2.sty}
+
+%unknown package option error message
+\msg_set:nnnn{ocgbase}{unknown~package~option}{Unknown~package~option~`#1'.}{
+ Package option~'#1'~is~unknown;\\
+ perhaps~it~is~spelled~incorrectly.
+}
+
+%package opts
+\keys_define:nn{ocgbase}{
+ xetex .code:n = {\PassOptionsToPackage{xetex}{pdfbase}},
+ dvipdfmx .code:n = {\PassOptionsToPackage{dvipdfmx}{pdfbase}}
+}
+
+%process package options
+\ProcessKeysOptions{ocgbase}
+
+\AtBeginDocument{
+ \@ifpackageloaded{pdfbase}{}{\RequirePackage{pdfbase}}
+}
+
+\tl_new:N\g_ocgbase_ocgs_tl %takes ocg object refs
+\tl_new:N\g_ocgbase_offocgs_tl
+\seq_new:N\g_ocgbase_ocgorder_seq
+
+\AtEndDvi{
+ \tl_if_empty:NF\g_ocgbase_ocgs_tl{
+ %global OCG array
+ \pbs_pdfobj:nnn{}{array}{\g_ocgbase_ocgs_tl}
+ \tl_set:Nx\l_ocgbase_ocgarray_tl{\pbs_pdflastobj:}
+ \tl_new:N\l_ocgbase_offocgentry_tl
+ %global OFF list
+ \tl_if_empty:NF\g_ocgbase_offocgs_tl{
+ \pbs_pdfobj:nnn{}{array}{\g_ocgbase_offocgs_tl}
+ \tl_set:Nx\l_ocgbase_offocgentry_tl{/OFF~\pbs_pdflastobj:}
+ }
+ %build Order list
+ \tl_new:N\l_ocgbase_ocgorderentry_tl
+ \seq_if_empty:NF\g_ocgbase_ocgorder_seq{
+ %process radio button groups in the Order array
+ \seq_map_inline:Nn\g_ocgbase_ocgorder_seq{
+ \cs_if_exist:cT{g_ocgbase_#1_rbtn_order_seq}{
+ \int_compare:nTF{\seq_count:c{g_ocgbase_#1_rbtn_groups_seq}>\c_one}{
+ \int_compare:nT{\seq_count:c{g_ocgbase_#1_rbtn_order_seq}>\c_zero}{
+ %remove all occurrences in Order array outside current rbtn group
+ \seq_map_inline:cn{g_ocgbase_#1_rbtn_order_seq}{
+ \seq_gremove_all:Nn\g_ocgbase_ocgorder_seq{##1}
+ }
+ }
+ }{
+ %ignore single-item radio button groups
+ \seq_gremove_all:Nn\g_ocgbase_ocgorder_seq{#1}
+ }
+ }
+ }
+ %second sweep on Order array to generate the final Order entry
+ \tl_new:N\l_ocgbase_ocgorder_tl
+ \seq_map_inline:Nn\g_ocgbase_ocgorder_seq{
+ \cs_if_exist:cTF{g_ocgbase_#1_rbtn_order_seq}{
+ \int_compare:nT{\seq_count:c{g_ocgbase_#1_rbtn_order_seq}>\c_zero}{
+ \tl_put_right:Nx\l_ocgbase_ocgorder_tl{
+ ~[(#1)~\seq_use:cn{g_ocgbase_#1_rbtn_order_seq}{~}]
+ }
+ }
+ }{
+ %ordinary (non-radiobutton group) item (ocg obj ref, `[', `]')
+ \tl_put_right:Nn\l_ocgbase_ocgorder_tl{~#1}
+ }
+ }
+ \tl_if_empty:NF\l_ocgbase_ocgorder_tl{
+ \pbs_pdfobj:nnn{}{array}{\l_ocgbase_ocgorder_tl}
+ \tl_set:Nx\l_ocgbase_ocgorderentry_tl{/Order~\pbs_pdflastobj:}
+ }
+ }
+ %generate RBGroups entry (radio button groups)
+ \tl_new:N\l_ocgbase_rbgroups_tl
+ \seq_map_inline:Nn\g_ocgbase_ocgorder_seq{
+ \cs_if_exist:cT{g_ocgbase_#1_rbtn_groups_seq}{
+ \int_compare:nT{\seq_count:c{g_ocgbase_#1_rbtn_groups_seq}>\c_one}{
+ \tl_put_right:Nx\l_ocgbase_rbgroups_tl{
+ ~[\seq_use:cn{g_ocgbase_#1_rbtn_groups_seq}{~}]
+ }
+ }
+ }
+ }
+ \tl_new:N\l_ocgbase_rbgroupsentry_tl
+ \tl_if_empty:NF\l_ocgbase_rbgroups_tl{
+ \pbs_pdfobj:nnn{}{array}{\l_ocgbase_rbgroups_tl}
+ \tl_set:Nx\l_ocgbase_rbgroupsentry_tl{/RBGroups~\pbs_pdflastobj:}
+ }
+ \pbs_pdfcatalog:n{
+ /OCProperties~<<
+ /OCGs~\l_ocgbase_ocgarray_tl
+ /D~<<
+ /AS~[
+ <</Event/View /Category[/View] /OCGs~\l_ocgbase_ocgarray_tl>>
+ <</Event/Print /Category[/Print] /OCGs~\l_ocgbase_ocgarray_tl>>
+ <</Event/Export/Category[/Export]/OCGs~\l_ocgbase_ocgarray_tl>>
+ ]
+ /BaseState/ON~\l_ocgbase_offocgentry_tl
+ \l_ocgbase_ocgorderentry_tl
+ \l_ocgbase_rbgroupsentry_tl
+ /ListMode/VisiblePages
+ >>
+ >>
+ }
+ }
+}
+
+%macro for inserting new OCG object
+\cs_new:Nn\ocgbase_new_ocg:nnn{
+ \pbs_pdfobj:nnn{}{dict}{
+ /Type/OCG/Name~(#1)~\tl_if_blank:oF{#2}{/Usage<<#2>>}
+ }
+ \tl_gput_right:Nx\g_ocgbase_ocgs_tl{~\g_pbs_pdflastobj_tl}
+ \bool_if:nT{
+ \str_if_eq_p:nn{#3}{\c_zero} ||
+ \str_if_eq_p:nn{#3}{off} ||
+ \str_if_eq_p:nn{#3}{false}
+ }{
+ \tl_gput_right:Nx\g_ocgbase_offocgs_tl{~\g_pbs_pdflastobj_tl}
+ \tl_new:c{off:\g_pbs_pdflastobj_tl}
+ }
+ \tl_gset_eq:NN\g_ocgbase_last_ocg_tl\g_pbs_pdflastobj_tl
+}
+\cs_generate_variant:Nn\ocgbase_new_ocg:nnn{xxx}
+
+\cs_new:Nn\ocgbase_last_ocg:{\g_ocgbase_last_ocg_tl}
+
+%macro for appending OCG object to global `Order' list
+% in Layers Tab of the GUI)
+\cs_new:Nn\ocgbase_add_to_order_list:n{
+ \seq_gput_right:Nx\g_ocgbase_ocgorder_seq{#1}
+}
+
+%macro for belated appending an OCG object ref to the global `OFF' list
+%(initial non-visibility)
+\cs_new:Nn\ocgbase_add_to_off_list:n{
+ \tl_if_exist:cF{off:#1}{
+ \tl_gput_right:Nx\g_ocgbase_offocgs_tl{~#1}\tl_new:c{off:#1}
+ }
+}
+
+\cs_new:Nn\ocgbase_add_ocg_to_radiobtn_grp:nnn{
+ % #1: rbtn group name,
+ % #2: OCG obj ref,
+ % #3: visible in Layers Tab
+ \seq_if_in:NnF\g_ocgbase_ocgorder_seq{#1}{
+ \seq_gput_right:Nn\g_ocgbase_ocgorder_seq{#1}
+ \seq_new:c{g_ocgbase_#1_rbtn_order_seq}
+ \seq_new:c{g_ocgbase_#1_rbtn_groups_seq}
+ }
+ \seq_if_in:cnTF{g_ocgbase_#1_rbtn_order_seq}{#2}{
+ \bool_if:nT{
+ \str_if_eq_p:nn{#3}{\c_zero} ||
+ \str_if_eq_p:nn{#3}{false}
+ }{
+ \seq_gremove_all:cn{g_ocgbase_#1_rbtn_order_seq}{#2}
+ }
+ }{
+ \bool_if:nF{
+ \str_if_eq_p:nn{#3}{\c_zero} ||
+ \str_if_eq_p:nn{#3}{false}
+ }{
+ \seq_gput_right:cn{g_ocgbase_#1_rbtn_order_seq}{#2}
+ }
+ }
+ \seq_gput_right:cn{g_ocgbase_#1_rbtn_groups_seq}{#2}
+}
+\cs_generate_variant:Nn\ocgbase_add_ocg_to_radiobtn_grp:nnn{xxx}
+
+%l2e versions
+\cs_gset_eq:NN\ocgbase@new@ocg\ocgbase_new_ocg:xxx
+\cs_gset_eq:NN\ocgbase@last@ocg\ocgbase_last_ocg:
+\cs_gset_eq:NN\ocgbase@add@to@order@list\ocgbase_add_to_order_list:n
+\cs_gset_eq:NN\ocgbase@add@to@off@list\ocgbase_add_to_off_list:n
+\cs_gset_eq:NN\ocgbase@add@ocg@to@radiobtn@grp\ocgbase_add_ocg_to_radiobtn_grp:xxx
diff --git a/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty b/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty
index e0da040c319..62b9c905b72 100644
--- a/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty
+++ b/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty
@@ -7,11 +7,11 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% The intent of this package is to be a drop-in replacement for the already
-% existing CTAN package `ocgx' by Paul Gaborit.
+% existing CTAN package `ocgx' by Paul Gaborit, and also for `ocg-p' and `ocg'.
%
% It re-implements the functionality of the ocg, ocgx and ocg-p packages
% and adds support for all known engines and backends including
-% latex+dvips+ps2pdf, xelatex, latex+dvipdfm, lualatex.
+% latex+dvips+ps2pdf, xelatex, latex+dvipdfmx, lualatex.
%
% Adds some minor improvements, such as package options, remembering option
% settings of reopened ocgs, correct behaviour of ocg switching links that were
@@ -33,58 +33,116 @@
% The Current Maintainer of this work is A. Grahn.
\RequirePackage{xparse}
-\RequirePackage{atenddvi}
-\RequirePackage{ifpdf}
\RequirePackage{l3keys2e}
-\AtBeginDocument{
- \@ifpackageloaded{media9}{}{\RequirePackage{media9}}
- \@ifpackagelater{media9}{2015/01/21}{}{
- \PackageError{ocgx2}{%
- Requires package `media9' v0.49 [2015/01/21] or\MessageBreak
- newer, but only v\g@mix@version@tl\space[\g@mix@date@tl] is available
- }{}%
+\ProvidesExplPackage{ocgx2}{2015/10/28}{0.9}
+{ports `ocgx' functionality to dvips+ps2pdf, xelatex and dvipdfmx}
+
+%package opts
+%unknown package option error message
+\msg_set:nnnn{ocgx2}{unknown~package~option}{Unknown~package~option~`#1'.}{
+ Package option~'#1'~is~unknown;\\
+ perhaps~it~is~spelled~incorrectly.
+}
+
+\bool_new:N\g_ocgxii_dvipdfmx_bool
+\bool_new:N\l_ocgxii_tikz_bool
+
+\keys_define:nn{ocgx2}{
+ xetex .code:n = {
+ \PassOptionsToPackage{xetex}{ocgbase}
+ },
+
+ dvipdfmx .code:n = {
+ \PassOptionsToPackage{dvipdfmx}{ocgbase}
+ \bool_gset_true:N\g_ocgxii_dvipdfmx_bool
+ },
+
+ viewocg .choice:,
+ viewocg / always .code:n={
+ \tl_gset:Nn\g_ocgxii_view_tl{/View<</ViewState/ON>>}},
+ viewocg / never .code:n={
+ \tl_gset:Nn\g_ocgxii_view_tl{/View<</ViewState/OFF>>}},
+ viewocg / ifvisible .code:n={\tl_gclear_new:N\g_ocgxii_view_tl},
+ viewocg .default:n={ifvisible},
+
+ printocg .choice:,
+ printocg / always .code:n={
+ \tl_gset:Nn\g_ocgxii_print_tl{/Print<</PrintState/ON>>}},
+ printocg / never .code:n={
+ \tl_gset:Nn\g_ocgxii_print_tl{/Print<</PrintState/OFF>>}},
+ printocg / ifvisible .code:n={\tl_gclear_new:N\g_ocgxii_print_tl},
+ printocg .default:n={ifvisible},
+
+ exportocg .choice:,
+ exportocg / always .code:n={
+ \tl_gset:Nn\g_ocgxii_export_tl{/Export<</ExportState/ON>>}},
+ exportocg / never .code:n={
+ \tl_gset:Nn\g_ocgxii_export_tl{/Export<</ExportState/OFF>>}},
+ exportocg / ifvisible .code:n={\tl_gclear_new:N\g_ocgxii_export_tl},
+ exportocg .default:n={ifvisible},
+
+ listintoolbar .choices:nn = {always,never,iffirstuse}{
+ \tl_gset:Nx\g_ocgxii_listno_tl{\int_eval:n{\l_keys_choice_int-\c_one}}
+ },
+ listintoolbar .default:n={iffirstuse},
+
+ showingui .meta:n = {listintoolbar=#1},
+ showingui .default:n={iffirstuse},
+
+ tikz .bool_set:N = \l_ocgxii_tikz_bool,
+ tikz .default:n = true,
+
+ unknown .code:n = {
+ \msg_error:nnx{ocgx2}{unknown~package~option}{\l_keys_key_tl}
}
}
-\ProvidesExplPackage{ocgx2}{2015/09/11}{0.8}
-{ports `ocgx' functionality to dvips+ps2pdf, xelatex and dvipdfmx}
+%package options preset
+\keys_set:nn{ocgx2}{viewocg,printocg,exportocg,showingui,tikz=false}
+
+%process package options
+\ProcessKeysOptions{ocgx2}
+\sys_if_engine_xetex:T{\bool_gset_true:N\g_ocgxii_dvipdfmx_bool}
+
+\RequirePackage{ocgbase}
%re-implement ocg-p's `ocg' environment
\DeclareDocumentEnvironment{ocg}{O{}mmm}{
- \bool_if:NT\g_ocgxii_nestedB_bool{\tl_gput_right:Nx\@ocgbase@ocgorder{~[}}
+ \bool_if:NT\g_ocgxii_nestedB_bool{\ocgbase_add_to_order_list:n{[}}
\bool_gset_true:N\g_ocgxii_nestedB_bool
\bool_gset_false:N\g_ocgxii_nestedE_bool
\group_begin:
\ocgxii_reset_cmd_opts: % ... to the user-set package options
\tl_if_exist:cTF{ocgxii@#3}{ %re-open existing layer
\tl_set:Nx\l_tempa_tl{\tl_use:c{ocgxii@#3.opts},#1}
- \keys_set:nV{ocgxii/user}\l_tempa_tl
+ \tl_gset:cx{ocgxii@#3.opts}{\l_tempa_tl} %new options appended
+ \keys_set:nV{ocgx2/user}\l_tempa_tl
\int_compare:nT{\l_ocgxii_listno_tl=\c_zero}{
- \tl_gput_right:Nx\@ocgbase@ocgorder{~\tl_use:c{ocgxii@#3}}
+ \ocgbase_add_to_order_list:n{\tl_use:c{ocgxii@#3}}
}
}{
\tl_gset:cn{ocgxii@#3.opts}{#1}
- \keys_set:nn{ocgxii/user}{#1}
- \mix_pdfobj:nnn{}{dict}{
- /Type/OCG/Name~(#2)/Usage<<
- \l_ocgxii_view_tl\l_ocgxii_print_tl\l_ocgxii_export_tl>>
- }
- \tl_gput_right:Nx\@ocgbase@ocgs{\space\g_mix_pdflastobj_tl}
- \int_compare:nT{#4==\c_zero}{
- \tl_gput_right:Nx\@ocgbase@offocgs{\space\g_mix_pdflastobj_tl}
- }
- \tl_gset:cx{ocgxii@#3}{\g_mix_pdflastobj_tl}
+ \keys_set:nn{ocgx2/user}{#1}
+ \ocgbase_new_ocg:xxx{#2}{
+ \l_ocgxii_view_tl\l_ocgxii_print_tl\l_ocgxii_export_tl
+ }{#4}
+ \tl_gset:cx{ocgxii@#3}{\ocgbase_last_ocg:}
\int_compare:nF{\l_ocgxii_listno_tl=\c_one}{
- \tl_gput_right:Nx\@ocgbase@ocgorder{~\g_mix_pdflastobj_tl}
+ \ocgbase_add_to_order_list:n{\ocgbase_last_ocg:}
}
\iow_now:Nx\@auxout{
\token_to_str:N\expandafter\xdef\token_to_str:N\csname
- \space OCGpdfobj#3\endcsname{\g_mix_pdflastobj_tl}
+ \space OCGpdfobj#3\endcsname{\ocgbase_last_ocg:}
+ }
+ }
+ \seq_map_inline:Nn\l_ocgxii_rbgrps_seq{% process list of radio btn groups
+ \ocgbase_add_ocg_to_radiobtn_grp:xxx{##1}{\tl_use:c{ocgxii@#3}}{
+ \int_compare:nTF{\l_ocgxii_listno_tl=\c_one}{false}{true}
}
}
\bool_if:nT{
-% !\cs_if_exist_p:c{OCGpdfobj#3} || %lazy evaluation may cease to work
+% !\cs_if_exist_p:c{OCGpdfobj#3} || %lazy evaluation may cease to work
% !\str_if_eq_x_p:nn{\use:c{OCGpdfobj#3}}{\tl_use:c{ocgxii@#3}}
!\cs_if_exist:cTF{OCGpdfobj#3}{
\str_if_eq_x_p:nn{\tl_use:c{OCGpdfobj#3}}{\tl_use:c{ocgxii@#3}}
@@ -98,15 +156,15 @@
}
}
\tl_gset:cx{OCGpdfobj#3}{\tl_use:c{ocgxii@#3}}
- \seq_gput_left:Nx\g_fixocg_ocgstack_seq{\tl_use:c{ocgxii@#3}}
+ \seq_gput_left:Nx\g_ocgxii_ocgstack_seq{\tl_use:c{ocgxii@#3}}
\group_end:
- \mix_pdfbdc:nn{/OC}{\tl_use:c{ocgxii@#3}}
+ \pbs_pdfbdc:nn{/OC}{\tl_use:c{ocgxii@#3}}
\ignorespaces
}{
\unskip
- \mix_pdfemc:
- \seq_gpop_left:NN\g_fixocg_ocgstack_seq\l_tempa_tl
- \bool_if:NT\g_ocgxii_nestedE_bool{\tl_gput_right:Nx\@ocgbase@ocgorder{~]}}
+ \pbs_pdfemc:
+ \seq_gpop_left:NN\g_ocgxii_ocgstack_seq\l_tempa_tl
+ \bool_if:NT\g_ocgxii_nestedE_bool{\ocgbase_add_to_order_list:n{]}}
\bool_gset_true:N\g_ocgxii_nestedE_bool
\bool_gset_false:N\g_ocgxii_nestedB_bool
}
@@ -114,13 +172,13 @@
\bool_new:N\g_ocgxii_nestedE_bool % nested OCG end
%stack of PDF obj references of currently open OCGs
-\seq_new:N\g_fixocg_ocgstack_seq
+\seq_new:N\g_ocgxii_ocgstack_seq
%macro that inserts /OC <<OCMD with currently open OCGs>> entry;
%for use within annotation dicts
\tl_set:Nn\ocgxii@insert@OC{
- \seq_if_empty:NF\g_fixocg_ocgstack_seq{
- /OC~<</Type/OCMD/OCGs~[\seq_use:Nn\g_fixocg_ocgstack_seq{~}]/P/AllOn>>
+ \seq_if_empty:NF\g_ocgxii_ocgstack_seq{
+ /OC~<</Type/OCMD/OCGs~[\seq_use:Nn\g_ocgxii_ocgstack_seq{~}]/P/AllOn>>
}
}
@@ -404,47 +462,8 @@
}
}
-%package opts
-\keys_define:nn{ocgxii}{
- viewocg .choice:,
- viewocg / always .code:n={
- \tl_gset:Nn\g_ocgxii_view_tl{/View<</ViewState/ON>>}},
- viewocg / never .code:n={
- \tl_gset:Nn\g_ocgxii_view_tl{/View<</ViewState/OFF>>}},
- viewocg / ifvisible .code:n={\tl_gclear_new:N\g_ocgxii_view_tl},
- viewocg .default:n={ifvisible},
-
- printocg .choice:,
- printocg / always .code:n={
- \tl_gset:Nn\g_ocgxii_print_tl{/Print<</PrintState/ON>>}},
- printocg / never .code:n={
- \tl_gset:Nn\g_ocgxii_print_tl{/Print<</PrintState/OFF>>}},
- printocg / ifvisible .code:n={\tl_gclear_new:N\g_ocgxii_print_tl},
- printocg .default:n={ifvisible},
-
- exportocg .choice:,
- exportocg / always .code:n={
- \tl_gset:Nn\g_ocgxii_export_tl{/Export<</ExportState/ON>>}},
- exportocg / never .code:n={
- \tl_gset:Nn\g_ocgxii_export_tl{/Export<</ExportState/OFF>>}},
- exportocg / ifvisible .code:n={\tl_gclear_new:N\g_ocgxii_export_tl},
- exportocg .default:n={ifvisible},
-
- listintoolbar .choices:nn = {always,never,iffirstuse}{
- \tl_gset:Nx\g_ocgxii_listno_tl{\int_eval:n{\l_keys_choice_int-\c_one}}
- },
- listintoolbar .default:n={iffirstuse},
-
- tikz .bool_set:N = \l_ocgxii_tikz_bool,
- tikz .default:n = true
-}
-
-%package options preset
-\keys_set:nn{ocgxii}{viewocg,printocg,exportocg,listintoolbar,tikz=false}
-\ProcessKeysOptions{ocgxii} %process package options
-
%command opts
-\keys_define:nn{ocgxii/user}{
+\keys_define:nn{ocgx2/user}{
viewocg .choice:,
viewocg / always .code:n={
\tl_set:Nn\l_ocgxii_view_tl{/View<</ViewState/ON>>}},
@@ -474,7 +493,15 @@
listintoolbar .choices:nn = {always,never,iffirstuse}{
\tl_set:Nx\l_ocgxii_listno_tl{\int_eval:n{\l_keys_choice_int-\c_one}}
},
- listintoolbar .default:n={iffirstuse}
+ listintoolbar .default:n={iffirstuse},
+
+ showingui .meta:n = {listintoolbar=#1},
+ showingui .default:n={iffirstuse},
+
+ radiobtngrp .code:n = {
+ \seq_put_right:Nx\l_ocgxii_rbgrps_seq{#1}
+ },
+ radiobtngrp .value_required:n = {true}
}
\cs_new:Nn\ocgxii_reset_cmd_opts:{
@@ -482,35 +509,8 @@
\tl_set_eq:NN\l_ocgxii_print_tl\g_ocgxii_print_tl
\tl_set_eq:NN\l_ocgxii_export_tl\g_ocgxii_export_tl
\tl_set_eq:NN\l_ocgxii_listno_tl\g_ocgxii_listno_tl
-}
-
-\group_begin:
-\char_set_catcode_active:N\+\let+\space
-\tl_gset:Nx\g_ocgxii_gsoldwarning_tl{
- {product~(Ghostscript)~search~{pop~pop~pop~true}{pop~false}ifelse~
- revision~915~lt~and~{
- (\token_to_str:N\n
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\token_to_str:N\n
- @@++++++++++++Warning:+Ghostscript+too+old!++++++++++++++@@\token_to_str:N\n
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\token_to_str:N\n
- @@+++++++++++++++++++++++++++++++++++++++++++++++++++++++@@\token_to_str:N\n
- @@+Package+`ocgx2'+requires+Ghostscript+version+>=+9.15.+@@\token_to_str:N\n
- @@+Otherwise,+PDF+layers+will+not+work.++++++++++++++++++@@\token_to_str:N\n
- @@+++++++++++++++++++++++++++++++++++++++++++++++++++++++@@\token_to_str:N\n
- @@+Get+current+version+from++++++++++++++++++++++++++++++@@\token_to_str:N\n
- @@+http://www.ghostscript.com/download+++++++++++++++++++@@\token_to_str:N\n
- @@+++++++++++++++++++++++++++++++++++++++++++++++++++++++@@\token_to_str:N\n
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\token_to_str:N\n)
- print}~if}~?pdfmark
-}
-\group_end:
-
-\AtBeginDocument{
- \ifpdf\else
- \bool_if:NF\g_mix_dvipdfmx_bool{
- \AtEndDvi{\special{ps::[nobreak]\g_ocgxii_gsoldwarning_tl}}
- }
- \fi
+ %stack of radio button group names the current ocg belongs to
+ \seq_clear_new:N\l_ocgxii_rbgrps_seq
}
\msg_set:nnn{ocgx2}{rerun}{Rerun~to~get~OCG~references~right!}
@@ -525,17 +525,17 @@
% dvipdfmx and xelatex workaround for ocg buttons within `tikzpicture' context
\cs_set:Nn\ocgxii_pdflink:nn{
\bool_if:nTF{
- \g_mix_dvipdfmx_bool && \cs_if_exist_p:N\pgfpictureid
+ \g_ocgxii_dvipdfmx_bool && \cs_if_exist_p:N\pgfpictureid
}{
\hbox_set:Nn\l_tmpa_box{#2}
- \mix_pdfannot:nnnn{
+ \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
}{#1}
\box_use_clear:N\l_tmpa_box
}{
- \mix_pdflink:nn{#1}{#2}
+ \pbs_pdflink:nn{#1}{#2}
}
}