From 266ba94198bf87cad9d0e5618c09f1ceac410c97 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Wed, 16 Dec 2009 00:54:43 +0000
Subject: hyperref update (15dec09)

git-svn-id: svn://tug.org/texlive/trunk@16418 c570f23f-e606-0410-a88d-b1316a301751
---
 .../texmf-dist/source/latex/hyperref/hyperref.dtx  | 334 ++++++++++++---------
 1 file changed, 196 insertions(+), 138 deletions(-)

(limited to 'Master/texmf-dist/source/latex/hyperref/hyperref.dtx')

diff --git a/Master/texmf-dist/source/latex/hyperref/hyperref.dtx b/Master/texmf-dist/source/latex/hyperref/hyperref.dtx
index d2681407366..35fd59c0e66 100644
--- a/Master/texmf-dist/source/latex/hyperref/hyperref.dtx
+++ b/Master/texmf-dist/source/latex/hyperref/hyperref.dtx
@@ -30,6 +30,7 @@
 %<textures>\ProvidesFile{htexture.def}
 %<dviwindo>\ProvidesFile{hdviwind.def}
 %<dvipdfm>\ProvidesFile{hdvipdfm.def}
+%<xetex>\ProvidesFile{hxetex.def}
 %<vtex>\ProvidesFile{hvtex.def}
 %<vtexhtml>\ProvidesFile{hvtexhtml.def}
 %<tex4ht>\ProvidesFile{htex4ht.def}
@@ -38,7 +39,7 @@
 %<puenc>\ProvidesFile{puenc.def}
 %<puvnenc>\ProvidesFile{puvnenc.def}
 %<puarenc>\ProvidesFile{puarenc.def}
-%<!none>  [2009/12/10 v6.79n
+%<!none>  [2009/12/15 v6.79p
 %<package>  Hypertext links for LaTeX]
 %<nohyperref>  Dummy hyperref (SR)]
 %<driver>  Hyperref documentation driver file]
@@ -52,6 +53,7 @@
 %<textures>  Hyperref driver for Textures]
 %<dviwindo>  Hyperref driver for dviwindo]
 %<dvipdfm>  Hyperref driver for dvipdfm]
+%<xetex>  Hyperref driver for XeTeX]
 %<vtex>  Hyperref driver for VTeX in PDF/PS mode]
 %<vtexhtml>  Hyperref driver for VTeX in HTML mode]
 %<tex4ht>  Hyperref driver for TeX4ht]
@@ -115,7 +117,7 @@
 \end{document}
 %</driver>
 % \fi
-% \CheckSum{24960}
+% \CheckSum{24974}
 %
 % \MakeShortVerb{|}
 % \StopEventually{}
@@ -1616,12 +1618,15 @@
         \@ifundefined{StringEncodingConvertTest}{%
         }{%
           \EdefUnescapeString\HyPsd@temp#1%
-          \StringEncodingConvertTest\HyPsd@temp\HyPsd@temp
-                                    {utf16be}{pdfdoc}{%
-            \EdefEscapeString\HyPsd@temp\HyPsd@temp
-            \global\let#1\HyPsd@temp
-            \Hy@unicodefalse
-          }{}%
+          \ifxetex
+            \StringEncodingConvertTest\HyPsd@temp\HyPsd@temp
+                                      {utf16be}{ascii}{%
+              \EdefEscapeString\HyPsd@temp\HyPsd@temp
+              \global\let#1\HyPsd@temp
+              \Hy@unicodefalse
+            }{}%
+          \else
+          \fi
         }%
       \fi
     \fi
@@ -3292,6 +3297,7 @@
 %    \end{macro}
 %    \begin{macro}{\HyPsd@Char}
 %    \begin{macrocode}
