% Copyright 2006 Konstantin Korikov <lostclus@ua.fm>
%
% 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 Konstantin Korikov.
%
% This work consists of all files listed in manifest.txt.
%
m4_ESKDX_INIT
m4_FILE_INIT
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{eskdtitle}[m4_dnl
m4_FILE_ID([[$Date:: 2010-01-14#$]]) Title GOST 2.105]

\RequirePackage{eskdstamp}
\RequirePackage{eskdlang}
\RequirePackage{eskdinfo}
\RequirePackage{eskdtitlebase}

\newcommand{\ESKD@title@split@field}[2]{%
  \parbox[t]{.4\hsize}{\raggedright#1}\hfill
  \parbox[t]{.4\hsize}{\raggedright#2}}

\renewcommand{\ESKDtheTitleFieldI}{%
  \ESKDtheDepartment\par\ESKDtheCompany}

\def\ESKDtheTitleFieldIIl{}
\renewcommand{\ESKDtheTitleFieldIIl}{%
  \ESKDtheClassCode}
\def\ESKDtheTitleFieldIIr{}
\renewcommand{\ESKDtheTitleFieldIIr}{}
\renewcommand{\ESKDtheTitleFieldII}{%
  \ESKD@title@split@field{\ESKDtheTitleFieldIIl}{\ESKDtheTitleFieldIIr}}

\def\ESKDtheTitleFieldIIIl{}
\renewcommand{\ESKDtheTitleFieldIIIl}{%
  \ifx\ESKD@title@approving@sheet\@undefined
    \expandafter\ifx\csname ESKD@title@agreed@name@1\endcsname\relax\else
      \textbf{\MakeUppercase{\ESKDagreedName}}\\
      \ESKD@title@make@stamp{agreed}{1}
    \fi
  \else
    \textbf{\MakeUppercase{\ESKDapprovedName}}\\
    \ESKD@title@approving@sheet
  \fi}
\def\ESKDtheTitleFieldIIIr{}
\renewcommand{\ESKDtheTitleFieldIIIr}{%
  \ifx\ESKD@title@approving@sheet\@undefined
    \expandafter\ifx\csname ESKD@title@approved@name@1\endcsname\relax\else
      \textbf{\MakeUppercase{\ESKDapprovingName}}\\
      \ESKD@title@make@stamp{approved}{1}
    \fi
  \fi}
\renewcommand{\ESKDtheTitleFieldIII}{%
  \ESKD@title@split@field{\ESKDtheTitleFieldIIIl}{\ESKDtheTitleFieldIIIr}}

\renewcommand{\ESKDtheTitleFieldIV}{%
  \MakeUppercase{\ESKDtheTitle}\par\ESKDtheDocName}

\renewcommand{\ESKDtheTitleFieldV}{}

\renewcommand{\ESKDtheTitleFieldVI}{%
  \MakeUppercase{\ESKDtheSignature}}

\renewcommand{\ESKDtheTitleFieldVII}{}

\def\ESKDtheTitleFieldVIIIl{}
\renewcommand{\ESKDtheTitleFieldVIIIl}{%
  \ifx\ESKD@title@approving@sheet\@undefined
    \ESKD@tmpcnta = 1
    \loop
    \ifnum \ESKD@tmpcnta < \ESKD@title@agreed@cnt
      \advance \ESKD@tmpcnta 1
      \ESKD@title@make@stamp{agreed}{\number\ESKD@tmpcnta}
      \par\vspace{5mm}
    \repeat
  \fi}
\def\ESKDtheTitleFieldVIIIr{}
\renewcommand{\ESKDtheTitleFieldVIIIr}{%
  \ifx\ESKD@title@approving@sheet\@undefined
    \ESKD@tmpcnta = 0
    \loop
    \ifnum \ESKD@tmpcnta < \ESKD@title@designed@cnt
      \advance \ESKD@tmpcnta 1
      \ESKD@title@make@stamp{designed}{\number\ESKD@tmpcnta}
      \par\vspace{5mm}
    \repeat
  \fi}
\renewcommand{\ESKDtheTitleFieldVIII}{%
  \ESKD@title@split@field{\ESKDtheTitleFieldVIIIl}{\ESKDtheTitleFieldVIIIr}}

\renewcommand{\ESKDtheTitleFieldX}{\ESKDtheYear}

\renewcommand{\ESKDtitleFontI}{\ESKDfontV}
\renewcommand{\ESKDtitleFontII}{\ESKDfontIII}
\renewcommand{\ESKDtitleFontIII}{%
  \ESKDfontIII\renewcommand{\baselinestretch}{1.50}\selectfont}
\renewcommand{\ESKDtitleFontIV}{\ESKDfontV}
\renewcommand{\ESKDtitleFontV}{\ESKDfontV}
\renewcommand{\ESKDtitleFontVI}{\ESKDfontV}
\renewcommand{\ESKDtitleFontVII}{\ESKDfontIII}
\renewcommand{\ESKDtitleFontVIII}{%
  \ESKDfontIII\renewcommand{\baselinestretch}{1.25}\selectfont}
\renewcommand{\ESKDtitleFontX}{\ESKDfontV}

\renewcommand{\maketitle}{%
  \begin{ESKDtitlePage}
  \setlength{\topsep}{0mm}
  \noindent
  \parbox[c][.28\vsize][t]{\hsize}{%
    \begin{center}\ESKDtitleFontI\bfseries\ESKDtheTitleFieldI\end{center}
    \vspace{5mm \@plus 15mm \@minus 3mm}
    \begin{center}\ESKDtitleFontII\ESKDtheTitleFieldII\end{center}
    \vspace{10mm \@plus 20mm \@minus 6mm}
    \begin{center}\ESKDtitleFontIII\ESKDtheTitleFieldIII\end{center}}
  \par\vspace{10mm \@plus 2mm \@minus 4mm}\noindent
  \parbox[c][.30\vsize][t]{\hsize}{%
    \begin{center}\ESKDtitleFontIV\bfseries\ESKDtheTitleFieldIV\end{center}
    \begin{center}\ESKDtitleFontV\ESKDtheTitleFieldV\end{center}
    \begin{center}\ESKDtitleFontVI\ESKDtheTitleFieldVI\end{center}
    \begin{center}\ESKDtitleFontVII\ESKDtheTitleFieldVII\end{center}}
  \par\vspace{4mm \@plus 2mm \@minus 2mm}\noindent
  \begin{center}\ESKDtitleFontVIII\ESKDtheTitleFieldVIII\end{center}
  \vfill
  \begin{center}\ESKDtitleFontX\ESKDtheTitleFieldX\end{center}
  \end{ESKDtitlePage}}

m4_dnl vim:ft=tex:sw=2:ai
