LCOV - code coverage report
Current view: top level - sw/source/core/undo - unspnd.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 13 95 13.7 %
Date: 2012-08-25 Functions: 3 6 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 120 5.8 %

           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 <UndoSplitMove.hxx>
      30                 :            : #include "doc.hxx"
      31                 :            : #include "pam.hxx"
      32                 :            : #include "swtable.hxx"
      33                 :            : #include "ndtxt.hxx"
      34                 :            : #include "swundo.hxx"
      35                 :            : #include <editeng/brkitem.hxx>
      36                 :            : #include <fmtpdsc.hxx>
      37                 :            : #include <frmfmt.hxx>
      38                 :            : #include <UndoCore.hxx>
      39                 :            : #include "rolbck.hxx"
      40                 :            : #include "redline.hxx"
      41                 :            : #include "docary.hxx"
      42                 :            : #include <IShellCursorSupplier.hxx>
      43                 :            : 
      44                 :            : //------------------------------------------------------------------
      45                 :            : // SPLITNODE
      46                 :            : 
      47                 :        440 : SwUndoSplitNode::SwUndoSplitNode( SwDoc* pDoc, const SwPosition& rPos,
      48                 :            :                                     sal_Bool bChkTable )
      49                 :        440 :     : SwUndo( UNDO_SPLITNODE ), pHistory( 0 ), pRedlData( 0 ), nNode( rPos.nNode.GetIndex() ),
      50                 :        440 :         nCntnt( rPos.nContent.GetIndex() ),
      51                 :        440 :         bTblFlag( sal_False ), bChkTblStt( bChkTable )
      52                 :            : {
      53                 :        440 :     SwTxtNode *const pTxtNd = rPos.nNode.GetNode().GetTxtNode();
      54                 :            :     OSL_ENSURE( pTxtNd, "only for TextNode" );
      55         [ -  + ]:        440 :     if( pTxtNd->GetpSwpHints() )
      56                 :            :     {
      57 [ #  # ][ #  # ]:          0 :         pHistory = new SwHistory;
      58                 :            :         pHistory->CopyAttr( pTxtNd->GetpSwpHints(), nNode, 0,
      59         [ #  # ]:          0 :                             pTxtNd->GetTxt().Len(), false );
      60         [ #  # ]:          0 :         if( !pHistory->Count() )
      61 [ #  # ][ #  # ]:          0 :             DELETEZ( pHistory );
      62                 :            :     }
      63                 :            :     // consider Redline
      64 [ +  - ][ -  + ]:        440 :     if( pDoc->IsRedlineOn() )
      65                 :            :     {
      66 [ #  # ][ #  # ]:          0 :         pRedlData = new SwRedlineData( nsRedlineType_t::REDLINE_INSERT, pDoc->GetRedlineAuthor() );
                 [ #  # ]
      67         [ #  # ]:          0 :         SetRedlineMode( pDoc->GetRedlineMode() );
      68                 :            :     }
      69                 :            : 
      70         [ +  - ]:        440 :     nParRsid = pTxtNd->GetParRsid();
      71                 :        440 : }
      72                 :            : 
      73                 :        438 : SwUndoSplitNode::~SwUndoSplitNode()
      74                 :            : {
      75 [ -  + ][ #  # ]:        438 :     delete pHistory;
      76 [ -  + ][ #  # ]:        438 :     delete pRedlData;
      77         [ -  + ]:        876 : }
      78                 :            : 
      79                 :          0 : void SwUndoSplitNode::UndoImpl(::sw::UndoRedoContext & rContext)
      80                 :            : {
      81                 :          0 :     SwDoc *const pDoc = & rContext.GetDoc();
      82                 :          0 :     SwPaM & rPam( rContext.GetCursorSupplier().CreateNewShellCursor() );
      83                 :          0 :     rPam.DeleteMark();
      84         [ #  # ]:          0 :     if( bTblFlag )
      85                 :            :     {
      86                 :            :         // than a TextNode was added directly before the current table
      87                 :          0 :         SwNodeIndex& rIdx = rPam.GetPoint()->nNode;
      88                 :          0 :         rIdx = nNode;
      89                 :            :         SwTxtNode* pTNd;
      90                 :          0 :         SwNode* pCurrNd = pDoc->GetNodes()[ nNode + 1 ];
      91                 :          0 :         SwTableNode* pTblNd = pCurrNd->FindTableNode();
      92   [ #  #  #  # ]:          0 :         if( pCurrNd->IsCntntNode() && pTblNd &&
         [ #  # ][ #  # ]
      93                 :          0 :             0 != ( pTNd = pDoc->GetNodes()[ pTblNd->GetIndex()-1 ]->GetTxtNode() ))
      94                 :            :         {
      95                 :            :             // move break attributes
      96                 :          0 :             SwFrmFmt* pTableFmt = pTblNd->GetTable().GetFrmFmt();
      97         [ #  # ]:          0 :             const SfxItemSet* pNdSet = pTNd->GetpSwAttrSet();
      98         [ #  # ]:          0 :             if( pNdSet )
      99                 :            :             {
     100                 :            :                 const SfxPoolItem *pItem;
     101         [ #  # ]:          0 :                 if( SFX_ITEM_SET == pNdSet->GetItemState( RES_PAGEDESC, sal_False,
     102         [ #  # ]:          0 :                     &pItem ) )
     103         [ #  # ]:          0 :                     pTableFmt->SetFmtAttr( *pItem );
     104                 :            : 
     105         [ #  # ]:          0 :                 if( SFX_ITEM_SET == pNdSet->GetItemState( RES_BREAK, sal_False,
     106         [ #  # ]:          0 :                      &pItem ) )
     107         [ #  # ]:          0 :                     pTableFmt->SetFmtAttr( *pItem );
     108                 :            :             }
     109                 :            : 
     110                 :            :             // than delete it again
     111         [ #  # ]:          0 :             SwNodeIndex aDelNd( *pTblNd, -1 );
     112 [ #  # ][ #  # ]:          0 :             rPam.GetPoint()->nContent.Assign( (SwCntntNode*)pCurrNd, 0 );
         [ #  # ][ #  # ]
     113         [ #  # ]:          0 :             RemoveIdxRel( aDelNd.GetIndex(), *rPam.GetPoint() );
     114 [ #  # ][ #  # ]:          0 :             pDoc->GetNodes().Delete( aDelNd );
                 [ #  # ]
     115                 :            :         }
     116                 :            :     }
     117                 :            :     else
     118                 :            :     {
     119                 :          0 :         SwTxtNode * pTNd = pDoc->GetNodes()[ nNode ]->GetTxtNode();
     120         [ #  # ]:          0 :         if( pTNd )
     121                 :            :         {
     122                 :          0 :             rPam.GetPoint()->nNode = *pTNd;
     123         [ #  # ]:          0 :             rPam.GetPoint()->nContent.Assign( pTNd, pTNd->GetTxt().Len() );
     124                 :            : 
     125         [ #  # ]:          0 :             if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ))
     126                 :            :             {
     127                 :          0 :                 rPam.SetMark();
     128                 :          0 :                 rPam.GetMark()->nNode++;
     129                 :          0 :                 rPam.GetMark()->nContent.Assign( rPam.GetMark()->
     130         [ #  # ]:          0 :                                     nNode.GetNode().GetCntntNode(), 0 );
     131                 :          0 :                 pDoc->DeleteRedline( rPam, true, USHRT_MAX );
     132                 :          0 :                 rPam.DeleteMark();
     133                 :            :             }
     134                 :            : 
     135                 :          0 :             RemoveIdxRel( nNode+1, *rPam.GetPoint() );
     136                 :            : 
     137                 :          0 :             pTNd->JoinNext();
     138         [ #  # ]:          0 :             if( pHistory )
     139                 :            :             {
     140                 :          0 :                 rPam.GetPoint()->nContent = 0;
     141                 :          0 :                 rPam.SetMark();
     142                 :          0 :                 rPam.GetPoint()->nContent = pTNd->GetTxt().Len();
     143                 :            : 
     144                 :          0 :                 pDoc->RstTxtAttrs( rPam, sal_True );
     145                 :          0 :                 pHistory->TmpRollback( pDoc, 0, false );
     146                 :            :             }
     147                 :            : 
     148                 :          0 :             pDoc->UpdateParRsid( pTNd, nParRsid );
     149                 :            :         }
     150                 :            :     }
     151                 :            : 
     152                 :            :     // also set the cursor onto undo section
     153                 :          0 :     rPam.DeleteMark();
     154                 :          0 :     rPam.GetPoint()->nNode = nNode;
     155         [ #  # ]:          0 :     rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), nCntnt );
     156                 :          0 : }
     157                 :            : 
     158                 :          0 : void SwUndoSplitNode::RedoImpl(::sw::UndoRedoContext & rContext)
     159                 :            : {
     160                 :          0 :     SwPaM & rPam( rContext.GetCursorSupplier().CreateNewShellCursor() );
     161                 :          0 :     rPam.GetPoint()->nNode = nNode;
     162                 :          0 :     SwTxtNode * pTNd = rPam.GetNode()->GetTxtNode();
     163                 :            :     OSL_ENSURE(pTNd, "SwUndoSplitNode::RedoImpl(): SwTxtNode expected");
     164         [ #  # ]:          0 :     if (pTNd)
     165                 :            :     {
     166         [ #  # ]:          0 :         rPam.GetPoint()->nContent.Assign( pTNd, nCntnt );
     167                 :            : 
     168                 :          0 :         SwDoc* pDoc = rPam.GetDoc();
     169                 :          0 :         pDoc->SplitNode( *rPam.GetPoint(), bChkTblStt );
     170                 :            : 
     171         [ #  # ]:          0 :         if( pHistory )
     172                 :          0 :             pHistory->SetTmpEnd( pHistory->Count() );
     173                 :            : 
     174 [ #  # ][ #  #  :          0 :         if( ( pRedlData && IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() )) ||
             #  #  #  # ]
                 [ #  # ]
     175                 :          0 :             ( !( nsRedlineMode_t::REDLINE_IGNORE & GetRedlineMode() ) &&
     176                 :          0 :                 !pDoc->GetRedlineTbl().empty() ))
     177                 :            :         {
     178                 :          0 :             rPam.SetMark();
     179         [ #  # ]:          0 :             if( rPam.Move( fnMoveBackward ))
     180                 :            :             {
     181 [ #  # ][ #  # ]:          0 :                 if( pRedlData && IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ))
                 [ #  # ]
     182                 :            :                 {
     183                 :          0 :                     RedlineMode_t eOld = pDoc->GetRedlineMode();
     184                 :          0 :                     pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld & ~nsRedlineMode_t::REDLINE_IGNORE));
     185         [ #  # ]:          0 :                     pDoc->AppendRedline( new SwRedline( *pRedlData, rPam ), true);
     186                 :          0 :                     pDoc->SetRedlineMode_intern( eOld );
     187                 :            :                 }
     188                 :            :                 else
     189                 :          0 :                     pDoc->SplitRedline( rPam );
     190                 :          0 :                 rPam.Exchange();
     191                 :            :             }
     192                 :          0 :             rPam.DeleteMark();
     193                 :            :         }
     194                 :            :     }
     195                 :          0 : }
     196                 :            : 
     197                 :          0 : void SwUndoSplitNode::RepeatImpl(::sw::RepeatContext & rContext)
     198                 :            : {
     199                 :          0 :     rContext.GetDoc().SplitNode(
     200                 :          0 :         *rContext.GetRepeatPaM().GetPoint(), bChkTblStt );
     201                 :          0 : }
     202                 :            : 
     203                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10