summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/fixocgx/fixocgx.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/fixocgx/fixocgx.sty')
-rw-r--r--Master/texmf-dist/tex/latex/fixocgx/fixocgx.sty191
1 files changed, 191 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/fixocgx/fixocgx.sty b/Master/texmf-dist/tex/latex/fixocgx/fixocgx.sty
new file mode 100644
index 00000000000..a0b43e76df6
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/fixocgx/fixocgx.sty
@@ -0,0 +1,191 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% fixocgx.sty
+%
+% Copyright 2015--\today, Alexander Grahn
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% This package extends the usability of `ocgx' to all known engines including
+% latex+dvips+ps2pdf, xelatex and latex+dvipdfmx.
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% 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{xparse}
+\RequirePackage{atenddvi}
+
+\@ifpackageloaded{ocgx}{}{
+ \PackageError{fixocgx}{%
+ Package `fixocgx' must be loaded /after/ one of\MessageBreak
+ \space\space\string\usepackage{ocgx}\MessageBreak
+ or\MessageBreak
+ \space\space\string\usetikzlibrary{ocgx}
+ }{}%
+}
+
+\AtBeginDocument{
+ \@ifpackageloaded{media9}{}{\RequirePackage{media9}}
+ \@ifpackagelater{media9}{2015/01/21}{}{
+ \PackageError{fixocgx}{%
+ 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{fixocgx}{2015/01/23}{0.1}
+{ports `ocgx' functionality to dvips+ps2pdf, xelatex and dvipdfmx}
+
+%re-implement ocg-p's `ocg' environment
+\DeclareDocumentEnvironment{ocg}{O{}mmm}{
+ \bool_if:NT\g_fxocg_nestedB_bool{\tl_gput_right:Nx\@ocgbase@ocgorder{~[}}
+ \bool_gset_true:N\g_fxocg_nestedB_bool
+ \bool_gset_false:N\g_fxocg_nestedE_bool
+ \group_begin:
+ \tl_if_exist:cTF{#3}{ %re-open existing layer
+ \tl_set:Nx\l_tempa_tl{[ocgp]{ocg}{\use:c{#3.opts},#1}}
+ \exp_after:wN\setkeys\l_tempa_tl
+ \int_compare:nT{\@ocgp@listno=\c_zero}{
+ \tl_gput_right:Nx\@ocgbase@ocgorder{~\use:c{#3}}
+ }
+ }{
+ \tl_gset:cn{#3.opts}{#1}
+ \setkeys[ocgp]{ocg}{#1}
+ \mix_pdfobj:nnn{}{dict}{
+ /Type/OCG/Name~(#2)/Usage<<\@ocgp@print\@ocgp@export>>
+ }
+ \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{#3}{\g_mix_pdflastobj_tl}
+ \tl_gset:cx{OCGpdfobj#3}{\g_mix_pdflastobj_tl}
+ \int_compare:nF{\@ocgp@listno=\c_one}{
+ \tl_gput_right:Nx\@ocgbase@ocgorder{~\g_mix_pdflastobj_tl}
+ }
+ }
+ \group_end:
+ \mix_pdfbdc:nn{/OC}{\use:c{#3}}
+ \ignorespaces
+}{
+ \unskip
+ \mix_pdfemc:
+ \bool_if:NT\g_fxocg_nestedE_bool{\tl_gput_right:Nx\@ocgbase@ocgorder{~]}}
+ \bool_gset_true:N\g_fxocg_nestedE_bool
+ \bool_gset_false:N\g_fxocg_nestedB_bool
+}
+\bool_new:N\g_fxocg_nestedB_bool % nested OCG begin
+\bool_new:N\g_fxocg_nestedE_bool % nested OCG end
+
+%re-implement commands from ocgx.sty (all engines including ps2pdf [gs>=9.15])
+\long\def\switchocg#1#2{
+ \tl_set:Nn\l_fxocg_ocglist_tl{}
+ \seq_set_split:Nnn\l_fxocg_ocglistarg_seq{~}{#1}
+ \seq_map_variable:NNn\l_fxocg_ocglistarg_seq\l_tempa_tl{
+ \tl_put_right:Nx\l_fxocg_ocglist_tl{~\use:c{OCGpdfobj\l_tempa_tl}}
+ }
+ \leavevmode
+ \mix_pdflink:nn{
+ /Subtype/Link
+ /A <</S/SetOCGState /State [/Toggle~\l_fxocg_ocglist_tl]>>
+ /Border [0~0~0]
+ }{#2}
+}
+
+\long\def\showocg#1#2{
+ \tl_set:Nn\l_fxocg_ocglist_tl{}
+ \seq_set_split:Nnn\l_fxocg_ocglistarg_seq{~}{#1}
+ \seq_map_variable:NNn\l_fxocg_ocglistarg_seq\l_tempa_tl{
+ \tl_put_right:Nx\l_fxocg_ocglist_tl{~\use:c{OCGpdfobj\l_tempa_tl}}
+ }
+ \leavevmode
+ \mix_pdflink:nn{
+ /Subtype/Link
+ /A <</S/SetOCGState/State [/ON~\l_fxocg_ocglist_tl]>>
+ /Border [0~0~0]
+ }{#2}
+}
+
+\long\def\hideocg#1#2{
+ \tl_set:Nn\l_fxocg_ocglist_tl{}
+ \seq_set_split:Nnn\l_fxocg_ocglistarg_seq{~}{#1}
+ \seq_map_variable:NNn\l_fxocg_ocglistarg_seq\l_tempa_tl{
+ \tl_put_right:Nx\l_fxocg_ocglist_tl{~\use:c{OCGpdfobj\l_tempa_tl}}
+ }
+ \leavevmode
+ \mix_pdflink:nn{
+ /Subtype/Link
+ /A <</S/SetOCGState/State [/OFF~\l_fxocg_ocglist_tl]>>
+ /Border [0~0~0]
+ }{#2}
+}
+
+\long\def\actionsocg#1#2#3#4{
+ \tl_set:Nn\l_fxocg_toswitch_tl{}
+ \seq_set_split:Nnn\l_fxocg_ocglistarg_seq{~}{#1}
+ \seq_map_variable:NNn\l_fxocg_ocglistarg_seq\l_tempa_tl{
+ \tl_put_right:Nx\l_fxocg_toswitch_tl{~\use:c{OCGpdfobj\l_tempa_tl}}
+ }
+ \tl_set:Nn\l_fxocg_toshow_tl{}
+ \seq_set_split:Nnn\l_fxocg_ocglistarg_seq{~}{#2}
+ \seq_map_variable:NNn\l_fxocg_ocglistarg_seq\l_tempa_tl{
+ \tl_put_right:Nx\l_fxocg_toshow_tl{~\use:c{OCGpdfobj\l_tempa_tl}}
+ }
+ \tl_set:Nn\l_fxocg_tohide_tl{}
+ \seq_set_split:Nnn\l_fxocg_ocglistarg_seq{~}{#3}
+ \seq_map_variable:NNn\l_fxocg_ocglistarg_seq\l_tempa_tl{
+ \tl_put_right:Nx\l_fxocg_tohide_tl{~\use:c{OCGpdfobj\l_tempa_tl}}
+ }
+ \leavevmode
+ \mix_pdflink:nn{
+ /Subtype/Link
+ /A <</S/SetOCGState
+ /State [
+ /Toggle~\l_fxocg_toswitch_tl~/ON~\l_fxocg_toshow_tl
+ /OFF~\l_fxocg_tohide_tl
+ ]
+ >>
+ /Border [0~0~0]
+ }{#4}
+}
+
+\group_begin:
+\char_set_catcode_active:N\+\let+\space
+\tl_gset:Nx\g_fxocg_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+`fixocgx'+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_fxocg_gsoldwarning_tl}}
+ }
+ \fi
+}