% This file is most probably built by Wolfgang Schuster!
\unprotect

\def\floathack#1%
  {\globallet\floatrotation\!!zerocount
   \ifparfloat
   \else
     \processallactionsinset
       [#1]
       [ 90=>\globallet\floatrotation\commalistelement,%
        180=>\globallet\floatrotation\commalistelement,%
        270=>\globallet\floatrotation\commalistelement]%
   \fi
   \setbox\scratchbox\hbox{\floatrotation}%
   \floatparameter\c!before}

\def\dodocomplexplacefloat[#1][#2][#3]#4%
  {\flushnotes
   \flushsidefloats % here !
   \ifsomefloatwaiting
     % this was \checkwaitingfloats spread all over
     \doifinsetelse\v!always{#2}
       {\showmessage\m!floatblocks5\empty}
       {\expanded{\doifcommonelse{#2}{\flushfloatslist}}\doflushfloats\donothing}%
     % but which should be done before using box \floatbox
   \fi
   \ifmargeblokken
     \doifinset\v!margin{#2}\endgraf
   \fi
   \global\insidefloattrue
   \begingroup % **
   \ifmargeblokken
     \doifinset\v!margin{#2}{\hsize\@@mbwidth}%
   \fi
   \the\everyinsidefloat
   \let\@@extrafloat\empty
   \presetmorefloatvariables{#2}%
   \dowithnextboxcontent % better a \the\everyfloattoks
     {\setlocalfloathsize
      \floatparameter\c!inner
      \fuzzysnappingfalse
      \postponenotes} % new
     {\doifsomething{\floatparameter\c!criterium}
        {\ifdim\wd\nextbox>\floatparameter\c!criterium\relax
           \edef\forcedfloatmethod{\executeifdefined{\??fl\currentfloat\c!fallback}\v!here}%
         \fi}%
       \xdocompletefloat{#1}{#3}{#1}{#2}{#1}{#4}% ** not yet done
       % we need to carry over the par because of side floats
      \doifnotinset\v!text{#2}{\carryoverpar\endgroup}%
      \global\sidefloatdownshift \zeropoint
      \global\sidefloatextrashift\zeropoint
      \ifparfloat
        \doifinset\v!reset{#2}\forgetsidefloats
        \doinhibitblank
      \fi}% better move this to side floats
     \vbox}

\def\splitrotation
  {\ifnum\floatrotation=90
     \scratchdimen\textwidth
   \else\ifnum\floatrotation=270
     \scratchdimen\textwidth
   \else
     \scratchdimen\textheight
   \fi\fi}

\def\handletsplit
  {\analyzesplitfloatcaption\tsplitcontent
   \global\setfalse\tsplitfirstdone
   \testpage
     [\tsplitminimumfreelines]
     [\dimexpr\tsplitminimumfreespace+\extrasplitfloatlines\lineheight\relax]%
   \setbox\scratchbox\vbox{\tsplitinbetween}%
   \edef\tsplitinbetweenheight{\the\htdp\scratchbox}% etex
   \!!doneafalse
   \doloop
     {\ifinsidecolumns
        % brrr, assumes empty columns
        \global\setfalse\tsplitfirstdone
        \splitrotation
        \!!donectrue
      \else
        \ifconditional\tsplitfirstdone
          \splitrotation
          \!!donectrue
        \else\ifdim\pagegoal<\maxdimen
          \scratchdimen\dimexpr\pagegoal-\pagetotal\relax
          \!!donecfalse
        \else
          \splitrotation
          \!!donectrue
        \fi\fi
      \fi
      \scratchdimen\dimexpr\scratchdimen-\tsplitinbetweenheight-\tsplitminimumfreespace-\extrasplitfloatlines\lineheight\relax
      \ifdim\htdp\tsplittail>\zeropoint
        \advance\scratchdimen-\htdp\tsplittail
      \fi
      \setbox\tsplitresult\vbox
        {\ifdim\ht\tsplithead>\zeropoint
           \unvcopy\tsplithead
           \tsplitinbetween
         \fi}%
      \if!!donea\else\ifdim\ht\tsplitnext>\zeropoint
        \setbox\tsplithead\box\tsplitnext
      \fi\fi
      \!!doneatrue
      \ifdim\ht\tsplitresult>\zeropoint
        \!!donedtrue  % table head
      \else
        \!!donedfalse % no tablehead
      \fi
      \splittopskip\zeropoint
      \doloop
        {\setbox\scratchbox\vsplit\tsplitcontent to \onepoint % \lineheight
         \setbox\scratchbox\vbox{\unvbox\scratchbox}%
         \ifdim\dimexpr\scratchdimen-\htdp\scratchbox-\htdp\tsplitresult\relax>\zeropoint
           \setbox\tsplitresult\vbox
             {\unvbox\tsplitresult
              \tsplitinbetween
              \unvbox\scratchbox}%
           \ifvoid\tsplitcontent \exitloop \fi
         \else\if!!doned
           % we only have a tablehead so far
           \setbox\tsplitresult\vbox{\unvbox\tsplitresult\unvbox\scratchbox}%
           \exitloop
         \else\if!!donec
           % we have text height available, but the (one) cell is too
           % large to fit, so, in order to avoid loops/deadcycles we do:
           \setbox\tsplitresult\vbox
             {\unvbox\tsplitresult
              \tsplitinbetween
              \unvbox\scratchbox}%
           \exitloop
         \else
           \setbox\tsplitcontent\vbox
             {\unvbox\scratchbox
              \tsplitinbetween
              \ifvoid\tsplitcontent\else\unvbox\tsplitcontent\fi}%
           \exitloop
         \fi\fi\fi
         \!!donedfalse
         \!!donecfalse}%
      \postprocesstsplit
      \dochecksplitofffloat\tsplitcontent
      \ifvoid\tsplitcontent
        \setbox\tsplitresult\vbox
          {\unvbox\tsplitresult
           \tsplitinbetween
           \unvcopy\tsplittail}%
        \dowithsplitofffloat{\tsplitbeforeresult\box\tsplitresult\tsplitafterresult}%
        \doifnotinsidesplitfloat\tsplitafter
        \endgraf
        \exitloop
      \else
        % hack
        \ifdim\pagegoal<\maxdimen
          \global\pagegoal\dimexpr\pagegoal+\lineheight\relax % etex
        \fi
        % brrr
        \ifdim\ht\tsplitresult>\zeropoint
          \setbox\tsplitresult\vbox
            {\unvbox\tsplitresult
             \tsplitinbetween
             \unvcopy\tsplittail}%
          \dowithsplitofffloat{\tsplitbeforeresult\box\tsplitresult\tsplitafterresult}%
          \doifnotinsidesplitfloat\tsplitafter
          \endgraf
        \fi
        \ifinsidecolumns
          \doifnotinsidesplitfloat\goodbreak
        \else
          \doifnotinsidesplitfloat\page
        \fi
      \fi}}

\protect \endinput
