Debian Codegraph @

texmf-dist/source/latex/pdfpc-movie/pdfpc-movie.dtx

raw
1 %\iffalse
2 %<*package>
3 %% \CharacterTable
4 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
5 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
6 %% Digits \0\1\2\3\4\5\6\7\8\9
7 %% Exclamation \! Double quote \" Hash (number) \#
8 %% Dollar \$ Percent \% Ampersand \&
9 %% Acute accent \' Left paren \( Right paren \)
10 %% Asterisk \* Plus \+ Comma \,
11 %% Minus \- Point \. Solidus \/
12 %% Colon \: Semicolon \; Less than \<
13 %% Equals \= Greater than \> Question mark \?
14 %% Commercial at \@ Left bracket \[ Backslash \\
15 %% Right bracket \] Circumflex \^ Underscore \_
16 %% Grave accent \` Left brace \{ Vertical bar \|
17 %% Right brace \} Tilde \~}
18 %</package>
19 %\fi
20 %\iffalse
21 % Doc-Source file to use with LaTeX2e
22 % Copyright (C) 2018 Sebastian Friedl
23 %
24 % This work is subject to the LaTeX Project Public License, Version 1.3c or -- at
25 % your option -- any later version of this license.
26 % This work consists of the files pdfpc-movie.dtx, pdfpc-movie.ins, pdfpc-movie-doc.dtx
27 % and the derived file pdfpc-movie.sty.
28 %
29 % This work has the LPPL maintenance status 'maintained'.
30 % Current maintainer of the work is Sebastian Friedl.
31 %
32 % -------------------------------------------------------------------------------------------
33 %
34 % Provides a \pdfpcmovie command for hyperlinking movies in a way compatible to the
35 % PDF Presenter Console.
36 %
37 % -------------------------------------------------------------------------------------------
38 %
39 % Please report bugs and other problems as well as suggestions for improvements
40 % to my email address ([email protected]).
41 %
42 % -------------------------------------------------------------------------------------------
43 %\fi
44 %
45 %
46 %
47 % Identify the package and force \LaTeXe:
48 % \begin{macrocode}
49 \ProvidesPackage{pdfpc-movie}%
50 [2018/07/21 v1.0 pdfpc compatible hyperlinking of movies]
51 \NeedsTeXFormat{LaTeX2e}
52 % \end{macrocode}
53 %
54 % Require additional packages needed by \sty{pdfpc-movie}:
55 % \begin{macrocode}
56 \RequirePackage{etoolbox}
57 \AtEndPreamble{\RequirePackage{hyperref}}
58 \RequirePackage{pgfkeys}
59 % \end{macrocode}
60 %
61 %
62 % \subsubsection*{Variables and options}
63 % Define some internal boolean variables required to assemble the URL parameters:
64 % \begin{macrocode}
65 \newif\if@pdfpcmovie@autostart
66 \newif\if@pdfpcmovie@loop
67 \newif\if@pdfpcmovie@noprogress
68 % \end{macrocode}
69 %
70 % Define a counter for storing the number of non-processed options:
71 % \begin{macrocode}
72 \newcount\pdfpcmovie@remopts
73 % \end{macrocode}
74 %
75 % Define a box and some dimensions to override the poster material's size:
76 % \begin{macrocode}
77 \newbox\pdfpcmovie@posterbox
78 \newdimen\pdfpcmovie@posterwd
79 \newdimen\pdfpcmovie@posterht
80 \newdimen\pdfpcmovie@posterdp
81 % \end{macrocode}
82 %
83 % Define the keys available as optional arguments of the "\pdfpcmovie" command.
84 % Each key requiring additional URL parameters advances "\pdfpcmovie@remopts" by "1":
85 % \begin{macrocode}
86 \pgfkeys{%
87 /pdfpc-movie/width/.cd, .value required,
88 .code={\pdfpcmovie@posterwd=#1\relax},
89 /pdfpc-movie/height/.cd, .value required,
90 .code={\pdfpcmovie@posterht=#1\relax},
91 /pdfpc-movie/depth/.cd, .value required,
92 .code={\pdfpcmovie@posterdp=#1\relax},
93 /pdfpc-movie/autostart/.cd, .value forbidden,
94 .code={%
95 \@pdfpcmovie@autostarttrue
96 \advance\pdfpcmovie@remopts 1\relax},
97 /pdfpc-movie/loop/.cd, .value forbidden,
98 .code={%
99 \@pdfpcmovie@looptrue
100 \advance\pdfpcmovie@remopts 1\relax},
101 /pdfpc-movie/noprogress/.cd, .value forbidden,
102 .code={%
103 \@pdfpcmovie@noprogresstrue
104 \advance\pdfpcmovie@remopts 1\relax},
105 /pdfpc-movie/start/.cd, .value required,
106 .code={%
107 \def\pdfpcmovie@start{#1}
108 \advance\pdfpcmovie@remopts 1\relax},
109 /pdfpc-movie/stop/.cd, .value required,
110 .code={%
111 \def\pdfpcmovie@stop{#1}
112 \advance\pdfpcmovie@remopts 1\relax},
113 }
114 % \end{macrocode}
115 %
116 %
117 %
118 % \subsubsection*{The \texttt{\textbackslash pdfpcmovie} macro}
119 % \begin{macro}{\pdfpcmovie}
120 % First, "\def" is used to ensure that there is a "\pdfpcmovie" command to (re-)define:
121 % \begin{macrocode}
122 \def\pdfpcmovie{}
123 \renewcommand{\pdfpcmovie}[3][]{%
124 % \end{macrocode}
125 %
126 % Leave vertical mode to ensure correct placement of the movie box
127 % if "\pdfpcmovie" is used at the beginning of a paragraph:
128 % \begin{macrocode}
129 \leavevmode%
130 % \end{macrocode}
131 %
132 % Check whether the requested movie file is present. Emit a warning if it's not:
133 % \begin{macrocode}
134 \IfFileExists{\@currdir #3}{}{\PackageWarning{pdfpc-movie}{%
135 The movie file "#3" could not be found in the current
136 directory, where it must reside for viewing.}%
137 }%
138 % \end{macrocode}
139 %
140 %
141 % Create a box with the poster content and determine its size:
142 % \begin{macrocode}
143 \setbox\pdfpcmovie@posterbox=\hbox{#2}%
144 % \end{macrocode}
145 %
146 % Reset all variables to their default values. \\
147 % After that, the optional argument containing all options gets processed:
148 % \begin{macrocode}
149 \@pdfpcmovie@autostartfalse%
150 \@pdfpcmovie@loopfalse%
151 \@pdfpcmovie@noprogressfalse%
152 \let\pdfpcmovie@start\@empty%
153 \let\pdfpcmovie@stop\@empty%
154 \pdfpcmovie@posterwd=\wd\pdfpcmovie@posterbox%
155 \pdfpcmovie@posterht=\ht\pdfpcmovie@posterbox%
156 \pdfpcmovie@posterdp=\dp\pdfpcmovie@posterbox%
157 %
158 \pdfpcmovie@remopts=0%
159 \pgfkeys{/pdfpc-movie/.cd, #1}%
160 % \end{macrocode}
161 %
162 % All hyperlink arguments appended to the file name are stored in the "\pdfpcmovie@params" variable.
163 % For every specified option, the respective hyperlink code is appended. \\
164 % If there are non-processed arguments remaining, an "&" separator is appended:
165 % \begin{macrocode}
166 \ifnum\pdfpcmovie@remopts>0\def\pdfpcmovie@params{?}%
167 \else\def\pdfpcmovie@params{}%
168 \fi%
169 %
170 \if@pdfpcmovie@autostart%
171 \edef\pdfpcmovie@params{\pdfpcmovie@params autostart}%
172 \advance\pdfpcmovie@remopts -1\relax%
173 \ifnum\pdfpcmovie@remopts>0%
174 \edef\pdfpcmovie@params{\pdfpcmovie@params\&}%
175 \fi%
176 \fi%
177 %
178 \if@pdfpcmovie@loop%
179 \edef\pdfpcmovie@params{\pdfpcmovie@params loop}%
180 \advance\pdfpcmovie@remopts -1\relax%
181 \ifnum\pdfpcmovie@remopts>0%
182 \edef\pdfpcmovie@params{\pdfpcmovie@params\&}%
183 \fi%
184 \fi%
185 %
186 \if@pdfpcmovie@noprogress%
187 \edef\pdfpcmovie@params{\pdfpcmovie@params noprogress}%
188 \advance\pdfpcmovie@remopts -1\relax%
189 \ifnum\pdfpcmovie@remopts>0%
190 \edef\pdfpcmovie@params{\pdfpcmovie@params\&}%
191 \fi%
192 \fi%
193 %
194 \ifx\pdfpcmovie@start\@empty\else%
195 \edef\pdfpcmovie@params{\pdfpcmovie@params start=\pdfpcmovie@start}%
196 \advance\pdfpcmovie@remopts -1\relax%
197 \ifnum\pdfpcmovie@remopts>0%
198 \edef\pdfpcmovie@params{\pdfpcmovie@params\&}%
199 \fi%
200 \fi%
201 %
202 \ifx\pdfpcmovie@stop\@empty\else%
203 \edef\pdfpcmovie@params{\pdfpcmovie@params stop=\pdfpcmovie@stop}%
204 \advance\pdfpcmovie@remopts -1\relax%
205 \ifnum\pdfpcmovie@remopts>0%
206 \edef\pdfpcmovie@params{\pdfpcmovie@params\&}%
207 \fi%
208 \fi%
209 %
210 %
211 %
212 % \end{macrocode}
213 %
214 % Set the size of the poster material box \dots
215 % \begin{macrocode}
216 \wd\pdfpcmovie@posterbox=\pdfpcmovie@posterwd%
217 \ht\pdfpcmovie@posterbox=\pdfpcmovie@posterht%
218 \dp\pdfpcmovie@posterbox=\pdfpcmovie@posterdp%
219 % \end{macrocode}
220 %
221 % \dots\ and -- last but not least -- create the hyperlink:
222 % \begin{macrocode}
223 \href{run:#3\pdfpcmovie@params}{\box\pdfpcmovie@posterbox}%
224 }
225 % \end{macrocode}
226 % \end{macro}
227 %
228 %
229 %
230 % \subsubsection*{Famous last words}
231 % Enough code for this package. "\endinput".
232 % \begin{macrocode}
233 \endinput
234 % \end{macrocode}