% This file is copyrighted (c) 1998 1999 by Javier Bezos.
% All Rights Reserved.
%
% This file is part of the titlesec distribution release 2.1.
% -----------------------------------------------------------
%
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or any later version.

\ProvidesFile{wrap.tss}[1999/02/20]

\gdef\ttlh@wrap#1#2#3#4#5#6#7#8{%
  \global\@noskipsectrue
  \gdef\ttl@makeline##1{##1}%
  #1%
  \parindent\z@
  \global\setbox\z@\vtop{\setlength\hsize{#6}%
    \color@begingroup
    \ifttl@numsec{#2}\hspace{#3}\fi#4{#8}\kern\z@\strut
    \@@par
	\color@endgroup}%
  \advance\@tempskipa1.5\baselineskip
  \advance\@tempskipa\ht\z@
  \advance\@tempskipa\dp\z@
  \advance\@tempskipa-\pagegoal
  \advance\@tempskipa\pagestretch
  \@tempskipb\pagegoal
  \pagegoal-\@tempskipa
  \ifdim\bottomtitlespace<\z@\else
    \def\@textbottom{\vskip\z@\@plus.0001fil}%
  \fi
  \penalty9999
  \pagegoal\@tempskipb
  \@tempdima\ht\z@ \advance\@tempdima\dp\z@
  \@tempdimb\@tempdima
  \divide\@tempdima\baselineskip \count@\@tempdima
  \advance\count@
    \ifdim\@tempdimb<\the\count@.5\baselineskip\@ne\else\tw@\fi
  \dp\z@=\z@
  \if@nobreak\advance\count@\@ne\fi
  \setbox\@ne\vbox{\unvcopy\z@}%
  \def\ttl@maxdimen{\z@}%
  \ttl@getlongest
  \wd\z@\ttl@maxdimen
  \xdef\@svsechd##1##2{%
    \noexpand\llap{\box\z@##2}%
    \sbox\z@{\hskip\ttl@maxdimen##2}%
    \global\hangindent\wd\z@
    \global\hangafter-\the\count@\relax}}
	
\gdef\ttl@getlongest{%
  \setbox\@ne=\vbox{%
    \unvcopy\@ne
    \unskip\unpenalty
    \global\setbox\tw@=\lastbox}%
  \ifvoid\tw@
  \else
    \setbox\thr@@=\hbox{\unhbox\tw@}%
    \ifdim\ttl@maxdimen<\wd\thr@@
	  \edef\ttl@maxdimen{\the\wd\thr@@}%
	\fi
    \expandafter\ttl@getlongest
  \fi}

\endinput
