texlive[43587] Master/texmf-dist: ocgx2 (23mar17)

commits+karl at tug.org commits+karl at tug.org
Thu Mar 23 22:29:19 CET 2017


Revision: 43587
          http://tug.org/svn/texlive?view=revision&revision=43587
Author:   karl
Date:     2017-03-23 22:29:19 +0100 (Thu, 23 Mar 2017)
Log Message:
-----------
ocgx2 (23mar17)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/ocgx2/ChangeLog
    trunk/Master/texmf-dist/doc/latex/ocgx2/README
    trunk/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty
    trunk/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty

Modified: trunk/Master/texmf-dist/doc/latex/ocgx2/ChangeLog
===================================================================
--- trunk/Master/texmf-dist/doc/latex/ocgx2/ChangeLog	2017-03-23 21:29:07 UTC (rev 43586)
+++ trunk/Master/texmf-dist/doc/latex/ocgx2/ChangeLog	2017-03-23 21:29:19 UTC (rev 43587)
@@ -1,3 +1,9 @@
+2017-03-23
+	* v0.21 : ocgx2.sty
+	* v0.9  : ocgbase.sty
+	* fix: error when building document with nested OCGs
+	* new: ocgcolorlinks extending over line and page breaks
+
 2017-03-16
 	* v0.20 : ocgx2.sty
 	* v0.8  : ocgbase.sty

Modified: trunk/Master/texmf-dist/doc/latex/ocgx2/README
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty	2017-03-23 21:29:07 UTC (rev 43586)
+++ trunk/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty	2017-03-23 21:29:19 UTC (rev 43587)
@@ -94,7 +94,6 @@
 % The Current Maintainer of this work is A. Grahn.
 
 \RequirePackage{expl3}
-\RequirePackage{atenddvi}
 \RequirePackage{pdfbase}
 
 \def\g at ocgbase@date at tl{2017/03/16}
@@ -107,7 +106,7 @@
 \seq_new:N\g_ocgbase_ocgorder_seq
 \seq_new:N\g_ocgbase_offocgs_seq
 
