% Copyright (c) 2009 Stephane GALLAND <galland@arakhne.org>
% 
% This program is free library; you can redistribute it and/or modify
% it under the terms of the GNU Lesser General Public License as
% published by the Free Software Foundation; either version 3 of the
% License, or any later version.
%
% This library is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
% Lesser General Public License for more details.
%
% You should have received a copy of the GNU Lesser General Public
% License along with this library; see the file COPYING.  If not,
% write to the Free Software Foundation, Inc., 59 Temple Place - Suite
% 330, Boston, MA 02111-1307, USA.
%
% Creation date: 2009-10-30
% Modifications (lastest first):
%    2009-11-03   \If* macros are marked with \long
%    2009-11-02   Add internal commands for footnotes.
%

\global\edef\upm@package@private@doctype@ver{2009/11/03}

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{upmethodology-p-doctype}[\upm@package@private@doctype@ver]

\RequirePackage{ifthen}
\RequirePackage{xspace}
\RequirePackage{color}

%----------------------------------------
% ARAKHNE.ORG MACRO
%----------------------------------------
\providecommand{\arakhneorg}{{\begingroup%
	{\usefont{T1}{pzc}{m}{it}\selectfont Arakhn\^e}%
	{\usefont{T1}{phv}{bc}{sc}\selectfont\tiny.org}\endgroup}\xspace}

%----------------------------------------
% CURRENT LANGUAGE
%----------------------------------------
\def\upmcurrentlang{english}

%----------------------------------------
% TEST MACROS
%----------------------------------------
\long\def\Ifnotempty#1{\ifthenelse{\equal{#1}{\@empty}}{}}
\long\def\Ifempty#1#2{\ifthenelse{\equal{#1}{\@empty}}{#2}{}}
\long\def\Ifelseempty#1#2#3{\ifthenelse{\equal{#1}{\@empty}}{#2}{#3}}

%----------------------------------------
% DOCUMENT TYPE
%----------------------------------------
\newif\ifupmbookformat
\newif\ifupmreportformat
\newif\ifupmarticleformat

\upmbookformatfalse
\upmreportformattrue
\upmarticleformatfalse

%----------------------------------------
% PDF COLORS
%----------------------------------------
\newcommand{\setpdfcolor}[1]{}

%----------------------------------------
% CREATE COMMAND WITH ID AS NAME
%----------------------------------------
\def\upm@protect#1{\upm@p@protect #1\relax}
\def\upm@p@protect#1#2\relax{%
	\ifx\relax #1%
		\relax
	\else%
		\string #1%
		\ifx\relax #2%
			\relax
		\else
			\upm@p@protect #2\relax%
		\fi
	\fi}

\def\upm@namedef#1#2{%
	\@namedef{\upm@protect{#1}}{#2}%
}

\def\upm@nameuse#1{%
	\@nameuse{\upm@protect{#1}}%
}

\def\upm@nameundef#1{%
	\expandafter\let\csname\upm@protect{#1}\endcsname\relax%
}

\def\upm@ifdefinedname#1#2#3{%
	\expandafter\ifx\csname\upm@protect{#1}\endcsname\relax%
		#3%
	\else%
		#2%
	\fi%
}

%----------------------------------------
% GET THE REFERENCE ID WITHOUT \REF
%----------------------------------------
\gdef\upm@getref#1{%
  \expandafter\ifx\csname r@#1\endcsname\relax
    \nfss@text{\reset@font\bfseries ??}%
  \else
    \expandafter\expandafter\expandafter\@car\csname r@#1\endcsname\@nil
  \fi
}

\gdef\upm@getpageref@filter#1#2#3#4#5{#2}

\gdef\upm@getpageref#1{%
  \expandafter\ifx\csname r@#1\endcsname\relax
    \nfss@text{\reset@font\bfseries ??}%
  \else%
    \protected@xdef\upm@p@tmp@tmp{\protect\upm@getpageref@filter\csname r@#1\endcsname}%
    \upm@p@tmp@tmp%
    \global\let\upm@p@tmp@tmp\relax%
  \fi
}

%----------------------------------------
% INTERNAL COMMAND FOR TEXT SUPPER/SUB SCRIPT
%----------------------------------------

\let\upm@textsuperscript\textsuperscript

\def\upm@textsubscript#1{%
  {\m@th\ensuremath{_{\mbox{\fontsize\sf@size\z@#1}}}}}


\endinput