%%
%% This is file `bkm-vtex.def',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% bookmark.dtx  (with options: `vtex')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2007-2009 by Heiko Oberdiek <oberdiek@uni-freiburg.de>
%% 
%% 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://www.latex-project.org/lppl.txt
%% 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".
%% 
%% This Current Maintainer of this work is Heiko Oberdiek.
%% 
%% This work consists of the main source file bookmark.dtx
%% and the derived files
%%    bookmark.sty, bookmark.pdf, bookmark.ins, bookmark.drv,
%%    bkm-dvipdfm.def, bkm-dvips.def, bkm-dvipsone.def,
%%    bkm-textures.def, bkm-pdftex.def, bkm-vtex.def,
%%    bookmark-example.tex.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{bkm-vtex.def}%
  [2009/08/13 v1.5 bookmark driver for VTeX (HO)]%
\ifvtexpdf
\else
  \PackageWarningNoLine{bookmark}{%
    The VTeX driver only supports PDF mode%
  }%
\fi
\newcount\BKM@id
\BKM@id=\z@
\def\BKM@0{00}
\newif\ifBKM@sw
\newcommand*{\bookmark}[2][]{%
  \if@filesw
    \begingroup
      \bookmarksetup{#1}%
      \ifBKM@keeplevel
      \else
        \xdef\BKM@currentlevel{\BKM@level}%
      \fi
      \edef\BKM@prev{\the\BKM@id}%
      \global\advance\BKM@id\@ne
      \BKM@swtrue
      \@whilesw\ifBKM@sw\fi{%
        \ifnum\ifBKM@startatroot\z@\else\BKM@prev\fi=\z@
          \global\BKM@startatrootfalse
          \def\BKM@parent{0}%
          \expandafter\xdef\csname BKM@\the\BKM@id\endcsname{%
            0{\BKM@level}%
          }%
          \BKM@swfalse
        \else
          \expandafter\expandafter\expandafter\BKM@getx
              \csname BKM@\BKM@prev\endcsname
          \ifnum\BKM@level>\BKM@x@level\relax
            \let\BKM@parent\BKM@prev
            \expandafter\xdef\csname BKM@\the\BKM@id\endcsname{%
              {\BKM@prev}{\BKM@level}%
            }%
            \BKM@swfalse
          \else
            \let\BKM@prev\BKM@x@parent
          \fi
        \fi
      }%
      \pdfstringdef\BKM@title{#2}%
      \BKM@vtex@title
      \edef\BKM@FLAGS{\BKM@PrintStyle}%
      \let\BKM@action\@empty
      \ifx\BKM@gotor\@empty
        \ifx\BKM@dest\@empty
          \ifx\BKM@named\@empty
            \ifx\BKM@rawaction\@empty
              \ifx\BKM@uri\@empty
                \ifx\BKM@page\@empty
                  \PackageError{bookmark}{Missing action}\@ehc
                  \def\BKM@action{!1}%
                \else
                  \edef\BKM@action{!\BKM@page}%
                \fi
              \else
                \BKM@EscapeString\BKM@uri
                \edef\BKM@action{%
                  <u=%
                    /S/URI%
                    /URI(\BKM@uri)%
                  >%
                }%
              \fi
            \else
              \edef\BKM@action{<u=\BKM@rawaction>}%
            \fi
          \else
            \BKM@EscapeName\BKM@named
            \edef\BKM@action{%
              <u=%
                /S/Named%
                /N/\BKM@named
              >%
            }%
          \fi
        \else
          \BKM@EscapeString\BKM@dest
          \edef\BKM@action{\BKM@dest}%
        \fi
      \else
        \ifx\BKM@dest\@empty
          \ifx\BKM@page\@empty
            \def\BKM@page{1}%
          \fi
          \ifx\BKM@view\@empty
            \def\BKM@view{Fit}%
          \fi
          \edef\BKM@action{/D[\BKM@page/\BKM@view]}%
        \else
          \BKM@EscapeString\BKM@dest
          \edef\BKM@action{/D(\BKM@dest)}%
        \fi
        \BKM@EscapeString\BKM@gotor
        \edef\BKM@action{%
          <u=%
            /S/GoToR%
            /F(\BKM@gotor)%
            \BKM@action
          >>%
        }%
      \fi
      \ifx\BKM@color\@empty
        \let\BKM@RGBcolor\@empty
      \else
        \expandafter\BKM@toRGB\BKM@color\@nil
      \fi
      \special{%
        !outline \BKM@action;%
        p=\BKM@parent,%
        i=\number\BKM@id,%
        s=%
          \ifBKM@open
            \ifnum\BKM@level<\BKM@openlevel
              o%
            \else
              c%
            \fi
          \else
            c%
          \fi,%
        \ifx\BKM@RGBcolor\@empty
        \else
          c=\BKM@RGBcolor,%
        \fi
        \ifnum\BKM@FLAGS>\z@
          f=\BKM@FLAGS,%
        \fi
        t=\BKM@title
      }%
    \endgroup
  \fi
}
\def\BKM@getx#1#2{%
  \def\BKM@x@parent{#1}%
  \def\BKM@x@level{#2}%
}
\def\BKM@toRGB#1 #2 #3\@nil{%
  \let\BKM@RGBcolor\@empty
  \BKM@toRGBComponent{#1}%
  \BKM@toRGBComponent{#2}%
  \BKM@toRGBComponent{#3}%
}
\def\BKM@toRGBComponent#1{%
  \dimen@=#1pt\relax
  \ifdim\dimen@>\z@
    \ifdim\dimen@<\p@
      \dimen@=255\dimen@
      \advance\dimen@ by 32768sp\relax
      \divide\dimen@ by 65536\relax
      \dimen@ii=\dimen@
      \divide\dimen@ii by 16\relax
      \edef\BKM@RGBcolor{%
        \BKM@RGBcolor
        \BKM@toHexDigit\dimen@ii
      }%
      \dimen@ii=16\dimen@ii
      \advance\dimen@-\dimen@ii
      \edef\BKM@RGBcolor{%
        \BKM@RGBcolor
        \BKM@toHexDigit\dimen@
      }%
    \else
      \edef\BKM@RGBcolor{\BKM@RGBcolor FF}%
    \fi
  \else
    \edef\BKM@RGBcolor{\BKM@RGBcolor00}%
  \fi
}
\def\BKM@toHexDigit#1{%
  \expandafter\ifcase\expandafter\@firstofone\expandafter{\number#1} %
    0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or
    8\or 9\or A\or B\or C\or D\or E\or F%
  \fi
}
\begingroup
  \catcode`\|=0 %
  \catcode`\\=12 %
  |gdef|BKM@vtex@title{%
    |@onelevel@sanitize|BKM@title
    |edef|BKM@title{|expandafter|BKM@vtex@leftparen|BKM@title\(|@nil}%
    |edef|BKM@title{|expandafter|BKM@vtex@rightparen|BKM@title\)|@nil}%
    |edef|BKM@title{|expandafter|BKM@vtex@zero|BKM@title\0|@nil}%
    |edef|BKM@title{|expandafter|BKM@vtex@one|BKM@title\1|@nil}%
    |edef|BKM@title{|expandafter|BKM@vtex@two|BKM@title\2|@nil}%
    |edef|BKM@title{|expandafter|BKM@vtex@three|BKM@title\3|@nil}%
  }%
  |gdef|BKM@vtex@leftparen#1\(#2|@nil{%
    #1%
    |ifx||#2||%
    |else
      (%
      |@ReturnAfterFi{%
        |BKM@vtex@leftparen#2|@nil
      }%
    |fi
  }%
  |gdef|BKM@vtex@rightparen#1\)#2|@nil{%
    #1%
    |ifx||#2||%
    |else
      )%
      |@ReturnAfterFi{%
        |BKM@vtex@rightparen#2|@nil
      }%
    |fi
  }%
  |gdef|BKM@vtex@zero#1\0#2|@nil{%
    #1%
    |ifx||#2||%
    |else
      |noexpand|hv@pdf@char0%
      |@ReturnAfterFi{%
        |BKM@vtex@zero#2|@nil
      }%
    |fi
  }%
  |gdef|BKM@vtex@one#1\1#2|@nil{%
    #1%
    |ifx||#2||%
    |else
      |noexpand|hv@pdf@char1%
      |@ReturnAfterFi{%
        |BKM@vtex@one#2|@nil
      }%
    |fi
  }%
  |gdef|BKM@vtex@two#1\2#2|@nil{%
    #1%
    |ifx||#2||%
    |else
      |noexpand|hv@pdf@char2%
      |@ReturnAfterFi{%
        |BKM@vtex@two#2|@nil
      }%
    |fi
  }%
  |gdef|BKM@vtex@three#1\3#2|@nil{%
    #1%
    |ifx||#2||%
    |else
      |noexpand|hv@pdf@char3%
      |@ReturnAfterFi{%
        |BKM@vtex@three#2|@nil
      }%
    |fi
  }%
|endgroup
\long\def\@ReturnafterFi#1\fi{\fi#1}
\ifBKM@atend
  \RequirePackage{atenddvi}%
  \AtEndDvi{\BKM@EndHook}%
\fi
\endinput
%%
%% End of file `bkm-vtex.def'.
