LCOV - code coverage report
Current view: top level - sw/source/core/undo - unredln.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 16 263 6.1 %
Date: 2012-08-25 Functions: 4 32 12.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 14 374 3.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <UndoRedline.hxx>
      30                 :            : #include <hintids.hxx>
      31                 :            : #include <unotools/charclass.hxx>
      32                 :            : #include <doc.hxx>
      33                 :            : #include <swundo.hxx>
      34                 :            : #include <pam.hxx>
      35                 :            : #include <ndtxt.hxx>
      36                 :            : #include <UndoCore.hxx>
      37                 :            : #include <UndoDelete.hxx>
      38                 :            : #include <rolbck.hxx>
      39                 :            : #include <redline.hxx>
      40                 :            : #include <docary.hxx>
      41                 :            : #include <sortopt.hxx>
      42                 :            : 
      43                 :            : extern void lcl_JoinText( SwPaM& rPam, sal_Bool bJoinPrev );
      44                 :            : extern void lcl_GetJoinFlags( SwPaM& rPam, sal_Bool& rJoinTxt, sal_Bool& rJoinPrev );
      45                 :            : 
      46                 :          8 : SwUndoRedline::SwUndoRedline( SwUndoId nUsrId, const SwPaM& rRange )
      47                 :            :     : SwUndo( UNDO_REDLINE ), SwUndRng( rRange ),
      48                 :            :     pRedlData( 0 ), pRedlSaveData( 0 ), nUserId( nUsrId ),
      49         [ +  - ]:          8 :     bHiddenRedlines( sal_False )
      50                 :            : {
      51                 :            :     // consider Redline
      52                 :          8 :     SwDoc& rDoc = *rRange.GetDoc();
      53 [ -  + ][ +  - ]:          8 :     if( rDoc.IsRedlineOn() )
      54                 :            :     {
      55         [ #  # ]:          0 :         switch( nUserId )
      56                 :            :         {
      57                 :            :         case UNDO_DELETE:
      58                 :            :         case UNDO_REPLACE:
      59 [ #  # ][ #  # ]:          0 :             pRedlData = new SwRedlineData( nsRedlineType_t::REDLINE_DELETE, rDoc.GetRedlineAuthor() );
                 [ #  # ]
      60                 :          0 :             break;
      61                 :            :         default:
      62                 :            :             ;
      63                 :            :         }
      64         [ #  # ]:          0 :         SetRedlineMode( rDoc.GetRedlineMode() );
      65                 :            :     }
      66                 :            : 
      67         [ +  - ]:          8 :     sal_uLong nEndExtra = rDoc.GetNodes().GetEndOfExtras().GetIndex();
      68                 :            : 
      69 [ +  - ][ +  - ]:          8 :     pRedlSaveData = new SwRedlineSaveDatas;
      70         [ +  - ]:          8 :     if( !FillSaveData( rRange, *pRedlSaveData, sal_False,
      71         [ +  - ]:          8 :                         UNDO_REJECT_REDLINE != nUserId ))
      72 [ +  - ][ +  - ]:          8 :         delete pRedlSaveData, pRedlSaveData = 0;
      73                 :            :     else
      74                 :            :     {
      75         [ #  # ]:          0 :         bHiddenRedlines = HasHiddenRedlines( *pRedlSaveData );
      76         [ #  # ]:          0 :         if( bHiddenRedlines )           // then the NodeIndices of SwUndRng need to be corrected
      77                 :            :         {
      78         [ #  # ]:          0 :             nEndExtra -= rDoc.GetNodes().GetEndOfExtras().GetIndex();
      79                 :          0 :             nSttNode -= nEndExtra;
      80                 :          0 :             nEndNode -= nEndExtra;
      81                 :            :         }
      82                 :            :     }
      83                 :          8 : }
      84                 :            : 
      85                 :          8 : SwUndoRedline::~SwUndoRedline()
      86                 :            : {
      87 [ -  + ][ #  # ]:          8 :     delete pRedlData;
      88 [ -  + ][ #  # ]:          8 :     delete pRedlSaveData;
      89         [ -  + ]:         16 : }
      90                 :            : 
      91                 :          8 : sal_uInt16 SwUndoRedline::GetRedlSaveCount() const
      92                 :            : {
      93         [ -  + ]:          8 :     return pRedlSaveData ? pRedlSaveData->size() : 0;
      94                 :            : }
      95                 :            : 
      96                 :          0 : void SwUndoRedline::UndoImpl(::sw::UndoRedoContext & rContext)
      97                 :            : {
      98                 :          0 :     SwDoc *const pDoc = & rContext.GetDoc();
      99                 :          0 :     SwPaM & rPam( AddUndoRedoPaM(rContext) );
     100                 :            : 
     101                 :          0 :     UndoRedlineImpl(*pDoc, rPam);
     102                 :            : 
     103         [ #  # ]:          0 :     if( pRedlSaveData )
     104                 :            :     {
     105                 :          0 :         sal_uLong nEndExtra = pDoc->GetNodes().GetEndOfExtras().GetIndex();
     106                 :          0 :         SetSaveData( *pDoc, *pRedlSaveData );
     107         [ #  # ]:          0 :         if( bHiddenRedlines )
     108                 :            :         {
     109                 :          0 :             pRedlSaveData->DeleteAndDestroyAll();
     110                 :            : 
     111                 :          0 :             nEndExtra = pDoc->GetNodes().GetEndOfExtras().GetIndex() - nEndExtra;
     112                 :          0 :             nSttNode += nEndExtra;
     113                 :          0 :             nEndNode += nEndExtra;
     114                 :            :         }
     115                 :          0 :         SetPaM(rPam, true);
     116                 :            :     }
     117                 :          0 : }
     118                 :            : 
     119                 :          0 : void SwUndoRedline::RedoImpl(::sw::UndoRedoContext & rContext)
     120                 :            : {
     121                 :          0 :     SwDoc *const pDoc = & rContext.GetDoc();
     122                 :          0 :     RedlineMode_t eOld = pDoc->GetRedlineMode();
     123                 :          0 :     pDoc->SetRedlineMode_intern((RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
     124                 :            : 
     125                 :          0 :     SwPaM & rPam( AddUndoRedoPaM(rContext) );
     126 [ #  # ][ #  # ]:          0 :     if( pRedlSaveData && bHiddenRedlines )
     127                 :            :     {
     128                 :          0 :         sal_uLong nEndExtra = pDoc->GetNodes().GetEndOfExtras().GetIndex();
     129                 :            :         FillSaveData(rPam, *pRedlSaveData, sal_False,
     130                 :          0 :                         UNDO_REJECT_REDLINE != nUserId );
     131                 :            : 
     132                 :          0 :         nEndExtra -= pDoc->GetNodes().GetEndOfExtras().GetIndex();
     133                 :          0 :         nSttNode -= nEndExtra;
     134                 :          0 :         nEndNode -= nEndExtra;
     135                 :            :     }
     136                 :            : 
     137                 :          0 :     RedoRedlineImpl(*pDoc, rPam);
     138                 :            : 
     139                 :          0 :     SetPaM(rPam, true);
     140                 :          0 :     pDoc->SetRedlineMode_intern( eOld );
     141                 :          0 : }
     142                 :            : 
     143                 :          0 : void SwUndoRedline::UndoRedlineImpl(SwDoc &, SwPaM &)
     144                 :            : {
     145                 :          0 : }
     146                 :            : 
     147                 :            : // default: remove redlines
     148                 :          0 : void SwUndoRedline::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
     149                 :            : {
     150                 :          0 :     rDoc.DeleteRedline(rPam, true, USHRT_MAX);
     151                 :          0 : }
     152                 :            : 
     153                 :          0 : SwUndoRedlineDelete::SwUndoRedlineDelete( const SwPaM& rRange, SwUndoId nUsrId )
     154                 :            :     : SwUndoRedline( nUsrId ? nUsrId : UNDO_DELETE, rRange ),
     155         [ #  # ]:          0 :     bCanGroup( sal_False ), bIsDelim( sal_False ), bIsBackspace( sal_False )
     156                 :            : {
     157                 :            :     const SwTxtNode* pTNd;
     158         [ #  # ]:          0 :     if( UNDO_DELETE == nUserId &&
           [ #  #  #  # ]
         [ #  # ][ #  # ]
     159                 :            :         nSttNode == nEndNode && nSttCntnt + 1 == nEndCntnt &&
     160                 :          0 :         0 != (pTNd = rRange.GetNode()->GetTxtNode()) )
     161                 :            :     {
     162                 :          0 :         sal_Unicode cCh = pTNd->GetTxt().GetChar( nSttCntnt );
     163 [ #  # ][ #  # ]:          0 :         if( CH_TXTATR_BREAKWORD != cCh && CH_TXTATR_INWORD != cCh )
     164                 :            :         {
     165                 :          0 :             bCanGroup = sal_True;
     166         [ #  # ]:          0 :             bIsDelim = !GetAppCharClass().isLetterNumeric( pTNd->GetTxt(),
     167         [ #  # ]:          0 :                                                             nSttCntnt );
     168                 :          0 :             bIsBackspace = nSttCntnt == rRange.GetPoint()->nContent.GetIndex();
     169                 :            :         }
     170                 :            :     }
     171                 :            : 
     172                 :          0 :     bCacheComment = false;
     173                 :          0 : }
     174                 :            : 
     175                 :          0 : void SwUndoRedlineDelete::UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
     176                 :            : {
     177                 :          0 :     rDoc.DeleteRedline(rPam, true, USHRT_MAX);
     178                 :          0 : }
     179                 :            : 
     180                 :          0 : void SwUndoRedlineDelete::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
     181                 :            : {
     182         [ #  # ]:          0 :     if (rPam.GetPoint() != rPam.GetMark())
     183                 :            :     {
     184         [ #  # ]:          0 :         rDoc.AppendRedline( new SwRedline(*pRedlData, rPam), sal_False );
     185                 :            :     }
     186                 :          0 : }
     187                 :            : 
     188                 :          0 : sal_Bool SwUndoRedlineDelete::CanGrouping( const SwUndoRedlineDelete& rNext )
     189                 :            : {
     190                 :          0 :     sal_Bool bRet = sal_False;
     191 [ #  # ][ #  # ]:          0 :     if( UNDO_DELETE == nUserId && nUserId == rNext.nUserId &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     192                 :            :         bCanGroup == rNext.bCanGroup &&
     193                 :            :         bIsDelim == rNext.bIsDelim &&
     194                 :            :         bIsBackspace == rNext.bIsBackspace &&
     195                 :            :         nSttNode == nEndNode &&
     196                 :            :         rNext.nSttNode == nSttNode &&
     197                 :            :         rNext.nEndNode == nEndNode )
     198                 :            :     {
     199                 :          0 :         int bIsEnd = 0;
     200         [ #  # ]:          0 :         if( rNext.nSttCntnt == nEndCntnt )
     201                 :          0 :             bIsEnd = 1;
     202         [ #  # ]:          0 :         else if( rNext.nEndCntnt == nSttCntnt )
     203                 :          0 :             bIsEnd = -1;
     204                 :            : 
     205 [ #  # ][ #  # ]:          0 :         if( bIsEnd &&
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     206                 :          0 :             (( !pRedlSaveData && !rNext.pRedlSaveData ) ||
     207                 :            :              ( pRedlSaveData && rNext.pRedlSaveData &&
     208                 :            :                 SwUndo::CanRedlineGroup( *pRedlSaveData,
     209                 :          0 :                             *rNext.pRedlSaveData, 1 != bIsEnd )
     210                 :            :              )))
     211                 :            :         {
     212         [ #  # ]:          0 :             if( 1 == bIsEnd )
     213                 :          0 :                 nEndCntnt = rNext.nEndCntnt;
     214                 :            :             else
     215                 :          0 :                 nSttCntnt = rNext.nSttCntnt;
     216                 :          0 :             bRet = sal_True;
     217                 :            :         }
     218                 :            :     }
     219                 :          0 :     return bRet;
     220                 :            : }
     221                 :            : 
     222                 :          0 : SwUndoRedlineSort::SwUndoRedlineSort( const SwPaM& rRange,
     223                 :            :                                     const SwSortOptions& rOpt )
     224                 :            :     : SwUndoRedline( UNDO_SORT_TXT, rRange ),
     225         [ #  # ]:          0 :     pOpt( new SwSortOptions( rOpt ) ),
     226         [ #  # ]:          0 :     nSaveEndNode( nEndNode ), nOffset( 0 ), nSaveEndCntnt( nEndCntnt )
     227                 :            : {
     228                 :          0 : }
     229                 :            : 
     230                 :          0 : SwUndoRedlineSort::~SwUndoRedlineSort()
     231                 :            : {
     232 [ #  # ][ #  # ]:          0 :     delete pOpt;
     233         [ #  # ]:          0 : }
     234                 :            : 
     235                 :          0 : void SwUndoRedlineSort::UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
     236                 :            : {
     237                 :            :     // rPam contains the sorted range
     238                 :            :     // aSaveRange contains copied (i.e. original) range
     239                 :            : 
     240         [ #  # ]:          0 :     SwPosition *const pStart = rPam.Start();
     241         [ #  # ]:          0 :     SwPosition *const pEnd   = rPam.End();
     242                 :            : 
     243         [ #  # ]:          0 :     SwNodeIndex aPrevIdx( pStart->nNode, -1 );
     244                 :          0 :     sal_uLong nOffsetTemp = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex();
     245                 :            : 
     246 [ #  # ][ #  # ]:          0 :     if( 0 == ( nsRedlineMode_t::REDLINE_SHOW_DELETE & rDoc.GetRedlineMode()) )
     247                 :            :     {
     248                 :            :         // Search both Redline objects and make them visible to make the nodes
     249                 :            :         // consistent again. The 'delete' one is hidden, thus search for the
     250                 :            :         // 'insert' Redline object. The former is located directly after the latter.
     251                 :            :         sal_uInt16 nFnd = rDoc.GetRedlinePos(
     252 [ #  # ][ #  # ]:          0 :                             *rDoc.GetNodes()[ nSttNode + 1 ],
     253         [ #  # ]:          0 :                             nsRedlineType_t::REDLINE_INSERT );
     254                 :            :         OSL_ENSURE( USHRT_MAX != nFnd && nFnd+1 < (sal_uInt16)rDoc.GetRedlineTbl().size(),
     255                 :            :                     "could not find an Insert object" );
     256                 :          0 :         ++nFnd;
     257 [ #  # ][ #  # ]:          0 :         rDoc.GetRedlineTbl()[nFnd]->Show( 1 );
                 [ #  # ]
     258                 :            :     }
     259                 :            : 
     260                 :            :     {
     261         [ #  # ]:          0 :         SwPaM aTmp( *rPam.GetMark() );
     262         [ #  # ]:          0 :         aTmp.GetMark()->nContent = 0;
     263         [ #  # ]:          0 :         aTmp.SetMark();
     264         [ #  # ]:          0 :         aTmp.GetPoint()->nNode = nSaveEndNode;
     265 [ #  # ][ #  # ]:          0 :         aTmp.GetPoint()->nContent.Assign( aTmp.GetCntntNode(), nSaveEndCntnt );
     266 [ #  # ][ #  # ]:          0 :         rDoc.DeleteRedline( aTmp, true, USHRT_MAX );
     267                 :            :     }
     268                 :            : 
     269         [ #  # ]:          0 :     rDoc.DelFullPara(rPam);
     270                 :            : 
     271                 :          0 :     SwPaM *const pPam = & rPam;
     272         [ #  # ]:          0 :     pPam->DeleteMark();
     273         [ #  # ]:          0 :     pPam->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 );
     274                 :          0 :     SwCntntNode* pCNd = pPam->GetCntntNode();
     275 [ #  # ][ #  # ]:          0 :     pPam->GetPoint()->nContent.Assign(pCNd, 0 );
     276         [ #  # ]:          0 :     pPam->SetMark();
     277                 :            : 
     278         [ #  # ]:          0 :     pPam->GetPoint()->nNode += nOffsetTemp;
     279                 :          0 :     pCNd = pPam->GetCntntNode();
     280 [ #  # ][ #  # ]:          0 :     pPam->GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
                 [ #  # ]
     281                 :            : 
     282         [ #  # ]:          0 :     SetValues( *pPam );
     283                 :            : 
     284 [ #  # ][ #  # ]:          0 :     SetPaM(rPam);
     285                 :          0 : }
     286                 :            : 
     287                 :          0 : void SwUndoRedlineSort::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
     288                 :            : {
     289                 :          0 :     SwPaM* pPam = &rPam;
     290         [ #  # ]:          0 :     SwPosition* pStart = pPam->Start();
     291         [ #  # ]:          0 :     SwPosition* pEnd   = pPam->End();
     292                 :            : 
     293         [ #  # ]:          0 :     SwNodeIndex aPrevIdx( pStart->nNode, -1 );
     294                 :          0 :     sal_uLong nOffsetTemp = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex();
     295                 :          0 :     xub_StrLen nCntStt  = pStart->nContent.GetIndex();
     296                 :            : 
     297         [ #  # ]:          0 :     rDoc.SortText(rPam, *pOpt);
     298                 :            : 
     299         [ #  # ]:          0 :     pPam->DeleteMark();
     300         [ #  # ]:          0 :     pPam->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 );
     301                 :          0 :     SwCntntNode* pCNd = pPam->GetCntntNode();
     302         [ #  # ]:          0 :     xub_StrLen nLen = pCNd->Len();
     303         [ #  # ]:          0 :     if( nLen > nCntStt )
     304                 :          0 :         nLen = nCntStt;
     305 [ #  # ][ #  # ]:          0 :     pPam->GetPoint()->nContent.Assign(pCNd, nLen );
     306         [ #  # ]:          0 :     pPam->SetMark();
     307                 :            : 
     308         [ #  # ]:          0 :     pPam->GetPoint()->nNode += nOffsetTemp;
     309                 :          0 :     pCNd = pPam->GetCntntNode();
     310 [ #  # ][ #  # ]:          0 :     pPam->GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
                 [ #  # ]
     311                 :            : 
     312         [ #  # ]:          0 :     SetValues( rPam );
     313                 :            : 
     314         [ #  # ]:          0 :     SetPaM( rPam );
     315         [ #  # ]:          0 :     rPam.GetPoint()->nNode = nSaveEndNode;
     316 [ #  # ][ #  # ]:          0 :     rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), nSaveEndCntnt );
                 [ #  # ]
     317                 :          0 : }
     318                 :            : 
     319                 :          0 : void SwUndoRedlineSort::RepeatImpl(::sw::RepeatContext & rContext)
     320                 :            : {
     321                 :          0 :     rContext.GetDoc().SortText( rContext.GetRepeatPaM(), *pOpt );
     322                 :          0 : }
     323                 :            : 
     324                 :          0 : void SwUndoRedlineSort::SetSaveRange( const SwPaM& rRange )
     325                 :            : {
     326                 :          0 :     const SwPosition& rPos = *rRange.End();
     327                 :          0 :     nSaveEndNode = rPos.nNode.GetIndex();
     328                 :          0 :     nSaveEndCntnt = rPos.nContent.GetIndex();
     329                 :          0 : }
     330                 :            : 
     331                 :          0 : void SwUndoRedlineSort::SetOffset( const SwNodeIndex& rIdx )
     332                 :            : {
     333                 :          0 :     nOffset = rIdx.GetIndex() - nSttNode;
     334                 :          0 : }
     335                 :            : 
     336                 :          0 : SwUndoAcceptRedline::SwUndoAcceptRedline( const SwPaM& rRange )
     337                 :          0 :     : SwUndoRedline( UNDO_ACCEPT_REDLINE, rRange )
     338                 :            : {
     339                 :          0 : }
     340                 :            : 
     341                 :          0 : void SwUndoAcceptRedline::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
     342                 :            : {
     343                 :          0 :     rDoc.AcceptRedline(rPam, false);
     344                 :          0 : }
     345                 :            : 
     346                 :          0 : void SwUndoAcceptRedline::RepeatImpl(::sw::RepeatContext & rContext)
     347                 :            : {
     348                 :          0 :     rContext.GetDoc().AcceptRedline(rContext.GetRepeatPaM(), true);
     349                 :          0 : }
     350                 :            : 
     351                 :          0 : SwUndoRejectRedline::SwUndoRejectRedline( const SwPaM& rRange )
     352                 :          0 :     : SwUndoRedline( UNDO_REJECT_REDLINE, rRange )
     353                 :            : {
     354                 :          0 : }
     355                 :            : 
     356                 :          0 : void SwUndoRejectRedline::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
     357                 :            : {
     358                 :          0 :     rDoc.RejectRedline(rPam, false);
     359                 :          0 : }
     360                 :            : 
     361                 :          0 : void SwUndoRejectRedline::RepeatImpl(::sw::RepeatContext & rContext)
     362                 :            : {
     363                 :          0 :     rContext.GetDoc().RejectRedline(rContext.GetRepeatPaM(), true);
     364                 :          0 : }
     365                 :            : 
     366                 :          0 : SwUndoCompDoc::SwUndoCompDoc( const SwPaM& rRg, sal_Bool bIns )
     367                 :            :     : SwUndo( UNDO_COMPAREDOC ), SwUndRng( rRg ), pRedlData( 0 ),
     368         [ #  # ]:          0 :     pUnDel( 0 ), pUnDel2( 0 ), pRedlSaveData( 0 ), bInsert( bIns )
     369                 :            : {
     370                 :          0 :     SwDoc* pDoc = (SwDoc*)rRg.GetDoc();
     371 [ #  # ][ #  # ]:          0 :     if( pDoc->IsRedlineOn() )
     372                 :            :     {
     373         [ #  # ]:          0 :         RedlineType_t eTyp = bInsert ? nsRedlineType_t::REDLINE_INSERT : nsRedlineType_t::REDLINE_DELETE;
     374 [ #  # ][ #  # ]:          0 :         pRedlData = new SwRedlineData( eTyp, pDoc->GetRedlineAuthor() );
                 [ #  # ]
     375         [ #  # ]:          0 :         SetRedlineMode( pDoc->GetRedlineMode() );
     376                 :            :     }
     377                 :          0 : }
     378                 :            : 
     379                 :          0 : SwUndoCompDoc::SwUndoCompDoc( const SwRedline& rRedl )
     380                 :            :     : SwUndo( UNDO_COMPAREDOC ), SwUndRng( rRedl ), pRedlData( 0 ),
     381                 :            :     pUnDel( 0 ), pUnDel2( 0 ), pRedlSaveData( 0 ),
     382                 :            :     // for MergeDoc the corresponding inverse is needed
     383 [ #  # ][ #  # ]:          0 :     bInsert( nsRedlineType_t::REDLINE_DELETE == rRedl.GetType() )
     384                 :            : {
     385                 :          0 :     SwDoc* pDoc = (SwDoc*)rRedl.GetDoc();
     386 [ #  # ][ #  # ]:          0 :     if( pDoc->IsRedlineOn() )
     387                 :            :     {
     388 [ #  # ][ #  # ]:          0 :         pRedlData = new SwRedlineData( rRedl.GetRedlineData() );
                 [ #  # ]
     389         [ #  # ]:          0 :         SetRedlineMode( pDoc->GetRedlineMode() );
     390                 :            :     }
     391                 :            : 
     392 [ #  # ][ #  # ]:          0 :     pRedlSaveData = new SwRedlineSaveDatas;
     393 [ #  # ][ #  # ]:          0 :     if( !FillSaveData( rRedl, *pRedlSaveData, sal_False, sal_True ))
     394 [ #  # ][ #  # ]:          0 :         delete pRedlSaveData, pRedlSaveData = 0;
     395                 :          0 : }
     396                 :            : 
     397                 :          0 : SwUndoCompDoc::~SwUndoCompDoc()
     398                 :            : {
     399 [ #  # ][ #  # ]:          0 :     delete pRedlData;
     400 [ #  # ][ #  # ]:          0 :     delete pUnDel;
     401 [ #  # ][ #  # ]:          0 :     delete pUnDel2;
     402 [ #  # ][ #  # ]:          0 :     delete pRedlSaveData;
     403         [ #  # ]:          0 : }
     404                 :            : 
     405                 :          0 : void SwUndoCompDoc::UndoImpl(::sw::UndoRedoContext & rContext)
     406                 :            : {
     407                 :          0 :     SwDoc *const pDoc = & rContext.GetDoc();
     408                 :          0 :     SwPaM *const pPam( & AddUndoRedoPaM(rContext) );
     409                 :            : 
     410         [ #  # ]:          0 :     if( !bInsert )
     411                 :            :     {
     412                 :            :         // delete Redlines
     413         [ #  # ]:          0 :         RedlineMode_t eOld = pDoc->GetRedlineMode();
     414         [ #  # ]:          0 :         pDoc->SetRedlineMode_intern((RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON));
     415                 :            : 
     416         [ #  # ]:          0 :         pDoc->DeleteRedline( *pPam, true, USHRT_MAX );
     417                 :            : 
     418         [ #  # ]:          0 :         pDoc->SetRedlineMode_intern( eOld );
     419                 :            : 
     420                 :            :         // per definition Point is end (in SwUndRng!)
     421                 :          0 :         SwCntntNode* pCSttNd = pPam->GetCntntNode( sal_False );
     422                 :          0 :         SwCntntNode* pCEndNd = pPam->GetCntntNode( sal_True );
     423                 :            : 
     424                 :            :         // if start- and end-content is zero, then the doc-compare moves
     425                 :            :         // complete nodes into the current doc. And then the selection
     426                 :            :         // must be from end to start, so the delete join into the right
     427                 :            :         // direction.
     428 [ #  # ][ #  # ]:          0 :         if( !nSttCntnt && !nEndCntnt )
     429                 :          0 :             pPam->Exchange();
     430                 :            : 
     431                 :            :         sal_Bool bJoinTxt, bJoinPrev;
     432         [ #  # ]:          0 :         ::lcl_GetJoinFlags( *pPam, bJoinTxt, bJoinPrev );
     433                 :            : 
     434 [ #  # ][ #  # ]:          0 :         pUnDel = new SwUndoDelete( *pPam, sal_False );
     435                 :            : 
     436         [ #  # ]:          0 :         if( bJoinTxt )
     437         [ #  # ]:          0 :             ::lcl_JoinText( *pPam, bJoinPrev );
     438                 :            : 
     439 [ #  # ][ #  # ]:          0 :         if( pCSttNd && !pCEndNd)
     440                 :            :         {
     441                 :            :             // #112139# Do not step behind the end of content.
     442                 :          0 :             SwNode * pTmp = pPam->GetNode(sal_True);
     443         [ #  # ]:          0 :             if (pTmp)
     444                 :            :             {
     445 [ #  # ][ #  # ]:          0 :                 SwNode * pEnd = pDoc->GetNodes().DocumentSectionEndNode(pTmp);
     446                 :            : 
     447         [ #  # ]:          0 :                 if (pTmp != pEnd)
     448                 :            :                 {
     449         [ #  # ]:          0 :                     pPam->SetMark();
     450         [ #  # ]:          0 :                     pPam->GetPoint()->nNode++;
     451         [ #  # ]:          0 :                     pPam->GetBound( sal_True ).nContent.Assign( 0, 0 );
     452         [ #  # ]:          0 :                     pPam->GetBound( sal_False ).nContent.Assign( 0, 0 );
     453 [ #  # ][ #  # ]:          0 :                     pUnDel2 = new SwUndoDelete( *pPam, sal_True );
     454                 :            :                 }
     455                 :            :             }
     456                 :            :         }
     457         [ #  # ]:          0 :         pPam->DeleteMark();
     458                 :            :     }
     459                 :            :     else
     460                 :            :     {
     461         [ #  # ]:          0 :         if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ))
     462                 :            :         {
     463                 :          0 :             pDoc->DeleteRedline( *pPam, true, USHRT_MAX );
     464                 :            : 
     465         [ #  # ]:          0 :             if( pRedlSaveData )
     466                 :          0 :                 SetSaveData( *pDoc, *pRedlSaveData );
     467                 :            :         }
     468                 :          0 :         SetPaM(*pPam, true);
     469                 :            :     }
     470                 :          0 : }
     471                 :            : 
     472                 :          0 : void SwUndoCompDoc::RedoImpl(::sw::UndoRedoContext & rContext)
     473                 :            : {
     474                 :          0 :     SwDoc *const pDoc = & rContext.GetDoc();
     475                 :          0 :     SwPaM *const pPam( & AddUndoRedoPaM(rContext) );
     476                 :            : 
     477         [ #  # ]:          0 :     if( bInsert )
     478                 :            :     {
     479 [ #  # ][ #  # ]:          0 :         if( pRedlData && IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ))
                 [ #  # ]
     480                 :            :         {
     481         [ #  # ]:          0 :             SwRedline* pTmp = new SwRedline( *pRedlData, *pPam );
     482                 :          0 :             ((SwRedlineTbl&)pDoc->GetRedlineTbl()).Insert( pTmp );
     483                 :          0 :             pTmp->InvalidateRange();
     484                 :            :         }
     485   [ #  #  #  # ]:          0 :         else if( !( nsRedlineMode_t::REDLINE_IGNORE & GetRedlineMode() ) &&
                 [ #  # ]
     486                 :          0 :                 !pDoc->GetRedlineTbl().empty() )
     487                 :          0 :             pDoc->SplitRedline( *pPam );
     488                 :            :     }
     489                 :            :     else
     490                 :            :     {
     491         [ #  # ]:          0 :         if( pUnDel2 )
     492                 :            :         {
     493                 :          0 :             pUnDel2->UndoImpl(rContext);
     494         [ #  # ]:          0 :             delete pUnDel2, pUnDel2 = 0;
     495                 :            :         }
     496                 :          0 :         pUnDel->UndoImpl(rContext);
     497         [ #  # ]:          0 :         delete pUnDel, pUnDel = 0;
     498                 :            : 
     499                 :          0 :         SetPaM( *pPam );
     500                 :            : 
     501         [ #  # ]:          0 :         SwRedline* pTmp = new SwRedline( *pRedlData, *pPam );
     502                 :          0 :         ((SwRedlineTbl&)pDoc->GetRedlineTbl()).Insert( pTmp );
     503         [ #  # ]:          0 :         if (pTmp) // #i19649#
     504                 :          0 :             pTmp->InvalidateRange();
     505                 :            :     }
     506                 :            : 
     507                 :          0 :     SetPaM(*pPam, true);
     508                 :          0 : }
     509                 :            : 
     510                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10