%%
%% 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.
%% 
%% Project: bookmark
%% Version: 2019/06/04 v1.27
%% 
%% Copyright (C) 2007-2011 by
%%    Heiko Oberdiek <heiko.oberdiek at googlemail.com>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. This version of this license is in
%%    http://www.latex-project.org/lppl/lppl-1-3c.txt
%% and 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}%
  [2019/06/04 v1.27 bookmark driver for VTeX (HO)]%
\ifvtexpdf
\else
  \PackageWarningNoLine{bookmark}{%
    The VTeX driver only supports PDF mode%
  }%
\fi
\newcount\BKM@id
\BKM@id=\z@
\@namedef{BKM@0}{00}
\newif\ifBKM@sw
\newcommand*{\bookmark}[2][]{%
  \if@filesw
    \begingroup
      \def\bookmark@text{#2}%
      \BKM@setup{#1}%
      \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@
          \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{\bookmark@text}%
      \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{%
  \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
      (%
      |ltx@ReturnAfterFi{%
        |BKM@vtex@leftparen#2|@nil
      }%
    |fi
  }%
  |gdef|BKM@vtex@rightparen#1\)#2|@nil{%
    #1%
    |ifx||#2||%
    |else
      )%
      |ltx@ReturnAfterFi{%
        |BKM@vtex@rightparen#2|@nil
      }%
    |fi
  }%
  |gdef|BKM@vtex@zero#1\0#2|@nil{%
    #1%
    |ifx||#2||%
    |else
      |noexpand|hv@pdf@char0%
      |ltx@ReturnAfterFi{%
        |BKM@vtex@zero#2|@nil
      }%
    |fi
  }%
  |gdef|BKM@vtex@one#1\1#2|@nil{%
    #1%
    |ifx||#2||%
    |else
      |noexpand|hv@pdf@char1%
      |ltx@ReturnAfterFi{%
        |BKM@vtex@one#2|@nil
      }%
    |fi
  }%
  |gdef|BKM@vtex@two#1\2#2|@nil{%
    #1%
    |ifx||#2||%
    |else
      |noexpand|hv@pdf@char2%
      |ltx@ReturnAfterFi{%
        |BKM@vtex@two#2|@nil
      }%
    |fi
  }%
  |gdef|BKM@vtex@three#1\3#2|@nil{%
    #1%
    |ifx||#2||%
    |else
      |noexpand|hv@pdf@char3%
      |ltx@ReturnAfterFi{%
        |BKM@vtex@three#2|@nil
      }%
    |fi
  }%
|endgroup
\ifBKM@atend
  \RequirePackage{atenddvi}%
  \AtEndDvi{\BKM@EndHook}%
\fi

\endinput
%%
%% End of file `bkm-vtex.def'.
