LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/undo - unspnd.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 95 0.0 %
Date: 2012-12-27 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <UndoSplitMove.hxx>
      21             : #include "doc.hxx"
      22             : #include "pam.hxx"
      23             : #include "swtable.hxx"
      24             : #include "ndtxt.hxx"
      25             : #include "swundo.hxx"
      26             : #include <editeng/brkitem.hxx>
      27             : #include <fmtpdsc.hxx>
      28             : #include <frmfmt.hxx>
      29             : #include <UndoCore.hxx>
      30             : #include "rolbck.hxx"
      31             : #include "redline.hxx"
      32             : #include "docary.hxx"
      33             : #include <IShellCursorSupplier.hxx>
      34             : 
      35             : //------------------------------------------------------------------
      36             : // SPLITNODE
      37             : 
      38           0 : SwUndoSplitNode::SwUndoSplitNode( SwDoc* pDoc, const SwPosition& rPos,
      39             :                                     sal_Bool bChkTable )
      40           0 :     : SwUndo( UNDO_SPLITNODE ), pHistory( 0 ), pRedlData( 0 ), nNode( rPos.nNode.GetIndex() ),
      41           0 :         nCntnt( rPos.nContent.GetIndex() ),
      42           0 :         bTblFlag( sal_False ), bChkTblStt( bChkTable )
      43             : {
      44           0 :     SwTxtNode *const pTxtNd = rPos.nNode.GetNode().GetTxtNode();
      45             :     OSL_ENSURE( pTxtNd, "only for TextNode" );
      46           0 :     if( pTxtNd->GetpSwpHints() )
      47             :     {
      48           0 :         pHistory = new SwHistory;
      49             :         pHistory->CopyAttr( pTxtNd->GetpSwpHints(), nNode, 0,
      50           0 :                             pTxtNd->GetTxt().Len(), false );
      51           0 :         if( !pHistory->Count() )
      52           0 :             DELETEZ( pHistory );
      53             :     }
      54             :     // consider Redline
      55           0 :     if( pDoc->IsRedlineOn() )
      56             :     {
      57           0 :         pRedlData = new SwRedlineData( nsRedlineType_t::REDLINE_INSERT, pDoc->GetRedlineAuthor() );
      58           0 :         SetRedlineMode( pDoc->GetRedlineMode() );
      59             :     }
      60             : 
      61           0 :     nParRsid = pTxtNd->GetParRsid();
      62           0 : }
      63             : 
      64           0 : SwUndoSplitNode::~SwUndoSplitNode()
      65             : {
      66           0 :     delete pHistory;
      67           0 :     delete pRedlData;
      68           0 : }
      69             : 
      70           0 : void SwUndoSplitNode::UndoImpl(::sw::UndoRedoContext & rContext)
      71             : {
      72           0 :     SwDoc *const pDoc = & rContext.GetDoc();
      73           0 :     SwPaM & rPam( rContext.GetCursorSupplier().CreateNewShellCursor() );
      74           0 :     rPam.DeleteMark();
      75           0 :     if( bTblFlag )
      76             :     {
      77             :         // than a TextNode was added directly before the current table
      78           0 :         SwNodeIndex& rIdx = rPam.GetPoint()->nNode;
      79           0 :         rIdx = nNode;
      80             :         SwTxtNode* pTNd;
      81           0 :         SwNode* pCurrNd = pDoc->GetNodes()[ nNode + 1 ];
      82           0 :         SwTableNode* pTblNd = pCurrNd->FindTableNode();
      83           0 :         if( pCurrNd->IsCntntNode() && pTblNd &&
      84           0 :             0 != ( pTNd = pDoc->GetNodes()[ pTblNd->GetIndex()-1 ]->GetTxtNode() ))
      85             :         {
      86             :             // move break attributes
      87           0 :             SwFrmFmt* pTableFmt = pTblNd->GetTable().GetFrmFmt();
      88           0 :             const SfxItemSet* pNdSet = pTNd->GetpSwAttrSet();
      89           0 :             if( pNdSet )
      90             :             {
      91             :                 const SfxPoolItem *pItem;
      92           0 :                 if( SFX_ITEM_SET == pNdSet->GetItemState( RES_PAGEDESC, sal_False,
      93           0 :                     &pItem ) )
      94           0 :                     pTableFmt->SetFmtAttr( *pItem );
      95             : 
      96           0 :                 if( SFX_ITEM_SET == pNdSet->GetItemState( RES_BREAK, sal_False,
      97           0 :                      &pItem ) )
      98           0 :                     pTableFmt->SetFmtAttr( *pItem );
      99             :             }
     100             : 
     101             :             // than delete it again
     102           0 :             SwNodeIndex aDelNd( *pTblNd, -1 );
     103           0 :             rPam.GetPoint()->nContent.Assign( (SwCntntNode*)pCurrNd, 0 );
     104           0 :             RemoveIdxRel( aDelNd.GetIndex(), *rPam.GetPoint() );
     105           0 :             pDoc->GetNodes().Delete( aDelNd );
     106             :         }
     107             :     }
     108             :     else
     109             :     {
     110           0 :         SwTxtNode * pTNd = pDoc->GetNodes()[ nNode ]->GetTxtNode();
     111           0 :         if( pTNd )
     112             :         {
     113           0 :             rPam.GetPoint()->nNode = *pTNd;
     114           0 :             rPam.GetPoint()->nContent.Assign( pTNd, pTNd->GetTxt().Len() );
     115             : 
     116           0 :             if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ))
     117             :             {
     118           0 :                 rPam.SetMark();
     119           0 :                 rPam.GetMark()->nNode++;
     120           0 :                 rPam.GetMark()->nContent.Assign( rPam.GetMark()->
     121           0 :                                     nNode.GetNode().GetCntntNode(), 0 );
     122           0 :                 pDoc->DeleteRedline( rPam, true, USHRT_MAX );
     123           0 :                 rPam.DeleteMark();
     124             :             }
     125             : 
     126           0 :             RemoveIdxRel( nNode+1, *rPam.GetPoint() );
     127             : 
     128           0 :             pTNd->JoinNext();
     129           0 :             if( pHistory )
     130             :             {
     131           0 :                 rPam.GetPoint()->nContent = 0;
     132           0 :                 rPam.SetMark();
     133           0 :                 rPam.GetPoint()->nContent = pTNd->GetTxt().Len();
     134             : 
     135           0 :                 pDoc->RstTxtAttrs( rPam, true );
     136           0 :                 pHistory->TmpRollback( pDoc, 0, false );
     137             :             }
     138             : 
     139           0 :             pDoc->UpdateParRsid( pTNd, nParRsid );
     140             :         }
     141             :     }
     142             : 
     143             :     // also set the cursor onto undo section
     144           0 :     rPam.DeleteMark();
     145           0 :     rPam.GetPoint()->nNode = nNode;
     146           0 :     rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), nCntnt );
     147           0 : }
     148             : 
     149           0 : void SwUndoSplitNode::RedoImpl(::sw::UndoRedoContext & rContext)
     150             : {
     151           0 :     SwPaM & rPam( rContext.GetCursorSupplier().CreateNewShellCursor() );
     152           0 :     rPam.GetPoint()->nNode = nNode;
     153           0 :     SwTxtNode * pTNd = rPam.GetNode()->GetTxtNode();
     154             :     OSL_ENSURE(pTNd, "SwUndoSplitNode::RedoImpl(): SwTxtNode expected");
     155           0 :     if (pTNd)
     156             :     {
     157           0 :         rPam.GetPoint()->nContent.Assign( pTNd, nCntnt );
     158             : 
     159           0 :         SwDoc* pDoc = rPam.GetDoc();
     160           0 :         pDoc->SplitNode( *rPam.GetPoint(), bChkTblStt );
     161             : 
     162           0 :         if( pHistory )
     163           0 :             pHistory->SetTmpEnd( pHistory->Count() );
     164             : 
     165           0 :         if( ( pRedlData && IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() )) ||
     166           0 :             ( !( nsRedlineMode_t::REDLINE_IGNORE & GetRedlineMode() ) &&
     167           0 :                 !pDoc->GetRedlineTbl().empty() ))
     168             :         {
     169           0 :             rPam.SetMark();
     170           0 :             if( rPam.Move( fnMoveBackward ))
     171             :             {
     172           0 :                 if( pRedlData && IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ))
     173             :                 {
     174           0 :                     RedlineMode_t eOld = pDoc->GetRedlineMode();
     175           0 :                     pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld & ~nsRedlineMode_t::REDLINE_IGNORE));
     176           0 :                     pDoc->AppendRedline( new SwRedline( *pRedlData, rPam ), true);
     177           0 :                     pDoc->SetRedlineMode_intern( eOld );
     178             :                 }
     179             :                 else
     180           0 :                     pDoc->SplitRedline( rPam );
     181           0 :                 rPam.Exchange();
     182             :             }
     183           0 :             rPam.DeleteMark();
     184             :         }
     185             :     }
     186           0 : }
     187             : 
     188           0 : void SwUndoSplitNode::RepeatImpl(::sw::RepeatContext & rContext)
     189             : {
     190           0 :     rContext.GetDoc().SplitNode(
     191           0 :         *rContext.GetRepeatPaM().GetPoint(), bChkTblStt );
     192           0 : }
     193             : 
     194             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10