%%
%% This is file `phfsvnwatermark.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% phfsvnwatermark.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2016 by Philippe Faist <philippe.faist@bluewin.ch>
%% 
%% This file 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.
%% 
\NeedsTeXFormat{LaTeX2e}[2005/12/01]
\ProvidesPackage{phfsvnwatermark}
    [2016/08/15 v1.0 phfsvnwatermark package]
\RequirePackage{kvoptions}
\RequirePackage{calc}
\@ifpackageloaded{xcolor}{}{%
  \@ifpackageloaded{color}{}{%
    \RequirePackage{xcolor}%
  }
}
\definecolor{phfsvnversionidcolor}{rgb}{0.6,0.6,0.6}
\def\phfsvnVersionIdTagOuterFont{\normalfont\scriptsize}
\def\phfsvnVersionIdTagInnerFont{\ttfamily}
\def\phfsvn@versionidtag{%
  \begingroup%
    \color{phfsvnversionidcolor}\phfsvnVersionIdTagOuterFont%
    [\,\begingroup\phfsvnVersionIdTagInnerFont%
        {\phfsvn@versionidtag@contents}\endgroup\,]%
  \endgroup%
}
\newcommand\phfsvnVersionIdTag{%
  \@ifstar\phfsvn@smashedsvnversionidtag\phfsvn@versionidtag
}
\def\phfsvn@smashedsvnversionidtag{%
  \hspace*{0pt}\smash{\phfsvn@clap{\phfsvn@versionidtag}}
}
\def\phfsvn@clap#1{\hbox to 0pt{\hss#1\hss}}
\def\phfsvn@versionidtag@contents@svn{%
  \SVNId%
}
\def\phfsvn@doincludesvn@svn{
  \RequirePackage{svn}
}
\def\phfsvn@versionidtag@contents@gitnotsvn{%
  \SVNId\hspace*{1.5em}\SVNDate~\SVNTime\hspace*{1.5em}\SVNAuthor%
}
\def\phfsvn@doincludesvn@gitnotsvn{
  \RequirePackage{svn}%
}
\def\phfsvn@versionidtag@contents@svnmulti{%
  SVN Document Version:\hspace*{1ex}%
  \svnmainfilename~r\svnrev~\svndate~\svnauthor%
}
\def\phfsvn@doincludesvn@svnmulti{
  \PassOptionsToPackage{filehooks}{svn-multi}
  \RequirePackage{svn-multi}
}
\def\phfsvn@svnmulticurrfile@maxwidth{0.8\paperwidth}
\newsavebox\phfsvn@box@upperline
\newsavebox\phfsvn@box@lowerline
\def\phfsvn@svnmulticurrfile@upperline{%
  SVN Document Version:\hspace{1.5ex}r\svnrev~\svndate~\svnauthor}%
\def\phfsvn@svnmulticurrfile@lowerline{%
  \svnkw{Filename}:\hspace{1.5ex}r\svnfilerev~\svnfiledate~\svnfileauthor}%
\def\phfsvn@versionidtag@for@svnmulticurrfile{%
  \begingroup%
  \color{phfsvnversionidcolor}%
  \phfsvnVersionIdTagOuterFont\phfsvnVersionIdTagInnerFont%
  \sbox\phfsvn@box@upperline{\phfsvn@svnmulticurrfile@upperline}%
  \sbox\phfsvn@box@lowerline{\phfsvn@svnmulticurrfile@lowerline}%
  \begin{minipage}[t]{\minof{\phfsvn@svnmulticurrfile@maxwidth}%
      {\maxof{\wd\phfsvn@box@upperline}{\wd\phfsvn@box@lowerline}}}%
    \parindent=0pt\relax\parskip=0pt\relax%
    \raggedleft%
    \par\phfsvn@svnmulticurrfile@upperline%
    \par\phfsvn@svnmulticurrfile@lowerline%
  \end{minipage}%
  \endgroup%
}%
\def\phfsvn@doincludesvn@svnmulticurrfile{%
  \RequirePackage{currfile}%
  \RequirePackage[filehooks]{svn-multi}%
}%
\def\phfsvn@doplace@shipout{%
  \RequirePackage{eso-pic}
  \AddToShipoutPicture{%
    \setlength{\@tempdimb}{\phfsvnShipoutWatermarkXposRight}%
    \setlength{\@tempdimc}{\phfsvnShipoutWatermarkYposBaseline}%
    \setlength{\unitlength}{1pt}%
    \put(2,\strip@pt\@tempdimc){%
      \makebox(\strip@pt\@tempdimb,0)[r]%
      {\hfill\phfsvn@versionidtag}}%
  }%
}
\def\phfsvnShipoutWatermarkXposRight{0.9\paperwidth}
\def\phfsvnShipoutWatermarkYposBaseline{0.05\paperheight}
\def\phfsvn@doplace@manual{}
\SetupKeyvalOptions{
  family=phfsvn,
  prefix=phfsvn@
}
\def\phfsvn@SetupForId#1{%
  \ifcsname phfsvn@SetupForId@#1\endcsname%
    \csname phfsvn@SetupForId@#1\endcsname%
  \else%
     \PackageError{phfsvn}{Unknown SvnId method: '#1'}%
  \fi
}
\def\phfsvn@doincludesvn{}
\def\phfsvn@SetupForId@svn{
  \message{phfsvn: Using SvnId method = svn}
  \let\phfsvn@doincludesvn\phfsvn@doincludesvn@svn
  \let\phfsvn@versionidtag@contents\phfsvn@versionidtag@contents@svn
}
\def\phfsvn@SetupForId@gitnotsvn{
  \message{phfsvn: Using SvnId method = gitnotsvn}
  \let\phfsvn@doincludesvn\phfsvn@doincludesvn@gitnotsvn
  \let\phfsvn@versionidtag@contents\phfsvn@versionidtag@contents@gitnotsvn
}
\expandafter\def\csname phfsvn@SetupForId@svn-multi\endcsname{
  \message{phfsvn: Using SvnId method = svn-multi}
  \let\phfsvn@doincludesvn\phfsvn@doincludesvn@svnmulti
  \let\phfsvn@versionidtag@contents\phfsvn@versionidtag@contents@svnmulti
}
\expandafter\def\csname phfsvn@SetupForId@svn-multi-currfile\endcsname{
  \message{phfsvn: Using SvnId method = svn-multi-currfile}
  \let\phfsvn@doincludesvn\phfsvn@doincludesvn@svnmulticurrfile
  % redefine whole versionidtag, not only contents:
  \let\phfsvn@versionidtag\phfsvn@versionidtag@for@svnmulticurrfile
}
\def\phfsvn@SetupForId@{% no ID method
  \PackageWarning{phfsvn}{*** No SvnId method provided, no watermark will be displayed.}
  \phfsvn@watermarkfalse
}
\def\phfsvn@SetupPlacement#1{%
  \ifcsname phfsvn@doplace@#1\endcsname%
    \csname phfsvn@doplace@#1\endcsname%
  \else%
     \PackageError{phfsvn}{Unknown placement method: '#1'}%
  \fi
}
\DeclareStringOption[]{id}[svn]
\DeclareBoolOption[true]{watermark}
\DeclareStringOption[shipout]{placement}
\DeclareDefaultOption{%
  % We provide the standard LaTeX error.
  \@unknownoptionerror
}
\ProcessKeyvalOptions*
\phfsvn@SetupForId{\phfsvn@id}
\phfsvn@doincludesvn
\ifphfsvn@watermark
  \phfsvn@SetupPlacement{\phfsvn@placement}
\fi
\endinput
%%
%% End of file `phfsvnwatermark.sty'.
