%%
%% This is file `graphicx-psmin.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% graphicx-psmin.dtx  (with options: `graphicx-psmin')
%% 
%% ---------------------------------------
%% Copyright (C) 2005-2020 Hendri Adriaens
%% ---------------------------------------
%%
%% 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 2003/12/01 or later.
%%
%% This work has the LPPL maintenance status "maintained".
%%
%% This Current Maintainer of this work is Hendri Adriaens.
%%
%% This work consists of the file graphicx-psmin.dtx and derived file
%% graphicx-psmin.sty.
%%
%% The following files constitute the graphicx-psmin bundle and must be
%% distributed as a whole: readme, graphicx-psmin.pdf, graphicx-psmin.sty
%% and graphicx-psmin.dtx.
%%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{graphicx-psmin}
  [2020/11/14 v1.2 single PostScript graphics inclusion (HA)]
\DeclareOption*{\PassOptionsToPackage\CurrentOption{graphicx}}
\ProcessOptions\relax
\RequirePackage{graphicx}
\def\gxpsm@tempa{dvips.def}
\ifx\Gin@driver\gxpsm@tempa\else
  \PackageError{graphicx-psmin}{This package cannot be used with any
    \MessageBreak back end driver other than dvips!}\@ehd
  \def\loadgraphics{\@testopt\gxpsm@loadgraphics{}}
  \def\gxpsm@loadgraphics[#1]#2{}
  \expandafter\endinput
\fi
\ifGin@draft
  \def\loadgraphics{\@testopt\gxpsm@loadgraphics{}}
  \def\gxpsm@loadgraphics[#1]#2{}
  \expandafter\endinput
\fi
\def\gxpsm@loaded{}
\def\@namexdef#1{\expandafter\xdef\csname#1\endcsname}
\def\loadgraphics{\@testopt\gxpsm@loadgraphics{}}
\def\gxpsm@loadgraphics[#1]#2{%
  \@for\gxpsm@file:=#2\do{%
    \begingroup
    \gxpsm@checkfile\gxpsm@file{%
      \ifx\@empty#1\@empty
        \Gread@eps{\Gin@base\Gin@ext}%
      \else
        \Gread@parse@bb#1 \\
      \fi
      \@namexdef{\Gin@base\Gin@ext @llx}{\Gin@llx}%
      \@namexdef{\Gin@base\Gin@ext @lly}{\Gin@lly}%
      \@namexdef{\Gin@base\Gin@ext @urx}{\Gin@urx}%
      \@namexdef{\Gin@base\Gin@ext @ury}{\Gin@ury}%
      \gxpsm@getcfile
      \AtBeginDvi{\special{header={\Gin@base\Gin@ext}
        pre={/\gxpsm@cfile-data^^Jcurrentfile^^J%
          << /Filter /SubFileDecode^^J/DecodeParms << /EODCount 0
          /EODString (*HA-EOD-??3.1416926!!*) >>^^J>>
          /ReusableStreamDecode filter^^J%
          \@percentchar\@percentchar BeginDocument:
          \Gin@base\Gin@ext^^J%
        }
        post={\@percentchar\@percentchar EndDocument^^J%
          *HA-EOD-??3.1416926!!*^^Jdef^^J/\gxpsm@cfile-form^^J%
          << /FormType 1^^J/BBox
          [\Gin@llx\space\Gin@lly\space\Gin@urx\space\Gin@ury]^^J%
          /Matrix [1 0 0 1 0 0]^^J/PaintProc^^J{ pop^^J%
          /ostate save def^^J/showpage {} def^^J%
          /setpagedevice /pop load def^^J%
          \gxpsm@cfile-data 0 setfileposition
          \gxpsm@cfile-data cvx exec^^J%
          ostate restore^^J} bind^^J>> def%
        }
      }}%
      \xdef\gxpsm@loaded{%
        \gxpsm@loaded\ifx\gxpsm@loaded\@empty\else,\fi
        \Gin@base\Gin@ext
      }%
    }%
    \endgroup
  }%
}
\@onlypreamble\loadgraphics
\@onlypreamble\gxpsm@loadgraphics
\def\gxpsm@getcfile{%
  \edef\gxpsm@tempa{%
    \noexpand\gxpsm@g@tcfile\Gin@base\Gin@ext\noexpand\@nil
  }%
  \gxpsm@tempa
}
\def\gxpsm@g@tcfile#1\@nil{%
  \begingroup\lccode`\/`\_\lowercase{\endgroup\def\gxpsm@cfile{#1}}%
}
\def\Ginclude@graphics#1{%
  \begingroup
  \gxpsm@checkfile{#1}{%
    \@expandtwoargs\in@{,\Gin@base\Gin@ext,}{,\gxpsm@loaded,}%
    \ifin@
      \ifGin@bbox\else
        \Gin@bboxtrue
        \edef\Gin@llx{\@nameuse{\Gin@base\Gin@ext @llx}}%
        \edef\Gin@lly{\@nameuse{\Gin@base\Gin@ext @lly}}%
        \edef\Gin@urx{\@nameuse{\Gin@base\Gin@ext @urx}}%
        \edef\Gin@ury{\@nameuse{\Gin@base\Gin@ext @ury}}%
      \fi
      \Gin@setfile{psdirect}{}{\Gin@base\Gin@ext}%
    \else
      \@ifundefined{Gin@rule@\Gin@ext}{%
        \ifx\Gin@rule@*\@undefined
          \@latex@error{Unknown graphics extension: \Gin@ext}\@ehc
        \else
          \expandafter\Gin@setfile\Gin@rule@*{\Gin@base\Gin@ext}%
        \fi
      }{%
        \expandafter\expandafter\expandafter\Gin@setfile
          \csname Gin@rule@\Gin@ext\endcsname{\Gin@base\Gin@ext}%
      }%
    \fi
  }%
  \endgroup
}
\def\gxpsm@checkfile#1#2{%
  \let\input@path\Ginput@path
  \ifx\unquote@name\@undefined
    \filename@parse{#1}%
  \else
    \expandafter\filename@parse\expandafter{\detokenize{#1}}%
  \fi
  \ifx\filename@ext\relax
    \@for\Gin@temp:=\Gin@extensions\do{%
      \ifx\Gin@ext\relax
        \Gin@getbase\Gin@temp
      \fi
    }%
  \else
    \Gin@getbase{\Gin@sepdefault\filename@ext}%
    \ifx\Gin@ext\relax
      \@warning{File `#1' not found}%
      \def\Gin@base{\filename@area\filename@base}%
      \edef\Gin@ext{\Gin@sepdefault\filename@ext}%
    \fi
  \fi
  \ifx\Gin@ext\relax
    \@latex@error{File `#1' not found}%
      {I could not locate the file with any of these extensions:^^J%
      \Gin@extensions^^J\@ehc}%
  \else#2\fi
}
\def\Ginclude@psdirect#1{%
  \message{<#1>}%
  \bgroup
  \def\@tempa{!}%
  \gxpsm@getcfile
  \dimen@\Gin@req@width
  \dimen@ii.1bp%
  \divide\dimen@\dimen@ii
  \@tempdima\Gin@req@height
  \divide\@tempdima\dimen@ii
  \special{ps:@beginspecial
    \Gin@llx\space @llx \Gin@lly\space @lly
    \Gin@urx\space @urx \Gin@ury\space @ury
    \ifx\Gin@scalex\@tempa\else\number\dimen@\space @rwi\fi
    \ifx\Gin@scaley\@tempa\else\space\number\@tempdima\space @rhi\fi
    \ifGin@clip\space @clip\fi\space @setspecial^^J
    save \gxpsm@cfile-form execform restore showpage @endspecial
  }%
  \egroup
}
\endinput
%%
%% End of file `graphicx-psmin.sty'.
