LCOV - code coverage report
Current view: top level - sw/source/core/undo - unattr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 136 547 24.9 %
Date: 2012-08-25 Functions: 31 69 44.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 110 635 17.3 %

           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                 :            : #include <UndoAttribute.hxx>
      30                 :            : #include <svl/itemiter.hxx>
      31                 :            : #include <editeng/tstpitem.hxx>
      32                 :            : #include <svx/svdmodel.hxx>
      33                 :            : #include <svx/svdpage.hxx>
      34                 :            : #include <hintids.hxx>
      35                 :            : #include <fmtflcnt.hxx>
      36                 :            : #include <txtftn.hxx>
      37                 :            : #include <fmtornt.hxx>
      38                 :            : #include <fmtanchr.hxx>
      39                 :            : #include <fmtfsize.hxx>
      40                 :            : #include <frmfmt.hxx>
      41                 :            : #include <fmtcntnt.hxx>
      42                 :            : #include <ftnidx.hxx>
      43                 :            : #include <doc.hxx>
      44                 :            : #include <IDocumentUndoRedo.hxx>
      45                 :            : #include <IShellCursorSupplier.hxx>
      46                 :            : #include <docary.hxx>
      47                 :            : #include <swundo.hxx>
      48                 :            : #include <pam.hxx>
      49                 :            : #include <ndtxt.hxx>
      50                 :            : #include <swtable.hxx>
      51                 :            : #include <swtblfmt.hxx>
      52                 :            : #include <UndoCore.hxx>
      53                 :            : #include <hints.hxx>
      54                 :            : #include <rolbck.hxx>
      55                 :            : #include <ndnotxt.hxx>
      56                 :            : #include <dcontact.hxx>
      57                 :            : #include <ftninfo.hxx>
      58                 :            : #include <redline.hxx>
      59                 :            : #include <section.hxx>
      60                 :            : #include <charfmt.hxx>
      61                 :            : #include <switerator.hxx>
      62                 :            : 
      63                 :        106 : SwUndoFmtAttrHelper::SwUndoFmtAttrHelper( SwFmt& rFmt, bool bSvDrwPt )
      64                 :            :     : SwClient( &rFmt )
      65                 :            :     , m_pUndo( 0 )
      66                 :        106 :     , m_bSaveDrawPt( bSvDrwPt )
      67                 :            : {
      68                 :        106 : }
      69                 :            : 
      70                 :        104 : void SwUndoFmtAttrHelper::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
      71                 :            : {
      72         [ +  - ]:        104 :     if( pOld )
      73                 :            :     {
      74         [ -  + ]:        104 :         if ( pOld->Which() == RES_OBJECTDYING )
      75                 :            :         {
      76                 :          0 :             CheckRegistration( pOld, pNew );
      77                 :            :         }
      78         [ +  - ]:        104 :         else if ( pNew )
      79                 :            :         {
      80         [ -  + ]:        104 :             if( POOLATTR_END >= pOld->Which() )
      81                 :            :             {
      82         [ #  # ]:          0 :                 if ( GetUndo() )
      83                 :            :                 {
      84                 :          0 :                     m_pUndo->PutAttr( *pOld );
      85                 :            :                 }
      86                 :            :                 else
      87                 :            :                 {
      88                 :            :                     m_pUndo.reset( new SwUndoFmtAttr( *pOld,
      89         [ #  # ]:          0 :                             *static_cast<SwFmt*>(GetRegisteredInNonConst()), m_bSaveDrawPt ) );
      90                 :            :                 }
      91                 :            :             }
      92         [ +  - ]:        104 :             else if ( RES_ATTRSET_CHG == pOld->Which() )
      93                 :            :             {
      94         [ -  + ]:        104 :                 if ( GetUndo() )
      95                 :            :                 {
      96                 :            :                     SfxItemIter aIter(
      97         [ #  # ]:          0 :                             *(static_cast<const SwAttrSetChg*>(pOld))->GetChgSet() );
      98                 :          0 :                     const SfxPoolItem* pItem = aIter.GetCurItem();
      99         [ #  # ]:          0 :                     while ( pItem )
     100                 :            :                     {
     101         [ #  # ]:          0 :                         m_pUndo->PutAttr( *pItem );
     102         [ #  # ]:          0 :                         if( aIter.IsAtEnd() )
     103                 :          0 :                             break;
     104         [ #  # ]:          0 :                         pItem = aIter.NextItem();
     105         [ #  # ]:          0 :                     }
     106                 :            :                 }
     107                 :            :                 else
     108                 :            :                 {
     109                 :            :                     m_pUndo.reset( new SwUndoFmtAttr(
     110                 :        104 :                             *static_cast<const SwAttrSetChg*>(pOld)->GetChgSet(),
     111         [ +  - ]:        104 :                             *static_cast<SwFmt*>(GetRegisteredInNonConst()), m_bSaveDrawPt ) );
     112                 :            :                 }
     113                 :            :             }
     114                 :            :         }
     115                 :            :     }
     116                 :        104 : }
     117                 :            : 
     118                 :        402 : SwUndoFmtAttr::SwUndoFmtAttr( const SfxItemSet& rOldSet,
     119                 :            :                               SwFmt& rChgFmt,
     120                 :            :                               bool bSaveDrawPt )
     121                 :            :     : SwUndo( UNDO_INSFMTATTR )
     122                 :            :     , m_pFmt( &rChgFmt )
     123                 :            :       // #i56253#
     124         [ +  - ]:        402 :     , m_pOldSet( new SfxItemSet( rOldSet ) )
     125                 :            :     , m_nNodeIndex( 0 )
     126                 :        402 :     , m_nFmtWhich( rChgFmt.Which() )
     127         [ +  - ]:        804 :     , m_bSaveDrawPt( bSaveDrawPt )
     128                 :            : {
     129         [ +  - ]:        402 :     Init();
     130                 :        402 : }
     131                 :            : 
     132                 :          0 : SwUndoFmtAttr::SwUndoFmtAttr( const SfxPoolItem& rItem, SwFmt& rChgFmt,
     133                 :            :                               bool bSaveDrawPt )
     134                 :            :     : SwUndo( UNDO_INSFMTATTR )
     135                 :            :     , m_pFmt( &rChgFmt )
     136                 :          0 :     , m_pOldSet( m_pFmt->GetAttrSet().Clone( sal_False ) )
     137                 :            :     , m_nNodeIndex( 0 )
     138                 :          0 :     , m_nFmtWhich( rChgFmt.Which() )
     139         [ #  # ]:          0 :     , m_bSaveDrawPt( bSaveDrawPt )
     140                 :            : {
     141         [ #  # ]:          0 :     m_pOldSet->Put( rItem );
     142         [ #  # ]:          0 :     Init();
     143                 :          0 : }
     144                 :            : 
     145                 :        402 : void SwUndoFmtAttr::Init()
     146                 :            : {
     147                 :            :     // treat change of anchor specially
     148         [ +  + ]:        402 :     if ( SFX_ITEM_SET == m_pOldSet->GetItemState( RES_ANCHOR, sal_False ))
     149                 :            :     {
     150                 :          6 :         SaveFlyAnchor( m_bSaveDrawPt );
     151                 :            :     }
     152         [ +  + ]:        396 :     else if ( RES_FRMFMT == m_nFmtWhich )
     153                 :            :     {
     154                 :         96 :         SwDoc* pDoc = m_pFmt->GetDoc();
     155         [ +  + ]:         96 :         if ( pDoc->GetTblFrmFmts()->Contains(static_cast<const SwFrmFmt*>(m_pFmt)))
     156                 :            :         {
     157                 :            :             // Table Format: save table position, table formats are volatile!
     158                 :         46 :             SwTable * pTbl = SwIterator<SwTable,SwFmt>::FirstElement( *m_pFmt );
     159         [ +  - ]:         46 :             if ( pTbl )
     160                 :            :             {
     161                 :         46 :                 m_nNodeIndex = pTbl->GetTabSortBoxes()[ 0 ]->GetSttNd()
     162                 :         46 :                     ->FindTableNode()->GetIndex();
     163                 :            :             }
     164                 :            :         }
     165         [ -  + ]:         50 :         else if ( pDoc->GetSections().Contains(static_cast<const SwSectionFmt*>(m_pFmt)))
     166                 :            :         {
     167                 :          0 :             m_nNodeIndex = m_pFmt->GetCntnt().GetCntntIdx()->GetIndex();
     168                 :            :         }
     169 [ +  - ][ +  + ]:         50 :         else if ( 0 != dynamic_cast< SwTableBoxFmt* >( m_pFmt ) )
                 [ +  + ]
     170                 :            :         {
     171                 :          4 :             SwTableBox * pTblBox = SwIterator<SwTableBox,SwFmt>::FirstElement( *m_pFmt );
     172         [ +  - ]:          4 :             if ( pTblBox )
     173                 :            :             {
     174                 :          4 :                 m_nNodeIndex = pTblBox->GetSttIdx();
     175                 :            :             }
     176                 :            :         }
     177                 :            :     }
     178                 :        402 : }
     179                 :            : 
     180         [ +  - ]:        402 : SwUndoFmtAttr::~SwUndoFmtAttr()
     181                 :            : {
     182         [ -  + ]:        804 : }
     183                 :            : 
     184                 :          4 : void SwUndoFmtAttr::UndoImpl(::sw::UndoRedoContext & rContext)
     185                 :            : {
     186                 :            :     // OD 2004-10-26 #i35443#
     187                 :            :     // Important note: <Undo(..)> also called by <ReDo(..)>
     188                 :            : 
     189 [ +  - ][ +  - ]:          4 :     if ( !m_pOldSet.get() || !m_pFmt || !IsFmtInDoc( &rContext.GetDoc() ))
         [ -  + ][ -  + ]
     190                 :          4 :         return;
     191                 :            : 
     192                 :            :     // #i35443# - If anchor attribute has been successfull
     193                 :            :     // restored, all other attributes are also restored.
     194                 :            :     // Thus, keep track of its restoration
     195                 :          4 :     bool bAnchorAttrRestored( false );
     196         [ -  + ]:          4 :     if ( SFX_ITEM_SET == m_pOldSet->GetItemState( RES_ANCHOR, sal_False ))
     197                 :            :     {
     198                 :          0 :         bAnchorAttrRestored = RestoreFlyAnchor(rContext);
     199         [ #  # ]:          0 :         if ( bAnchorAttrRestored )
     200                 :            :         {
     201                 :            :             // Anchor attribute successfull restored.
     202                 :            :             // Thus, keep anchor position for redo
     203                 :          0 :             SaveFlyAnchor();
     204                 :            :         }
     205                 :            :         else
     206                 :            :         {
     207                 :            :             // Anchor attribute not restored due to invalid anchor position.
     208                 :            :             // Thus, delete anchor attribute.
     209                 :          0 :             m_pOldSet->ClearItem( RES_ANCHOR );
     210                 :            :         }
     211                 :            :     }
     212                 :            : 
     213         [ +  - ]:          4 :     if ( !bAnchorAttrRestored )
     214                 :            :     {
     215         [ +  - ]:          4 :         SwUndoFmtAttrHelper aTmp( *m_pFmt, m_bSaveDrawPt );
     216         [ +  - ]:          4 :         m_pFmt->SetFmtAttr( *m_pOldSet );
     217         [ +  - ]:          4 :         if ( aTmp.GetUndo() )
     218                 :            :         {
     219                 :            :             // transfer ownership of helper object's old set
     220                 :          4 :             m_pOldSet = aTmp.GetUndo()->m_pOldSet;
     221                 :            :         }
     222                 :            :         else
     223                 :            :         {
     224         [ #  # ]:          0 :             m_pOldSet->ClearItem();
     225                 :            :         }
     226                 :            : 
     227 [ +  - ][ -  + ]:          4 :         if ( RES_FLYFRMFMT == m_nFmtWhich || RES_DRAWFRMFMT == m_nFmtWhich )
     228                 :            :         {
     229                 :          0 :             rContext.SetSelections(static_cast<SwFrmFmt*>(m_pFmt), 0);
     230         [ +  - ]:          4 :         }
     231                 :            :     }
     232                 :            : }
     233                 :            : 
     234                 :          4 : bool SwUndoFmtAttr::IsFmtInDoc( SwDoc* pDoc )
     235                 :            : {
     236                 :            :     // search for the Format in the Document; if it does not exist any more,
     237                 :            :     // the attribute is not restored!
     238                 :          4 :     sal_uInt16 nPos = USHRT_MAX;
     239   [ -  -  -  +  :          4 :     switch ( m_nFmtWhich )
                   -  - ]
     240                 :            :     {
     241                 :            :         case RES_TXTFMTCOLL:
     242                 :            :             nPos = pDoc->GetTxtFmtColls()->GetPos(
     243                 :          0 :                     static_cast<const SwTxtFmtColl*>(m_pFmt) );
     244                 :          0 :             break;
     245                 :            : 
     246                 :            :         case RES_GRFFMTCOLL:
     247                 :            :             nPos = pDoc->GetGrfFmtColls()->GetPos(
     248                 :          0 :                     static_cast<const SwGrfFmtColl*>(m_pFmt) );
     249                 :          0 :             break;
     250                 :            : 
     251                 :            :         case RES_CHRFMT:
     252                 :            :             nPos = pDoc->GetCharFmts()->GetPos(
     253                 :          0 :                     static_cast<SwCharFmt*>(m_pFmt) );
     254                 :          0 :             break;
     255                 :            : 
     256                 :            :         case RES_FRMFMT:
     257 [ +  - ][ +  - ]:          4 :             if ( m_nNodeIndex && (m_nNodeIndex < pDoc->GetNodes().Count()) )
                 [ +  - ]
     258                 :            :             {
     259                 :          4 :                 SwNode* pNd = pDoc->GetNodes()[ m_nNodeIndex ];
     260         [ +  + ]:          4 :                 if ( pNd->IsTableNode() )
     261                 :            :                 {
     262                 :            :                     m_pFmt =
     263                 :          2 :                         static_cast<SwTableNode*>(pNd)->GetTable().GetFrmFmt();
     264                 :          2 :                     nPos = 0;
     265                 :          2 :                     break;
     266                 :            :                 }
     267         [ -  + ]:          2 :                 else if ( pNd->IsSectionNode() )
     268                 :            :                 {
     269                 :            :                     m_pFmt =
     270                 :          0 :                         static_cast<SwSectionNode*>(pNd)->GetSection().GetFmt();
     271                 :          0 :                     nPos = 0;
     272                 :          0 :                     break;
     273                 :            :                 }
     274   [ +  -  +  - ]:          4 :                 else if ( pNd->IsStartNode() && (SwTableBoxStartNode ==
                 [ +  - ]
     275                 :          2 :                     static_cast< SwStartNode* >(pNd)->GetStartNodeType()) )
     276                 :            :                 {
     277                 :          2 :                     SwTableNode* pTblNode = pNd->FindTableNode();
     278         [ +  - ]:          2 :                     if ( pTblNode )
     279                 :            :                     {
     280                 :            :                         SwTableBox* pBox =
     281                 :          2 :                             pTblNode->GetTable().GetTblBox( m_nNodeIndex );
     282         [ +  - ]:          2 :                         if ( pBox )
     283                 :            :                         {
     284                 :          2 :                             m_pFmt = pBox->GetFrmFmt();
     285                 :          2 :                             nPos = 0;
     286                 :          2 :                             break;
     287                 :            :                         }
     288                 :            :                     }
     289                 :            :                 }
     290                 :            :             }
     291                 :            :             // no break!
     292                 :            :         case RES_DRAWFRMFMT:
     293                 :            :         case RES_FLYFRMFMT:
     294                 :            :             nPos = pDoc->GetSpzFrmFmts()->GetPos(
     295                 :          0 :                     static_cast<const SwFrmFmt*>(m_pFmt) );
     296         [ #  # ]:          0 :             if ( USHRT_MAX == nPos )
     297                 :            :             {
     298                 :            :                 nPos = pDoc->GetFrmFmts()->GetPos(
     299                 :          0 :                     static_cast<const SwFrmFmt*>(m_pFmt) );
     300                 :            :             }
     301                 :          0 :             break;
     302                 :            :     }
     303                 :            : 
     304         [ -  + ]:          4 :     if ( USHRT_MAX == nPos )
     305                 :            :     {
     306                 :            :         // Format does not exist; reset
     307                 :          0 :         m_pFmt = 0;
     308                 :            :     }
     309                 :            : 
     310                 :          4 :     return 0 != m_pFmt;
     311                 :            : }
     312                 :            : 
     313                 :            : // Check if it is still in Doc
     314                 :          0 : SwFmt* SwUndoFmtAttr::GetFmt( SwDoc& rDoc )
     315                 :            : {
     316 [ #  # ][ #  # ]:          0 :     return m_pFmt && IsFmtInDoc( &rDoc ) ? m_pFmt : 0;
     317                 :            : }
     318                 :            : 
     319                 :          0 : void SwUndoFmtAttr::RedoImpl(::sw::UndoRedoContext & rContext)
     320                 :            : {
     321                 :            :     // #i35443# - Because the undo stores the attributes for
     322                 :            :     // redo, the same code as for <Undo(..)> can be applied for <Redo(..)>
     323                 :          0 :     UndoImpl(rContext);
     324                 :          0 : }
     325                 :            : 
     326                 :          0 : void SwUndoFmtAttr::RepeatImpl(::sw::RepeatContext & rContext)
     327                 :            : {
     328         [ #  # ]:          0 :     if ( !m_pOldSet.get() )
     329                 :          0 :         return;
     330                 :            : 
     331                 :          0 :     SwDoc & rDoc(rContext.GetDoc());
     332                 :            : 
     333   [ #  #  #  # ]:          0 :     switch ( m_nFmtWhich )
     334                 :            :     {
     335                 :            :     case RES_GRFFMTCOLL:
     336                 :            :         {
     337                 :            :             SwNoTxtNode *const pNd =
     338                 :          0 :                 rContext.GetRepeatPaM().GetNode()->GetNoTxtNode();
     339         [ #  # ]:          0 :             if( pNd )
     340                 :            :             {
     341                 :          0 :                 rDoc.SetAttr( m_pFmt->GetAttrSet(), *pNd->GetFmtColl() );
     342                 :            :             }
     343                 :            :         }
     344                 :          0 :         break;
     345                 :            : 
     346                 :            :     case RES_TXTFMTCOLL:
     347                 :            :         {
     348                 :            :             SwTxtNode *const pNd =
     349                 :          0 :                 rContext.GetRepeatPaM().GetNode()->GetTxtNode();
     350         [ #  # ]:          0 :             if( pNd )
     351                 :            :             {
     352                 :          0 :                 rDoc.SetAttr( m_pFmt->GetAttrSet(), *pNd->GetFmtColl() );
     353                 :            :             }
     354                 :            :         }
     355                 :          0 :         break;
     356                 :            : 
     357                 :            :     case RES_FLYFRMFMT:
     358                 :            :         {
     359                 :            :             // Check if the cursor is in a flying frame
     360                 :            :             // Steps: search in all FlyFrmFormats for the FlyCntnt attribute
     361                 :            :             // and validate if the cursor is in the respective section
     362                 :            :             SwFrmFmt *const pFly =
     363                 :          0 :                 rContext.GetRepeatPaM().GetNode()->GetFlyFmt();
     364         [ #  # ]:          0 :             if( pFly )
     365                 :            :             {
     366                 :            :                 // Bug 43672: do not set all attributes!
     367         [ #  # ]:          0 :                 if (SFX_ITEM_SET ==
     368                 :          0 :                         m_pFmt->GetAttrSet().GetItemState( RES_CNTNT ))
     369                 :            :                 {
     370         [ #  # ]:          0 :                     SfxItemSet aTmpSet( m_pFmt->GetAttrSet() );
     371         [ #  # ]:          0 :                     aTmpSet.ClearItem( RES_CNTNT );
     372         [ #  # ]:          0 :                     if( aTmpSet.Count() )
     373                 :            :                     {
     374         [ #  # ]:          0 :                         rDoc.SetAttr( aTmpSet, *pFly );
     375         [ #  # ]:          0 :                     }
     376                 :            :                 }
     377                 :            :                 else
     378                 :            :                 {
     379                 :          0 :                     rDoc.SetAttr( m_pFmt->GetAttrSet(), *pFly );
     380                 :            :                 }
     381                 :            :             }
     382                 :          0 :             break;
     383                 :            :         }
     384                 :            :     }
     385                 :            : }
     386                 :            : 
     387                 :        398 : SwRewriter SwUndoFmtAttr::GetRewriter() const
     388                 :            : {
     389                 :        398 :     SwRewriter aRewriter;
     390                 :            : 
     391         [ +  - ]:        398 :     if (m_pFmt)
     392                 :            :     {
     393         [ +  - ]:        398 :         aRewriter.AddRule(UndoArg1, m_pFmt->GetName());
     394                 :            :     }
     395                 :            : 
     396                 :        398 :     return aRewriter;
     397                 :            : }
     398                 :            : 
     399                 :          0 : void SwUndoFmtAttr::PutAttr( const SfxPoolItem& rItem )
     400                 :            : {
     401                 :          0 :     m_pOldSet->Put( rItem );
     402         [ #  # ]:          0 :     if ( RES_ANCHOR == rItem.Which() )
     403                 :            :     {
     404                 :          0 :         SaveFlyAnchor( m_bSaveDrawPt );
     405                 :            :     }
     406                 :          0 : }
     407                 :            : 
     408                 :          6 : void SwUndoFmtAttr::SaveFlyAnchor( bool bSvDrwPt )
     409                 :            : {
     410                 :            :     // Format is valid, otherwise you would not reach this point here
     411         [ +  - ]:          6 :     if( bSvDrwPt )
     412                 :            :     {
     413         [ -  + ]:          6 :         if ( RES_DRAWFRMFMT == m_pFmt->Which() )
     414                 :            :         {
     415         [ #  # ]:          0 :             Point aPt( static_cast<SwFrmFmt*>(m_pFmt)->FindSdrObject()
     416         [ #  # ]:          0 :                             ->GetRelativePos() );
     417                 :            :             // store old value as attribute, to keep SwUndoFmtAttr small
     418 [ #  # ][ #  # ]:          0 :             m_pOldSet->Put( SwFmtFrmSize( ATT_VAR_SIZE, aPt.X(), aPt.Y() ) );
                 [ #  # ]
     419                 :            :         }
     420                 :            :     }
     421                 :            : 
     422                 :            :     const SwFmtAnchor& rAnchor =
     423         [ +  - ]:          6 :         static_cast<const SwFmtAnchor&>( m_pOldSet->Get( RES_ANCHOR, sal_False ) );
     424 [ +  - ][ +  + ]:          6 :     if( !rAnchor.GetCntntAnchor() )
     425                 :            :         return;
     426                 :            : 
     427                 :          4 :     xub_StrLen nCntnt = 0;
     428      [ -  +  - ]:          4 :     switch( rAnchor.GetAnchorId() )
     429                 :            :     {
     430                 :            :     case FLY_AS_CHAR:
     431                 :            :     case FLY_AT_CHAR:
     432         [ #  # ]:          0 :         nCntnt = rAnchor.GetCntntAnchor()->nContent.GetIndex();
     433                 :            :     case FLY_AT_PARA:
     434                 :            :     case FLY_AT_FLY:
     435         [ +  - ]:          4 :         m_nNodeIndex = rAnchor.GetCntntAnchor()->nNode.GetIndex();
     436                 :          4 :         break;
     437                 :            :     default:
     438                 :            :         return;
     439                 :            :     }
     440                 :            : 
     441         [ +  - ]:          4 :     SwFmtAnchor aAnchor( rAnchor.GetAnchorId(), nCntnt );
     442 [ +  - ][ +  - ]:          6 :     m_pOldSet->Put( aAnchor );
     443                 :            : }
     444                 :            : 
     445                 :            : // #i35443# - Add return value, type <bool>.
     446                 :            : // Return value indicates, if anchor attribute is restored.
     447                 :            : // Note: If anchor attribute is restored, all other existing attributes
     448                 :            : //       are also restored.
     449                 :          0 : bool SwUndoFmtAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext)
     450                 :            : {
     451                 :          0 :     SwDoc *const pDoc = & rContext.GetDoc();
     452                 :          0 :     SwFlyFrmFmt* pFrmFmt = static_cast<SwFlyFrmFmt*>(m_pFmt);
     453                 :            :     const SwFmtAnchor& rAnchor =
     454         [ #  # ]:          0 :         static_cast<const SwFmtAnchor&>( m_pOldSet->Get( RES_ANCHOR, sal_False ) );
     455                 :            : 
     456         [ #  # ]:          0 :     SwFmtAnchor aNewAnchor( rAnchor.GetAnchorId() );
     457         [ #  # ]:          0 :     if (FLY_AT_PAGE != rAnchor.GetAnchorId())
     458                 :            :     {
     459 [ #  # ][ #  # ]:          0 :         SwNode* pNd = pDoc->GetNodes()[ m_nNodeIndex  ];
     460                 :            : 
     461   [ #  #  #  #  :          0 :         if (  (FLY_AT_FLY == rAnchor.GetAnchorId())
           #  # ][ #  # ]
     462                 :          0 :             ? ( !pNd->IsStartNode() || (SwFlyStartNode !=
     463                 :          0 :                     static_cast<SwStartNode*>(pNd)->GetStartNodeType()) )
     464                 :          0 :             : !pNd->IsTxtNode() )
     465                 :            :         {
     466                 :            :             // #i35443# - invalid position.
     467                 :            :             // Thus, anchor attribute not restored
     468                 :          0 :             return false;
     469                 :            :         }
     470                 :            : 
     471         [ #  # ]:          0 :         SwPosition aPos( *pNd );
     472   [ #  #  #  # ]:          0 :         if ((FLY_AS_CHAR == rAnchor.GetAnchorId()) ||
                 [ #  # ]
     473                 :          0 :             (FLY_AT_CHAR == rAnchor.GetAnchorId()))
     474                 :            :         {
     475 [ #  # ][ #  # ]:          0 :             aPos.nContent.Assign( (SwTxtNode*)pNd, rAnchor.GetPageNum() );
         [ #  # ][ #  # ]
     476         [ #  # ]:          0 :             if ( aPos.nContent.GetIndex() >
     477         [ #  # ]:          0 :                     static_cast<SwTxtNode*>(pNd)->GetTxt().Len() )
     478                 :            :             {
     479                 :            :                 // #i35443# - invalid position.
     480                 :            :                 // Thus, anchor attribute not restored
     481                 :          0 :                 return false;
     482                 :            :             }
     483                 :            :         }
     484 [ #  # ][ #  # ]:          0 :         aNewAnchor.SetAnchor( &aPos );
                 [ #  # ]
     485                 :            :     }
     486                 :            :     else
     487                 :          0 :         aNewAnchor.SetPageNum( rAnchor.GetPageNum() );
     488                 :            : 
     489                 :          0 :     Point aDrawSavePt, aDrawOldPt;
     490 [ #  # ][ #  # ]:          0 :     if( pDoc->GetCurrentViewShell() )   //swmod 071108//swmod 071225
     491                 :            :     {
     492         [ #  # ]:          0 :         if( RES_DRAWFRMFMT == pFrmFmt->Which() )
     493                 :            :         {
     494                 :            :             // get the old cached value
     495                 :            :             const SwFmtFrmSize& rOldSize = static_cast<const SwFmtFrmSize&>(
     496         [ #  # ]:          0 :                     m_pOldSet->Get( RES_FRM_SIZE ) );
     497                 :          0 :             aDrawSavePt.X() = rOldSize.GetWidth();
     498                 :          0 :             aDrawSavePt.Y() = rOldSize.GetHeight();
     499         [ #  # ]:          0 :             m_pOldSet->ClearItem( RES_FRM_SIZE );
     500                 :            : 
     501                 :            :             // write the current value into cache
     502 [ #  # ][ #  # ]:          0 :             aDrawOldPt = pFrmFmt->FindSdrObject()->GetRelativePos();
     503                 :            :         }
     504                 :            :         else
     505                 :            :         {
     506         [ #  # ]:          0 :             pFrmFmt->DelFrms();         // delete Frms
     507                 :            :         }
     508                 :            :     }
     509                 :            : 
     510         [ #  # ]:          0 :     const SwFmtAnchor &rOldAnch = pFrmFmt->GetAnchor();
     511                 :            :     // #i54336#
     512                 :            :     // Consider case, that as-character anchored object has moved its anchor position.
     513         [ #  # ]:          0 :     if (FLY_AS_CHAR == rOldAnch.GetAnchorId())
     514                 :            :     {
     515                 :            :         // With InCntnts it's tricky: the text attribute needs to be deleted.
     516                 :            :         // Unfortunately, this not only destroys the Frms but also the format.
     517                 :            :         // To prevent that, first detach the connection between attribute and
     518                 :            :         // format.
     519         [ #  # ]:          0 :         const SwPosition *pPos = rOldAnch.GetCntntAnchor();
     520         [ #  # ]:          0 :         SwTxtNode *pTxtNode = (SwTxtNode*)&pPos->nNode.GetNode();
     521                 :            :         OSL_ENSURE( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." );
     522                 :          0 :         const xub_StrLen nIdx = pPos->nContent.GetIndex();
     523                 :            :         SwTxtAttr * const pHnt =
     524         [ #  # ]:          0 :             pTxtNode->GetTxtAttrForCharAt( nIdx, RES_TXTATR_FLYCNT );
     525                 :            :         OSL_ENSURE( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT,
     526                 :            :                     "Missing FlyInCnt-Hint." );
     527                 :            :         OSL_ENSURE( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFrmFmt,
     528                 :            :                     "Wrong TxtFlyCnt-Hint." );
     529                 :          0 :         const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt();
     530                 :            : 
     531                 :            :         // Connection is now detached, therefore the attribute can be deleted
     532         [ #  # ]:          0 :         pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx );
     533                 :            :     }
     534                 :            : 
     535                 :            :     {
     536         [ #  # ]:          0 :         m_pOldSet->Put( aNewAnchor );
     537         [ #  # ]:          0 :         SwUndoFmtAttrHelper aTmp( *m_pFmt, m_bSaveDrawPt );
     538         [ #  # ]:          0 :         m_pFmt->SetFmtAttr( *m_pOldSet );
     539         [ #  # ]:          0 :         if ( aTmp.GetUndo() )
     540                 :            :         {
     541                 :          0 :             m_nNodeIndex = aTmp.GetUndo()->m_nNodeIndex;
     542                 :            :             // transfer ownership of helper object's old set
     543                 :          0 :             m_pOldSet = aTmp.GetUndo()->m_pOldSet;
     544                 :            :         }
     545                 :            :         else
     546                 :            :         {
     547         [ #  # ]:          0 :             m_pOldSet->ClearItem();
     548         [ #  # ]:          0 :         }
     549                 :            :     }
     550                 :            : 
     551         [ #  # ]:          0 :     if ( RES_DRAWFRMFMT == pFrmFmt->Which() )
     552                 :            :     {
     553                 :            :         SwDrawContact *pCont =
     554         [ #  # ]:          0 :             static_cast<SwDrawContact*>(pFrmFmt->FindContactObj());
     555                 :            :         // The Draw model also prepared an Undo object for its right positioning
     556                 :            :         // which unfortunately is relative. Therefore block here a position
     557                 :            :         // change of the Contact object by setting the anchor.
     558         [ #  # ]:          0 :         SdrObject* pObj = pCont->GetMaster();
     559                 :            : 
     560 [ #  # ][ #  # ]:          0 :         if( pCont->GetAnchorFrm() && !pObj->IsInserted() )
         [ #  # ][ #  # ]
                 [ #  # ]
     561                 :            :         {
     562                 :            :             OSL_ENSURE( pDoc->GetDrawModel(), "RestoreFlyAnchor without DrawModel" );
     563 [ #  # ][ #  # ]:          0 :             pDoc->GetDrawModel()->GetPage( 0 )->InsertObject( pObj );
                 [ #  # ]
     564                 :            :         }
     565         [ #  # ]:          0 :         pObj->SetRelativePos( aDrawSavePt );
     566                 :            : 
     567                 :            :         // cache the old value again
     568                 :            :         m_pOldSet->Put(
     569 [ #  # ][ #  # ]:          0 :             SwFmtFrmSize( ATT_VAR_SIZE, aDrawOldPt.X(), aDrawOldPt.Y() ) );
                 [ #  # ]
     570                 :            :     }
     571                 :            : 
     572         [ #  # ]:          0 :     if (FLY_AS_CHAR == aNewAnchor.GetAnchorId())
     573                 :            :     {
     574         [ #  # ]:          0 :         const SwPosition* pPos = aNewAnchor.GetCntntAnchor();
     575                 :          0 :         SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode();
     576                 :            :         OSL_ENSURE( pTxtNd, "no Text Node at position." );
     577         [ #  # ]:          0 :         SwFmtFlyCnt aFmt( pFrmFmt );
     578 [ #  # ][ #  # ]:          0 :         pTxtNd->InsertItem( aFmt, pPos->nContent.GetIndex(), 0 );
     579                 :            :     }
     580                 :            : 
     581                 :            : 
     582         [ #  # ]:          0 :     if( RES_DRAWFRMFMT != pFrmFmt->Which() )
     583         [ #  # ]:          0 :         pFrmFmt->MakeFrms();
     584                 :            : 
     585                 :          0 :     rContext.SetSelections(pFrmFmt, 0);
     586                 :            : 
     587                 :            :     // #i35443# - anchor attribute restored.
     588         [ #  # ]:          0 :     return true;
     589                 :            : }
     590                 :            : 
     591                 :          0 : SwUndoFmtResetAttr::SwUndoFmtResetAttr( SwFmt& rChangedFormat,
     592                 :            :                                         const sal_uInt16 nWhichId )
     593                 :            :     : SwUndo( UNDO_RESETATTR )
     594                 :            :     , m_pChangedFormat( &rChangedFormat )
     595                 :            :     , m_nWhichId( nWhichId )
     596                 :          0 :     , m_pOldItem( 0 )
     597                 :            : {
     598                 :          0 :     const SfxPoolItem* pItem = 0;
     599 [ #  # ][ #  # ]:          0 :     if (rChangedFormat.GetItemState( nWhichId, sal_False, &pItem ) == SFX_ITEM_SET)
     600                 :            :     {
     601         [ #  # ]:          0 :         m_pOldItem.reset( pItem->Clone() );
     602                 :            :     }
     603                 :          0 : }
     604                 :            : 
     605         [ #  # ]:          0 : SwUndoFmtResetAttr::~SwUndoFmtResetAttr()
     606                 :            : {
     607         [ #  # ]:          0 : }
     608                 :            : 
     609                 :          0 : void SwUndoFmtResetAttr::UndoImpl(::sw::UndoRedoContext &)
     610                 :            : {
     611         [ #  # ]:          0 :     if ( m_pOldItem.get() )
     612                 :            :     {
     613                 :          0 :         m_pChangedFormat->SetFmtAttr( *m_pOldItem );
     614                 :            :     }
     615                 :          0 : }
     616                 :            : 
     617                 :          0 : void SwUndoFmtResetAttr::RedoImpl(::sw::UndoRedoContext &)
     618                 :            : {
     619         [ #  # ]:          0 :     if ( m_pOldItem.get() )
     620                 :            :     {
     621                 :          0 :         m_pChangedFormat->ResetFmtAttr( m_nWhichId );
     622                 :            :     }
     623                 :          0 : }
     624                 :            : 
     625                 :         10 : SwUndoResetAttr::SwUndoResetAttr( const SwPaM& rRange, sal_uInt16 nFmtId )
     626                 :            :     : SwUndo( UNDO_RESETATTR ), SwUndRng( rRange )
     627         [ +  - ]:         10 :     , m_pHistory( new SwHistory )
     628 [ +  - ][ +  - ]:         20 :     , m_nFormatId( nFmtId )
                 [ +  - ]
     629                 :            : {
     630                 :         10 : }
     631                 :            : 
     632                 :         10 : SwUndoResetAttr::SwUndoResetAttr( const SwPosition& rPos, sal_uInt16 nFmtId )
     633                 :            :     : SwUndo( UNDO_RESETATTR )
     634         [ +  - ]:         10 :     , m_pHistory( new SwHistory )
     635 [ +  - ][ +  - ]:         20 :     , m_nFormatId( nFmtId )
                 [ +  - ]
     636                 :            : {
     637                 :         10 :     nSttNode = nEndNode = rPos.nNode.GetIndex();
     638                 :         10 :     nSttCntnt = nEndCntnt = rPos.nContent.GetIndex();
     639                 :         10 : }
     640                 :            : 
     641         [ +  - ]:         20 : SwUndoResetAttr::~SwUndoResetAttr()
     642                 :            : {
     643         [ -  + ]:         40 : }
     644                 :            : 
     645                 :          0 : void SwUndoResetAttr::UndoImpl(::sw::UndoRedoContext & rContext)
     646                 :            : {
     647                 :            :     // reset old values
     648                 :          0 :     SwDoc & rDoc = rContext.GetDoc();
     649                 :          0 :     m_pHistory->TmpRollback( &rDoc, 0 );
     650                 :          0 :     m_pHistory->SetTmpEnd( m_pHistory->Count() );
     651                 :            : 
     652 [ #  # ][ #  # ]:          0 :     if ((RES_CONDTXTFMTCOLL == m_nFormatId) &&
                 [ #  # ]
     653                 :            :         (nSttNode == nEndNode) && (nSttCntnt == nEndCntnt))
     654                 :            :     {
     655                 :          0 :         SwTxtNode* pTNd = rDoc.GetNodes()[ nSttNode ]->GetTxtNode();
     656         [ #  # ]:          0 :         if( pTNd )
     657                 :            :         {
     658 [ #  # ][ #  # ]:          0 :             SwIndex aIdx( pTNd, nSttCntnt );
     659 [ #  # ][ #  # ]:          0 :             pTNd->DontExpandFmt( aIdx, sal_False );
     660                 :            :         }
     661                 :            :     }
     662                 :            : 
     663                 :          0 :     AddUndoRedoPaM(rContext);
     664                 :          0 : }
     665                 :            : 
     666                 :          0 : void SwUndoResetAttr::RedoImpl(::sw::UndoRedoContext & rContext)
     667                 :            : {
     668                 :          0 :     SwDoc & rDoc = rContext.GetDoc();
     669                 :          0 :     SwPaM & rPam = AddUndoRedoPaM(rContext);
     670                 :            : 
     671   [ #  #  #  #  :          0 :     switch ( m_nFormatId )
                      # ]
     672                 :            :     {
     673                 :            :     case RES_CHRFMT:
     674                 :          0 :         rDoc.RstTxtAttrs(rPam);
     675                 :          0 :         break;
     676                 :            :     case RES_TXTFMTCOLL:
     677                 :          0 :         rDoc.ResetAttrs(rPam, sal_False, m_Ids );
     678                 :          0 :         break;
     679                 :            :     case RES_CONDTXTFMTCOLL:
     680                 :          0 :         rDoc.ResetAttrs(rPam, sal_True, m_Ids );
     681                 :            : 
     682                 :          0 :         break;
     683                 :            :     case RES_TXTATR_TOXMARK:
     684                 :            :         // special treatment for TOXMarks
     685                 :            :         {
     686         [ #  # ]:          0 :             SwTOXMarks aArr;
     687 [ #  # ][ #  # ]:          0 :             SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode );
     688                 :          0 :             SwPosition aPos( aIdx, SwIndex( aIdx.GetNode().GetCntntNode(),
     689 [ #  # ][ #  # ]:          0 :                                                                 nSttCntnt ));
         [ #  # ][ #  # ]
     690                 :            : 
     691         [ #  # ]:          0 :             sal_uInt16 nCnt = rDoc.GetCurTOXMark( aPos, aArr );
     692         [ #  # ]:          0 :             if( nCnt )
     693                 :            :             {
     694         [ #  # ]:          0 :                 if( 1 < nCnt )
     695                 :            :                 {
     696                 :            :                     // search for the right one
     697         [ #  # ]:          0 :                     SwHistoryHint* pHHint = (GetHistory())[ 0 ];
     698 [ #  # ][ #  # ]:          0 :                     if( pHHint && HSTRY_SETTOXMARKHNT == pHHint->Which() )
                 [ #  # ]
     699                 :            :                     {
     700         [ #  # ]:          0 :                         while( nCnt )
     701                 :            :                         {
     702         [ #  # ]:          0 :                             if ( static_cast<SwHistorySetTOXMark*>(pHHint)
     703         [ #  # ]:          0 :                                     ->IsEqual( *aArr[ --nCnt ] ) )
     704                 :            :                             {
     705                 :          0 :                                 ++nCnt;
     706                 :          0 :                                 break;
     707                 :            :                             }
     708                 :            :                         }
     709                 :            :                     }
     710                 :            :                     else
     711                 :          0 :                         nCnt = 0;
     712                 :            :                 }
     713                 :            :                 // found one, thus delete it
     714         [ #  # ]:          0 :                 if( nCnt-- )
     715                 :            :                 {
     716         [ #  # ]:          0 :                     rDoc.DeleteTOXMark( aArr[ nCnt ] );
     717                 :            :                 }
     718 [ #  # ][ #  # ]:          0 :             }
     719                 :            :         }
     720                 :          0 :         break;
     721                 :            :     }
     722                 :          0 : }
     723                 :            : 
     724                 :          0 : void SwUndoResetAttr::RepeatImpl(::sw::RepeatContext & rContext)
     725                 :            : {
     726         [ #  # ]:          0 :     if (m_nFormatId < RES_FMT_BEGIN)
     727                 :            :     {
     728                 :          0 :         return;
     729                 :            :     }
     730                 :            : 
     731   [ #  #  #  # ]:          0 :     switch ( m_nFormatId )
     732                 :            :     {
     733                 :            :     case RES_CHRFMT:
     734                 :          0 :         rContext.GetDoc().RstTxtAttrs(rContext.GetRepeatPaM());
     735                 :          0 :         break;
     736                 :            :     case RES_TXTFMTCOLL:
     737                 :          0 :         rContext.GetDoc().ResetAttrs(rContext.GetRepeatPaM(), false, m_Ids);
     738                 :          0 :         break;
     739                 :            :     case RES_CONDTXTFMTCOLL:
     740                 :          0 :         rContext.GetDoc().ResetAttrs(rContext.GetRepeatPaM(), true, m_Ids);
     741                 :          0 :         break;
     742                 :            :     }
     743                 :            : }
     744                 :            : 
     745                 :            : 
     746                 :         10 : void SwUndoResetAttr::SetAttrs( const std::set<sal_uInt16> &rAttrs )
     747                 :            : {
     748                 :         10 :     m_Ids.clear();
     749                 :         10 :     m_Ids.insert( rAttrs.begin(), rAttrs.end() );
     750                 :         10 : }
     751                 :            : 
     752                 :        382 : SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxPoolItem& rAttr,
     753                 :            :                         const SetAttrMode nFlags )
     754                 :            :     : SwUndo( UNDO_INSATTR ), SwUndRng( rRange )
     755                 :        382 :     , m_AttrSet( rRange.GetDoc()->GetAttrPool(), rAttr.Which(), rAttr.Which() )
     756         [ +  - ]:        382 :     , m_pHistory( new SwHistory )
     757                 :            :     , m_pRedlineData( 0 )
     758                 :            :     , m_pRedlineSaveData( 0 )
     759                 :            :     , m_nNodeIndex( ULONG_MAX )
     760   [ +  -  +  - ]:       1146 :     , m_nInsertFlags( nFlags )
                 [ +  - ]
     761                 :            : {
     762         [ +  - ]:        382 :     m_AttrSet.Put( rAttr );
     763                 :        382 : }
     764                 :            : 
     765                 :       3154 : SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxItemSet& rSet,
     766                 :            :                         const SetAttrMode nFlags )
     767                 :            :     : SwUndo( UNDO_INSATTR ), SwUndRng( rRange )
     768                 :            :     , m_AttrSet( rSet )
     769         [ +  - ]:       3154 :     , m_pHistory( new SwHistory )
     770                 :            :     , m_pRedlineData( 0 )
     771                 :            :     , m_pRedlineSaveData( 0 )
     772                 :            :     , m_nNodeIndex( ULONG_MAX )
     773 [ +  - ][ +  - ]:       6308 :     , m_nInsertFlags( nFlags )
                 [ +  - ]
     774                 :            : {
     775                 :       3154 : }
     776                 :            : 
     777 [ +  - ][ +  - ]:       3534 : SwUndoAttr::~SwUndoAttr()
         [ +  - ][ +  - ]
     778                 :            : {
     779         [ -  + ]:       7068 : }
     780                 :            : 
     781                 :          0 : void SwUndoAttr::SaveRedlineData( const SwPaM& rPam, sal_Bool bIsCntnt )
     782                 :            : {
     783                 :          0 :     SwDoc* pDoc = rPam.GetDoc();
     784         [ #  # ]:          0 :     if ( pDoc->IsRedlineOn() )
     785                 :            :     {
     786                 :            :         m_pRedlineData.reset( new SwRedlineData( bIsCntnt
     787                 :            :                                     ? nsRedlineType_t::REDLINE_INSERT
     788                 :            :                                     : nsRedlineType_t::REDLINE_FORMAT,
     789 [ #  # ][ #  # ]:          0 :                                 pDoc->GetRedlineAuthor() ) );
     790                 :            :     }
     791                 :            : 
     792         [ #  # ]:          0 :     m_pRedlineSaveData.reset( new SwRedlineSaveDatas );
     793         [ #  # ]:          0 :     if ( !FillSaveDataForFmt( rPam, *m_pRedlineSaveData ))
     794                 :            :     {
     795                 :          0 :         m_pRedlineSaveData.reset(0);
     796                 :            :     }
     797                 :            : 
     798                 :          0 :     SetRedlineMode( pDoc->GetRedlineMode() );
     799         [ #  # ]:          0 :     if ( bIsCntnt )
     800                 :            :     {
     801                 :          0 :         m_nNodeIndex = rPam.GetPoint()->nNode.GetIndex();
     802                 :            :     }
     803                 :          0 : }
     804                 :            : 
     805                 :          0 : void SwUndoAttr::UndoImpl(::sw::UndoRedoContext & rContext)
     806                 :            : {
     807                 :          0 :     SwDoc *const pDoc = & rContext.GetDoc();
     808                 :            : 
     809                 :          0 :     RemoveIdx( *pDoc );
     810                 :            : 
     811         [ #  # ]:          0 :     if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) )
     812                 :            :     {
     813 [ #  # ][ #  # ]:          0 :         SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
     814         [ #  # ]:          0 :         if ( ULONG_MAX != m_nNodeIndex )
     815                 :            :         {
     816         [ #  # ]:          0 :             aPam.DeleteMark();
     817         [ #  # ]:          0 :             aPam.GetPoint()->nNode = m_nNodeIndex;
     818 [ #  # ][ #  # ]:          0 :             aPam.GetPoint()->nContent.Assign( aPam.GetCntntNode(), nSttCntnt );
     819         [ #  # ]:          0 :             aPam.SetMark();
     820         [ #  # ]:          0 :             aPam.GetPoint()->nContent++;
     821         [ #  # ]:          0 :             pDoc->DeleteRedline(aPam, false, USHRT_MAX);
     822                 :            :         }
     823                 :            :         else
     824                 :            :         {
     825                 :            :             // remove all format redlines, will be recreated if needed
     826         [ #  # ]:          0 :             SetPaM(aPam);
     827         [ #  # ]:          0 :             pDoc->DeleteRedline(aPam, false, nsRedlineType_t::REDLINE_FORMAT);
     828         [ #  # ]:          0 :             if ( m_pRedlineSaveData.get() )
     829                 :            :             {
     830         [ #  # ]:          0 :                 SetSaveData( *pDoc, *m_pRedlineSaveData );
     831                 :            :             }
     832         [ #  # ]:          0 :         }
     833                 :            :     }
     834                 :            : 
     835                 :          0 :     const bool bToLast =  (1 == m_AttrSet.Count())
     836                 :          0 :                        && (RES_TXTATR_FIELD <= *m_AttrSet.GetRanges())
     837         [ #  # ]:          0 :                        && (*m_AttrSet.GetRanges() <= RES_TXTATR_FTN);
           [ #  #  #  # ]
     838                 :            : 
     839                 :            :     // restore old values
     840                 :          0 :     m_pHistory->TmpRollback( pDoc, 0, !bToLast );
     841                 :          0 :     m_pHistory->SetTmpEnd( m_pHistory->Count() );
     842                 :            : 
     843                 :            :     // set cursor onto Undo area
     844                 :          0 :     AddUndoRedoPaM(rContext);
     845                 :          0 : }
     846                 :            : 
     847                 :          0 : void SwUndoAttr::RepeatImpl(::sw::RepeatContext & rContext)
     848                 :            : {
     849                 :            :     // RefMarks are not repeat capable
     850         [ #  # ]:          0 :     if ( SFX_ITEM_SET != m_AttrSet.GetItemState( RES_TXTATR_REFMARK, sal_False ) )
     851                 :            :     {
     852                 :          0 :         rContext.GetDoc().InsertItemSet( rContext.GetRepeatPaM(),
     853                 :          0 :                                            m_AttrSet, m_nInsertFlags );
     854                 :            :     }
     855         [ #  # ]:          0 :     else if ( 1 < m_AttrSet.Count() )
     856                 :            :     {
     857         [ #  # ]:          0 :         SfxItemSet aTmpSet( m_AttrSet );
     858         [ #  # ]:          0 :         aTmpSet.ClearItem( RES_TXTATR_REFMARK );
     859                 :          0 :         rContext.GetDoc().InsertItemSet( rContext.GetRepeatPaM(),
     860 [ #  # ][ #  # ]:          0 :                                            aTmpSet, m_nInsertFlags );
     861                 :            :     }
     862                 :          0 : }
     863                 :            : 
     864                 :          0 : void SwUndoAttr::RedoImpl(::sw::UndoRedoContext & rContext)
     865                 :            : {
     866                 :          0 :     SwDoc & rDoc = rContext.GetDoc();
     867                 :          0 :     SwPaM & rPam = AddUndoRedoPaM(rContext);
     868                 :            : 
     869         [ #  # ]:          0 :     if ( m_pRedlineData.get() &&
           [ #  #  #  # ]
     870                 :          0 :          IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) )
     871                 :            :     {
     872                 :          0 :         RedlineMode_t eOld = rDoc.GetRedlineMode();
     873                 :            :         rDoc.SetRedlineMode_intern(static_cast<RedlineMode_t>(
     874                 :          0 :                     eOld & ~nsRedlineMode_t::REDLINE_IGNORE));
     875                 :          0 :         rDoc.InsertItemSet( rPam, m_AttrSet, m_nInsertFlags );
     876                 :            : 
     877         [ #  # ]:          0 :         if ( ULONG_MAX != m_nNodeIndex )
     878                 :            :         {
     879                 :          0 :             rPam.SetMark();
     880         [ #  # ]:          0 :             if ( rPam.Move( fnMoveBackward ) )
     881                 :            :             {
     882         [ #  # ]:          0 :                 rDoc.AppendRedline( new SwRedline( *m_pRedlineData, rPam ),
     883                 :          0 :                         true);
     884                 :            :             }
     885                 :          0 :             rPam.DeleteMark();
     886                 :            :         }
     887                 :            :         else
     888                 :            :         {
     889         [ #  # ]:          0 :             rDoc.AppendRedline( new SwRedline( *m_pRedlineData, rPam ), true);
     890                 :            :         }
     891                 :            : 
     892                 :          0 :         rDoc.SetRedlineMode_intern( eOld );
     893                 :            :     }
     894                 :            :     else
     895                 :            :     {
     896                 :          0 :         rDoc.InsertItemSet( rPam, m_AttrSet, m_nInsertFlags );
     897                 :            :     }
     898                 :          0 : }
     899                 :            : 
     900                 :          0 : void SwUndoAttr::RemoveIdx( SwDoc& rDoc )
     901                 :            : {
     902         [ #  # ]:          0 :     if ( SFX_ITEM_SET != m_AttrSet.GetItemState( RES_TXTATR_FTN, sal_False ))
     903                 :          0 :         return ;
     904                 :            : 
     905                 :            :     SwHistoryHint* pHstHnt;
     906                 :          0 :     SwNodes& rNds = rDoc.GetNodes();
     907         [ #  # ]:          0 :     for ( sal_uInt16 n = 0; n < m_pHistory->Count(); ++n )
     908                 :            :     {
     909                 :          0 :         xub_StrLen nCntnt = 0;
     910                 :          0 :         sal_uLong nNode = 0;
     911                 :          0 :         pHstHnt = (*m_pHistory)[ n ];
     912      [ #  #  # ]:          0 :         switch ( pHstHnt->Which() )
     913                 :            :         {
     914                 :            :             case HSTRY_RESETTXTHNT:
     915                 :            :                 {
     916                 :            :                     SwHistoryResetTxt * pHistoryHint
     917                 :          0 :                         = static_cast<SwHistoryResetTxt*>(pHstHnt);
     918         [ #  # ]:          0 :                     if ( RES_TXTATR_FTN == pHistoryHint->GetWhich() )
     919                 :            :                     {
     920                 :          0 :                         nNode = pHistoryHint->GetNode();
     921                 :          0 :                         nCntnt = pHistoryHint->GetCntnt();
     922                 :            :                     }
     923                 :            :                 }
     924                 :          0 :                 break;
     925                 :            : 
     926                 :            :             case HSTRY_RESETATTRSET:
     927                 :            :                 {
     928                 :            :                     SwHistoryResetAttrSet * pHistoryHint
     929                 :          0 :                         = static_cast<SwHistoryResetAttrSet*>(pHstHnt);
     930                 :          0 :                     nCntnt = pHistoryHint->GetCntnt();
     931         [ #  # ]:          0 :                     if ( STRING_MAXLEN != nCntnt )
     932                 :            :                     {
     933                 :          0 :                         const std::vector<sal_uInt16>& rArr = pHistoryHint->GetArr();
     934         [ #  # ]:          0 :                         for ( sal_uInt16 i = rArr.size(); i; )
     935                 :            :                         {
     936         [ #  # ]:          0 :                             if ( RES_TXTATR_FTN == rArr[ --i ] )
     937                 :            :                             {
     938                 :          0 :                                 nNode = pHistoryHint->GetNode();
     939                 :          0 :                                 break;
     940                 :            :                             }
     941                 :            :                         }
     942                 :            :                     }
     943                 :            :                 }
     944                 :          0 :                 break;
     945                 :            : 
     946                 :            :             default:
     947                 :          0 :                 break;
     948                 :            :         }
     949                 :            : 
     950         [ #  # ]:          0 :         if( nNode )
     951                 :            :         {
     952                 :          0 :             SwTxtNode* pTxtNd = rNds[ nNode ]->GetTxtNode();
     953         [ #  # ]:          0 :             if( pTxtNd )
     954                 :            :             {
     955                 :            :                 SwTxtAttr *const pTxtHt =
     956                 :          0 :                     pTxtNd->GetTxtAttrForCharAt(nCntnt, RES_TXTATR_FTN);
     957         [ #  # ]:          0 :                 if( pTxtHt )
     958                 :            :                 {
     959                 :            :                     // ok, so get values
     960                 :          0 :                     SwTxtFtn* pFtn = static_cast<SwTxtFtn*>(pTxtHt);
     961                 :          0 :                     RemoveIdxFromSection( rDoc, pFtn->GetStartNode()->GetIndex() );
     962                 :          0 :                     return ;
     963                 :            :                 }
     964                 :            :             }
     965                 :            :         }
     966                 :            :     }
     967                 :            : }
     968                 :            : 
     969                 :          2 : SwUndoDefaultAttr::SwUndoDefaultAttr( const SfxItemSet& rSet )
     970                 :            :     : SwUndo( UNDO_SETDEFTATTR )
     971                 :            :     , m_pOldSet( 0 )
     972                 :          2 :     , m_pTabStop( 0 )
     973                 :            : {
     974                 :            :     const SfxPoolItem* pItem;
     975 [ -  + ][ +  - ]:          2 :     if( SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_TABSTOP, sal_False, &pItem ) )
     976                 :            :     {
     977                 :            :         // store separately, because it may change!
     978         [ #  # ]:          0 :         m_pTabStop.reset( static_cast<SvxTabStopItem*>(pItem->Clone()) );
     979         [ #  # ]:          0 :         if ( 1 != rSet.Count() ) // are there more attributes?
     980                 :            :         {
     981 [ #  # ][ #  # ]:          0 :             m_pOldSet.reset( new SfxItemSet( rSet ) );
     982                 :            :         }
     983                 :            :     }
     984                 :            :     else
     985                 :            :     {
     986 [ +  - ][ +  - ]:          2 :         m_pOldSet.reset( new SfxItemSet( rSet ) );
     987                 :            :     }
     988                 :          2 : }
     989                 :            : 
     990 [ +  - ][ +  - ]:          2 : SwUndoDefaultAttr::~SwUndoDefaultAttr()
     991                 :            : {
     992         [ -  + ]:          4 : }
     993                 :            : 
     994                 :          0 : void SwUndoDefaultAttr::UndoImpl(::sw::UndoRedoContext & rContext)
     995                 :            : {
     996                 :          0 :     SwDoc & rDoc = rContext.GetDoc();
     997         [ #  # ]:          0 :     if ( m_pOldSet.get() )
     998                 :            :     {
     999                 :            :         SwUndoFmtAttrHelper aTmp(
    1000         [ #  # ]:          0 :                 *const_cast<SwTxtFmtColl*>(rDoc.GetDfltTxtFmtColl()) );
    1001         [ #  # ]:          0 :         rDoc.SetDefault( *m_pOldSet );
    1002                 :          0 :         m_pOldSet.reset( 0 );
    1003         [ #  # ]:          0 :         if ( aTmp.GetUndo() )
    1004                 :            :         {
    1005                 :            :             // transfer ownership of helper object's old set
    1006                 :          0 :             m_pOldSet = aTmp.GetUndo()->m_pOldSet;
    1007         [ #  # ]:          0 :         }
    1008                 :            :     }
    1009         [ #  # ]:          0 :     if ( m_pTabStop.get() )
    1010                 :            :     {
    1011                 :            :         SvxTabStopItem* pOld = static_cast<SvxTabStopItem*>(
    1012                 :          0 :                 rDoc.GetDefault( RES_PARATR_TABSTOP ).Clone() );
    1013                 :          0 :         rDoc.SetDefault( *m_pTabStop );
    1014                 :          0 :         m_pTabStop.reset( pOld );
    1015                 :            :     }
    1016                 :          0 : }
    1017                 :            : 
    1018                 :          0 : void SwUndoDefaultAttr::RedoImpl(::sw::UndoRedoContext & rContext)
    1019                 :            : {
    1020                 :          0 :     UndoImpl(rContext);
    1021                 :          0 : }
    1022                 :            : 
    1023                 :          0 : SwUndoMoveLeftMargin::SwUndoMoveLeftMargin(
    1024                 :            :             const SwPaM& rPam, sal_Bool bFlag, sal_Bool bMod )
    1025                 :            :     : SwUndo( bFlag ? UNDO_INC_LEFTMARGIN : UNDO_DEC_LEFTMARGIN )
    1026                 :            :     , SwUndRng( rPam )
    1027         [ #  # ]:          0 :     , m_pHistory( new SwHistory )
    1028 [ #  # ][ #  # ]:          0 :     , m_bModulus( bMod )
                 [ #  # ]
    1029                 :            : {
    1030                 :          0 : }
    1031                 :            : 
    1032         [ #  # ]:          0 : SwUndoMoveLeftMargin::~SwUndoMoveLeftMargin()
    1033                 :            : {
    1034         [ #  # ]:          0 : }
    1035                 :            : 
    1036                 :          0 : void SwUndoMoveLeftMargin::UndoImpl(::sw::UndoRedoContext & rContext)
    1037                 :            : {
    1038                 :          0 :     SwDoc & rDoc = rContext.GetDoc();
    1039                 :            : 
    1040                 :            :     // restore old values
    1041                 :          0 :     m_pHistory->TmpRollback( & rDoc, 0 );
    1042                 :          0 :     m_pHistory->SetTmpEnd( m_pHistory->Count() );
    1043                 :            : 
    1044                 :          0 :     AddUndoRedoPaM(rContext);
    1045                 :          0 : }
    1046                 :            : 
    1047                 :          0 : void SwUndoMoveLeftMargin::RedoImpl(::sw::UndoRedoContext & rContext)
    1048                 :            : {
    1049                 :          0 :     SwDoc & rDoc = rContext.GetDoc();
    1050                 :          0 :     SwPaM & rPam = AddUndoRedoPaM(rContext);
    1051                 :            : 
    1052                 :            :     rDoc.MoveLeftMargin( rPam,
    1053                 :          0 :             GetId() == UNDO_INC_LEFTMARGIN, m_bModulus );
    1054                 :          0 : }
    1055                 :            : 
    1056                 :          0 : void SwUndoMoveLeftMargin::RepeatImpl(::sw::RepeatContext & rContext)
    1057                 :            : {
    1058                 :          0 :     SwDoc & rDoc = rContext.GetDoc();
    1059                 :          0 :     rDoc.MoveLeftMargin(rContext.GetRepeatPaM(), GetId() == UNDO_INC_LEFTMARGIN,
    1060                 :          0 :             m_bModulus );
    1061                 :          0 : }
    1062                 :            : 
    1063                 :          4 : SwUndoChangeFootNote::SwUndoChangeFootNote(
    1064                 :            :             const SwPaM& rRange, const String& rTxt,
    1065                 :            :             sal_uInt16 nNum, bool bIsEndNote )
    1066                 :            :     : SwUndo( UNDO_CHGFTN ), SwUndRng( rRange )
    1067                 :          0 :     , m_pHistory( new SwHistory() )
    1068                 :            :     , m_Text( rTxt )
    1069                 :            :     , m_nNumber( nNum )
    1070 [ +  - ][ +  - ]:          4 :     , m_bEndNote( bIsEndNote )
         [ +  - ][ +  - ]
    1071                 :            : {
    1072                 :          4 : }
    1073                 :            : 
    1074 [ +  - ][ +  - ]:          4 : SwUndoChangeFootNote::~SwUndoChangeFootNote()
    1075                 :            : {
    1076         [ -  + ]:          8 : }
    1077                 :            : 
    1078                 :          0 : void SwUndoChangeFootNote::UndoImpl(::sw::UndoRedoContext & rContext)
    1079                 :            : {
    1080                 :          0 :     SwDoc & rDoc = rContext.GetDoc();
    1081                 :            : 
    1082                 :          0 :     m_pHistory->TmpRollback( &rDoc, 0 );
    1083                 :          0 :     m_pHistory->SetTmpEnd( m_pHistory->Count() );
    1084                 :            : 
    1085                 :          0 :     rDoc.GetFtnIdxs().UpdateAllFtn();
    1086                 :            : 
    1087                 :          0 :     AddUndoRedoPaM(rContext);
    1088                 :          0 : }
    1089                 :            : 
    1090                 :          0 : void SwUndoChangeFootNote::RedoImpl(::sw::UndoRedoContext & rContext)
    1091                 :            : {
    1092                 :          0 :     SwDoc & rDoc( rContext.GetDoc() );
    1093                 :          0 :     SwPaM & rPaM = AddUndoRedoPaM(rContext);
    1094                 :          0 :     rDoc.SetCurFtn(rPaM, m_Text, m_nNumber, m_bEndNote);
    1095                 :          0 :     SetPaM(rPaM);
    1096                 :          0 : }
    1097                 :            : 
    1098                 :          0 : void SwUndoChangeFootNote::RepeatImpl(::sw::RepeatContext & rContext)
    1099                 :            : {
    1100                 :          0 :     SwDoc & rDoc = rContext.GetDoc();
    1101                 :          0 :     rDoc.SetCurFtn( rContext.GetRepeatPaM(), m_Text, m_nNumber, m_bEndNote );
    1102                 :          0 : }
    1103                 :            : 
    1104                 :         26 : SwUndoFootNoteInfo::SwUndoFootNoteInfo( const SwFtnInfo &rInfo )
    1105                 :            :     : SwUndo( UNDO_FTNINFO )
    1106 [ +  - ][ +  - ]:         26 :     , m_pFootNoteInfo( new SwFtnInfo( rInfo ) )
    1107                 :            : {
    1108                 :         26 : }
    1109                 :            : 
    1110         [ +  - ]:         26 : SwUndoFootNoteInfo::~SwUndoFootNoteInfo()
    1111                 :            : {
    1112         [ -  + ]:         52 : }
    1113                 :            : 
    1114                 :          0 : void SwUndoFootNoteInfo::UndoImpl(::sw::UndoRedoContext & rContext)
    1115                 :            : {
    1116                 :          0 :     SwDoc & rDoc = rContext.GetDoc();
    1117         [ #  # ]:          0 :     SwFtnInfo *pInf = new SwFtnInfo( rDoc.GetFtnInfo() );
    1118                 :          0 :     rDoc.SetFtnInfo( *m_pFootNoteInfo );
    1119                 :          0 :     m_pFootNoteInfo.reset( pInf );
    1120                 :          0 : }
    1121                 :            : 
    1122                 :          0 : void SwUndoFootNoteInfo::RedoImpl(::sw::UndoRedoContext & rContext)
    1123                 :            : {
    1124                 :          0 :     SwDoc & rDoc = rContext.GetDoc();
    1125         [ #  # ]:          0 :     SwFtnInfo *pInf = new SwFtnInfo( rDoc.GetFtnInfo() );
    1126                 :          0 :     rDoc.SetFtnInfo( *m_pFootNoteInfo );
    1127                 :          0 :     m_pFootNoteInfo.reset( pInf );
    1128                 :          0 : }
    1129                 :            : 
    1130                 :         14 : SwUndoEndNoteInfo::SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo )
    1131                 :            :     : SwUndo( UNDO_FTNINFO )
    1132 [ +  - ][ +  - ]:         14 :     , m_pEndNoteInfo( new SwEndNoteInfo( rInfo ) )
    1133                 :            : {
    1134                 :         14 : }
    1135                 :            : 
    1136         [ +  - ]:         14 : SwUndoEndNoteInfo::~SwUndoEndNoteInfo()
    1137                 :            : {
    1138         [ -  + ]:         28 : }
    1139                 :            : 
    1140                 :          0 : void SwUndoEndNoteInfo::UndoImpl(::sw::UndoRedoContext & rContext)
    1141                 :            : {
    1142                 :          0 :     SwDoc & rDoc = rContext.GetDoc();
    1143         [ #  # ]:          0 :     SwEndNoteInfo *pInf = new SwEndNoteInfo( rDoc.GetEndNoteInfo() );
    1144                 :          0 :     rDoc.SetEndNoteInfo( *m_pEndNoteInfo );
    1145                 :          0 :     m_pEndNoteInfo.reset( pInf );
    1146                 :          0 : }
    1147                 :            : 
    1148                 :          0 : void SwUndoEndNoteInfo::RedoImpl(::sw::UndoRedoContext & rContext)
    1149                 :            : {
    1150                 :          0 :     SwDoc & rDoc = rContext.GetDoc();
    1151         [ #  # ]:          0 :     SwEndNoteInfo *pInf = new SwEndNoteInfo( rDoc.GetEndNoteInfo() );
    1152                 :          0 :     rDoc.SetEndNoteInfo( *m_pEndNoteInfo );
    1153                 :          0 :     m_pEndNoteInfo.reset( pInf );
    1154                 :          0 : }
    1155                 :            : 
    1156                 :          0 : SwUndoDontExpandFmt::SwUndoDontExpandFmt( const SwPosition& rPos )
    1157                 :            :     : SwUndo( UNDO_DONTEXPAND )
    1158                 :          0 :     , m_nNodeIndex( rPos.nNode.GetIndex() )
    1159                 :          0 :     , m_nContentIndex( rPos.nContent.GetIndex() )
    1160                 :            : {
    1161                 :          0 : }
    1162                 :            : 
    1163                 :          0 : void SwUndoDontExpandFmt::UndoImpl(::sw::UndoRedoContext & rContext)
    1164                 :            : {
    1165                 :          0 :     SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
    1166                 :          0 :     SwDoc *const pDoc = & rContext.GetDoc();
    1167                 :            : 
    1168                 :          0 :     SwPosition& rPos = *pPam->GetPoint();
    1169                 :          0 :     rPos.nNode = m_nNodeIndex;
    1170         [ #  # ]:          0 :     rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(), m_nContentIndex);
    1171                 :          0 :     pDoc->DontExpandFmt( rPos, sal_False );
    1172                 :          0 : }
    1173                 :            : 
    1174                 :          0 : void SwUndoDontExpandFmt::RedoImpl(::sw::UndoRedoContext & rContext)
    1175                 :            : {
    1176                 :          0 :     SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
    1177                 :          0 :     SwDoc *const pDoc = & rContext.GetDoc();
    1178                 :            : 
    1179                 :          0 :     SwPosition& rPos = *pPam->GetPoint();
    1180                 :          0 :     rPos.nNode = m_nNodeIndex;
    1181         [ #  # ]:          0 :     rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(), m_nContentIndex);
    1182                 :          0 :     pDoc->DontExpandFmt( rPos );
    1183                 :          0 : }
    1184                 :            : 
    1185                 :          0 : void SwUndoDontExpandFmt::RepeatImpl(::sw::RepeatContext & rContext)
    1186                 :            : {
    1187                 :          0 :     SwPaM & rPam = rContext.GetRepeatPaM();
    1188                 :          0 :     SwDoc & rDoc = rContext.GetDoc();
    1189                 :          0 :     rDoc.DontExpandFmt( *rPam.GetPoint() );
    1190                 :          0 : }
    1191                 :            : 
    1192                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10