\setcounter{errorcontextlines}{100}
\listfiles
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesClass{vl-versandauftrag}
    [2022/04/28 v0.3e Dokumentenklasse (RN/PTB)]

\newcommand*\vl@lang{english}
\newcommand*\vl@version{2018}

\DeclareOption{de}{\def\vl@lang{ngerman}}
\DeclareOption{german}{\def\vl@lang{ngerman}}
\DeclareOption{ngerman}{\def\vl@lang{ngerman}}
\DeclareOption{en}{\def\vl@lang{english}}

\DeclareOption{2017}{\def\vl@version{2017}}
\DeclareOption{2018}{\def\vl@version{2018}}
\DeclareOption{2019}{\def\vl@version{2019}}
\DeclareOption{2020}{\def\vl@version{2020}}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrartcl}}

\ProcessOptions\relax
\PassOptionsToPackage{paper=a4,pagesize}{typearea}

\LoadClass[%
,fontsize=10pt
]{scrartcl}

\RequirePackage{iftex,setspace,url}
\setstretch{1.5}

\iftutex% XeLaTeX oder luaLaTeX
  \input{vl-versandauftrag-new-engines.clo}
\else
  \input{vl-versandauftrag-old-engines.clo}
\fi

\setlength\textwidth{488bp}
\setlength\textheight{741bp}

