diff options
author | Karl Berry <karl@freefriends.org> | 2013-01-31 00:00:31 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-01-31 00:00:31 +0000 |
commit | abb000d9b877f6ae30b59469cb8ddc0bdc2471c7 (patch) | |
tree | 988e23309732f2ed74aa6393a8720620f6d632a4 /Master/texmf-dist/tex/latex | |
parent | a39ede1ed9e87ec13ea9f8407c989fd24223afea (diff) |
media9 (30jan13)
git-svn-id: svn://tug.org/texlive/trunk@28994 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/media9/media9.sty | 218 |
1 files changed, 192 insertions, 26 deletions
diff --git a/Master/texmf-dist/tex/latex/media9/media9.sty b/Master/texmf-dist/tex/latex/media9/media9.sty index 3acd29c393a..93dfbedbe82 100644 --- a/Master/texmf-dist/tex/latex/media9/media9.sty +++ b/Master/texmf-dist/tex/latex/media9/media9.sty @@ -35,12 +35,14 @@ % The Current Maintainer of this work is A. Grahn. \RequirePackage{expl3} -\RequirePackage{xparse} +\RequirePackage{l3regex} \RequirePackage{l3keys2e} +\RequirePackage{xparse} \RequirePackage{ifpdf} +\RequirePackage{atbegshi} -\def\g@mix@date@tl{2013/01/23} -\def\g@mix@version@tl{0.21} +\def\g@mix@date@tl{2013/01/31} +\def\g@mix@version@tl{0.22} \def\g@mix@liiikerneldate{2012/07/16} \def\g@mix@liiipkgdate{2012/07/16} @@ -81,9 +83,6 @@ %testing for PDF output \bool_new:N\g_mix_pdfoutput_bool \bool_gset_false:N\g_mix_pdfoutput_bool -%\cs_if_exist:NT\pdfoutput{ -% \int_compare:nT{\pdfoutput>0}{\bool_gset_true:N\g_mix_pdfoutput_bool} -%} \ifpdf \bool_gset_true:N\g_mix_pdfoutput_bool \fi %pdfTeX version check @@ -238,6 +237,10 @@ \int_new:N\g_mix_rmcnt_int \int_new:N\l_mix_viewcnt_int %counter for 3D views per annot +\int_new:N\g@mix@page@int %abs. page counter (zero based) +\int_gset:Nn\g@mix@page@int{\c_minus_one} +\AtBeginShipout{\int_gincr:N\g@mix@page@int} + \bool_new:N\g_mix_url_bool \bool_new:N\l_mix_url_bool \bool_new:N\g_mix_iiidcalc_bool @@ -283,6 +286,16 @@ %macros for writing global defs to \jobname.aux \msg_set:nnn{media9}{rerun}{Rerun~to~get~media~labels~right!} +\msg_set:nnn{media9}{undefined~reference}{ + Line~\msg_line_number: :~Media~reference~`#1'~not~defined. +} +\msg_set:nnn{media9}{undefined~references}{ + There~were~undefined~media~references!} +\msg_set:nnn{media9}{same~label}{ + Line~\msg_line_number: :~Label~`#1'~multiply~defined. +} +\msg_set:nnn{media9}{multiple~labels}{There~were~multiply-defined~labels!} + \cs_gset:Nn\mix_keytoaux_now:nn{ \iow_now:Nx\@auxout{\token_to_str:N\mix@newkey{#1}{#2}} \bool_if:nF{ @@ -1057,6 +1070,9 @@ \tl_gtrim_spaces:N\g_mix_flashvars_tl \mix_scale:n{\l_mix_poster_box} \bool_if:NTF\g_mix_usrdraft_bool{ + \tl_if_empty:NF\g_mix_usrlabel_tl{ + \mix_keytoaux_now:nn{ann@\g_mix_usrlabel_tl}{draft} + } \mix_draftbox:n{\tl_to_str:n{#3}} }{ %embed main asset @@ -1249,11 +1265,15 @@ } \tl_if_empty:NF\g_mix_usrlabel_tl{ \mix_keytoaux_now:nn{ann@\g_mix_usrlabel_tl}{\g_mix_pdflastann_tl} + \mix_keytoaux_shipout:nn{page@\g_mix_usrlabel_tl}{ + \noexpand\the\g@mix@page@int} \mix_pdfobj:nnn{}{dict}{ /S/JavaScript/JS~( if(typeof(annotRM)=='undefined'){annotRM=new~Array();} - annotRM['\g_mix_label_tl']= - this.getAnnotRichMedia(this.pageNum,~'\g_mix_label_tl'); + if(typeof(annotRM['\g_mix_label_tl'])=='undefined'){ + annotRM['\g_mix_label_tl']= + this.getAnnotRichMedia(this.pageNum,'\g_mix_label_tl'); + } ) } \mix_pdfannot:nnnn{0pt}{0pt}{0pt}{ @@ -1428,7 +1448,7 @@ /NA~[\l_mix_naarray_tl] /SA~[\l_mix_saarray_tl] \l_mix_bg_tl\l_mix_ls_tl\l_mix_rm_tl - /XN~(#1) + /XN~(#1)/IN~(#1) } } @@ -1453,12 +1473,6 @@ perhaps~it~is~spelled~incorrectly. } -\msg_set:nnn{media9}{same~label}{ - Line~\msg_line_number: :~Label~`#1'~multiply~defined. -} - -\msg_set:nnn{media9}{multiple~labels}{ There~were~multiply-defined~labels!} - \bool_new:N\g_mix_usrdraft_bool \bool_new:N\g_mix_opt_iiidview_bool \bool_new:N\l_mix_roo_bool @@ -1476,6 +1490,7 @@ %user override automatic label label .code:n = { \tl_gset:Nx\g_mix_usrlabel_tl{#1} + \tl_gtrim_spaces:N\g_mix_usrlabel_tl \cs_if_exist:cTF{rm@#1}{ \msg_warning:nnx{media9}{same~label}{#1} \cs_if_exist:NF\g_mix_samelabel_tl{ @@ -1802,6 +1817,7 @@ \tl_set:Nn\l_mix_level_tl{\c_zero} \tl_set:Nn\l_mix_cscount_tl{\c_zero} \tl_set:Nx\l_mix_xname_tl{#1}%optional name of the view + \tl_trim_spaces:N\l_mix_xname_tl %reset 3D settings to defaults \mix_iiidreset: }, @@ -2117,24 +2133,174 @@ } %options for \mediabutton command + +%helpers for option parsing +\cs_new:Npn\mix_separate_cmd_from_actn:w#1[#2]#3\q_stop{#1} +\cs_new:Npn\mix_separate_arg_from_actn:w#1[#2]#3\q_stop{#2} +\cs_generate_variant:Nn\regex_match:nnTF{nV} +\cs_generate_variant:Nn\tl_if_blank:nF{c} + \keys_define:nn{media9/mbtn}{ overface .code:n = { - \hbox_set:Nn\l_tmpa_box{#1} - \mix_pdfxform:n{\l_tmpa_box} + \hbox_set:Nn\l_mix_poster_box{#1} + \mix_pdfxform:n{\l_mix_poster_box} \tl_gset:Nx\g_mix_overbtn_tl{\g_mix_pdflastxform_tl} }, overface .value_required:, downface .code:n = { - \hbox_set:Nn\l_tmpa_box{#1} - \mix_pdfxform:n{\l_tmpa_box} + \hbox_set:Nn\l_mix_poster_box{#1} + \mix_pdfxform:n{\l_mix_poster_box} \tl_gset:Nx\g_mix_downbtn_tl{\g_mix_pdflastxform_tl} }, downface .value_required:, - 3Dviewindex .code:n ={ + 3Dgotoview .code:n = { + \tl_set:Nx\l_tmpa_tl{#1} %extract ref + \regex_replace_once:nnN{([^:]+):??.*}{\1}\l_tmpa_tl + \tl_trim_spaces:N\l_tmpa_tl + \tl_if_exist:cTF{ann@\l_tmpa_tl}{ + \str_if_eq_x:nnF{\tl_use:c{ann@\l_tmpa_tl}}{draft}{ + \tl_set:Nx\l_tmpb_tl{#1} %extract idx + \regex_replace_once:nnN{[^:]+:?}{}\l_tmpb_tl + \tl_trim_spaces:N\l_tmpb_tl + \tl_if_blank:VF\l_tmpb_tl{ + \regex_match:nVTF{^[DFLNP]$}\l_tmpb_tl{ + \tl_set:Nx\l_mix_vidx_tl{/\l_tmpb_tl} + }{ + \regex_match:nVTF{^\d+$}\l_tmpb_tl{ + \tl_set:Nx\l_mix_vidx_tl{~\l_tmpb_tl} + }{ + \regex_replace_once:nnN{^\(\s*}{}\l_tmpb_tl + \regex_replace_once:nnN{\s*\)$}{}\l_tmpb_tl + \tl_set:Nx\l_mix_vidx_tl{~(\l_tmpb_tl)} + } + } + } + \mix_pdfobj:nnn{}{dict}{ + /S/JavaScript/JS~( + if(typeof(annotRM)=='undefined'){annotRM=new~Array();} + if(typeof(annotRM['\l_tmpa_tl'])=='undefined'){ + annotRM['\l_tmpa_tl']= + this.getAnnotRichMedia(\tl_use:c{page@\l_tmpa_tl},'\l_tmpa_tl'); + } + annotRM['\l_tmpa_tl'].activated=true; + ) + \tl_if_blank:VF\l_tmpb_tl{ + /Next~<< + /S/GoTo3DView + /TA~\tl_use:c{ann@\l_tmpa_tl} + /V\l_mix_vidx_tl + >> + } + } + \tl_gput_right:Nx\g_mix_btnactions_tl{~\g_mix_pdflastobj_tl} + } + }{ + \msg_warning:nnx{media9}{undefined~reference}{\l_tmpa_tl} + \cs_if_exist:NF\g_mix_refundefwarned_tl{ + \tl_new:N\g_mix_refundefwarned_tl + \AtEndDocument{\msg_warning:nn{media9}{undefined~references}} + } + } + }, + 3Dgotoview .value_required:, + + mediacommand .code:n = { + \tl_set:Nx\l_tmpa_tl{#1} + \regex_replace_once:nnN{([^:]+):??.*}{\1}\l_tmpa_tl %extract ref + \tl_trim_spaces:N\l_tmpa_tl + \tl_if_exist:cTF{ann@\l_tmpa_tl}{ + \str_if_eq_x:nnF{\tl_use:c{ann@\l_tmpa_tl}}{draft}{ + \tl_set:Nx\l_tmpb_tl{#1} + \regex_replace_once:nnN{[^:]+\:?}{}\l_tmpb_tl + \tl_set:Nx\l_mix_cmd_tl{ + \exp_after:wN\mix_separate_cmd_from_actn:w\l_tmpb_tl[]\q_stop} + \tl_trim_spaces:N\l_mix_cmd_tl + \tl_set:Nx\l_mix_arg_tl{ + \exp_after:wN\mix_separate_arg_from_actn:w\l_tmpb_tl[]\q_stop} + \tl_trim_spaces:N\l_mix_arg_tl + \mix_pdfobj:nnn{}{dict}{ + /S/JavaScript/JS~( + if(typeof(annotRM)=='undefined'){annotRM=new~Array();} + if(typeof(annotRM['\l_tmpa_tl'])=='undefined'){ + annotRM['\l_tmpa_tl']= + this.getAnnotRichMedia(\tl_use:c{page@\l_tmpa_tl},'\l_tmpa_tl'); + } + annotRM['\l_tmpa_tl'].activated=true; + ) + \tl_if_blank:VF\l_mix_cmd_tl{ + /Next~<< + /S/RichMediaExecute + /TA~\tl_use:c{ann@\l_tmpa_tl} + /TI~\tl_use:c{main@\l_tmpa_tl} + /CMD~<< + /C~(\l_mix_cmd_tl) + \tl_if_blank:VF\l_mix_arg_tl{ + /A~[\l_mix_arg_tl] + } + >> + >> + } + } + \tl_gput_right:Nx\g_mix_btnactions_tl{~\g_mix_pdflastobj_tl} + } + }{ + \msg_warning:nnx{media9}{undefined~reference}{\l_tmpa_tl} + \cs_if_exist:NF\g_mix_refundefwarned_tl{ + \tl_new:N\g_mix_refundefwarned_tl + \AtEndDocument{\msg_warning:nn{media9}{undefined~references}} + } + } + }, + mediacommand .value_required:, + + jsaction .code:n = { + \tl_set:Nx\l_tmpa_tl{#1} + \regex_match:nVTF{^[^\{:]+:.*$}\l_tmpa_tl{ + \regex_replace_once:nnN{([^:]+):??.*}{\1}\l_tmpa_tl %extract ref + \tl_trim_spaces:N\l_tmpa_tl + }{\tl_clear:N\l_tmpa_tl} + \tl_set:Nx\l_tmpb_tl{#1} + \tl_if_blank:VF\l_tmpa_tl{ + \tl_if_exist:cF{ann@\l_tmpa_tl}{ + \msg_warning:nnx{media9}{undefined~reference}{\l_tmpa_tl} + \cs_if_exist:NF\g_mix_refundefwarned_tl{ + \tl_new:N\g_mix_refundefwarned_tl + \AtEndDocument{\msg_warning:nn{media9}{undefined~references}} + } + } + \regex_replace_once:nnN{[^:]+\:}{}\l_tmpb_tl + } + \tl_set:Nx\l_tmpb_tl{\exp_after:wN\use:n\l_tmpb_tl} + \tl_trim_spaces:N\l_tmpb_tl + \tl_if_blank:VF\l_tmpb_tl{ + \mix_pdfobj:nnn{}{dict}{/S/JavaScript/JS~(try{\l_tmpb_tl}catch(e){})}} + \bool_if:nT{ + \tl_if_exist_p:c{ann@\l_tmpa_tl}&& + !\str_if_eq_x_p:nn{\tl_use:c{ann@\l_tmpa_tl}}{draft} + }{ + \mix_pdfobj:nnn{}{dict}{ + /S/JavaScript/JS~( + if(typeof(annotRM)=='undefined'){annotRM=new~Array();} + if(typeof(annotRM['\l_tmpa_tl'])=='undefined'){ + annotRM['\l_tmpa_tl']= + this.getAnnotRichMedia(\tl_use:c{page@\l_tmpa_tl},'\l_tmpa_tl'); + } + annotRM['\l_tmpa_tl'].activated=true; + ) + \tl_if_blank:VF\l_tmpb_tl{/Next~\g_mix_pdflastobj_tl} + } + } + \bool_if:nT{ + \tl_if_exist_p:c{ann@\l_tmpa_tl}&& + !\str_if_eq_x_p:nn{\tl_use:c{ann@\l_tmpa_tl}}{draft}|| + !\tl_if_blank_p:V\l_tmpb_tl + }{ + \tl_gput_right:Nx\g_mix_btnactions_tl{~\g_mix_pdflastobj_tl} + } }, - 3Dviewindex .value_required:, + jsaction .value_required:, unknown .code:n = { \msg_error:nnx{media9}{unknown~option}{\l_keys_key_tl} @@ -2155,11 +2321,11 @@ \keys_set:nn{media9/mbtn}{#1} \mix_uriend: %normal button appearance - \hbox_set:Nn\l_tmpa_box{#2} - \tl_set:Nx\width {\dim_use:N\box_wd:N\l_tmpa_box} - \tl_set:Nx\height{\dim_use:N\box_ht:N\l_tmpa_box} - \tl_set:Nx\depth {\dim_use:N\box_dp:N\l_tmpa_box} - \mix_pdfxform:n{\l_tmpa_box} + \hbox_set:Nn\l_mix_poster_box{#2} + \tl_set:Nx\width {\dim_use:N\box_wd:N\l_mix_poster_box} + \tl_set:Nx\height{\dim_use:N\box_ht:N\l_mix_poster_box} + \tl_set:Nx\depth {\dim_use:N\box_dp:N\l_mix_poster_box} + \mix_pdfxform:n{\l_mix_poster_box} \tl_set:Nx\g_mix_normalbtn_tl{\g_mix_pdflastxform_tl} %insert widget annotation \mix_pdfannot:nnnn{\width}{\height}{\depth}{ |