LCOV - code coverage report
Current view: top level - sw/source/core/doc - docftn.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 239 274 87.2 %
Date: 2015-06-13 12:38:46 Functions: 23 23 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <ftnidx.hxx>
      21             : #include <rootfrm.hxx>
      22             : #include <txtftn.hxx>
      23             : #include <fmtftn.hxx>
      24             : #include <pam.hxx>
      25             : #include <pagedesc.hxx>
      26             : #include <charfmt.hxx>
      27             : #include <UndoAttribute.hxx>
      28             : #include <hints.hxx>
      29             : #include <rolbck.hxx>
      30             : #include <doc.hxx>
      31             : #include <IDocumentFieldsAccess.hxx>
      32             : #include <IDocumentUndoRedo.hxx>
      33             : #include <IDocumentState.hxx>
      34             : #include <IDocumentLayoutAccess.hxx>
      35             : #include <IDocumentStylePoolAccess.hxx>
      36             : #include <ndtxt.hxx>
      37             : #include <poolfmt.hxx>
      38             : #include <ftninfo.hxx>
      39             : 
      40         119 : SwEndNoteInfo& SwEndNoteInfo::operator=(const SwEndNoteInfo& rInfo)
      41             : {
      42         119 :     if( rInfo.GetFootnoteTextColl() )
      43          18 :         rInfo.GetFootnoteTextColl()->Add(this);
      44         101 :     else if ( GetRegisteredIn())
      45           0 :         GetRegisteredInNonConst()->Remove(this);
      46             : 
      47         119 :     if ( rInfo.aPageDescDep.GetRegisteredIn() )
      48          64 :         const_cast<SwModify*>(rInfo.aPageDescDep.GetRegisteredIn())->Add( &aPageDescDep );
      49          55 :     else if ( aPageDescDep.GetRegisteredIn() )
      50           0 :         aPageDescDep.GetRegisteredIn()->Remove( &aPageDescDep );
      51             : 
      52         119 :     if ( rInfo.aCharFormatDep.GetRegisteredIn() )
      53         118 :         const_cast<SwModify*>(rInfo.aCharFormatDep.GetRegisteredIn())->Add( &aCharFormatDep );
      54           1 :     else if ( aCharFormatDep.GetRegisteredIn() )
      55           0 :         aCharFormatDep.GetRegisteredIn()->Remove( &aCharFormatDep );
      56             : 
      57         119 :     if ( rInfo.aAnchorCharFormatDep.GetRegisteredIn() )
      58          45 :         const_cast<SwModify*>(rInfo.aAnchorCharFormatDep.GetRegisteredIn())->Add(
      59          90 :                                                     &aAnchorCharFormatDep );
      60          74 :     else if( aAnchorCharFormatDep.GetRegisteredIn() )
      61             :         static_cast<SwModify*>(aAnchorCharFormatDep.GetRegisteredIn())->Remove(
      62           0 :                                                     &aAnchorCharFormatDep );
      63             : 
      64         119 :     aFormat = rInfo.aFormat;
      65         119 :     nFootnoteOffset = rInfo.nFootnoteOffset;
      66         119 :     m_bEndNote = rInfo.m_bEndNote;
      67         119 :     sPrefix = rInfo.sPrefix;
      68         119 :     sSuffix = rInfo.sSuffix;
      69         119 :     return *this;
      70             : }
      71             : 
      72        5799 : bool SwEndNoteInfo::operator==( const SwEndNoteInfo& rInfo ) const
      73             : {
      74        5799 :     return  aPageDescDep.GetRegisteredIn() ==
      75       11594 :                                 rInfo.aPageDescDep.GetRegisteredIn() &&
      76        5795 :             aCharFormatDep.GetRegisteredIn() ==
      77       11550 :                                 rInfo.aCharFormatDep.GetRegisteredIn() &&
      78        5755 :             aAnchorCharFormatDep.GetRegisteredIn() ==
      79       11492 :                                 rInfo.aAnchorCharFormatDep.GetRegisteredIn() &&
      80       11469 :             GetFootnoteTextColl() == rInfo.GetFootnoteTextColl() &&
      81       11443 :             aFormat.GetNumberingType() == rInfo.aFormat.GetNumberingType() &&
      82       11418 :             nFootnoteOffset == rInfo.nFootnoteOffset &&
      83       11414 :             m_bEndNote == rInfo.m_bEndNote &&
      84       17209 :             sPrefix == rInfo.sPrefix &&
      85       11502 :             sSuffix == rInfo.sSuffix;
      86             : }
      87             : 
      88        5834 : SwEndNoteInfo::SwEndNoteInfo(const SwEndNoteInfo& rInfo) :
      89        5834 :     SwClient( rInfo.GetFootnoteTextColl() ),
      90             :     aPageDescDep( this, 0 ),
      91             :     aCharFormatDep( this, 0 ),
      92             :     aAnchorCharFormatDep( this, 0 ),
      93             :     sPrefix( rInfo.sPrefix ),
      94             :     sSuffix( rInfo.sSuffix ),
      95             :     m_bEndNote( true ),
      96             :     aFormat( rInfo.aFormat ),
      97        5834 :     nFootnoteOffset( rInfo.nFootnoteOffset )
      98             : {
      99        5834 :     if( rInfo.aPageDescDep.GetRegisteredIn() )
     100         161 :         const_cast<SwModify*>(rInfo.aPageDescDep.GetRegisteredIn())->Add( &aPageDescDep );
     101             : 
     102        5834 :     if( rInfo.aCharFormatDep.GetRegisteredIn() )
     103         362 :         const_cast<SwModify*>(rInfo.aCharFormatDep.GetRegisteredIn())->Add( &aCharFormatDep );
     104             : 
     105        5834 :     if( rInfo.aAnchorCharFormatDep.GetRegisteredIn() )
     106         170 :         const_cast<SwModify*>(rInfo.aAnchorCharFormatDep.GetRegisteredIn())->Add(
     107         340 :                 &aAnchorCharFormatDep );
     108        5834 : }
     109             : 
     110        5917 : SwEndNoteInfo::SwEndNoteInfo(SwTextFormatColl *pFormat) :
     111             :     SwClient(pFormat),
     112             :     aPageDescDep( this, 0 ),
     113             :     aCharFormatDep( this, 0 ),
     114             :     aAnchorCharFormatDep( this, 0 ),
     115             :     m_bEndNote( true ),
     116        5917 :     nFootnoteOffset( 0 )
     117             : {
     118        5917 :     aFormat.SetNumberingType(SVX_NUM_ROMAN_LOWER);
     119        5917 : }
     120             : 
     121         116 : SwPageDesc *SwEndNoteInfo::GetPageDesc( SwDoc &rDoc ) const
     122             : {
     123         116 :     if ( !aPageDescDep.GetRegisteredIn() )
     124             :     {
     125          59 :         SwPageDesc *pDesc = rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool( static_cast<sal_uInt16>(
     126          59 :             m_bEndNote ? RES_POOLPAGE_ENDNOTE   : RES_POOLPAGE_FOOTNOTE ) );
     127          59 :         pDesc->Add( &const_cast<SwClient&>(static_cast<const SwClient&>(aPageDescDep)) );
     128             :     }
     129             : 
     130         116 :     return const_cast<SwPageDesc*>(static_cast<const SwPageDesc*>( aPageDescDep.GetRegisteredIn() ));
     131             : }
     132             : 
     133         148 : bool SwEndNoteInfo::KnowsPageDesc() const
     134             : {
     135         148 :     return (aPageDescDep.GetRegisteredIn() != 0);
     136             : }
     137             : 
     138       14774 : bool SwEndNoteInfo::DependsOn( const SwPageDesc* pDesc ) const
     139             : {
     140       14774 :     return ( aPageDescDep.GetRegisteredIn() == pDesc );
     141             : }
     142             : 
     143          20 : void SwEndNoteInfo::ChgPageDesc( SwPageDesc *pDesc )
     144             : {
     145          20 :     pDesc->Add( &static_cast<SwClient&>(aPageDescDep) );
     146          20 : }
     147             : 
     148           5 : void SwEndNoteInfo::SetFootnoteTextColl(SwTextFormatColl& rFormat)
     149             : {
     150           5 :     rFormat.Add(this);
     151           5 : }
     152             : 
     153         435 : SwCharFormat* SwEndNoteInfo::GetCharFormat(SwDoc &rDoc) const
     154             : {
     155         435 :     if ( !aCharFormatDep.GetRegisteredIn() )
     156             :     {
     157         156 :         SwCharFormat* pFormat = rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( static_cast<sal_uInt16>(
     158         156 :             m_bEndNote ? RES_POOLCHR_ENDNOTE : RES_POOLCHR_FOOTNOTE ) );
     159         156 :         pFormat->Add( &const_cast<SwClient&>(static_cast<const SwClient&>(aCharFormatDep)) );
     160             :     }
     161         435 :     return const_cast<SwCharFormat*>(static_cast<const SwCharFormat*>(aCharFormatDep.GetRegisteredIn()));
     162             : }
     163             : 
     164          40 : void SwEndNoteInfo::SetCharFormat( SwCharFormat* pChFormat )
     165             : {
     166             :     OSL_ENSURE(pChFormat, "no CharFormat?");
     167          40 :     pChFormat->Add( &static_cast<SwClient&>(aCharFormatDep) );
     168          40 : }
     169             : 
     170         463 : SwCharFormat* SwEndNoteInfo::GetAnchorCharFormat(SwDoc &rDoc) const
     171             : {
     172         463 :     if( !aAnchorCharFormatDep.GetRegisteredIn() )
     173             :     {
     174          59 :         SwCharFormat* pFormat = rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( static_cast<sal_uInt16>(
     175          59 :             m_bEndNote ? RES_POOLCHR_ENDNOTE_ANCHOR : RES_POOLCHR_FOOTNOTE_ANCHOR ) );
     176          59 :         pFormat->Add( &const_cast<SwClient&>(static_cast<const SwClient&>(aAnchorCharFormatDep)) );
     177             :     }
     178         463 :     return const_cast<SwCharFormat*>(static_cast<const SwCharFormat*>(aAnchorCharFormatDep.GetRegisteredIn()));
     179             : }
     180             : 
     181          18 : void SwEndNoteInfo::SetAnchorCharFormat( SwCharFormat* pChFormat )
     182             : {
     183             :     OSL_ENSURE(pChFormat, "no CharFormat?");
     184          18 :     pChFormat->Add( &static_cast<SwClient&>(aAnchorCharFormatDep) );
     185          18 : }
     186             : 
     187         533 : void SwEndNoteInfo::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
     188             : {
     189         533 :     const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ;
     190             : 
     191         533 :     if( RES_ATTRSET_CHG == nWhich ||
     192             :         RES_FMT_CHG == nWhich )
     193             :     {
     194             :         SwDoc* pDoc;
     195         496 :         if( aCharFormatDep.GetRegisteredIn() )
     196         496 :             pDoc = static_cast<SwFormat*>(aCharFormatDep.GetRegisteredIn())->GetDoc();
     197             :         else
     198           0 :             pDoc = static_cast<SwFormat*>(aAnchorCharFormatDep.GetRegisteredIn())->GetDoc();
     199         496 :         SwFootnoteIdxs& rFootnoteIdxs = pDoc->GetFootnoteIdxs();
     200         781 :         for( size_t nPos = 0; nPos < rFootnoteIdxs.size(); ++nPos )
     201             :         {
     202         285 :             SwTextFootnote *pTextFootnote = rFootnoteIdxs[ nPos ];
     203         285 :             const SwFormatFootnote &rFootnote = pTextFootnote->GetFootnote();
     204         285 :             if ( rFootnote.IsEndNote() == m_bEndNote )
     205             :             {
     206         220 :                 pTextFootnote->SetNumber(rFootnote.GetNumber(), rFootnote.GetNumStr());
     207             :             }
     208         496 :         }
     209             :     }
     210             :     else
     211          37 :         CheckRegistration( pOld, pNew );
     212         533 : }
     213             : 
     214          69 : SwFootnoteInfo& SwFootnoteInfo::operator=(const SwFootnoteInfo& rInfo)
     215             : {
     216          69 :     SwEndNoteInfo::operator=(rInfo);
     217          69 :     aQuoVadis =  rInfo.aQuoVadis;
     218          69 :     aErgoSum = rInfo.aErgoSum;
     219          69 :     ePos = rInfo.ePos;
     220          69 :     eNum = rInfo.eNum;
     221          69 :     return *this;
     222             : }
     223             : 
     224        3698 : bool SwFootnoteInfo::operator==( const SwFootnoteInfo& rInfo ) const
     225             : {
     226        7395 :     return  ePos == rInfo.ePos &&
     227        7379 :             eNum == rInfo.eNum &&
     228        7314 :             SwEndNoteInfo::operator==(rInfo) &&
     229       10961 :             aQuoVadis == rInfo.aQuoVadis &&
     230        7329 :             aErgoSum == rInfo.aErgoSum;
     231             : }
     232             : 
     233        3710 : SwFootnoteInfo::SwFootnoteInfo(const SwFootnoteInfo& rInfo) :
     234             :     SwEndNoteInfo( rInfo ),
     235             :     aQuoVadis( rInfo.aQuoVadis ),
     236             :     aErgoSum( rInfo.aErgoSum ),
     237             :     ePos( rInfo.ePos ),
     238        3710 :     eNum( rInfo.eNum )
     239             : {
     240        3710 :     m_bEndNote = false;
     241        3710 : }
     242             : 
     243        2959 : SwFootnoteInfo::SwFootnoteInfo(SwTextFormatColl *pFormat) :
     244             :     SwEndNoteInfo( pFormat ),
     245             :     ePos( FTNPOS_PAGE ),
     246        2959 :     eNum( FTNNUM_DOC )
     247             : {
     248        2959 :     aFormat.SetNumberingType(SVX_NUM_ARABIC);
     249        2959 :     m_bEndNote = false;
     250        2959 : }
     251             : 
     252        3698 : void SwDoc::SetFootnoteInfo(const SwFootnoteInfo& rInfo)
     253             : {
     254        3698 :     SwRootFrm* pTmpRoot = getIDocumentLayoutAccess().GetCurrentLayout();
     255        3698 :     if( !(GetFootnoteInfo() == rInfo) )
     256             :     {
     257          68 :         const SwFootnoteInfo &rOld = GetFootnoteInfo();
     258             : 
     259          68 :         if (GetIDocumentUndoRedo().DoesUndo())
     260             :         {
     261          13 :             GetIDocumentUndoRedo().AppendUndo( new SwUndoFootNoteInfo(rOld) );
     262             :         }
     263             : 
     264          68 :         bool bFootnotePos  = rInfo.ePos != rOld.ePos;
     265          68 :         bool bFootnoteDesc = rOld.ePos == FTNPOS_CHAPTER &&
     266          68 :                             rInfo.GetPageDesc( *this ) != rOld.GetPageDesc( *this );
     267         135 :         bool bExtra   = rInfo.aQuoVadis != rOld.aQuoVadis ||
     268         133 :                             rInfo.aErgoSum != rOld.aErgoSum ||
     269         131 :                             rInfo.aFormat.GetNumberingType() != rOld.aFormat.GetNumberingType() ||
     270         195 :                             rInfo.GetPrefix() != rOld.GetPrefix() ||
     271         130 :                             rInfo.GetSuffix() != rOld.GetSuffix();
     272          68 :         SwCharFormat *pOldChrFormat = rOld.GetCharFormat( *this ),
     273          68 :                   *pNewChrFormat = rInfo.GetCharFormat( *this );
     274          68 :         bool bFootnoteChrFormats = pOldChrFormat != pNewChrFormat;
     275             : 
     276          68 :         *mpFootnoteInfo = rInfo;
     277             : 
     278          68 :         if (pTmpRoot)
     279             :         {
     280          13 :             std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
     281          13 :             if ( bFootnotePos )
     282           1 :                 std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllRemoveFootnotes));
     283             :             else
     284             :             {
     285          12 :                 std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::UpdateFootnoteNums));
     286          12 :                 if ( bFootnoteDesc )
     287           0 :                     std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::CheckFootnotePageDescs), false));
     288          12 :                 if ( bExtra )
     289             :                 {
     290             :                     // For messages regarding ErgoSum etc. we save the extra code and use the
     291             :                     // available methods.
     292           7 :                     SwFootnoteIdxs& rFootnoteIdxs = GetFootnoteIdxs();
     293          12 :                     for( size_t nPos = 0; nPos < rFootnoteIdxs.size(); ++nPos )
     294             :                     {
     295           5 :                         SwTextFootnote *pTextFootnote = rFootnoteIdxs[ nPos ];
     296           5 :                         const SwFormatFootnote &rFootnote = pTextFootnote->GetFootnote();
     297           5 :                         if ( !rFootnote.IsEndNote() )
     298           5 :                             pTextFootnote->SetNumber(rFootnote.GetNumber(), rFootnote.GetNumStr());
     299             :                     }
     300             :                 }
     301          13 :             }
     302             :         }
     303          68 :         if( FTNNUM_PAGE != rInfo.eNum )
     304          58 :             GetFootnoteIdxs().UpdateAllFootnote();
     305          10 :         else if( bFootnoteChrFormats )
     306             :         {
     307           0 :             SwFormatChg aOld( pOldChrFormat );
     308           0 :             SwFormatChg aNew( pNewChrFormat );
     309           0 :             mpFootnoteInfo->ModifyNotification( &aOld, &aNew );
     310             :         }
     311             : 
     312             :         // #i81002# no update during loading
     313          68 :         if ( !IsInReading() )
     314             :         {
     315          13 :             getIDocumentFieldsAccess().UpdateRefFields(NULL);
     316             :         }
     317          68 :         getIDocumentState().SetModified();
     318             :     }
     319        3698 : }
     320             : 
     321        2117 : void SwDoc::SetEndNoteInfo(const SwEndNoteInfo& rInfo)
     322             : {
     323        2117 :     SwRootFrm* pTmpRoot = getIDocumentLayoutAccess().GetCurrentLayout();
     324        2117 :     if( !(GetEndNoteInfo() == rInfo) )
     325             :     {
     326          50 :         if(GetIDocumentUndoRedo().DoesUndo())
     327             :         {
     328           7 :             SwUndo *const pUndo( new SwUndoEndNoteInfo( GetEndNoteInfo() ) );
     329           7 :             GetIDocumentUndoRedo().AppendUndo(pUndo);
     330             :         }
     331             : 
     332          50 :         bool bNumChg  = rInfo.nFootnoteOffset != GetEndNoteInfo().nFootnoteOffset;
     333             :         // this seems to be an optimization: UpdateAllFootnote() is only called
     334             :         // if the offset changes; if the offset is the same,
     335             :         // but type/prefix/suffix changes, just set new numbers.
     336         121 :         bool const bExtra = !bNumChg &&
     337          48 :                 (   (rInfo.aFormat.GetNumberingType() !=
     338          48 :                         GetEndNoteInfo().aFormat.GetNumberingType())
     339          28 :                 ||  (rInfo.GetPrefix() != GetEndNoteInfo().GetPrefix())
     340          27 :                 ||  (rInfo.GetSuffix() != GetEndNoteInfo().GetSuffix())
     341          50 :                 );
     342          50 :         bool bFootnoteDesc = rInfo.GetPageDesc( *this ) !=
     343          50 :                             GetEndNoteInfo().GetPageDesc( *this );
     344          50 :         SwCharFormat *pOldChrFormat = GetEndNoteInfo().GetCharFormat( *this ),
     345          50 :                   *pNewChrFormat = rInfo.GetCharFormat( *this );
     346          50 :         bool bFootnoteChrFormats = pOldChrFormat != pNewChrFormat;
     347             : 
     348          50 :         *mpEndNoteInfo = rInfo;
     349             : 
     350          50 :         if ( pTmpRoot )
     351             :         {
     352           7 :             if ( bFootnoteDesc )
     353             :             {
     354           1 :                 std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
     355           1 :                 std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::CheckFootnotePageDescs), true));
     356             :             }
     357           7 :             if ( bExtra )
     358             :             {
     359             :                 // For messages regarding ErgoSum etc. we save the extra code and use the
     360             :                 // available methods.
     361           3 :                 SwFootnoteIdxs& rFootnoteIdxs = GetFootnoteIdxs();
     362           6 :                 for( size_t nPos = 0; nPos < rFootnoteIdxs.size(); ++nPos )
     363             :                 {
     364           3 :                     SwTextFootnote *pTextFootnote = rFootnoteIdxs[ nPos ];
     365           3 :                     const SwFormatFootnote &rFootnote = pTextFootnote->GetFootnote();
     366           3 :                     if ( rFootnote.IsEndNote() )
     367           3 :                         pTextFootnote->SetNumber(rFootnote.GetNumber(), rFootnote.GetNumStr());
     368             :                 }
     369             :             }
     370             :         }
     371          50 :         if( bNumChg )
     372           2 :             GetFootnoteIdxs().UpdateAllFootnote();
     373          48 :         else if( bFootnoteChrFormats )
     374             :         {
     375           1 :             SwFormatChg aOld( pOldChrFormat );
     376           2 :             SwFormatChg aNew( pNewChrFormat );
     377           2 :             mpEndNoteInfo->ModifyNotification( &aOld, &aNew );
     378             :         }
     379             : 
     380             :         // #i81002# no update during loading
     381          50 :         if ( !IsInReading() )
     382             :         {
     383           7 :             getIDocumentFieldsAccess().UpdateRefFields(NULL);
     384             :         }
     385          50 :         getIDocumentState().SetModified();
     386             :     }
     387        2117 : }
     388             : 
     389           2 : bool SwDoc::SetCurFootnote( const SwPaM& rPam, const OUString& rNumStr,
     390             :                        sal_uInt16 nNumber, bool bIsEndNote )
     391             : {
     392           2 :     SwFootnoteIdxs& rFootnoteArr = GetFootnoteIdxs();
     393           2 :     SwRootFrm* pTmpRoot = getIDocumentLayoutAccess().GetCurrentLayout();
     394             : 
     395           2 :     const SwPosition* pStt = rPam.Start(), *pEnd = rPam.End();
     396           2 :     const sal_uLong nSttNd = pStt->nNode.GetIndex();
     397           2 :     const sal_Int32 nSttCnt = pStt->nContent.GetIndex();
     398           2 :     const sal_uLong nEndNd = pEnd->nNode.GetIndex();
     399           2 :     const sal_Int32 nEndCnt = pEnd->nContent.GetIndex();
     400             : 
     401           2 :     size_t nPos = 0;
     402           2 :     rFootnoteArr.SeekEntry( pStt->nNode, &nPos );
     403             : 
     404           2 :     SwUndoChangeFootNote* pUndo = 0;
     405           2 :     if (GetIDocumentUndoRedo().DoesUndo())
     406             :     {
     407           2 :         GetIDocumentUndoRedo().ClearRedo(); // AppendUndo far below, so leave it
     408           2 :         pUndo = new SwUndoChangeFootNote( rPam, rNumStr, nNumber, bIsEndNote );
     409             :     }
     410             : 
     411             :     SwTextFootnote* pTextFootnote;
     412             :     sal_uLong nIdx;
     413           2 :     bool bChg = false;
     414           2 :     bool bTypeChgd = false;
     415           2 :     const size_t nPosSave = nPos;
     416          12 :     while( nPos < rFootnoteArr.size() &&
     417           4 :             (( nIdx = _SwTextFootnote_GetIndex((pTextFootnote = rFootnoteArr[ nPos++ ] )))
     418           4 :                 < nEndNd || ( nIdx == nEndNd &&
     419           2 :                 nEndCnt >= pTextFootnote->GetStart() )) )
     420           4 :         if( nIdx > nSttNd || ( nIdx == nSttNd &&
     421           2 :                 nSttCnt <= pTextFootnote->GetStart() ) )
     422             :         {
     423           2 :             const SwFormatFootnote& rFootnote = pTextFootnote->GetFootnote();
     424           2 :             if( rFootnote.GetNumStr() != rNumStr ||
     425           0 :                 rFootnote.IsEndNote() != bIsEndNote )
     426             :             {
     427           2 :                 bChg = true;
     428           2 :                 if ( pUndo )
     429             :                 {
     430           2 :                     pUndo->GetHistory().Add( *pTextFootnote );
     431             :                 }
     432             : 
     433           2 :                 pTextFootnote->SetNumber( nNumber, rNumStr );
     434           2 :                 if( rFootnote.IsEndNote() != bIsEndNote )
     435             :                 {
     436           0 :                     const_cast<SwFormatFootnote&>(rFootnote).SetEndNote( bIsEndNote );
     437           0 :                     bTypeChgd = true;
     438           0 :                     pTextFootnote->CheckCondColl();
     439             :                     //#i11339# dispose UNO wrapper when a footnote is changed to an endnote or vice versa
     440           0 :                     const_cast<SwFormatFootnote&>(rFootnote).InvalidateFootnote();
     441             :                 }
     442             :             }
     443             :         }
     444             : 
     445           2 :     nPos = nPosSave;       // There are more in the front!
     446           4 :     while( nPos &&
     447           0 :             (( nIdx = _SwTextFootnote_GetIndex((pTextFootnote = rFootnoteArr[ --nPos ] )))
     448           0 :                 > nSttNd || ( nIdx == nSttNd &&
     449           0 :                 nSttCnt <= pTextFootnote->GetStart() )) )
     450           0 :         if( nIdx < nEndNd || ( nIdx == nEndNd &&
     451           0 :             nEndCnt >= pTextFootnote->GetStart() ) )
     452             :         {
     453           0 :             const SwFormatFootnote& rFootnote = pTextFootnote->GetFootnote();
     454           0 :             if( rFootnote.GetNumStr() != rNumStr ||
     455           0 :                 rFootnote.IsEndNote() != bIsEndNote )
     456             :             {
     457           0 :                 bChg = true;
     458           0 :                 if ( pUndo )
     459             :                 {
     460           0 :                     pUndo->GetHistory().Add( *pTextFootnote );
     461             :                 }
     462             : 
     463           0 :                 pTextFootnote->SetNumber( nNumber, rNumStr );
     464           0 :                 if( rFootnote.IsEndNote() != bIsEndNote )
     465             :                 {
     466           0 :                     const_cast<SwFormatFootnote&>(rFootnote).SetEndNote( bIsEndNote );
     467           0 :                     bTypeChgd = true;
     468           0 :                     pTextFootnote->CheckCondColl();
     469             :                 }
     470             :             }
     471             :         }
     472             : 
     473             :     // Who needs to be triggered?
     474           2 :     if( bChg )
     475             :     {
     476           2 :         if( pUndo )
     477             :         {
     478           2 :             GetIDocumentUndoRedo().AppendUndo(pUndo);
     479             :         }
     480             : 
     481           2 :         if ( bTypeChgd )
     482           0 :             rFootnoteArr.UpdateAllFootnote();
     483           2 :         if( FTNNUM_PAGE != GetFootnoteInfo().eNum )
     484             :         {
     485           2 :             if ( !bTypeChgd )
     486           2 :                 rFootnoteArr.UpdateAllFootnote();
     487             :         }
     488           0 :         else if( pTmpRoot )
     489             :         {
     490           0 :             std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
     491           0 :             std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::UpdateFootnoteNums));
     492             :         }
     493           2 :         getIDocumentState().SetModified();
     494             :     }
     495             :     else
     496           0 :         delete pUndo;
     497           2 :     return bChg;
     498         177 : }
     499             : 
     500             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11