LCOV - code coverage report
Current view: top level - editeng/source/outliner - outlundo.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 22 102 21.6 %
Date: 2015-06-13 12:38:46 Functions: 4 21 19.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             : 
      21             : #include <svl/intitem.hxx>
      22             : #include <editeng/editeng.hxx>
      23             : #include <editeng/editview.hxx>
      24             : #include <editeng/editdata.hxx>
      25             : #include <editeng/eerdll.hxx>
      26             : #include <editeng/lrspitem.hxx>
      27             : #include <editeng/fhgtitem.hxx>
      28             : 
      29             : #include <editeng/outliner.hxx>
      30             : #include <outlundo.hxx>
      31             : 
      32             : 
      33         328 : OutlinerUndoBase::OutlinerUndoBase( sal_uInt16 _nId, Outliner* pOutliner )
      34         328 :     : EditUndo( _nId, NULL )
      35             : {
      36             :     DBG_ASSERT( pOutliner, "Undo: Outliner?!" );
      37         328 :     mpOutliner = pOutliner;
      38         328 : }
      39             : 
      40           0 : OutlinerUndoChangeParaFlags::OutlinerUndoChangeParaFlags( Outliner* pOutliner, sal_Int32 nPara, ParaFlag nOldFlags, ParaFlag nNewFlags )
      41           0 : : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner )
      42             : {
      43           0 :     mnPara = nPara;
      44           0 :     mnOldFlags = nOldFlags;
      45           0 :     mnNewFlags = nNewFlags;
      46           0 : }
      47             : 
      48           0 : void OutlinerUndoChangeParaFlags::Undo()
      49             : {
      50           0 :     ImplChangeFlags( mnOldFlags );
      51           0 : }
      52             : 
      53           0 : void OutlinerUndoChangeParaFlags::Redo()
      54             : {
      55           0 :     ImplChangeFlags( mnNewFlags );
      56           0 : }
      57             : 
      58           0 : void OutlinerUndoChangeParaFlags::ImplChangeFlags( ParaFlag nFlags )
      59             : {
      60           0 :     Outliner* pOutliner = GetOutliner();
      61           0 :     Paragraph* pPara = pOutliner->GetParagraph( mnPara );
      62           0 :     if( pPara )
      63             :     {
      64           0 :         pOutliner->nDepthChangedHdlPrevDepth = pPara->GetDepth();
      65           0 :         pOutliner->mnDepthChangeHdlPrevFlags = pPara->nFlags;
      66           0 :         pOutliner->pHdlParagraph = pPara;
      67             : 
      68           0 :         pPara->nFlags = nFlags;
      69           0 :         pOutliner->DepthChangedHdl();
      70             :     }
      71           0 : }
      72             : 
      73           4 : OutlinerUndoChangeParaNumberingRestart::OutlinerUndoChangeParaNumberingRestart( Outliner* pOutliner, sal_Int32 nPara,
      74             :         sal_Int16 nOldNumberingStartValue, sal_Int16 nNewNumberingStartValue,
      75             :         bool  bOldParaIsNumberingRestart, bool bNewParaIsNumberingRestart )
      76           4 : : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner )
      77             : {
      78           4 :     mnPara = nPara;
      79             : 
      80           4 :     maUndoData.mnNumberingStartValue = nOldNumberingStartValue;
      81           4 :     maUndoData.mbParaIsNumberingRestart = bOldParaIsNumberingRestart;
      82           4 :     maRedoData.mnNumberingStartValue = nNewNumberingStartValue;
      83           4 :     maRedoData.mbParaIsNumberingRestart = bNewParaIsNumberingRestart;
      84           4 : }
      85             : 
      86           0 : void OutlinerUndoChangeParaNumberingRestart::Undo()
      87             : {
      88           0 :     ImplApplyData( maUndoData );
      89           0 : }
      90             : 
      91           0 : void OutlinerUndoChangeParaNumberingRestart::Redo()
      92             : {
      93           0 :     ImplApplyData( maRedoData );
      94           0 : }
      95             : 
      96           0 : void OutlinerUndoChangeParaNumberingRestart::ImplApplyData( const ParaRestartData& rData )
      97             : {
      98           0 :     Outliner* pOutliner = GetOutliner();
      99           0 :     pOutliner->SetNumberingStartValue( mnPara, rData.mnNumberingStartValue );
     100           0 :     pOutliner->SetParaIsNumberingRestart( mnPara, rData.mbParaIsNumberingRestart );
     101           0 : }
     102             : 
     103         156 : OutlinerUndoChangeDepth::OutlinerUndoChangeDepth( Outliner* pOutliner, sal_Int32 nPara, sal_Int16 nOldDepth, sal_Int16 nNewDepth )
     104         156 :     : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner )
     105             : {
     106         156 :     mnPara = nPara;
     107         156 :     mnOldDepth = nOldDepth;
     108         156 :     mnNewDepth = nNewDepth;
     109         156 : }
     110             : 
     111           0 : void OutlinerUndoChangeDepth::Undo()
     112             : {
     113           0 :     GetOutliner()->ImplInitDepth( mnPara, mnOldDepth, false );
     114           0 : }
     115             : 
     116           0 : void OutlinerUndoChangeDepth::Redo()
     117             : {
     118           0 :     GetOutliner()->ImplInitDepth( mnPara, mnNewDepth, false );
     119           0 : }
     120             : 
     121         168 : OutlinerUndoCheckPara::OutlinerUndoCheckPara( Outliner* pOutliner, sal_Int32 nPara )
     122         168 :     : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner )
     123             : {
     124         168 :     mnPara = nPara;
     125         168 : }
     126             : 
     127           0 : void OutlinerUndoCheckPara::Undo()
     128             : {
     129           0 :     Paragraph* pPara = GetOutliner()->GetParagraph( mnPara );
     130           0 :     pPara->Invalidate();
     131           0 :     GetOutliner()->ImplCalcBulletText( mnPara, false, false );
     132           0 : }
     133             : 
     134           0 : void OutlinerUndoCheckPara::Redo()
     135             : {
     136           0 :     Paragraph* pPara = GetOutliner()->GetParagraph( mnPara );
     137           0 :     pPara->Invalidate();
     138           0 :     GetOutliner()->ImplCalcBulletText( mnPara, false, false );
     139           0 : }
     140             : 
     141           0 : OLUndoExpand::OLUndoExpand(Outliner* pOut, sal_uInt16 _nId )
     142           0 :     : EditUndo( _nId, 0 )
     143             : {
     144             :     DBG_ASSERT(pOut,"Undo:No Outliner");
     145           0 :     pOutliner = pOut;
     146           0 :     nCount = 0;
     147           0 :     pParas = 0;
     148           0 : }
     149             : 
     150             : 
     151           0 : OLUndoExpand::~OLUndoExpand()
     152             : {
     153           0 :     delete pParas;
     154           0 : }
     155             : 
     156             : 
     157           0 : void OLUndoExpand::Restore( bool bUndo )
     158             : {
     159             :     DBG_ASSERT(pOutliner,"Undo:No Outliner");
     160             :     DBG_ASSERT(pOutliner->pEditEngine,"Outliner already deleted");
     161             :     Paragraph* pPara;
     162             : 
     163           0 :     bool bExpand = false;
     164           0 :     sal_uInt16 _nId = GetId();
     165           0 :     if((_nId == OLUNDO_EXPAND && !bUndo) || (_nId == OLUNDO_COLLAPSE && bUndo))
     166           0 :         bExpand = true;
     167           0 :     if( !pParas )
     168             :     {
     169           0 :         pPara = pOutliner->GetParagraph( nCount );
     170           0 :         if( bExpand )
     171           0 :             pOutliner->Expand( pPara );
     172             :         else
     173           0 :             pOutliner->Collapse( pPara );
     174             :     }
     175             :     else
     176             :     {
     177           0 :         for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ )
     178             :         {
     179           0 :             pPara = pOutliner->GetParagraph( pParas[nIdx] );
     180           0 :             if( bExpand )
     181           0 :                 pOutliner->Expand( pPara );
     182             :             else
     183           0 :                 pOutliner->Collapse( pPara );
     184             :         }
     185             :     }
     186           0 : }
     187             : 
     188           0 : void OLUndoExpand::Undo()
     189             : {
     190           0 :     Restore( true );
     191           0 : }
     192             : 
     193           0 : void OLUndoExpand::Redo()
     194             : {
     195           0 :     Restore( false );
     196           0 : }
     197             : 
     198             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11