+\RequirePackage{intcalc}[2007/09/27]
 \begingroup
   \catcode0=9 %
   \catcode`\^=7 %
@@ -3897,30 +3903,8 @@
   \Hy@boolkey{final}{#1}%
 }
 \let\KV@Hyp@nolinks\KV@Hyp@draft
-\define@key{Hyp}{a4paper}[true]{%
-  \def\special@paper{210mm,297mm}%
-  \def\Hy@pageheight{842}%
-}
-\define@key{Hyp}{a5paper}[true]{%
-  \def\special@paper{148mm,210mm}%
-  \def\Hy@pageheight{595}%
-}
-\define@key{Hyp}{b5paper}[true]{%
-  \def\special@paper{176mm,250mm}%
-  \def\Hy@pageheight{709}%
-}
-\define@key{Hyp}{letterpaper}[true]{%
-  \def\special@paper{8.5in,11in}%
-  \def\Hy@pageheight{792}%
-}
-\define@key{Hyp}{legalpaper}[true]{%
-  \def\special@paper{8.5in,14in}%
-  \def\Hy@pageheight{1008}%
-}
-\define@key{Hyp}{executivepaper}[true]{%
-  \def\special@paper{7.25in,10.5in}%
-  \def\Hy@pageheight{720}%
-}
+%    \end{macrocode}
+%    \begin{macrocode}
 \define@key{Hyp}{setpagesize}[true]{%
   \Hy@boolkey{setpagesize}{#1}%
 }
@@ -4195,7 +4179,7 @@
   \fi
 }
 \define@key{Hyp}{xetex}[true]{%
-  \def\Hy@driver{hdvipdfm}%
+  \def\Hy@driver{hxetex}%
 }
 \define@key{Hyp}{pdfmark}[true]{%
   \def\Hy@driver{hdvips}%
@@ -5117,10 +5101,36 @@
 \define@key{Hyp}{pdfusetitle}[true]{%
   \Hy@boolkey[pdfusetitle]{usetitle}{#1}%
 }
-\define@key{Hyp}{pdftitle}{\pdfstringdef\@pdftitle{#1}}
-\define@key{Hyp}{pdfauthor}{\pdfstringdef\@pdfauthor{#1}}
-\define@key{Hyp}{pdfproducer}{\pdfstringdef\@pdfproducer{#1}}
-\define@key{Hyp}{pdfcreator}{\pdfstringdef\@pdfcreator{#1}}
+\def\HyXeTeX@CheckUnicode{%
+  \ifxetex
+    \ifHy@unicode
+    \else
+      \Hy@WarningNoLine{%
+        XeTeX driver only supports unicode.\MessageBreak
+        Enabling option `unicode'%
+      }%
+      \setkeys{Hyp}{unicode}%
+    \fi
+  \else
+    \let\HyXeTeX@CheckUnicode\relax
+  \fi
+}
+\define@key{Hyp}{pdftitle}{%
+  \HyXeTeX@CheckUnicode
+  \pdfstringdef\@pdftitle{#1}%
+}
+\define@key{Hyp}{pdfauthor}{%
+  \HyXeTeX@CheckUnicode
+  \pdfstringdef\@pdfauthor{#1}%
+}
+\define@key{Hyp}{pdfproducer}{%
+  \HyXeTeX@CheckUnicode
+  \pdfstringdef\@pdfproducer{#1}%
+}
+\define@key{Hyp}{pdfcreator}{%
+  \HyXeTeX@CheckUnicode
+  \pdfstringdef\@pdfcreator{#1}%
+}
 \define@key{Hyp}{pdfcreationdate}{%
   \begingroup
     \Hy@unicodefalse
@@ -5133,8 +5143,14 @@
     \pdfstringdef\@pdfmoddate{#1}%
   \endgroup
 }
-\define@key{Hyp}{pdfsubject}{\pdfstringdef\@pdfsubject{#1}}
-\define@key{Hyp}{pdfkeywords}{\pdfstringdef\@pdfkeywords{#1}}
+\define@key{Hyp}{pdfsubject}{%
+  \HyXeTeX@CheckUnicode
+  \pdfstringdef\@pdfsubject{#1}%
+}
+\define@key{Hyp}{pdfkeywords}{%
+  \HyXeTeX@CheckUnicode
+  \pdfstringdef\@pdfkeywords{#1}%
+}
 \define@key{Hyp}{pdfview}{\calculate@pdfview#1 \\}
 \define@key{Hyp}{pdflinkmargin}{\setpdflinkmargin{#1}}
 \let\setpdflinkmargin\@gobble
@@ -5252,34 +5268,23 @@
 \let\phantomsection\@empty
 \let\special@paper\@empty
 \def\HyperDestNameFilter#1{#1}
-\@ifundefined{stockwidth}{%
-  \ifdim\paperwidth>\z@
-    \ifdim\paperheight>\z@
-      \edef\special@paper{\the\paperwidth,\the\paperheight}%
-    \fi
-  \fi
-}{%
-  \ifdim\stockwidth>\z@
-    \ifdim\stockheight>\z@
-      \edef\special@paper{\the\stockwidth,\the\stockheight}%
+\AtBeginDocument{%
+  \begingroup
+    \edef\x{\@ifundefined{stockheight}\paperheight\stockheight}%
+    \dimen@=\x\relax
+    \ifdim\dimen@>\z@
+    \else
+      \dimen@=11in\relax
+      \Hy@WarningNoLine{%
+        Height of page (\expandafter\string\x) %
+        is invalid (\the\x),\MessageBreak
+        using 11in%
+      }%
     \fi
-  \fi
+    \dimen@=0.99626401\dimen@
+    \xdef\Hy@pageheight{\strip@pt\dimen@}%
+  \endgroup
 }
-\begingroup
-  \edef\x{\@ifundefined{stockheight}\paperheight\stockheight}%
-  \dimen@=\x\relax
-  \ifdim\dimen@>\z@
-  \else
-    \dimen@=11in\relax
-    \Hy@WarningNoLine{%
-      Height of page (\expandafter\string\x) %
-      is invalid (\the\x),\MessageBreak
-      using 11in%
-    }%
-  \fi
-  \dimen@=0.99626401\dimen@
-  \xdef\Hy@pageheight{\strip@pt\dimen@}%
-\endgroup
 \def\HyInd@EncapChar{\|}
 %    \end{macrocode}
 %
@@ -5562,7 +5567,7 @@
   \fi
   \ifx\Hy@driver\@empty
   \else
-    \def\Hy@temp{hdvipdfm}%
+    \def\Hy@temp{hxetex}%
     \ifxetex
       \ifx\Hy@driver\Hy@temp
       \else
@@ -5609,7 +5614,7 @@
       \def\Hy@driver{hpdftex}%
     \else
       \ifxetex
-        \def\Hy@driver{hdvipdfm}%
+        \def\Hy@driver{hxetex}%
       \else
         \ifvtexhtml
           \def\Hy@driver{hvtexhtm}%
@@ -8031,7 +8036,48 @@
 %</pdftex|vtex>
 %    \end{macrocode}
 %
-% \subsubsection{pdfmarkbase, dvipdfm}
+% \subsubsection{xetex}
+%
+%    \begin{macrocode}
+%<*xetex>
+\HyPsd@LoadUnicode
+\Hy@unicodetrue
+\ifx\HyPsd@pdfencoding\HyPsd@pdfencoding@auto
+\else
+  \let\HyPsd@pdfencoding\HyPsd@pdfencoding@unicode
+\fi
+\define@key{Hyp}{unicode}[true]{%
+  \Hy@boolkey{unicode}{#1}%
+  \ifHy@unicode
+  \else
+    \Hy@Warning{%
+      XeTeX driver only supports `unicode=true'.\MessageBreak
+      Ignoring option setting `unicode=false'%
+    }%
+    \Hy@unicodetrue
+  \fi
+}
+\define@key{Hyp}{pdfencoding}{%
+  \edef\HyPsd@temp{#1}%
+  \ifx\HyPsd@temp\HyPsd@pdfencoding@unicode
+    \let\HyPsd@pdfencoding\HyPsd@temp
+  \else
+    \ifx\HyPsd@temp\HyPsd@pdfencoding@auto
+      \let\HyPsd@pdfencoding\HyPsd@temp
+    \else
+      \HyWarning{%
+        XeTeX driver only supports `pdfencoding=unicode|auto.%
+        \MessageBreak
+        Ignoring option setting `pdfencoding=\HyPsd@temp'%
+      }%
+    \fi
+  \fi
+}
+\let\HyXeTeX@CheckUnicode\relax
+%</xetex>
+%    \end{macrocode}
+%
+% \subsubsection{pdfmarkbase, dvipdfm, xetex}
 %
 %    \begin{macrocode}
 %<*pdfmarkbase>
@@ -8056,7 +8102,7 @@
 %
 %    \begin{macro}{\Hy@PutCatalog}
 %    \begin{macrocode}
-%<dvipdfm>\def\Hy@PutCatalog#1{\@pdfm@mark{docview << #1 >>}}
+%<dvipdfm|xetex>\def\Hy@PutCatalog#1{\@pdfm@mark{docview << #1 >>}}
 %<*pdfmarkbase>
 \def\Hy@PutCatalog#1{%
   \pdfmark{pdfmark=/PUT,Raw={\string{Catalog\string} << #1 >>}}%
@@ -8066,7 +8112,7 @@
 %    \end{macro}
 %
 %    \begin{macrocode}
-%<*pdfmarkbase|dvipdfm>
+%<*pdfmarkbase|dvipdfm|xetex>
 \ifHy@pagelabels
 %    \end{macrocode}
 %
@@ -8119,7 +8165,7 @@
 %
 %    \begin{macrocode}
 \fi
-%</pdfmarkbase|dvipdfm>
+%</pdfmarkbase|dvipdfm|xetex>
 %    \end{macrocode}
 %
 %    \begin{macrocode}
@@ -10513,7 +10559,7 @@
 %    argument is the string that needs protecting.
 %    Since version 1.30.0 pdf\TeX\ offers \cs{pdfescapestring}.
 %    \begin{macrocode}
-%<*pdftex|dvipdfm|vtex|pdfmarkbase|dviwindo>
+%<*pdftex|dvipdfm|xetex|vtex|pdfmarkbase|dviwindo>
 \RequirePackage{pdftexcmds}[2009/04/10]
 \begingroup\expandafter\expandafter\expandafter\endgroup
 \expandafter\ifx\csname pdf@escapestring\endcsname\relax
@@ -10572,7 +10618,7 @@
     \let#1\Hy@gtemp
   }%
 \fi
-%</pdftex|dvipdfm|vtex|pdfmarkbase|dviwindo>
+%</pdftex|dvipdfm|xetex|vtex|pdfmarkbase|dviwindo>
 %    \end{macrocode}
 %    \end{macro}
 %
@@ -11262,7 +11308,11 @@
 }
 %    \end{macrocode}
 %
+%    Also Xe\TeX\ support \cs{pdfpagewidth} and \cs{pdfpageheight},
+%    but it does not provide \cs{pdfhorigin} and \cs{pdfvorigin}.
 %    \begin{macrocode}
+%</pdftex>
+%<*pdftex|xetex>
 \AtBeginDocument{%
   \ifHy@setpagesize
     \expandafter\@firstofone
@@ -11271,8 +11321,10 @@
   \fi
   {%
     \@ifclassloaded{seminar}{%
+%<*pdftex>
       \setlength{\pdfhorigin}{1truein}%
       \setlength{\pdfvorigin}{1truein}%
+%</pdftex>
       \ifportrait
         \ifdim\paperwidth=\z@
         \else
@@ -11294,21 +11346,17 @@
       \fi
     }{%
       \@ifundefined{stockwidth}{%
-        \ifdim\paperwidth=\z@
-        \else
+        \ifdim\paperwidth>\z@
           \setlength{\pdfpagewidth}{\paperwidth}%
         \fi
-        \ifdim\paperheight=\z@
-        \else
+        \ifdim\paperheight>\z@
           \setlength{\pdfpageheight}{\paperheight}%
         \fi
       }{%
-        \ifdim\stockwidth=\z@
-        \else
+        \ifdim\stockwidth>\z@
           \setlength{\pdfpagewidth}{\stockwidth}%
         \fi
-        \ifdim\stockheight=\z@
-        \else
+        \ifdim\stockheight>\z@
           \setlength{\pdfpageheight}{\stockheight}%
         \fi
       }%
@@ -11316,6 +11364,8 @@
   }%
   \Hy@DisableOption{setpagesize}%
 }
+%</pdftex|xetex>
+%<*pdftex>
 \def\Acrobatmenu#1#2{%
   \Hy@Acrobatmenu{#1}{#2}{%
     \pdfstartlink
@@ -11769,9 +11819,9 @@
   }%
 }
 %</dviwindo>
-%<*dvipdfm>
+%<*dvipdfm|xetex>
 %    \end{macrocode}
-% \subsection{dvipdfm dvi to PDF converter}
+% \subsection{dvipdfm/xetex dvi to PDF converter}
 % Provided by Mark Wicks (mwicks@kettering.edu)
 %    \begin{macrocode}
 \providecommand*{\XR@ext}{pdf}
@@ -12197,21 +12247,26 @@
     \@pdfm@mark{put @pages <</CropBox[\@pdfpagescrop]>>}%
   \fi
 }
+%</dvipdfm|xetex>
 %    \end{macrocode}
+%    Xe\TeX\ uses pdf\TeX's method \cs{pdfpagewidth}
+%    and \cs{pdfpageheight} for setting the paper size.
 %    \begin{macrocode}
+%<*dvipdfm>
 \AtBeginShipoutFirst{%
   \ifHy@setpagesize
     \begingroup
       \@ifundefined{stockwidth}{%
-        \ifx\special@paper\@empty
-          \special{papersize=\the\paperwidth,\the\paperheight}%
-        \else
-          \special{papersize=\special@paper}%
+        \ifdim\paperwidth>\z@
+          \ifdim\paperheight>\z@
+            \special{papersize=\the\paperwidth,\the\paperheight}%
+          \fi
         \fi
       }{%
-        \ifdim\stockwidth=\z@
-        \else
-          \special{papersize=\the\stockwidth,\the\stockheight}%
+        \ifdim\stockwidth>\z@
+          \ifdim\stockheight>\z@
+            \special{papersize=\the\stockwidth,\the\stockheight}%
+          \fi
         \fi
       }%
     \endgroup
@@ -13835,15 +13890,16 @@
   \ifHy@setpagesize
     \begingroup
       \@ifundefined{stockwidth}{%
-        \ifx\special@paper\@empty
-          \special{papersize=\the\paperwidth,\the\paperheight}%
-        \else
-          \special{papersize=\special@paper}%
+        \ifdim\paperwidth>\z@
+          \ifdim\paperheight>\z@
+            \special{papersize=\the\paperwidth,\the\paperheight}%
+          \fi
         \fi
       }{%
-        \ifdim\stockwidth=\z@
-        \else
-          \special{papersize=\the\stockwidth,\the\stockheight}%
+        \ifdim\stockwidth>\z@
+          \ifdim\stockheight>\z@
+            \special{papersize=\the\stockwidth,\the\stockheight}%
+          \fi
         \fi
       }%
     \endgroup
@@ -14061,46 +14117,48 @@
 % The Rect pair are called at the LL and UR corners of a box
 % known to \TeX.
 %    \begin{macrocode}
-\headerps@out{%
+\AfterBeginDocument{%
+  \headerps@out{%
 %    \end{macrocode}
 % Textures lives in normal points, I think. So conversion from one
 % coordinate system to another involves doing nothing.
 %
 %    \begin{macrocode}
-  /vsize {\Hy@pageheight} def%
-  /DvipsToPDF {} def%
-  /PDFToDvips {} def%
-  /BPToDvips {} def%
-  /HyperBorder  { 1 PDFToDvips } def\Hy@ps@CR
-  /H.V {pdf@hoff pdf@voff null} def\Hy@ps@CR
-  /H.B {/Rect[pdf@llx pdf@lly pdf@urx pdf@ury]} def\Hy@ps@CR
-  /H.S {%
-    currentpoint %
-    HyperBorder add /pdf@lly exch def %
-    dup DvipsToPDF 72 add /pdf@hoff exch def %
-    HyperBorder sub /pdf@llx exch def%
-  } def\Hy@ps@CR
-  /H.L {%
-    2 sub %
-    PDFToDvips /HyperBase exch def %
-    currentpoint %
-    HyperBase sub /pdf@ury exch def%
-    /pdf@urx exch def%
-  } def\Hy@ps@CR
-  /H.A {%
-    H.L %
-    currentpoint exch pop %
-    vsize 72 sub exch DvipsToPDF %
-    HyperBase sub % baseline skip
-    sub /pdf@voff exch def%
-  } def\Hy@ps@CR
-  /H.R {%
-    currentpoint %
-    HyperBorder sub /pdf@ury exch def %
-    HyperBorder add /pdf@urx exch def %
-    currentpoint exch pop vsize 72 sub %
-    exch DvipsToPDF sub /pdf@voff exch def%
-  } def\Hy@ps@CR
+    /vsize {\Hy@pageheight} def%
+    /DvipsToPDF {} def%
+    /PDFToDvips {} def%
+    /BPToDvips {} def%
+    /HyperBorder  { 1 PDFToDvips } def\Hy@ps@CR
+    /H.V {pdf@hoff pdf@voff null} def\Hy@ps@CR
+    /H.B {/Rect[pdf@llx pdf@lly pdf@urx pdf@ury]} def\Hy@ps@CR
+    /H.S {%
+      currentpoint %
+      HyperBorder add /pdf@lly exch def %
+      dup DvipsToPDF 72 add /pdf@hoff exch def %
+      HyperBorder sub /pdf@llx exch def%
+    } def\Hy@ps@CR
+    /H.L {%
+      2 sub %
+      PDFToDvips /HyperBase exch def %
+      currentpoint %
+      HyperBase sub /pdf@ury exch def%
+      /pdf@urx exch def%
+    } def\Hy@ps@CR
+    /H.A {%
+      H.L %
+      currentpoint exch pop %
+      vsize 72 sub exch DvipsToPDF %
+      HyperBase sub % baseline skip
+      sub /pdf@voff exch def%
+    } def\Hy@ps@CR
+    /H.R {%
+      currentpoint %
+      HyperBorder sub /pdf@ury exch def %
+      HyperBorder add /pdf@urx exch def %
+      currentpoint exch pop vsize 72 sub %
+      exch DvipsToPDF sub /pdf@voff exch def%
+    } def\Hy@ps@CR
+  }%
 }
 %    \end{macrocode}
 %    \begin{macrocode}
@@ -15470,17 +15528,17 @@
 %</pdftex>
 %    \end{macrocode}
 %
-% \subsection{dvipdfm}
+% \subsection{dvipdfm, xetex}
 %    D. P. Story adapted the pdf\TeX{} forms part for dvipdfm, of which
 %    version 0.12.7b or higher is required because of a bug.
 %    \begin{macrocode}
-%<*dvipdfm>
+%<*dvipdfm|xetex>
 %    \end{macrocode}
 %
 %    \begin{macro}{\@Gauge}
 %    \begin{macrocode}
 \def\@Gauge[#1]#2#3#4{% parameters, label, minimum, maximum
-  \typeout{Sorry, dvipdfm does not support FORM gauges}%
+  \typeout{Sorry, dvipdfm/XeTeX does not support FORM gauges}%
 }
 %    \end{macrocode}
 %    \end{macro}
@@ -15914,7 +15972,7 @@
   }%
   \global\let\Hy@FormObjects\relax
 }
-%</dvipdfm>
+%</dvipdfm|xetex>
 %    \end{macrocode}
 %
 % \subsection{Common forms part}
@@ -16645,7 +16703,7 @@
         Title=\expandafter\strip@prefix\meaning\Hy@temp
       }%
 %</pdfmark>
-%<*dvipdfm>
+%<*dvipdfm|xetex>
       \Hy@pstringdef\Hy@pstringName{\HyperDestNameFilter{##3}}%
       \@pdfm@mark{%
         outline \ifHy@DvipdfmxOutlineOpen
@@ -16664,7 +16722,7 @@
           >>%
         >>%
       }%
-%</dvipdfm>
+%</dvipdfm|xetex>
    }%
    {%
     \def\WriteBookmarks{0}%
-- 
cgit v1.2.3