-\AtEndDvi{
+\pbs_at_end_dvi:n{
   \tl_if_empty:NF\g_ocgbase_ocgs_tl{
     %global OCG array
     \pbs_pdfobj:nnn{}{array}{\g_ocgbase_ocgs_tl}
@@ -295,7 +294,7 @@
 \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}}
+  \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

Modified: trunk/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty	2017-03-23 21:29:07 UTC (rev 43586)
+++ trunk/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty	2017-03-23 21:29:19 UTC (rev 43587)
@@ -37,8 +37,8 @@
 \RequirePackage{xparse}
 \RequirePackage{l3keys2e}
 
-\def\g at ocgxii@date at tl{2017/03/16}
-\def\g at ocgxii@version at tl{0.20}
+\def\g at ocgxii@date at tl{2017/03/23}
+\def\g at ocgxii@version at tl{0.21}
 
 \ProvidesExplPackage{ocgx2}{\g at ocgxii@date at tl}{\g at ocgxii@version at tl}
 {ports `ocgx' functionality to dvips+ps2pdf, xelatex and dvipdfmx}
@@ -46,6 +46,22 @@
 %creating global definitions
 \cs_new:Npn\ocgxii at newkey#1#2{\tl_gset:cx{#1}{#2}}
 
+\AtBeginDocument{
+  \iow_now:Nx\@mainaux{
+    \token_to_str:N\providecommand\token_to_str:N\ocgxii at newkey[2]{}
+    \token_to_str:N\providecommand
+      \token_to_str:N\ocgxii at stack@on at page[2]{}
+  }
+}
+
+\msg_set:nnn{ocgx2}{missing~package}{
+  Package~`#1'~must~be~loaded~before~ocgx2.\\\\
+  Put\\\\
+  \space\space\string\usepackage#2{#1}\\
+  \space\space\string\usepackage[ocgcolorlinks]{ocgx2}\\\\
+  to~the~preamble~of~your~document.
+}
+
 %package opts
 %unknown package option error message
 \msg_set:nnnn{ocgx2}{unknown~package~option}{Unknown~package~option~`#1'.}{
@@ -124,7 +140,7 @@
   Get~an~up~to~date~version~of~`#1'.\\
   Aborting.
 }
-\@ifpackagelater{pdfbase}{2016/03/11}{}{
+\@ifpackagelater{pdfbase}{2017/03/23}{}{
   \msg_error:nnn{xsavebox}{support~outdated}{pdfbase.sty}
   \tex_endinput:D
 }
@@ -248,8 +264,8 @@
 }
 \ocgxii at stack@on at page{0}{} %initialize
 
-%end-of-page action in output routine
-\cs_new_nopar:Nn\ocgxii_at_end_page:{
+%end-of-page action
+\pbs_eop_action:n{
   %check whether end-of-page ocg stack has settled
   \iow_shipout:Nx\@mainaux{
     \token_to_str:N\ocgxii at newkey{ocgx2.oldstack.\int_use:N\g_ocgxii_page_int}{
@@ -276,12 +292,16 @@
   \seq_map_variable:cNn{
     g_pending_ocgs_on_\int_use:c{g_ocgxii_page_int}_seq
   }\l_ocgxii_arg_tl{
-    \ocgbase_oc_emc:
+    \str_if_eq_x:nnTF{\l_ocgxii_arg_tl}{(ocglink)}{
+      \ocgxii_colorlink_end:
+    }{
+      \ocgbase_oc_emc:
+    }
   }
 }
 
-%begin-of-page action in output routine
-\cs_new_nopar:Nn\ocgxii_at_begin_page:{
+%begin-of-page action (to output box background)
+\pbs_bop_action:n{
   % re-open pending ocgs
   \seq_set_eq:Nc\l_ocgxii_temp_seq{
     g_pending_ocgs_on_\int_use:c{g_ocgxii_page_int}_seq
@@ -288,7 +308,11 @@
   }
   \seq_reverse:N\l_ocgxii_temp_seq
   \seq_map_variable:NNn\l_ocgxii_temp_seq\l_ocgxii_arg_tl{
-    \ocgbase_oc_bdc:n{\l_ocgxii_arg_tl}
+    \str_if_eq_x:nnTF{\l_ocgxii_arg_tl}{(ocglink)}{
+      \ocgxii_colorlink_begin:
+    }{
+      \ocgbase_oc_bdc:n{\l_ocgxii_arg_tl}
+    }
   }
   \int_gincr:N\g_ocgxii_page_int
   % copy pending ocg stack from previous page, if it has not been initialized
@@ -303,17 +327,6 @@
 }
 \int_new:N\g_ocgxii_page_int %abs. page counter
 
-%modify output routine to manage ocgs spanning multiple pages
-\cs_set_eq:NN\ocgxii_outputpage_orig:\@outputpage
-\cs_set_nopar:Npn\@outputpage{
-  \vbox_set:Nn\@outputbox{
-    \ocgxii_at_begin_page:
-    \box_use_clear:N\@outputbox
-    \ocgxii_at_end_page:
-  }
-  \ocgxii_outputpage_orig:
-}
-
 \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
@@ -511,7 +524,7 @@
 \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}{}{
@@ -587,55 +600,125 @@
   Line~\msg_line_number: :~unknown~option~`#1'.
 }
 
-\cs_gset_eq:NN\ocgxii_atenddvi_checkimpl_orig:\AtEndDvi at CheckImpl%
-\def\AtEndDvi at CheckImpl{
-  \ocgxii_atenddvi_checkimpl_orig:
-  \cs_if_exist:NTF\AtEndDvi at LastPage{
-    \int_compare:nF{\AtEndDvi at LastPage=\value{abspage}}{
-      \cs_if_exist:NF\g_ocgxii_rerunwarned_tl{
-        \tl_new:N\g_ocgxii_rerunwarned_tl
-        \msg_warning:nn{ocgx2}{rerun}
-      }
-    }
-  }{
-    \cs_if_exist:NF\g_ocgxii_rerunwarned_tl{
-      \tl_new:N\g_ocgxii_rerunwarned_tl
-      \msg_warning:nn{ocgx2}{rerun}
-    }
-  }
-}
-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % patch hyperref to ensure compatibility with our `ocgcolorlinks' option
-% similar to http://tex.stackexchange.com/a/104227;
-% add `ocgcolorlinks' support to all drivers
+%
+% Plus:
+%
+% * add `ocgcolorlinks' support to all drivers
+%
+% * allows for `ocgcolorlinks' extending over
+%
+%      line-breaks AND page-breaks
+%
+%   with pdftex, luatex, xetex, dvipdfmx drivers
+%
+% based on Ben Lerner's solution
+%   http://tex.stackexchange.com/a/104227;
+% with some improvements
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\cs_new_nopar:Nn\ocgxii_enable_ocglinks:{
-  \def\Hy at colorlink##1{
-    \begingroup
-    \def\Hy at ocgcolor{##1}
-    \setbox0=\hbox\bgroup\color at begingroup\let\color at setgroup\begingroup
+\sys_if_output_pdf:TF{
+  \cs_new:Nn\ocgxii_literal_page:n{\pdfliteral~page~{#1}}
+}{
+  \bool_if:NT\g_ocgxii_dvipdfmx_bool{ %dvipdfmx/XeTeX
+    \cs_new:Nn\ocgxii_literal_page:n{\special{pdf:code~#1}}
   }
-  \def\Hy at endcolorlink{
-    \color at endgroup\egroup
-    \mbox{
-      \ocgbase at oc@bdc{\OBJ at OCG@print}
-      \rlap{\copy0}
-      \ocgbase at oc@emc\ocgbase at oc@bdc{\OBJ at OCG@view}
+}
+
+\bool_if:nTF{\sys_if_output_dvi_p: && !\g_ocgxii_dvipdfmx_bool}{
+  % non-breakable links in dvips
+  \cs_new_nopar:Nn\ocgxii_enable_ocglinks:{
+    \def\Hy at colorlink##1{
       \begingroup
-        \expandafter\HyColor at UseColor\Hy at ocgcolor
-        \box0
+      \def\Hy at ocgcolor{##1}
+      \setbox0=\hbox\bgroup\color at begingroup\let\color at setgroup\begingroup
+    }
+    \def\Hy at endcolorlink{
+      \color at endgroup\egroup
+      \mbox{
+        \ocgbase at oc@bdc{\OBJ at OCG@print}
+        \rlap{\copy0}
+        \ocgbase at oc@emc\ocgbase at oc@bdc{\OBJ at OCG@view}
+        \begingroup
+          \expandafter\HyColor at UseColor\Hy at ocgcolor
+          \box0
+        \endgroup
+        \ocgbase at oc@emc
+      }
       \endgroup
+    }
+  }
+}{
+  % pdftex,luatex,xetex,dvipdfmx:
+  % ocgcolorlinks that extend over line and page breaks
+  \cs_new_nopar:Nn\ocgxii_enable_ocglinks:{
+    \def\Hy at colorlink##1{
+      \ifx\Hy at setbreaklinks\@gobble
+        \ifHy at breaklinks\Hy at breaklinkstrue\fi
+      \else
+        \Hy at breaklinkstrue
+      \fi
+      \ifHy at breaklinks
+        \seq_if_in:NnT\g_ocgbase_ocgstack_seq{(ocglink)}{
+          \msg_error:nn{ocgx2}{nested~breakable~ocgcolorlinks}
+        }
+        \ocgbase_ocgstack_push:n{(ocglink)}
+        \ocgxii_ocgstack_shipout:N\g_ocgbase_ocgstack_seq
+        \begingroup
+        \gdef\ocgxii at ocgcolor{##1}
+        \ocgxii_colorlink_begin:
+      \else
+        \begingroup
+        \def\ocgxii at ocgcolor{##1}
+        \setbox0=\hbox\bgroup\color at begingroup\let\color at setgroup\begingroup
+      \fi
+    }
+    \def\Hy at endcolorlink{
+      \ifHy at breaklinks
+        \ocgxii_colorlink_end:
+        \ocgbase_ocgstack_pop:N\l_trash_tl
+        \ocgxii_ocgstack_shipout:N\g_ocgbase_ocgstack_seq
+        \endgroup
+      \else
+        \color at endgroup\egroup
+        \mbox{
+          \ocgbase at oc@bdc{\OBJ at OCG@print}
+          \rlap{\copy0}
+          \ocgbase at oc@emc\ocgbase at oc@bdc{\OBJ at OCG@view}
+          \begingroup
+            \expandafter\HyColor at UseColor\ocgxii at ocgcolor
+            \box0
+          \endgroup
+          \ocgbase at oc@emc
+        }
+        \endgroup
+      \fi
+    }
+    \cs_new_nopar:Nn\ocgxii_colorlink_begin:{
+      \ocgxii_literal_page:n{q~7~Tr}
+      \vbox_to_zero:n{
+        \vss
+        \hbox_to_zero:n{\skip_horizontal:n{2\paperwidth}.\hss}
+        \skip_vertical:n{2\paperheight}
+      }
+    }
+    \cs_new_nopar:Nn\ocgxii_colorlink_end:{
+      \ocgbase at oc@bdc{\OBJ at OCG@print}
+        \ocgxii_literal_page:n{-88888~-88888~99999~99999~re~f}
       \ocgbase at oc@emc
+      \ocgbase at oc@bdc{\OBJ at OCG@view}
+        \begingroup
+          \expandafter\HyColor at UseColor\ocgxii at ocgcolor
+          \ocgxii_literal_page:n{-88888~-88888~99999~99999~re~f}
+        \endgroup
+      \ocgbase at oc@emc
+      \ocgxii_literal_page:n{0~Tr~Q}
     }
-    \endgroup
   }
 }
 
-\RequirePackage{scrlfile}
-\bool_if:NT\l_ocgxii_ocgcolorlinks_bool{
-  \PassOptionsToPackage{colorlinks}{hyperref}
-  \AfterPackage*{hyperref}{
+\bool_if:nT\l_ocgxii_ocgcolorlinks_bool{
+  \@ifpackageloaded{hyperref}{
     \Hy at colorlinkstrue
     \Hy at AtBeginDocument{
       \ocgbase_new_ocg:nnn{OCView}{/Print<</PrintState/OFF>>}{on}
@@ -644,8 +727,20 @@
       \tl_gset:Nx\OBJ at OCG@print{\ocgbase_last_ocg:}
       \ocgxii_enable_ocglinks:
     }
+  }{
+    \msg_error:nnn{ocgx2}{missing~package}{hyperref}
   }
 }
+
+\msg_set:nnn{ocgx2}{nested~breakable~ocgcolorlinks}{
+  Breakable~OCG~color-links~cannot~be~nested.~Sorry.\\\\
+  Put\\\\
+  \space\space\string\hypersetup{breaklinks=false}...
+  \string\hypersetup{breaklinks=true}\\\\
+  around~the~outermost~of~a~group~of~nested~links.
+}
+\def\ocgxii at ocgcolor{{black}}
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 % tikz related code follows (to be enabled with package option `tikz')



More information about the tex-live-commits mailing list