LCOV - code coverage report
Current view: top level - sw/source/core/layout - ftnfrm.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 632 1442 43.8 %
Date: 2012-08-25 Functions: 37 49 75.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 556 2086 26.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <txtftn.hxx>
      31                 :            : #include <fmtftn.hxx>
      32                 :            : #include <ftnidx.hxx>
      33                 :            : #include <pagefrm.hxx>
      34                 :            : #include <colfrm.hxx>
      35                 :            : #include <rootfrm.hxx>
      36                 :            : #include <cntfrm.hxx>
      37                 :            : #include <doc.hxx>
      38                 :            : #include <ndtxt.hxx>
      39                 :            : #include <frmtool.hxx>
      40                 :            : #include <swtable.hxx>
      41                 :            : #include <ftnfrm.hxx>
      42                 :            : #include <txtfrm.hxx>
      43                 :            : #include <tabfrm.hxx>
      44                 :            : #include <pagedesc.hxx>
      45                 :            : #include <ftninfo.hxx>
      46                 :            : #include <ndindex.hxx>
      47                 :            : #include <sectfrm.hxx>
      48                 :            : #include <pam.hxx>
      49                 :            : #include <objectformatter.hxx>
      50                 :            : #include "viewopt.hxx"
      51                 :            : #include "viewsh.hxx"
      52                 :            : #include <switerator.hxx>
      53                 :            : 
      54                 :            : /*************************************************************************
      55                 :            : |*
      56                 :            : |*  lcl_FindFtnPos()        Sucht die Position des Attributes im FtnArray am
      57                 :            : |*      Dokument, dort stehen die Fussnoten gluecklicherweise nach ihrem
      58                 :            : |*      Index sortiert.
      59                 :            : |*
      60                 :            : |*************************************************************************/
      61                 :            : 
      62                 :            : #define ENDNOTE 0x80000000
      63                 :            : 
      64                 :        157 : sal_uLong lcl_FindFtnPos( const SwDoc *pDoc, const SwTxtFtn *pAttr )
      65                 :            : {
      66                 :        157 :     const SwFtnIdxs &rFtnIdxs = pDoc->GetFtnIdxs();
      67                 :            : 
      68                 :        157 :     SwTxtFtn* pBla = (SwTxtFtn*)pAttr;
      69         [ +  - ]:        157 :     SwFtnIdxs::const_iterator it = rFtnIdxs.find( pBla );
      70 [ +  - ][ +  - ]:        157 :     if ( it != rFtnIdxs.end() )
      71                 :            :     {
      72         [ +  - ]:        157 :         sal_uInt16 nRet = it - rFtnIdxs.begin();
      73         [ +  + ]:        157 :         if( pAttr->GetFtn().IsEndNote() )
      74                 :          8 :             return sal_uLong(nRet) + ENDNOTE;
      75                 :        149 :         return nRet;
      76                 :            :     }
      77                 :            :     OSL_ENSURE( !pDoc, "FtnPos not found." );
      78                 :        157 :     return 0;
      79                 :            : }
      80                 :            : 
      81                 :          0 : sal_Bool SwFtnFrm::operator<( const SwTxtFtn* pTxtFtn ) const
      82                 :            : {
      83                 :          0 :     const SwDoc* pDoc = GetFmt()->GetDoc();
      84                 :            :     OSL_ENSURE( pDoc, "SwFtnFrm: Missing doc!" );
      85                 :          0 :     return lcl_FindFtnPos( pDoc, GetAttr() ) <
      86                 :          0 :            lcl_FindFtnPos( pDoc, pTxtFtn );
      87                 :            : }
      88                 :            : 
      89                 :            : /*************************************************************************
      90                 :            : |*
      91                 :            : |*  sal_Bool lcl_NextFtnBoss( SwFtnBossFrm* pBoss, SwPageFrm* pPage)
      92                 :            : |*  setzt pBoss auf den naechsten SwFtnBossFrm, das kann entweder eine Spalte
      93                 :            : |*  oder eine Seite (ohne Spalten) sein. Wenn die Seite dabei gewechselt wird
      94                 :            : |*  enthaelt pPage die neue Seite und die Funktion liefert sal_True.
      95                 :            : |*
      96                 :            : |*************************************************************************/
      97                 :            : 
      98                 :        104 : sal_Bool lcl_NextFtnBoss( SwFtnBossFrm* &rpBoss, SwPageFrm* &rpPage,
      99                 :            :     sal_Bool bDontLeave )
     100                 :            : {
     101         [ -  + ]:        104 :     if( rpBoss->IsColumnFrm() )
     102                 :            :     {
     103         [ #  # ]:          0 :         if( rpBoss->GetNext() )
     104                 :            :         {
     105                 :          0 :             rpBoss = (SwFtnBossFrm*)rpBoss->GetNext(); //naechste Spalte
     106                 :          0 :             return sal_False;
     107                 :            :         }
     108         [ #  # ]:          0 :         if( rpBoss->IsInSct() )
     109                 :            :         {
     110                 :          0 :             SwSectionFrm* pSct = rpBoss->FindSctFrm()->GetFollow();
     111         [ #  # ]:          0 :             if( pSct )
     112                 :            :             {
     113                 :            :                 OSL_ENSURE( pSct->Lower() && pSct->Lower()->IsColumnFrm(),
     114                 :            :                         "Where's the column?" );
     115                 :          0 :                 rpBoss = (SwColumnFrm*)pSct->Lower();
     116                 :          0 :                 SwPageFrm* pOld = rpPage;
     117                 :          0 :                 rpPage = pSct->FindPageFrm();
     118                 :          0 :                 return pOld != rpPage;
     119                 :            :             }
     120         [ #  # ]:          0 :             else if( bDontLeave )
     121                 :            :             {
     122                 :          0 :                 rpPage = NULL;
     123                 :          0 :                 rpBoss = NULL;
     124                 :          0 :                 return sal_False;
     125                 :            :             }
     126                 :            :         }
     127                 :            :     }
     128                 :        104 :     rpPage = (SwPageFrm*)rpPage->GetNext(); // naechste Seite
     129                 :        104 :     rpBoss = rpPage;
     130         [ -  + ]:        104 :     if( rpPage )
     131                 :            :     {
     132                 :          0 :         SwLayoutFrm* pBody = rpPage->FindBodyCont();
     133 [ #  # ][ #  # ]:          0 :         if( pBody && pBody->Lower() && pBody->Lower()->IsColumnFrm() )
         [ #  # ][ #  # ]
     134                 :          0 :             rpBoss = (SwFtnBossFrm*)pBody->Lower(); // erste Spalte
     135                 :            :     }
     136                 :        104 :     return sal_True;
     137                 :            : }
     138                 :            : 
     139                 :            : /*************************************************************************
     140                 :            : |*
     141                 :            : |*  sal_uInt16 lcl_ColumnNum( SwFrm* pBoss )
     142                 :            : |*  liefert die Spaltennummer, wenn pBoss eine Spalte ist,
     143                 :            : |*  sonst eine Null (bei Seiten).
     144                 :            : |*
     145                 :            : |*************************************************************************/
     146                 :            : 
     147                 :        276 : sal_uInt16 lcl_ColumnNum( const SwFrm* pBoss )
     148                 :            : {
     149                 :        276 :     sal_uInt16 nRet = 0;
     150         [ +  - ]:        276 :     if( !pBoss->IsColumnFrm() )
     151                 :        276 :         return 0;
     152                 :            :     const SwFrm* pCol;
     153         [ #  # ]:          0 :     if( pBoss->IsInSct() )
     154                 :            :     {
     155                 :          0 :         pCol = pBoss->GetUpper()->FindColFrm();
     156 [ #  # ][ #  # ]:          0 :         if( pBoss->GetNext() || pBoss->GetPrev() )
                 [ #  # ]
     157                 :            :         {
     158         [ #  # ]:          0 :             while( pBoss )
     159                 :            :             {
     160                 :          0 :                 ++nRet;                     // Section columns
     161                 :          0 :                 pBoss = pBoss->GetPrev();
     162                 :            :             }
     163                 :            :         }
     164                 :            :     }
     165                 :            :     else
     166                 :          0 :         pCol = pBoss;
     167         [ #  # ]:          0 :     while( pCol )
     168                 :            :     {
     169                 :          0 :         nRet += 256;                    // Page columns
     170                 :          0 :         pCol = pCol->GetPrev();
     171                 :            :     }
     172                 :        276 :     return nRet;
     173                 :            : }
     174                 :            : 
     175                 :            : /*************************************************************************
     176                 :            : |*
     177                 :            : |*  SwFtnContFrm::SwFtnContFrm()
     178                 :            : |*
     179                 :            : |*************************************************************************/
     180                 :            : 
     181                 :            : 
     182                 :         45 : SwFtnContFrm::SwFtnContFrm( SwFrmFmt *pFmt, SwFrm* pSib ):
     183                 :         45 :     SwLayoutFrm( pFmt, pSib )
     184                 :            : {
     185                 :         45 :     nType = FRMC_FTNCONT;
     186                 :         45 : }
     187                 :            : 
     188                 :            : 
     189                 :            : // lcl_Undersize(..) klappert einen SwFrm und dessen Inneres ab
     190                 :            : // und liefert die Summe aller TxtFrm-Vergroesserungswuensche
     191                 :            : 
     192                 :        330 : long lcl_Undersize( const SwFrm* pFrm )
     193                 :            : {
     194                 :        330 :     long nRet = 0;
     195 [ -  + ][ #  # ]:        330 :     SWRECTFN( pFrm )
         [ #  # ][ -  + ]
     196         [ +  + ]:        330 :     if( pFrm->IsTxtFrm() )
     197                 :            :     {
     198         [ -  + ]:        176 :         if( ((SwTxtFrm*)pFrm)->IsUndersized() )
     199                 :            :         {
     200                 :            :             // Dieser TxtFrm waere gern ein bisschen groesser
     201                 :          0 :             nRet = ((SwTxtFrm*)pFrm)->GetParHeight() -
     202         [ #  # ]:          0 :                     (pFrm->Prt().*fnRect->fnGetHeight)();
     203         [ #  # ]:          0 :             if( nRet < 0 )
     204                 :          0 :                 nRet = 0;
     205                 :            :         }
     206                 :            :     }
     207         [ +  - ]:        154 :     else if( pFrm->IsLayoutFrm() )
     208                 :            :     {
     209                 :        154 :         const SwFrm* pNxt = ((SwLayoutFrm*)pFrm)->Lower();
     210         [ +  + ]:        342 :         while( pNxt )
     211                 :            :         {
     212                 :        188 :             nRet += lcl_Undersize( pNxt );
     213                 :        188 :             pNxt = pNxt->GetNext();
     214                 :            :         }
     215                 :            :     }
     216                 :        330 :     return nRet;
     217                 :            : }
     218                 :            : 
     219                 :            : /*************************************************************************
     220                 :            : |*
     221                 :            : |*  SwFtnContFrm::Format()
     222                 :            : |*
     223                 :            : |*  Beschreibung:       "Formatiert" den Frame;
     224                 :            : |*                      Die Fixsize wird hier nicht eingestellt.
     225                 :            : |*
     226                 :            : |*************************************************************************/
     227                 :            : 
     228                 :            : 
     229                 :        138 : void SwFtnContFrm::Format( const SwBorderAttrs * )
     230                 :            : {
     231                 :            :     //GesamtBorder ermitteln, es gibt nur einen Abstand nach oben.
     232                 :        138 :     const SwPageFrm* pPage = FindPageFrm();
     233                 :        138 :     const SwPageFtnInfo &rInf = pPage->GetPageDesc()->GetFtnInfo();
     234                 :        138 :     const SwTwips nBorder = rInf.GetTopDist() + rInf.GetBottomDist() +
     235                 :        138 :                             rInf.GetLineWidth();
     236 [ #  # ][ #  # ]:        138 :     SWRECTFN( this )
         [ -  + ][ -  + ]
     237         [ +  - ]:        138 :     if ( !bValidPrtArea )
     238                 :            :     {
     239                 :        138 :         bValidPrtArea = sal_True;
     240         [ +  - ]:        138 :         (Prt().*fnRect->fnSetTop)( nBorder );
     241 [ +  - ][ +  - ]:        138 :         (Prt().*fnRect->fnSetWidth)( (Frm().*fnRect->fnGetWidth)() );
     242 [ +  - ][ +  - ]:        138 :         (Prt().*fnRect->fnSetHeight)((Frm().*fnRect->fnGetHeight)() - nBorder );
     243 [ +  + ][ +  + ]:        138 :         if( (Prt().*fnRect->fnGetHeight)() < 0 && !pPage->IsFtnPage() )
         [ +  + ][ +  - ]
     244                 :         35 :             bValidSize = sal_False;
     245                 :            :     }
     246                 :            : 
     247         [ +  - ]:        138 :     if ( !bValidSize )
     248                 :            :     {
     249                 :        138 :         bool bGrow = pPage->IsFtnPage();
     250         [ +  + ]:        138 :         if( bGrow )
     251                 :            :         {
     252         [ +  - ]:         16 :             const ViewShell *pSh = getRootFrm() ? getRootFrm()->GetCurrShell() : 0;
     253 [ +  - ][ -  + ]:         16 :             if( pSh && pSh->GetViewOptions()->getBrowseMode() )
                 [ -  + ]
     254                 :          0 :                 bGrow = false;
     255                 :            :         }
     256         [ +  + ]:        138 :         if( bGrow )
     257                 :         16 :                 Grow( LONG_MAX, sal_False );
     258                 :            :         else
     259                 :            :         {
     260                 :            :             //Die Groesse in der VarSize wird durch den Inhalt plus den
     261                 :            :             //Raendern bestimmt.
     262                 :        122 :             SwTwips nRemaining = 0;
     263                 :        122 :             SwFrm *pFrm = pLower;
     264         [ +  + ]:        264 :             while ( pFrm )
     265                 :            :             {   // lcl_Undersize(..) beruecksichtigt (rekursiv) TxtFrms, die gerne
     266                 :            :                 // groesser waeren. Diese entstehen insbesondere in spaltigen Rahmen,
     267                 :            :                 // wenn diese noch nicht ihre maximale Groesse haben.
     268         [ +  - ]:        142 :                 nRemaining += (pFrm->Frm().*fnRect->fnGetHeight)()
     269                 :        142 :                               + lcl_Undersize( pFrm );
     270                 :        142 :                 pFrm = pFrm->GetNext();
     271                 :            :             }
     272                 :            :             //Jetzt noch den Rand addieren
     273                 :        122 :             nRemaining += nBorder;
     274                 :            : 
     275                 :            :             SwTwips nDiff;
     276         [ -  + ]:        122 :             if( IsInSct() )
     277                 :            :             {
     278                 :          0 :                 nDiff = -(Frm().*fnRect->fnBottomDist)(
     279 [ #  # ][ #  # ]:          0 :                                         (GetUpper()->*fnRect->fnGetPrtBottom)() );
     280         [ #  # ]:          0 :                 if( nDiff > 0 )
     281                 :            :                 {
     282 [ #  # ][ #  # ]:          0 :                     if( nDiff > (Frm().*fnRect->fnGetHeight)() )
     283         [ #  # ]:          0 :                         nDiff = (Frm().*fnRect->fnGetHeight)();
     284         [ #  # ]:          0 :                     (Frm().*fnRect->fnAddBottom)( -nDiff );
     285         [ #  # ]:          0 :                     (Prt().*fnRect->fnAddHeight)( -nDiff );
     286                 :            :                 }
     287                 :            :             }
     288         [ +  - ]:        122 :             nDiff = (Frm().*fnRect->fnGetHeight)() - nRemaining;
     289         [ -  + ]:        122 :             if ( nDiff > 0 )
     290                 :          0 :                 Shrink( nDiff );
     291         [ +  + ]:        122 :             else if ( nDiff < 0 )
     292                 :            :             {
     293                 :         35 :                 Grow( -nDiff );
     294                 :            :                 //Es kann passieren, dass weniger Platz zur Verfuegung steht,
     295                 :            :                 //als der bereits der Border benoetigt - die Groesse der
     296                 :            :                 //PrtArea wird dann negativ.
     297         [ +  - ]:         35 :                 SwTwips nPrtHeight = (Prt().*fnRect->fnGetHeight)();
     298         [ -  + ]:         35 :                 if( nPrtHeight < 0 )
     299                 :            :                 {
     300                 :          0 :                     const SwTwips nTmpDiff = Max( (Prt().*fnRect->fnGetTop)(),
     301         [ #  # ]:          0 :                                                 -nPrtHeight );
     302         [ #  # ]:          0 :                     (Prt().*fnRect->fnSubTop)( nTmpDiff );
     303                 :            :                 }
     304                 :            :             }
     305                 :            :         }
     306                 :        138 :         bValidSize = sal_True;
     307                 :            :     }
     308                 :        138 : }
     309                 :            : /*************************************************************************
     310                 :            : |*
     311                 :            : |*  SwFtnContFrm::GrowFrm(), ShrinkFrm()
     312                 :            : |*
     313                 :            : |*************************************************************************/
     314                 :            : 
     315                 :        423 : SwTwips SwFtnContFrm::GrowFrm( SwTwips nDist, sal_Bool bTst, sal_Bool )
     316                 :            : {
     317                 :            :     //Keine Pruefung ob FixSize oder nicht, die FtnContainer sind immer bis
     318                 :            :     //zur Maximalhoehe variabel.
     319                 :            :     //Wenn die Maximalhoehe LONG_MAX ist, so nehmen wir uns soviel Platz wie eben
     320                 :            :     //moeglich.
     321                 :            :     //Wenn die Seite eine spezielle Fussnotenseite ist, so nehmen wir uns auch
     322                 :            :     //soviel Platz wie eben moeglich.
     323                 :            : #if OSL_DEBUG_LEVEL > 1
     324                 :            :     if ( !GetUpper() || !GetUpper()->IsFtnBossFrm() )
     325                 :            :     { OSL_ENSURE( !this, "Keine FtnBoss." );
     326                 :            :         return 0;
     327                 :            :     }
     328                 :            : #endif
     329                 :            : 
     330 [ -  + ][ #  # ]:        423 :     SWRECTFN( this )
         [ #  # ][ -  + ]
     331         [ +  - ]:        801 :     if( (Frm().*fnRect->fnGetHeight)() > 0 &&
           [ +  +  +  + ]
                 [ +  + ]
     332         [ +  - ]:        378 :          nDist > ( LONG_MAX - (Frm().*fnRect->fnGetHeight)() ) )
     333         [ +  - ]:        222 :         nDist = LONG_MAX - (Frm().*fnRect->fnGetHeight)();
     334                 :            : 
     335                 :        423 :     SwFtnBossFrm *pBoss = (SwFtnBossFrm*)GetUpper();
     336         [ -  + ]:        423 :     if( IsInSct() )
     337                 :            :     {
     338                 :          0 :         SwSectionFrm* pSect = FindSctFrm();
     339                 :            :         OSL_ENSURE( pSect, "GrowFrm: Missing SectFrm" );
     340                 :            :         // In a section, which has to maximize, a footnotecontainer is allowed
     341                 :            :         // to grow, when the section can't grow anymore.
     342   [ #  #  #  #  :          0 :         if( !bTst && !pSect->IsColLocked() &&
           #  # ][ #  # ]
                 [ #  # ]
     343                 :          0 :             pSect->ToMaximize( sal_False ) && pSect->Growable() )
     344                 :            :         {
     345                 :          0 :             pSect->InvalidateSize();
     346                 :          0 :             return 0;
     347                 :            :         }
     348                 :            :     }
     349         [ +  - ]:        423 :     const ViewShell *pSh = getRootFrm() ? getRootFrm()->GetCurrShell() : 0;
     350 [ +  - ][ -  + ]:        423 :     const sal_Bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
     351                 :        423 :     SwPageFrm *pPage = pBoss->FindPageFrm();
     352 [ +  + ][ +  + ]:        423 :     if ( bBrowseMode || !pPage->IsFtnPage() )
                 [ +  - ]
     353                 :            :     {
     354         [ +  + ]:        387 :         if ( pBoss->GetMaxFtnHeight() != LONG_MAX )
     355                 :            :         {
     356                 :        385 :             nDist = Min( nDist, pBoss->GetMaxFtnHeight()
     357         [ +  - ]:        385 :                          - (Frm().*fnRect->fnGetHeight)() );
     358         [ -  + ]:        385 :             if ( nDist <= 0 )
     359                 :          0 :                 return 0L;
     360                 :            :         }
     361                 :            :         //Der FtnBoss will bezueglich des MaxWerts auch noch mitreden.
     362         [ +  - ]:        387 :         if( !IsInSct() )
     363                 :            :         {
     364                 :        387 :             const SwTwips nMax = pBoss->GetVarSpace();
     365         [ +  + ]:        387 :             if ( nDist > nMax )
     366                 :        216 :                 nDist = nMax;
     367         [ -  + ]:        387 :             if ( nDist <= 0 )
     368                 :          0 :                 return 0L;
     369                 :            :         }
     370                 :            :     }
     371 [ +  - ][ +  - ]:         36 :     else if( nDist > (GetPrev()->Frm().*fnRect->fnGetHeight)() )
     372                 :            :         //aber mehr als der Body kann koennen und wollen wir nun auch wieder
     373                 :            :         //nicht herausruecken.
     374         [ +  - ]:         36 :         nDist = (GetPrev()->Frm().*fnRect->fnGetHeight)();
     375                 :            : 
     376                 :        423 :     long nAvail = 0;
     377         [ -  + ]:        423 :     if ( bBrowseMode )
     378                 :            :     {
     379                 :          0 :         nAvail = GetUpper()->Prt().Height();
     380                 :          0 :         const SwFrm *pAvail = GetUpper()->Lower();
     381         [ #  # ]:          0 :         do
     382                 :          0 :         {   nAvail -= pAvail->Frm().Height();
     383                 :          0 :             pAvail = pAvail->GetNext();
     384                 :            :         } while ( pAvail );
     385         [ #  # ]:          0 :         if ( nAvail > nDist )
     386                 :          0 :             nAvail = nDist;
     387                 :            :     }
     388                 :            : 
     389         [ +  + ]:        423 :     if ( !bTst )
     390                 :            :     {
     391 [ +  - ][ +  - ]:        122 :         (Frm().*fnRect->fnSetHeight)( (Frm().*fnRect->fnGetHeight)() + nDist );
     392                 :            :         //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
     393 [ #  # ][ #  # ]:        122 :         if( IsVertical() && !IsVertLR() && !IsReverse() )
         [ -  + ][ -  + ]
     394                 :          0 :             Frm().Pos().X() -= nDist;
     395                 :            :     }
     396                 :        423 :     long nGrow = nDist - nAvail,
     397                 :        423 :          nReal = 0;
     398         [ +  + ]:        423 :     if ( nGrow > 0 )
     399                 :            :     {
     400                 :        397 :         sal_uInt8 nAdjust = pBoss->NeighbourhoodAdjustment( this );
     401         [ +  - ]:        397 :         if( NA_ONLY_ADJUST == nAdjust )
     402                 :        397 :             nReal = AdjustNeighbourhood( nGrow, bTst );
     403                 :            :         else
     404                 :            :         {
     405         [ #  # ]:          0 :             if( NA_GROW_ADJUST == nAdjust )
     406                 :            :             {
     407                 :          0 :                 SwFrm* pFtn = Lower();
     408         [ #  # ]:          0 :                 if( pFtn )
     409                 :            :                 {
     410         [ #  # ]:          0 :                     while( pFtn->GetNext() )
     411                 :          0 :                         pFtn = pFtn->GetNext();
     412         [ #  # ]:          0 :                     if( ((SwFtnFrm*)pFtn)->GetAttr()->GetFtn().IsEndNote() )
     413                 :            :                     {
     414                 :          0 :                         nReal = AdjustNeighbourhood( nGrow, bTst );
     415                 :          0 :                         nAdjust = NA_GROW_SHRINK; // no more AdjustNeighbourhood
     416                 :            :                     }
     417                 :            :                 }
     418                 :            :             }
     419                 :          0 :             nReal += pBoss->Grow( nGrow - nReal, bTst );
     420 [ #  # ][ #  # ]:          0 :             if( ( NA_GROW_ADJUST == nAdjust || NA_ADJUST_GROW == nAdjust )
                 [ #  # ]
     421                 :            :                   && nReal < nGrow )
     422                 :          0 :                 nReal += AdjustNeighbourhood( nGrow - nReal, bTst );
     423                 :            :         }
     424                 :            :     }
     425                 :            : 
     426                 :        423 :     nReal += nAvail;
     427                 :            : 
     428         [ +  + ]:        423 :     if ( !bTst )
     429                 :            :     {
     430         [ -  + ]:        122 :         if ( nReal != nDist )
     431                 :            :         {
     432                 :          0 :             nDist -= nReal;
     433                 :            :             //Den masslosen Wunsch koennen wir leider nur in Grenzen erfuellen.
     434                 :          0 :             Frm().SSize().Height() -= nDist;
     435                 :            :             //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
     436 [ #  # ][ #  # ]:          0 :             if( IsVertical() && !IsVertLR() && !IsReverse() )
         [ #  # ][ #  # ]
     437                 :          0 :                 Frm().Pos().X() += nDist;
     438                 :            :         }
     439                 :            : 
     440                 :            :         //Nachfolger braucht nicht invalidiert werden, denn wir wachsen
     441                 :            :         //immer nach oben.
     442         [ +  + ]:        122 :         if( nReal )
     443                 :            :         {
     444                 :        116 :             _InvalidateSize();
     445                 :        116 :             _InvalidatePos();
     446                 :        116 :             InvalidatePage( pPage );
     447                 :            :         }
     448                 :            :     }
     449                 :        423 :     return nReal;
     450                 :            : }
     451                 :            : 
     452                 :            : 
     453                 :         26 : SwTwips SwFtnContFrm::ShrinkFrm( SwTwips nDiff, sal_Bool bTst, sal_Bool bInfo )
     454                 :            : {
     455                 :         26 :     SwPageFrm *pPage = FindPageFrm();
     456                 :         26 :     bool bShrink = false;
     457         [ +  - ]:         26 :     if ( pPage )
     458                 :            :     {
     459         [ +  - ]:         26 :         if( !pPage->IsFtnPage() )
     460                 :         26 :             bShrink = true;
     461                 :            :         else
     462                 :            :         {
     463                 :          0 :             const ViewShell *pSh = getRootFrm()->GetCurrShell();
     464 [ #  # ][ #  # ]:          0 :             if( pSh && pSh->GetViewOptions()->getBrowseMode() )
                 [ #  # ]
     465                 :          0 :                 bShrink = true;
     466                 :            :         }
     467                 :            :     }
     468         [ +  - ]:         26 :     if( bShrink )
     469                 :            :     {
     470                 :         26 :         SwTwips nRet = SwLayoutFrm::ShrinkFrm( nDiff, bTst, bInfo );
     471 [ #  # ][ -  + ]:         26 :         if( IsInSct() && !bTst )
                 [ -  + ]
     472                 :          0 :             FindSctFrm()->InvalidateNextPos();
     473 [ +  - ][ +  - ]:         26 :         if ( !bTst && nRet )
     474                 :            :         {
     475                 :         26 :             _InvalidatePos();
     476                 :         26 :             InvalidatePage( pPage );
     477                 :            :         }
     478                 :         26 :         return nRet;
     479                 :            :     }
     480                 :         26 :     return 0;
     481                 :            : }
     482                 :            : 
     483                 :            : 
     484                 :            : /*************************************************************************
     485                 :            : |*
     486                 :            : |*  SwFtnFrm::SwFtnFrm()
     487                 :            : |*
     488                 :            : |*************************************************************************/
     489                 :            : 
     490                 :            : 
     491                 :         65 : SwFtnFrm::SwFtnFrm( SwFrmFmt *pFmt, SwFrm* pSib, SwCntntFrm *pCnt, SwTxtFtn *pAt ):
     492                 :            :     SwLayoutFrm( pFmt, pSib ),
     493                 :            :     pFollow( 0 ),
     494                 :            :     pMaster( 0 ),
     495                 :            :     pRef( pCnt ),
     496                 :            :     pAttr( pAt ),
     497                 :            :     bBackMoveLocked( sal_False ),
     498                 :            :     // #i49383#
     499                 :         65 :     mbUnlockPosOfLowerObjs( true )
     500                 :            : {
     501                 :         65 :     nType = FRMC_FTN;
     502                 :         65 : }
     503                 :            : 
     504                 :            : /*************************************************************************
     505                 :            : |*
     506                 :            : |*  SwFtnFrm::InvalidateNxtFtnCnts()
     507                 :            : |*
     508                 :            : |*************************************************************************/
     509                 :            : 
     510                 :            : 
     511                 :         65 : void SwFtnFrm::InvalidateNxtFtnCnts( SwPageFrm *pPage )
     512                 :            : {
     513         [ +  + ]:         65 :     if ( GetNext() )
     514                 :            :     {
     515                 :          6 :         SwFrm *pCnt = ((SwLayoutFrm*)GetNext())->ContainsAny();
     516         [ +  - ]:          6 :         if( pCnt )
     517                 :            :         {
     518                 :          6 :             pCnt->InvalidatePage( pPage );
     519                 :          6 :             pCnt->_InvalidatePrt();
     520         [ -  + ]:          6 :             do
           [ -  +  #  # ]
     521                 :          6 :             {   pCnt->_InvalidatePos();
     522         [ -  + ]:          6 :                 if( pCnt->IsSctFrm() )
     523                 :            :                 {
     524                 :          0 :                     SwFrm* pTmp = ((SwSectionFrm*)pCnt)->ContainsAny();
     525         [ #  # ]:          0 :                     if( pTmp )
     526                 :          0 :                         pTmp->_InvalidatePos();
     527                 :            :                 }
     528                 :          6 :                 pCnt->GetUpper()->_InvalidateSize();
     529                 :          6 :                 pCnt = pCnt->FindNext();
     530                 :          0 :             } while ( pCnt && GetUpper()->IsAnLower( pCnt ) );
     531                 :            :         }
     532                 :            :     }
     533                 :         65 : }
     534                 :            : 
     535                 :            : #ifdef DBG_UTIL
     536                 :            : SwTwips SwFtnFrm::GrowFrm( SwTwips nDist, sal_Bool bTst, sal_Bool bInfo )
     537                 :            : {
     538                 :            :     static sal_uInt16 nNum = USHRT_MAX;
     539                 :            :     SwTxtFtn* pTxtFtn = GetAttr();
     540                 :            :     if ( pTxtFtn->GetFtn().GetNumber() == nNum )
     541                 :            :     {
     542                 :            :         int bla = 5;
     543                 :            :         (void)bla;
     544                 :            : 
     545                 :            :     }
     546                 :            :     return SwLayoutFrm::GrowFrm( nDist, bTst, bInfo );
     547                 :            : }
     548                 :            : 
     549                 :            : 
     550                 :            : SwTwips SwFtnFrm::ShrinkFrm( SwTwips nDist, sal_Bool bTst, sal_Bool bInfo )
     551                 :            : {
     552                 :            :     static sal_uInt16 nNum = USHRT_MAX;
     553                 :            :     if( nNum != USHRT_MAX )
     554                 :            :     {
     555                 :            :         SwTxtFtn* pTxtFtn = GetAttr();
     556                 :            :         if( &pTxtFtn->GetAttr() && pTxtFtn->GetFtn().GetNumber() == nNum )
     557                 :            :         {
     558                 :            :             int bla = 5;
     559                 :            :             (void)bla;
     560                 :            :         }
     561                 :            :     }
     562                 :            :     return SwLayoutFrm::ShrinkFrm( nDist, bTst, bInfo );
     563                 :            : }
     564                 :            : #endif
     565                 :            : 
     566                 :            : /*************************************************************************
     567                 :            : |*
     568                 :            : |*  SwFtnFrm::Cut()
     569                 :            : |*
     570                 :            : |*************************************************************************/
     571                 :            : 
     572                 :            : 
     573                 :         62 : void SwFtnFrm::Cut()
     574                 :            : {
     575         [ +  + ]:         62 :     if ( GetNext() )
     576                 :         14 :         GetNext()->InvalidatePos();
     577         [ +  + ]:         48 :     else if ( GetPrev() )
     578                 :          6 :         GetPrev()->SetRetouche();
     579                 :            : 
     580                 :            :     //Erst removen, dann Upper Shrinken.
     581                 :         62 :     SwLayoutFrm *pUp = GetUpper();
     582                 :            : 
     583                 :            :     //Verkettung korrigieren.
     584                 :         62 :     SwFtnFrm *pFtn = (SwFtnFrm*)this;
     585         [ -  + ]:         62 :     if ( pFtn->GetFollow() )
     586                 :          0 :         pFtn->GetFollow()->SetMaster( pFtn->GetMaster() );
     587         [ -  + ]:         62 :     if ( pFtn->GetMaster() )
     588                 :          0 :         pFtn->GetMaster()->SetFollow( pFtn->GetFollow() );
     589                 :         62 :     pFtn->SetFollow( 0 );
     590                 :         62 :     pFtn->SetMaster( 0 );
     591                 :            : 
     592                 :            :     // Alle Verbindungen kappen.
     593                 :         62 :     Remove();
     594                 :            : 
     595         [ +  - ]:         62 :     if ( pUp )
     596                 :            :     {
     597                 :            :         //Die letzte Fussnote nimmt ihren Container mit.
     598         [ +  + ]:         62 :         if ( !pUp->Lower() )
     599                 :            :         {
     600                 :         42 :             SwPageFrm *pPage = pUp->FindPageFrm();
     601         [ +  - ]:         42 :             if ( pPage )
     602                 :            :             {
     603                 :         42 :                 SwLayoutFrm *pBody = pPage->FindBodyCont();
     604 [ +  + ][ +  + ]:         42 :                 if( pBody && !pBody->ContainsCntnt() )
                 [ +  - ]
     605                 :         10 :                     pPage->getRootFrm()->SetSuperfluous();
     606                 :            :             }
     607                 :         42 :             SwSectionFrm* pSect = pUp->FindSctFrm();
     608                 :         42 :             pUp->Cut();
     609         [ +  - ]:         42 :             delete pUp;
     610                 :            :             // Wenn der letzte Fussnotencontainer aus einem spaltigen Bereich verschwindet,
     611                 :            :             // so kann dieser, falls er keinen Follow besitzt, zusammenschrumpfen.
     612 [ -  + ][ #  # ]:         42 :             if( pSect && !pSect->ToMaximize( sal_False ) && !pSect->IsColLocked() )
         [ #  # ][ -  + ]
     613                 :          0 :                 pSect->_InvalidateSize();
     614                 :            :         }
     615                 :            :         else
     616         [ +  - ]:         20 :         {   if ( Frm().Height() )
     617                 :         20 :                 pUp->Shrink( Frm().Height() );
     618                 :         20 :             pUp->SetCompletePaint();
     619                 :         20 :             pUp->InvalidatePage();
     620                 :            :         }
     621                 :            :     }
     622                 :         62 : }
     623                 :            : 
     624                 :            : /*************************************************************************
     625                 :            : |*
     626                 :            : |*  SwFtnFrm::Paste()
     627                 :            : |*
     628                 :            : |*************************************************************************/
     629                 :            : 
     630                 :            : 
     631                 :         65 : void SwFtnFrm::Paste(  SwFrm* pParent, SwFrm* pSibling )
     632                 :            : {
     633                 :            :     OSL_ENSURE( pParent, "Kein Parent fuer Paste." );
     634                 :            :     OSL_ENSURE( pParent->IsLayoutFrm(), "Parent ist CntntFrm." );
     635                 :            :     OSL_ENSURE( pParent != this, "Bin selbst der Parent." );
     636                 :            :     OSL_ENSURE( pSibling != this, "Bin mein eigener Nachbar." );
     637                 :            :     OSL_ENSURE( !GetPrev() && !GetNext() && !GetUpper(),
     638                 :            :             "Bin noch irgendwo angemeldet." );
     639                 :            : 
     640                 :            :     //In den Baum einhaengen.
     641                 :         65 :     InsertBefore( (SwLayoutFrm*)pParent, pSibling );
     642                 :            : 
     643 [ #  # ][ #  # ]:         65 :     SWRECTFN( this )
         [ -  + ][ -  + ]
     644 [ +  - ][ +  - ]:         65 :     if( (Frm().*fnRect->fnGetWidth)()!=(pParent->Prt().*fnRect->fnGetWidth)() )
                 [ +  + ]
     645                 :         20 :         _InvalidateSize();
     646                 :         65 :     _InvalidatePos();
     647                 :         65 :     SwPageFrm *pPage = FindPageFrm();
     648                 :         65 :     InvalidatePage( pPage );
     649         [ +  + ]:         65 :     if ( GetNext() )
     650                 :          6 :         GetNext()->_InvalidatePos();
     651 [ +  - ][ -  + ]:         65 :     if( (Frm().*fnRect->fnGetHeight)() )
     652         [ #  # ]:          0 :         pParent->Grow( (Frm().*fnRect->fnGetHeight)() );
     653                 :            : 
     654                 :            :     //Wenn mein Vorgaenger mein Master ist und/oder wenn mein Nachfolger mein
     655                 :            :     //Follow ist so kann ich deren Inhalt uebernehmen und sie vernichten.
     656 [ +  + ][ -  + ]:         65 :     if ( GetPrev() && GetPrev() == GetMaster() )
                 [ -  + ]
     657                 :            :     { OSL_ENSURE( SwFlowFrm::CastFlowFrm( GetPrev()->GetLower() ),
     658                 :            :                 "Fussnote ohne Inhalt?" );
     659                 :            :         (SwFlowFrm::CastFlowFrm( GetPrev()->GetLower()))->
     660                 :          0 :             MoveSubTree( this, GetLower() );
     661                 :          0 :         SwFrm *pDel = GetPrev();
     662                 :          0 :         pDel->Cut();
     663         [ #  # ]:          0 :         delete pDel;
     664                 :            :     }
     665 [ +  + ][ -  + ]:         65 :     if ( GetNext() && GetNext() == GetFollow() )
                 [ -  + ]
     666                 :            :     { OSL_ENSURE( SwFlowFrm::CastFlowFrm( GetNext()->GetLower() ),
     667                 :            :                 "Fussnote ohne Inhalt?" );
     668                 :          0 :         (SwFlowFrm::CastFlowFrm( GetNext()->GetLower()))->MoveSubTree( this );
     669                 :          0 :         SwFrm *pDel = GetNext();
     670                 :          0 :         pDel->Cut();
     671         [ #  # ]:          0 :         delete pDel;
     672                 :            :     }
     673                 :            : #if OSL_DEBUG_LEVEL > 0
     674                 :            :     SwDoc *pDoc = GetFmt()->GetDoc();
     675                 :            :     if ( GetPrev() )
     676                 :            :     {
     677                 :            :         OSL_ENSURE( lcl_FindFtnPos( pDoc, ((SwFtnFrm*)GetPrev())->GetAttr() ) <=
     678                 :            :                 lcl_FindFtnPos( pDoc, GetAttr() ), "Prev ist not FtnPrev" );
     679                 :            :     }
     680                 :            :     if ( GetNext() )
     681                 :            :     {
     682                 :            :         OSL_ENSURE( lcl_FindFtnPos( pDoc, GetAttr() ) <=
     683                 :            :                 lcl_FindFtnPos( pDoc, ((SwFtnFrm*)GetNext())->GetAttr() ),
     684                 :            :                 "Next is not FtnNext" );
     685                 :            :     }
     686                 :            : #endif
     687                 :         65 :     InvalidateNxtFtnCnts( pPage );
     688                 :         65 : }
     689                 :            : 
     690                 :            : /*************************************************************************
     691                 :            : |*
     692                 :            : |*  SwFrm::GetNextFtnLeaf()
     693                 :            : |*
     694                 :            : |*  Beschreibung        Liefert das naechste LayoutBlatt in den das
     695                 :            : |*      Frame gemoved werden kann.
     696                 :            : |*      Neue Seiten werden nur dann erzeugt, wenn der Parameter sal_True ist.
     697                 :            : |*
     698                 :            : |*************************************************************************/
     699                 :            : 
     700                 :            : 
     701                 :          0 : SwLayoutFrm *SwFrm::GetNextFtnLeaf( MakePageType eMakePage )
     702                 :            : {
     703                 :          0 :     SwFtnBossFrm *pOldBoss = FindFtnBossFrm();
     704                 :          0 :     SwPageFrm* pOldPage = pOldBoss->FindPageFrm();
     705                 :            :     SwPageFrm* pPage;
     706                 :          0 :     SwFtnBossFrm *pBoss = pOldBoss->IsColumnFrm() ?
     707         [ #  # ]:          0 :         (SwFtnBossFrm*)pOldBoss->GetNext() : 0; // naechste Spalte, wenn vorhanden
     708         [ #  # ]:          0 :     if( pBoss )
     709                 :          0 :         pPage = NULL;
     710                 :            :     else
     711                 :            :     {
     712         [ #  # ]:          0 :         if( pOldBoss->GetUpper()->IsSctFrm() )
     713                 :            :         {   // Das kann nur in einem spaltigen Bereich sein
     714                 :          0 :             SwLayoutFrm* pNxt = pOldBoss->GetNextSctLeaf( eMakePage );
     715         [ #  # ]:          0 :             if( pNxt )
     716                 :            :             {
     717                 :            :                 OSL_ENSURE( pNxt->IsColBodyFrm(), "GetNextFtnLeaf: Funny Leaf" );
     718                 :          0 :                 pBoss = (SwFtnBossFrm*)pNxt->GetUpper();
     719                 :          0 :                 pPage = pBoss->FindPageFrm();
     720                 :            :             }
     721                 :            :             else
     722                 :          0 :                 return 0;
     723                 :            :         }
     724                 :            :         else
     725                 :            :         {
     726                 :            :             // naechste Seite
     727                 :          0 :             pPage = (SwPageFrm*)pOldPage->GetNext();
     728                 :            :             // Leerseiten ueberspringen
     729 [ #  # ][ #  # ]:          0 :             if( pPage && pPage->IsEmptyPage() )
                 [ #  # ]
     730                 :          0 :                 pPage = (SwPageFrm*)pPage->GetNext();
     731                 :          0 :             pBoss = pPage;
     732                 :            :         }
     733                 :            :     }
     734                 :            :     // Was haben wir jetzt?
     735                 :            :     // pBoss != NULL, pPage==NULL => pBoss ist die auf der gleichen Seite folgende Spalte
     736                 :            :     // pBoss != NULL, pPage!=NULL => pBoss und pPage sind die folgende Seite (Empty uebersprungen)
     737                 :            :     // pBoss == NULL => pPage == NULL, es gibt keine folgende Seite
     738                 :            : 
     739                 :            :     //Wenn die Fussnote bereits einen Follow hat brauchen wir nicht zu suchen.
     740                 :            :     //Wenn allerdings zwischen Ftn und Follow unerwuenschte Leerseiten/spalten
     741                 :            :     //herumlungern, so legen wir auf der naechstbesten Seite/Spalte einen weiteren
     742                 :            :     //Follow an, der Rest wird sich schon finden.
     743                 :          0 :     SwFtnFrm *pFtn = FindFtnFrm();
     744 [ #  # ][ #  # ]:          0 :     if ( pFtn && pFtn->GetFollow() )
                 [ #  # ]
     745                 :            :     {
     746                 :          0 :         SwFtnBossFrm* pTmpBoss = pFtn->GetFollow()->FindFtnBossFrm();
     747                 :            :         // Folgende Faelle werden hier erkannt und akzeptiert
     748                 :            :         // 1. Die FtnBosse sind benachbarte Seiten oder benachbarte Spalten
     749                 :            :         // 2. Der neue ist die erste Spalte der benachbarten Seite
     750                 :            :         // 3. Der neue ist die erste Spalte in einem Bereich in der naechsten Spalte/Seite
     751 [ #  # ][ #  # ]:          0 :         while( pTmpBoss != pBoss && pTmpBoss && !pTmpBoss->GetPrev() )
         [ #  # ][ #  # ]
     752                 :          0 :             pTmpBoss = pTmpBoss->GetUpper()->FindFtnBossFrm();
     753         [ #  # ]:          0 :         if( pTmpBoss == pBoss )
     754                 :          0 :             return pFtn->GetFollow();
     755                 :            :     }
     756                 :            : 
     757                 :            :     // Wenn wir keinen pBoss gefunden haben oder es sich um eine "falsche" Seite handelt,
     758                 :            :     // muss eine neue Seite her
     759 [ #  # ][ #  # ]:          0 :     if ( !pBoss || ( pPage && pPage->IsEndNotePage() && !pOldPage->IsEndNotePage() ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     760                 :            :     {
     761 [ #  # ][ #  # ]:          0 :         if ( eMakePage == MAKEPAGE_APPEND || eMakePage == MAKEPAGE_INSERT )
     762                 :            :         {
     763                 :          0 :             pBoss = InsertPage( pOldPage, pOldPage->IsFtnPage() );
     764                 :          0 :             ((SwPageFrm*)pBoss)->SetEndNotePage( pOldPage->IsEndNotePage() );
     765                 :            :         }
     766                 :            :         else
     767                 :          0 :             return 0;
     768                 :            :     }
     769         [ #  # ]:          0 :     if( pBoss->IsPageFrm() )
     770                 :            :     {   // Wenn wir auf einer spaltigen Seite gelandet sind,
     771                 :            :         // gehen wir in die erste Spalte
     772                 :          0 :         SwLayoutFrm* pLay = pBoss->FindBodyCont();
     773 [ #  # ][ #  # ]:          0 :         if( pLay && pLay->Lower() && pLay->Lower()->IsColumnFrm() )
         [ #  # ][ #  # ]
     774                 :          0 :             pBoss = (SwFtnBossFrm*)pLay->Lower();
     775                 :            :     }
     776                 :            :     //Seite/Spalte gefunden, da schummeln wir uns doch gleich mal 'rein
     777                 :          0 :     SwFtnContFrm *pCont = pBoss->FindFtnCont();
     778 [ #  # ][ #  # ]:          0 :     if ( !pCont && pBoss->GetMaxFtnHeight() &&
         [ #  # ][ #  # ]
                 [ #  # ]
     779                 :            :          ( eMakePage == MAKEPAGE_APPEND || eMakePage == MAKEPAGE_INSERT ) )
     780                 :          0 :         pCont = pBoss->MakeFtnCont();
     781                 :          0 :     return pCont;
     782                 :            : }
     783                 :            : 
     784                 :            : /*************************************************************************
     785                 :            : |*
     786                 :            : |*  SwFrm::GetPrevFtnLeaf()
     787                 :            : |*
     788                 :            : |*  Beschreibung        Liefert das vorhergehende LayoutBlatt in das der
     789                 :            : |*      Frame gemoved werden kann.
     790                 :            : |*
     791                 :            : |*************************************************************************/
     792                 :            : 
     793                 :            : 
     794                 :         37 : SwLayoutFrm *SwFrm::GetPrevFtnLeaf( MakePageType eMakeFtn )
     795                 :            : {
     796                 :            :     //Der Vorgaenger fuer eine Fussnote ist falls moeglich der Master
     797                 :            :     //in der Fussnoteneigenen Verkettung.
     798                 :         37 :     SwLayoutFrm *pRet = 0;
     799                 :         37 :     SwFtnFrm *pFtn = FindFtnFrm();
     800                 :         37 :     pRet = pFtn->GetMaster();
     801                 :            : 
     802                 :         37 :     SwFtnBossFrm* pOldBoss = FindFtnBossFrm();
     803                 :         37 :     SwPageFrm *pOldPage = pOldBoss->FindPageFrm();
     804                 :            : 
     805 [ #  # ][ -  + ]:         37 :     if ( !pOldBoss->GetPrev() && !pOldPage->GetPrev() )
                 [ -  + ]
     806                 :          0 :         return pRet; // es gibt weder eine Spalte noch eine Seite vor uns
     807                 :            : 
     808         [ +  - ]:         37 :     if ( !pRet )
     809                 :            :     {
     810                 :         37 :         bool bEndn = pFtn->GetAttr()->GetFtn().IsEndNote();
     811                 :         37 :         SwFrm* pTmpRef = NULL;
     812 [ -  + ][ -  + ]:         37 :         if( bEndn && pFtn->IsInSct() )
                 [ +  + ]
     813                 :            :         {
     814                 :          0 :             SwSectionFrm* pSect = pFtn->FindSctFrm();
     815         [ #  # ]:          0 :             if( pSect->IsEndnAtEnd() )
     816                 :          0 :                 pTmpRef = pSect->FindLastCntnt( FINDMODE_LASTCNT );
     817                 :            :         }
     818         [ +  - ]:         37 :         if( !pTmpRef )
     819                 :         37 :             pTmpRef = pFtn->GetRef();
     820                 :         37 :         SwFtnBossFrm* pStop = pTmpRef->FindFtnBossFrm( !bEndn );
     821                 :            : 
     822                 :         37 :         const sal_uInt16 nNum = pStop->GetPhyPageNum();
     823                 :            : 
     824                 :            :         //Wenn die Fussnoten am Dokumentende angezeigt werden, so verlassen wir
     825                 :            :         //die Entsprechenden Seiten nicht.
     826                 :            :         //Selbiges gilt analog fuer die Endnotenseiten.
     827                 :         37 :         const sal_Bool bEndNote = pOldPage->IsEndNotePage();
     828                 :         37 :         const sal_Bool bFtnEndDoc = pOldPage->IsFtnPage();
     829                 :         37 :         SwFtnBossFrm* pNxtBoss = pOldBoss;
     830                 :         37 :         SwSectionFrm *pSect = pNxtBoss->GetUpper()->IsSctFrm() ?
     831         [ -  + ]:         37 :                               (SwSectionFrm*)pNxtBoss->GetUpper() : 0;
     832                 :            : 
     833         [ #  # ]:          0 :         do
     834                 :            :         {
     835 [ -  + ][ #  # ]:         37 :             if( pNxtBoss->IsColumnFrm() && pNxtBoss->GetPrev() )
                 [ -  + ]
     836                 :          0 :                 pNxtBoss = (SwFtnBossFrm*)pNxtBoss->GetPrev();  // eine Spalte zurueck
     837                 :            :             else                                // oder eine Seite zurueck
     838                 :            :             {
     839                 :         37 :                 SwLayoutFrm* pBody = 0;
     840         [ -  + ]:         37 :                 if( pSect )
     841                 :            :                 {
     842         [ #  # ]:          0 :                     if( pSect->IsFtnLock() )
     843                 :            :                     {
     844         [ #  # ]:          0 :                         if( pNxtBoss == pOldBoss )
     845                 :          0 :                             return 0;
     846                 :          0 :                         pStop = pNxtBoss;
     847                 :            :                     }
     848                 :            :                     else
     849                 :            :                     {
     850                 :          0 :                         pSect = (SwSectionFrm*)pSect->FindMaster();
     851 [ #  # ][ #  # ]:          0 :                         if( !pSect || !pSect->Lower() )
                 [ #  # ]
     852                 :          0 :                             return 0;
     853                 :            :                         OSL_ENSURE( pSect->Lower()->IsColumnFrm(),
     854                 :            :                                 "GetPrevFtnLeaf: Where's the column?" );
     855                 :          0 :                         pNxtBoss = (SwFtnBossFrm*)pSect->Lower();
     856                 :          0 :                         pBody = pSect;
     857                 :            :                     }
     858                 :            :                 }
     859                 :            :                 else
     860                 :            :                 {
     861                 :         37 :                     SwPageFrm* pPage = (SwPageFrm*)pNxtBoss->FindPageFrm()->GetPrev();
     862   [ +  -  +  +  :         78 :                     if( !pPage || pPage->GetPhyPageNum() < nNum ||
           +  - ][ +  - ]
                 [ +  - ]
     863                 :         41 :                         bEndNote != pPage->IsEndNotePage() || bFtnEndDoc != pPage->IsFtnPage() )
     864                 :         37 :                         return NULL; // Keine in Frage kommende Seite mehr gefunden
     865                 :          0 :                     pNxtBoss = pPage;
     866                 :          0 :                     pBody = pPage->FindBodyCont();
     867                 :            :                 }
     868                 :            :                 // Die vorherige Seite haben wir nun, ggf. sollten wir in die letzte Spalte
     869                 :            :                 // der Seite wechseln
     870         [ #  # ]:          0 :                 if( pBody )
     871                 :            :                 {
     872 [ #  # ][ #  # ]:          0 :                     if ( pBody->Lower() && pBody->Lower()->IsColumnFrm() )
                 [ #  # ]
     873                 :            :                     {
     874                 :          0 :                         pNxtBoss = static_cast<SwFtnBossFrm*>(pBody->GetLastLower());
     875                 :            :                     }
     876                 :            :                 }
     877                 :            :             }
     878                 :          0 :             SwFtnContFrm *pCont = pNxtBoss->FindFtnCont();
     879         [ #  # ]:          0 :             if ( pCont )
     880                 :            :             {
     881                 :          0 :                 pRet = pCont;
     882                 :          0 :                 break;
     883                 :            :             }
     884         [ #  # ]:          0 :             if ( pStop == pNxtBoss )
     885                 :            :             {   //Die Seite/Spalte auf der sich auch die Referenz tummelt, ist erreicht.
     886                 :            :                 //Wir koennen jetzt probehalber mal einen Container erzeugen und
     887                 :            :                 //uns hineinpasten.
     888 [ #  # ][ #  # ]:          0 :                 if ( eMakeFtn == MAKEPAGE_FTN && pNxtBoss->GetMaxFtnHeight() )
                 [ #  # ]
     889                 :          0 :                     pRet = pNxtBoss->MakeFtnCont();
     890                 :          0 :                 break;
     891                 :            :             }
     892                 :          0 :         } while( !pRet );
     893                 :            :     }
     894         [ #  # ]:          0 :     if ( pRet )
     895                 :            :     {
     896                 :          0 :         const SwFtnBossFrm* pNewBoss = pRet->FindFtnBossFrm();
     897                 :          0 :         sal_Bool bJump = sal_False;
     898 [ #  # ][ #  # ]:          0 :         if( pOldBoss->IsColumnFrm() && pOldBoss->GetPrev() ) // es gibt eine vorherige Spalte
                 [ #  # ]
     899                 :          0 :             bJump = pOldBoss->GetPrev() != (SwFrm*)pNewBoss;         // sind wir darin gelandet?
     900 [ #  # ][ #  # ]:          0 :         else if( pNewBoss->IsColumnFrm() && pNewBoss->GetNext() )
                 [ #  # ]
     901                 :          0 :             bJump = sal_True; // es gibt hinter dem neuen Boss noch eine Spalte, die aber nicht
     902                 :            :                           // der alte Boss sein kann, das haben wir ja bereits geprueft.
     903                 :            :         else // hier landen wir nur, wenn neuer und alter Boss entweder Seiten oder letzte (neu)
     904                 :            :         {   // bzw. erste (alt) Spalten einer Seite sind. In diesem Fall muss noch geprueft
     905                 :            :             // werden, ob Seiten ueberspringen wurden.
     906                 :          0 :             sal_uInt16 nDiff = pOldPage->GetPhyPageNum() - pRet->FindPageFrm()->GetPhyPageNum();
     907   [ #  #  #  # ]:          0 :             if ( nDiff > 2 ||
         [ #  # ][ #  # ]
     908                 :          0 :                  (nDiff > 1 && !((SwPageFrm*)pOldPage->GetPrev())->IsEmptyPage()) )
     909                 :          0 :                 bJump = sal_True;
     910                 :            :         }
     911         [ #  # ]:          0 :         if( bJump )
     912                 :          0 :             SwFlowFrm::SetMoveBwdJump( sal_True );
     913                 :            :     }
     914                 :         37 :     return pRet;
     915                 :            : }
     916                 :            : 
     917                 :            : /*************************************************************************
     918                 :            : |*
     919                 :            : |*  SwFrm::IsFtnAllowed()
     920                 :            : |*
     921                 :            : |*************************************************************************/
     922                 :            : 
     923                 :            : 
     924                 :       3376 : sal_Bool SwFrm::IsFtnAllowed() const
     925                 :            : {
     926         [ +  + ]:       3376 :     if ( !IsInDocBody() )
     927                 :         42 :         return sal_False;
     928                 :            : 
     929         [ +  + ]:       3334 :     if ( IsInTab() )
     930                 :            :     {
     931                 :            :         //Keine Ftns in wiederholten Headlines.
     932                 :        699 :         const SwTabFrm *pTab = ((SwFrm*)this)->ImplFindTabFrm();
     933         [ -  + ]:        699 :         if ( pTab->IsFollow() )
     934                 :          0 :             return !pTab->IsInHeadline( *this );
     935                 :            :     }
     936                 :       3376 :     return sal_True;
     937                 :            : }
     938                 :            : 
     939                 :            : /*************************************************************************
     940                 :            : |*
     941                 :            : |*  SwRootFrm::UpdateFtnNums()
     942                 :            : |*
     943                 :            : |*************************************************************************/
     944                 :            : 
     945                 :            : 
     946                 :         24 : void SwRootFrm::UpdateFtnNums()
     947                 :            : {
     948                 :            :     //Seitenweise Numerierung nur wenn es am Dokument so eingestellt ist.
     949         [ -  + ]:         24 :     if ( GetFmt()->GetDoc()->GetFtnInfo().eNum == FTNNUM_PAGE )
     950                 :            :     {
     951                 :          0 :         SwPageFrm *pPage = (SwPageFrm*)Lower();
     952 [ #  # ][ #  # ]:          0 :         while ( pPage && !pPage->IsFtnPage() )
                 [ #  # ]
     953                 :            :         {
     954                 :          0 :             pPage->UpdateFtnNum();
     955                 :          0 :             pPage = (SwPageFrm*)pPage->GetNext();
     956                 :            :         }
     957                 :            :     }
     958                 :         24 : }
     959                 :            : 
     960                 :            : /*************************************************************************
     961                 :            : |*
     962                 :            : |*  RemoveFtns()        Entfernen aller Fussnoten (nicht etwa die Referenzen)
     963                 :            : |*                      und Entfernen aller Fussnotenseiten.
     964                 :            : |*
     965                 :            : |*************************************************************************/
     966                 :            : 
     967                 :       1352 : void lcl_RemoveFtns( SwFtnBossFrm* pBoss, sal_Bool bPageOnly, sal_Bool bEndNotes )
     968                 :            : {
     969         [ +  + ]:       1352 :     do
     970                 :            :     {
     971                 :       1352 :         SwFtnContFrm *pCont = pBoss->FindFtnCont();
     972         [ +  + ]:       1352 :         if ( pCont )
     973                 :            :         {
     974                 :         34 :             SwFtnFrm *pFtn = (SwFtnFrm*)pCont->Lower();
     975                 :            :             OSL_ENSURE( pFtn, "FtnCont ohne Ftn." );
     976         [ -  + ]:         34 :             if ( bPageOnly )
     977         [ #  # ]:          0 :                 while ( pFtn->GetMaster() )
     978                 :          0 :                     pFtn = pFtn->GetMaster();
     979         [ +  + ]:         36 :             do
     980                 :            :             {
     981                 :         36 :                 SwFtnFrm *pNxt = (SwFtnFrm*)pFtn->GetNext();
     982 [ +  - ][ +  - ]:         36 :                 if ( !pFtn->GetAttr()->GetFtn().IsEndNote() ||
                 [ +  + ]
     983                 :            :                         bEndNotes )
     984                 :            :                 {
     985                 :         36 :                     pFtn->GetRef()->Prepare( PREP_FTN, (void*)pFtn->GetAttr() );
     986 [ #  # ][ -  + ]:         36 :                     if ( bPageOnly && !pNxt )
     987                 :          0 :                         pNxt = pFtn->GetFollow();
     988                 :         36 :                     pFtn->Cut();
     989         [ +  - ]:         36 :                     delete pFtn;
     990                 :            :                 }
     991                 :         36 :                 pFtn = pNxt;
     992                 :            : 
     993                 :            :             } while ( pFtn );
     994                 :            :         }
     995         [ +  + ]:       1352 :         if( !pBoss->IsInSct() )
     996                 :            :         {
     997                 :            :             // A sectionframe with the Ftn/EndnAtEnd-flags may contain
     998                 :            :             // foot/endnotes. If the last lower frame of the bodyframe is
     999                 :            :             // a multicolumned sectionframe, it may contain footnotes, too.
    1000                 :       1324 :             SwLayoutFrm* pBody = pBoss->FindBodyCont();
    1001 [ +  + ][ +  + ]:       1324 :             if( pBody && pBody->Lower() )
                 [ +  + ]
    1002                 :            :             {
    1003                 :       1305 :                 SwFrm* pLow = pBody->Lower();
    1004         [ +  + ]:       4106 :                 while (pLow)
    1005                 :            :                 {
    1006 [ +  + ][ +  +  :       2913 :                     if( pLow->IsSctFrm() && ( !pLow->GetNext() ||
          +  +  +  -  +  
              + ][ +  + ]
    1007                 :         74 :                         ((SwSectionFrm*)pLow)->IsAnyNoteAtEnd() ) &&
    1008                 :         19 :                         ((SwSectionFrm*)pLow)->Lower() &&
    1009                 :         19 :                         ((SwSectionFrm*)pLow)->Lower()->IsColumnFrm() )
    1010                 :          4 :                         lcl_RemoveFtns( (SwColumnFrm*)((SwSectionFrm*)pLow)->Lower(),
    1011                 :          4 :                             bPageOnly, bEndNotes );
    1012                 :       2801 :                     pLow = pLow->GetNext();
    1013                 :            :                 }
    1014                 :            :             }
    1015                 :            :         }
    1016                 :            :         // noch 'ne Spalte?
    1017         [ +  + ]:       1352 :         pBoss = pBoss->IsColumnFrm() ? (SwColumnFrm*)pBoss->GetNext() : NULL;
    1018                 :            :     } while( pBoss );
    1019                 :       1340 : }
    1020                 :            : 
    1021                 :       1239 : void SwRootFrm::RemoveFtns( SwPageFrm *pPage, sal_Bool bPageOnly, sal_Bool bEndNotes )
    1022                 :            : {
    1023         [ +  + ]:       1239 :     if ( !pPage )
    1024                 :       1233 :         pPage = (SwPageFrm*)Lower();
    1025                 :            : 
    1026         [ +  + ]:       1312 :     do
    1027                 :            :     {   // Bei spaltigen Seiten muessen wir in allen Spalten aufraeumen
    1028                 :            :         SwFtnBossFrm* pBoss;
    1029                 :       1318 :         SwLayoutFrm* pBody = pPage->FindBodyCont();
    1030 [ +  + ][ +  + ]:       1318 :         if( pBody && pBody->Lower() && pBody->Lower()->IsColumnFrm() )
         [ +  + ][ +  + ]
    1031                 :          6 :             pBoss = (SwFtnBossFrm*)pBody->Lower(); // die erste Spalte
    1032                 :            :         else
    1033                 :       1312 :             pBoss = pPage; // keine Spalten
    1034                 :       1318 :         lcl_RemoveFtns( pBoss, bPageOnly, bEndNotes );
    1035         [ +  + ]:       1318 :         if ( !bPageOnly )
    1036                 :            :         {
    1037   [ +  +  +  + ]:       1322 :             if ( pPage->IsFtnPage() &&
         [ +  - ][ +  + ]
    1038                 :         10 :                  (!pPage->IsEndNotePage() || bEndNotes) )
    1039                 :            :             {
    1040                 :         10 :                 SwFrm *pDel = pPage;
    1041                 :         10 :                 pPage = (SwPageFrm*)pPage->GetNext();
    1042                 :         10 :                 pDel->Cut();
    1043         [ +  - ]:         10 :                 delete pDel;
    1044                 :            :             }
    1045                 :            :             else
    1046                 :       1302 :                 pPage = (SwPageFrm*)pPage->GetNext();
    1047                 :            :         }
    1048                 :            :         else
    1049                 :          6 :             break;
    1050                 :            : 
    1051                 :            :     } while ( pPage );
    1052                 :       1239 : }
    1053                 :            : 
    1054                 :            : /*************************************************************************
    1055                 :            : |*
    1056                 :            : |*  SetFtnPageDescs()   Seitenvorlagen der Fussnotenseiten aendern
    1057                 :            : |*
    1058                 :            : |*************************************************************************/
    1059                 :            : 
    1060                 :          2 : void SwRootFrm::CheckFtnPageDescs( sal_Bool bEndNote )
    1061                 :            : {
    1062                 :          2 :     SwPageFrm *pPage = (SwPageFrm*)Lower();
    1063 [ +  - ][ +  + ]:          4 :     while ( pPage && !pPage->IsFtnPage() )
                 [ +  + ]
    1064                 :          2 :         pPage = (SwPageFrm*)pPage->GetNext();
    1065 [ +  - ][ -  + ]:          2 :     while ( pPage && pPage->IsEndNotePage() != bEndNote )
                 [ -  + ]
    1066                 :          0 :         pPage = (SwPageFrm*)pPage->GetNext();
    1067         [ +  - ]:          2 :     if ( pPage )
    1068                 :          2 :         SwFrm::CheckPageDescs( pPage, sal_False );
    1069                 :          2 : }
    1070                 :            : 
    1071                 :            : 
    1072                 :            : /*************************************************************************
    1073                 :            : |*
    1074                 :            : |*  SwFtnBossFrm::MakeFtnCont()
    1075                 :            : |*
    1076                 :            : |*************************************************************************/
    1077                 :            : 
    1078                 :            : 
    1079                 :         45 : SwFtnContFrm *SwFtnBossFrm::MakeFtnCont()
    1080                 :            : {
    1081                 :            :     //Einfuegen eines Fussnotencontainers. Der Fussnotencontainer sitzt
    1082                 :            :     //immer direkt hinter dem Bodytext.
    1083                 :            :     //Sein FrmFmt ist immer das DefaultFrmFmt.
    1084                 :            : 
    1085                 :            : #if OSL_DEBUG_LEVEL > 1
    1086                 :            :     if ( FindFtnCont() )
    1087                 :            :     {   OSL_ENSURE( !this, "Fussnotencontainer bereits vorhanden." );
    1088                 :            :         return 0;
    1089                 :            :     }
    1090                 :            : #endif
    1091                 :            : 
    1092         [ +  - ]:         45 :     SwFtnContFrm *pNew = new SwFtnContFrm( GetFmt()->GetDoc()->GetDfltFrmFmt(), this );
    1093                 :         45 :     SwLayoutFrm *pLay = FindBodyCont();
    1094                 :         45 :     pNew->Paste( this, pLay->GetNext() );
    1095                 :         45 :     return pNew;
    1096                 :            : }
    1097                 :            : 
    1098                 :            : /*************************************************************************
    1099                 :            : |*
    1100                 :            : |*  SwFtnBossFrm::FindFtnCont()
    1101                 :            : |*
    1102                 :            : |*************************************************************************/
    1103                 :            : 
    1104                 :            : 
    1105                 :       3485 : SwFtnContFrm *SwFtnBossFrm::FindFtnCont()
    1106                 :            : {
    1107                 :       3485 :     SwFrm *pFrm = Lower();
    1108 [ +  + ][ +  + ]:       7032 :     while( pFrm && !pFrm->IsFtnContFrm() )
                 [ +  + ]
    1109                 :       3547 :         pFrm = pFrm->GetNext();
    1110                 :            : 
    1111                 :            : #if OSL_DEBUG_LEVEL > 0
    1112                 :            :     if ( pFrm )
    1113                 :            :     {
    1114                 :            :         SwFrm *pFtn = pFrm->GetLower();
    1115                 :            :         OSL_ENSURE( pFtn, "Cont ohne Fussnote." );
    1116                 :            :         while ( pFtn )
    1117                 :            :         {
    1118                 :            :             OSL_ENSURE( pFtn->IsFtnFrm(), "Nachbar von Fussnote keine Fussnote." );
    1119                 :            :             pFtn = pFtn->GetNext();
    1120                 :            :         }
    1121                 :            :     }
    1122                 :            : #endif
    1123                 :            : 
    1124                 :       3485 :     return (SwFtnContFrm*)pFrm;
    1125                 :            : }
    1126                 :            : 
    1127                 :            : /*************************************************************************
    1128                 :            : |*
    1129                 :            : |*  SwFtnBossFrm::FindNearestFtnCont()  Sucht den naechst greifbaren Fussnotencontainer.
    1130                 :            : |*
    1131                 :            : |*************************************************************************/
    1132                 :            : 
    1133                 :        207 : SwFtnContFrm *SwFtnBossFrm::FindNearestFtnCont( sal_Bool bDontLeave )
    1134                 :            : {
    1135                 :        207 :     SwFtnContFrm *pCont = 0;
    1136         [ +  - ]:        207 :     if ( !GetFmt()->GetDoc()->GetFtnIdxs().empty() )
    1137                 :            :     {
    1138                 :        207 :         pCont = FindFtnCont();
    1139         [ +  + ]:        207 :         if ( !pCont )
    1140                 :            :         {
    1141         [ +  - ]:         90 :             SwPageFrm *pPage = FindPageFrm();
    1142                 :         90 :             SwFtnBossFrm* pBoss = this;
    1143                 :         90 :             sal_Bool bEndNote = pPage->IsEndNotePage();
    1144 [ +  - ][ -  + ]:         90 :             do
                 [ -  + ]
    1145                 :            :             {
    1146         [ +  - ]:         90 :                 sal_Bool bChgPage = lcl_NextFtnBoss( pBoss, pPage, bDontLeave );
    1147                 :            :                 // Haben wir noch einen Boss gefunden? Bei einem Seitenwechsel muss
    1148                 :            :                 // zudem noch das EndNotenFlag uebereinstimmen
    1149 [ -  + ][ #  # ]:         90 :                 if( pBoss && ( !bChgPage || pPage->IsEndNotePage() == bEndNote ) )
         [ #  # ][ -  + ]
    1150                 :          0 :                     pCont = pBoss->FindFtnCont();
    1151                 :            :             } while ( !pCont && pPage );
    1152                 :            :         }
    1153                 :            :     }
    1154                 :        207 :     return pCont;
    1155                 :            : }
    1156                 :            : 
    1157                 :            : 
    1158                 :            : /*************************************************************************
    1159                 :            : |*
    1160                 :            : |*  SwFtnBossFrm::FindFirstFtn()
    1161                 :            : |*
    1162                 :            : |*  Beschreibung        Erste Fussnote des Fussnotenbosses suchen.
    1163                 :            : |*
    1164                 :            : |*************************************************************************/
    1165                 :            : 
    1166                 :            : 
    1167                 :        162 : SwFtnFrm *SwFtnBossFrm::FindFirstFtn()
    1168                 :            : {
    1169                 :            :     //Erstmal den naechsten FussnotenContainer suchen.
    1170         [ +  - ]:        162 :     SwFtnContFrm *pCont = FindNearestFtnCont();
    1171         [ +  + ]:        162 :     if ( !pCont )
    1172                 :         45 :         return 0;
    1173                 :            : 
    1174                 :            :     //Ab der ersten Fussnote im Container die erste suchen, die
    1175                 :            :     //von der aktuellen Spalte (bzw. einspaltigen Seite) referenziert wird.
    1176                 :            : 
    1177                 :        117 :     SwFtnFrm *pRet = (SwFtnFrm*)pCont->Lower();
    1178         [ +  - ]:        117 :     const sal_uInt16 nRefNum = FindPageFrm()->GetPhyPageNum();
    1179         [ +  - ]:        117 :     const sal_uInt16 nRefCol = lcl_ColumnNum( this );
    1180                 :            :     sal_uInt16 nPgNum, nColNum; //Seitennummer, Spaltennummer
    1181                 :            :     SwFtnBossFrm* pBoss;
    1182                 :            :     SwPageFrm* pPage;
    1183         [ +  - ]:        117 :     if( pRet )
    1184                 :            :     {
    1185         [ +  - ]:        117 :         pBoss = pRet->GetRef()->FindFtnBossFrm();
    1186                 :            :         OSL_ENSURE( pBoss, "FindFirstFtn: No boss found" );
    1187         [ -  + ]:        117 :         if( !pBoss )
    1188                 :          0 :             return sal_False; // ?There must be a bug, but no GPF
    1189         [ +  - ]:        117 :         pPage = pBoss->FindPageFrm();
    1190                 :        117 :         nPgNum = pPage->GetPhyPageNum();
    1191         [ +  - ]:        117 :         if ( nPgNum == nRefNum )
    1192                 :            :         {
    1193         [ +  - ]:        117 :             nColNum = lcl_ColumnNum( pBoss );
    1194         [ +  - ]:        117 :             if( nColNum == nRefCol )
    1195                 :        117 :                 return pRet; //hat ihn.
    1196         [ #  # ]:          0 :             else if( nColNum > nRefCol )
    1197                 :          0 :                 return NULL; //mind. eine Spalte zu weit.
    1198                 :            :         }
    1199         [ #  # ]:          0 :         else if ( nPgNum > nRefNum )
    1200                 :          0 :             return NULL;    //mind. eine Seite zu weit.
    1201                 :            :     }
    1202                 :            :     else
    1203                 :          0 :         return NULL;
    1204                 :            :     // Ende, wenn Ref auf einer spaeteren Seite oder auf der gleichen Seite in einer
    1205                 :            :     // spaeteren Spalte liegt
    1206                 :            : 
    1207         [ #  # ]:          0 :     do
    1208                 :            :     {
    1209         [ #  # ]:          0 :         while ( pRet->GetFollow() )
    1210                 :          0 :             pRet = pRet->GetFollow();
    1211                 :            : 
    1212                 :          0 :         SwFtnFrm *pNxt = (SwFtnFrm*)pRet->GetNext();
    1213         [ #  # ]:          0 :         if ( !pNxt )
    1214                 :            :         {
    1215         [ #  # ]:          0 :             pBoss = pRet->FindFtnBossFrm();
    1216         [ #  # ]:          0 :             pPage = pBoss->FindPageFrm();
    1217         [ #  # ]:          0 :             lcl_NextFtnBoss( pBoss, pPage, sal_False ); // naechster FtnBoss
    1218 [ #  # ][ #  # ]:          0 :             pCont = pBoss ? pBoss->FindNearestFtnCont() : 0;
    1219         [ #  # ]:          0 :             if ( pCont )
    1220                 :          0 :                 pNxt = (SwFtnFrm*)pCont->Lower();
    1221                 :            :         }
    1222         [ #  # ]:          0 :         if ( pNxt )
    1223                 :            :         {
    1224                 :          0 :             pRet = pNxt;
    1225         [ #  # ]:          0 :             pBoss = pRet->GetRef()->FindFtnBossFrm();
    1226         [ #  # ]:          0 :             pPage = pBoss->FindPageFrm();
    1227                 :          0 :             nPgNum = pPage->GetPhyPageNum();
    1228         [ #  # ]:          0 :             if ( nPgNum == nRefNum )
    1229                 :            :             {
    1230         [ #  # ]:          0 :                 nColNum = lcl_ColumnNum( pBoss );
    1231         [ #  # ]:          0 :                 if( nColNum == nRefCol )
    1232                 :          0 :                     break; //hat ihn.
    1233         [ #  # ]:          0 :                 else if( nColNum > nRefCol )
    1234                 :          0 :                     pRet = 0; //mind. eine Spalte zu weit.
    1235                 :            :             }
    1236         [ #  # ]:          0 :             else if ( nPgNum > nRefNum )
    1237                 :          0 :                 pRet = 0;   //mind. eine Seite zu weit.
    1238                 :            :         }
    1239                 :            :         else
    1240                 :          0 :             pRet = 0;   //Gibt eben keinen.
    1241                 :            :     } while( pRet );
    1242                 :        162 :     return pRet;
    1243                 :            : }
    1244                 :            : 
    1245                 :            : /*************************************************************************
    1246                 :            : |*
    1247                 :            : |*  SwFtnBossFrm::FindFirstFtn()
    1248                 :            : |*
    1249                 :            : |*  Beschreibunt        Erste Fussnote zum Cnt suchen.
    1250                 :            : |*
    1251                 :            : |*************************************************************************/
    1252                 :            : 
    1253                 :            : 
    1254                 :         28 : const SwFtnFrm *SwFtnBossFrm::FindFirstFtn( SwCntntFrm *pCnt ) const
    1255                 :            : {
    1256                 :         28 :     const SwFtnFrm *pRet = ((SwFtnBossFrm*)this)->FindFirstFtn();
    1257         [ +  - ]:         28 :     if ( pRet )
    1258                 :            :     {
    1259                 :         28 :         const sal_uInt16 nColNum = lcl_ColumnNum( this ); //Spaltennummer
    1260                 :         28 :         const sal_uInt16 nPageNum = GetPhyPageNum();
    1261 [ +  - ][ -  + ]:         28 :         while ( pRet && (pRet->GetRef() != pCnt) )
                 [ -  + ]
    1262                 :            :         {
    1263         [ #  # ]:          0 :             while ( pRet->GetFollow() )
    1264                 :          0 :                 pRet = pRet->GetFollow();
    1265                 :            : 
    1266         [ #  # ]:          0 :             if ( pRet->GetNext() )
    1267                 :          0 :                 pRet = (const SwFtnFrm*)pRet->GetNext();
    1268                 :            :             else
    1269         [ #  # ]:          0 :             {   SwFtnBossFrm *pBoss = (SwFtnBossFrm*)pRet->FindFtnBossFrm();
    1270         [ #  # ]:          0 :                 SwPageFrm *pPage = pBoss->FindPageFrm();
    1271         [ #  # ]:          0 :                 lcl_NextFtnBoss( pBoss, pPage, sal_False ); // naechster FtnBoss
    1272 [ #  # ][ #  # ]:          0 :                 SwFtnContFrm *pCont = pBoss ? pBoss->FindNearestFtnCont() : 0;
    1273         [ #  # ]:          0 :                 pRet = pCont ? (SwFtnFrm*)pCont->Lower() : 0;
    1274                 :            :             }
    1275         [ #  # ]:          0 :             if ( pRet )
    1276                 :            :             {
    1277                 :          0 :                 const SwFtnBossFrm* pBoss = pRet->GetRef()->FindFtnBossFrm();
    1278         [ #  # ]:          0 :                 if( pBoss->GetPhyPageNum() != nPageNum ||
           [ #  #  #  # ]
    1279                 :          0 :                     nColNum != lcl_ColumnNum( pBoss ) )
    1280                 :          0 :                 pRet = 0;
    1281                 :            :             }
    1282                 :            :         }
    1283                 :            :     }
    1284                 :         28 :     return pRet;
    1285                 :            : }
    1286                 :            : 
    1287                 :            : /*************************************************************************
    1288                 :            : |*
    1289                 :            : |*  SwFtnBossFrm::ResetFtn()
    1290                 :            : |*
    1291                 :            : |*************************************************************************/
    1292                 :            : 
    1293                 :            : 
    1294                 :         65 : void SwFtnBossFrm::ResetFtn( const SwFtnFrm *pCheck )
    1295                 :            : {
    1296                 :            :     //Vernichten der Inkarnationen von Fussnoten zum Attribut, wenn sie nicht
    1297                 :            :     //zu pAssumed gehoeren.
    1298                 :            :     OSL_ENSURE( !pCheck->GetMaster(), "Master not an Master." );
    1299                 :            : 
    1300         [ +  - ]:         65 :     SwNodeIndex aIdx( *pCheck->GetAttr()->GetStartNode(), 1 );
    1301                 :         65 :     SwCntntNode *pNd = aIdx.GetNode().GetCntntNode();
    1302         [ -  + ]:         65 :     if ( !pNd )
    1303         [ #  # ]:          0 :         pNd = pCheck->GetFmt()->GetDoc()->
    1304 [ #  # ][ #  # ]:          0 :               GetNodes().GoNextSection( &aIdx, sal_True, sal_False );
    1305         [ +  - ]:         65 :     SwIterator<SwFrm,SwCntntNode> aIter( *pNd );
    1306         [ +  - ]:         65 :     SwFrm* pFrm = aIter.First();
    1307         [ +  + ]:        130 :     while( pFrm )
    1308                 :            :     {
    1309         [ +  - ]:         65 :             if( pFrm->getRootFrm() == pCheck->getRootFrm() )
    1310                 :            :             {
    1311                 :         65 :             SwFrm *pTmp = pFrm->GetUpper();
    1312 [ +  - ][ -  + ]:         65 :             while ( pTmp && !pTmp->IsFtnFrm() )
                 [ -  + ]
    1313                 :          0 :                 pTmp = pTmp->GetUpper();
    1314                 :            : 
    1315                 :         65 :             SwFtnFrm *pFtn = (SwFtnFrm*)pTmp;
    1316 [ +  - ][ -  + ]:         65 :             while ( pFtn && pFtn->GetMaster() )
                 [ -  + ]
    1317                 :          0 :                 pFtn = pFtn->GetMaster();
    1318         [ -  + ]:         65 :             if ( pFtn != pCheck )
    1319                 :            :             {
    1320         [ #  # ]:          0 :                 while ( pFtn )
    1321                 :            :                 {
    1322                 :          0 :                     SwFtnFrm *pNxt = pFtn->GetFollow();
    1323         [ #  # ]:          0 :                     pFtn->Cut();
    1324 [ #  # ][ #  # ]:          0 :                     delete pFtn;
    1325                 :          0 :                     pFtn = pNxt;
    1326                 :            :                 }
    1327                 :            :             }
    1328                 :            :         }
    1329                 :            : 
    1330         [ +  - ]:         65 :         pFrm = aIter.Next();
    1331 [ +  - ][ +  - ]:         65 :     }
    1332                 :         65 : }
    1333                 :            : 
    1334                 :            : /*************************************************************************
    1335                 :            : |*
    1336                 :            : |*  SwFtnBossFrm::InsertFtn()
    1337                 :            : |*
    1338                 :            : |*************************************************************************/
    1339                 :            : 
    1340                 :            : 
    1341                 :         65 : void SwFtnBossFrm::InsertFtn( SwFtnFrm* pNew )
    1342                 :            : {
    1343                 :            :     //Die Fussnote haben wir, sie muss jetzt nur noch irgendwo
    1344                 :            :     //hin und zwar vor die Fussnote, deren Attribut vor das
    1345                 :            :     //der neuen zeigt (Position wird ueber das Doc ermittelt)
    1346                 :            :     //Gibt es in diesem Fussnotenboss noch keine Fussnoten, so muss eben ein
    1347                 :            :     //Container erzeugt werden.
    1348                 :            :     //Gibt es bereits einen Container aber noch keine Fussnote zu diesem
    1349                 :            :     //Fussnotenboss, so muss die Fussnote hinter die letzte Fussnote der dichtesten
    1350                 :            :     //Vorseite/spalte.
    1351                 :            : 
    1352                 :         65 :     ResetFtn( pNew );
    1353                 :         65 :     SwFtnFrm *pSibling = FindFirstFtn();
    1354                 :         65 :     sal_Bool bDontLeave = sal_False;
    1355                 :            : 
    1356                 :            :     // Ok, a sibling has been found, but is the sibling in an acceptable
    1357                 :            :     // environment?
    1358         [ -  + ]:         65 :     if( IsInSct() )
    1359                 :            :     {
    1360                 :          0 :         SwSectionFrm* pMySect = ImplFindSctFrm();
    1361                 :          0 :         bool bEndnt = pNew->GetAttr()->GetFtn().IsEndNote();
    1362         [ #  # ]:          0 :         if( bEndnt )
    1363                 :            :         {
    1364                 :          0 :             const SwSectionFmt* pEndFmt = pMySect->GetEndSectFmt();
    1365                 :          0 :             bDontLeave = 0 != pEndFmt;
    1366         [ #  # ]:          0 :             if( pSibling )
    1367                 :            :             {
    1368         [ #  # ]:          0 :                 if( pEndFmt )
    1369                 :            :                 {
    1370   [ #  #  #  # ]:          0 :                     if( !pSibling->IsInSct() ||
                 [ #  # ]
    1371                 :          0 :                         !pSibling->ImplFindSctFrm()->IsDescendantFrom( pEndFmt ) )
    1372                 :          0 :                         pSibling = NULL;
    1373                 :            :                 }
    1374         [ #  # ]:          0 :                 else if( pSibling->IsInSct() )
    1375                 :          0 :                     pSibling = NULL;
    1376                 :            :             }
    1377                 :            :         }
    1378                 :            :         else
    1379                 :            :         {
    1380                 :          0 :             bDontLeave = pMySect->IsFtnAtEnd();
    1381         [ #  # ]:          0 :             if( pSibling )
    1382                 :            :             {
    1383         [ #  # ]:          0 :                 if( pMySect->IsFtnAtEnd() )
    1384                 :            :                 {
    1385   [ #  #  #  # ]:          0 :                     if( !pSibling->IsInSct() ||
                 [ #  # ]
    1386         [ #  # ]:          0 :                         !pMySect->IsAnFollow( pSibling->ImplFindSctFrm() ) )
    1387                 :          0 :                         pSibling = NULL;
    1388                 :            :                 }
    1389         [ #  # ]:          0 :                 else if( pSibling->IsInSct() )
    1390                 :          0 :                     pSibling = NULL;
    1391                 :            :             }
    1392                 :            :         }
    1393                 :            :     }
    1394                 :            : 
    1395 [ +  + ][ -  + ]:         85 :     if( pSibling && pSibling->FindPageFrm()->IsEndNotePage() !=
                 [ -  + ]
    1396                 :         20 :         FindPageFrm()->IsEndNotePage() )
    1397                 :          0 :         pSibling = NULL;
    1398                 :            : 
    1399                 :            :     //Damit die Position herausgefunden werden kann.
    1400                 :         65 :     SwDoc *pDoc = GetFmt()->GetDoc();
    1401                 :         65 :     const sal_uLong nStPos = ::lcl_FindFtnPos( pDoc, pNew->GetAttr() );
    1402                 :            : 
    1403                 :         65 :     sal_uLong nCmpPos = 0;
    1404                 :         65 :     sal_uLong nLastPos = 0;
    1405                 :         65 :     SwFtnContFrm *pParent = 0;
    1406         [ +  + ]:         65 :     if( pSibling )
    1407                 :            :     {
    1408                 :         20 :         nCmpPos = ::lcl_FindFtnPos( pDoc, pSibling->GetAttr() );
    1409         [ +  + ]:         20 :         if( nCmpPos > nStPos )
    1410                 :          6 :             pSibling = NULL;
    1411                 :            :     }
    1412                 :            : 
    1413         [ +  + ]:         65 :     if ( !pSibling )
    1414                 :         51 :     {   pParent = FindFtnCont();
    1415         [ +  + ]:         51 :         if ( !pParent )
    1416                 :            :         {
    1417                 :            :             //Es gibt noch keinen FussnotenContainer, also machen wir einen.
    1418                 :            :             //HAAAAAAAALT! So einfach ist das leider mal wieder nicht: Es kann
    1419                 :            :             //sein, dass irgendeine naechste Fussnote existiert die vor der
    1420                 :            :             //einzufuegenden zu stehen hat, weil z.B. eine Fussnote ueber zig
    1421                 :            :             //Seiten aufgespalten ist usw.
    1422                 :         45 :             pParent = FindNearestFtnCont( bDontLeave );
    1423         [ -  + ]:         45 :             if ( pParent )
    1424                 :            :             {
    1425                 :          0 :                 SwFtnFrm *pFtn = (SwFtnFrm*)pParent->Lower();
    1426         [ #  # ]:          0 :                 if ( pFtn )
    1427                 :            :                 {
    1428                 :            : 
    1429                 :          0 :                     nCmpPos = ::lcl_FindFtnPos( pDoc, pFtn->GetAttr() );
    1430         [ #  # ]:          0 :                     if ( nCmpPos > nStPos )
    1431                 :          0 :                         pParent = 0;
    1432                 :            :                 }
    1433                 :            :                 else
    1434                 :          0 :                     pParent = 0;
    1435                 :            :             }
    1436                 :            :         }
    1437         [ +  + ]:         51 :         if ( !pParent )
    1438                 :            :             //Jetzt kann aber ein Fussnotencontainer gebaut werden.
    1439                 :         45 :             pParent = MakeFtnCont();
    1440                 :            :         else
    1441                 :            :         {
    1442                 :            :             //Ausgehend von der ersten Fussnote unterhalb des Parents wird die
    1443                 :            :             //erste Fussnote gesucht deren Index hinter dem Index der
    1444                 :            :             //einzufuegenden liegt; vor dieser kann der neue dann gepastet
    1445                 :            :             //werden.
    1446                 :          6 :             pSibling = (SwFtnFrm*)pParent->Lower();
    1447         [ +  - ]:          6 :             if ( !pSibling )
    1448                 :            :             { OSL_ENSURE( !this, "Keinen Platz fuer Fussnote gefunden.");
    1449                 :         65 :                 return;
    1450                 :            :             }
    1451         [ +  - ]:          6 :             nCmpPos  = ::lcl_FindFtnPos( pDoc, pSibling->GetAttr() );
    1452                 :            : 
    1453                 :          6 :             SwFtnBossFrm *pNxtB = this; //Immer den letzten merken, damit wir nicht
    1454                 :          6 :             SwFtnFrm  *pLastSib = 0;    //ueber das Ziel hinausschiessen.
    1455                 :            : 
    1456 [ +  - ][ -  + ]:          6 :             while ( pSibling && nCmpPos <= nStPos )
                 [ -  + ]
    1457                 :            :             {
    1458                 :          0 :                 pLastSib = pSibling; // der kommt schon mal in Frage
    1459                 :          0 :                 nLastPos = nCmpPos;
    1460                 :            : 
    1461         [ #  # ]:          0 :                 while ( pSibling->GetFollow() )
    1462                 :          0 :                     pSibling = pSibling->GetFollow();
    1463                 :            : 
    1464         [ #  # ]:          0 :                 if ( pSibling->GetNext() )
    1465                 :            :                 {
    1466                 :          0 :                     pSibling = (SwFtnFrm*)pSibling->GetNext();
    1467                 :            :                     OSL_ENSURE( !pSibling->GetMaster() || ( ENDNOTE > nStPos &&
    1468                 :            :                             pSibling->GetAttr()->GetFtn().IsEndNote() ),
    1469                 :            :                             "InsertFtn: Master expected I" );
    1470                 :            :                 }
    1471                 :            :                 else
    1472                 :            :                 {
    1473         [ #  # ]:          0 :                     pNxtB = pSibling->FindFtnBossFrm();
    1474         [ #  # ]:          0 :                     SwPageFrm *pSibPage = pNxtB->FindPageFrm();
    1475                 :          0 :                     sal_Bool bEndNote = pSibPage->IsEndNotePage();
    1476         [ #  # ]:          0 :                     sal_Bool bChgPage = lcl_NextFtnBoss( pNxtB, pSibPage, bDontLeave );
    1477                 :            :                     // Bei Seitenwechsel muss das EndNoteFlag ueberprueft werden.
    1478                 :            :                     SwFtnContFrm *pCont = pNxtB && ( !bChgPage ||
    1479                 :          0 :                         pSibPage->IsEndNotePage() == bEndNote )
    1480         [ #  # ]:          0 :                         ? pNxtB->FindNearestFtnCont( bDontLeave ) : 0;
           [ #  #  #  # ]
                 [ #  # ]
    1481         [ #  # ]:          0 :                     if( pCont )
    1482                 :          0 :                         pSibling = (SwFtnFrm*)pCont->Lower();
    1483                 :            :                     else // kein weiterer FtnContainer, dann werden  wir uns wohl hinter
    1484                 :            :                         break; // pSibling haengen
    1485                 :            :                 }
    1486         [ #  # ]:          0 :                 if ( pSibling )
    1487                 :            :                 {
    1488         [ #  # ]:          0 :                     nCmpPos = ::lcl_FindFtnPos( pDoc, pSibling->GetAttr() );
    1489                 :            :                     OSL_ENSURE( nCmpPos > nLastPos, "InsertFtn: Order of FtnFrm's buggy" );
    1490                 :            :                 }
    1491                 :            :             }
    1492                 :            :             // pLastSib ist jetzt die letzte Fussnote vor uns,
    1493                 :            :             // pSibling leer oder die erste nach uns.
    1494 [ +  - ][ -  + ]:          6 :             if ( pSibling && pLastSib && (pSibling != pLastSib) )
                 [ #  # ]
    1495                 :            :             {   //Sind wir vielleicht bereits ueber das Ziel hinausgeschossen?
    1496         [ #  # ]:          0 :                 if ( nCmpPos > nStPos )
    1497                 :          0 :                     pSibling = pLastSib;
    1498                 :            :             }
    1499         [ -  + ]:          6 :             else if ( !pSibling )
    1500                 :            :             {   //Eine Chance haben wir noch: wir nehmen einfach die letzte
    1501                 :            :                 //Fussnote im Parent. Ein Sonderfall, der z.B. beim
    1502                 :            :                 //zurueckfliessen von Absaetzen mit mehreren Fussnoten
    1503                 :            :                 //vorkommt.
    1504                 :            :                 //Damit wir nicht die Reihenfolge verwuerfeln muessen wir den
    1505                 :            :                 //Parent der letzten Fussnote, die wir an der Hand hatten benutzen.
    1506                 :          0 :                 pSibling = pLastSib;
    1507         [ #  # ]:          6 :                 while( pSibling->GetFollow() )
    1508                 :          0 :                     pSibling = pSibling->GetFollow();
    1509                 :            :                 OSL_ENSURE( !pSibling->GetNext(), "InsertFtn: Who's that guy?" );
    1510                 :            :             }
    1511                 :            :         }
    1512                 :            :     }
    1513                 :            :     else
    1514                 :            :     {   //Die erste Fussnote der Spalte/Seite haben wir an der Hand, jetzt ausgehend
    1515                 :            :         //von dieser die erste zur selben Spalte/Seite suchen deren Index hinter
    1516                 :            :         //den uebergebenen zeigt, die letzte, die wir an der Hand hatten, ist
    1517                 :            :         //dann der Vorgaenger.
    1518                 :         14 :         SwFtnBossFrm* pBoss = pNew->GetRef()->FindFtnBossFrm(
    1519                 :         28 :             !pNew->GetAttr()->GetFtn().IsEndNote() );
    1520                 :         14 :         sal_uInt16 nRefNum = pBoss->GetPhyPageNum();    // Die Seiten- und
    1521                 :         14 :         sal_uInt16 nRefCol = lcl_ColumnNum( pBoss );    // Spaltennummer der neuen Fussnote
    1522                 :         14 :         sal_Bool bEnd = sal_False;
    1523                 :         14 :         SwFtnFrm *pLastSib = 0;
    1524 [ +  - ][ +  + ]:         28 :         while ( pSibling && !bEnd && (nCmpPos <= nStPos) )
         [ +  - ][ +  + ]
    1525                 :            :         {
    1526                 :         14 :             pLastSib = pSibling;
    1527                 :         14 :             nLastPos = nCmpPos;
    1528                 :            : 
    1529         [ -  + ]:         14 :             while ( pSibling->GetFollow() )
    1530                 :          0 :                 pSibling = pSibling->GetFollow();
    1531                 :            : 
    1532                 :         14 :             SwFtnFrm *pFoll = (SwFtnFrm*)pSibling->GetNext();
    1533         [ -  + ]:         14 :             if ( pFoll )
    1534                 :            :             {
    1535                 :          0 :                 pBoss = pSibling->GetRef()->FindFtnBossFrm( !pSibling->
    1536                 :          0 :                                             GetAttr()->GetFtn().IsEndNote() );
    1537                 :            :                 sal_uInt16 nTmpRef;
    1538         [ #  # ]:          0 :                 if( nStPos >= ENDNOTE ||
           [ #  #  #  # ]
         [ #  # ][ #  # ]
    1539                 :          0 :                     (nTmpRef = pBoss->GetPhyPageNum()) < nRefNum ||
    1540                 :          0 :                     ( nTmpRef == nRefNum && lcl_ColumnNum( pBoss ) <= nRefCol ))
    1541                 :          0 :                     pSibling = pFoll;
    1542                 :            :                 else
    1543                 :          0 :                     bEnd = sal_True;
    1544                 :            :             }
    1545                 :            :             else
    1546                 :            :             {
    1547         [ +  - ]:         14 :                 SwFtnBossFrm* pNxtB = pSibling->FindFtnBossFrm();
    1548         [ +  - ]:         14 :                 SwPageFrm *pSibPage = pNxtB->FindPageFrm();
    1549                 :         14 :                 sal_Bool bEndNote = pSibPage->IsEndNotePage();
    1550         [ +  - ]:         14 :                 sal_Bool bChgPage = lcl_NextFtnBoss( pNxtB, pSibPage, bDontLeave );
    1551                 :            :                 // Bei Seitenwechsel muss das EndNoteFlag ueberprueft werden.
    1552                 :            :                 SwFtnContFrm *pCont = pNxtB && ( !bChgPage ||
    1553                 :          0 :                     pSibPage->IsEndNotePage() == bEndNote )
    1554         [ -  + ]:         14 :                     ? pNxtB->FindNearestFtnCont( bDontLeave ) : 0;
           [ #  #  #  # ]
                 [ #  # ]
    1555         [ -  + ]:         14 :                 if ( pCont )
    1556                 :          0 :                     pSibling = (SwFtnFrm*)pCont->Lower();
    1557                 :            :                 else
    1558                 :         14 :                     bEnd = sal_True;
    1559                 :            :             }
    1560 [ -  + ][ #  # ]:         14 :             if ( !bEnd && pSibling )
    1561                 :          0 :                 nCmpPos = ::lcl_FindFtnPos( pDoc, pSibling->GetAttr() );
    1562 [ +  - ][ +  - ]:         14 :             if ( pSibling && pLastSib && (pSibling != pLastSib) )
                 [ -  + ]
    1563                 :            :             {   //Sind wir vielleicht bereits ueber das Ziel hinausgeschossen?
    1564 [ #  # ][ #  # ]:          0 :                 if ( (nLastPos < nCmpPos) && (nCmpPos > nStPos) )
    1565                 :            :                 {
    1566                 :          0 :                     pSibling = pLastSib;
    1567                 :          0 :                     bEnd = sal_True;
    1568                 :            :                 }
    1569                 :            :             }
    1570                 :            :         }
    1571                 :            :     }
    1572         [ +  + ]:         65 :     if ( pSibling )
    1573                 :            :     {
    1574                 :         20 :         nCmpPos = ::lcl_FindFtnPos( pDoc, pSibling->GetAttr() );
    1575         [ +  + ]:         20 :         if ( nCmpPos < nStPos )
    1576                 :            :         {
    1577         [ -  + ]:         14 :             while ( pSibling->GetFollow() )
    1578                 :          0 :                 pSibling = pSibling->GetFollow();
    1579                 :         14 :             pParent = (SwFtnContFrm*)pSibling->GetUpper();
    1580                 :         14 :             pSibling = (SwFtnFrm*)pSibling->GetNext();
    1581                 :            :         }
    1582                 :            :         else
    1583                 :            :         {
    1584         [ -  + ]:          6 :             if( pSibling->GetMaster() )
    1585                 :            :             {
    1586 [ #  # ][ #  # ]:          0 :                 if( ENDNOTE > nCmpPos || nStPos >= ENDNOTE )
    1587                 :            :                 {
    1588                 :            :                     OSL_FAIL( "InsertFtn: Master expected II" );
    1589         [ #  # ]:          0 :                     do
    1590                 :          0 :                         pSibling = pSibling->GetMaster();
    1591                 :          0 :                     while ( pSibling->GetMaster() );
    1592                 :            :                 }
    1593                 :            :             }
    1594                 :          6 :             pParent = (SwFtnContFrm*)pSibling->GetUpper();
    1595                 :            :         }
    1596                 :            :     }
    1597                 :            :     OSL_ENSURE( pParent, "paste in space?" );
    1598                 :         65 :     pNew->Paste( pParent, pSibling );
    1599                 :            : }
    1600                 :            : 
    1601                 :            : /*************************************************************************
    1602                 :            : |*
    1603                 :            : |*  SwFtnBossFrm::AppendFtn()
    1604                 :            : |*
    1605                 :            : |*************************************************************************/
    1606                 :            : 
    1607                 :            : 
    1608                 :         65 : void SwFtnBossFrm::AppendFtn( SwCntntFrm *pRef, SwTxtFtn *pAttr )
    1609                 :            : {
    1610                 :            :     //Wenn es die Fussnote schon gibt tun wir nix.
    1611         [ -  + ]:         65 :     if ( FindFtn( pRef, pAttr ) )
    1612                 :          0 :         return;
    1613                 :            : 
    1614                 :            :     //Wenn Fussnoten am Dokumentende eingestellt sind, so brauchen wir 'eh erst
    1615                 :            :     //ab der entsprechenden Seite zu suchen.
    1616                 :            :     //Wenn es noch keine gibt, muss eben eine erzeugt werden.
    1617                 :            :     //Wenn es sich um eine Endnote handelt, muss eine Endnotenseite gesucht
    1618                 :            :     //bzw. erzeugt werden.
    1619                 :         65 :     SwDoc *pDoc = GetFmt()->GetDoc();
    1620                 :         65 :     SwFtnBossFrm *pBoss = this;
    1621                 :         65 :     SwPageFrm *pPage = FindPageFrm();
    1622                 :         65 :     SwPageFrm *pMyPage = pPage;
    1623                 :         65 :     sal_Bool bChgPage = sal_False;
    1624                 :         65 :     sal_Bool bEnd = sal_False;
    1625         [ +  + ]:         65 :     if ( pAttr->GetFtn().IsEndNote() )
    1626                 :            :     {
    1627                 :          8 :         bEnd = sal_True;
    1628   [ -  +  #  # ]:          8 :         if( GetUpper()->IsSctFrm() &&
                 [ -  + ]
    1629                 :          0 :             ((SwSectionFrm*)GetUpper())->IsEndnAtEnd() )
    1630                 :            :         {
    1631                 :            :             SwFrm* pLast =
    1632                 :          0 :                 ((SwSectionFrm*)GetUpper())->FindLastCntnt( FINDMODE_ENDNOTE );
    1633         [ #  # ]:          0 :             if( pLast )
    1634                 :            :             {
    1635                 :          0 :                 pBoss = pLast->FindFtnBossFrm();
    1636                 :          0 :                 pPage = pBoss->FindPageFrm();
    1637                 :            :             }
    1638                 :            :         }
    1639                 :            :         else
    1640                 :            :         {
    1641 [ -  + ][ #  # ]:          8 :             while ( pPage->GetNext() && !pPage->IsEndNotePage() )
                 [ -  + ]
    1642                 :            :             {
    1643                 :          0 :                 pPage = (SwPageFrm*)pPage->GetNext();
    1644                 :          0 :                 bChgPage = sal_True;
    1645                 :            :             }
    1646         [ +  - ]:          8 :             if ( !pPage->IsEndNotePage() )
    1647                 :            :             {
    1648                 :          8 :                 SwPageDesc *pDesc = pDoc->GetEndNoteInfo().GetPageDesc( *pDoc );
    1649                 :          8 :                 pPage = ::InsertNewPage( *pDesc, pPage->GetUpper(),
    1650                 :         16 :                         !pPage->OnRightPage(), false, sal_False, sal_True, 0 );
    1651                 :          8 :                 pPage->SetEndNotePage( sal_True );
    1652                 :          8 :                 bChgPage = sal_True;
    1653                 :            :             }
    1654                 :            :             else
    1655                 :            :             {
    1656                 :            :                 //Wir koennen wenigstens schon mal ungefaehr die richtige Seite
    1657                 :            :                 //suchen. Damit stellen wir sicher das wir auch bei hunderten
    1658                 :            :                 //Fussnoten noch in endlicher Zeit fertig werden.
    1659                 :          0 :                 SwPageFrm *pNxt = (SwPageFrm*)pPage->GetNext();
    1660                 :          0 :                 const sal_uLong nStPos = ::lcl_FindFtnPos( pDoc, pAttr );
    1661 [ #  # ][ #  # ]:          8 :                 while ( pNxt && pNxt->IsEndNotePage() )
                 [ #  # ]
    1662                 :            :                 {
    1663                 :          0 :                     SwFtnContFrm *pCont = pNxt->FindFtnCont();
    1664 [ #  # ][ #  # ]:          0 :                     if ( pCont && pCont->Lower() )
                 [ #  # ]
    1665                 :            :                     {
    1666                 :            :                         OSL_ENSURE( pCont->Lower()->IsFtnFrm(), "Keine Ftn im Container" );
    1667         [ #  # ]:          0 :                         if ( nStPos > ::lcl_FindFtnPos( pDoc,
    1668                 :          0 :                                         ((SwFtnFrm*)pCont->Lower())->GetAttr()))
    1669                 :            :                         {
    1670                 :          0 :                             pPage = pNxt;
    1671                 :          0 :                             pNxt = (SwPageFrm*)pPage->GetNext();
    1672                 :          0 :                             continue;
    1673                 :            :                         }
    1674                 :            :                     }
    1675                 :          0 :                     break;
    1676                 :            :                 }
    1677                 :            :             }
    1678                 :            :         }
    1679                 :            :     }
    1680         [ +  + ]:         59 :     else if( FTNPOS_CHAPTER == pDoc->GetFtnInfo().ePos && ( !GetUpper()->
           [ -  +  #  # ]
                 [ +  + ]
    1681                 :          2 :              IsSctFrm() || !((SwSectionFrm*)GetUpper())->IsFtnAtEnd() ) )
    1682                 :            :     {
    1683         [ -  + ]:          2 :         while ( pPage->GetNext() && !pPage->IsFtnPage() &&
           [ #  #  #  # ]
                 [ -  + ]
    1684                 :          0 :                 !((SwPageFrm*)pPage->GetNext())->IsEndNotePage() )
    1685                 :            :         {
    1686                 :          0 :             pPage = (SwPageFrm*)pPage->GetNext();
    1687                 :          0 :             bChgPage = sal_True;
    1688                 :            :         }
    1689                 :            : 
    1690         [ +  - ]:          2 :         if ( !pPage->IsFtnPage() )
    1691                 :            :         {
    1692                 :          2 :             SwPageDesc *pDesc = pDoc->GetFtnInfo().GetPageDesc( *pDoc );
    1693                 :          2 :             pPage = ::InsertNewPage( *pDesc, pPage->GetUpper(),
    1694                 :          4 :                 !pPage->OnRightPage(), false, sal_False, sal_True, pPage->GetNext() );
    1695                 :          2 :             bChgPage = sal_True;
    1696                 :            :         }
    1697                 :            :         else
    1698                 :            :         {
    1699                 :            :             //Wir koennen wenigstens schon mal ungefaehr die richtige Seite
    1700                 :            :             //suchen. Damit stellen wir sicher das wir auch bei hunderten
    1701                 :            :             //Fussnoten noch in endlicher Zeit fertig werden.
    1702                 :          0 :             SwPageFrm *pNxt = (SwPageFrm*)pPage->GetNext();
    1703                 :          0 :             const sal_uLong nStPos = ::lcl_FindFtnPos( pDoc, pAttr );
    1704 [ #  # ][ #  # ]:          2 :             while ( pNxt && pNxt->IsFtnPage() && !pNxt->IsEndNotePage() )
         [ #  # ][ #  # ]
    1705                 :            :             {
    1706                 :          0 :                 SwFtnContFrm *pCont = pNxt->FindFtnCont();
    1707 [ #  # ][ #  # ]:          0 :                 if ( pCont && pCont->Lower() )
                 [ #  # ]
    1708                 :            :                 {
    1709                 :            :                     OSL_ENSURE( pCont->Lower()->IsFtnFrm(), "Keine Ftn im Container" );
    1710         [ #  # ]:          0 :                     if ( nStPos > ::lcl_FindFtnPos( pDoc,
    1711                 :          0 :                                         ((SwFtnFrm*)pCont->Lower())->GetAttr()))
    1712                 :            :                     {
    1713                 :          0 :                         pPage = pNxt;
    1714                 :          0 :                         pNxt = (SwPageFrm*)pPage->GetNext();
    1715                 :          0 :                         continue;
    1716                 :            :                     }
    1717                 :            :                 }
    1718                 :          0 :                 break;
    1719                 :            :             }
    1720                 :            :         }
    1721                 :            :     }
    1722                 :            : 
    1723                 :            :     //Erstmal eine Fussnote und die benoetigten CntntFrms anlegen.
    1724         [ -  + ]:         65 :     if ( !pAttr->GetStartNode() )
    1725                 :            :     { OSL_ENSURE( !this, "Kein Fussnoteninhalt." );
    1726                 :          0 :         return;
    1727                 :            :     }
    1728                 :            : 
    1729                 :            :     // Wenn es auf der Seite/Spalte bereits einen FtnCont gibt,
    1730                 :            :     // kann in einen spaltigen Bereich keiner erzeugt werden.
    1731 [ -  + ][ #  # ]:         65 :     if( pBoss->IsInSct() && pBoss->IsColumnFrm() && !pPage->IsFtnPage() )
         [ #  # ][ -  + ]
    1732                 :            :     {
    1733                 :          0 :         SwSectionFrm* pSct = pBoss->FindSctFrm();
    1734 [ #  # ][ #  # ]:          0 :         if( bEnd ? !pSct->IsEndnAtEnd() : !pSct->IsFtnAtEnd() )
    1735                 :            :         {
    1736                 :          0 :             SwFtnContFrm* pFtnCont = pSct->FindFtnBossFrm(!bEnd)->FindFtnCont();
    1737         [ #  # ]:          0 :             if( pFtnCont )
    1738                 :            :             {
    1739                 :          0 :                 SwFtnFrm* pTmp = (SwFtnFrm*)pFtnCont->Lower();
    1740         [ #  # ]:          0 :                 if( bEnd )
    1741 [ #  # ][ #  # ]:          0 :                     while( pTmp && !pTmp->GetAttr()->GetFtn().IsEndNote() )
                 [ #  # ]
    1742                 :          0 :                         pTmp = (SwFtnFrm*)pTmp->GetNext();
    1743 [ #  # ][ #  # ]:          0 :                 if( pTmp && *pTmp < pAttr )
                 [ #  # ]
    1744                 :          0 :                     return;
    1745                 :            :             }
    1746                 :            :         }
    1747                 :            :     }
    1748                 :            : 
    1749         [ +  - ]:         65 :     SwFtnFrm *pNew = new SwFtnFrm( pDoc->GetDfltFrmFmt(), this, pRef, pAttr );
    1750                 :            :     {
    1751         [ +  - ]:         65 :         SwNodeIndex aIdx( *pAttr->GetStartNode(), 1 );
    1752 [ +  - ][ +  - ]:         65 :         ::_InsertCnt( pNew, pDoc, aIdx.GetIndex() );
    1753                 :            :     }
    1754                 :            :     // Wenn die Seite gewechselt (oder gar neu angelegt) wurde,
    1755                 :            :     // muessen wir uns dort in die erste Spalte setzen
    1756         [ +  + ]:         65 :     if( bChgPage )
    1757                 :            :     {
    1758                 :         10 :         SwLayoutFrm* pBody = pPage->FindBodyCont();
    1759                 :            :         OSL_ENSURE( pBody, "AppendFtn: NoPageBody?" );
    1760 [ #  # ][ -  + ]:         10 :         if( pBody->Lower() && pBody->Lower()->IsColumnFrm() )
                 [ -  + ]
    1761                 :          0 :             pBoss = (SwFtnBossFrm*)pBody->Lower();
    1762                 :            :         else
    1763                 :         10 :             pBoss = pPage; // bei nichtspaltigen Seiten auf die Seite selbst
    1764                 :            :     }
    1765                 :         65 :     pBoss->InsertFtn( pNew );
    1766         [ +  - ]:         65 :     if ( pNew->GetUpper() )         //Eingesetzt oder nicht?
    1767                 :            :     {
    1768                 :         65 :         ::RegistFlys( pNew->FindPageFrm(), pNew );
    1769                 :         65 :         SwSectionFrm* pSect = FindSctFrm();
    1770                 :            :         // Der Inhalt des FtnContainers in einem (spaltigen) Bereich
    1771                 :            :         // braucht nur kalkuliert zu werden,
    1772                 :            :         // wenn der Bereich bereits bis zur Unterkante seines Uppers geht.
    1773 [ #  # ][ #  # ]:         65 :         if( pSect && !pSect->IsJoinLocked() && ( bEnd ? !pSect->IsEndnAtEnd() :
           [ #  #  #  #  
           #  # ][ -  + ]
                 [ -  + ]
    1774                 :          0 :             !pSect->IsFtnAtEnd() ) && pSect->Growable() )
    1775                 :          0 :             pSect->InvalidateSize();
    1776                 :            :         else
    1777                 :            :         {
    1778                 :            :             // #i49383# - disable unlock of position of
    1779                 :            :             // lower objects during format of footnote content.
    1780                 :         65 :             const bool bOldFtnFrmLocked( pNew->IsColLocked() );
    1781                 :         65 :             pNew->ColLock();
    1782                 :         65 :             pNew->KeepLockPosOfLowerObjs();
    1783                 :            :             // #i57914# - adjust fix #i49383#
    1784                 :            :             // no extra notify for footnote frame
    1785                 :            : //            SwLayNotify* pFtnFrmNotitfy = new SwLayNotify( pNew );
    1786                 :         65 :             SwCntntFrm *pCnt = pNew->ContainsCntnt();
    1787 [ +  + ][ +  + ]:        130 :             while ( pCnt && pCnt->FindFtnFrm()->GetAttr() == pAttr )
                 [ +  + ]
    1788                 :            :             {
    1789                 :         65 :                 pCnt->Calc();
    1790                 :            :                 // #i49383# - format anchored objects
    1791 [ +  - ][ +  - ]:         65 :                 if ( pCnt->IsTxtFrm() && pCnt->IsValid() )
                 [ +  - ]
    1792                 :            :                 {
    1793         [ -  + ]:         65 :                     if ( !SwObjectFormatter::FormatObjsAtFrm( *pCnt,
    1794                 :         65 :                                                               *(pCnt->FindPageFrm()) ) )
    1795                 :            :                     {
    1796                 :            :                         // restart format with first content
    1797                 :          0 :                         pCnt = pNew->ContainsCntnt();
    1798                 :          0 :                         continue;
    1799                 :            :                     }
    1800                 :            :                 }
    1801                 :         65 :                 pCnt = (SwCntntFrm*)pCnt->FindNextCnt();
    1802                 :            :             }
    1803                 :            :             // #i49383#
    1804         [ +  - ]:         65 :             if ( !bOldFtnFrmLocked )
    1805                 :            :             {
    1806                 :         65 :                 pNew->ColUnlock();
    1807                 :            :             }
    1808                 :            :             // #i57914# - adjust fix #i49383#
    1809                 :            :             // enable lock of lower object position before format of footnote frame.
    1810                 :         65 :             pNew->UnlockPosOfLowerObjs();
    1811                 :         65 :             pNew->Calc();
    1812                 :            :             // #i57914# - adjust fix #i49383#
    1813                 :            :             // no extra notify for footnote frame
    1814                 :            : //            pNew->UnlockPosOfLowerObjs();
    1815                 :            : //            delete pFtnFrmNotitfy;
    1816   [ -  +  #  #  :         65 :             if ( !bOldFtnFrmLocked && !pNew->GetLower() &&
           #  # ][ -  + ]
                 [ +  - ]
    1817                 :          0 :                  !pNew->IsColLocked() && !pNew->IsBackMoveLocked() )
    1818                 :            :             {
    1819                 :          0 :                 pNew->Cut();
    1820         [ #  # ]:          0 :                 delete pNew;
    1821                 :            :             }
    1822                 :            :         }
    1823                 :         65 :         pMyPage->UpdateFtnNum();
    1824                 :            :     }
    1825                 :            :     else
    1826         [ #  # ]:         65 :         delete pNew;
    1827                 :            : }
    1828                 :            : /*************************************************************************
    1829                 :            : |*
    1830                 :            : |*  SwFtnBossFrm::FindFtn()
    1831                 :            : |*
    1832                 :            : |*************************************************************************/
    1833                 :            : 
    1834                 :            : 
    1835                 :        569 : SwFtnFrm *SwFtnBossFrm::FindFtn( const SwCntntFrm *pRef, const SwTxtFtn *pAttr )
    1836                 :            : {
    1837                 :            :     //Der einfachste und sicherste Weg geht ueber das Attribut.
    1838                 :            :     OSL_ENSURE( pAttr->GetStartNode(), "FtnAtr ohne StartNode." );
    1839         [ +  - ]:        569 :     SwNodeIndex aIdx( *pAttr->GetStartNode(), 1 );
    1840                 :        569 :     SwCntntNode *pNd = aIdx.GetNode().GetCntntNode();
    1841         [ +  + ]:        569 :     if ( !pNd )
    1842                 :            :         pNd = pRef->GetAttrSet()->GetDoc()->
    1843 [ +  - ][ +  - ]:          8 :               GetNodes().GoNextSection( &aIdx, sal_True, sal_False );
                 [ +  - ]
    1844         [ -  + ]:        569 :     if ( !pNd )
    1845                 :          0 :         return 0;
    1846         [ +  - ]:        569 :     SwIterator<SwFrm,SwCntntNode> aIter( *pNd );
    1847         [ +  - ]:        569 :     SwFrm* pFrm = aIter.First();
    1848         [ +  + ]:        569 :     if( pFrm )
    1849 [ #  # ][ #  # ]:          0 :         do
    1850                 :            :         {
    1851                 :        439 :                 pFrm = pFrm->GetUpper();
    1852                 :            :                 // #i28500#, #i27243# Due to the endnode collector, there are
    1853                 :            :                 // SwFtnFrms, which are not in the layout. Therefore the
    1854                 :            :                 // bInfFtn flags are not set correctly, and a cell of FindFtnFrm
    1855                 :            :                 // would return 0. Therefore we better call ImplFindFtnFrm().
    1856         [ +  - ]:        439 :                 SwFtnFrm *pFtn = pFrm->ImplFindFtnFrm();
    1857 [ +  - ][ +  - ]:        439 :                 if ( pFtn && pFtn->GetRef() == pRef )
                 [ +  - ]
    1858                 :            :                 {
    1859                 :            :                     // The following condition becomes true, if the whole
    1860                 :            :                     // footnotecontent is a section. While no frames exist,
    1861                 :            :                     // the HiddenFlag of the section is set, this causes
    1862                 :            :                     // the GoNextSection-function leaves the footnote.
    1863         [ -  + ]:        439 :                     if( pFtn->GetAttr() != pAttr )
    1864                 :          0 :                         return 0;
    1865 [ +  - ][ -  + ]:        439 :                     while ( pFtn && pFtn->GetMaster() )
                 [ -  + ]
    1866                 :          0 :                         pFtn = pFtn->GetMaster();
    1867                 :        439 :                     return pFtn;
    1868                 :            :                 }
    1869                 :            : 
    1870                 :            :         } while ( 0 != (pFrm = aIter.Next()) );
    1871                 :            : 
    1872 [ +  - ][ +  - ]:        569 :     return 0;
    1873                 :            : }
    1874                 :            : /*************************************************************************
    1875                 :            : |*
    1876                 :            : |*  SwFtnBossFrm::RemoveFtn()
    1877                 :            : |*
    1878                 :            : |*************************************************************************/
    1879                 :            : 
    1880                 :            : 
    1881                 :         26 : void SwFtnBossFrm::RemoveFtn( const SwCntntFrm *pRef, const SwTxtFtn *pAttr,
    1882                 :            :                               sal_Bool bPrep )
    1883                 :            : {
    1884                 :         26 :     SwFtnFrm *pFtn = FindFtn( pRef, pAttr );
    1885         [ +  - ]:         26 :     if( pFtn )
    1886                 :            :     {
    1887         [ -  + ]:         26 :         do
    1888                 :            :         {
    1889                 :         26 :             SwFtnFrm *pFoll = pFtn->GetFollow();
    1890                 :         26 :             pFtn->Cut();
    1891         [ +  - ]:         26 :             delete pFtn;
    1892                 :         26 :             pFtn = pFoll;
    1893                 :            :         } while ( pFtn );
    1894 [ +  - ][ -  + ]:         26 :         if( bPrep && pRef->IsFollow() )
                 [ -  + ]
    1895                 :            :         {
    1896                 :            :             OSL_ENSURE( pRef->IsTxtFrm(), "NoTxtFrm has Footnote?" );
    1897                 :          0 :             SwTxtFrm* pMaster = (SwTxtFrm*)pRef->FindMaster();
    1898         [ #  # ]:          0 :             if( !pMaster->IsLocked() )
    1899                 :          0 :                 pMaster->Prepare( PREP_FTN_GONE );
    1900                 :            :         }
    1901                 :            :     }
    1902                 :         26 :     FindPageFrm()->UpdateFtnNum();
    1903                 :         26 : }
    1904                 :            : 
    1905                 :            : /*************************************************************************
    1906                 :            : |*
    1907                 :            : |*  SwFtnBossFrm::ChangeFtnRef()
    1908                 :            : |*
    1909                 :            : |*************************************************************************/
    1910                 :            : 
    1911                 :            : 
    1912                 :          0 : void SwFtnBossFrm::ChangeFtnRef( const SwCntntFrm *pOld, const SwTxtFtn *pAttr,
    1913                 :            :                                  SwCntntFrm *pNew )
    1914                 :            : {
    1915                 :          0 :     SwFtnFrm *pFtn = FindFtn( pOld, pAttr );
    1916         [ #  # ]:          0 :     while ( pFtn )
    1917                 :            :     {
    1918                 :          0 :         pFtn->SetRef( pNew );
    1919                 :          0 :         pFtn = pFtn->GetFollow();
    1920                 :            :     }
    1921                 :          0 : }
    1922                 :            : 
    1923                 :            : /*************************************************************************
    1924                 :            : |*
    1925                 :            : |*  SwFtnBossFrm::CollectFtns()
    1926                 :            : |*
    1927                 :            : |*************************************************************************/
    1928                 :            : 
    1929                 :            : 
    1930                 :            : /// OD 03.04.2003 #108446# - add parameter <_bCollectOnlyPreviousFtns> in
    1931                 :            : /// order to control, if only footnotes, which are positioned before the
    1932                 :            : /// footnote boss frame <this> have to be collected.
    1933                 :          0 : void SwFtnBossFrm::CollectFtns( const SwCntntFrm* _pRef,
    1934                 :            :                                 SwFtnBossFrm*     _pOld,
    1935                 :            :                                 SwFtnFrms&        _rFtnArr,
    1936                 :            :                                 const sal_Bool    _bCollectOnlyPreviousFtns )
    1937                 :            : {
    1938                 :          0 :     SwFtnFrm *pFtn = _pOld->FindFirstFtn();
    1939         [ #  # ]:          0 :     while( !pFtn )
    1940                 :            :     {
    1941         [ #  # ]:          0 :         if( _pOld->IsColumnFrm() )
    1942                 :            :         {   // Spalten abklappern
    1943 [ #  # ][ #  # ]:          0 :             while ( !pFtn && _pOld->GetPrev() )
                 [ #  # ]
    1944                 :            :             {
    1945                 :            :                 //Wenn wir keine Fussnote gefunden haben, ist noch nicht alles zu
    1946                 :            :                 //spaet. Die Schleife wird beim Aufnehmen von Follow-Zeilen durch
    1947                 :            :                 //Tabellen benoetigt. Fuer alle anderen Faelle ist sie in der Lage
    1948                 :            :                 //'krumme' Verhaeltnisse zu korrigieren.
    1949                 :          0 :                 _pOld = (SwFtnBossFrm*)_pOld->GetPrev();
    1950                 :          0 :                 pFtn = _pOld->FindFirstFtn();
    1951                 :            :             }
    1952                 :            :         }
    1953         [ #  # ]:          0 :         if( !pFtn )
    1954                 :            :         {
    1955                 :            :             //  vorherige Seite
    1956                 :            :             SwPageFrm* pPg;
    1957   [ #  #  #  # ]:          0 :             for ( SwFrm* pTmp = _pOld;
                 [ #  # ]
    1958                 :          0 :                   0 != ( pPg = (SwPageFrm*)pTmp->FindPageFrm()->GetPrev())
    1959                 :          0 :                     && pPg->IsEmptyPage() ;
    1960                 :            :                 )
    1961                 :            :             {
    1962                 :          0 :                 pTmp = pPg;
    1963                 :            :             }
    1964         [ #  # ]:          0 :             if( !pPg )
    1965                 :          0 :                 return;
    1966                 :            : 
    1967                 :          0 :             SwLayoutFrm* pBody = pPg->FindBodyCont();
    1968 [ #  # ][ #  # ]:          0 :             if( pBody->Lower() && pBody->Lower()->IsColumnFrm() )
                 [ #  # ]
    1969                 :            :             {
    1970                 :            :                 // mehrspaltige Seite => letzte Spalte suchen
    1971                 :          0 :                 _pOld = static_cast<SwFtnBossFrm*>(pBody->GetLastLower());
    1972                 :            :             }
    1973                 :            :             else
    1974                 :          0 :                 _pOld = pPg; // einspaltige Seite
    1975                 :          0 :             pFtn = _pOld->FindFirstFtn();
    1976                 :            :         }
    1977                 :            :     }
    1978                 :            :     // OD 03.04.2003 #108446# - consider new parameter <_bCollectOnlyPreviousFtns>
    1979                 :          0 :     SwFtnBossFrm* pRefBossFrm = NULL;
    1980         [ #  # ]:          0 :     if ( _bCollectOnlyPreviousFtns )
    1981                 :            :     {
    1982                 :          0 :         pRefBossFrm = this;
    1983                 :            :     }
    1984                 :          0 :     _CollectFtns( _pRef, pFtn, _rFtnArr, _bCollectOnlyPreviousFtns, pRefBossFrm );
    1985                 :            : }
    1986                 :            : 
    1987                 :            : 
    1988                 :            : /*************************************************************************
    1989                 :            : |*
    1990                 :            : |*  SwFtnBossFrm::_CollectFtns()
    1991                 :            : |*
    1992                 :            : |*************************************************************************/
    1993                 :          0 : inline void FtnInArr( SwFtnFrms& rFtnArr, SwFtnFrm* pFtn )
    1994                 :            : {
    1995 [ #  # ][ #  # ]:          0 :     if ( rFtnArr.end() == std::find( rFtnArr.begin(), rFtnArr.end(), pFtn ) )
    1996                 :          0 :         rFtnArr.push_back( pFtn );
    1997                 :          0 : }
    1998                 :            : 
    1999                 :            : /// OD 03.04.2003 #108446# - add parameters <_bCollectOnlyPreviousFtns> and
    2000                 :            : /// <_pRefFtnBossFrm> in order to control, if only footnotes, which are positioned
    2001                 :            : /// before the given reference footnote boss frame have to be collected.
    2002                 :            : /// Note: if parameter <_bCollectOnlyPreviousFtns> is true, then parameter
    2003                 :            : /// <_pRefFtnBossFrm> have to be referenced to an object.
    2004                 :            : /// Adjust parameter names.
    2005                 :          0 : void SwFtnBossFrm::_CollectFtns( const SwCntntFrm*   _pRef,
    2006                 :            :                                  SwFtnFrm*           _pFtn,
    2007                 :            :                                  SwFtnFrms&          _rFtnArr,
    2008                 :            :                                  sal_Bool            _bCollectOnlyPreviousFtns,
    2009                 :            :                                  const SwFtnBossFrm* _pRefFtnBossFrm)
    2010                 :            : {
    2011                 :            :     // OD 03.04.2003 #108446# - assert, that no reference footnote boss frame
    2012                 :            :     // is set, in spite of the order, that only previous footnotes has to be
    2013                 :            :     // collected.
    2014                 :            :     OSL_ENSURE( !_bCollectOnlyPreviousFtns || _pRefFtnBossFrm,
    2015                 :            :             "<SwFtnBossFrm::_CollectFtns(..)> - No reference footnote boss frame for collecting only previous footnotes set.\nCrash will be caused!" );
    2016                 :            : 
    2017                 :            :     //Alle Fussnoten die von pRef referenziert werden nacheinander
    2018                 :            :     //einsammeln (Attribut fuer Attribut), zusammengefuegen
    2019                 :            :     //(der Inhalt zu einem Attribut kann ueber mehrere Seiten verteilt sein)
    2020                 :            :     //und ausschneiden.
    2021                 :            : 
    2022         [ #  # ]:          0 :     SwFtnFrms aNotFtnArr;           //Zur Robustheit werden hier die nicht
    2023                 :            :                                     //dazugehoerigen Fussnoten eingetragen.
    2024                 :            :                                     //Wenn eine Fussnote zweimal angefasst wird
    2025                 :            :                                     //ists vorbei! So kommt die Funktion auch
    2026                 :            :                                     //noch mit einem kaputten Layout
    2027                 :            :                                     //einigermassen (ohne Schleife und Absturz)
    2028                 :            :                                     //"klar".
    2029                 :            : 
    2030                 :            :     //Hier sollte keiner mit einer Follow-Ftn ankommen, es sei denn er hat
    2031                 :            :     //ernste Absichten (:-)); spricht er kommt mit einer Ftn an die vor der
    2032                 :            :     //ersten der Referenz liegt.
    2033                 :            :     OSL_ENSURE( !_pFtn->GetMaster() || _pFtn->GetRef() != _pRef, "FollowFtn moven?" );
    2034         [ #  # ]:          0 :     while ( _pFtn->GetMaster() )
    2035                 :          0 :         _pFtn = _pFtn->GetMaster();
    2036                 :            : 
    2037                 :          0 :     sal_Bool bFound = sal_False;
    2038                 :            : 
    2039         [ #  # ]:          0 :     while ( _pFtn )
    2040                 :            :     {
    2041                 :            :         //Erstmal die naechste Fussnote der Spalte/Seite suchen, damit wir nicht
    2042                 :            :         //nach dem Cut jeder Fussnote von vorn anfangen muessen.
    2043                 :          0 :         SwFtnFrm *pNxtFtn = _pFtn;
    2044         [ #  # ]:          0 :         while ( pNxtFtn->GetFollow() )
    2045                 :          0 :             pNxtFtn = pNxtFtn->GetFollow();
    2046                 :          0 :         pNxtFtn = (SwFtnFrm*)pNxtFtn->GetNext();
    2047                 :            : 
    2048         [ #  # ]:          0 :         if ( !pNxtFtn )
    2049                 :            :         {
    2050         [ #  # ]:          0 :             SwFtnBossFrm* pBoss = _pFtn->FindFtnBossFrm();
    2051         [ #  # ]:          0 :             SwPageFrm* pPage = pBoss->FindPageFrm();
    2052 [ #  # ][ #  # ]:          0 :             do
                 [ #  # ]
    2053                 :            :             {
    2054         [ #  # ]:          0 :                 lcl_NextFtnBoss( pBoss, pPage, sal_False );
    2055         [ #  # ]:          0 :                 if( pBoss )
    2056                 :            :                 {
    2057                 :          0 :                     SwLayoutFrm* pCont = pBoss->FindFtnCont();
    2058         [ #  # ]:          0 :                     if( pCont )
    2059                 :            :                     {
    2060                 :          0 :                         pNxtFtn = (SwFtnFrm*)pCont->Lower();
    2061         [ #  # ]:          0 :                         if( pNxtFtn )
    2062                 :            :                         {
    2063         [ #  # ]:          0 :                             while( pNxtFtn->GetMaster() )
    2064                 :          0 :                                 pNxtFtn = pNxtFtn->GetMaster();
    2065         [ #  # ]:          0 :                             if( pNxtFtn == _pFtn )
    2066                 :          0 :                                 pNxtFtn = NULL;
    2067                 :            :                         }
    2068                 :            :                     }
    2069                 :            :                 }
    2070                 :          0 :             } while( !pNxtFtn && pBoss );
    2071                 :            :         }
    2072         [ #  # ]:          0 :         else if( !pNxtFtn->GetAttr()->GetFtn().IsEndNote() )
    2073                 :            :         { OSL_ENSURE( !pNxtFtn->GetMaster(), "_CollectFtn: Master exspected" );
    2074         [ #  # ]:          0 :             while ( pNxtFtn->GetMaster() )
    2075                 :          0 :                 pNxtFtn = pNxtFtn->GetMaster();
    2076                 :            :         }
    2077         [ #  # ]:          0 :         if ( pNxtFtn == _pFtn )
    2078                 :            :         {
    2079                 :            :             OSL_FAIL(   "_CollectFtn: Devil's circle" );
    2080                 :          0 :             pNxtFtn = 0;
    2081                 :            :         }
    2082                 :            : 
    2083                 :            :         // OD 03.04.2003 #108446# - determine, if found footnote has to be collected.
    2084                 :          0 :         sal_Bool bCollectFoundFtn = sal_False;
    2085 [ #  # ][ #  # ]:          0 :         if ( _pFtn->GetRef() == _pRef && !_pFtn->GetAttr()->GetFtn().IsEndNote() )
                 [ #  # ]
    2086                 :            :         {
    2087         [ #  # ]:          0 :             if ( _bCollectOnlyPreviousFtns )
    2088                 :            :             {
    2089         [ #  # ]:          0 :                 SwFtnBossFrm* pBossOfFoundFtn = _pFtn->FindFtnBossFrm( sal_True );
    2090                 :            :                 OSL_ENSURE( pBossOfFoundFtn,
    2091                 :            :                         "<SwFtnBossFrm::_CollectFtns(..)> - footnote boss frame of found footnote frame missing.\nWrong layout!" );
    2092 [ #  # ][ #  # ]:          0 :                 if ( !pBossOfFoundFtn ||    // don't crash, if no footnote boss is found.
                 [ #  # ]
    2093         [ #  # ]:          0 :                      pBossOfFoundFtn->IsBefore( _pRefFtnBossFrm )
    2094                 :            :                    )
    2095                 :            :                 {
    2096                 :          0 :                     bCollectFoundFtn = sal_True;
    2097                 :            :                 }
    2098                 :            :             }
    2099                 :            :             else
    2100                 :            :             {
    2101                 :          0 :                 bCollectFoundFtn = sal_True;
    2102                 :            :             }
    2103                 :            :         }
    2104                 :            : 
    2105         [ #  # ]:          0 :         if ( bCollectFoundFtn )
    2106                 :            :         {
    2107                 :            :             OSL_ENSURE( !_pFtn->GetMaster(), "FollowFtn moven?" );
    2108                 :          0 :             SwFtnFrm *pNxt = _pFtn->GetFollow();
    2109         [ #  # ]:          0 :             while ( pNxt )
    2110                 :            :             {
    2111         [ #  # ]:          0 :                 SwFrm *pCnt = pNxt->ContainsAny();
    2112         [ #  # ]:          0 :                 if ( pCnt )
    2113                 :            :                 {   //Unterwegs wird der Follow zerstoert weil er leer wird!
    2114         [ #  # ]:          0 :                     do
    2115                 :          0 :                     {   SwFrm *pNxtCnt = pCnt->GetNext();
    2116         [ #  # ]:          0 :                         pCnt->Cut();
    2117         [ #  # ]:          0 :                         pCnt->Paste( _pFtn );
    2118                 :          0 :                         pCnt = pNxtCnt;
    2119                 :            :                     } while ( pCnt );
    2120                 :            :                 }
    2121                 :            :                 else
    2122                 :            :                 { OSL_ENSURE( !pNxt, "Fussnote ohne Inhalt?" );
    2123         [ #  # ]:          0 :                     pNxt->Cut();
    2124 [ #  # ][ #  # ]:          0 :                     delete pNxt;
    2125                 :            :                 }
    2126                 :          0 :                 pNxt = _pFtn->GetFollow();
    2127                 :            :             }
    2128         [ #  # ]:          0 :             _pFtn->Cut();
    2129         [ #  # ]:          0 :             FtnInArr( _rFtnArr, _pFtn );
    2130                 :          0 :             bFound = sal_True;
    2131                 :            :         }
    2132                 :            :         else
    2133                 :            :         {
    2134         [ #  # ]:          0 :             FtnInArr( aNotFtnArr, _pFtn );
    2135         [ #  # ]:          0 :             if( bFound )
    2136                 :            :                 break;
    2137                 :            :         }
    2138 [ #  # ][ #  # ]:          0 :         if ( pNxtFtn &&
         [ #  # ][ #  # ]
    2139 [ #  # ][ #  # ]:          0 :              _rFtnArr.end() == std::find( _rFtnArr.begin(), _rFtnArr.end(), pNxtFtn ) &&
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    2140 [ #  # ][ #  # ]:          0 :              aNotFtnArr.end() == std::find( aNotFtnArr.begin(), aNotFtnArr.end(), pNxtFtn ) )
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    2141                 :          0 :             _pFtn = pNxtFtn;
    2142                 :            :         else
    2143                 :            :             break;
    2144                 :          0 :     }
    2145                 :          0 : }
    2146                 :            : 
    2147                 :            : /*************************************************************************
    2148                 :            : |*
    2149                 :            : |*  SwFtnBossFrm::_MoveFtns()
    2150                 :            : |*
    2151                 :            : |*************************************************************************/
    2152                 :            : 
    2153                 :            : 
    2154                 :          0 : void SwFtnBossFrm::_MoveFtns( SwFtnFrms &rFtnArr, sal_Bool bCalc )
    2155                 :            : {
    2156                 :            :     //Alle Fussnoten die von pRef referenziert werden muessen von der
    2157                 :            :     //aktuellen Position, die sich durch die alte Spalte/Seite ergab, auf eine
    2158                 :            :     //neue Position, bestimmt durch die neue Spalte/Seite, gemoved werden.
    2159                 :          0 :     const sal_uInt16 nMyNum = FindPageFrm()->GetPhyPageNum();
    2160                 :          0 :     const sal_uInt16 nMyCol = lcl_ColumnNum( this );
    2161 [ #  # ][ #  # ]:          0 :     SWRECTFN( this )
         [ #  # ][ #  # ]
    2162                 :            : 
    2163                 :            :     // #i21478# - keep last inserted footnote in order to
    2164                 :            :     // format the content of the following one.
    2165                 :          0 :     SwFtnFrm* pLastInsertedFtn = 0L;
    2166         [ #  # ]:          0 :     for ( sal_uInt16 i = 0; i < rFtnArr.size(); ++i )
    2167                 :            :     {
    2168                 :          0 :         SwFtnFrm *pFtn = rFtnArr[i];
    2169                 :            : 
    2170                 :          0 :         SwFtnBossFrm* pRefBoss = pFtn->GetRef()->FindFtnBossFrm( sal_True );
    2171         [ #  # ]:          0 :         if( pRefBoss != this )
    2172                 :            :         {
    2173                 :          0 :             const sal_uInt16 nRefNum = pRefBoss->FindPageFrm()->GetPhyPageNum();
    2174                 :          0 :             const sal_uInt16 nRefCol = lcl_ColumnNum( this );
    2175 [ #  # ][ #  # ]:          0 :             if( nRefNum < nMyNum || ( nRefNum == nMyNum && nRefCol <= nMyCol ) )
                 [ #  # ]
    2176                 :          0 :                 pRefBoss = this;
    2177                 :            :         }
    2178                 :          0 :         pRefBoss->InsertFtn( pFtn );
    2179                 :            : 
    2180         [ #  # ]:          0 :         if ( pFtn->GetUpper() ) //Robust, z.B. bei doppelten
    2181                 :            :         {
    2182                 :            :             // Damit FtnFrms, die nicht auf die Seite passen, nicht fuer zuviel
    2183                 :            :             // Unruhe sorgen (Loop 66312), wird ihr Inhalt zunaechst zusammengestaucht.
    2184                 :            :             // Damit wird der FtnCont erst gegrowt, wenn der Inhalt formatiert wird
    2185                 :            :             // und feststellt, dass er auf die Seite passt.
    2186                 :          0 :             SwFrm *pCnt = pFtn->ContainsAny();
    2187         [ #  # ]:          0 :             while( pCnt )
    2188                 :            :             {
    2189         [ #  # ]:          0 :                 if( pCnt->IsLayoutFrm() )
    2190                 :            :                 {
    2191                 :          0 :                     SwFrm* pTmp = ((SwLayoutFrm*)pCnt)->ContainsAny();
    2192 [ #  # ][ #  # ]:          0 :                     while( pTmp && ((SwLayoutFrm*)pCnt)->IsAnLower( pTmp ) )
                 [ #  # ]
    2193                 :            :                     {
    2194                 :          0 :                         pTmp->Prepare( PREP_MOVEFTN );
    2195         [ #  # ]:          0 :                         (pTmp->Frm().*fnRect->fnSetHeight)(0);
    2196         [ #  # ]:          0 :                         (pTmp->Prt().*fnRect->fnSetHeight)(0);
    2197                 :          0 :                         pTmp = pTmp->FindNext();
    2198                 :            :                     }
    2199                 :            :                 }
    2200                 :            :                 else
    2201                 :          0 :                     pCnt->Prepare( PREP_MOVEFTN );
    2202         [ #  # ]:          0 :                 (pCnt->Frm().*fnRect->fnSetHeight)(0);
    2203         [ #  # ]:          0 :                 (pCnt->Prt().*fnRect->fnSetHeight)(0);
    2204                 :          0 :                 pCnt = pCnt->GetNext();
    2205                 :            :             }
    2206         [ #  # ]:          0 :             (pFtn->Frm().*fnRect->fnSetHeight)(0);
    2207         [ #  # ]:          0 :             (pFtn->Prt().*fnRect->fnSetHeight)(0);
    2208                 :          0 :             pFtn->Calc();
    2209                 :          0 :             pFtn->GetUpper()->Calc();
    2210                 :            : 
    2211         [ #  # ]:          0 :             if( bCalc )
    2212                 :            :             {
    2213                 :          0 :                 SwTxtFtn *pAttr = pFtn->GetAttr();
    2214                 :          0 :                 pCnt = pFtn->ContainsAny();
    2215                 :          0 :                 sal_Bool bUnlock = !pFtn->IsBackMoveLocked();
    2216                 :          0 :                 pFtn->LockBackMove();
    2217                 :            : 
    2218                 :            :                 // #i49383# - disable unlock of position of
    2219                 :            :                 // lower objects during format of footnote content.
    2220                 :          0 :                 pFtn->KeepLockPosOfLowerObjs();
    2221                 :            :                 // #i57914# - adjust fix #i49383#
    2222                 :            :                 // no extra notify for footnote frame
    2223                 :            : //                SwLayNotify aFtnFrmNotitfy( pFtn );
    2224                 :            : 
    2225 [ #  # ][ #  # ]:          0 :                 while ( pCnt && pCnt->FindFtnFrm()->GetAttr() == pAttr )
                 [ #  # ]
    2226                 :            :                 {
    2227                 :          0 :                     pCnt->_InvalidatePos();
    2228                 :          0 :                     pCnt->Calc();
    2229                 :            :                     // #i49383# - format anchored objects
    2230 [ #  # ][ #  # ]:          0 :                     if ( pCnt->IsTxtFrm() && pCnt->IsValid() )
                 [ #  # ]
    2231                 :            :                     {
    2232         [ #  # ]:          0 :                         if ( !SwObjectFormatter::FormatObjsAtFrm( *pCnt,
    2233                 :          0 :                                                                   *(pCnt->FindPageFrm()) ) )
    2234                 :            :                         {
    2235                 :            :                             // restart format with first content
    2236                 :          0 :                             pCnt = pFtn->ContainsAny();
    2237                 :          0 :                             continue;
    2238                 :            :                         }
    2239                 :            :                     }
    2240         [ #  # ]:          0 :                     if( pCnt->IsSctFrm() )
    2241                 :            :                     {   // Wenn es sich um einen nichtleeren Bereich handelt,
    2242                 :            :                         // iterieren wir auch ueber seinen Inhalt
    2243                 :          0 :                         SwFrm* pTmp = ((SwSectionFrm*)pCnt)->ContainsAny();
    2244         [ #  # ]:          0 :                         if( pTmp )
    2245                 :          0 :                             pCnt = pTmp;
    2246                 :            :                         else
    2247                 :          0 :                             pCnt = pCnt->FindNext();
    2248                 :            :                     }
    2249                 :            :                     else
    2250                 :          0 :                         pCnt = pCnt->FindNext();
    2251                 :            :                 }
    2252         [ #  # ]:          0 :                 if( bUnlock )
    2253                 :            :                 {
    2254                 :          0 :                     pFtn->UnlockBackMove();
    2255 [ #  # ][ #  # ]:          0 :                     if( !pFtn->ContainsAny() && !pFtn->IsColLocked() )
                 [ #  # ]
    2256                 :            :                     {
    2257                 :          0 :                         pFtn->Cut();
    2258         [ #  # ]:          0 :                         delete pFtn;
    2259                 :            :                         // #i21478#
    2260                 :          0 :                         pFtn = 0L;
    2261                 :            :                     }
    2262                 :            :                 }
    2263                 :            :                 // #i49383#
    2264         [ #  # ]:          0 :                 if ( pFtn )
    2265                 :            :                 {
    2266                 :            :                     // #i57914# - adjust fix #i49383#
    2267                 :            :                     // enable lock of lower object position before format of footnote frame.
    2268                 :          0 :                     pFtn->UnlockPosOfLowerObjs();
    2269                 :          0 :                     pFtn->Calc();
    2270                 :            : //                    pFtn->UnlockPosOfLowerObjs();
    2271                 :            :                 }
    2272                 :            :                 // #i57914# - adjust fix #i49383#
    2273                 :            :                 // no extra notify for footnote frame
    2274                 :            : //                else
    2275                 :            : //                {
    2276                 :            : //                    aFtnFrmNotitfy.FrmDeleted();
    2277                 :            : //                }
    2278                 :            :             }
    2279                 :            :         }
    2280                 :            :         else
    2281                 :            :         { OSL_ENSURE( !pFtn->GetMaster() && !pFtn->GetFollow(),
    2282                 :            :                     "DelFtn und Master/Follow?" );
    2283         [ #  # ]:          0 :             delete pFtn;
    2284                 :            :             // #i21478#
    2285                 :          0 :             pFtn = 0L;
    2286                 :            :         }
    2287                 :            : 
    2288                 :            :         // #i21478#
    2289         [ #  # ]:          0 :         if ( pFtn )
    2290                 :            :         {
    2291                 :          0 :             pLastInsertedFtn = pFtn;
    2292                 :            :         }
    2293                 :            :     }
    2294                 :            : 
    2295                 :            :     // #i21478# - format content of footnote following
    2296                 :            :     // the new inserted ones.
    2297 [ #  # ][ #  # ]:          0 :     if ( bCalc && pLastInsertedFtn )
    2298                 :            :     {
    2299         [ #  # ]:          0 :         if ( pLastInsertedFtn->GetNext() )
    2300                 :            :         {
    2301                 :          0 :             SwFtnFrm* pNextFtn = static_cast<SwFtnFrm*>(pLastInsertedFtn->GetNext());
    2302                 :          0 :             SwTxtFtn* pAttr = pNextFtn->GetAttr();
    2303                 :          0 :             SwFrm* pCnt = pNextFtn->ContainsAny();
    2304                 :            : 
    2305                 :          0 :             sal_Bool bUnlock = !pNextFtn->IsBackMoveLocked();
    2306                 :          0 :             pNextFtn->LockBackMove();
    2307                 :            :             // #i49383# - disable unlock of position of
    2308                 :            :             // lower objects during format of footnote content.
    2309                 :          0 :             pNextFtn->KeepLockPosOfLowerObjs();
    2310                 :            :             // #i57914# - adjust fix #i49383#
    2311                 :            :             // no extra notify for footnote frame
    2312                 :            : //            SwLayNotify aFtnFrmNotitfy( pNextFtn );
    2313                 :            : 
    2314 [ #  # ][ #  # ]:          0 :             while ( pCnt && pCnt->FindFtnFrm()->GetAttr() == pAttr )
                 [ #  # ]
    2315                 :            :             {
    2316                 :          0 :                 pCnt->_InvalidatePos();
    2317                 :          0 :                 pCnt->Calc();
    2318                 :            :                 // #i49383# - format anchored objects
    2319 [ #  # ][ #  # ]:          0 :                 if ( pCnt->IsTxtFrm() && pCnt->IsValid() )
                 [ #  # ]
    2320                 :            :                 {
    2321         [ #  # ]:          0 :                     if ( !SwObjectFormatter::FormatObjsAtFrm( *pCnt,
    2322                 :          0 :                                                               *(pCnt->FindPageFrm()) ) )
    2323                 :            :                     {
    2324                 :            :                         // restart format with first content
    2325                 :          0 :                         pCnt = pNextFtn->ContainsAny();
    2326                 :          0 :                         continue;
    2327                 :            :                     }
    2328                 :            :                 }
    2329         [ #  # ]:          0 :                 if( pCnt->IsSctFrm() )
    2330                 :            :                 {   // Wenn es sich um einen nichtleeren Bereich handelt,
    2331                 :            :                     // iterieren wir auch ueber seinen Inhalt
    2332                 :          0 :                     SwFrm* pTmp = ((SwSectionFrm*)pCnt)->ContainsAny();
    2333         [ #  # ]:          0 :                     if( pTmp )
    2334                 :          0 :                         pCnt = pTmp;
    2335                 :            :                     else
    2336                 :          0 :                         pCnt = pCnt->FindNext();
    2337                 :            :                 }
    2338                 :            :                 else
    2339                 :          0 :                     pCnt = pCnt->FindNext();
    2340                 :            :             }
    2341         [ #  # ]:          0 :             if( bUnlock )
    2342                 :            :             {
    2343                 :          0 :                 pNextFtn->UnlockBackMove();
    2344                 :            :             }
    2345                 :            :             // #i49383#
    2346                 :            :             // #i57914# - adjust fix #i49383#
    2347                 :            :             // enable lock of lower object position before format of footnote frame.
    2348                 :          0 :             pNextFtn->UnlockPosOfLowerObjs();
    2349                 :          0 :             pNextFtn->Calc();
    2350                 :            : //            pNextFtn->UnlockPosOfLowerObjs();
    2351                 :            :         }
    2352                 :            :     }
    2353                 :          0 : }
    2354                 :            : 
    2355                 :            : /*************************************************************************
    2356                 :            : |*
    2357                 :            : |*  SwFtnBossFrm::MoveFtns()
    2358                 :            : |*
    2359                 :            : |*************************************************************************/
    2360                 :            : 
    2361                 :            : 
    2362                 :          0 : void SwFtnBossFrm::MoveFtns( const SwCntntFrm *pSrc, SwCntntFrm *pDest,
    2363                 :            :                              SwTxtFtn *pAttr )
    2364                 :            : {
    2365   [ #  #  #  #  :          0 :     if( ( GetFmt()->GetDoc()->GetFtnInfo().ePos == FTNPOS_CHAPTER &&
             #  #  #  # ]
                 [ #  # ]
    2366                 :          0 :         (!GetUpper()->IsSctFrm() || !((SwSectionFrm*)GetUpper())->IsFtnAtEnd()))
    2367                 :          0 :         || pAttr->GetFtn().IsEndNote() )
    2368                 :          0 :         return;
    2369                 :            : 
    2370                 :            :     OSL_ENSURE( this == pSrc->FindFtnBossFrm( sal_True ),
    2371                 :            :             "SwPageFrm::MoveFtns: source frame isn't on that FtnBoss" );
    2372                 :            : 
    2373                 :          0 :     SwFtnFrm *pFtn = FindFirstFtn();
    2374         [ #  # ]:          0 :     if( pFtn )
    2375                 :            :     {
    2376                 :          0 :         ChangeFtnRef( pSrc, pAttr, pDest );
    2377                 :          0 :         SwFtnBossFrm *pDestBoss = pDest->FindFtnBossFrm( sal_True );
    2378                 :            :         OSL_ENSURE( pDestBoss, "+SwPageFrm::MoveFtns: no destination boss" );
    2379         [ #  # ]:          0 :         if( pDestBoss )     // robust
    2380                 :            :         {
    2381         [ #  # ]:          0 :             SwFtnFrms aFtnArr;
    2382         [ #  # ]:          0 :             pDestBoss->_CollectFtns( pDest, pFtn, aFtnArr );
    2383         [ #  # ]:          0 :             if ( !aFtnArr.empty() )
    2384                 :            :             {
    2385         [ #  # ]:          0 :                 pDestBoss->_MoveFtns( aFtnArr, sal_True );
    2386         [ #  # ]:          0 :                 SwPageFrm* pSrcPage = FindPageFrm();
    2387         [ #  # ]:          0 :                 SwPageFrm* pDestPage = pDestBoss->FindPageFrm();
    2388                 :            :                 // Nur beim Seitenwechsel FtnNum Updaten
    2389         [ #  # ]:          0 :                 if( pSrcPage != pDestPage )
    2390                 :            :                 {
    2391         [ #  # ]:          0 :                     if( pSrcPage->GetPhyPageNum() > pDestPage->GetPhyPageNum() )
    2392         [ #  # ]:          0 :                         pSrcPage->UpdateFtnNum();
    2393         [ #  # ]:          0 :                     pDestPage->UpdateFtnNum();
    2394                 :            :                 }
    2395                 :          0 :             }
    2396                 :            :         }
    2397                 :            :     }
    2398                 :            : }
    2399                 :            : 
    2400                 :            : /*************************************************************************
    2401                 :            : |*
    2402                 :            : |*  SwFtnBossFrm::RearrangeFtns()
    2403                 :            : |*
    2404                 :            : |*************************************************************************/
    2405                 :            : 
    2406                 :            : 
    2407                 :         69 : void SwFtnBossFrm::RearrangeFtns( const SwTwips nDeadLine, const sal_Bool bLock,
    2408                 :            :                                   const SwTxtFtn *pAttr )
    2409                 :            : {
    2410                 :            :     //Alle Fussnoten der Spalte/Seite dergestalt anformatieren,
    2411                 :            :     //dass sie ggf. die Spalte/Seite wechseln.
    2412                 :            : 
    2413         [ +  - ]:         69 :     SwSaveFtnHeight aSave( this, nDeadLine );
    2414         [ +  - ]:         69 :     SwFtnFrm *pFtn = FindFirstFtn();
    2415 [ +  - ][ -  + ]:         69 :     if( pFtn && pFtn->GetPrev() && bLock )
         [ #  # ][ -  + ]
    2416                 :            :     {
    2417                 :          0 :         SwFtnFrm* pFirst = (SwFtnFrm*)pFtn->GetUpper()->Lower();
    2418         [ #  # ]:          0 :         SwFrm* pCntnt = pFirst->ContainsAny();
    2419         [ #  # ]:          0 :         if( pCntnt )
    2420                 :            :         {
    2421                 :          0 :             sal_Bool bUnlock = !pFirst->IsBackMoveLocked();
    2422                 :          0 :             pFirst->LockBackMove();
    2423         [ #  # ]:          0 :             pFirst->Calc();
    2424         [ #  # ]:          0 :             pCntnt->Calc();
    2425                 :            :             // #i49383# - format anchored objects
    2426 [ #  # ][ #  # ]:          0 :             if ( pCntnt->IsTxtFrm() && pCntnt->IsValid() )
                 [ #  # ]
    2427                 :            :             {
    2428                 :            :                 SwObjectFormatter::FormatObjsAtFrm( *pCntnt,
    2429 [ #  # ][ #  # ]:          0 :                                                     *(pCntnt->FindPageFrm()) );
    2430                 :            :             }
    2431         [ #  # ]:          0 :             if( bUnlock )
    2432                 :          0 :                 pFirst->UnlockBackMove();
    2433                 :            :         }
    2434         [ #  # ]:          0 :         pFtn = FindFirstFtn();
    2435                 :            :     }
    2436         [ +  - ]:         69 :     SwDoc *pDoc = GetFmt()->GetDoc();
    2437 [ +  - ][ +  + ]:         69 :     const sal_uLong nFtnPos = pAttr ? ::lcl_FindFtnPos( pDoc, pAttr ) : 0;
    2438 [ +  - ][ +  - ]:         69 :     SwFrm *pCnt = pFtn ? pFtn->ContainsAny() : 0;
    2439         [ +  - ]:         69 :     if ( pCnt )
    2440                 :            :     {
    2441                 :         69 :         sal_Bool bMore = sal_True;
    2442                 :         69 :         sal_Bool bStart = pAttr == 0; // wenn kein Attribut uebergeben wird, alle bearbeiten
    2443                 :            :         // #i49383# - disable unlock of position of
    2444                 :            :         // lower objects during format of footnote and footnote content.
    2445                 :         69 :         SwFtnFrm* pLastFtnFrm( 0L );
    2446                 :            :         // #i57914# - adjust fix #i49383#
    2447                 :            :         // no extra notify for footnote frame
    2448                 :            : //        SwLayNotify* pFtnFrmNotify( 0L );
    2449                 :            :         // footnote frame needs to be locked, if <bLock> isn't set.
    2450                 :         69 :         bool bUnlockLastFtnFrm( false );
    2451         [ +  + ]:        113 :         do
    2452                 :            :         {
    2453         [ +  + ]:        113 :             if( !bStart )
    2454 [ +  - ][ +  - ]:         14 :                 bStart = ::lcl_FindFtnPos( pDoc, pCnt->FindFtnFrm()->GetAttr() )
    2455                 :         14 :                          == nFtnPos;
    2456         [ +  - ]:        113 :             if( bStart )
    2457                 :            :             {
    2458         [ +  - ]:        113 :                 pCnt->_InvalidatePos();
    2459         [ +  - ]:        113 :                 pCnt->_InvalidateSize();
    2460         [ +  - ]:        113 :                 pCnt->Prepare( PREP_ADJUST_FRM );
    2461         [ +  - ]:        113 :                 SwFtnFrm* pFtnFrm = pCnt->FindFtnFrm();
    2462                 :            :                 // #i49383#
    2463         [ +  + ]:        113 :                 if ( pFtnFrm != pLastFtnFrm )
    2464                 :            :                 {
    2465         [ +  + ]:         89 :                     if ( pLastFtnFrm )
    2466                 :            :                     {
    2467 [ -  + ][ #  # ]:         20 :                         if ( !bLock && bUnlockLastFtnFrm )
    2468                 :            :                         {
    2469                 :          0 :                             pLastFtnFrm->ColUnlock();
    2470                 :            :                         }
    2471                 :            :                         // #i57914# - adjust fix #i49383#
    2472                 :            :                         // enable lock of lower object position before format of footnote frame.
    2473                 :         20 :                         pLastFtnFrm->UnlockPosOfLowerObjs();
    2474         [ +  - ]:         20 :                         pLastFtnFrm->Calc();
    2475                 :            : //                        pLastFtnFrm->UnlockPosOfLowerObjs();
    2476                 :            :                         // no extra notify for footnote frame
    2477                 :            : //                        delete pFtnFrmNotify;
    2478 [ -  + ][ #  # ]:         20 :                         if ( !bLock && bUnlockLastFtnFrm &&
           [ #  #  #  #  
           #  # ][ -  + ]
    2479         [ #  # ]:          0 :                              !pLastFtnFrm->GetLower() &&
    2480                 :          0 :                              !pLastFtnFrm->IsColLocked() &&
    2481                 :          0 :                              !pLastFtnFrm->IsBackMoveLocked() )
    2482                 :            :                         {
    2483         [ #  # ]:          0 :                             pLastFtnFrm->Cut();
    2484 [ #  # ][ #  # ]:          0 :                             delete pLastFtnFrm;
    2485                 :          0 :                             pLastFtnFrm = 0L;
    2486                 :            :                         }
    2487                 :            :                     }
    2488         [ +  + ]:         89 :                     if ( !bLock )
    2489                 :            :                     {
    2490                 :         14 :                         bUnlockLastFtnFrm = !pFtnFrm->IsColLocked();
    2491                 :         14 :                         pFtnFrm->ColLock();
    2492                 :            :                     }
    2493                 :         89 :                     pFtnFrm->KeepLockPosOfLowerObjs();
    2494                 :         89 :                     pLastFtnFrm = pFtnFrm;
    2495                 :            :                     // #i57914# - adjust fix #i49383#
    2496                 :            :                     // no extra notify for footnote frame
    2497                 :            : //                    pFtnFrmNotify = new SwLayNotify( pLastFtnFrm );
    2498                 :            :                 }
    2499                 :            :                 // OD 30.10.2002 #97265# - invalidate position of footnote
    2500                 :            :                 // frame, if it's below its footnote container, in order to
    2501                 :            :                 // assure its correct position, probably calculating its previous
    2502                 :            :                 // footnote frames.
    2503                 :            :                 {
    2504 [ +  - ][ -  + ]:        113 :                     SWRECTFN( this );
         [ #  # ][ #  # ]
                 [ -  + ]
    2505                 :        113 :                     SwFrm* aFtnContFrm = pFtnFrm->GetUpper();
    2506 [ +  - ][ +  - ]:        113 :                     if ( (pFtnFrm->Frm().*fnRect->fnTopDist)((aFtnContFrm->*fnRect->fnGetPrtBottom)()) > 0 )
         [ +  - ][ -  + ]
                 [ +  - ]
    2507                 :            :                     {
    2508         [ #  # ]:          0 :                         pFtnFrm->_InvalidatePos();
    2509                 :            :                     }
    2510                 :            :                 }
    2511         [ +  + ]:        113 :                 if ( bLock )
    2512                 :            :                 {
    2513                 :         75 :                     sal_Bool bUnlock = !pFtnFrm->IsBackMoveLocked();
    2514                 :         75 :                     pFtnFrm->LockBackMove();
    2515         [ +  - ]:         75 :                     pFtnFrm->Calc();
    2516         [ +  - ]:         75 :                     pCnt->Calc();
    2517                 :            :                     // #i49383# - format anchored objects
    2518 [ +  - ][ +  - ]:         75 :                     if ( pCnt->IsTxtFrm() && pCnt->IsValid() )
                 [ +  - ]
    2519                 :            :                     {
    2520         [ -  + ]:         75 :                         if ( !SwObjectFormatter::FormatObjsAtFrm( *pCnt,
    2521 [ +  - ][ +  - ]:         75 :                                                                   *(pCnt->FindPageFrm()) ) )
    2522                 :            :                         {
    2523                 :            :                             // restart format with first content
    2524         [ #  # ]:          0 :                             pCnt = pFtn->ContainsAny();
    2525                 :          0 :                             continue;
    2526                 :            :                         }
    2527                 :            :                     }
    2528         [ +  - ]:         75 :                     if( bUnlock )
    2529                 :            :                     {
    2530                 :         75 :                         pFtnFrm->UnlockBackMove();
    2531         [ -  + ]:         75 :                         if( !pFtnFrm->Lower() &&
           [ -  +  #  # ]
    2532                 :          0 :                             !pFtnFrm->IsColLocked() )
    2533                 :            :                         {
    2534                 :            :                             // #i49383#
    2535                 :            :                             OSL_ENSURE( pLastFtnFrm == pFtnFrm,
    2536                 :            :                                     "<SwFtnBossFrm::RearrangeFtns(..)> - <pLastFtnFrm> != <pFtnFrm>" );
    2537                 :          0 :                             pLastFtnFrm = 0L;
    2538                 :            :                             // #i57914# - adjust fix #i49383#
    2539                 :            :                             // no extra notify for footnote frame
    2540                 :            : //                            pFtnFrmNotify->FrmDeleted();
    2541                 :            : //                            delete pFtnFrmNotify;
    2542         [ #  # ]:          0 :                             pFtnFrm->Cut();
    2543 [ #  # ][ #  # ]:          0 :                             delete pFtnFrm;
    2544                 :            :                         }
    2545                 :            :                     }
    2546                 :            :                 }
    2547                 :            :                 else
    2548                 :            :                 {
    2549         [ +  - ]:         38 :                     pFtnFrm->Calc();
    2550         [ +  - ]:         38 :                     pCnt->Calc();
    2551                 :            :                     // #i49383# - format anchored objects
    2552 [ +  + ][ +  - ]:         38 :                     if ( pCnt->IsTxtFrm() && pCnt->IsValid() )
                 [ +  + ]
    2553                 :            :                     {
    2554         [ -  + ]:         32 :                         if ( !SwObjectFormatter::FormatObjsAtFrm( *pCnt,
    2555 [ +  - ][ +  - ]:         32 :                                                                   *(pCnt->FindPageFrm()) ) )
    2556                 :            :                         {
    2557                 :            :                             // restart format with first content
    2558         [ #  # ]:          0 :                             pCnt = pFtn->ContainsAny();
    2559                 :          0 :                             continue;
    2560                 :            :                         }
    2561                 :            :                     }
    2562                 :            :                 }
    2563                 :            :             }
    2564                 :        113 :             SwSectionFrm *pDel = NULL;
    2565         [ +  + ]:        113 :             if( pCnt->IsSctFrm() )
    2566                 :            :             {
    2567         [ +  - ]:          6 :                 SwFrm* pTmp = ((SwSectionFrm*)pCnt)->ContainsAny();
    2568         [ +  - ]:          6 :                 if( pTmp )
    2569                 :            :                 {
    2570                 :          6 :                     pCnt = pTmp;
    2571                 :          6 :                     continue;
    2572                 :            :                 }
    2573                 :          0 :                 pDel = (SwSectionFrm*)pCnt;
    2574                 :            :             }
    2575         [ +  + ]:        107 :             if ( pCnt->GetNext() )
    2576                 :         12 :                 pCnt = pCnt->GetNext();
    2577                 :            :             else
    2578                 :            :             {
    2579         [ +  - ]:         95 :                 pCnt = pCnt->FindNext();
    2580         [ +  + ]:         95 :                 if ( pCnt )
    2581                 :            :                 {
    2582         [ +  - ]:         26 :                     SwFtnFrm* pFtnFrm = pCnt->FindFtnFrm();
    2583         [ -  + ]:         52 :                     if( pFtnFrm->GetRef()->FindFtnBossFrm(
    2584         [ +  - ]:         52 :                         pFtnFrm->GetAttr()->GetFtn().IsEndNote() ) != this )
    2585                 :          0 :                         bMore = sal_False;
    2586                 :            :                 }
    2587                 :            :                 else
    2588                 :         69 :                     bMore = sal_False;
    2589                 :            :             }
    2590         [ -  + ]:        107 :             if( pDel )
    2591                 :            :             {
    2592         [ #  # ]:          0 :                 pDel->Cut();
    2593 [ #  # ][ #  # ]:          0 :                 delete pDel;
    2594                 :            :             }
    2595         [ +  + ]:        107 :             if ( bMore )
    2596                 :            :             {
    2597                 :            :                 //Nicht weiter als bis zur angegebenen Fussnote, falls eine
    2598                 :            :                 //angegeben wurde.
    2599 [ +  + ][ -  + ]:         56 :                 if ( pAttr &&
                 [ -  + ]
    2600                 :            :                      (::lcl_FindFtnPos( pDoc,
    2601 [ +  - ][ +  - ]:         18 :                                     pCnt->FindFtnFrm()->GetAttr()) > nFtnPos ) )
    2602                 :          0 :                     bMore = sal_False;
    2603                 :            :             }
    2604                 :            :         } while ( bMore );
    2605                 :            :         // #i49383#
    2606         [ +  - ]:         69 :         if ( pLastFtnFrm )
    2607                 :            :         {
    2608 [ +  + ][ +  - ]:         69 :             if ( !bLock && bUnlockLastFtnFrm )
    2609                 :            :             {
    2610                 :         14 :                 pLastFtnFrm->ColUnlock();
    2611                 :            :             }
    2612                 :            :             // #i57914# - adjust fix #i49383#
    2613                 :            :             // enable lock of lower object position before format of footnote frame.
    2614                 :         69 :             pLastFtnFrm->UnlockPosOfLowerObjs();
    2615         [ +  - ]:         69 :             pLastFtnFrm->Calc();
    2616                 :            : //            pLastFtnFrm->UnlockPosOfLowerObjs();
    2617                 :            :             // no extra notify for footnote frame
    2618                 :            : //            delete pFtnFrmNotify;
    2619 [ +  + ][ +  - ]:         83 :             if ( !bLock && bUnlockLastFtnFrm &&
           [ -  +  #  #  
           #  # ][ -  + ]
    2620         [ +  - ]:         14 :                  !pLastFtnFrm->GetLower() &&
    2621                 :          0 :                  !pLastFtnFrm->IsColLocked() &&
    2622                 :          0 :                  !pLastFtnFrm->IsBackMoveLocked() )
    2623                 :            :             {
    2624         [ #  # ]:          0 :                 pLastFtnFrm->Cut();
    2625 [ #  # ][ #  # ]:          0 :                 delete pLastFtnFrm;
    2626                 :            :             }
    2627                 :            :         }
    2628                 :         69 :     }
    2629                 :         69 : }
    2630                 :            : 
    2631                 :            : /*************************************************************************
    2632                 :            : |*
    2633                 :            : |*  SwPageFrm::UpdateFtnNum()
    2634                 :            : |*
    2635                 :            : |*************************************************************************/
    2636                 :            : 
    2637                 :         91 : void SwPageFrm::UpdateFtnNum()
    2638                 :            : {
    2639                 :            :     //Seitenweise Numerierung nur wenn es am Dokument so eingestellt ist.
    2640         [ +  - ]:         91 :     if ( GetFmt()->GetDoc()->GetFtnInfo().eNum != FTNNUM_PAGE )
    2641                 :         91 :         return;
    2642                 :            : 
    2643                 :          0 :     SwLayoutFrm* pBody = FindBodyCont();
    2644 [ #  # ][ #  # ]:          0 :     if( !pBody || !pBody->Lower() )
                 [ #  # ]
    2645                 :          0 :         return;
    2646                 :            : 
    2647                 :          0 :     SwCntntFrm* pCntnt = pBody->ContainsCntnt();
    2648                 :          0 :     sal_uInt16 nNum = 0;
    2649                 :            : 
    2650 [ #  # ][ #  # ]:         91 :     while( pCntnt && pCntnt->FindPageFrm() == this )
                 [ #  # ]
    2651                 :            :     {
    2652         [ #  # ]:          0 :         if( ((SwTxtFrm*)pCntnt)->HasFtn() )
    2653                 :            :         {
    2654                 :          0 :             SwFtnBossFrm* pBoss = pCntnt->FindFtnBossFrm( sal_True );
    2655         [ #  # ]:          0 :             if( pBoss->GetUpper()->IsSctFrm() &&
           [ #  #  #  # ]
    2656                 :          0 :                 ((SwSectionFrm*)pBoss->GetUpper())->IsOwnFtnNum() )
    2657                 :          0 :                 pCntnt = ((SwSectionFrm*)pBoss->GetUpper())->FindLastCntnt();
    2658                 :            :             else
    2659                 :            :             {
    2660                 :          0 :                 SwFtnFrm* pFtn = (SwFtnFrm*)pBoss->FindFirstFtn( pCntnt );
    2661         [ #  # ]:          0 :                 while( pFtn )
    2662                 :            :                 {
    2663                 :          0 :                     SwTxtFtn* pTxtFtn = pFtn->GetAttr();
    2664 [ #  # ][ #  #  :          0 :                     if( !pTxtFtn->GetFtn().IsEndNote() &&
          #  #  #  #  #  
                      # ]
    2665                 :          0 :                          !pTxtFtn->GetFtn().GetNumStr().Len() &&
    2666                 :          0 :                          !pFtn->GetMaster() &&
    2667                 :          0 :                          (pTxtFtn->GetFtn().GetNumber() != ++nNum) )
    2668                 :          0 :                         pTxtFtn->SetNumber( nNum );
    2669         [ #  # ]:          0 :                     if ( pFtn->GetNext() )
    2670                 :          0 :                         pFtn = (SwFtnFrm*)pFtn->GetNext();
    2671                 :            :                     else
    2672                 :            :                     {
    2673         [ #  # ]:          0 :                         SwFtnBossFrm* pTmpBoss = pFtn->FindFtnBossFrm( sal_True );
    2674         [ #  # ]:          0 :                         if( pTmpBoss )
    2675                 :            :                         {
    2676         [ #  # ]:          0 :                             SwPageFrm* pPage = pTmpBoss->FindPageFrm();
    2677                 :          0 :                             pFtn = NULL;
    2678         [ #  # ]:          0 :                             lcl_NextFtnBoss( pTmpBoss, pPage, sal_False );
    2679 [ #  # ][ #  # ]:          0 :                             SwFtnContFrm *pCont = pTmpBoss ? pTmpBoss->FindNearestFtnCont() : NULL;
    2680         [ #  # ]:          0 :                             if ( pCont )
    2681                 :          0 :                                 pFtn = (SwFtnFrm*)pCont->Lower();
    2682                 :            :                         }
    2683                 :            :                     }
    2684 [ #  # ][ #  # ]:          0 :                     if( pFtn && pFtn->GetRef() != pCntnt )
                 [ #  # ]
    2685                 :          0 :                         pFtn = NULL;
    2686                 :            :                 }
    2687                 :            :             }
    2688                 :            :         }
    2689                 :          0 :         pCntnt = pCntnt->FindNextCnt();
    2690                 :            :     }
    2691                 :            : }
    2692                 :            : 
    2693                 :            : /*************************************************************************
    2694                 :            : |*
    2695                 :            : |*  SwFtnBossFrm::SetFtnDeadLine()
    2696                 :            : |*
    2697                 :            : |*************************************************************************/
    2698                 :            : 
    2699                 :       1188 : void SwFtnBossFrm::SetFtnDeadLine( const SwTwips nDeadLine )
    2700                 :            : {
    2701                 :       1188 :     SwFrm *pBody = FindBodyCont();
    2702                 :       1188 :     pBody->Calc();
    2703                 :            : 
    2704                 :       1188 :     SwFrm *pCont = FindFtnCont();
    2705                 :       1188 :     const SwTwips nMax = nMaxFtnHeight;//Aktuelle MaxHeight nicht ueberschreiten.
    2706 [ #  # ][ #  # ]:       1188 :     SWRECTFN( this )
         [ -  + ][ -  + ]
    2707         [ +  + ]:       1188 :     if ( pCont )
    2708                 :            :     {
    2709                 :        342 :         pCont->Calc();
    2710         [ +  - ]:        342 :         nMaxFtnHeight = -(pCont->Frm().*fnRect->fnBottomDist)( nDeadLine );
    2711                 :            :     }
    2712                 :            :     else
    2713         [ +  - ]:        846 :         nMaxFtnHeight = -(pBody->Frm().*fnRect->fnBottomDist)( nDeadLine );
    2714                 :            : 
    2715         [ +  - ]:       1188 :     const ViewShell *pSh = getRootFrm() ? getRootFrm()->GetCurrShell() : 0;
    2716 [ +  - ][ -  + ]:       1188 :     if( pSh && pSh->GetViewOptions()->getBrowseMode() )
                 [ -  + ]
    2717                 :          0 :         nMaxFtnHeight += pBody->Grow( LONG_MAX, sal_True );
    2718         [ +  + ]:       1188 :     if ( IsInSct() )
    2719                 :         76 :         nMaxFtnHeight += FindSctFrm()->Grow( LONG_MAX, sal_True );
    2720                 :            : 
    2721         [ +  + ]:       1188 :     if ( nMaxFtnHeight < 0 )
    2722                 :        712 :         nMaxFtnHeight = 0;
    2723 [ +  + ][ -  + ]:       1188 :     if ( nMax != LONG_MAX && nMaxFtnHeight > nMax )
    2724                 :          0 :         nMaxFtnHeight = nMax;
    2725                 :       1188 : }
    2726                 :            : 
    2727                 :            : /*************************************************************************
    2728                 :            : |*
    2729                 :            : |*  SwFtnBossFrm::GetVarSpace()
    2730                 :            : |*
    2731                 :            : |*************************************************************************/
    2732                 :        980 : SwTwips SwFtnBossFrm::GetVarSpace() const
    2733                 :            : {
    2734                 :            :     //Fuer Seiten soll ein Wert von 20% der Seitenhoehe nicht unterschritten
    2735                 :            :     //werden (->AMA: was macht MS da?)
    2736                 :            :     //->AMA: Was ist da fuer Bereiche sinnvoll (und kompatibel zu MS ;-)?
    2737                 :            :     //AMA: MS kennt scheinbar kein Begrenzung, die Fussnoten nehmen durchaus
    2738                 :            :     // die ganze Seite/Spalte ein.
    2739                 :            : 
    2740                 :        980 :     const SwPageFrm* pPg = FindPageFrm();
    2741                 :            :     OSL_ENSURE( pPg || IsInSct(), "Footnote lost page" );
    2742                 :            : 
    2743                 :        980 :     const SwFrm *pBody = FindBodyCont();
    2744                 :            :     SwTwips nRet;
    2745         [ +  - ]:        980 :     if( pBody )
    2746                 :            :     {
    2747 [ -  + ][ #  # ]:        980 :         SWRECTFN( this )
         [ #  # ][ -  + ]
    2748         [ -  + ]:        980 :         if( IsInSct() )
    2749                 :            :         {
    2750                 :          0 :             nRet = 0;
    2751                 :          0 :             SwTwips nTmp = (*fnRect->fnYDiff)( (pBody->*fnRect->fnGetPrtTop)(),
    2752 [ #  # ][ #  # ]:          0 :                                                (Frm().*fnRect->fnGetTop)() );
    2753                 :          0 :             const SwSectionFrm* pSect = FindSctFrm();
    2754                 :            :             //  Endnotes in a ftncontainer causes a deadline:
    2755                 :            :             // the bottom of the last contentfrm
    2756         [ #  # ]:          0 :             if( pSect->IsEndnAtEnd() ) // endnotes allowed?
    2757                 :            :             {
    2758                 :            :                 OSL_ENSURE( !Lower() || !Lower()->GetNext() || Lower()->GetNext()->
    2759                 :            :                         IsFtnContFrm(), "FtnContainer exspected" );
    2760                 :          0 :                 const SwFtnContFrm* pCont = Lower() ?
    2761         [ #  # ]:          0 :                     (SwFtnContFrm*)Lower()->GetNext() : 0;
    2762         [ #  # ]:          0 :                 if( pCont )
    2763                 :            :                 {
    2764                 :          0 :                     SwFtnFrm* pFtn = (SwFtnFrm*)pCont->Lower();
    2765         [ #  # ]:          0 :                     while( pFtn)
    2766                 :            :                     {
    2767         [ #  # ]:          0 :                         if( pFtn->GetAttr()->GetFtn().IsEndNote() )
    2768                 :            :                         { // endnote found
    2769                 :          0 :                             SwFrm* pFrm = ((SwLayoutFrm*)Lower())->Lower();
    2770         [ #  # ]:          0 :                             if( pFrm )
    2771                 :            :                             {
    2772         [ #  # ]:          0 :                                 while( pFrm->GetNext() )
    2773                 :          0 :                                     pFrm = pFrm->GetNext(); // last cntntfrm
    2774                 :            :                                 nTmp += (*fnRect->fnYDiff)(
    2775                 :          0 :                                          (Frm().*fnRect->fnGetTop)(),
    2776 [ #  # ][ #  # ]:          0 :                                          (pFrm->Frm().*fnRect->fnGetBottom)() );
    2777                 :            :                             }
    2778                 :          0 :                             break;
    2779                 :            :                         }
    2780                 :          0 :                         pFtn = (SwFtnFrm*)pFtn->GetNext();
    2781                 :            :                     }
    2782                 :            :                 }
    2783                 :            :             }
    2784         [ #  # ]:          0 :             if( nTmp < nRet )
    2785                 :          0 :                 nRet = nTmp;
    2786                 :            :         }
    2787                 :            :         else
    2788         [ +  - ]:        980 :             nRet = - (pPg->Prt().*fnRect->fnGetHeight)()/5;
    2789         [ +  - ]:        980 :         nRet += (pBody->Frm().*fnRect->fnGetHeight)();
    2790         [ -  + ]:        980 :         if( nRet < 0 )
    2791                 :          0 :             nRet = 0;
    2792                 :            :     }
    2793                 :            :     else
    2794                 :          0 :         nRet = 0;
    2795         [ +  - ]:        980 :     if ( IsPageFrm() )
    2796                 :            :     {
    2797         [ +  - ]:        980 :         const ViewShell *pSh = getRootFrm() ? getRootFrm()->GetCurrShell() : 0;
    2798 [ +  + ][ -  + ]:        980 :         if( pSh && pSh->GetViewOptions()->getBrowseMode() )
                 [ -  + ]
    2799                 :          0 :         nRet += BROWSE_HEIGHT - Frm().Height();
    2800                 :            :     }
    2801                 :        980 :     return nRet;
    2802                 :            : }
    2803                 :            : 
    2804                 :            : /*************************************************************************
    2805                 :            : |*
    2806                 :            : |*  SwFtnBossFrm::NeighbourhoodAdjustment(SwFrm*)
    2807                 :            : |*
    2808                 :            : |*  gibt Auskunft, ob die Groessenveraenderung von pFrm von AdjustNeighbourhood(...)
    2809                 :            : |*  oder von Grow/Shrink(..) verarbeitet werden sollte.
    2810                 :            : |*  Bei einem PageFrm oder in Spalten direkt unterhalb der Seite muss AdjustNei..
    2811                 :            : |*  gerufen werden, in Rahmenspalten Grow/Shrink.
    2812                 :            : |*  Spannend sind die spaltigen Bereiche: Wenn es in der Spalte einen Fussnotencontainer
    2813                 :            : |*  gibt und die Fussnoten nicht vom Bereich eingesammelt werden, ist ein Adjust..,
    2814                 :            : |*  ansonsten ein Grow/Shrink notwendig.
    2815                 :            : |*
    2816                 :            : |*************************************************************************/
    2817                 :            : 
    2818                 :        372 : sal_uInt8 SwFtnBossFrm::_NeighbourhoodAdjustment( const SwFrm* ) const
    2819                 :            : {
    2820                 :        372 :     sal_uInt8 nRet = NA_ONLY_ADJUST;
    2821 [ +  - ][ +  + ]:        372 :     if( GetUpper() && !GetUpper()->IsPageBodyFrm() )
                 [ +  + ]
    2822                 :            :     {
    2823                 :            :         // Spaltige Rahmen erfordern Grow/Shrink
    2824         [ -  + ]:        360 :         if( GetUpper()->IsFlyFrm() )
    2825                 :          0 :             nRet = NA_GROW_SHRINK;
    2826                 :            :         else
    2827                 :            :         {
    2828                 :            :             OSL_ENSURE( GetUpper()->IsSctFrm(), "NeighbourhoodAdjustment: Unexspected Upper" );
    2829 [ +  + ][ +  + ]:        360 :             if( !GetNext() && !GetPrev() )
                 [ +  + ]
    2830                 :         52 :                 nRet = NA_GROW_ADJUST; // section with a single column (FtnAtEnd)
    2831                 :            :             else
    2832                 :            :             {
    2833                 :        308 :                 const SwFrm* pTmp = Lower();
    2834                 :            :                 OSL_ENSURE( pTmp, "NeighbourhoodAdjustment: Missing Lower()" );
    2835         [ +  - ]:        308 :                 if( !pTmp->GetNext() )
    2836                 :        308 :                     nRet = NA_GROW_SHRINK;
    2837         [ #  # ]:          0 :                 else if( !GetUpper()->IsColLocked() )
    2838                 :          0 :                     nRet = NA_ADJUST_GROW;
    2839                 :            :                 OSL_ENSURE( !pTmp->GetNext() || pTmp->GetNext()->IsFtnContFrm(),
    2840                 :            :                         "NeighbourhoodAdjustment: Who's that guy?" );
    2841                 :            :             }
    2842                 :            :         }
    2843                 :            :     }
    2844                 :        372 :     return nRet;
    2845                 :            : }
    2846                 :            : 
    2847                 :            : /*************************************************************************
    2848                 :            : |*
    2849                 :            : |*  SwPageFrm::SetColMaxFtnHeight()
    2850                 :            : |*
    2851                 :            : |*************************************************************************/
    2852                 :          0 : void SwPageFrm::SetColMaxFtnHeight()
    2853                 :            : {
    2854                 :          0 :     SwLayoutFrm *pBody = FindBodyCont();
    2855 [ #  # ][ #  # ]:          0 :     if( pBody && pBody->Lower() && pBody->Lower()->IsColumnFrm() )
         [ #  # ][ #  # ]
    2856                 :            :     {
    2857                 :          0 :         SwColumnFrm* pCol = (SwColumnFrm*)pBody->Lower();
    2858         [ #  # ]:          0 :         do
    2859                 :            :         {
    2860                 :          0 :             pCol->SetMaxFtnHeight( GetMaxFtnHeight() );
    2861                 :          0 :             pCol = (SwColumnFrm*)pCol->GetNext();
    2862                 :            :         } while ( pCol );
    2863                 :            :     }
    2864                 :          0 : }
    2865                 :            : 
    2866                 :            : /*************************************************************************
    2867                 :            : |*
    2868                 :            : |*  SwLayoutFrm::MoveLowerFtns
    2869                 :            : |*
    2870                 :            : |*************************************************************************/
    2871                 :            : 
    2872                 :            : 
    2873                 :        170 : sal_Bool SwLayoutFrm::MoveLowerFtns( SwCntntFrm *pStart, SwFtnBossFrm *pOldBoss,
    2874                 :            :                                  SwFtnBossFrm *pNewBoss, const sal_Bool bFtnNums )
    2875                 :            : {
    2876         [ +  - ]:        170 :     SwDoc *pDoc = GetFmt()->GetDoc();
    2877         [ +  - ]:        170 :     if ( pDoc->GetFtnIdxs().empty() )
    2878                 :        170 :         return sal_False;
    2879         [ #  # ]:          0 :     if( pDoc->GetFtnInfo().ePos == FTNPOS_CHAPTER &&
           [ #  #  #  # ]
                 [ #  # ]
    2880 [ #  # ][ #  # ]:          0 :         ( !IsInSct() || !FindSctFrm()->IsFtnAtEnd() ) )
    2881                 :          0 :         return sal_True;
    2882                 :            : 
    2883         [ #  # ]:          0 :     if ( !pNewBoss )
    2884         [ #  # ]:          0 :         pNewBoss = FindFtnBossFrm( sal_True );
    2885         [ #  # ]:          0 :     if ( pNewBoss == pOldBoss )
    2886                 :          0 :         return sal_False;
    2887                 :            : 
    2888                 :          0 :     sal_Bool bMoved = sal_False;
    2889         [ #  # ]:          0 :     if( !pStart )
    2890         [ #  # ]:          0 :         pStart = ContainsCntnt();
    2891                 :            : 
    2892         [ #  # ]:          0 :     SwFtnFrms aFtnArr;
    2893                 :            : 
    2894 [ #  # ][ #  # ]:          0 :     while ( IsAnLower( pStart ) )
    2895                 :            :     {
    2896         [ #  # ]:          0 :         if ( ((SwTxtFrm*)pStart)->HasFtn() )
    2897                 :            :         {
    2898                 :            :             // OD 03.04.2003 #108446# - To avoid unnecessary moves of footnotes
    2899                 :            :             // use new parameter <_bCollectOnlyPreviousFtn> (4th parameter of
    2900                 :            :             // method <SwFtnBossFrm::CollectFtn(..)>) to control, that only
    2901                 :            :             // footnotes have to be collected, that are positioned before the
    2902                 :            :             // new dedicated footnote boss frame.
    2903         [ #  # ]:          0 :             pNewBoss->CollectFtns( pStart, pOldBoss, aFtnArr, sal_True );
    2904                 :            :         }
    2905         [ #  # ]:          0 :         pStart = pStart->GetNextCntntFrm();
    2906                 :            :     }
    2907                 :            : 
    2908                 :            :     OSL_ENSURE( pOldBoss->IsInSct() == pNewBoss->IsInSct(),
    2909                 :            :             "MoveLowerFtns: Section confusion" );
    2910                 :            :     SwFtnFrms *pFtnArr;
    2911                 :          0 :     SwLayoutFrm* pNewChief = 0;
    2912                 :          0 :     SwLayoutFrm* pOldChief = 0;
    2913 [ #  # ][ #  # ]:          0 :     if( pStart && pOldBoss->IsInSct() && ( pOldChief = pOldBoss->FindSctFrm() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2914                 :          0 :         != ( pNewChief = pNewBoss->FindSctFrm() ) )
    2915                 :            :     {
    2916 [ #  # ][ #  # ]:          0 :         pFtnArr = new SwFtnFrms;
    2917         [ #  # ]:          0 :         pOldChief = pOldBoss->FindFtnBossFrm( sal_True );
    2918         [ #  # ]:          0 :         pNewChief = pNewBoss->FindFtnBossFrm( sal_True );
    2919 [ #  # ][ #  # ]:          0 :         while( pOldChief->IsAnLower( pStart ) )
    2920                 :            :         {
    2921         [ #  # ]:          0 :             if ( ((SwTxtFrm*)pStart)->HasFtn() )
    2922                 :            :                 ((SwFtnBossFrm*)pNewChief)->CollectFtns( pStart,
    2923         [ #  # ]:          0 :                                         (SwFtnBossFrm*)pOldBoss, *pFtnArr );
    2924         [ #  # ]:          0 :             pStart = pStart->GetNextCntntFrm();
    2925                 :            :         }
    2926         [ #  # ]:          0 :         if( pFtnArr->empty() )
    2927                 :            :         {
    2928         [ #  # ]:          0 :             delete pFtnArr;
    2929                 :          0 :             pFtnArr = NULL;
    2930                 :            :         }
    2931                 :            :     }
    2932                 :            :     else
    2933                 :          0 :         pFtnArr = NULL;
    2934                 :            : 
    2935 [ #  # ][ #  # ]:          0 :     if ( !aFtnArr.empty() || pFtnArr )
                 [ #  # ]
    2936                 :            :     {
    2937         [ #  # ]:          0 :         if( !aFtnArr.empty() )
    2938         [ #  # ]:          0 :             pNewBoss->_MoveFtns( aFtnArr, sal_True );
    2939         [ #  # ]:          0 :         if( pFtnArr )
    2940                 :            :         {
    2941         [ #  # ]:          0 :             ((SwFtnBossFrm*)pNewChief)->_MoveFtns( *pFtnArr, sal_True );
    2942         [ #  # ]:          0 :             delete pFtnArr;
    2943                 :            :         }
    2944                 :          0 :         bMoved = sal_True;
    2945                 :            : 
    2946                 :            :         // Nur bei einem Seitenwechsel muss die FtnNum neu berechnet werden
    2947         [ #  # ]:          0 :         if ( bFtnNums )
    2948                 :            :         {
    2949         [ #  # ]:          0 :             SwPageFrm* pOldPage = pOldBoss->FindPageFrm();
    2950         [ #  # ]:          0 :             SwPageFrm* pNewPage =pNewBoss->FindPageFrm();
    2951         [ #  # ]:          0 :             if( pOldPage != pNewPage )
    2952                 :            :             {
    2953         [ #  # ]:          0 :                 pOldPage->UpdateFtnNum();
    2954         [ #  # ]:          0 :                 pNewPage->UpdateFtnNum();
    2955                 :            :             }
    2956                 :            :         }
    2957                 :            :     }
    2958                 :        170 :     return bMoved;
    2959                 :            : }
    2960                 :            : 
    2961                 :            : /*************************************************************************
    2962                 :            : |*
    2963                 :            : |*  SwLayoutFrm::MoveFtnCntFwd()
    2964                 :            : |*
    2965                 :            : |*************************************************************************/
    2966                 :            : 
    2967                 :            : 
    2968                 :          0 : sal_Bool SwCntntFrm::MoveFtnCntFwd( sal_Bool bMakePage, SwFtnBossFrm *pOldBoss )
    2969                 :            : {
    2970                 :            :     OSL_ENSURE( IsInFtn(), "Keine Ftn." );
    2971                 :          0 :     SwLayoutFrm *pFtn = FindFtnFrm();
    2972                 :            : 
    2973                 :            :     // The first paragraph in the first footnote in the first column in the
    2974                 :            :     // sectionfrm at the top of the page has not to move forward, if the
    2975                 :            :     // columnbody is empty.
    2976         [ #  # ]:          0 :     if( pOldBoss->IsInSct() && !pOldBoss->GetIndPrev() && !GetIndPrev() &&
           [ #  #  #  # ]
         [ #  # ][ #  # ]
    2977                 :          0 :         !pFtn->GetPrev() )
    2978                 :            :     {
    2979                 :          0 :         SwLayoutFrm* pBody = pOldBoss->FindBodyCont();
    2980 [ #  # ][ #  # ]:          0 :         if( !pBody || !pBody->Lower() )
                 [ #  # ]
    2981                 :          0 :             return sal_True;
    2982                 :            :     }
    2983                 :            : 
    2984                 :            :     //fix(9538): Wenn die Ftn noch Nachbarn hinter sich hat, so muessen
    2985                 :            :     //diese ersteinmal verschwinden.
    2986                 :          0 :     SwLayoutFrm *pNxt = (SwLayoutFrm*)pFtn->GetNext();
    2987                 :          0 :     SwLayoutFrm *pLst = 0;
    2988         [ #  # ]:          0 :     while ( pNxt )
    2989                 :            :     {
    2990         [ #  # ]:          0 :         while ( pNxt->GetNext() )
    2991                 :          0 :             pNxt = (SwLayoutFrm*)pNxt->GetNext();
    2992         [ #  # ]:          0 :         if ( pNxt == pLst )
    2993                 :          0 :             pNxt = 0;
    2994                 :            :         else
    2995                 :          0 :         {   pLst = pNxt;
    2996                 :          0 :             SwCntntFrm *pCnt = pNxt->ContainsCntnt();
    2997         [ #  # ]:          0 :             if( pCnt )
    2998                 :          0 :                 pCnt->MoveFtnCntFwd( sal_True, pOldBoss );
    2999                 :          0 :             pNxt = (SwLayoutFrm*)pFtn->GetNext();
    3000                 :            :         }
    3001                 :            :     }
    3002                 :            : 
    3003                 :          0 :     sal_Bool bSamePage = sal_True;
    3004                 :            :     SwLayoutFrm *pNewUpper =
    3005         [ #  # ]:          0 :                 GetLeaf( bMakePage ? MAKEPAGE_INSERT : MAKEPAGE_NONE, sal_True );
    3006                 :            : 
    3007         [ #  # ]:          0 :     if ( pNewUpper )
    3008                 :            :     {
    3009                 :          0 :         sal_Bool bSameBoss = sal_True;
    3010                 :          0 :         SwFtnBossFrm * const pNewBoss = pNewUpper->FindFtnBossFrm();
    3011                 :            :         //Wechseln wir die Spalte/Seite?
    3012         [ #  # ]:          0 :         if ( sal_False == ( bSameBoss = (pNewBoss == pOldBoss) ) )
    3013                 :            :         {
    3014                 :          0 :             bSamePage = pOldBoss->FindPageFrm() == pNewBoss->FindPageFrm(); // Seitenwechsel?
    3015                 :          0 :             pNewUpper->Calc();
    3016                 :            :         }
    3017                 :            : 
    3018                 :            :         //Das Layoutblatt, dass wir fuer Fussnoten bekommen ist entweder
    3019                 :            :         //ein Fussnotencontainer oder eine Fussnote
    3020                 :            :         //Wenn es eine Fussnote ist, und sie die gleiche Fussnotenreferez
    3021                 :            :         //wie der alte Upper hat, so moven wir uns direkt hinein.
    3022                 :            :         //Ist die Referenz einen andere oder ist es ein Container, so wird
    3023                 :            :         //eine neue Fussnote erzeugt und in den Container gestellt.
    3024                 :            :         // Wenn wir in einem Bereich innerhalb der Fussnote sind, muss
    3025                 :            :         // SectionFrame noch angelegt werden.
    3026         [ #  # ]:          0 :         SwFtnFrm* pTmpFtn = pNewUpper->IsFtnFrm() ? ((SwFtnFrm*)pNewUpper) : 0;
    3027         [ #  # ]:          0 :         if( !pTmpFtn )
    3028                 :            :         {
    3029                 :            :             OSL_ENSURE( pNewUpper->IsFtnContFrm(), "Neuer Upper kein FtnCont.");
    3030                 :          0 :             SwFtnContFrm *pCont = (SwFtnContFrm*)pNewUpper;
    3031                 :            : 
    3032                 :            :             //Fussnote erzeugen.
    3033                 :          0 :             SwFtnFrm *pOld = FindFtnFrm();
    3034                 :          0 :             pTmpFtn = new SwFtnFrm( pOld->GetFmt()->GetDoc()->GetDfltFrmFmt(),
    3035         [ #  # ]:          0 :                                     pOld, pOld->GetRef(), pOld->GetAttr() );
    3036                 :            :             //Verkettung der Fussnoten.
    3037         [ #  # ]:          0 :             if ( pOld->GetFollow() )
    3038                 :            :             {
    3039                 :          0 :                 pTmpFtn->SetFollow( pOld->GetFollow() );
    3040                 :          0 :                 pOld->GetFollow()->SetMaster( pTmpFtn );
    3041                 :            :             }
    3042                 :          0 :             pOld->SetFollow( pTmpFtn );
    3043                 :          0 :             pTmpFtn->SetMaster( pOld );
    3044                 :          0 :             SwFrm* pNx = pCont->Lower();
    3045 [ #  # ][ #  # ]:          0 :             if( pNx && pTmpFtn->GetAttr()->GetFtn().IsEndNote() )
                 [ #  # ]
    3046 [ #  # ][ #  # ]:          0 :                 while(pNx && !((SwFtnFrm*)pNx)->GetAttr()->GetFtn().IsEndNote())
                 [ #  # ]
    3047                 :          0 :                     pNx = pNx->GetNext();
    3048                 :          0 :             pTmpFtn->Paste( pCont, pNx );
    3049                 :          0 :             pTmpFtn->Calc();
    3050                 :            :         }
    3051                 :            :         OSL_ENSURE( pTmpFtn->GetAttr() == FindFtnFrm()->GetAttr(), "Wrong Footnote!" );
    3052                 :            :         // Bereiche in Fussnoten beduerfen besonderer Behandlung
    3053                 :          0 :         SwLayoutFrm *pNewUp = pTmpFtn;
    3054         [ #  # ]:          0 :         if( IsInSct() )
    3055                 :            :         {
    3056                 :          0 :             SwSectionFrm* pSect = FindSctFrm();
    3057                 :            :             // Bereich in Fussnote (oder nur Fussnote in Bereich)?
    3058         [ #  # ]:          0 :             if( pSect->IsInFtn() )
    3059                 :            :             {
    3060         [ #  # ]:          0 :                 if( pTmpFtn->Lower() && pTmpFtn->Lower()->IsSctFrm() &&
           [ #  #  #  # ]
                 [ #  # ]
    3061                 :          0 :                     pSect->GetFollow() == (SwSectionFrm*)pTmpFtn->Lower() )
    3062                 :          0 :                     pNewUp = (SwSectionFrm*)pTmpFtn->Lower();
    3063                 :            :                 else
    3064                 :            :                 {
    3065         [ #  # ]:          0 :                     pNewUp = new SwSectionFrm( *pSect, sal_False );
    3066                 :          0 :                     pNewUp->InsertBefore( pTmpFtn, pTmpFtn->Lower() );
    3067                 :          0 :                     static_cast<SwSectionFrm*>(pNewUp)->Init();
    3068                 :          0 :                     pNewUp->Frm().Pos() = pTmpFtn->Frm().Pos();
    3069                 :          0 :                     pNewUp->Frm().Pos().Y() += 1; //wg. Benachrichtigungen.
    3070                 :            : 
    3071                 :            :                     // Wenn unser Bereichsframe einen Nachfolger hat, so muss dieser
    3072                 :            :                     // umgehaengt werden hinter den neuen Follow der Bereichsframes.
    3073                 :          0 :                     SwFrm* pTmp = pSect->GetNext();
    3074         [ #  # ]:          0 :                     if( pTmp )
    3075                 :            :                     {
    3076                 :            :                         SwFlowFrm* pTmpNxt;
    3077         [ #  # ]:          0 :                         if( pTmp->IsCntntFrm() )
    3078         [ #  # ]:          0 :                             pTmpNxt = (SwCntntFrm*)pTmp;
    3079         [ #  # ]:          0 :                         else if( pTmp->IsSctFrm() )
    3080         [ #  # ]:          0 :                             pTmpNxt = (SwSectionFrm*)pTmp;
    3081                 :            :                         else
    3082                 :            :                         {
    3083                 :            :                             OSL_ENSURE( pTmp->IsTabFrm(), "GetNextSctLeaf: Wrong Type" );
    3084         [ #  # ]:          0 :                             pTmpNxt = (SwTabFrm*)pTmp;
    3085                 :            :                         }
    3086                 :          0 :                         pTmpNxt->MoveSubTree( pTmpFtn, pNewUp->GetNext() );
    3087                 :            :                     }
    3088                 :            :                 }
    3089                 :            :             }
    3090                 :            :         }
    3091                 :            : 
    3092                 :          0 :         MoveSubTree( pNewUp, pNewUp->Lower() );
    3093                 :            : 
    3094         [ #  # ]:          0 :         if( !bSameBoss )
    3095                 :          0 :             Prepare( PREP_BOSS_CHGD );
    3096                 :            :     }
    3097                 :          0 :     return bSamePage;
    3098                 :            : }
    3099                 :            : 
    3100                 :            : /*************************************************************************
    3101                 :            : |*
    3102                 :            : |*  class SwSaveFtnHeight
    3103                 :            : |*
    3104                 :            : |*************************************************************************/
    3105                 :            : 
    3106                 :            : 
    3107                 :       1188 : SwSaveFtnHeight::SwSaveFtnHeight( SwFtnBossFrm *pBs, const SwTwips nDeadLine ) :
    3108                 :            :     pBoss( pBs ),
    3109                 :       1188 :     nOldHeight( pBs->GetMaxFtnHeight() )
    3110                 :            : {
    3111                 :       1188 :     pBoss->SetFtnDeadLine( nDeadLine );
    3112                 :       1188 :     nNewHeight = pBoss->GetMaxFtnHeight();
    3113                 :       1188 : }
    3114                 :            : 
    3115                 :            : 
    3116                 :            : 
    3117                 :       1188 : SwSaveFtnHeight::~SwSaveFtnHeight()
    3118                 :            : {
    3119                 :            :     //Wenn zwischendurch jemand an der DeadLine gedreht hat, so lassen wir
    3120                 :            :     //ihm seinen Spass!
    3121         [ +  - ]:       1188 :     if ( nNewHeight == pBoss->GetMaxFtnHeight() )
    3122                 :       1188 :         pBoss->nMaxFtnHeight = nOldHeight;
    3123                 :       1188 : }
    3124                 :            : 
    3125                 :            : 
    3126                 :            : #ifdef DBG_UTIL
    3127                 :            : //JP 15.10.2001: in a non pro version test if the attribute has the same
    3128                 :            : //              meaning which his reference is
    3129                 :            : 
    3130                 :            : // Normally, the pRef member and the GetRefFromAttr() result has to be
    3131                 :            : // identically. Sometimes footnote will be moved from a master to its follow,
    3132                 :            : // but the GetRef() is called first, so we have to ignore a master/follow
    3133                 :            : // mismatch.
    3134                 :            : 
    3135                 :            : const SwCntntFrm* SwFtnFrm::GetRef() const
    3136                 :            : {
    3137                 :            :     const SwCntntFrm* pRefAttr = GetRefFromAttr();
    3138                 :            :     SAL_WARN_IF( pRef != pRefAttr && !pRef->IsAnFollow( pRefAttr )
    3139                 :            :             && !pRefAttr->IsAnFollow( pRef ),
    3140                 :            :             "sw", "access to deleted Frame? pRef != pAttr->GetRef()" );
    3141                 :            :     return pRef;
    3142                 :            : }
    3143                 :            : 
    3144                 :            : SwCntntFrm* SwFtnFrm::GetRef()
    3145                 :            : {
    3146                 :            :     const SwCntntFrm* pRefAttr = GetRefFromAttr();
    3147                 :            :     SAL_WARN_IF( pRef != pRefAttr && !pRef->IsAnFollow( pRefAttr )
    3148                 :            :             && !pRefAttr->IsAnFollow( pRef ),
    3149                 :            :             "sw", "access to deleted Frame? pRef != pAttr->GetRef()" );
    3150                 :            :     return pRef;
    3151                 :            : }
    3152                 :            : 
    3153                 :            : #endif
    3154                 :            : 
    3155                 :          0 : const SwCntntFrm* SwFtnFrm::GetRefFromAttr()  const
    3156                 :            : {
    3157                 :          0 :     SwFtnFrm* pThis = (SwFtnFrm*)this;
    3158                 :          0 :     return pThis->GetRefFromAttr();
    3159                 :            : }
    3160                 :            : 
    3161                 :          6 : SwCntntFrm* SwFtnFrm::GetRefFromAttr()
    3162                 :            : {
    3163                 :            :     OSL_ENSURE( pAttr, "invalid Attribute" );
    3164                 :          6 :     SwTxtNode& rTNd = (SwTxtNode&)pAttr->GetTxtNode();
    3165 [ +  - ][ +  - ]:          6 :     SwPosition aPos( rTNd, SwIndex( &rTNd, *pAttr->GetStart() ));
         [ +  - ][ +  - ]
                 [ +  - ]
    3166         [ +  - ]:          6 :     SwCntntFrm* pCFrm = rTNd.getLayoutFrm( getRootFrm(), 0, &aPos, sal_False );
    3167         [ +  - ]:          6 :     return pCFrm;
    3168                 :            : }
    3169                 :            : 
    3170                 :            : /** search for last content in the current footnote frame
    3171                 :            : 
    3172                 :            :     OD 2005-12-02 #i27138#
    3173                 :            : 
    3174                 :            :     @author OD
    3175                 :            : */
    3176                 :          0 : SwCntntFrm* SwFtnFrm::FindLastCntnt()
    3177                 :            : {
    3178                 :          0 :     SwCntntFrm* pLastCntntFrm( 0L );
    3179                 :            : 
    3180                 :            :     // find last lower, which is a content frame or contains content.
    3181                 :            :     // hidden text frames, empty sections and empty tables have to be skipped.
    3182                 :          0 :     SwFrm* pLastLowerOfFtn( GetLower() );
    3183                 :          0 :     SwFrm* pTmpLastLower( pLastLowerOfFtn );
    3184 [ #  # ][ #  # ]:          0 :     while ( pTmpLastLower && pTmpLastLower->GetNext() )
                 [ #  # ]
    3185                 :            :     {
    3186                 :          0 :         pTmpLastLower = pTmpLastLower->GetNext();
    3187 [ #  # ][ #  #  :          0 :         if ( ( pTmpLastLower->IsTxtFrm() &&
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
    3188                 :          0 :                !static_cast<SwTxtFrm*>(pTmpLastLower)->IsHiddenNow() ) ||
    3189                 :          0 :              ( pTmpLastLower->IsSctFrm() &&
    3190                 :          0 :                static_cast<SwSectionFrm*>(pTmpLastLower)->GetSection() &&
    3191                 :          0 :                static_cast<SwSectionFrm*>(pTmpLastLower)->ContainsCntnt() ) ||
    3192                 :          0 :              ( pTmpLastLower->IsTabFrm() &&
    3193                 :          0 :                static_cast<SwTabFrm*>(pTmpLastLower)->ContainsCntnt() ) )
    3194                 :            :         {
    3195                 :          0 :             pLastLowerOfFtn = pTmpLastLower;
    3196                 :            :         }
    3197                 :            :     }
    3198                 :            : 
    3199                 :            :     // determine last content frame depending on type of found last lower.
    3200 [ #  # ][ #  # ]:          0 :     if ( pLastLowerOfFtn && pLastLowerOfFtn->IsTabFrm() )
                 [ #  # ]
    3201                 :            :     {
    3202                 :          0 :         pLastCntntFrm = static_cast<SwTabFrm*>(pLastLowerOfFtn)->FindLastCntnt();
    3203                 :            :     }
    3204 [ #  # ][ #  # ]:          0 :     else if ( pLastLowerOfFtn && pLastLowerOfFtn->IsSctFrm() )
                 [ #  # ]
    3205                 :            :     {
    3206                 :          0 :         pLastCntntFrm = static_cast<SwSectionFrm*>(pLastLowerOfFtn)->FindLastCntnt();
    3207                 :            :     }
    3208                 :            :     else
    3209                 :            :     {
    3210         [ #  # ]:          0 :         pLastCntntFrm = dynamic_cast<SwCntntFrm*>(pLastLowerOfFtn);
    3211                 :            :     }
    3212                 :            : 
    3213                 :          0 :     return pLastCntntFrm;
    3214                 :            : }
    3215                 :            : 
    3216                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10