\RequirePackage{eso-pic,pict2e,picture,xcolor,relsize,trimspaces}
\RequirePackage[\vl@lang]{babel}
\RequirePackage{iflang}
\IfLanguageName{ngerman}{%
  \RequirePackage[babel=once,german=guillemets]{csquotes}
  \AtEndOfClass{\shorthandon{"}}
  \defineshorthand{"`}{\openautoquote}
  \defineshorthand{"'}{\closeautoquote}
  \MakeAutoQuote{»}{«}
}{%
  \RequirePackage[babel=once]{csquotes}
}

\definecolor{thisGray}{gray}{0.881}

\let\vl@tempdima=\@ovxx
\let\vl@tempdimb=\@ovyy
\let\vl@tempdimc=\@ovdx
\let\vl@tempdimd=\@clnwd
\let\vl@tempdime=\@clnht
\let\vl@tempdimf=\@dashdim
\newcommand\vl@tempa{}
\newcommand\vl@tempb{}

\newdimen\vl@fontdim
\newdimen\vl@upperfontdim
\newdimen\vl@lowerfontdim
\newif\if@vl@moreiterations
\vl@fontdim=12pt %

\newcommand\vl@buildbox[2]{%
  \setbox0\vbox{\hbox{\parbox{#1}{%
    \fontsize{\vl@fontdim}{\vl@fontdim}\selectfont #2}}}%
  \dimen@\ht0 %
  \advance\dimen@\dp0 %
}

% Modifiziert nach:
% http://tex.stackexchange.com/questions/26002/fit-text-into-given-box-by-adjusting-the-fontsize
% siehe auch: http://www.tug.org/TUGboat/tb29-1/tb91pearls.pdf
%
% Verhält sich wie \parbox, wenn Text in vorgegebene Höhe passt,
% sonst Reduktion der Schriftgröße.
\newcommand\lfitbox[4][c]{% [pos] <width> <height> <stuff>
  \vl@buildbox{#2}{#4}%
  \ifdim\dimen@<#3\relax
    \parbox[#1][#3]{#2}{#4}%
  \else
    % Compute upper and lower bounds
    \loop
      \vl@fontdim.5\vl@fontdim % Reduce font size by half
      \vl@buildbox{#2}{#4}%
    \ifdim\dimen@>#3\relax \repeat
    \vl@lowerfontdim\vl@fontdim
    \vl@upperfontdim=2\vl@fontdim
    \vl@fontdim=1.5\vl@fontdim
    % Now try to find the optimum size
    \loop
      %\message{Bounds: \the\vl@lowerfontdim\space
      %         \the\vl@fontdim\space \the\vl@upperfontdim^^J}
      \vl@buildbox{#2}{#4}%
      \ifdim\dimen@>#3\relax %
        \@vl@moreiterationstrue
        \vl@upperfontdim\vl@fontdim
        \advance\vl@fontdim\vl@lowerfontdim
        \vl@fontdim=.5\vl@fontdim
      \else
        \advance\dimen@-#3\relax %
        \ifdim\dimen@<10pt %
          \vl@lowerfontdim\vl@fontdim
          \advance\vl@fontdim\vl@upperfontdim
          \vl@fontdim=.5\vl@fontdim
          \dimen@\vl@upperfontdim
          \advance\dimen@-\vl@lowerfontdim
          \ifdim\dimen@<.2pt %
            \@vl@moreiterationsfalse
          \else
            \@vl@moreiterationstrue
          \fi
        \else
          \@vl@moreiterationsfalse
        \fi
      \fi
    \if@vl@moreiterations \repeat
    \parbox[#1][#3]{#2}{\fontsize{\vl@fontdim}{\vl@fontdim}\selectfont#4}%
  \fi
}

\newcommand*\vl@setboolean[3][false]{%  #1=default (opt.), #2=if, #3=value
  \edef\vl@tempa{\trim@spaces{#3}}%
  \expandafter\csname #2\ifx\@empty\vl@tempa #1\else\vl@tempa\fi\endcsname
}

\newcommand*\vl@setcounter[3][0]{%  #1=default (opt.), #2=counter, #3=value
  \edef\vl@tempa{\trim@spaces{#3}}%
  \setcounter{#2}{\ifx\@empty\vl@tempa #1\else\vl@tempa\fi}%
}

\newcommand*\vl@setcommand[3][]{%  #1=default (opt.), #2=macro, #3=value
  \edef\vl@tempa{\trim@spaces@noexp{#3}}%
  \expandafter\protected@xdef\csname #2\endcsname{%
    \ifx\@empty\vl@tempa #1\else\vl@tempa\fi}%
}

\newcommand*\Inland[1]{}% nur wegen Kompatibilität zur 2017er Version
\newcommand*\EU[1]{}% nur wegen Kompatibilität zur 2017er Version 
\newcommand*\ShippingComment[1]{}

\newcommand*\Account[1]{}% dummy
\newcommand*\Value[1]{}% dummy

\newcommand*\vl@CalibrationCosts{}
\newcommand*\CalibrationCosts[1]{\vl@setcommand{vl@CalibrationCosts}{#1}}
\newcommand*\vl@ShippingNo{}
\newcommand*\ShippingNo[1]{\vl@setcommand{vl@ShippingNo}{#1}}
\newcommand*\vl@ShippingName{}
\newcommand*\ShippingName[1]{\vl@setcommand{vl@ShippingName}{#1}}
\newcommand*\vl@ShippingContact{}
\newcommand*\ShippingContact[1]{\vl@setcommand{vl@ShippingContact}{#1}}
\newcommand*\vl@ShippingStreet{}
\newcommand*\ShippingStreet[1]{\vl@setcommand{vl@ShippingStreet}{#1}}
\newcommand*\vl@ShippingTown{}
\newcommand*\ShippingTown[1]{\vl@setcommand{vl@ShippingTown}{#1}}
\newcommand*\vl@ShippingZipcode{}
\newcommand*\ShippingZipcode[1]{\vl@setcommand{vl@ShippingZipcode}{#1}}
\newcommand*\vl@ShippingLand{}
\newcommand*\ShippingLand[1]{\vl@setcommand{vl@ShippingLand}{#1}}
\newcommand*\vl@ShippingEmail{}
\newcommand*\ShippingEmail[1]{\vl@setcommand{vl@ShippingEmail}{#1}}
\newcommand*\vl@ShippingPhone{}
\newcommand*\ShippingPhone[1]{\vl@setcommand{vl@ShippingPhone}{#1}}
%%\newcommand*\vl@ShippingComment{}
%%\newcommand*\ShippingComment[1]{\vl@setcommand{vl@ShippingComment}{#1}}
\newcommand*\vl@CostUnit{}
\newcommand*\CostUnit[1]{\vl@setcommand{vl@CostUnit}{#1}}
\newcommand*\vl@FinanceUnit{}
\newcommand*\FinanceUnit[1]{\vl@setcommand{vl@FinanceUnit}{#1}}
\newcommand*\vl@SAPNo{}
\newcommand*\SAPNo[1]{\vl@setcommand{vl@SAPNo}{#1}}
\newcommand*\vl@IndicationOfValue{}
\newcommand*\IndicationOfValue[1]{\vl@setcommand{vl@IndicationOfValue}{#1}}
\newcommand*\vl@WorkingGroup{}
\newcommand*\WorkingGroup[1]{\vl@setcommand{vl@WorkingGroup}{#1}}
\newcommand*\vl@TelefonExtension{}
\newcommand*\TelefonExtension[1]{\vl@setcommand{vl@TelefonExtension}{#1}}
\newcommand*\vl@Date{}
\newcommand*\Date[1]{\vl@setcommand{vl@Date}{#1}}
\newcommand*\vl@Content{}
\newcommand*\Content[1]{\vl@setcommand{vl@Content}{#1}}
\newcommand*\vl@Purchaser{}
\newcommand*\Purchaser[1]{\vl@setcommand{vl@Purchaser}{#1}}
\newcommand*\vl@Referee{}
\newcommand*\Referee[1]{\vl@setcommand{vl@Referee}{#1}}
\newcommand*\vl@DateOfArrival{}% wird nicht benutzt
\newif\ifDateOfArrival \DateOfArrivalfalse
\newcommand*\DateOfArrival[1]{%
  \vl@setcommand{vl@DateOfArrival}{#1}%
  \ifx\@empty\vl@DateOfArrival\else\DateOfArrivaltrue\fi 
}
\newif\ifShippingCompany \ShippingCompanyfalse
\newcommand*\vl@ModeOfTransport{}
\newcommand*\ModeOfTransport[1]{%
  \ifx\relax#1\relax\else
    \expandafter\@ModeOfTransport#1 \@nil
  \fi
}
\newcommand*\@ModeOfTransport{}
\def\@ModeOfTransport#1 #2\@nil{%
  \def\vl@tempa{#2}%
  \if#1*%
    \ShippingCompanytrue
    \edef\vl@tempb{\noexpand\vl@setcommand{vl@ModeOfTransport}{\vl@tempa}}%
    \vl@tempb
  \else
    \ShippingCompanyfalse
    \vl@setcommand{vl@ModeOfTransport}{#1 #2}%
  \fi
}

\newcommand*\vl@ShippingCustomerID{}
\newcommand*\ShippingCustomerID[1]{\vl@setcommand{vl@ShippingCustomerID}{#1}} 

\newcounter{vl@TransportType} \setcounter{vl@TransportType}{0}
\newcommand*\TransportType[1]{\vl@setcounter{vl@TransportType}{#1}}
\newcounter{vl@ShippingType} \setcounter{vl@ShippingType}{0}
\newcommand*\ShippingType[1]{\vl@setcounter{vl@ShippingType}{#1}}
\newcounter{vl@ShippingCompany} \setcounter{vl@ShippingCompany}{4}
\newcommand*\ShippingCompany[1]{\vl@setcounter[4]{vl@ShippingCompany}{#1}}
\newcounter{vl@ShippingPayment} \setcounter{vl@ShippingPayment}{2}
\newcommand*\ShippingPayment[1]{\vl@setcounter{vl@ShippingPayment}{#1}}

\newif\ifInsurance \Insurancefalse
\newcommand*\Insurance[1]{\vl@setboolean{Insurance}{#1}}
\newif\ifInflammable \Inflammablefalse
\newcommand*\LabelInflammable[1]{\vl@setboolean{Inflammable}{#1}}
\newif\ifGlas \Glasfalse
\newcommand*\LabelGlas[1]{\vl@setboolean{Glas}{#1}}
\newif\ifSensitive \Sensitivefalse
\newcommand*\LabelSensitive[1]{\vl@setboolean{Sensitive}{#1}}
\newif\ifTop \Topfalse
\newcommand*\LabelTop[1]{\vl@setboolean{Top}{#1}}
\newif\ifDangerous \Dangerousfalse
\newcommand*\LabelDangerous[1]{\vl@setboolean{Dangerous}{#1}}

\newcommand*\vl@PurchaserEmail{vacuum.cal@ptb.de}
\newcommand*\PurchaserEmail[1]{\vl@setcommand{vl@PurchaserEmail}{#1}}

\newcommand*\vl@mainTitle{}
\newcommand\vl@mainTitle@i{\huge Versandauftrag}
\newcommand\vl@mainTitle@ii{\normalsize\relscale{1.65} Versandauftrag\par{}
  \normalsize --~Kopie für Versender~--}
  

\AtBeginDocument{%
  \def\vl@mainTitle{\vl@mainTitle@i}
  \mbox{}
  \iffalse % Kopie unterdrücken
    \newpage
    \def\vl@mainTitle{\vl@mainTitle@ii}
    \mbox{}
  \fi
}

\renewcommand*\familydefault{\sfdefault}
\def\huge{\@setfontsize\huge{20.08}{24.2}}
%%\def\large{\@setfontsize\large{11.62}{13.56}}
%%\def\tiny{\@setfontsize\tiny\@viipt\@viiipt}

\newcommand*\checkBox[2][0]{%
  \begingroup
    \fboxrule=0.7bp\fboxsep=0pt % 0.7bp (10pt)
    \raisebox{.3\height}{\fbox{\parbox[c][11bp]{11bp}{%
      \mbox{}\ifcase#1\or\centering\relscale{1.35}$\times$\fi%
    }}}%
  \endgroup\ifx\relax#2\relax\else~\raisebox{.2\height}{#2}\fi%
}

\newcommand*\vl@SelCompany[1]{
  \ifnum\c@vl@TransportType=0 %
    \ifnum\c@vl@ShippingCompany=#1 %
      1%
    \else
      0%
    \fi
  \else
    0%
  \fi
}

\input{vl-versandauftrag-\vl@version.clo}

\emergencystretch=3em %
\pagestyle{empty}

\endinput